startx 0.9.4 → 0.9.9

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.
Files changed (48) hide show
  1. package/apps/cli/package.json +3 -1
  2. package/apps/cli/src/commands/common/hashing.ts +34 -0
  3. package/apps/cli/src/commands/common/ping.ts +11 -0
  4. package/apps/cli/src/commands/common/random.ts +41 -0
  5. package/apps/cli/src/commands/i-command.ts +6 -0
  6. package/apps/cli/src/commands/index.ts +6 -0
  7. package/apps/cli/src/index.ts +6 -4
  8. package/apps/cli/tsconfig.json +4 -6
  9. package/apps/startx-cli/dist/index.mjs +52 -52
  10. package/configs/eslint-config/src/configs/base.ts +26 -11
  11. package/package.json +2 -2
  12. package/packages/@db/drizzle/tsconfig.json +2 -8
  13. package/packages/@db/sqlite/tsconfig.json +2 -8
  14. package/packages/@repo/env/package.json +2 -1
  15. package/packages/@repo/env/src/utils.ts +7 -6
  16. package/packages/@repo/lib/src/events/i-event.ts +1 -1
  17. package/packages/aix/eslint.config.ts +4 -0
  18. package/packages/aix/package.json +53 -0
  19. package/packages/aix/src/aix.ts +519 -0
  20. package/packages/aix/src/index.ts +3 -0
  21. package/packages/aix/src/lib/convertor/schema-convertor.ts +108 -0
  22. package/packages/aix/src/lib/convertor/variable-resolver.ts +161 -0
  23. package/packages/aix/src/lib/tokenizer/index.ts +1 -0
  24. package/packages/aix/src/lib/tokenizer/tokenizer.ts +42 -0
  25. package/packages/aix/src/providers/ai-chat.ts +25 -0
  26. package/packages/aix/src/providers/ai-event.ts +21 -0
  27. package/packages/aix/src/providers/ai-interface.ts +236 -0
  28. package/packages/aix/src/providers/ai-prompt.ts +14 -0
  29. package/packages/aix/src/providers/default-models.ts +471 -0
  30. package/packages/aix/src/providers/index.ts +1 -0
  31. package/packages/aix/src/providers/openai/openai.ts +139 -0
  32. package/packages/aix/src/providers/providers.ts +39 -0
  33. package/packages/aix/src/providers/types.ts +54 -0
  34. package/packages/aix/src/tools/generic/database.ts +290 -0
  35. package/packages/aix/src/tools/generic/forecast.ts +216 -0
  36. package/packages/aix/src/tools/generic/index.ts +4 -0
  37. package/packages/aix/src/tools/generic/planner.ts +114 -0
  38. package/packages/aix/src/tools/generic/summarizer.ts +101 -0
  39. package/packages/aix/src/tools/i-tool.ts +33 -0
  40. package/packages/aix/src/tools/index.ts +2 -0
  41. package/packages/aix/src/tools/system/index.ts +297 -0
  42. package/packages/aix/src/tools/tool-manager.ts +241 -0
  43. package/packages/aix/src/tools/types.ts +109 -0
  44. package/packages/aix/tsconfig.json +7 -0
  45. package/packages/aix/vitest.config.ts +3 -0
  46. package/pnpm-workspace.yaml +7 -0
  47. package/turbo.json +0 -1
  48. package/apps/cli/src/commands/ping.ts +0 -10
