bravecode-cli 0.1.45 → 0.1.46
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-main.mjs +4 -3
- package/dist/cli-main.mjs.map +2 -2
- package/package.json +1 -1
- package/dist/autoModel.d.ts +0 -39
- package/dist/autoModel.d.ts.map +0 -1
- package/dist/autoModel.js +0 -127
- package/dist/autoModel.js.map +0 -1
- package/dist/bravecode +0 -22
- package/dist/cli.d.ts +0 -2
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js +0 -468
- package/dist/cli.js.map +0 -1
- package/dist/core/agent/index.d.ts +0 -31
- package/dist/core/agent/index.d.ts.map +0 -1
- package/dist/core/agent/index.js +0 -339
- package/dist/core/agent/index.js.map +0 -1
- package/dist/core/config/index.d.ts +0 -54
- package/dist/core/config/index.d.ts.map +0 -1
- package/dist/core/config/index.js +0 -138
- package/dist/core/config/index.js.map +0 -1
- package/dist/core/context/index.d.ts +0 -20
- package/dist/core/context/index.d.ts.map +0 -1
- package/dist/core/context/index.js +0 -70
- package/dist/core/context/index.js.map +0 -1
- package/dist/core/mcp/index.d.ts +0 -32
- package/dist/core/mcp/index.d.ts.map +0 -1
- package/dist/core/mcp/index.js +0 -160
- package/dist/core/mcp/index.js.map +0 -1
- package/dist/core/permission/index.d.ts +0 -24
- package/dist/core/permission/index.d.ts.map +0 -1
- package/dist/core/permission/index.js +0 -96
- package/dist/core/permission/index.js.map +0 -1
- package/dist/core/plugin/index.d.ts +0 -44
- package/dist/core/plugin/index.d.ts.map +0 -1
- package/dist/core/plugin/index.js +0 -139
- package/dist/core/plugin/index.js.map +0 -1
- package/dist/core/session/index.d.ts +0 -23
- package/dist/core/session/index.d.ts.map +0 -1
- package/dist/core/session/index.js +0 -51
- package/dist/core/session/index.js.map +0 -1
- package/dist/core/share/index.d.ts +0 -28
- package/dist/core/share/index.d.ts.map +0 -1
- package/dist/core/share/index.js +0 -100
- package/dist/core/share/index.js.map +0 -1
- package/dist/core/snapshot/index.d.ts +0 -30
- package/dist/core/snapshot/index.d.ts.map +0 -1
- package/dist/core/snapshot/index.js +0 -141
- package/dist/core/snapshot/index.js.map +0 -1
- package/dist/core/tool/bash.d.ts +0 -8
- package/dist/core/tool/bash.d.ts.map +0 -1
- package/dist/core/tool/bash.js +0 -29
- package/dist/core/tool/bash.js.map +0 -1
- package/dist/core/tool/browser.d.ts +0 -5
- package/dist/core/tool/browser.d.ts.map +0 -1
- package/dist/core/tool/browser.js +0 -119
- package/dist/core/tool/browser.js.map +0 -1
- package/dist/core/tool/file.d.ts +0 -5
- package/dist/core/tool/file.d.ts.map +0 -1
- package/dist/core/tool/file.js +0 -79
- package/dist/core/tool/file.js.map +0 -1
- package/dist/core/tool/index.d.ts +0 -21
- package/dist/core/tool/index.d.ts.map +0 -1
- package/dist/core/tool/index.js +0 -90
- package/dist/core/tool/index.js.map +0 -1
- package/dist/core/tool/search.d.ts +0 -4
- package/dist/core/tool/search.d.ts.map +0 -1
- package/dist/core/tool/search.js +0 -107
- package/dist/core/tool/search.js.map +0 -1
- package/dist/core/tool/task.d.ts +0 -9
- package/dist/core/tool/task.d.ts.map +0 -1
- package/dist/core/tool/task.js +0 -54
- package/dist/core/tool/task.js.map +0 -1
- package/dist/core/tool/todowrite.d.ts +0 -3
- package/dist/core/tool/todowrite.d.ts.map +0 -1
- package/dist/core/tool/todowrite.js +0 -75
- package/dist/core/tool/todowrite.js.map +0 -1
- package/dist/core/tool/websearch.d.ts +0 -3
- package/dist/core/tool/websearch.d.ts.map +0 -1
- package/dist/core/tool/websearch.js +0 -46
- package/dist/core/tool/websearch.js.map +0 -1
- package/dist/core/tui/ChatTUI.d.ts +0 -16
- package/dist/core/tui/ChatTUI.d.ts.map +0 -1
- package/dist/core/tui/ChatTUI.js +0 -65
- package/dist/core/tui/ChatTUI.js.map +0 -1
- package/dist/core/tui/index.d.ts +0 -15
- package/dist/core/tui/index.d.ts.map +0 -1
- package/dist/core/tui/index.js +0 -45
- package/dist/core/tui/index.js.map +0 -1
- package/dist/core/update/index.d.ts +0 -23
- package/dist/core/update/index.d.ts.map +0 -1
- package/dist/core/update/index.js +0 -115
- package/dist/core/update/index.js.map +0 -1
- package/dist/index.d.ts +0 -18
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -11
- package/dist/index.js.map +0 -1
- package/dist/models.json +0 -545
- package/dist/provider.d.ts +0 -43
- package/dist/provider.d.ts.map +0 -1
- package/dist/provider.js +0 -294
- package/dist/provider.js.map +0 -1
- package/dist/tui/ChatTUI.mjs +0 -89
- package/dist/tui-launcher.mjs +0 -64
package/dist/provider.js
DELETED
|
@@ -1,294 +0,0 @@
|
|
|
1
|
-
import { generateText, streamText } from "ai";
|
|
2
|
-
import { createMistral } from "@ai-sdk/mistral";
|
|
3
|
-
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
|
|
4
|
-
import modelsConfig from "./models.json";
|
|
5
|
-
export class LLMProviderManager {
|
|
6
|
-
providers = new Map();
|
|
7
|
-
coderoApiKey = "";
|
|
8
|
-
constructor() {
|
|
9
|
-
this.initializeProviders();
|
|
10
|
-
}
|
|
11
|
-
initializeProviders() {
|
|
12
|
-
const providers = modelsConfig.providers;
|
|
13
|
-
this.coderoApiKey = process.env.BRAVECODE_API_KEY || "";
|
|
14
|
-
for (const [providerId, config] of Object.entries(providers)) {
|
|
15
|
-
if (providerId === "bravecode") {
|
|
16
|
-
this.providers.set(providerId, createOpenAICompatible({
|
|
17
|
-
name: "bravecode",
|
|
18
|
-
apiKey: this.coderoApiKey,
|
|
19
|
-
baseURL: config.baseURL,
|
|
20
|
-
}));
|
|
21
|
-
}
|
|
22
|
-
else if (providerId === "mistral") {
|
|
23
|
-
this.providers.set(providerId, createMistral({
|
|
24
|
-
apiKey: process.env.MISTRAL_API_KEY || "",
|
|
25
|
-
baseURL: config.baseURL,
|
|
26
|
-
}));
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
this.providers.set(providerId, createOpenAICompatible({
|
|
30
|
-
name: providerId,
|
|
31
|
-
apiKey: process.env[config.envKey] || "",
|
|
32
|
-
baseURL: config.baseURL,
|
|
33
|
-
}));
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
getModelProvider(modelConfig) {
|
|
38
|
-
const provider = this.providers.get(modelConfig.provider);
|
|
39
|
-
if (!provider) {
|
|
40
|
-
throw new Error(`Provider ${modelConfig.provider} not found`);
|
|
41
|
-
}
|
|
42
|
-
return provider;
|
|
43
|
-
}
|
|
44
|
-
mapMessages(messages) {
|
|
45
|
-
return messages.map((m) => {
|
|
46
|
-
if (m.role === "tool") {
|
|
47
|
-
return {
|
|
48
|
-
role: "tool",
|
|
49
|
-
content: m.content,
|
|
50
|
-
toolCallId: m.toolCallId || "",
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
return {
|
|
54
|
-
role: m.role,
|
|
55
|
-
content: m.content,
|
|
56
|
-
};
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
async chat(params, modelConfig) {
|
|
60
|
-
const config = modelConfig || this.getModelConfigById(params.model);
|
|
61
|
-
if (!config) {
|
|
62
|
-
throw new Error(`Model ${params.model} not found`);
|
|
63
|
-
}
|
|
64
|
-
if (config.provider === "bravecode") {
|
|
65
|
-
return this.coderoChat(params, config);
|
|
66
|
-
}
|
|
67
|
-
const provider = this.getModelProvider(config);
|
|
68
|
-
const modelId = config.id;
|
|
69
|
-
try {
|
|
70
|
-
const result = await generateText({
|
|
71
|
-
model: provider(modelId),
|
|
72
|
-
messages: this.mapMessages(params.messages),
|
|
73
|
-
temperature: params.temperature ?? 0.7,
|
|
74
|
-
maxOutputTokens: params.maxTokens ?? config.maxOutputTokens,
|
|
75
|
-
});
|
|
76
|
-
return {
|
|
77
|
-
text: result.text,
|
|
78
|
-
toolCalls: result.toolCalls,
|
|
79
|
-
finishReason: result.finishReason,
|
|
80
|
-
usage: {
|
|
81
|
-
input: result.usage.inputTokens ?? 0,
|
|
82
|
-
output: result.usage.outputTokens ?? 0,
|
|
83
|
-
},
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
catch (error) {
|
|
87
|
-
console.error("Chat error:", error);
|
|
88
|
-
throw error;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
async *chatStream(params, modelConfig) {
|
|
92
|
-
const config = modelConfig || this.getModelConfigById(params.model);
|
|
93
|
-
if (!config) {
|
|
94
|
-
throw new Error(`Model ${params.model} not found`);
|
|
95
|
-
}
|
|
96
|
-
if (config.provider === "bravecode") {
|
|
97
|
-
yield* this.coderoChatStream(params, config);
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
const provider = this.getModelProvider(config);
|
|
101
|
-
const modelId = config.id;
|
|
102
|
-
try {
|
|
103
|
-
const stream = streamText({
|
|
104
|
-
model: provider(modelId),
|
|
105
|
-
messages: this.mapMessages(params.messages),
|
|
106
|
-
temperature: params.temperature ?? 0.7,
|
|
107
|
-
maxOutputTokens: params.maxTokens ?? config.maxOutputTokens,
|
|
108
|
-
});
|
|
109
|
-
for await (const chunk of stream.textStream) {
|
|
110
|
-
yield { type: "text", text: chunk };
|
|
111
|
-
}
|
|
112
|
-
yield {
|
|
113
|
-
type: "finish",
|
|
114
|
-
finishReason: "stop",
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
catch (error) {
|
|
118
|
-
console.error("Stream error:", error);
|
|
119
|
-
throw error;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
async coderoChat(params, config) {
|
|
123
|
-
const messages = this.mapMessages(params.messages);
|
|
124
|
-
const systemMessage = messages.find((m) => m.role === "system");
|
|
125
|
-
const conversationMessages = messages.filter((m) => m.role !== "system");
|
|
126
|
-
const payload = {
|
|
127
|
-
model: config.id,
|
|
128
|
-
messages: conversationMessages,
|
|
129
|
-
stream: true,
|
|
130
|
-
};
|
|
131
|
-
if (systemMessage) {
|
|
132
|
-
payload.system = systemMessage.content;
|
|
133
|
-
}
|
|
134
|
-
if (params.temperature !== undefined) {
|
|
135
|
-
payload.temperature = params.temperature;
|
|
136
|
-
}
|
|
137
|
-
try {
|
|
138
|
-
const https = require("https");
|
|
139
|
-
const response = await fetch("https://codero.sohailsyed.com/api/chat", {
|
|
140
|
-
method: "POST",
|
|
141
|
-
headers: {
|
|
142
|
-
"Content-Type": "application/json",
|
|
143
|
-
...(this.coderoApiKey ? { Authorization: `Bearer ${this.coderoApiKey}` } : {}),
|
|
144
|
-
},
|
|
145
|
-
body: JSON.stringify(payload),
|
|
146
|
-
// @ts-ignore
|
|
147
|
-
dispatcher: new https.Agent({ rejectUnauthorized: false }),
|
|
148
|
-
});
|
|
149
|
-
if (!response.ok) {
|
|
150
|
-
throw new Error(`BraveCode API error: ${response.status}`);
|
|
151
|
-
}
|
|
152
|
-
const reader = response.body?.getReader();
|
|
153
|
-
if (!reader) {
|
|
154
|
-
throw new Error("No response body");
|
|
155
|
-
}
|
|
156
|
-
const decoder = new TextDecoder();
|
|
157
|
-
let buffer = "";
|
|
158
|
-
let fullText = "";
|
|
159
|
-
while (true) {
|
|
160
|
-
const { done, value } = await reader.read();
|
|
161
|
-
if (done)
|
|
162
|
-
break;
|
|
163
|
-
buffer += decoder.decode(value, { stream: true });
|
|
164
|
-
const lines = buffer.split("\n");
|
|
165
|
-
buffer = lines.pop() || "";
|
|
166
|
-
for (const line of lines) {
|
|
167
|
-
const trimmed = line.trim();
|
|
168
|
-
if (!trimmed)
|
|
169
|
-
continue;
|
|
170
|
-
try {
|
|
171
|
-
const parsed = JSON.parse(trimmed);
|
|
172
|
-
const text = parsed.delta || parsed.chunk;
|
|
173
|
-
if (text) {
|
|
174
|
-
fullText += text;
|
|
175
|
-
}
|
|
176
|
-
if (parsed.done || parsed.type === "done") {
|
|
177
|
-
return {
|
|
178
|
-
text: fullText,
|
|
179
|
-
toolCalls: undefined,
|
|
180
|
-
finishReason: "stop",
|
|
181
|
-
usage: {
|
|
182
|
-
input: 0,
|
|
183
|
-
output: 0,
|
|
184
|
-
},
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
catch {
|
|
189
|
-
// Skip malformed JSON
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
return {
|
|
194
|
-
text: fullText,
|
|
195
|
-
toolCalls: undefined,
|
|
196
|
-
finishReason: "stop",
|
|
197
|
-
usage: {
|
|
198
|
-
input: 0,
|
|
199
|
-
output: 0,
|
|
200
|
-
},
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
|
-
catch (error) {
|
|
204
|
-
console.error("BraveCode chat error:", error);
|
|
205
|
-
throw error;
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
async *coderoChatStream(params, config) {
|
|
209
|
-
const messages = this.mapMessages(params.messages);
|
|
210
|
-
const systemMessage = messages.find((m) => m.role === "system");
|
|
211
|
-
const conversationMessages = messages.filter((m) => m.role !== "system");
|
|
212
|
-
const payload = {
|
|
213
|
-
model: config.id,
|
|
214
|
-
messages: conversationMessages,
|
|
215
|
-
stream: true,
|
|
216
|
-
};
|
|
217
|
-
if (systemMessage) {
|
|
218
|
-
payload.system = systemMessage.content;
|
|
219
|
-
}
|
|
220
|
-
if (params.temperature !== undefined) {
|
|
221
|
-
payload.temperature = params.temperature;
|
|
222
|
-
}
|
|
223
|
-
try {
|
|
224
|
-
const https = require("https");
|
|
225
|
-
const response = await fetch("https://codero.sohailsyed.com/api/chat", {
|
|
226
|
-
method: "POST",
|
|
227
|
-
headers: {
|
|
228
|
-
"Content-Type": "application/json",
|
|
229
|
-
...(this.coderoApiKey ? { Authorization: `Bearer ${this.coderoApiKey}` } : {}),
|
|
230
|
-
},
|
|
231
|
-
body: JSON.stringify(payload),
|
|
232
|
-
// @ts-ignore
|
|
233
|
-
agent: new https.Agent({ rejectUnauthorized: false }),
|
|
234
|
-
});
|
|
235
|
-
if (!response.ok) {
|
|
236
|
-
throw new Error(`BraveCode API error: ${response.status}`);
|
|
237
|
-
}
|
|
238
|
-
const reader = response.body?.getReader();
|
|
239
|
-
if (!reader) {
|
|
240
|
-
throw new Error("No response body");
|
|
241
|
-
}
|
|
242
|
-
const decoder = new TextDecoder();
|
|
243
|
-
let buffer = "";
|
|
244
|
-
while (true) {
|
|
245
|
-
const { done, value } = await reader.read();
|
|
246
|
-
if (done)
|
|
247
|
-
break;
|
|
248
|
-
buffer += decoder.decode(value, { stream: true });
|
|
249
|
-
const lines = buffer.split("\n");
|
|
250
|
-
buffer = lines.pop() || "";
|
|
251
|
-
for (const line of lines) {
|
|
252
|
-
const trimmed = line.trim();
|
|
253
|
-
if (!trimmed)
|
|
254
|
-
continue;
|
|
255
|
-
try {
|
|
256
|
-
const parsed = JSON.parse(trimmed);
|
|
257
|
-
const text = parsed.delta || parsed.chunk;
|
|
258
|
-
if (text) {
|
|
259
|
-
yield { type: "text", text };
|
|
260
|
-
}
|
|
261
|
-
if (parsed.done || parsed.type === "done") {
|
|
262
|
-
yield { type: "finish", finishReason: "stop" };
|
|
263
|
-
return;
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
catch {
|
|
267
|
-
// Skip malformed JSON
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
yield { type: "finish", finishReason: "stop" };
|
|
272
|
-
}
|
|
273
|
-
catch (error) {
|
|
274
|
-
console.error("BraveCode stream error:", error);
|
|
275
|
-
throw error;
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
getModelConfigById(modelId) {
|
|
279
|
-
return modelsConfig.models.find((m) => m.id === modelId);
|
|
280
|
-
}
|
|
281
|
-
getAvailableProviders() {
|
|
282
|
-
return Array.from(this.providers.keys());
|
|
283
|
-
}
|
|
284
|
-
isProviderConfigured(providerId) {
|
|
285
|
-
const provider = modelsConfig.providers[providerId];
|
|
286
|
-
if (!provider)
|
|
287
|
-
return false;
|
|
288
|
-
if (providerId === "bravecode") {
|
|
289
|
-
return true;
|
|
290
|
-
}
|
|
291
|
-
return !!process.env[provider.envKey];
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
//# sourceMappingURL=provider.js.map
|
package/dist/provider.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAEnE,OAAO,YAAY,MAAM,eAAe,CAAC;AAsCzC,MAAM,OAAO,kBAAkB;IACrB,SAAS,GAAqB,IAAI,GAAG,EAAE,CAAC;IACxC,YAAY,GAAW,EAAE,CAAC;IAElC;QACE,IAAI,CAAC,mBAAmB,EAAE,CAAC;IAC7B,CAAC;IAEO,mBAAmB;QACzB,MAAM,SAAS,GAAG,YAAY,CAAC,SAAgE,CAAC;QAEhG,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,EAAE,CAAC;QAExD,KAAK,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;YAC7D,IAAI,UAAU,KAAK,WAAW,EAAE,CAAC;gBAC/B,IAAI,CAAC,SAAS,CAAC,GAAG,CAChB,UAAU,EACV,sBAAsB,CAAC;oBACrB,IAAI,EAAE,WAAW;oBACjB,MAAM,EAAE,IAAI,CAAC,YAAY;oBACzB,OAAO,EAAE,MAAM,CAAC,OAAO;iBACxB,CAAC,CACH,CAAC;YACJ,CAAC;iBAAM,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;gBACpC,IAAI,CAAC,SAAS,CAAC,GAAG,CAChB,UAAU,EACV,aAAa,CAAC;oBACZ,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,EAAE;oB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AAQ,GAAG,YAAY,CAAC,SAAS,CAAC,UAAiD,CAAC,CAAC;QAC3F,IAAI,CAAC,QAAQ;YAAE,OAAO,KAAK,CAAC;QAC5B,IAAI,UAAU,KAAK,WAAW,EAAE,CAAC;YAC/B,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACxC,CAAC;CACF"}
|
package/dist/tui/ChatTUI.mjs
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import React, { useState, useCallback } from "react";
|
|
3
|
-
import { Box, Text, useInput, useApp } from "ink";
|
|
4
|
-
import TextInput from "ink-text-input";
|
|
5
|
-
function ChatTUI({ agentName, modelName, onMessage, onExit }) {
|
|
6
|
-
const [messages, setMessages] = useState([]);
|
|
7
|
-
const [input, setInput] = useState("");
|
|
8
|
-
const [isLoading, setIsLoading] = useState(false);
|
|
9
|
-
const { exit } = useApp();
|
|
10
|
-
const handleSubmit = useCallback(async (value) => {
|
|
11
|
-
if (!value.trim()) return;
|
|
12
|
-
const userMessage = {
|
|
13
|
-
id: Date.now().toString(),
|
|
14
|
-
role: "user",
|
|
15
|
-
content: value,
|
|
16
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
17
|
-
};
|
|
18
|
-
setMessages((prev) => [...prev, userMessage]);
|
|
19
|
-
setInput("");
|
|
20
|
-
setIsLoading(true);
|
|
21
|
-
try {
|
|
22
|
-
const response = await onMessage(value);
|
|
23
|
-
const assistantMessage = {
|
|
24
|
-
id: (Date.now() + 1).toString(),
|
|
25
|
-
role: "assistant",
|
|
26
|
-
content: response,
|
|
27
|
-
agent: agentName,
|
|
28
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
29
|
-
};
|
|
30
|
-
setMessages((prev) => [...prev, assistantMessage]);
|
|
31
|
-
} catch (error) {
|
|
32
|
-
const errorMessage = {
|
|
33
|
-
id: (Date.now() + 1).toString(),
|
|
34
|
-
role: "assistant",
|
|
35
|
-
content: `Error: ${error.message}`,
|
|
36
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
37
|
-
};
|
|
38
|
-
setMessages((prev) => [...prev, errorMessage]);
|
|
39
|
-
} finally {
|
|
40
|
-
setIsLoading(false);
|
|
41
|
-
}
|
|
42
|
-
}, [onMessage, agentName]);
|
|
43
|
-
useInput((inputChar, key) => {
|
|
44
|
-
if (key.ctrl && inputChar === "c") {
|
|
45
|
-
onExit();
|
|
46
|
-
exit();
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", height: "100%", children: [
|
|
50
|
-
/* @__PURE__ */ jsxs(Box, { borderStyle: "round", borderColor: "blue", padding: 1, flexDirection: "column", children: [
|
|
51
|
-
/* @__PURE__ */ jsxs(Box, { marginBottom: 1, children: [
|
|
52
|
-
/* @__PURE__ */ jsx(Text, { bold: true, color: "blue", children: "BraveCode AI" }),
|
|
53
|
-
/* @__PURE__ */ jsx(Text, { color: "gray", children: " | " }),
|
|
54
|
-
/* @__PURE__ */ jsx(Text, { color: "yellow", children: agentName }),
|
|
55
|
-
/* @__PURE__ */ jsx(Text, { color: "gray", children: " | " }),
|
|
56
|
-
/* @__PURE__ */ jsx(Text, { color: "cyan", children: modelName })
|
|
57
|
-
] }),
|
|
58
|
-
/* @__PURE__ */ jsxs(Box, { borderStyle: "single", borderColor: "gray", flexDirection: "column", padding: 1, flexGrow: 1, children: [
|
|
59
|
-
messages.map((msg) => /* @__PURE__ */ jsx(Box, { marginBottom: 1, children: msg.role === "user" ? /* @__PURE__ */ jsxs(Text, { children: [
|
|
60
|
-
/* @__PURE__ */ jsx(Text, { bold: true, color: "green", children: "You: " }),
|
|
61
|
-
msg.content
|
|
62
|
-
] }) : /* @__PURE__ */ jsxs(Text, { children: [
|
|
63
|
-
/* @__PURE__ */ jsxs(Text, { bold: true, color: "blue", children: [
|
|
64
|
-
msg.agent || "AI",
|
|
65
|
-
": "
|
|
66
|
-
] }),
|
|
67
|
-
msg.content
|
|
68
|
-
] }) }, msg.id)),
|
|
69
|
-
isLoading && /* @__PURE__ */ jsx(Text, { color: "gray", italic: true, children: "Thinking..." })
|
|
70
|
-
] })
|
|
71
|
-
] }),
|
|
72
|
-
/* @__PURE__ */ jsx(Box, { marginTop: 1, children: /* @__PURE__ */ jsx(Text, { color: "gray", children: "Ctrl+C: exit" }) }),
|
|
73
|
-
/* @__PURE__ */ jsxs(Box, { marginTop: 1, children: [
|
|
74
|
-
/* @__PURE__ */ jsx(Text, { color: "green", bold: true, children: "> " }),
|
|
75
|
-
/* @__PURE__ */ jsx(
|
|
76
|
-
TextInput,
|
|
77
|
-
{
|
|
78
|
-
value: input,
|
|
79
|
-
onChange: setInput,
|
|
80
|
-
onSubmit: handleSubmit,
|
|
81
|
-
placeholder: "Type a message..."
|
|
82
|
-
}
|
|
83
|
-
)
|
|
84
|
-
] })
|
|
85
|
-
] });
|
|
86
|
-
}
|
|
87
|
-
export {
|
|
88
|
-
ChatTUI
|
|
89
|
-
};
|
package/dist/tui-launcher.mjs
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { render } from "ink";
|
|
3
|
-
import React from "react";
|
|
4
|
-
import { ChatTUI } from "./ChatTUI";
|
|
5
|
-
import { LLMProviderManager } from "../../provider";
|
|
6
|
-
import { ToolRegistry } from "../tool";
|
|
7
|
-
import { Agent, defaultAgents } from "../agent";
|
|
8
|
-
class TUILauncher {
|
|
9
|
-
provider;
|
|
10
|
-
tools;
|
|
11
|
-
agent;
|
|
12
|
-
agentName;
|
|
13
|
-
modelName;
|
|
14
|
-
constructor(model, agentId) {
|
|
15
|
-
this.provider = new LLMProviderManager();
|
|
16
|
-
this.tools = new ToolRegistry();
|
|
17
|
-
const agentConfig = defaultAgents.find((a) => a.id === (agentId || "build")) || defaultAgents[0];
|
|
18
|
-
this.agentName = agentConfig.name;
|
|
19
|
-
this.modelName = model || agentConfig.model;
|
|
20
|
-
this.agent = new Agent(this.provider, this.tools, {
|
|
21
|
-
...agentConfig,
|
|
22
|
-
model: this.modelName
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
async start() {
|
|
26
|
-
const onMessage = async (message) => {
|
|
27
|
-
let response = "";
|
|
28
|
-
await this.agent.run(message, (chunk) => {
|
|
29
|
-
response += chunk;
|
|
30
|
-
});
|
|
31
|
-
return response;
|
|
32
|
-
};
|
|
33
|
-
const onExit = () => {
|
|
34
|
-
console.log("\nGoodbye!");
|
|
35
|
-
process.exit(0);
|
|
36
|
-
};
|
|
37
|
-
const { waitUntilExit } = render(
|
|
38
|
-
React.createElement(ChatTUI, {
|
|
39
|
-
agentName: this.agentName,
|
|
40
|
-
modelName: this.modelName,
|
|
41
|
-
onMessage,
|
|
42
|
-
onExit
|
|
43
|
-
})
|
|
44
|
-
);
|
|
45
|
-
await waitUntilExit();
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
const BANNER = `
|
|
49
|
-
\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557
|
|
50
|
-
\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2554\u2550\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D
|
|
51
|
-
\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557
|
|
52
|
-
\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2550\u255D \u2588\u2588\u2554\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2588\u2588\u2551
|
|
53
|
-
\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551
|
|
54
|
-
\u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D
|
|
55
|
-
`;
|
|
56
|
-
async function main() {
|
|
57
|
-
console.log(BANNER);
|
|
58
|
-
const launcher = new TUILauncher();
|
|
59
|
-
await launcher.start();
|
|
60
|
-
}
|
|
61
|
-
main().catch(console.error);
|
|
62
|
-
export {
|
|
63
|
-
TUILauncher
|
|
64
|
-
};
|