@projectservan8n/cnapse 0.6.3 → 0.8.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.
- package/dist/ProviderSelector-MXRZFAOB.js +6 -0
- package/dist/chunk-OPX7FFL6.js +391 -0
- package/dist/index.js +882 -525
- package/package.json +17 -16
- package/src/agents/executor.ts +20 -13
- package/src/index.tsx +32 -6
- package/src/lib/tasks.ts +451 -74
- package/src/services/browser.ts +669 -0
- package/src/tools/index.ts +0 -1
- package/dist/ConfigUI-I2CJVODT.js +0 -305
- package/dist/Setup-KGYXCA7Y.js +0 -177
- package/dist/chunk-COKO6V5J.js +0 -50
- package/src/components/ConfigUI.tsx +0 -352
- package/src/components/Setup.tsx +0 -202
- package/src/lib/screen.ts +0 -118
- package/src/tools/vision.ts +0 -65
|
@@ -1,305 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getConfig,
|
|
3
|
-
setApiKey,
|
|
4
|
-
setModel,
|
|
5
|
-
setProvider
|
|
6
|
-
} from "./chunk-COKO6V5J.js";
|
|
7
|
-
|
|
8
|
-
// src/components/ConfigUI.tsx
|
|
9
|
-
import { useState, useEffect } from "react";
|
|
10
|
-
import { Box, Text, useInput, useApp } from "ink";
|
|
11
|
-
import TextInput from "ink-text-input";
|
|
12
|
-
import Spinner from "ink-spinner";
|
|
13
|
-
import { exec } from "child_process";
|
|
14
|
-
import { promisify } from "util";
|
|
15
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
16
|
-
var execAsync = promisify(exec);
|
|
17
|
-
var PROVIDERS = [
|
|
18
|
-
{
|
|
19
|
-
id: "ollama",
|
|
20
|
-
name: "Ollama",
|
|
21
|
-
description: "Local AI - Free, private, runs on your PC",
|
|
22
|
-
needsApiKey: false,
|
|
23
|
-
models: [
|
|
24
|
-
{ id: "qwen2.5:0.5b", name: "Qwen 2.5 0.5B", description: "Ultra fast, good for tasks", recommended: true },
|
|
25
|
-
{ id: "qwen2.5:1.5b", name: "Qwen 2.5 1.5B", description: "Fast, better quality" },
|
|
26
|
-
{ id: "qwen2.5:7b", name: "Qwen 2.5 7B", description: "Best quality, needs 8GB+ RAM" },
|
|
27
|
-
{ id: "llama3.2:1b", name: "Llama 3.2 1B", description: "Fast, good general use" },
|
|
28
|
-
{ id: "llama3.2:3b", name: "Llama 3.2 3B", description: "Balanced speed/quality" },
|
|
29
|
-
{ id: "codellama:7b", name: "Code Llama 7B", description: "Best for coding tasks" },
|
|
30
|
-
{ id: "llava:7b", name: "LLaVA 7B", description: "Vision model - can see images" }
|
|
31
|
-
]
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
id: "openrouter",
|
|
35
|
-
name: "OpenRouter",
|
|
36
|
-
description: "Many models, pay-per-use, great value",
|
|
37
|
-
needsApiKey: true,
|
|
38
|
-
models: [
|
|
39
|
-
{ id: "openai/gpt-5-nano", name: "GPT-5 Nano", description: "Best budget vision! $0.05/1M in", recommended: true },
|
|
40
|
-
{ id: "google/gemini-2.5-flash-lite", name: "Gemini 2.5 Flash Lite", description: "Fast reasoning, $0.10/1M in" },
|
|
41
|
-
{ id: "qwen/qwen-2.5-coder-32b-instruct", name: "Qwen 2.5 Coder 32B", description: "Best for coding, $0.07/1M" },
|
|
42
|
-
{ id: "meta-llama/llama-3.3-70b-instruct", name: "Llama 3.3 70B", description: "Powerful, $0.10/1M" },
|
|
43
|
-
{ id: "deepseek/deepseek-chat", name: "DeepSeek V3", description: "Cheap, $0.14/1M" }
|
|
44
|
-
]
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
id: "anthropic",
|
|
48
|
-
name: "Anthropic",
|
|
49
|
-
description: "Claude models - Best for complex reasoning",
|
|
50
|
-
needsApiKey: true,
|
|
51
|
-
models: [
|
|
52
|
-
{ id: "claude-3-5-sonnet-20241022", name: "Claude 3.5 Sonnet", description: "Best balance of speed/quality", recommended: true },
|
|
53
|
-
{ id: "claude-3-opus-20240229", name: "Claude 3 Opus", description: "Most capable, slower" },
|
|
54
|
-
{ id: "claude-3-haiku-20240307", name: "Claude 3 Haiku", description: "Fastest, cheapest" }
|
|
55
|
-
]
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
id: "openai",
|
|
59
|
-
name: "OpenAI",
|
|
60
|
-
description: "GPT models - Well-known, reliable",
|
|
61
|
-
needsApiKey: true,
|
|
62
|
-
models: [
|
|
63
|
-
{ id: "gpt-4o", name: "GPT-4o", description: "Latest, multimodal", recommended: true },
|
|
64
|
-
{ id: "gpt-4o-mini", name: "GPT-4o Mini", description: "Fast and cheap" },
|
|
65
|
-
{ id: "gpt-4-turbo", name: "GPT-4 Turbo", description: "Previous best" },
|
|
66
|
-
{ id: "gpt-3.5-turbo", name: "GPT-3.5 Turbo", description: "Legacy, very cheap" }
|
|
67
|
-
]
|
|
68
|
-
}
|
|
69
|
-
];
|
|
70
|
-
function ConfigUI() {
|
|
71
|
-
const { exit } = useApp();
|
|
72
|
-
const config = getConfig();
|
|
73
|
-
const [step, setStep] = useState("provider");
|
|
74
|
-
const [providerIndex, setProviderIndex] = useState(() => {
|
|
75
|
-
const idx = PROVIDERS.findIndex((p) => p.id === config.provider);
|
|
76
|
-
return idx >= 0 ? idx : 0;
|
|
77
|
-
});
|
|
78
|
-
const [modelIndex, setModelIndex] = useState(0);
|
|
79
|
-
const [apiKeyInput, setApiKeyInput] = useState("");
|
|
80
|
-
const [selectedProvider, setSelectedProvider] = useState(null);
|
|
81
|
-
const [ollamaStatus, setOllamaStatus] = useState("checking");
|
|
82
|
-
const [ollamaMessage, setOllamaMessage] = useState("");
|
|
83
|
-
useInput((input, key) => {
|
|
84
|
-
if (key.escape) {
|
|
85
|
-
exit();
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
if (step === "provider") {
|
|
89
|
-
if (key.upArrow) {
|
|
90
|
-
setProviderIndex((prev) => prev > 0 ? prev - 1 : PROVIDERS.length - 1);
|
|
91
|
-
} else if (key.downArrow) {
|
|
92
|
-
setProviderIndex((prev) => prev < PROVIDERS.length - 1 ? prev + 1 : 0);
|
|
93
|
-
} else if (key.return) {
|
|
94
|
-
const provider = PROVIDERS[providerIndex];
|
|
95
|
-
setSelectedProvider(provider);
|
|
96
|
-
setProvider(provider.id);
|
|
97
|
-
const recommendedIdx = provider.models.findIndex((m) => m.recommended);
|
|
98
|
-
setModelIndex(recommendedIdx >= 0 ? recommendedIdx : 0);
|
|
99
|
-
if (provider.needsApiKey) {
|
|
100
|
-
const apiKeyProvider = provider.id;
|
|
101
|
-
if (!config.apiKeys[apiKeyProvider]) {
|
|
102
|
-
setStep("apiKey");
|
|
103
|
-
} else {
|
|
104
|
-
setStep("model");
|
|
105
|
-
}
|
|
106
|
-
} else {
|
|
107
|
-
setStep("model");
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
} else if (step === "model" && selectedProvider) {
|
|
111
|
-
if (key.upArrow) {
|
|
112
|
-
setModelIndex((prev) => prev > 0 ? prev - 1 : selectedProvider.models.length - 1);
|
|
113
|
-
} else if (key.downArrow) {
|
|
114
|
-
setModelIndex((prev) => prev < selectedProvider.models.length - 1 ? prev + 1 : 0);
|
|
115
|
-
} else if (key.return) {
|
|
116
|
-
const model = selectedProvider.models[modelIndex];
|
|
117
|
-
setModel(model.id);
|
|
118
|
-
if (selectedProvider.id === "ollama") {
|
|
119
|
-
setStep("ollamaCheck");
|
|
120
|
-
} else {
|
|
121
|
-
setStep("done");
|
|
122
|
-
setTimeout(() => exit(), 2e3);
|
|
123
|
-
}
|
|
124
|
-
} else if (key.leftArrow || input === "b") {
|
|
125
|
-
setStep("provider");
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
const handleApiKeySubmit = (value) => {
|
|
130
|
-
if (value.trim() && selectedProvider) {
|
|
131
|
-
setApiKey(selectedProvider.id, value.trim());
|
|
132
|
-
setStep("model");
|
|
133
|
-
}
|
|
134
|
-
};
|
|
135
|
-
useEffect(() => {
|
|
136
|
-
if (step !== "ollamaCheck" || !selectedProvider) return;
|
|
137
|
-
const modelId = selectedProvider.models[modelIndex].id;
|
|
138
|
-
async function checkAndRunOllama() {
|
|
139
|
-
try {
|
|
140
|
-
setOllamaStatus("checking");
|
|
141
|
-
setOllamaMessage("Checking Ollama...");
|
|
142
|
-
try {
|
|
143
|
-
await execAsync("ollama list", { timeout: 5e3 });
|
|
144
|
-
} catch {
|
|
145
|
-
setOllamaStatus("error");
|
|
146
|
-
setOllamaMessage("Ollama not found. Install from https://ollama.ai");
|
|
147
|
-
setTimeout(() => exit(), 3e3);
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
150
|
-
const { stdout } = await execAsync("ollama list");
|
|
151
|
-
const modelName = modelId.split(":")[0];
|
|
152
|
-
const hasModel = stdout.toLowerCase().includes(modelName.toLowerCase());
|
|
153
|
-
if (!hasModel) {
|
|
154
|
-
setOllamaStatus("pulling");
|
|
155
|
-
setOllamaMessage(`Downloading ${modelId}... (this may take a few minutes)`);
|
|
156
|
-
await execAsync(`ollama pull ${modelId}`, { timeout: 6e5 });
|
|
157
|
-
}
|
|
158
|
-
setOllamaStatus("running");
|
|
159
|
-
setOllamaMessage(`Starting ${modelId}...`);
|
|
160
|
-
await execAsync(`ollama run ${modelId} "Hello" --nowordwrap`, { timeout: 12e4 });
|
|
161
|
-
setOllamaStatus("ready");
|
|
162
|
-
setOllamaMessage(`${modelId} is ready!`);
|
|
163
|
-
setStep("done");
|
|
164
|
-
setTimeout(() => exit(), 2e3);
|
|
165
|
-
} catch (err) {
|
|
166
|
-
setOllamaStatus("error");
|
|
167
|
-
setOllamaMessage(`Error: ${err instanceof Error ? err.message : "Unknown error"}`);
|
|
168
|
-
setTimeout(() => exit(), 3e3);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
checkAndRunOllama();
|
|
172
|
-
}, [step, selectedProvider, modelIndex, exit]);
|
|
173
|
-
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", padding: 1, children: [
|
|
174
|
-
/* @__PURE__ */ jsx(Box, { marginBottom: 1, children: /* @__PURE__ */ jsx(Text, { bold: true, color: "cyan", children: "C-napse Configuration" }) }),
|
|
175
|
-
step === "provider" && /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
176
|
-
/* @__PURE__ */ jsx(Text, { bold: true, children: "Select AI Provider:" }),
|
|
177
|
-
/* @__PURE__ */ jsx(Text, { color: "gray", dimColor: true, children: "(Use arrows, Enter to select, Esc to cancel)" }),
|
|
178
|
-
/* @__PURE__ */ jsx(Box, { marginTop: 1, flexDirection: "column", children: PROVIDERS.map((p, i) => {
|
|
179
|
-
const isSelected = i === providerIndex;
|
|
180
|
-
const isCurrent = p.id === config.provider;
|
|
181
|
-
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
182
|
-
/* @__PURE__ */ jsxs(Text, { color: isSelected ? "cyan" : "white", children: [
|
|
183
|
-
isSelected ? "\u276F " : " ",
|
|
184
|
-
/* @__PURE__ */ jsx(Text, { bold: isSelected, children: p.name }),
|
|
185
|
-
isCurrent && /* @__PURE__ */ jsx(Text, { color: "green", children: " (current)" }),
|
|
186
|
-
p.needsApiKey && p.id !== "ollama" && config.apiKeys[p.id] && /* @__PURE__ */ jsx(Text, { color: "yellow", children: " (key saved)" })
|
|
187
|
-
] }),
|
|
188
|
-
isSelected && /* @__PURE__ */ jsxs(Text, { color: "gray", children: [
|
|
189
|
-
" ",
|
|
190
|
-
p.description
|
|
191
|
-
] })
|
|
192
|
-
] }, p.id);
|
|
193
|
-
}) })
|
|
194
|
-
] }),
|
|
195
|
-
step === "apiKey" && selectedProvider && /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
196
|
-
/* @__PURE__ */ jsxs(Text, { children: [
|
|
197
|
-
/* @__PURE__ */ jsx(Text, { color: "green", children: "\u2713" }),
|
|
198
|
-
" Provider: ",
|
|
199
|
-
/* @__PURE__ */ jsx(Text, { bold: true, children: selectedProvider.name })
|
|
200
|
-
] }),
|
|
201
|
-
/* @__PURE__ */ jsxs(Box, { marginTop: 1, flexDirection: "column", children: [
|
|
202
|
-
/* @__PURE__ */ jsxs(Text, { bold: true, children: [
|
|
203
|
-
"Enter your ",
|
|
204
|
-
selectedProvider.name,
|
|
205
|
-
" API key:"
|
|
206
|
-
] }),
|
|
207
|
-
/* @__PURE__ */ jsxs(Text, { color: "gray", dimColor: true, children: [
|
|
208
|
-
selectedProvider.id === "openrouter" && "Get key at: https://openrouter.ai/keys",
|
|
209
|
-
selectedProvider.id === "anthropic" && "Get key at: https://console.anthropic.com",
|
|
210
|
-
selectedProvider.id === "openai" && "Get key at: https://platform.openai.com/api-keys"
|
|
211
|
-
] }),
|
|
212
|
-
/* @__PURE__ */ jsxs(Box, { marginTop: 1, children: [
|
|
213
|
-
/* @__PURE__ */ jsx(Text, { color: "cyan", children: "\u276F " }),
|
|
214
|
-
/* @__PURE__ */ jsx(
|
|
215
|
-
TextInput,
|
|
216
|
-
{
|
|
217
|
-
value: apiKeyInput,
|
|
218
|
-
onChange: setApiKeyInput,
|
|
219
|
-
onSubmit: handleApiKeySubmit,
|
|
220
|
-
mask: "*"
|
|
221
|
-
}
|
|
222
|
-
)
|
|
223
|
-
] })
|
|
224
|
-
] })
|
|
225
|
-
] }),
|
|
226
|
-
step === "model" && selectedProvider && /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
227
|
-
/* @__PURE__ */ jsxs(Text, { children: [
|
|
228
|
-
/* @__PURE__ */ jsx(Text, { color: "green", children: "\u2713" }),
|
|
229
|
-
" Provider: ",
|
|
230
|
-
/* @__PURE__ */ jsx(Text, { bold: true, children: selectedProvider.name })
|
|
231
|
-
] }),
|
|
232
|
-
selectedProvider.needsApiKey && /* @__PURE__ */ jsxs(Text, { children: [
|
|
233
|
-
/* @__PURE__ */ jsx(Text, { color: "green", children: "\u2713" }),
|
|
234
|
-
" API Key: ",
|
|
235
|
-
/* @__PURE__ */ jsx(Text, { bold: true, children: "configured" })
|
|
236
|
-
] }),
|
|
237
|
-
/* @__PURE__ */ jsxs(Box, { marginTop: 1, flexDirection: "column", children: [
|
|
238
|
-
/* @__PURE__ */ jsx(Text, { bold: true, children: "Select Model:" }),
|
|
239
|
-
/* @__PURE__ */ jsx(Text, { color: "gray", dimColor: true, children: "(Arrows to navigate, Enter to select, B to go back)" }),
|
|
240
|
-
/* @__PURE__ */ jsx(Box, { marginTop: 1, flexDirection: "column", children: selectedProvider.models.map((model, i) => {
|
|
241
|
-
const isSelected = i === modelIndex;
|
|
242
|
-
const isCurrent = model.id === config.model && selectedProvider.id === config.provider;
|
|
243
|
-
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
244
|
-
/* @__PURE__ */ jsxs(Text, { color: isSelected ? "cyan" : "white", children: [
|
|
245
|
-
isSelected ? "\u276F " : " ",
|
|
246
|
-
/* @__PURE__ */ jsx(Text, { bold: isSelected, children: model.name }),
|
|
247
|
-
model.recommended && /* @__PURE__ */ jsx(Text, { color: "yellow", children: " *" }),
|
|
248
|
-
isCurrent && /* @__PURE__ */ jsx(Text, { color: "green", children: " (current)" })
|
|
249
|
-
] }),
|
|
250
|
-
isSelected && /* @__PURE__ */ jsxs(Text, { color: "gray", children: [
|
|
251
|
-
" ",
|
|
252
|
-
model.description
|
|
253
|
-
] })
|
|
254
|
-
] }, model.id);
|
|
255
|
-
}) }),
|
|
256
|
-
/* @__PURE__ */ jsx(Box, { marginTop: 1, children: /* @__PURE__ */ jsx(Text, { color: "gray", dimColor: true, children: "* = Recommended for C-napse" }) })
|
|
257
|
-
] })
|
|
258
|
-
] }),
|
|
259
|
-
step === "ollamaCheck" && selectedProvider && /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
260
|
-
/* @__PURE__ */ jsxs(Text, { children: [
|
|
261
|
-
/* @__PURE__ */ jsx(Text, { color: "green", children: "\u2713" }),
|
|
262
|
-
" Provider: ",
|
|
263
|
-
/* @__PURE__ */ jsx(Text, { bold: true, children: selectedProvider.name })
|
|
264
|
-
] }),
|
|
265
|
-
/* @__PURE__ */ jsxs(Text, { children: [
|
|
266
|
-
/* @__PURE__ */ jsx(Text, { color: "green", children: "\u2713" }),
|
|
267
|
-
" Model: ",
|
|
268
|
-
/* @__PURE__ */ jsx(Text, { bold: true, children: selectedProvider.models[modelIndex]?.name })
|
|
269
|
-
] }),
|
|
270
|
-
/* @__PURE__ */ jsx(Box, { marginTop: 1, children: ollamaStatus === "error" ? /* @__PURE__ */ jsxs(Text, { color: "red", children: [
|
|
271
|
-
"\u2717 ",
|
|
272
|
-
ollamaMessage
|
|
273
|
-
] }) : ollamaStatus === "ready" ? /* @__PURE__ */ jsxs(Text, { color: "green", children: [
|
|
274
|
-
"\u2713 ",
|
|
275
|
-
ollamaMessage
|
|
276
|
-
] }) : /* @__PURE__ */ jsxs(Text, { children: [
|
|
277
|
-
/* @__PURE__ */ jsx(Text, { color: "cyan", children: /* @__PURE__ */ jsx(Spinner, { type: "dots" }) }),
|
|
278
|
-
" ",
|
|
279
|
-
ollamaMessage
|
|
280
|
-
] }) })
|
|
281
|
-
] }),
|
|
282
|
-
step === "done" && selectedProvider && /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
283
|
-
/* @__PURE__ */ jsxs(Text, { children: [
|
|
284
|
-
/* @__PURE__ */ jsx(Text, { color: "green", children: "\u2713" }),
|
|
285
|
-
" Provider: ",
|
|
286
|
-
/* @__PURE__ */ jsx(Text, { bold: true, children: selectedProvider.name })
|
|
287
|
-
] }),
|
|
288
|
-
selectedProvider.needsApiKey && /* @__PURE__ */ jsxs(Text, { children: [
|
|
289
|
-
/* @__PURE__ */ jsx(Text, { color: "green", children: "\u2713" }),
|
|
290
|
-
" API Key: ",
|
|
291
|
-
/* @__PURE__ */ jsx(Text, { bold: true, children: "configured" })
|
|
292
|
-
] }),
|
|
293
|
-
/* @__PURE__ */ jsxs(Text, { children: [
|
|
294
|
-
/* @__PURE__ */ jsx(Text, { color: "green", children: "\u2713" }),
|
|
295
|
-
" Model: ",
|
|
296
|
-
/* @__PURE__ */ jsx(Text, { bold: true, children: selectedProvider.models[modelIndex]?.name })
|
|
297
|
-
] }),
|
|
298
|
-
/* @__PURE__ */ jsx(Box, { marginTop: 1, children: /* @__PURE__ */ jsx(Text, { color: "green", bold: true, children: "Configuration saved! Run `cnapse` to start." }) })
|
|
299
|
-
] }),
|
|
300
|
-
/* @__PURE__ */ jsx(Box, { marginTop: 2, children: /* @__PURE__ */ jsx(Text, { color: "gray", dimColor: true, children: "Press Esc to cancel" }) })
|
|
301
|
-
] });
|
|
302
|
-
}
|
|
303
|
-
export {
|
|
304
|
-
ConfigUI
|
|
305
|
-
};
|
package/dist/Setup-KGYXCA7Y.js
DELETED
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
setApiKey,
|
|
3
|
-
setModel,
|
|
4
|
-
setProvider
|
|
5
|
-
} from "./chunk-COKO6V5J.js";
|
|
6
|
-
|
|
7
|
-
// src/components/Setup.tsx
|
|
8
|
-
import { useState } from "react";
|
|
9
|
-
import { Box, Text, useInput, useApp } from "ink";
|
|
10
|
-
import TextInput from "ink-text-input";
|
|
11
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
-
var PROVIDERS = [
|
|
13
|
-
{ id: "ollama", name: "Ollama", desc: "Local AI (free, no API key needed)" },
|
|
14
|
-
{ id: "openrouter", name: "OpenRouter", desc: "Many models, pay per use" },
|
|
15
|
-
{ id: "anthropic", name: "Anthropic", desc: "Claude models" },
|
|
16
|
-
{ id: "openai", name: "OpenAI", desc: "GPT models" }
|
|
17
|
-
];
|
|
18
|
-
var DEFAULT_MODELS = {
|
|
19
|
-
ollama: ["qwen2.5:0.5b", "qwen2.5:7b", "llama3.2:3b", "codellama:7b"],
|
|
20
|
-
openrouter: [
|
|
21
|
-
"openai/gpt-5-nano",
|
|
22
|
-
// $0.05/1M - Best budget + vision!
|
|
23
|
-
"google/gemini-2.5-flash-lite",
|
|
24
|
-
// $0.10/1M - Fast reasoning
|
|
25
|
-
"qwen/qwen-2.5-coder-32b-instruct",
|
|
26
|
-
// $0.07/1M - Best for coding
|
|
27
|
-
"meta-llama/llama-3.3-70b-instruct"
|
|
28
|
-
// $0.10/1M
|
|
29
|
-
],
|
|
30
|
-
anthropic: [
|
|
31
|
-
"claude-3-5-sonnet-20241022",
|
|
32
|
-
"claude-3-haiku-20240307"
|
|
33
|
-
],
|
|
34
|
-
openai: ["gpt-4o-mini", "gpt-3.5-turbo"]
|
|
35
|
-
};
|
|
36
|
-
function Setup() {
|
|
37
|
-
const { exit } = useApp();
|
|
38
|
-
const [step, setStep] = useState("provider");
|
|
39
|
-
const [selectedProvider, setSelectedProvider] = useState(0);
|
|
40
|
-
const [selectedModel, setSelectedModel] = useState(0);
|
|
41
|
-
const [apiKey, setApiKeyInput] = useState("");
|
|
42
|
-
const [provider, setProviderState] = useState("ollama");
|
|
43
|
-
useInput((input, key) => {
|
|
44
|
-
if (key.escape) {
|
|
45
|
-
exit();
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
if (step === "provider") {
|
|
49
|
-
if (key.upArrow) {
|
|
50
|
-
setSelectedProvider((prev) => prev > 0 ? prev - 1 : PROVIDERS.length - 1);
|
|
51
|
-
} else if (key.downArrow) {
|
|
52
|
-
setSelectedProvider((prev) => prev < PROVIDERS.length - 1 ? prev + 1 : 0);
|
|
53
|
-
} else if (key.return) {
|
|
54
|
-
const selected = PROVIDERS[selectedProvider];
|
|
55
|
-
setProviderState(selected.id);
|
|
56
|
-
setProvider(selected.id);
|
|
57
|
-
if (selected.id === "ollama") {
|
|
58
|
-
setStep("model");
|
|
59
|
-
} else {
|
|
60
|
-
setStep("apiKey");
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
} else if (step === "model") {
|
|
64
|
-
const models = DEFAULT_MODELS[provider] || [];
|
|
65
|
-
if (key.upArrow) {
|
|
66
|
-
setSelectedModel((prev) => prev > 0 ? prev - 1 : models.length - 1);
|
|
67
|
-
} else if (key.downArrow) {
|
|
68
|
-
setSelectedModel((prev) => prev < models.length - 1 ? prev + 1 : 0);
|
|
69
|
-
} else if (key.return) {
|
|
70
|
-
const model = models[selectedModel];
|
|
71
|
-
setModel(model);
|
|
72
|
-
setStep("done");
|
|
73
|
-
setTimeout(() => exit(), 1500);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
const handleApiKeySubmit = (value) => {
|
|
78
|
-
if (value.trim()) {
|
|
79
|
-
setApiKey(provider, value.trim());
|
|
80
|
-
setApiKeyInput(value);
|
|
81
|
-
setStep("model");
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", padding: 1, children: [
|
|
85
|
-
/* @__PURE__ */ jsx(Box, { marginBottom: 1, children: /* @__PURE__ */ jsx(Text, { bold: true, color: "cyan", children: "\u{1F680} C-napse Setup" }) }),
|
|
86
|
-
step === "provider" && /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
87
|
-
/* @__PURE__ */ jsx(Text, { bold: true, children: "Select AI Provider:" }),
|
|
88
|
-
/* @__PURE__ */ jsx(Text, { color: "gray", dimColor: true, children: "(Use \u2191\u2193 arrows, Enter to select)" }),
|
|
89
|
-
/* @__PURE__ */ jsx(Box, { marginTop: 1, flexDirection: "column", children: PROVIDERS.map((p, i) => /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsxs(Text, { color: i === selectedProvider ? "cyan" : "white", children: [
|
|
90
|
-
i === selectedProvider ? "\u276F " : " ",
|
|
91
|
-
/* @__PURE__ */ jsx(Text, { bold: i === selectedProvider, children: p.name }),
|
|
92
|
-
/* @__PURE__ */ jsxs(Text, { color: "gray", children: [
|
|
93
|
-
" - ",
|
|
94
|
-
p.desc
|
|
95
|
-
] })
|
|
96
|
-
] }) }, p.id)) })
|
|
97
|
-
] }),
|
|
98
|
-
step === "apiKey" && /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
99
|
-
/* @__PURE__ */ jsxs(Text, { children: [
|
|
100
|
-
/* @__PURE__ */ jsx(Text, { color: "green", children: "\u2713" }),
|
|
101
|
-
" Provider: ",
|
|
102
|
-
/* @__PURE__ */ jsx(Text, { bold: true, children: provider })
|
|
103
|
-
] }),
|
|
104
|
-
/* @__PURE__ */ jsxs(Box, { marginTop: 1, flexDirection: "column", children: [
|
|
105
|
-
/* @__PURE__ */ jsxs(Text, { bold: true, children: [
|
|
106
|
-
"Enter your ",
|
|
107
|
-
provider,
|
|
108
|
-
" API key:"
|
|
109
|
-
] }),
|
|
110
|
-
/* @__PURE__ */ jsx(Text, { color: "gray", dimColor: true, children: "(Paste with Ctrl+V or right-click, then Enter)" }),
|
|
111
|
-
/* @__PURE__ */ jsxs(Box, { marginTop: 1, children: [
|
|
112
|
-
/* @__PURE__ */ jsx(Text, { color: "cyan", children: "\u276F " }),
|
|
113
|
-
/* @__PURE__ */ jsx(
|
|
114
|
-
TextInput,
|
|
115
|
-
{
|
|
116
|
-
value: apiKey,
|
|
117
|
-
onChange: setApiKeyInput,
|
|
118
|
-
onSubmit: handleApiKeySubmit,
|
|
119
|
-
mask: "*"
|
|
120
|
-
}
|
|
121
|
-
)
|
|
122
|
-
] })
|
|
123
|
-
] })
|
|
124
|
-
] }),
|
|
125
|
-
step === "model" && /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
126
|
-
/* @__PURE__ */ jsxs(Text, { children: [
|
|
127
|
-
/* @__PURE__ */ jsx(Text, { color: "green", children: "\u2713" }),
|
|
128
|
-
" Provider: ",
|
|
129
|
-
/* @__PURE__ */ jsx(Text, { bold: true, children: provider })
|
|
130
|
-
] }),
|
|
131
|
-
provider !== "ollama" && /* @__PURE__ */ jsxs(Text, { children: [
|
|
132
|
-
/* @__PURE__ */ jsx(Text, { color: "green", children: "\u2713" }),
|
|
133
|
-
" API Key: ",
|
|
134
|
-
/* @__PURE__ */ jsx(Text, { bold: true, children: "saved" })
|
|
135
|
-
] }),
|
|
136
|
-
/* @__PURE__ */ jsxs(Box, { marginTop: 1, flexDirection: "column", children: [
|
|
137
|
-
/* @__PURE__ */ jsx(Text, { bold: true, children: "Select Model:" }),
|
|
138
|
-
/* @__PURE__ */ jsx(Text, { color: "gray", dimColor: true, children: "(Use \u2191\u2193 arrows, Enter to select)" }),
|
|
139
|
-
/* @__PURE__ */ jsx(Box, { marginTop: 1, flexDirection: "column", children: (DEFAULT_MODELS[provider] || []).map((model, i) => /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsxs(Text, { color: i === selectedModel ? "cyan" : "white", children: [
|
|
140
|
-
i === selectedModel ? "\u276F " : " ",
|
|
141
|
-
/* @__PURE__ */ jsx(Text, { bold: i === selectedModel, children: model })
|
|
142
|
-
] }) }, model)) })
|
|
143
|
-
] })
|
|
144
|
-
] }),
|
|
145
|
-
step === "done" && /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
146
|
-
/* @__PURE__ */ jsxs(Text, { children: [
|
|
147
|
-
/* @__PURE__ */ jsx(Text, { color: "green", children: "\u2713" }),
|
|
148
|
-
" Provider: ",
|
|
149
|
-
/* @__PURE__ */ jsx(Text, { bold: true, children: provider })
|
|
150
|
-
] }),
|
|
151
|
-
provider !== "ollama" && /* @__PURE__ */ jsxs(Text, { children: [
|
|
152
|
-
/* @__PURE__ */ jsx(Text, { color: "green", children: "\u2713" }),
|
|
153
|
-
" API Key: ",
|
|
154
|
-
/* @__PURE__ */ jsx(Text, { bold: true, children: "saved" })
|
|
155
|
-
] }),
|
|
156
|
-
/* @__PURE__ */ jsxs(Text, { children: [
|
|
157
|
-
/* @__PURE__ */ jsx(Text, { color: "green", children: "\u2713" }),
|
|
158
|
-
" Model:",
|
|
159
|
-
" ",
|
|
160
|
-
/* @__PURE__ */ jsx(Text, { bold: true, children: DEFAULT_MODELS[provider]?.[selectedModel] })
|
|
161
|
-
] }),
|
|
162
|
-
/* @__PURE__ */ jsx(Box, { marginTop: 1, children: /* @__PURE__ */ jsx(Text, { color: "green", bold: true, children: "\u2705 Setup complete! Run `cnapse` to start chatting." }) }),
|
|
163
|
-
provider === "ollama" && /* @__PURE__ */ jsxs(Box, { marginTop: 1, flexDirection: "column", children: [
|
|
164
|
-
/* @__PURE__ */ jsx(Text, { color: "yellow", children: "Note: Make sure the model is downloaded. Run:" }),
|
|
165
|
-
/* @__PURE__ */ jsxs(Text, { color: "cyan", children: [
|
|
166
|
-
" ",
|
|
167
|
-
"ollama pull ",
|
|
168
|
-
DEFAULT_MODELS[provider]?.[selectedModel]
|
|
169
|
-
] })
|
|
170
|
-
] })
|
|
171
|
-
] }),
|
|
172
|
-
/* @__PURE__ */ jsx(Box, { marginTop: 2, children: /* @__PURE__ */ jsx(Text, { color: "gray", dimColor: true, children: "Press Esc to cancel" }) })
|
|
173
|
-
] });
|
|
174
|
-
}
|
|
175
|
-
export {
|
|
176
|
-
Setup
|
|
177
|
-
};
|
package/dist/chunk-COKO6V5J.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
// src/lib/config.ts
|
|
2
|
-
import Conf from "conf";
|
|
3
|
-
var config = new Conf({
|
|
4
|
-
projectName: "cnapse",
|
|
5
|
-
defaults: {
|
|
6
|
-
provider: "ollama",
|
|
7
|
-
model: "qwen2.5:0.5b",
|
|
8
|
-
apiKeys: {},
|
|
9
|
-
ollamaHost: "http://localhost:11434",
|
|
10
|
-
openrouter: {
|
|
11
|
-
siteUrl: "https://github.com/projectservan8n/C-napse",
|
|
12
|
-
appName: "C-napse"
|
|
13
|
-
},
|
|
14
|
-
telegram: {
|
|
15
|
-
enabled: false
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
function getConfig() {
|
|
20
|
-
return {
|
|
21
|
-
provider: config.get("provider"),
|
|
22
|
-
model: config.get("model"),
|
|
23
|
-
apiKeys: config.get("apiKeys"),
|
|
24
|
-
ollamaHost: config.get("ollamaHost"),
|
|
25
|
-
openrouter: config.get("openrouter"),
|
|
26
|
-
telegram: config.get("telegram")
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
function setProvider(provider) {
|
|
30
|
-
config.set("provider", provider);
|
|
31
|
-
}
|
|
32
|
-
function setModel(model) {
|
|
33
|
-
config.set("model", model);
|
|
34
|
-
}
|
|
35
|
-
function setApiKey(provider, key) {
|
|
36
|
-
const keys = config.get("apiKeys");
|
|
37
|
-
keys[provider] = key;
|
|
38
|
-
config.set("apiKeys", keys);
|
|
39
|
-
}
|
|
40
|
-
function getApiKey(provider) {
|
|
41
|
-
return config.get("apiKeys")[provider];
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export {
|
|
45
|
-
getConfig,
|
|
46
|
-
setProvider,
|
|
47
|
-
setModel,
|
|
48
|
-
setApiKey,
|
|
49
|
-
getApiKey
|
|
50
|
-
};
|