@sylix/coworker 2.0.16 → 2.0.18
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.
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +307 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/commands/slash/core.d.ts.map +1 -1
- package/dist/commands/slash/core.js +9 -0
- package/dist/commands/slash/core.js.map +1 -1
- package/dist/core/CoWorkerAgent.d.ts +6 -1
- package/dist/core/CoWorkerAgent.d.ts.map +1 -1
- package/dist/core/CoWorkerAgent.js +54 -13
- package/dist/core/CoWorkerAgent.js.map +1 -1
- package/dist/coworker/ui/REPL.d.ts +36 -0
- package/dist/coworker/ui/REPL.d.ts.map +1 -0
- package/dist/coworker/ui/REPL.js +469 -0
- package/dist/coworker/ui/REPL.js.map +1 -0
- package/dist/coworker/ui/hooks/useInputBuffer.d.ts +16 -0
- package/dist/coworker/ui/hooks/useInputBuffer.d.ts.map +1 -0
- package/dist/coworker/ui/hooks/useInputBuffer.js +55 -0
- package/dist/coworker/ui/hooks/useInputBuffer.js.map +1 -0
- package/dist/coworker/ui/hooks/useKeyboardShortcuts.d.ts +17 -0
- package/dist/coworker/ui/hooks/useKeyboardShortcuts.d.ts.map +1 -0
- package/dist/coworker/ui/hooks/useKeyboardShortcuts.js +42 -0
- package/dist/coworker/ui/hooks/useKeyboardShortcuts.js.map +1 -0
- package/dist/coworker/ui/hooks/useMessageScroll.d.ts +11 -0
- package/dist/coworker/ui/hooks/useMessageScroll.d.ts.map +1 -0
- package/dist/coworker/ui/hooks/useMessageScroll.js +31 -0
- package/dist/coworker/ui/hooks/useMessageScroll.js.map +1 -0
- package/dist/coworker/ui/hooks/useStreamHandler.d.ts +22 -0
- package/dist/coworker/ui/hooks/useStreamHandler.d.ts.map +1 -0
- package/dist/coworker/ui/hooks/useStreamHandler.js +87 -0
- package/dist/coworker/ui/hooks/useStreamHandler.js.map +1 -0
- package/dist/coworker/ui/index.d.ts +11 -0
- package/dist/coworker/ui/index.d.ts.map +1 -0
- package/dist/coworker/ui/index.js +31 -0
- package/dist/coworker/ui/index.js.map +1 -0
- package/dist/coworker/ui/store/actions.d.ts +46 -0
- package/dist/coworker/ui/store/actions.d.ts.map +1 -0
- package/dist/coworker/ui/store/actions.js +207 -0
- package/dist/coworker/ui/store/actions.js.map +1 -0
- package/dist/coworker/ui/store/messageStore.d.ts +25 -0
- package/dist/coworker/ui/store/messageStore.d.ts.map +1 -0
- package/dist/coworker/ui/store/messageStore.js +103 -0
- package/dist/coworker/ui/store/messageStore.js.map +1 -0
- package/dist/coworker/ui/store/types.d.ts +62 -0
- package/dist/coworker/ui/store/types.d.ts.map +1 -0
- package/dist/coworker/ui/store/types.js +3 -0
- package/dist/coworker/ui/store/types.js.map +1 -0
- package/dist/coworker/ui/utils/formatOutput.d.ts +12 -0
- package/dist/coworker/ui/utils/formatOutput.d.ts.map +1 -0
- package/dist/coworker/ui/utils/formatOutput.js +92 -0
- package/dist/coworker/ui/utils/formatOutput.js.map +1 -0
- package/dist/coworker/ui/utils/parseThinking.d.ts +13 -0
- package/dist/coworker/ui/utils/parseThinking.d.ts.map +1 -0
- package/dist/coworker/ui/utils/parseThinking.js +66 -0
- package/dist/coworker/ui/utils/parseThinking.js.map +1 -0
- package/dist/session/SessionManager.d.ts +1 -0
- package/dist/session/SessionManager.d.ts.map +1 -1
- package/dist/session/SessionManager.js +2 -1
- package/dist/session/SessionManager.js.map +1 -1
- package/dist/tools/NativeTools.js +2 -2
- package/dist/tools/NativeTools.js.map +1 -1
- package/dist/tools/WebFetchTool.js +2 -2
- package/dist/tools/WebFetchTool.js.map +1 -1
- package/dist/types/message.d.ts +62 -0
- package/dist/types/message.d.ts.map +1 -0
- package/dist/types/message.js +3 -0
- package/dist/types/message.js.map +1 -0
- package/dist/utils/PromptCache.js +1 -1
- package/dist/utils/PromptCache.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,469 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.StreamHandler = void 0;
|
|
37
|
+
exports.createStreamHandler = createStreamHandler;
|
|
38
|
+
exports.startREPL = startREPL;
|
|
39
|
+
const output_1 = require("../../utils/output");
|
|
40
|
+
const character_1 = require("../../utils/character");
|
|
41
|
+
const readline = __importStar(require("readline"));
|
|
42
|
+
const fs = __importStar(require("fs"));
|
|
43
|
+
const path = __importStar(require("path"));
|
|
44
|
+
const os = __importStar(require("os"));
|
|
45
|
+
const THINKING_SYMBOL = '∴';
|
|
46
|
+
const FOLD_SYMBOL = '⎿';
|
|
47
|
+
const SPINNER_FRAMES = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
|
|
48
|
+
const DONE_SYMBOL = '✓';
|
|
49
|
+
const BLOCKED_SYMBOL = '🔒';
|
|
50
|
+
const ERROR_SYMBOL = '❌';
|
|
51
|
+
const TOOL_COLORS = {
|
|
52
|
+
Bash: output_1.theme.ai,
|
|
53
|
+
executeBash: output_1.theme.ai,
|
|
54
|
+
run_terminal_command: output_1.theme.ai,
|
|
55
|
+
Read: output_1.theme.accent,
|
|
56
|
+
executeRead: output_1.theme.accent,
|
|
57
|
+
Write: output_1.theme.success,
|
|
58
|
+
executeWrite: output_1.theme.success,
|
|
59
|
+
Edit: output_1.theme.success,
|
|
60
|
+
executeEdit: output_1.theme.success,
|
|
61
|
+
MultiEdit: output_1.theme.success,
|
|
62
|
+
executeMultiEdit: output_1.theme.success,
|
|
63
|
+
Grep: output_1.theme.warning,
|
|
64
|
+
executeGrep: output_1.theme.warning,
|
|
65
|
+
Glob: output_1.theme.warning,
|
|
66
|
+
executeGlob: output_1.theme.warning,
|
|
67
|
+
WebSearch: output_1.theme.purple,
|
|
68
|
+
executeWebSearch: output_1.theme.purple,
|
|
69
|
+
WebFetch: output_1.theme.purple,
|
|
70
|
+
executeWebFetch: output_1.theme.purple,
|
|
71
|
+
TaskCreate: output_1.theme.success,
|
|
72
|
+
TaskGet: output_1.theme.accent,
|
|
73
|
+
TaskUpdate: output_1.theme.warning,
|
|
74
|
+
TaskList: output_1.theme.dim,
|
|
75
|
+
TodoWrite: output_1.theme.success,
|
|
76
|
+
todoWrite: output_1.theme.success,
|
|
77
|
+
todoRead: output_1.theme.dim,
|
|
78
|
+
LSP_Definition: output_1.theme.ai,
|
|
79
|
+
LSP_References: output_1.theme.ai,
|
|
80
|
+
executeOpenBrowser: output_1.theme.purple,
|
|
81
|
+
executeBrowser: output_1.theme.purple,
|
|
82
|
+
};
|
|
83
|
+
function getToolColor(toolName) {
|
|
84
|
+
return TOOL_COLORS[toolName] || output_1.theme.white;
|
|
85
|
+
}
|
|
86
|
+
function formatToolName(toolName) {
|
|
87
|
+
return getToolColor(toolName)(toolName);
|
|
88
|
+
}
|
|
89
|
+
function formatToolArgs(args) {
|
|
90
|
+
const keys = ['path', 'dir', 'filePath', 'pattern', 'command', 'query', 'url', 'searchQuery', 'filePath'];
|
|
91
|
+
for (const key of keys) {
|
|
92
|
+
if (args[key])
|
|
93
|
+
return output_1.theme.dim(String(args[key]));
|
|
94
|
+
}
|
|
95
|
+
const vals = Object.values(args).filter(v => v !== undefined && v !== null && typeof v !== 'object');
|
|
96
|
+
if (vals.length > 0)
|
|
97
|
+
return output_1.theme.dim(vals.slice(0, 2).join(' '));
|
|
98
|
+
return '';
|
|
99
|
+
}
|
|
100
|
+
function truncateWithExpand(text, maxLen = 200) {
|
|
101
|
+
if (text.length <= maxLen)
|
|
102
|
+
return text;
|
|
103
|
+
return text.substring(0, maxLen) + '...';
|
|
104
|
+
}
|
|
105
|
+
function escapeHtml(text) {
|
|
106
|
+
return text.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
|
107
|
+
}
|
|
108
|
+
class StreamHandler {
|
|
109
|
+
constructor(agent, options) {
|
|
110
|
+
this.buffer = '';
|
|
111
|
+
this.inThinking = false;
|
|
112
|
+
this.thinkingBuffer = '';
|
|
113
|
+
this.currentTool = null;
|
|
114
|
+
this.spinnerIndex = 0;
|
|
115
|
+
this.spinnerInterval = null;
|
|
116
|
+
this.expandedTools = new Set();
|
|
117
|
+
this.agent = agent;
|
|
118
|
+
this.options = options;
|
|
119
|
+
}
|
|
120
|
+
startSpinner() {
|
|
121
|
+
this.spinnerIndex = 0;
|
|
122
|
+
this.spinnerInterval = setInterval(() => {
|
|
123
|
+
this.spinnerIndex = (this.spinnerIndex + 1) % SPINNER_FRAMES.length;
|
|
124
|
+
if (this.currentTool && this.currentTool.status === 'running') {
|
|
125
|
+
process.stdout.write(`\r ${output_1.theme.dim(SPINNER_FRAMES[this.spinnerIndex])} ${formatToolName(this.currentTool.name)} ${formatToolArgs(this.currentTool.args)}\r`);
|
|
126
|
+
}
|
|
127
|
+
}, 80);
|
|
128
|
+
}
|
|
129
|
+
stopSpinner() {
|
|
130
|
+
if (this.spinnerInterval) {
|
|
131
|
+
clearInterval(this.spinnerInterval);
|
|
132
|
+
this.spinnerInterval = null;
|
|
133
|
+
}
|
|
134
|
+
process.stdout.write('\r' + '\x1b[2K\r');
|
|
135
|
+
}
|
|
136
|
+
async *processStream(prompt) {
|
|
137
|
+
this.buffer = '';
|
|
138
|
+
this.inThinking = false;
|
|
139
|
+
this.thinkingBuffer = '';
|
|
140
|
+
this.currentTool = null;
|
|
141
|
+
this.expandedTools.clear();
|
|
142
|
+
for await (const chunk of this.agent.chat(prompt)) {
|
|
143
|
+
this.buffer += chunk;
|
|
144
|
+
const lines = this.buffer.split('\n');
|
|
145
|
+
this.buffer = lines.pop() || '';
|
|
146
|
+
for (const line of lines) {
|
|
147
|
+
const trimmed = line.trim();
|
|
148
|
+
if (!trimmed)
|
|
149
|
+
continue;
|
|
150
|
+
if (trimmed.startsWith('[TOOL]')) {
|
|
151
|
+
const toolMatch = trimmed.match(/\[TOOL\]\s+(\w+)/);
|
|
152
|
+
const pathMatch = trimmed.match(/\[TOOL\]\s+\w+\s*:\s*(.+)/);
|
|
153
|
+
if (toolMatch && !this.currentTool) {
|
|
154
|
+
const toolId = `tool_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
155
|
+
const args = pathMatch ? { path: pathMatch[1] } : {};
|
|
156
|
+
this.currentTool = {
|
|
157
|
+
id: toolId,
|
|
158
|
+
name: toolMatch[1],
|
|
159
|
+
args,
|
|
160
|
+
status: 'running',
|
|
161
|
+
startTime: Date.now()
|
|
162
|
+
};
|
|
163
|
+
this.startSpinner();
|
|
164
|
+
this.options.onToolCall?.(toolMatch[1], args, toolId);
|
|
165
|
+
yield { type: 'tool_call', tool: toolMatch[1], args, id: toolId };
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
else if (trimmed.startsWith('[ERROR]')) {
|
|
169
|
+
this.stopSpinner();
|
|
170
|
+
if (this.currentTool) {
|
|
171
|
+
this.currentTool.status = 'error';
|
|
172
|
+
this.options.onToolCall?.(this.currentTool.name, this.currentTool.args, this.currentTool.id);
|
|
173
|
+
}
|
|
174
|
+
const errorMsg = trimmed.replace('[ERROR]', '').trim();
|
|
175
|
+
this.options.onError?.(errorMsg);
|
|
176
|
+
yield { type: 'error', message: errorMsg };
|
|
177
|
+
this.currentTool = null;
|
|
178
|
+
}
|
|
179
|
+
else if (trimmed.startsWith('[SYSTEM]') || trimmed.startsWith('[DONE]') || trimmed.startsWith('[RETRY]') || trimmed.startsWith(' [DONE]') || trimmed.startsWith(' [RETRY]') || trimmed.startsWith(' [SYSTEM]') || trimmed.startsWith(' ⚡') || trimmed.startsWith('⚡')) {
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
else if (trimmed.startsWith(' ')) {
|
|
183
|
+
const toolResult = trimmed.replace(/^[├└├─\s]+/, '').trim();
|
|
184
|
+
if (toolResult && toolResult !== 'Thinking...' && toolResult !== 'Thinking') {
|
|
185
|
+
this.stopSpinner();
|
|
186
|
+
if (this.currentTool) {
|
|
187
|
+
this.currentTool.status = 'completed';
|
|
188
|
+
this.currentTool.result = toolResult;
|
|
189
|
+
this.options.onToolResult?.(this.currentTool.name, toolResult, this.currentTool.id);
|
|
190
|
+
yield { type: 'tool_result', tool: this.currentTool.name, result: toolResult, id: this.currentTool.id };
|
|
191
|
+
this.currentTool = null;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
else if (trimmed.startsWith('∴') || trimmed.startsWith('Thinking:')) {
|
|
196
|
+
this.inThinking = true;
|
|
197
|
+
const thinkingContent = trimmed.replace(/^∴|Thinking:/, '').trim();
|
|
198
|
+
this.thinkingBuffer += thinkingContent + ' ';
|
|
199
|
+
this.options.onThinking?.(this.thinkingBuffer);
|
|
200
|
+
yield { type: 'thinking', content: this.thinkingBuffer };
|
|
201
|
+
}
|
|
202
|
+
else if (this.inThinking && trimmed.match(/^[A-Z][a-z]/)) {
|
|
203
|
+
this.inThinking = false;
|
|
204
|
+
if (this.thinkingBuffer) {
|
|
205
|
+
this.options.onTextChunk?.(trimmed);
|
|
206
|
+
yield { type: 'text_chunk', content: trimmed };
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
else if (trimmed.startsWith('⚠') || trimmed.startsWith('✗') || trimmed.startsWith(' ⚠') || trimmed.startsWith(' ✗')) {
|
|
210
|
+
continue;
|
|
211
|
+
}
|
|
212
|
+
else if (!trimmed.startsWith('[') && !trimmed.startsWith(' ')) {
|
|
213
|
+
this.inThinking = false;
|
|
214
|
+
if (trimmed) {
|
|
215
|
+
this.options.onTextChunk?.(trimmed);
|
|
216
|
+
yield { type: 'text_chunk', content: trimmed };
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
this.stopSpinner();
|
|
222
|
+
this.options.onDone?.();
|
|
223
|
+
yield { type: 'done' };
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
exports.StreamHandler = StreamHandler;
|
|
227
|
+
function createStreamHandler(agent, options) {
|
|
228
|
+
return new StreamHandler(agent, options);
|
|
229
|
+
}
|
|
230
|
+
function renderThinking(content, isExpanded) {
|
|
231
|
+
if (!content)
|
|
232
|
+
return '';
|
|
233
|
+
if (!isExpanded) {
|
|
234
|
+
return `${output_1.theme.dim(THINKING_SYMBOL)} ${output_1.theme.dim('Thinking...')} ${output_1.theme.dim('(Ctrl+O to expand)')}`;
|
|
235
|
+
}
|
|
236
|
+
return `${output_1.theme.dim(THINKING_SYMBOL)} ${output_1.theme.dim(content)}`;
|
|
237
|
+
}
|
|
238
|
+
function renderToolCall(tool, expanded) {
|
|
239
|
+
const statusIcon = tool.status === 'running'
|
|
240
|
+
? output_1.theme.dim(SPINNER_FRAMES[0])
|
|
241
|
+
: tool.status === 'completed'
|
|
242
|
+
? output_1.theme.success(DONE_SYMBOL)
|
|
243
|
+
: tool.status === 'error'
|
|
244
|
+
? output_1.theme.error(ERROR_SYMBOL)
|
|
245
|
+
: output_1.theme.dim('○');
|
|
246
|
+
const toolDisplay = formatToolName(tool.name);
|
|
247
|
+
const argsDisplay = formatToolArgs(tool.args);
|
|
248
|
+
let line = ` ${statusIcon} [${toolDisplay}]${argsDisplay ? ' ' + argsDisplay : ''}`;
|
|
249
|
+
if (tool.result && !expanded) {
|
|
250
|
+
line += `\n ${output_1.theme.dim('└─')} ${truncateWithExpand(tool.result, 80)}`;
|
|
251
|
+
line += `\n ${output_1.theme.dim(' (Ctrl+O to expand)')}`;
|
|
252
|
+
}
|
|
253
|
+
else if (tool.result && expanded) {
|
|
254
|
+
line += `\n ${output_1.theme.dim('└─')} ${tool.result}`;
|
|
255
|
+
}
|
|
256
|
+
return line;
|
|
257
|
+
}
|
|
258
|
+
function renderMessage(msg, expanded) {
|
|
259
|
+
if (msg.role === 'user') {
|
|
260
|
+
return `${output_1.theme.accent('>')} ${msg.content}`;
|
|
261
|
+
}
|
|
262
|
+
if (msg.role === 'assistant') {
|
|
263
|
+
let output = '';
|
|
264
|
+
if (msg.thinking) {
|
|
265
|
+
const isExpanded = expanded.has(msg.id + '_thinking');
|
|
266
|
+
output += renderThinking(msg.thinking, isExpanded) + '\n';
|
|
267
|
+
}
|
|
268
|
+
if (msg.content) {
|
|
269
|
+
output += msg.content;
|
|
270
|
+
}
|
|
271
|
+
if (msg.tool_calls) {
|
|
272
|
+
for (const tc of msg.tool_calls) {
|
|
273
|
+
output += '\n' + renderToolCall(tc, expanded.has(tc.id));
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
return output;
|
|
277
|
+
}
|
|
278
|
+
if (msg.role === 'tool') {
|
|
279
|
+
const isExpanded = expanded.has(msg.id);
|
|
280
|
+
const content = isExpanded ? msg.content : truncateWithExpand(msg.content, 200);
|
|
281
|
+
return `${output_1.theme.dim('├─')} ${content}${!isExpanded && msg.content.length > 200 ? `\n${output_1.theme.dim(' (Ctrl+O to expand)')}` : ''}`;
|
|
282
|
+
}
|
|
283
|
+
if (msg.role === 'system') {
|
|
284
|
+
return output_1.theme.warning(msg.content);
|
|
285
|
+
}
|
|
286
|
+
return '';
|
|
287
|
+
}
|
|
288
|
+
function getHistory() {
|
|
289
|
+
const histPath = path.join(os.homedir(), '.coworker', 'repl_history.json');
|
|
290
|
+
try {
|
|
291
|
+
if (fs.existsSync(histPath)) {
|
|
292
|
+
return JSON.parse(fs.readFileSync(histPath, 'utf8'));
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
catch { }
|
|
296
|
+
return [];
|
|
297
|
+
}
|
|
298
|
+
function visLen(str) {
|
|
299
|
+
return str.replace(/\x1b\[[0-9;]*m/g, '').length;
|
|
300
|
+
}
|
|
301
|
+
function saveHistory(history) {
|
|
302
|
+
const histPath = path.join(os.homedir(), '.coworker', 'repl_history.json');
|
|
303
|
+
try {
|
|
304
|
+
const dir = path.dirname(histPath);
|
|
305
|
+
if (!fs.existsSync(dir))
|
|
306
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
307
|
+
fs.writeFileSync(histPath, JSON.stringify(history.slice(-100)));
|
|
308
|
+
}
|
|
309
|
+
catch { }
|
|
310
|
+
}
|
|
311
|
+
function startREPL(agent) {
|
|
312
|
+
const rl = readline.createInterface({
|
|
313
|
+
input: process.stdin,
|
|
314
|
+
output: process.stdout,
|
|
315
|
+
terminal: false,
|
|
316
|
+
});
|
|
317
|
+
const charLines = (0, character_1.renderCharacter)('idle');
|
|
318
|
+
const termWidth = process.stdout.columns || 80;
|
|
319
|
+
const boxWidth = Math.min(termWidth - 4, 50);
|
|
320
|
+
const leftWidth = Math.floor(boxWidth * 0.45);
|
|
321
|
+
const charPadding = ' '.repeat(Math.max(0, Math.floor((leftWidth - 12) / 2)));
|
|
322
|
+
console.log('');
|
|
323
|
+
console.log(output_1.theme.brand(` ╭── CoWorker v2.0 ${'─'.repeat(boxWidth - 18)}╮`));
|
|
324
|
+
for (let i = 0; i < charLines.length; i++) {
|
|
325
|
+
const left = i < charLines.length ? charPadding + charLines[i] : charPadding + ' ';
|
|
326
|
+
const right = i === 0 ? output_1.theme.dim('Type your message...') :
|
|
327
|
+
i === 1 ? output_1.theme.dim('↑↓ history | Ctrl+L clear') :
|
|
328
|
+
i === 2 ? output_1.theme.dim('Ctrl+O expand | Ctrl+C exit') : '';
|
|
329
|
+
const leftPad = ' '.repeat(Math.max(0, leftWidth - 2 - visLen(left)));
|
|
330
|
+
console.log(output_1.theme.brand(' │') + left + leftPad + output_1.theme.dim(' │ ') + right + output_1.theme.brand('│'));
|
|
331
|
+
}
|
|
332
|
+
const emptyLines = 5 - charLines.length;
|
|
333
|
+
for (let i = 0; i < emptyLines; i++) {
|
|
334
|
+
console.log(output_1.theme.brand(' │') + ' '.repeat(leftWidth) + output_1.theme.dim(' │ ') + output_1.theme.brand('│'));
|
|
335
|
+
}
|
|
336
|
+
console.log(output_1.theme.brand(` ╰${'─'.repeat(boxWidth - 2)}╯`));
|
|
337
|
+
console.log('');
|
|
338
|
+
let history = getHistory();
|
|
339
|
+
let historyIndex = -1;
|
|
340
|
+
let messages = [];
|
|
341
|
+
let expandedTools = new Set();
|
|
342
|
+
const refreshDisplay = () => {
|
|
343
|
+
console.clear();
|
|
344
|
+
console.log(`\n ${output_1.theme.brand(output_1.BRAND_SYMBOL)} ${output_1.theme.white('CoWorker')} ${output_1.theme.dim('v2.0')}\n`);
|
|
345
|
+
for (const msg of messages) {
|
|
346
|
+
console.log(renderMessage(msg, expandedTools));
|
|
347
|
+
}
|
|
348
|
+
};
|
|
349
|
+
const printToolCall = (tool, args, _id) => {
|
|
350
|
+
console.log(` ${output_1.theme.brand('[TOOL]')} ${formatToolName(tool)} ${formatToolArgs(args)}`);
|
|
351
|
+
};
|
|
352
|
+
const printToolResult = (_tool, result, _id) => {
|
|
353
|
+
const truncated = result.length > 80 ? result.substring(0, 80) + '...' : result;
|
|
354
|
+
console.log(` ${output_1.theme.dim('└─')} ${truncated}`);
|
|
355
|
+
};
|
|
356
|
+
const printThinking = (content) => {
|
|
357
|
+
process.stdout.write(`${output_1.theme.dim(THINKING_SYMBOL)} `);
|
|
358
|
+
};
|
|
359
|
+
const printDone = () => {
|
|
360
|
+
console.log('');
|
|
361
|
+
};
|
|
362
|
+
const printError = (message) => {
|
|
363
|
+
console.log(`\n ${output_1.theme.error(ERROR_SYMBOL)} ${message}\n`);
|
|
364
|
+
};
|
|
365
|
+
console.log('');
|
|
366
|
+
const ask = () => {
|
|
367
|
+
rl.question(`${output_1.theme.accent('>')} `, async (input) => {
|
|
368
|
+
if (!input.trim()) {
|
|
369
|
+
ask();
|
|
370
|
+
return;
|
|
371
|
+
}
|
|
372
|
+
if (input === '\\clear') {
|
|
373
|
+
console.clear();
|
|
374
|
+
messages = [];
|
|
375
|
+
expandedTools.clear();
|
|
376
|
+
ask();
|
|
377
|
+
return;
|
|
378
|
+
}
|
|
379
|
+
if (input.startsWith('\\')) {
|
|
380
|
+
const cmd = input.slice(1);
|
|
381
|
+
if (cmd === 'expand') {
|
|
382
|
+
for (const msg of messages) {
|
|
383
|
+
if (msg.tool_calls) {
|
|
384
|
+
for (const tc of msg.tool_calls) {
|
|
385
|
+
expandedTools.add(tc.id);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
refreshDisplay();
|
|
390
|
+
}
|
|
391
|
+
else if (cmd === 'collapse') {
|
|
392
|
+
expandedTools.clear();
|
|
393
|
+
refreshDisplay();
|
|
394
|
+
}
|
|
395
|
+
else if (cmd === 'history') {
|
|
396
|
+
console.log('\nHistory:');
|
|
397
|
+
history.forEach((h, i) => console.log(` ${i + 1}. ${h}`));
|
|
398
|
+
console.log('');
|
|
399
|
+
}
|
|
400
|
+
ask();
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
403
|
+
if (input.startsWith('!')) {
|
|
404
|
+
const idx = parseInt(input.slice(1)) - 1;
|
|
405
|
+
if (!isNaN(idx) && history[idx]) {
|
|
406
|
+
input = history[idx];
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
console.log('');
|
|
410
|
+
messages.push({ id: Date.now(), role: 'user', content: input, timestamp: Date.now() });
|
|
411
|
+
history = [...history.slice(-99), input];
|
|
412
|
+
historyIndex = -1;
|
|
413
|
+
saveHistory(history);
|
|
414
|
+
const handler = new StreamHandler(agent, {
|
|
415
|
+
onThinking: printThinking,
|
|
416
|
+
onToolCall: printToolCall,
|
|
417
|
+
onToolResult: printToolResult,
|
|
418
|
+
onTextChunk: (content) => process.stdout.write(content),
|
|
419
|
+
onDone: () => {
|
|
420
|
+
printDone();
|
|
421
|
+
ask();
|
|
422
|
+
},
|
|
423
|
+
onError: printError,
|
|
424
|
+
});
|
|
425
|
+
try {
|
|
426
|
+
for await (const event of handler.processStream(input)) {
|
|
427
|
+
if (event.type === 'tool_call') {
|
|
428
|
+
const lastMsg = messages[messages.length - 1];
|
|
429
|
+
if (!lastMsg.tool_calls)
|
|
430
|
+
lastMsg.tool_calls = [];
|
|
431
|
+
lastMsg.tool_calls.push({
|
|
432
|
+
id: event.id,
|
|
433
|
+
name: event.tool,
|
|
434
|
+
args: event.args,
|
|
435
|
+
status: 'running'
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
else if (event.type === 'tool_result') {
|
|
439
|
+
const lastMsg = messages[messages.length - 1];
|
|
440
|
+
if (lastMsg.tool_calls) {
|
|
441
|
+
const tc = lastMsg.tool_calls.find((t) => t.id === event.id);
|
|
442
|
+
if (tc) {
|
|
443
|
+
tc.status = 'completed';
|
|
444
|
+
tc.result = event.result;
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
else if (event.type === 'text_chunk') {
|
|
449
|
+
const lastMsg = messages[messages.length - 1];
|
|
450
|
+
if (!lastMsg.content)
|
|
451
|
+
lastMsg.content = '';
|
|
452
|
+
lastMsg.content += event.content;
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
catch (err) {
|
|
457
|
+
printError(err.message);
|
|
458
|
+
}
|
|
459
|
+
ask();
|
|
460
|
+
});
|
|
461
|
+
};
|
|
462
|
+
rl.on('line', (input) => { });
|
|
463
|
+
ask();
|
|
464
|
+
process.on('SIGINT', () => {
|
|
465
|
+
console.log(`\n ${output_1.theme.dim('Goodbye!')}\n`);
|
|
466
|
+
process.exit(0);
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
//# sourceMappingURL=REPL.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"REPL.js","sourceRoot":"","sources":["../../../src/coworker/ui/REPL.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0NA,kDAEC;AA4FD,8BA4KC;AAleD,+CAAyD;AACzD,qDAAwD;AACxD,mDAAqC;AACrC,uCAAyB;AACzB,2CAA6B;AAC7B,uCAAyB;AAEzB,MAAM,eAAe,GAAG,GAAG,CAAC;AAC5B,MAAM,WAAW,GAAG,GAAG,CAAC;AACxB,MAAM,cAAc,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AAC1E,MAAM,WAAW,GAAG,GAAG,CAAC;AACxB,MAAM,cAAc,GAAG,IAAI,CAAC;AAC5B,MAAM,YAAY,GAAG,GAAG,CAAC;AAoB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AAG,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;wBAC9C,IAAI,CAAC,OAAO,CAAC,OAAO;4BAAE,OAAO,CAAC,OAAO,GAAG,EAAE,CAAC;wBAC3C,OAAO,CAAC,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC;oBACnC,CAAC;gBACH,CAAC;YACH,CAAC;YAAC,OAAO,GAAQ,EAAE,CAAC;gBAClB,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YAC1B,CAAC;YAED,GAAG,EAAE,CAAC;QACR,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,EAAE,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAa,EAAE,EAAE,GAAE,CAAC,CAAC,CAAC;IAErC,GAAG,EAAE,CAAC;IAEN,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;QACxB,OAAO,CAAC,GAAG,CAAC,OAAO,cAAK,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAC9C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface UseInputBufferOptions {
|
|
2
|
+
maxHistory?: number;
|
|
3
|
+
onSubmit?: (input: string) => void;
|
|
4
|
+
}
|
|
5
|
+
export interface UseInputBufferReturn {
|
|
6
|
+
input: string;
|
|
7
|
+
setInput: (value: string) => void;
|
|
8
|
+
history: string[];
|
|
9
|
+
historyIndex: number;
|
|
10
|
+
submit: () => void;
|
|
11
|
+
goBack: () => void;
|
|
12
|
+
goForward: () => void;
|
|
13
|
+
clear: () => void;
|
|
14
|
+
}
|
|
15
|
+
export declare function useInputBuffer(options?: UseInputBufferOptions): UseInputBufferReturn;
|
|
16
|
+
//# sourceMappingURL=useInputBuffer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useInputBuffer.d.ts","sourceRoot":"","sources":["../../../../src/coworker/ui/hooks/useInputBuffer.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,qBAAqB;IACpC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACpC;AAED,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAED,wBAAgB,cAAc,CAAC,OAAO,GAAE,qBAA0B,GAAG,oBAAoB,CAsDxF"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useInputBuffer = useInputBuffer;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
function useInputBuffer(options = {}) {
|
|
6
|
+
const { maxHistory = 100, onSubmit } = options;
|
|
7
|
+
const [input, setInput] = (0, react_1.useState)('');
|
|
8
|
+
const [history, setHistory] = (0, react_1.useState)([]);
|
|
9
|
+
const [historyIndex, setHistoryIndex] = (0, react_1.useState)(-1);
|
|
10
|
+
const inputRef = (0, react_1.useRef)('');
|
|
11
|
+
(0, react_1.useEffect)(() => {
|
|
12
|
+
inputRef.current = input;
|
|
13
|
+
}, [input]);
|
|
14
|
+
const submit = (0, react_1.useCallback)(() => {
|
|
15
|
+
const trimmed = inputRef.current.trim();
|
|
16
|
+
if (!trimmed)
|
|
17
|
+
return;
|
|
18
|
+
setHistory(prev => [...prev.slice(-(maxHistory - 1)), trimmed]);
|
|
19
|
+
setHistoryIndex(-1);
|
|
20
|
+
setInput('');
|
|
21
|
+
onSubmit?.(trimmed);
|
|
22
|
+
}, [maxHistory, onSubmit]);
|
|
23
|
+
const goBack = (0, react_1.useCallback)(() => {
|
|
24
|
+
if (history.length === 0)
|
|
25
|
+
return;
|
|
26
|
+
const newIndex = historyIndex < history.length - 1 ? historyIndex + 1 : historyIndex;
|
|
27
|
+
setHistoryIndex(newIndex);
|
|
28
|
+
setInput(history[history.length - 1 - newIndex] || '');
|
|
29
|
+
}, [history, historyIndex]);
|
|
30
|
+
const goForward = (0, react_1.useCallback)(() => {
|
|
31
|
+
if (historyIndex <= 0) {
|
|
32
|
+
setHistoryIndex(-1);
|
|
33
|
+
setInput('');
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const newIndex = historyIndex - 1;
|
|
37
|
+
setHistoryIndex(newIndex);
|
|
38
|
+
setInput(history[history.length - 1 - newIndex] || '');
|
|
39
|
+
}, [history, historyIndex]);
|
|
40
|
+
const clear = (0, react_1.useCallback)(() => {
|
|
41
|
+
setInput('');
|
|
42
|
+
setHistoryIndex(-1);
|
|
43
|
+
}, []);
|
|
44
|
+
return {
|
|
45
|
+
input,
|
|
46
|
+
setInput,
|
|
47
|
+
history,
|
|
48
|
+
historyIndex,
|
|
49
|
+
submit,
|
|
50
|
+
goBack,
|
|
51
|
+
goForward,
|
|
52
|
+
clear,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=useInputBuffer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useInputBuffer.js","sourceRoot":"","sources":["../../../../src/coworker/ui/hooks/useInputBuffer.ts"],"names":[],"mappings":";;AAkBA,wCAsDC;AAxED,iCAAiE;AAkBjE,SAAgB,cAAc,CAAC,UAAiC,EAAE;IAChE,MAAM,EAAE,UAAU,GAAG,GAAG,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IAC/C,M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1B,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;IACzD,CAAC,EAAE,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC;IAE5B,MAAM,SAAS,GAAG,IAAA,mBAAW,EAAC,GAAG,EAAE;QACjC,IAAI,YAAY,IAAI,CAAC,EAAE,CAAC;YACtB,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;YACpB,QAAQ,CAAC,EAAE,CAAC,CAAC;YACb,OAAO;QACT,CAAC;QACD,MAAM,QAAQ,GAAG,YAAY,GAAG,CAAC,CAAC;QAClC,eAAe,CAAC,QAAQ,CAAC,CAAC;QAC1B,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;IACzD,CAAC,EAAE,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC;IAE5B,MAAM,KAAK,GAAG,IAAA,mBAAW,EAAC,GAAG,EAAE;QAC7B,QAAQ,CAAC,EAAE,CAAC,CAAC;QACb,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;IACtB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO;QACL,KAAK;QACL,QAAQ;QACR,OAAO;QACP,YAAY;QACZ,MAAM;QACN,MAAM;QACN,SAAS;QACT,KAAK;KACN,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface KeyboardShortcut {
|
|
2
|
+
key: string;
|
|
3
|
+
ctrl?: boolean;
|
|
4
|
+
shift?: boolean;
|
|
5
|
+
alt?: boolean;
|
|
6
|
+
action: () => void;
|
|
7
|
+
description?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface UseKeyboardShortcutsOptions {
|
|
10
|
+
shortcuts: KeyboardShortcut[];
|
|
11
|
+
enabled?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare function useKeyboardShortcuts(options: UseKeyboardShortcutsOptions): {
|
|
14
|
+
shortcuts: KeyboardShortcut[];
|
|
15
|
+
};
|
|
16
|
+
export declare const DEFAULT_SHORTCUTS: KeyboardShortcut[];
|
|
17
|
+
//# sourceMappingURL=useKeyboardShortcuts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useKeyboardShortcuts.d.ts","sourceRoot":"","sources":["../../../../src/coworker/ui/hooks/useKeyboardShortcuts.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,gBAAgB;IAC/B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,2BAA2B;IAC1C,SAAS,EAAE,gBAAgB,EAAE,CAAC;IAC9B,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,2BAA2B;;EAiCxE;AAED,eAAO,MAAM,iBAAiB,EAAE,gBAAgB,EAQ/C,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_SHORTCUTS = void 0;
|
|
4
|
+
exports.useKeyboardShortcuts = useKeyboardShortcuts;
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
function useKeyboardShortcuts(options) {
|
|
7
|
+
const { shortcuts, enabled = true } = options;
|
|
8
|
+
const handleKeyDown = (0, react_1.useCallback)((e) => {
|
|
9
|
+
if (!enabled)
|
|
10
|
+
return;
|
|
11
|
+
for (const shortcut of shortcuts) {
|
|
12
|
+
const ctrlMatch = shortcut.ctrl ? (e.ctrlKey || e.metaKey) : !e.ctrlKey && !e.metaKey;
|
|
13
|
+
const shiftMatch = shortcut.shift ? e.shiftKey : !e.shiftKey;
|
|
14
|
+
const altMatch = shortcut.alt ? e.altKey : !e.altKey;
|
|
15
|
+
const keyMatch = e.key.toLowerCase() === shortcut.key.toLowerCase();
|
|
16
|
+
if (ctrlMatch && shiftMatch && altMatch && keyMatch) {
|
|
17
|
+
e.preventDefault();
|
|
18
|
+
shortcut.action();
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}, [shortcuts, enabled]);
|
|
23
|
+
(0, react_1.useEffect)(() => {
|
|
24
|
+
if (enabled) {
|
|
25
|
+
window.addEventListener('keydown', handleKeyDown);
|
|
26
|
+
return () => window.removeEventListener('keydown', handleKeyDown);
|
|
27
|
+
}
|
|
28
|
+
}, [handleKeyDown, enabled]);
|
|
29
|
+
return {
|
|
30
|
+
shortcuts,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
exports.DEFAULT_SHORTCUTS = [
|
|
34
|
+
{ key: 'Enter', action: () => { }, description: 'Submit prompt' },
|
|
35
|
+
{ key: 'c', ctrl: true, action: () => { }, description: 'Cancel current operation' },
|
|
36
|
+
{ key: 'o', ctrl: true, action: () => { }, description: 'Expand/collapse thinking' },
|
|
37
|
+
{ key: 'ArrowUp', action: () => { }, description: 'Navigate input history' },
|
|
38
|
+
{ key: 'ArrowDown', action: () => { }, description: 'Navigate input history' },
|
|
39
|
+
{ key: 'Escape', action: () => { }, description: 'Exit current mode' },
|
|
40
|
+
{ key: 'l', ctrl: true, action: () => console.clear(), description: 'Clear screen' },
|
|
41
|
+
];
|
|
42
|
+
//# sourceMappingURL=useKeyboardShortcuts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useKeyboardShortcuts.js","sourceRoot":"","sources":["../../../../src/coworker/ui/hooks/useKeyboardShortcuts.ts"],"names":[],"mappings":";;;AAgBA,oDAiCC;AAjDD,iCAA+C;AAgB/C,SAAgB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