koneck 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.
- package/LICENSE +21 -0
- package/README.md +109 -0
- package/dist/astValidator.d.ts +6 -0
- package/dist/astValidator.d.ts.map +1 -0
- package/dist/astValidator.js +57 -0
- package/dist/astValidator.js.map +1 -0
- package/dist/chat.d.ts +3 -0
- package/dist/chat.d.ts.map +1 -0
- package/dist/chat.js +205 -0
- package/dist/chat.js.map +1 -0
- package/dist/completion.d.ts +2 -0
- package/dist/completion.d.ts.map +1 -0
- package/dist/completion.js +137 -0
- package/dist/completion.js.map +1 -0
- package/dist/compressor.d.ts +9 -0
- package/dist/compressor.d.ts.map +1 -0
- package/dist/compressor.js +71 -0
- package/dist/compressor.js.map +1 -0
- package/dist/config.d.ts +14 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +40 -0
- package/dist/config.js.map +1 -0
- package/dist/doctor.d.ts +2 -0
- package/dist/doctor.d.ts.map +1 -0
- package/dist/doctor.js +99 -0
- package/dist/doctor.js.map +1 -0
- package/dist/engine.d.ts +11 -0
- package/dist/engine.d.ts.map +1 -0
- package/dist/engine.js +510 -0
- package/dist/engine.js.map +1 -0
- package/dist/generate-koneck-md.d.ts +3 -0
- package/dist/generate-koneck-md.d.ts.map +1 -0
- package/dist/generate-koneck-md.js +69 -0
- package/dist/generate-koneck-md.js.map +1 -0
- package/dist/git-tools.d.ts +4 -0
- package/dist/git-tools.d.ts.map +1 -0
- package/dist/git-tools.js +206 -0
- package/dist/git-tools.js.map +1 -0
- package/dist/highlight.d.ts +3 -0
- package/dist/highlight.d.ts.map +1 -0
- package/dist/highlight.js +139 -0
- package/dist/highlight.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +448 -0
- package/dist/index.js.map +1 -0
- package/dist/init.d.ts +9 -0
- package/dist/init.d.ts.map +1 -0
- package/dist/init.js +93 -0
- package/dist/init.js.map +1 -0
- package/dist/mcp.d.ts +24 -0
- package/dist/mcp.d.ts.map +1 -0
- package/dist/mcp.js +75 -0
- package/dist/mcp.js.map +1 -0
- package/dist/memory.d.ts +3 -0
- package/dist/memory.d.ts.map +1 -0
- package/dist/memory.js +18 -0
- package/dist/memory.js.map +1 -0
- package/dist/plugins.d.ts +9 -0
- package/dist/plugins.d.ts.map +1 -0
- package/dist/plugins.js +60 -0
- package/dist/plugins.js.map +1 -0
- package/dist/pricing.d.ts +9 -0
- package/dist/pricing.d.ts.map +1 -0
- package/dist/pricing.js +84 -0
- package/dist/pricing.js.map +1 -0
- package/dist/project.d.ts +14 -0
- package/dist/project.d.ts.map +1 -0
- package/dist/project.js +151 -0
- package/dist/project.js.map +1 -0
- package/dist/providers.d.ts +13 -0
- package/dist/providers.d.ts.map +1 -0
- package/dist/providers.js +130 -0
- package/dist/providers.js.map +1 -0
- package/dist/session.d.ts +19 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +71 -0
- package/dist/session.js.map +1 -0
- package/dist/setup.d.ts +4 -0
- package/dist/setup.d.ts.map +1 -0
- package/dist/setup.js +63 -0
- package/dist/setup.js.map +1 -0
- package/dist/stats.d.ts +2 -0
- package/dist/stats.d.ts.map +1 -0
- package/dist/stats.js +81 -0
- package/dist/stats.js.map +1 -0
- package/dist/tools.d.ts +17 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +713 -0
- package/dist/tools.js.map +1 -0
- package/dist/tui.d.ts +38 -0
- package/dist/tui.d.ts.map +1 -0
- package/dist/tui.js +364 -0
- package/dist/tui.js.map +1 -0
- package/dist/types.d.ts +158 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/watch.d.ts +3 -0
- package/dist/watch.d.ts.map +1 -0
- package/dist/watch.js +68 -0
- package/dist/watch.js.map +1 -0
- package/dist/worktree.d.ts +8 -0
- package/dist/worktree.d.ts.map +1 -0
- package/dist/worktree.js +94 -0
- package/dist/worktree.js.map +1 -0
- package/package.json +67 -0
package/dist/mcp.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
2
|
+
import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
|
|
3
|
+
import fs from 'fs/promises';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
export async function loadMCPConfig(cwd) {
|
|
6
|
+
try {
|
|
7
|
+
const raw = await fs.readFile(path.join(cwd, '.koneck', 'mcp.json'), 'utf-8');
|
|
8
|
+
return JSON.parse(raw);
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function resolveEnv(env) {
|
|
15
|
+
const result = {};
|
|
16
|
+
for (const [k, v] of Object.entries(env)) {
|
|
17
|
+
result[k] = v.replace(/\$\{([^}]+)\}/g, (_, name) => process.env[name] ?? '');
|
|
18
|
+
}
|
|
19
|
+
return result;
|
|
20
|
+
}
|
|
21
|
+
export async function connectMCPServers(mcpConfig) {
|
|
22
|
+
const entries = [];
|
|
23
|
+
for (const [serverName, serverConfig] of Object.entries(mcpConfig.servers)) {
|
|
24
|
+
try {
|
|
25
|
+
const transport = new StdioClientTransport({
|
|
26
|
+
command: serverConfig.command,
|
|
27
|
+
args: serverConfig.args ?? [],
|
|
28
|
+
env: {
|
|
29
|
+
...process.env,
|
|
30
|
+
...resolveEnv(serverConfig.env ?? {}),
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
const client = new Client({ name: 'koneck', version: '1.0.0' }, { capabilities: {} });
|
|
34
|
+
await client.connect(transport);
|
|
35
|
+
const { tools } = await client.listTools();
|
|
36
|
+
entries.push({
|
|
37
|
+
serverName,
|
|
38
|
+
client,
|
|
39
|
+
tools: tools.map(t => ({
|
|
40
|
+
name: t.name,
|
|
41
|
+
description: t.description,
|
|
42
|
+
inputSchema: t.inputSchema,
|
|
43
|
+
})),
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
catch (err) {
|
|
47
|
+
process.stderr.write(` [MCP] Failed to connect "${serverName}": ${err instanceof Error ? err.message : String(err)}\n`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return entries;
|
|
51
|
+
}
|
|
52
|
+
export async function callMCPTool(serverName, toolName, args, clients) {
|
|
53
|
+
const entry = clients.find(e => e.serverName === serverName);
|
|
54
|
+
if (!entry)
|
|
55
|
+
return `ERROR: MCP server "${serverName}" is not connected.`;
|
|
56
|
+
try {
|
|
57
|
+
const result = await entry.client.callTool({ name: toolName, arguments: args });
|
|
58
|
+
const content = result.content;
|
|
59
|
+
if (result.isError) {
|
|
60
|
+
const msg = content.filter(c => c.type === 'text').map(c => c.text ?? '').join('\n');
|
|
61
|
+
return `ERROR: MCP tool "${toolName}" returned error: ${msg}`;
|
|
62
|
+
}
|
|
63
|
+
return (content
|
|
64
|
+
.filter(c => c.type === 'text')
|
|
65
|
+
.map(c => c.text ?? '')
|
|
66
|
+
.join('\n') || '(no output)');
|
|
67
|
+
}
|
|
68
|
+
catch (err) {
|
|
69
|
+
return `ERROR: ${err instanceof Error ? err.message : String(err)}`;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
export async function disconnectMCPServers(clients) {
|
|
73
|
+
await Promise.allSettled(clients.map(e => e.client.close()));
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=mcp.js.map
|
package/dist/mcp.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp.js","sourceRoot":"","sources":["../src/mcp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AAwBxB,MAAM,CAAC,KAAK,UAAU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AAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,EACf,QAAQ,SAAU,GACjB,OAAO,CAAC,IAAI,CAAC,CAKf"}
|
package/dist/memory.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import fs from 'fs/promises';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
const MEMORY_FILE = '.koneck/MEMORY.md';
|
|
4
|
+
export async function loadMemory(cwd) {
|
|
5
|
+
try {
|
|
6
|
+
return await fs.readFile(path.join(cwd, MEMORY_FILE), 'utf-8');
|
|
7
|
+
}
|
|
8
|
+
catch {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export async function appendMemory(cwd, content, category = 'notes') {
|
|
13
|
+
const file = path.join(cwd, MEMORY_FILE);
|
|
14
|
+
await fs.mkdir(path.dirname(file), { recursive: true });
|
|
15
|
+
const date = new Date().toISOString().slice(0, 10);
|
|
16
|
+
await fs.appendFile(file, `\n## [${date}] ${category}\n${content}\n`, 'utf-8');
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=memory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory.js","sourceRoot":"","sources":["../src/memory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,MAAM,WAAW,GAAG,mBAAmB,CAAC;AAExC,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,GAAW;IAC1C,IAAI,CAAC;QACH,OAAO,MAAM,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC,EAAE,OAAO,CAAC,CAAC;IACjE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,GAAW,EACX,OAAe,EACf,QAAQ,GAAG,OAAO;IAElB,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;IACzC,MAAM,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACxD,MAAM,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACnD,MAAM,EAAE,CAAC,UAAU,CAAC,IAAI,EAAE,SAAS,IAAI,KAAK,QAAQ,KAAK,OAAO,IAAI,EAAE,OAAO,CAAC,CAAC;AACjF,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ToolDefinition } from './types.js';
|
|
2
|
+
export interface PluginEntry {
|
|
3
|
+
definition: ToolDefinition;
|
|
4
|
+
handler: (args: unknown, cwd: string) => Promise<string>;
|
|
5
|
+
file: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function loadPlugins(cwd: string): Promise<PluginEntry[]>;
|
|
8
|
+
export declare function callPlugin(name: string, argsJson: string, cwd: string, plugins: PluginEntry[]): Promise<string>;
|
|
9
|
+
//# sourceMappingURL=plugins.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugins.d.ts","sourceRoot":"","sources":["../src/plugins.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,cAAc,CAAC;IAC3B,OAAO,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IACzD,IAAI,EAAE,MAAM,CAAC;CACd;AAED,wBAAsB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAmDrE;AAED,wBAAsB,UAAU,CAC9B,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,WAAW,EAAE,GACrB,OAAO,CAAC,MAAM,CAAC,CAgBjB"}
|
package/dist/plugins.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import fs from 'fs/promises';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
export async function loadPlugins(cwd) {
|
|
4
|
+
const pluginsDir = path.join(cwd, '.koneck', 'plugins');
|
|
5
|
+
let files;
|
|
6
|
+
try {
|
|
7
|
+
files = await fs.readdir(pluginsDir);
|
|
8
|
+
}
|
|
9
|
+
catch {
|
|
10
|
+
return [];
|
|
11
|
+
}
|
|
12
|
+
const jsFiles = files.filter(f => f.endsWith('.js') || f.endsWith('.mjs'));
|
|
13
|
+
if (jsFiles.length === 0)
|
|
14
|
+
return [];
|
|
15
|
+
const results = await Promise.allSettled(jsFiles.map(async (f) => {
|
|
16
|
+
const filePath = path.join(pluginsDir, f);
|
|
17
|
+
const mod = await import(filePath);
|
|
18
|
+
if (!mod.definition || typeof mod.handler !== 'function') {
|
|
19
|
+
throw new Error(`Plugin ${f} must export 'definition' (ToolDefinition) and 'handler' (async function)`);
|
|
20
|
+
}
|
|
21
|
+
const def = mod.definition;
|
|
22
|
+
if (!def.name || !def.description || !def.parameters) {
|
|
23
|
+
throw new Error(`Plugin ${f}: definition must have name, description, and parameters`);
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
definition: def,
|
|
27
|
+
handler: mod.handler,
|
|
28
|
+
file: f,
|
|
29
|
+
};
|
|
30
|
+
}));
|
|
31
|
+
const plugins = [];
|
|
32
|
+
for (const result of results) {
|
|
33
|
+
if (result.status === 'fulfilled') {
|
|
34
|
+
plugins.push(result.value);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
process.stderr.write(` [plugin] Load error: ${result.reason instanceof Error ? result.reason.message : String(result.reason)}\n`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return plugins;
|
|
41
|
+
}
|
|
42
|
+
export async function callPlugin(name, argsJson, cwd, plugins) {
|
|
43
|
+
const plugin = plugins.find(p => p.definition.name === name);
|
|
44
|
+
if (!plugin)
|
|
45
|
+
return `ERROR: Plugin tool "${name}" is not loaded.`;
|
|
46
|
+
let parsed;
|
|
47
|
+
try {
|
|
48
|
+
parsed = JSON.parse(argsJson);
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
return `ERROR: Malformed JSON for plugin "${name}": ${argsJson.slice(0, 200)}`;
|
|
52
|
+
}
|
|
53
|
+
try {
|
|
54
|
+
return await plugin.handler(parsed, cwd);
|
|
55
|
+
}
|
|
56
|
+
catch (err) {
|
|
57
|
+
return `ERROR: Plugin "${name}" threw: ${err instanceof Error ? err.message : String(err)}`;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=plugins.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugins.js","sourceRoot":"","sources":["../src/plugins.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AASxB,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,GAAW;IAC3C,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;IAExD,IAAI,KAAe,CAAC;IACpB,IAAI,CAAC;QACH,KAAK,GAAG,MAAM,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IACvC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;IAC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AM,CAAC,MAAM,CAAC,IAAI,CAC7G,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,IAAY,EACZ,QAAgB,EAChB,GAAW,EACX,OAAsB;IAEtB,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;IAC7D,IAAI,CAAC,MAAM;QAAE,OAAO,uBAAuB,IAAI,kBAAkB,CAAC;IAElE,IAAI,MAAe,CAAC;IACpB,IAAI,CAAC;QACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAChC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,qCAAqC,IAAI,MAAM,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC;IACjF,CAAC;IAED,IAAI,CAAC;QACH,OAAO,MAAM,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3C,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,kBAAkB,IAAI,YAAY,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;IAC9F,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface CostEstimate {
|
|
2
|
+
inputCost: number;
|
|
3
|
+
outputCost: number;
|
|
4
|
+
total: number;
|
|
5
|
+
known: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function estimateCost(model: string, promptTokens: number, completionTokens: number): CostEstimate;
|
|
8
|
+
export declare function formatCost(amount: number): string;
|
|
9
|
+
//# sourceMappingURL=pricing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pricing.d.ts","sourceRoot":"","sources":["../src/pricing.ts"],"names":[],"mappings":"AAwEA,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,OAAO,CAAC;CAChB;AAWD,wBAAgB,YAAY,CAC1B,KAAK,EAAE,MAAM,EACb,YAAY,EAAE,MAAM,EACpB,gBAAgB,EAAE,MAAM,GACvB,YAAY,CAOd;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAKjD"}
|
package/dist/pricing.js
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
const PRICING = {
|
|
2
|
+
// OpenAI
|
|
3
|
+
'gpt-4o': { input: 2.50, output: 10.00 },
|
|
4
|
+
'gpt-4o-mini': { input: 0.15, output: 0.60 },
|
|
5
|
+
'gpt-4-turbo': { input: 10.00, output: 30.00 },
|
|
6
|
+
'o1': { input: 15.00, output: 60.00 },
|
|
7
|
+
'o1-mini': { input: 1.10, output: 4.40 },
|
|
8
|
+
'o3': { input: 10.00, output: 40.00 },
|
|
9
|
+
'o3-mini': { input: 1.10, output: 4.40 },
|
|
10
|
+
// Anthropic
|
|
11
|
+
'claude-opus-4-5': { input: 15.00, output: 75.00 },
|
|
12
|
+
'claude-opus-4': { input: 15.00, output: 75.00 },
|
|
13
|
+
'claude-sonnet-4-5': { input: 3.00, output: 15.00 },
|
|
14
|
+
'claude-sonnet-4': { input: 3.00, output: 15.00 },
|
|
15
|
+
'claude-3-7-sonnet-20250219': { input: 3.00, output: 15.00 },
|
|
16
|
+
'claude-3-5-sonnet-20241022': { input: 3.00, output: 15.00 },
|
|
17
|
+
'claude-3-5-haiku-20241022': { input: 0.80, output: 4.00 },
|
|
18
|
+
'claude-haiku-4-5': { input: 0.80, output: 4.00 },
|
|
19
|
+
'claude-3-opus-20240229': { input: 15.00, output: 75.00 },
|
|
20
|
+
// DeepSeek
|
|
21
|
+
'deepseek-coder': { input: 0.14, output: 0.28 },
|
|
22
|
+
'deepseek-chat': { input: 0.27, output: 1.10 },
|
|
23
|
+
'deepseek-reasoner': { input: 0.55, output: 2.19 },
|
|
24
|
+
// Groq (pay-as-you-go)
|
|
25
|
+
'llama-3.3-70b-versatile': { input: 0.59, output: 0.79 },
|
|
26
|
+
'llama-3.1-70b-versatile': { input: 0.59, output: 0.79 },
|
|
27
|
+
'llama-3.1-8b-instant': { input: 0.05, output: 0.08 },
|
|
28
|
+
'mixtral-8x7b-32768': { input: 0.24, output: 0.24 },
|
|
29
|
+
'gemma2-9b-it': { input: 0.20, output: 0.20 },
|
|
30
|
+
// Google Gemini
|
|
31
|
+
'gemini-2.0-flash': { input: 0.10, output: 0.40 },
|
|
32
|
+
'gemini-2.0-flash-lite': { input: 0.075, output: 0.30 },
|
|
33
|
+
'gemini-1.5-pro': { input: 1.25, output: 5.00 },
|
|
34
|
+
'gemini-1.5-flash': { input: 0.075, output: 0.30 },
|
|
35
|
+
// Mistral
|
|
36
|
+
'mistral-large-latest': { input: 3.00, output: 9.00 },
|
|
37
|
+
'mistral-medium-latest': { input: 0.40, output: 2.00 },
|
|
38
|
+
'mistral-small-latest': { input: 0.20, output: 0.60 },
|
|
39
|
+
'codestral-latest': { input: 0.20, output: 0.60 },
|
|
40
|
+
// Kimi / Moonshot
|
|
41
|
+
'moonshot-v1-128k': { input: 1.60, output: 1.60 },
|
|
42
|
+
'moonshot-v1-32k': { input: 0.80, output: 0.80 },
|
|
43
|
+
// xAI
|
|
44
|
+
'grok-2': { input: 2.00, output: 10.00 },
|
|
45
|
+
'grok-2-mini': { input: 0.20, output: 1.00 },
|
|
46
|
+
'grok-beta': { input: 5.00, output: 15.00 },
|
|
47
|
+
// Together AI
|
|
48
|
+
'meta-llama/Llama-3-70b-chat-hf': { input: 0.88, output: 0.88 },
|
|
49
|
+
'meta-llama/Llama-3-8b-chat-hf': { input: 0.20, output: 0.20 },
|
|
50
|
+
// Cohere
|
|
51
|
+
'command-r-plus': { input: 2.50, output: 10.00 },
|
|
52
|
+
'command-r': { input: 0.15, output: 0.60 },
|
|
53
|
+
// Perplexity
|
|
54
|
+
'sonar-pro': { input: 3.00, output: 15.00 },
|
|
55
|
+
'sonar': { input: 1.00, output: 1.00 },
|
|
56
|
+
};
|
|
57
|
+
function findPricing(model) {
|
|
58
|
+
if (PRICING[model])
|
|
59
|
+
return PRICING[model];
|
|
60
|
+
// Prefix match — handles dated model suffixes like claude-opus-4-5-20250101
|
|
61
|
+
for (const [key, p] of Object.entries(PRICING)) {
|
|
62
|
+
if (model.startsWith(key) || key.startsWith(model))
|
|
63
|
+
return p;
|
|
64
|
+
}
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
export function estimateCost(model, promptTokens, completionTokens) {
|
|
68
|
+
const p = findPricing(model);
|
|
69
|
+
if (!p)
|
|
70
|
+
return { inputCost: 0, outputCost: 0, total: 0, known: false };
|
|
71
|
+
const inputCost = (promptTokens / 1_000_000) * p.input;
|
|
72
|
+
const outputCost = (completionTokens / 1_000_000) * p.output;
|
|
73
|
+
return { inputCost, outputCost, total: inputCost + outputCost, known: true };
|
|
74
|
+
}
|
|
75
|
+
export function formatCost(amount) {
|
|
76
|
+
if (amount === 0)
|
|
77
|
+
return '$0.000';
|
|
78
|
+
if (amount < 0.0005)
|
|
79
|
+
return '< $0.001';
|
|
80
|
+
if (amount < 0.01)
|
|
81
|
+
return `$${amount.toFixed(4)}`;
|
|
82
|
+
return `$${amount.toFixed(3)}`;
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=pricing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pricing.js","sourceRoot":"","sources":["../src/pricing.ts"],"names":[],"mappings":"AAKA,MAAM,OAAO,GAAiC;IAC5C,SAAS;IACT,QAAQ,EAAsB,EAAE,KAAK,EAAE,IAAI,EAAG,MAAM,EAAE,KAAK,EAAE;IAC7D,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AAU,YAAY,CAC1B,KAAa,EACb,YAAoB,EACpB,gBAAwB;IAExB,MAAM,CAAC,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC;IAC7B,IAAI,CAAC,CAAC;QAAE,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;IAEvE,MAAM,SAAS,GAAI,CAAC,YAAY,GAAO,SAAS,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC;IAC5D,MAAM,UAAU,GAAG,CAAC,gBAAgB,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC;IAC7D,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,GAAG,UAAU,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAC/E,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,MAAc;IACvC,IAAI,MAAM,KAAK,CAAC;QAAK,OAAO,QAAQ,CAAC;IACrC,IAAI,MAAM,GAAG,MAAM;QAAE,OAAO,UAAU,CAAC;IACvC,IAAI,MAAM,GAAG,IAAI;QAAI,OAAO,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;IACpD,OAAO,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface ProjectInfo {
|
|
2
|
+
type: 'node' | 'python' | 'go' | 'rust' | 'java' | 'ruby' | 'php' | 'dotnet' | 'unknown';
|
|
3
|
+
packageManager?: string;
|
|
4
|
+
framework?: string;
|
|
5
|
+
testCommand?: string;
|
|
6
|
+
lintCommand?: string;
|
|
7
|
+
buildCommand?: string;
|
|
8
|
+
runCommand?: string;
|
|
9
|
+
agentInstructions?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function loadAgentInstructions(cwd: string): Promise<string | null>;
|
|
12
|
+
export declare function detectProject(cwd: string): Promise<ProjectInfo>;
|
|
13
|
+
export declare function projectSummary(p: ProjectInfo): string;
|
|
14
|
+
//# sourceMappingURL=project.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../src/project.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,SAAS,CAAC;IACzF,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAaD,wBAAsB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAQ/E;AAcD,wBAAsB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CA0GrE;AAID,wBAAgB,cAAc,CAAC,CAAC,EAAE,WAAW,GAAG,MAAM,CAarD"}
|
package/dist/project.js
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import fs from 'fs/promises';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
// ─── Project-instruction file discovery ──────────────────────────────────────
|
|
4
|
+
const INSTRUCTION_FILES = [
|
|
5
|
+
'KONECK.md',
|
|
6
|
+
'AGENTS.md',
|
|
7
|
+
'.koneck/AGENTS.md',
|
|
8
|
+
'CLAUDE.md',
|
|
9
|
+
'.cursorrules',
|
|
10
|
+
'.github/copilot-instructions.md',
|
|
11
|
+
];
|
|
12
|
+
export async function loadAgentInstructions(cwd) {
|
|
13
|
+
for (const rel of INSTRUCTION_FILES) {
|
|
14
|
+
try {
|
|
15
|
+
const content = await fs.readFile(path.join(cwd, rel), 'utf-8');
|
|
16
|
+
if (content.trim())
|
|
17
|
+
return `# Project instructions (from ${rel})\n\n${content.trim()}`;
|
|
18
|
+
}
|
|
19
|
+
catch { /* not found */ }
|
|
20
|
+
}
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
// ─── Project type detection ───────────────────────────────────────────────────
|
|
24
|
+
async function readJson(filePath) {
|
|
25
|
+
try {
|
|
26
|
+
return JSON.parse(await fs.readFile(filePath, 'utf-8'));
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
async function exists(filePath) {
|
|
33
|
+
try {
|
|
34
|
+
await fs.access(filePath);
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
export async function detectProject(cwd) {
|
|
42
|
+
// ── Node.js ────────────────────────────────────────────────────────────────
|
|
43
|
+
const pkgJson = await readJson(path.join(cwd, 'package.json'));
|
|
44
|
+
if (pkgJson) {
|
|
45
|
+
const scripts = pkgJson['scripts'] ?? {};
|
|
46
|
+
const deps = {
|
|
47
|
+
...(pkgJson['dependencies'] ?? {}),
|
|
48
|
+
...(pkgJson['devDependencies'] ?? {}),
|
|
49
|
+
};
|
|
50
|
+
const pm = await exists(path.join(cwd, 'pnpm-lock.yaml')) ? 'pnpm' :
|
|
51
|
+
await exists(path.join(cwd, 'yarn.lock')) ? 'yarn' :
|
|
52
|
+
'npm';
|
|
53
|
+
const framework = deps['next'] ? 'Next.js' :
|
|
54
|
+
deps['react'] ? 'React' :
|
|
55
|
+
deps['vue'] ? 'Vue' :
|
|
56
|
+
deps['svelte'] ? 'Svelte' :
|
|
57
|
+
deps['express'] ? 'Express' :
|
|
58
|
+
deps['fastify'] ? 'Fastify' :
|
|
59
|
+
deps['@nestjs/core'] ? 'NestJS' :
|
|
60
|
+
undefined;
|
|
61
|
+
const testCmd = scripts['test'] ? `${pm} test` :
|
|
62
|
+
scripts['test:ci'] ? `${pm} run test:ci` :
|
|
63
|
+
deps['vitest'] ? `${pm} run test` :
|
|
64
|
+
deps['jest'] ? `${pm} run test` :
|
|
65
|
+
undefined;
|
|
66
|
+
const lintCmd = scripts['lint'] ? `${pm} run lint` :
|
|
67
|
+
scripts['lint:fix'] ? `${pm} run lint` :
|
|
68
|
+
undefined;
|
|
69
|
+
const buildCmd = scripts['build'] ? `${pm} run build` :
|
|
70
|
+
undefined;
|
|
71
|
+
return {
|
|
72
|
+
type: 'node',
|
|
73
|
+
packageManager: pm,
|
|
74
|
+
framework,
|
|
75
|
+
testCommand: testCmd,
|
|
76
|
+
lintCommand: lintCmd,
|
|
77
|
+
buildCommand: buildCmd,
|
|
78
|
+
runCommand: scripts['start'] ? `${pm} start` : scripts['dev'] ? `${pm} run dev` : undefined,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
// ── Python ─────────────────────────────────────────────────────────────────
|
|
82
|
+
if (await exists(path.join(cwd, 'pyproject.toml')) ||
|
|
83
|
+
await exists(path.join(cwd, 'setup.py')) ||
|
|
84
|
+
await exists(path.join(cwd, 'setup.cfg')) ||
|
|
85
|
+
await exists(path.join(cwd, 'requirements.txt'))) {
|
|
86
|
+
const hasPytest = await exists(path.join(cwd, 'pytest.ini')) || await exists(path.join(cwd, 'conftest.py'));
|
|
87
|
+
const hasPoetry = await exists(path.join(cwd, 'poetry.lock'));
|
|
88
|
+
const hasUv = await exists(path.join(cwd, 'uv.lock'));
|
|
89
|
+
const pm = hasPoetry ? 'poetry' : hasUv ? 'uv' : 'pip';
|
|
90
|
+
return {
|
|
91
|
+
type: 'python',
|
|
92
|
+
packageManager: pm,
|
|
93
|
+
testCommand: hasPytest ? 'pytest' : 'python -m unittest discover',
|
|
94
|
+
lintCommand: 'ruff check . || flake8 .',
|
|
95
|
+
buildCommand: hasPoetry ? 'poetry build' : undefined,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
// ── Go ─────────────────────────────────────────────────────────────────────
|
|
99
|
+
if (await exists(path.join(cwd, 'go.mod'))) {
|
|
100
|
+
return { type: 'go', testCommand: 'go test ./...', lintCommand: 'go vet ./...', buildCommand: 'go build ./...' };
|
|
101
|
+
}
|
|
102
|
+
// ── Rust ───────────────────────────────────────────────────────────────────
|
|
103
|
+
if (await exists(path.join(cwd, 'Cargo.toml'))) {
|
|
104
|
+
return { type: 'rust', packageManager: 'cargo', testCommand: 'cargo test', lintCommand: 'cargo clippy', buildCommand: 'cargo build' };
|
|
105
|
+
}
|
|
106
|
+
// ── Java ───────────────────────────────────────────────────────────────────
|
|
107
|
+
if (await exists(path.join(cwd, 'pom.xml'))) {
|
|
108
|
+
return { type: 'java', packageManager: 'maven', testCommand: 'mvn test', buildCommand: 'mvn package' };
|
|
109
|
+
}
|
|
110
|
+
if (await exists(path.join(cwd, 'build.gradle')) || await exists(path.join(cwd, 'build.gradle.kts'))) {
|
|
111
|
+
return { type: 'java', packageManager: 'gradle', testCommand: './gradlew test', buildCommand: './gradlew build' };
|
|
112
|
+
}
|
|
113
|
+
// ── Ruby ───────────────────────────────────────────────────────────────────
|
|
114
|
+
if (await exists(path.join(cwd, 'Gemfile'))) {
|
|
115
|
+
return { type: 'ruby', packageManager: 'bundler', testCommand: 'bundle exec rspec || bundle exec rake test' };
|
|
116
|
+
}
|
|
117
|
+
// ── PHP ────────────────────────────────────────────────────────────────────
|
|
118
|
+
if (await exists(path.join(cwd, 'composer.json'))) {
|
|
119
|
+
return { type: 'php', packageManager: 'composer', testCommand: './vendor/bin/phpunit' };
|
|
120
|
+
}
|
|
121
|
+
// ── .NET ───────────────────────────────────────────────────────────────────
|
|
122
|
+
try {
|
|
123
|
+
const entries = await fs.readdir(cwd);
|
|
124
|
+
if (entries.some(e => e.endsWith('.csproj') || e.endsWith('.sln'))) {
|
|
125
|
+
return { type: 'dotnet', testCommand: 'dotnet test', buildCommand: 'dotnet build' };
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
catch { /* ignore */ }
|
|
129
|
+
return { type: 'unknown' };
|
|
130
|
+
}
|
|
131
|
+
// ─── Summary string for system prompt ────────────────────────────────────────
|
|
132
|
+
export function projectSummary(p) {
|
|
133
|
+
const lines = [];
|
|
134
|
+
const typeLabel = {
|
|
135
|
+
node: 'Node.js', python: 'Python', go: 'Go', rust: 'Rust',
|
|
136
|
+
java: 'Java', ruby: 'Ruby', php: 'PHP', dotnet: '.NET', unknown: 'Unknown',
|
|
137
|
+
};
|
|
138
|
+
lines.push(`- Language/runtime: ${typeLabel[p.type]}${p.framework ? ` (${p.framework})` : ''}`);
|
|
139
|
+
if (p.packageManager)
|
|
140
|
+
lines.push(`- Package manager: ${p.packageManager}`);
|
|
141
|
+
if (p.testCommand)
|
|
142
|
+
lines.push(`- Test command: \`${p.testCommand}\``);
|
|
143
|
+
if (p.lintCommand)
|
|
144
|
+
lines.push(`- Lint command: \`${p.lintCommand}\``);
|
|
145
|
+
if (p.buildCommand)
|
|
146
|
+
lines.push(`- Build command: \`${p.buildCommand}\``);
|
|
147
|
+
if (p.runCommand)
|
|
148
|
+
lines.push(`- Run command: \`${p.runCommand}\``);
|
|
149
|
+
return lines.join('\n');
|
|
150
|
+
}
|
|
151
|
+
//# sourceMappingURL=project.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project.js","sourceRoot":"","sources":["../src/project.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AAaxB,gFAAgF;AAEhF,MAAM,iBAAiB,GAAG;IACxB,WAAW;IACX,WAAW;IACX,mBAAmB;IACnB,WAAW;IACX,cAAc;IACd,iCAAiC;CAClC,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,qBAAqB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1,13 @@
|
|
|
1
|
+
export interface ProviderDef {
|
|
2
|
+
name: string;
|
|
3
|
+
displayName: string;
|
|
4
|
+
baseURL: string;
|
|
5
|
+
apiKeyEnv: string;
|
|
6
|
+
defaultModel: string;
|
|
7
|
+
extraHeaders?: Record<string, string>;
|
|
8
|
+
}
|
|
9
|
+
export declare const PROVIDERS: Record<string, ProviderDef>;
|
|
10
|
+
export declare function resolveProvider(name: string, baseURLOverride?: string): ProviderDef;
|
|
11
|
+
export declare function getApiKey(def: ProviderDef, override?: string): string;
|
|
12
|
+
export declare function listProviders(): string;
|
|
13
|
+
//# sourceMappingURL=providers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../src/providers.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACvC;AAED,eAAO,MAAM,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CA6FjD,CAAC;AAEF,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,MAAM,GAAG,WAAW,CAmBnF;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,WAAW,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAgBrE;AAED,wBAAgB,aAAa,IAAI,MAAM,CAItC"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
export const PROVIDERS = {
|
|
2
|
+
omni: {
|
|
3
|
+
name: 'omni',
|
|
4
|
+
displayName: 'OmniRoute (local)',
|
|
5
|
+
baseURL: 'http://localhost:20128/v1',
|
|
6
|
+
apiKeyEnv: 'OMNI_ROUTE_API_KEY',
|
|
7
|
+
defaultModel: 'auto',
|
|
8
|
+
},
|
|
9
|
+
openai: {
|
|
10
|
+
name: 'openai',
|
|
11
|
+
displayName: 'OpenAI',
|
|
12
|
+
baseURL: 'https://api.openai.com/v1',
|
|
13
|
+
apiKeyEnv: 'OPENAI_API_KEY',
|
|
14
|
+
defaultModel: 'gpt-4o',
|
|
15
|
+
},
|
|
16
|
+
anthropic: {
|
|
17
|
+
name: 'anthropic',
|
|
18
|
+
displayName: 'Anthropic',
|
|
19
|
+
baseURL: 'https://api.anthropic.com/v1',
|
|
20
|
+
apiKeyEnv: 'ANTHROPIC_API_KEY',
|
|
21
|
+
defaultModel: 'claude-opus-4-5',
|
|
22
|
+
extraHeaders: { 'anthropic-version': '2023-06-01' },
|
|
23
|
+
},
|
|
24
|
+
deepseek: {
|
|
25
|
+
name: 'deepseek',
|
|
26
|
+
displayName: 'DeepSeek',
|
|
27
|
+
baseURL: 'https://api.deepseek.com/v1',
|
|
28
|
+
apiKeyEnv: 'DEEPSEEK_API_KEY',
|
|
29
|
+
defaultModel: 'deepseek-coder',
|
|
30
|
+
},
|
|
31
|
+
groq: {
|
|
32
|
+
name: 'groq',
|
|
33
|
+
displayName: 'Groq',
|
|
34
|
+
baseURL: 'https://api.groq.com/openai/v1',
|
|
35
|
+
apiKeyEnv: 'GROQ_API_KEY',
|
|
36
|
+
defaultModel: 'llama-3.3-70b-versatile',
|
|
37
|
+
},
|
|
38
|
+
together: {
|
|
39
|
+
name: 'together',
|
|
40
|
+
displayName: 'Together AI',
|
|
41
|
+
baseURL: 'https://api.together.xyz/v1',
|
|
42
|
+
apiKeyEnv: 'TOGETHER_API_KEY',
|
|
43
|
+
defaultModel: 'meta-llama/Llama-3-70b-chat-hf',
|
|
44
|
+
},
|
|
45
|
+
ollama: {
|
|
46
|
+
name: 'ollama',
|
|
47
|
+
displayName: 'Ollama (local)',
|
|
48
|
+
baseURL: 'http://localhost:11434/v1',
|
|
49
|
+
apiKeyEnv: 'OLLAMA_API_KEY',
|
|
50
|
+
defaultModel: 'codellama',
|
|
51
|
+
},
|
|
52
|
+
gemini: {
|
|
53
|
+
name: 'gemini',
|
|
54
|
+
displayName: 'Google Gemini',
|
|
55
|
+
baseURL: 'https://generativelanguage.googleapis.com/v1beta/openai',
|
|
56
|
+
apiKeyEnv: 'GOOGLE_API_KEY',
|
|
57
|
+
defaultModel: 'gemini-2.0-flash',
|
|
58
|
+
},
|
|
59
|
+
kimi: {
|
|
60
|
+
name: 'kimi',
|
|
61
|
+
displayName: 'Kimi (Moonshot)',
|
|
62
|
+
baseURL: 'https://api.moonshot.cn/v1',
|
|
63
|
+
apiKeyEnv: 'MOONSHOT_API_KEY',
|
|
64
|
+
defaultModel: 'moonshot-v1-128k',
|
|
65
|
+
},
|
|
66
|
+
mistral: {
|
|
67
|
+
name: 'mistral',
|
|
68
|
+
displayName: 'Mistral AI',
|
|
69
|
+
baseURL: 'https://api.mistral.ai/v1',
|
|
70
|
+
apiKeyEnv: 'MISTRAL_API_KEY',
|
|
71
|
+
defaultModel: 'mistral-large-latest',
|
|
72
|
+
},
|
|
73
|
+
cohere: {
|
|
74
|
+
name: 'cohere',
|
|
75
|
+
displayName: 'Cohere',
|
|
76
|
+
baseURL: 'https://api.cohere.com/compatibility/v1',
|
|
77
|
+
apiKeyEnv: 'COHERE_API_KEY',
|
|
78
|
+
defaultModel: 'command-r-plus',
|
|
79
|
+
},
|
|
80
|
+
xai: {
|
|
81
|
+
name: 'xai',
|
|
82
|
+
displayName: 'xAI (Grok)',
|
|
83
|
+
baseURL: 'https://api.x.ai/v1',
|
|
84
|
+
apiKeyEnv: 'XAI_API_KEY',
|
|
85
|
+
defaultModel: 'grok-2',
|
|
86
|
+
},
|
|
87
|
+
perplexity: {
|
|
88
|
+
name: 'perplexity',
|
|
89
|
+
displayName: 'Perplexity',
|
|
90
|
+
baseURL: 'https://api.perplexity.ai',
|
|
91
|
+
apiKeyEnv: 'PERPLEXITY_API_KEY',
|
|
92
|
+
defaultModel: 'sonar-pro',
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
export function resolveProvider(name, baseURLOverride) {
|
|
96
|
+
const key = name.toLowerCase();
|
|
97
|
+
const def = PROVIDERS[key];
|
|
98
|
+
if (!def) {
|
|
99
|
+
if (baseURLOverride) {
|
|
100
|
+
return {
|
|
101
|
+
name: 'custom',
|
|
102
|
+
displayName: 'Custom',
|
|
103
|
+
baseURL: baseURLOverride,
|
|
104
|
+
apiKeyEnv: 'KONECK_API_KEY',
|
|
105
|
+
defaultModel: 'default',
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
const known = Object.keys(PROVIDERS).join(', ');
|
|
109
|
+
throw new Error(`Unknown provider "${name}". Known: ${known}\nOr pass --base-url to use a custom endpoint.`);
|
|
110
|
+
}
|
|
111
|
+
return baseURLOverride ? { ...def, baseURL: baseURLOverride } : def;
|
|
112
|
+
}
|
|
113
|
+
export function getApiKey(def, override) {
|
|
114
|
+
const key = override ??
|
|
115
|
+
process.env[def.apiKeyEnv] ??
|
|
116
|
+
process.env['KONECK_API_KEY'];
|
|
117
|
+
if (key)
|
|
118
|
+
return key;
|
|
119
|
+
if (def.name === 'omni' || def.name === 'ollama') {
|
|
120
|
+
return 'local';
|
|
121
|
+
}
|
|
122
|
+
throw new Error(`No API key found for ${def.displayName}.\n` +
|
|
123
|
+
`Set the ${def.apiKeyEnv} environment variable (or KONECK_API_KEY as a fallback).`);
|
|
124
|
+
}
|
|
125
|
+
export function listProviders() {
|
|
126
|
+
return Object.values(PROVIDERS)
|
|
127
|
+
.map(p => ` ${p.name.padEnd(12)} ${p.displayName.padEnd(20)} default model: ${p.defaultModel}`)
|
|
128
|
+
.join('\n');
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=providers.js.map
|