@ftarganski/omni-ai 0.1.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/chunk-3RZELMF2.js +214 -0
- package/dist/chunk-5WELBZWN.js +70 -0
- package/dist/chunk-6APAA6WD.js +495 -0
- package/dist/chunk-6OPRALDC.js +163 -0
- package/dist/chunk-6YFFZMXY.js +104 -0
- package/dist/chunk-AG6NZIJ3.js +122 -0
- package/dist/chunk-AWMSN7OB.js +451 -0
- package/dist/chunk-JTXDF5KG.js +156 -0
- package/dist/chunk-M4QJF7CV.js +57 -0
- package/dist/chunk-PPTEJ2FH.js +102 -0
- package/dist/chunk-S5MK6LBH.js +136 -0
- package/dist/chunk-TFU437SW.js +107 -0
- package/dist/chunk-Y4EYGADJ.js +216 -0
- package/dist/cli/bin.js +2723 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +42 -0
- package/dist/mcp.d.ts +1 -0
- package/dist/mcp.js +86 -0
- package/dist/memory.d.ts +1 -0
- package/dist/memory.js +320 -0
- package/dist/provider-anthropic.d.ts +1 -0
- package/dist/provider-anthropic.js +120 -0
- package/dist/provider-google.d.ts +1 -0
- package/dist/provider-google.js +141 -0
- package/dist/provider-openai.d.ts +1 -0
- package/dist/provider-openai.js +214 -0
- package/dist/skills/backend.d.ts +1 -0
- package/dist/skills/backend.js +12 -0
- package/dist/skills/code.d.ts +1 -0
- package/dist/skills/code.js +6 -0
- package/dist/skills/frontend.d.ts +1 -0
- package/dist/skills/frontend.js +10 -0
- package/dist/skills/fs.d.ts +1 -0
- package/dist/skills/fs.js +10 -0
- package/dist/skills/git.d.ts +1 -0
- package/dist/skills/git.js +12 -0
- package/dist/skills/http.d.ts +1 -0
- package/dist/skills/http.js +6 -0
- package/dist/skills/index.d.ts +1 -0
- package/dist/skills/index.js +60 -0
- package/dist/skills/multimodal.d.ts +1 -0
- package/dist/skills/multimodal.js +6 -0
- package/dist/skills/qa.d.ts +1 -0
- package/dist/skills/qa.js +8 -0
- package/dist/skills/ux.d.ts +1 -0
- package/dist/skills/ux.js +6 -0
- package/dist/src-6MUVU5ML.js +8 -0
- package/dist/src-ZHTGR7T6.js +8 -0
- package/package.json +136 -0
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
registerProvider
|
|
4
|
+
} from "./chunk-AWMSN7OB.js";
|
|
5
|
+
|
|
6
|
+
// ../provider-openai/src/provider.ts
|
|
7
|
+
import OpenAI from "openai";
|
|
8
|
+
|
|
9
|
+
// ../provider-openai/src/mappers.ts
|
|
10
|
+
function toOpenAIUserContentPart(part) {
|
|
11
|
+
if (part.type === "text") return { type: "text", text: part.text };
|
|
12
|
+
return {
|
|
13
|
+
type: "image_url",
|
|
14
|
+
image_url: { url: `data:${part.mimeType};base64,${part.data}` }
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function contentAsString(content) {
|
|
18
|
+
if (typeof content === "string") return content;
|
|
19
|
+
return content.map((p) => p.type === "text" ? p.text : "").join("");
|
|
20
|
+
}
|
|
21
|
+
function toOpenAIMessages(messages) {
|
|
22
|
+
return messages.map((m) => {
|
|
23
|
+
if (m.role === "system") {
|
|
24
|
+
return { role: "system", content: contentAsString(m.content) };
|
|
25
|
+
}
|
|
26
|
+
if (m.role === "assistant") {
|
|
27
|
+
return { role: "assistant", content: contentAsString(m.content) };
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
role: "user",
|
|
31
|
+
content: typeof m.content === "string" ? m.content : m.content.map(toOpenAIUserContentPart)
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
function toOpenAITools(tools) {
|
|
36
|
+
return tools.map((t) => ({
|
|
37
|
+
type: "function",
|
|
38
|
+
function: {
|
|
39
|
+
name: t.name,
|
|
40
|
+
description: t.description,
|
|
41
|
+
parameters: t.parameters
|
|
42
|
+
}
|
|
43
|
+
}));
|
|
44
|
+
}
|
|
45
|
+
function fromOpenAIResponse(response, providerName) {
|
|
46
|
+
const choice = response.choices[0];
|
|
47
|
+
const message = choice.message;
|
|
48
|
+
const toolCalls = [];
|
|
49
|
+
for (const tc of message.tool_calls ?? []) {
|
|
50
|
+
toolCalls.push({
|
|
51
|
+
id: tc.id,
|
|
52
|
+
name: tc.function.name,
|
|
53
|
+
arguments: JSON.parse(tc.function.arguments || "{}")
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
content: message.content ?? "",
|
|
58
|
+
toolCalls: toolCalls.length > 0 ? toolCalls : void 0,
|
|
59
|
+
usage: response.usage ? {
|
|
60
|
+
inputTokens: response.usage.prompt_tokens,
|
|
61
|
+
outputTokens: response.usage.completion_tokens
|
|
62
|
+
} : void 0,
|
|
63
|
+
model: response.model,
|
|
64
|
+
provider: providerName
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// ../provider-openai/src/provider.ts
|
|
69
|
+
var OpenAIProvider = class {
|
|
70
|
+
name;
|
|
71
|
+
capabilities = {
|
|
72
|
+
chat: true,
|
|
73
|
+
embedding: true,
|
|
74
|
+
streaming: true,
|
|
75
|
+
toolUse: true,
|
|
76
|
+
vision: true
|
|
77
|
+
};
|
|
78
|
+
client;
|
|
79
|
+
defaultModel;
|
|
80
|
+
constructor(options) {
|
|
81
|
+
this.name = options.name ?? "openai";
|
|
82
|
+
this.defaultModel = options.defaultModel ?? "gpt-4o";
|
|
83
|
+
this.client = new OpenAI({
|
|
84
|
+
apiKey: options.apiKey,
|
|
85
|
+
baseURL: options.baseUrl
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
async complete(request) {
|
|
89
|
+
const model = request.model ?? this.defaultModel;
|
|
90
|
+
const messages = toOpenAIMessages(request.messages);
|
|
91
|
+
const tools = request.tools && request.tools.length > 0 ? toOpenAITools(request.tools) : void 0;
|
|
92
|
+
if (request.onToken) {
|
|
93
|
+
const stream = await this.client.chat.completions.create({
|
|
94
|
+
model,
|
|
95
|
+
temperature: request.temperature,
|
|
96
|
+
max_tokens: request.maxTokens,
|
|
97
|
+
messages,
|
|
98
|
+
tools,
|
|
99
|
+
tool_choice: tools ? "auto" : void 0,
|
|
100
|
+
stream: true,
|
|
101
|
+
stream_options: { include_usage: true }
|
|
102
|
+
});
|
|
103
|
+
let content = "";
|
|
104
|
+
const toolCallAccum = {};
|
|
105
|
+
let inputTokens = 0;
|
|
106
|
+
let outputTokens = 0;
|
|
107
|
+
for await (const chunk of stream) {
|
|
108
|
+
const delta = chunk.choices[0]?.delta;
|
|
109
|
+
if (delta?.content) {
|
|
110
|
+
content += delta.content;
|
|
111
|
+
request.onToken(delta.content);
|
|
112
|
+
}
|
|
113
|
+
if (delta?.tool_calls) {
|
|
114
|
+
for (const tc of delta.tool_calls) {
|
|
115
|
+
const idx = tc.index;
|
|
116
|
+
if (!toolCallAccum[idx]) {
|
|
117
|
+
toolCallAccum[idx] = { id: "", name: "", args: "" };
|
|
118
|
+
}
|
|
119
|
+
if (tc.id) toolCallAccum[idx].id = tc.id;
|
|
120
|
+
if (tc.function?.name) toolCallAccum[idx].name = tc.function.name;
|
|
121
|
+
if (tc.function?.arguments) toolCallAccum[idx].args += tc.function.arguments;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
if (chunk.usage) {
|
|
125
|
+
inputTokens = chunk.usage.prompt_tokens;
|
|
126
|
+
outputTokens = chunk.usage.completion_tokens;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
const toolCalls = Object.values(toolCallAccum);
|
|
130
|
+
return {
|
|
131
|
+
content,
|
|
132
|
+
toolCalls: toolCalls.length > 0 ? toolCalls.map((tc) => ({
|
|
133
|
+
id: tc.id,
|
|
134
|
+
name: tc.name,
|
|
135
|
+
arguments: (() => {
|
|
136
|
+
try {
|
|
137
|
+
return JSON.parse(tc.args);
|
|
138
|
+
} catch {
|
|
139
|
+
return {};
|
|
140
|
+
}
|
|
141
|
+
})()
|
|
142
|
+
})) : void 0,
|
|
143
|
+
usage: inputTokens > 0 ? { inputTokens, outputTokens } : void 0,
|
|
144
|
+
model,
|
|
145
|
+
provider: this.name
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
const response = await this.client.chat.completions.create({
|
|
149
|
+
model,
|
|
150
|
+
temperature: request.temperature,
|
|
151
|
+
max_tokens: request.maxTokens,
|
|
152
|
+
messages,
|
|
153
|
+
tools,
|
|
154
|
+
tool_choice: tools ? "auto" : void 0
|
|
155
|
+
});
|
|
156
|
+
return fromOpenAIResponse(response, this.name);
|
|
157
|
+
}
|
|
158
|
+
async embed(request) {
|
|
159
|
+
const model = request.model ?? "text-embedding-3-small";
|
|
160
|
+
const input = Array.isArray(request.input) ? request.input : [request.input];
|
|
161
|
+
const response = await this.client.embeddings.create({ model, input });
|
|
162
|
+
return {
|
|
163
|
+
embeddings: response.data.map((d) => d.embedding),
|
|
164
|
+
model: response.model,
|
|
165
|
+
provider: this.name
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
// ../provider-openai/src/index.ts
|
|
171
|
+
registerProvider("openai", (config) => {
|
|
172
|
+
if (!config.apiKey) {
|
|
173
|
+
throw new Error(`Provider "${config.name}" (openai) requires OPENAI_API_KEY to be set in the environment.`);
|
|
174
|
+
}
|
|
175
|
+
return new OpenAIProvider({
|
|
176
|
+
apiKey: config.apiKey,
|
|
177
|
+
defaultModel: config.defaultModel,
|
|
178
|
+
baseUrl: config.baseUrl,
|
|
179
|
+
name: config.name
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
registerProvider("copilot", (config) => {
|
|
183
|
+
if (!config.apiKey) {
|
|
184
|
+
throw new Error(`Provider "${config.name}" (copilot) requires GITHUB_TOKEN to be set in the environment.`);
|
|
185
|
+
}
|
|
186
|
+
return new OpenAIProvider({
|
|
187
|
+
apiKey: config.apiKey,
|
|
188
|
+
defaultModel: config.defaultModel ?? "gpt-4o",
|
|
189
|
+
baseUrl: config.baseUrl ?? "https://api.githubcopilot.com",
|
|
190
|
+
name: config.name
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
registerProvider("groq", (config) => {
|
|
194
|
+
if (!config.apiKey) {
|
|
195
|
+
throw new Error(`Provider "${config.name}" (groq) requires GROQ_API_KEY to be set in the environment.`);
|
|
196
|
+
}
|
|
197
|
+
return new OpenAIProvider({
|
|
198
|
+
apiKey: config.apiKey,
|
|
199
|
+
defaultModel: config.defaultModel ?? "llama-3.3-70b-versatile",
|
|
200
|
+
baseUrl: config.baseUrl ?? "https://api.groq.com/openai/v1",
|
|
201
|
+
name: config.name
|
|
202
|
+
});
|
|
203
|
+
});
|
|
204
|
+
registerProvider("ollama", (config) => {
|
|
205
|
+
return new OpenAIProvider({
|
|
206
|
+
// Ollama does not require an API key; use a placeholder so the SDK does not complain
|
|
207
|
+
apiKey: config.apiKey ?? "ollama",
|
|
208
|
+
defaultModel: config.defaultModel ?? "llama3.2",
|
|
209
|
+
baseUrl: config.baseUrl ?? "http://localhost:11434/v1",
|
|
210
|
+
name: config.name
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
export {
|
|
215
|
+
OpenAIProvider
|
|
216
|
+
};
|