@@ -0,0 +1,471 @@
1
+ import type { AiProvider, AiProviderModelType } from "./types.js";
2
+
3
+ export const DefaultAiModels = {
4
+ groq: [
5
+ {
6
+ id: "llama-3.3-70b-versatile",
7
+ owner: "Meta",
8
+ contextWindowToken: 131072,
9
+ maxCompletionToken: 32768,
10
+ type: "text-completion",
11
+ },
12
+ {
13
+ id: "llama-3.1-8b-instant",
14
+ owner: "Meta",
15
+ contextWindowToken: 131072,
16
+ maxCompletionToken: 131072,
17
+ type: "text-completion",
18
+ },
19
+ {
20
+ id: "openai/gpt-oss-120b",
21
+ owner: "OpenAI",
22
+ contextWindowToken: 131072,
23
+ maxCompletionToken: 65536,
24
+ type: "text-completion",
25
+ },
26
+ {
27
+ id: "openai/gpt-oss-20b",
28
+ owner: "OpenAI",
29
+ contextWindowToken: 131072,
30
+ maxCompletionToken: 65536,
31
+ type: "text-completion",
32
+ },
33
+ ],
34
+ openAi: [
35
+ {
36
+ id: "gpt-4o",
37
+ owner: "OpenAI",
38
+ contextWindowToken: 128000,
39
+ maxCompletionToken: 16384,
40
+ type: "text-completion",
41
+ },
42
+ {
43
+ id: "o1",
44
+ owner: "OpenAI",
45
+ contextWindowToken: 200000,
46
+ maxCompletionToken: 100000,
47
+ type: "text-completion",
48
+ },
49
+ {
50
+ id: "dall-e-3",
51
+ owner: "OpenAI",
52
+ contextWindowToken: 0,
53
+ maxCompletionToken: 1,
54
+ type: "image-generation",
55
+ },
56
+ {
57
+ id: "tts-1",
58
+ owner: "OpenAI",
59
+ contextWindowToken: 4096,
60
+ maxCompletionToken: 0,
61
+ type: "audio-generation",
62
+ },
63
+ ],
64
+ cloudflare: [
65
+ {
66
+ id: "@cf/meta/llama-3.2-1b-instruct",
67
+ owner: "Meta",
68
+ contextWindowToken: 131072,
69
+ maxCompletionToken: 8192,
70
+ type: "text-completion",
71
+ },
72
+ {
73
+ id: "@cf/meta/llama-3.2-3b-instruct",
74
+ owner: "Meta",
75
+ contextWindowToken: 131072,
76
+ maxCompletionToken: 8192,
77
+ type: "text-completion",
78
+ },
79
+ {
80
+ id: "@cf/meta/llama-3.1-8b-instruct-fp8-fast",
81
+ owner: "Meta",
82
+ contextWindowToken: 131072,
83
+ maxCompletionToken: 8192,
84
+ type: "text-completion",
85
+ },
86
+ {
87
+ id: "@cf/meta/llama-3.2-11b-vision-instruct",
88
+ owner: "Meta",
89
+ contextWindowToken: 131072,
90
+ maxCompletionToken: 8192,
91
+ type: "text-completion",
92
+ },
93
+ {
94
+ id: "@cf/meta/llama-3.1-70b-instruct-fp8-fast",
95
+ owner: "Meta",
96
+ contextWindowToken: 131072,
97
+ maxCompletionToken: 8192,
98
+ type: "text-completion",
99
+ },
100
+ {
101
+ id: "@cf/meta/llama-3.3-70b-instruct-fp8-fast",
102
+ owner: "Meta",
103
+ contextWindowToken: 131072,
104
+ maxCompletionToken: 8192,
105
+ type: "text-completion",
106
+ },
107
+ {
108
+ id: "@cf/deepseek-ai/deepseek-r1-distill-qwen-32b",
109
+ owner: "DeepSeek",
110
+ contextWindowToken: 131072,
111
+ maxCompletionToken: 8192,
112
+ type: "text-completion",
113
+ },
114
+ {
115
+ id: "@cf/mistral/mistral-7b-instruct-v0.1",
116
+ owner: "Mistral",
117
+ contextWindowToken: 32768,
118
+ maxCompletionToken: 8192,
119
+ type: "text-completion",
120
+ },
121
+ {
122
+ id: "@cf/mistralai/mistral-small-3.1-24b-instruct",
123
+ owner: "Mistral",
124
+ contextWindowToken: 131072,
125
+ maxCompletionToken: 8192,
126
+ type: "text-completion",
127
+ },
128
+ {
129
+ id: "@cf/meta/llama-3.1-8b-instruct",
130
+ owner: "Meta",
131
+ contextWindowToken: 131072,
132
+ maxCompletionToken: 8192,
133
+ type: "text-completion",
134
+ },
135
+ {
136
+ id: "@cf/meta/llama-3.1-8b-instruct-fp8",
137
+ owner: "Meta",
138
+ contextWindowToken: 131072,
139
+ maxCompletionToken: 8192,
140
+ type: "text-completion",
141
+ },
142
+ {
143
+ id: "@cf/meta/llama-3.1-8b-instruct-awq",
144
+ owner: "Meta",
145
+ contextWindowToken: 131072,
146
+ maxCompletionToken: 8192,
147
+ type: "text-completion",
148
+ },
149
+ {
150
+ id: "@cf/meta/llama-3-8b-instruct",
151
+ owner: "Meta",
152
+ contextWindowToken: 8192,
153
+ maxCompletionToken: 8192,
154
+ type: "text-completion",
155
+ },
156
+ {
157
+ id: "@cf/meta/llama-3-8b-instruct-awq",
158
+ owner: "Meta",
159
+ contextWindowToken: 8192,
160
+ maxCompletionToken: 8192,
161
+ type: "text-completion",
162
+ },
163
+ {
164
+ id: "@cf/meta/llama-2-7b-chat-fp16",
165
+ owner: "Meta",
166
+ contextWindowToken: 4096,
167
+ maxCompletionToken: 4096,
168
+ type: "text-completion",
169
+ },
170
+ {
171
+ id: "@cf/meta/llama-guard-3-8b",
172
+ owner: "Meta",
173
+ contextWindowToken: 131072,
174
+ maxCompletionToken: 8192,
175
+ type: "text-completion",
176
+ },
177
+ {
178
+ id: "@cf/meta/llama-4-scout-17b-16e-instruct",
179
+ owner: "Meta",
180
+ contextWindowToken: 131072,
181
+ maxCompletionToken: 8192,
182
+ type: "text-completion",
183
+ },
184
+ {
185
+ id: "@cf/google/gemma-3-12b-it",
186
+ owner: "Google",
187
+ contextWindowToken: 131072,
188
+ maxCompletionToken: 8192,
189
+ type: "text-completion",
190
+ },
191
+ {
192
+ id: "@cf/qwen/qwq-32b",
193
+ owner: "Qwen",
194
+ contextWindowToken: 131072,
195
+ maxCompletionToken: 8192,
196
+ type: "text-completion",
197
+ },
198
+ {
199
+ id: "@cf/qwen/qwen2.5-coder-32b-instruct",
200
+ owner: "Qwen",
201
+ contextWindowToken: 131072,
202
+ maxCompletionToken: 8192,
203
+ type: "text-completion",
204
+ },
205
+ {
206
+ id: "@cf/qwen/qwen3-30b-a3b-fp8",
207
+ owner: "Qwen",
208
+ contextWindowToken: 131072,
209
+ maxCompletionToken: 8192,
210
+ type: "text-completion",
211
+ },
212
+ {
213
+ id: "@cf/openai/gpt-oss-120b",
214
+ owner: "OpenAI",
215
+ contextWindowToken: 128000,
216
+ maxCompletionToken: 16384,
217
+ type: "text-completion",
218
+ },
219
+ {
220
+ id: "@cf/openai/gpt-oss-20b",
221
+ owner: "OpenAI",
222
+ contextWindowToken: 128000,
223
+ maxCompletionToken: 16384,
224
+ type: "text-completion",
225
+ },
226
+ {
227
+ id: "@cf/aisingapore/gemma-sea-lion-v4-27b-it",
228
+ owner: "AI Singapore",
229
+ contextWindowToken: 131072,
230
+ maxCompletionToken: 8192,
231
+ type: "text-completion",
232
+ },
233
+ {
234
+ id: "@cf/ibm-granite/granite-4.0-h-micro",
235
+ owner: "IBM",
236
+ contextWindowToken: 128000,
237
+ maxCompletionToken: 8192,
238
+ type: "text-completion",
239
+ },
240
+ {
241
+ id: "@cf/zai-org/glm-4.7-flash",
242
+ owner: "Zhipu AI",
243
+ contextWindowToken: 128000,
244
+ maxCompletionToken: 8192,
245
+ type: "text-completion",
246
+ },
247
+ {
248
+ id: "@cf/nvidia/nemotron-3-120b-a12b",
249
+ owner: "Nvidia",
250
+ contextWindowToken: 128000,
251
+ maxCompletionToken: 8192,
252
+ type: "text-completion",
253
+ },
254
+ {
255
+ id: "@cf/moonshotai/kimi-k2.5",
256
+ owner: "Moonshot AI",
257
+ contextWindowToken: 200000,
258
+ maxCompletionToken: 8192,
259
+ type: "text-completion",
260
+ },
261
+ {
262
+ id: "@cf/moonshotai/kimi-k2.6",
263
+ owner: "Moonshot AI",
264
+ contextWindowToken: 200000,
265
+ maxCompletionToken: 8192,
266
+ type: "text-completion",
267
+ },
268
+ {
269
+ id: "@cf/google/gemma-4-26b-a4b-it",
270
+ owner: "Google",
271
+ contextWindowToken: 131072,
272
+ maxCompletionToken: 8192,
273
+ type: "text-completion",
274
+ },
275
+
276
+ // Image Models
277
+ {
278
+ id: "@cf/black-forest-labs/flux-1-schnell",
279
+ owner: "Black Forest Labs",
280
+ contextWindowToken: 0,
281
+ maxCompletionToken: 1,
282
+ type: "image-generation",
283
+ },
284
+ {
285
+ id: "@cf/leonardo/lucid-origin",
286
+ owner: "Leonardo",
287
+ contextWindowToken: 0,
288
+ maxCompletionToken: 1,
289
+ type: "image-generation",
290
+ },
291
+ {
292
+ id: "@cf/leonardo/phoenix-1.0",
293
+ owner: "Leonardo",
294
+ contextWindowToken: 0,
295
+ maxCompletionToken: 1,
296
+ type: "image-generation",
297
+ },
298
+ {
299
+ id: "@cf/black-forest-labs/flux-2-dev",
300
+ owner: "Black Forest Labs",
301
+ contextWindowToken: 0,
302
+ maxCompletionToken: 1,
303
+ type: "image-generation",
304
+ },
305
+ {
306
+ id: "@cf/black-forest-labs/flux-2-klein-4b",
307
+ owner: "Black Forest Labs",
308
+ contextWindowToken: 0,
309
+ maxCompletionToken: 1,
310
+ type: "image-generation",
311
+ },
312
+ {
313
+ id: "@cf/black-forest-labs/flux-2-klein-9b",
314
+ owner: "Black Forest Labs",
315
+ contextWindowToken: 0,
316
+ maxCompletionToken: 1,
317
+ type: "image-generation",
318
+ },
319
+
320
+ // Audio Models
321
+ {
322
+ id: "@cf/openai/whisper",
323
+ owner: "OpenAI",
324
+ contextWindowToken: 4096,
325
+ maxCompletionToken: 0,
326
+ type: "audio-generation",
327
+ },
328
+ {
329
+ id: "@cf/openai/whisper-large-v3-turbo",
330
+ owner: "OpenAI",
331
+ contextWindowToken: 4096,
332
+ maxCompletionToken: 0,
333
+ type: "audio-generation",
334
+ },
335
+ {
336
+ id: "@cf/myshell-ai/melotts",
337
+ owner: "MyShell",
338
+ contextWindowToken: 4096,
339
+ maxCompletionToken: 0,
340
+ type: "audio-generation",
341
+ },
342
+ {
343
+ id: "@cf/deepgram/aura-1",
344
+ owner: "Deepgram",
345
+ contextWindowToken: 4096,
346
+ maxCompletionToken: 0,
347
+ type: "audio-generation",
348
+ },
349
+ {
350
+ id: "@cf/deepgram/nova-3",
351
+ owner: "Deepgram",
352
+ contextWindowToken: 4096,
353
+ maxCompletionToken: 0,
354
+ type: "audio-generation",
355
+ },
356
+ {
357
+ id: "@cf/deepgram/nova-3 (WebSocket)",
358
+ owner: "Deepgram",
359
+ contextWindowToken: 4096,
360
+ maxCompletionToken: 0,
361
+ type: "audio-generation",
362
+ },
363
+ {
364
+ id: "@cf/pipecat-ai/smart-turn-v2",
365
+ owner: "Pipecat",
366
+ contextWindowToken: 4096,
367
+ maxCompletionToken: 0,
368
+ type: "audio-generation",
369
+ },
370
+ {
371
+ id: "@cf/deepgram/aura-2-en",
372
+ owner: "Deepgram",
373
+ contextWindowToken: 4096,
374
+ maxCompletionToken: 0,
375
+ type: "audio-generation",
376
+ },
377
+ {
378
+ id: "@cf/deepgram/aura-2-es",
379
+ owner: "Deepgram",
380
+ contextWindowToken: 4096,
381
+ maxCompletionToken: 0,
382
+ type: "audio-generation",
383
+ },
384
+ {
385
+ id: "@cf/deepgram/flux (WebSocket)",
386
+ owner: "Deepgram",
387
+ contextWindowToken: 4096,
388
+ maxCompletionToken: 0,
389
+ type: "audio-generation",
390
+ },
391
+ ],
392
+ gemini: [
393
+ {
394
+ id: "gemini-2.5-pro",
395
+ owner: "Google",
396
+ contextWindowToken: 2000000,
397
+ maxCompletionToken: 8192,
398
+ type: "text-completion",
399
+ },
400
+ {
401
+ id: "gemini-2.5-flash",
402
+ owner: "Google",
403
+ contextWindowToken: 1000000,
404
+ maxCompletionToken: 8192,
405
+ type: "text-completion",
406
+ },
407
+ {
408
+ id: "imagen-3.0-generate-002",
409
+ owner: "Google",
410
+ contextWindowToken: 0,
411
+ maxCompletionToken: 1,
412
+ type: "image-generation",
413
+ },
414
+ ],
415
+ anthropic: [
416
+ {
417
+ id: "claude-opus-4-7",
418
+ owner: "Anthropic",
419
+ contextWindowToken: 1000000,
420
+ maxCompletionToken: 128000,
421
+ type: "text-completion",
422
+ },
423
+ {
424
+ id: "claude-sonnet-4-6",
425
+ owner: "Anthropic",
426
+ contextWindowToken: 1000000,
427
+ maxCompletionToken: 64000,
428
+ type: "text-completion",
429
+ },
430
+ {
431
+ id: "claude-haiku-4-5",
432
+ owner: "Anthropic",
433
+ contextWindowToken: 200000,
434
+ maxCompletionToken: 64000,
435
+ type: "text-completion",
436
+ },
437
+ ],
438
+ cerebras: [
439
+ {
440
+ id: "llama3.1-8b",
441
+ owner: "Meta",
442
+ contextWindowToken: 8192,
443
+ maxCompletionToken: 8192,
444
+ type: "text-completion",
445
+ },
446
+ {
447
+ id: "llama3.1-70b",
448
+ owner: "Meta",
449
+ contextWindowToken: 8192,
450
+ maxCompletionToken: 8192,
451
+ type: "text-completion",
452
+ },
453
+ {
454
+ id: "qwen-3-235b-a22b-instruct-2507",
455
+ owner: "Meta",
456
+ contextWindowToken: 100000,
457
+ maxCompletionToken: 40000,
458
+ type: "text-completion",
459
+ },
460
+ ],
461
+ } as const satisfies Record<
462
+ AiProvider,
463
+ ReadonlyArray<{
464
+ id: string;
465
+ owner: string;
466
+ created?: Date;
467
+ contextWindowToken: number;
468
+ maxCompletionToken: number;
469
+ type?: AiProviderModelType;
470
+ }>
471
+ >;
@@ -0,0 +1 @@
1
+ export * from "./providers.js";
@@ -0,0 +1,139 @@
1
+ import OpenAI from "openai";
2
+ import type { ChatCompletionCreateParamsBase } from "openai/resources/chat/completions.mjs";
3
+ import { AiInterface, type AiInterfaceConstructor } from "../ai-interface.js";
4
+ export class OpenAIClient extends AiInterface<OpenAI, "openAi"> {
5
+ constructor(props: AiInterfaceConstructor) {
6
+ super(props);
7
+ this.ai = new OpenAI({ apiKey: props.credentials.apiKey, baseURL: props.credentials.baseUrl });
8
+ }
9
+ ai: OpenAI;
10
+ async listModels(): Promise<any> {
11
+ return await this.ai.models.list();
12
+ }
13
+ async handleAi() {
14
+ const getCompletion = async (retries = 1): Promise<OpenAI.Chat.ChatCompletion> => {
15
+ try {
16
+ const tools = this.tools.getActiveTools().map(tool => ({
17
+ type: "function" as const,
18
+ function: {
19
+ name: tool.name,
20
+ description: tool.description,
21
+ parameters: tool.input_schema.toJSONSchema(),
22
+ } as const,
23
+ }));
24
+
25
+ const hasAnyTools =
26
+ tools.length > 0
27
+ ? ({
28
+ tools,
29
+ tool_choice: this.preferences.toolOnly ? "required" : "auto",
30
+ } as const)
31
+ : {};
32
+
33
+ const messages = this.chats.getMessages();
34
+ const response = await this.ai.chat.completions.create({
35
+ model: this.model,
36
+ messages: messages.map(e => ({
37
+ role: e.role,
38
+ content: e.content,
39
+ })) as unknown as ChatCompletionCreateParamsBase["messages"],
40
+ temperature: this.preferences.temperature,
41
+ ...hasAnyTools,
42
+ });
43
+ if (response.usage) {
44
+ this.event.emit("token", {
45
+ input: response.usage.prompt_tokens,
46
+ output: response.usage.completion_tokens,
47
+ });
48
+ }
49
+ return response;
50
+ } catch (error) {
51
+ const err = error as Error;
52
+ this.event.emit("log", {
53
+ type: "error",
54
+ message: err.message,
55
+ meta: err.cause as Record<string, unknown>,
56
+ stack: err.stack,
57
+ });
58
+ throw error;
59
+ }
60
+ };
61
+
62
+ let response = await getCompletion();
63
+
64
+ while (true) {
65
+ const choice = response?.choices?.[0];
66
+ if (!choice) {
67
+ this.event.emit("log", {
68
+ type: "warn",
69
+ message: `⚠️ No choices returned in response: ${JSON.stringify(response, null, 2)}`,
70
+ });
71
+ return;
72
+ }
73
+
74
+ const message = choice.message;
75
+ this.chats.addMessage({
76
+ role: "assistant",
77
+ content: message.content || "",
78
+ tool_calls: message.tool_calls,
79
+ timestamp: new Date(),
80
+ });
81
+ if (message.content) {
82
+ return;
83
+ }
84
+
85
+ if (!message.tool_calls?.length) {
86
+ return;
87
+ }
88
+
89
+ if (message.tool_calls?.length) {
90
+ for (const toolCall of message.tool_calls) {
91
+ switch (toolCall.type) {
92
+ case "function": {
93
+ let toolArgs: object;
94
+ try {
95
+ toolArgs = JSON.parse(toolCall.function.arguments) as object;
96
+ } catch (err) {
97
+ this.event.emit("log", {
98
+ type: "error",
99
+ message: `Tool: ${toolCall.function.name}⚠️ Failed to parse tool arguments: ${toolCall.function.arguments}`,
100
+ meta: { err },
101
+ // stack: (err as any).stack,
102
+ });
103
+ continue;
104
+ }
105
+ const result = await this.callTool({
106
+ args: toolArgs as Record<string, unknown>,
107
+ name: toolCall.function.name,
108
+ toolCallId: toolCall.id,
109
+ });
110
+
111
+ if (result.isCompleted) {
112
+ return;
113
+ }
114
+ if (result.isError) {
115
+ return;
116
+ }
117
+ break;
118
+ }
119
+ case "custom": {
120
+ this.event.emit("log", {
121
+ type: "error",
122
+ message: `Tool: ${toolCall.type}⚠️ Unsupported tool type: ${toolCall.type}`,
123
+ });
124
+ continue;
125
+ }
126
+ }
127
+ }
128
+
129
+ response = await getCompletion();
130
+ continue;
131
+ }
132
+ this.event.emit("log", {
133
+ type: "warn",
134
+ message: `⚠️ No content returned in response: ${JSON.stringify(response, null, 2)}`,
135
+ });
136
+ return;
137
+ }
138
+ }
139
+ }
@@ -0,0 +1,39 @@
1
+ import type { AiInterfaceConstructor } from "./ai-interface.js";
2
+ import { OpenAIClient } from "./openai/openai.js";
3
+ import type { AiProvider } from "./types.js";
4
+ export function aiProvider<T extends AiProvider>(type: T) {
5
+ return (props: AiInterfaceConstructor) => {
6
+ switch (type) {
7
+ case "openAi":
8
+ return new OpenAIClient(props);
9
+ case "anthropic":
10
+ return new OpenAIClient({
11
+ ...props,
12
+ credentials: {
13
+ apiKey: props.credentials.apiKey,
14
+ baseUrl: props.credentials.baseUrl || "https://api.anthropic.com/v1",
15
+ },
16
+ });
17
+ case "groq":
18
+ return new OpenAIClient({
19
+ ...props,
20
+ credentials: {
21
+ apiKey: props.credentials.apiKey,
22
+ baseUrl: props.credentials.baseUrl || "https://api.groq.com/openai/v1",
23
+ },
24
+ });
25
+ case "cerebras":
26
+ return new OpenAIClient({
27
+ ...props,
28
+ credentials: {
29
+ apiKey: props.credentials.apiKey,
30
+ baseUrl: props.credentials.baseUrl || "https://api.cerebras.ai/v1/",
31
+ },
32
+ });
33
+ case "cloudflare":
34
+ return new OpenAIClient(props);
35
+ default:
36
+ throw new Error("Provider not implemented");
37
+ }
38
+ };
39
+ }
@@ -0,0 +1,54 @@
1
+ export type AiProvider = "groq" | "openAi" | "cloudflare" | "gemini" | "anthropic" | "cerebras";
2
+ export type AiProviderModelType = "text-completion" | "image-generation" | "audio-generation";
3
+
4
+ export type AiChatRole = "user" | "system" | "assistant";
5
+
6
+ export type AiChatMessage =
7
+ | {
8
+ role: AiChatRole;
9
+ content: string;
10
+ timestamp: Date;
11
+ }
12
+ | {
13
+ role: "tool";
14
+ content: string;
15
+ tool_call_id: string;
16
+ timestamp: Date;
17
+ }
18
+ | {
19
+ role: "assistant";
20
+ content: string;
21
+ tool_calls: Array<{
22
+ type: "function" | "custom";
23
+ id: string;
24
+ }>;
25
+ timestamp: Date;
26
+ };
27
+
28
+ export type AiResource =
29
+ | {
30
+ type: "table";
31
+ data: Array<Record<string, unknown>>;
32
+ columns?: string[];
33
+ meta?: {
34
+ rowCount?: number;
35
+ };
36
+ }
37
+ | {
38
+ type: "image";
39
+ source: { kind: "url"; url: string } | { kind: "base64"; data: string; mimeType?: string };
40
+ alt?: string;
41
+ meta?: {
42
+ width?: number;
43
+ height?: number;
44
+ };
45
+ }
46
+ | {
47
+ type: "file";
48
+ source: { kind: "url"; url: string } | { kind: "base64"; data: string; mimeType?: string };
49
+ name?: string;
50
+ size?: number;
51
+ meta?: {
52
+ extension?: string;
53
+ };
54
+ };