friday-code 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.
@@ -0,0 +1,213 @@
1
+ import { createOpenAI } from '@ai-sdk/openai';
2
+ import { createAnthropic } from '@ai-sdk/anthropic';
3
+ import { createOpenAI as createOllamaProvider } from '@ai-sdk/openai';
4
+ import { extractReasoningMiddleware, wrapLanguageModel } from 'ai';
5
+ import { db } from '../../db/index.js';
6
+ import { providers, models, settings } from '../../db/schema.js';
7
+ import { eq } from 'drizzle-orm';
8
+ // Detect if an Ollama model uses reasoning (via <think> tags through OpenAI-compat)
9
+ function isOllamaReasoningModel(modelId) {
10
+ const lower = modelId.toLowerCase();
11
+ return lower.includes('think') || lower.includes('reason') ||
12
+ lower.includes('deepseek-r1') || lower.includes('qwq') ||
13
+ lower.includes(':thinking');
14
+ }
15
+ export function createModel(provider, modelId) {
16
+ switch (provider.type) {
17
+ case 'openai': {
18
+ const openai = createOpenAI({
19
+ apiKey: provider.apiKey || process.env.OPENAI_API_KEY || '',
20
+ baseURL: provider.baseUrl || undefined,
21
+ });
22
+ return openai(modelId);
23
+ }
24
+ case 'anthropic': {
25
+ const anthropic = createAnthropic({
26
+ apiKey: provider.apiKey || process.env.ANTHROPIC_API_KEY || '',
27
+ baseURL: provider.baseUrl || undefined,
28
+ });
29
+ return anthropic(modelId);
30
+ }
31
+ case 'ollama': {
32
+ const ollama = createOllamaProvider({
33
+ apiKey: 'ollama',
34
+ baseURL: (provider.baseUrl || 'http://localhost:11434') + '/v1',
35
+ });
36
+ const baseModel = ollama(modelId);
37
+ // All Ollama reasoning models use <think> tags through OpenAI-compat endpoint
38
+ if (isOllamaReasoningModel(modelId)) {
39
+ return wrapLanguageModel({
40
+ model: baseModel,
41
+ middleware: extractReasoningMiddleware({ tagName: 'think' }),
42
+ });
43
+ }
44
+ return baseModel;
45
+ }
46
+ default:
47
+ throw new Error(`Unknown provider type: ${provider.type}`);
48
+ }
49
+ }
50
+ export async function fetchModelsFromProvider(provider) {
51
+ const fetched = [];
52
+ try {
53
+ switch (provider.type) {
54
+ case 'openai': {
55
+ const apiKey = provider.apiKey || process.env.OPENAI_API_KEY;
56
+ if (!apiKey)
57
+ return [];
58
+ const res = await fetch(`${provider.baseUrl || 'https://api.openai.com/v1'}/models`, {
59
+ headers: { Authorization: `Bearer ${apiKey}` },
60
+ });
61
+ if (!res.ok)
62
+ return [];
63
+ const data = await res.json();
64
+ for (const m of data.data) {
65
+ if (m.id.startsWith('gpt-') || m.id.startsWith('o1') || m.id.startsWith('o3') || m.id.startsWith('o4')) {
66
+ fetched.push({
67
+ id: `openai:${m.id}`,
68
+ providerId: 'openai',
69
+ modelId: m.id,
70
+ name: m.id,
71
+ supportsStreaming: true,
72
+ supportsTools: !m.id.includes('instruct'),
73
+ supportsReasoning: m.id.startsWith('o1') || m.id.startsWith('o3') || m.id.startsWith('o4'),
74
+ contextWindow: m.id.includes('gpt-4') ? 128000 : 16384,
75
+ });
76
+ }
77
+ }
78
+ break;
79
+ }
80
+ case 'anthropic': {
81
+ // Anthropic doesn't have a public list endpoint, so we use known models
82
+ const claudeModels = [
83
+ { id: 'claude-sonnet-4-20250514', name: 'Claude Sonnet 4', reasoning: true, ctx: 200000 },
84
+ { id: 'claude-3-5-sonnet-20241022', name: 'Claude 3.5 Sonnet', reasoning: false, ctx: 200000 },
85
+ { id: 'claude-3-5-haiku-20241022', name: 'Claude 3.5 Haiku', reasoning: false, ctx: 200000 },
86
+ { id: 'claude-3-opus-20240229', name: 'Claude 3 Opus', reasoning: false, ctx: 200000 },
87
+ ];
88
+ for (const m of claudeModels) {
89
+ fetched.push({
90
+ id: `anthropic:${m.id}`,
91
+ providerId: 'anthropic',
92
+ modelId: m.id,
93
+ name: m.name,
94
+ supportsStreaming: true,
95
+ supportsTools: true,
96
+ supportsReasoning: m.reasoning,
97
+ contextWindow: m.ctx,
98
+ });
99
+ }
100
+ break;
101
+ }
102
+ case 'ollama': {
103
+ try {
104
+ const baseUrl = provider.baseUrl || 'http://localhost:11434';
105
+ const res = await fetch(`${baseUrl}/api/tags`);
106
+ if (!res.ok)
107
+ return [];
108
+ const data = await res.json();
109
+ for (const m of data.models || []) {
110
+ fetched.push({
111
+ id: `ollama:${m.name}`,
112
+ providerId: 'ollama',
113
+ modelId: m.name,
114
+ name: m.name,
115
+ supportsStreaming: true,
116
+ supportsTools: true,
117
+ supportsReasoning: isOllamaReasoningModel(m.name),
118
+ });
119
+ }
120
+ }
121
+ catch {
122
+ // Ollama might not be running
123
+ }
124
+ break;
125
+ }
126
+ }
127
+ }
128
+ catch {
129
+ // Network error
130
+ }
131
+ return fetched;
132
+ }
133
+ export function getProviders() {
134
+ return db.select().from(providers).all().map(p => ({
135
+ id: p.id,
136
+ name: p.name,
137
+ type: p.type,
138
+ apiKey: p.apiKey,
139
+ baseUrl: p.baseUrl,
140
+ isEnabled: p.isEnabled ?? true,
141
+ }));
142
+ }
143
+ export function updateProviderKey(providerId, apiKey) {
144
+ db.update(providers).set({ apiKey }).where(eq(providers.id, providerId)).run();
145
+ }
146
+ export function getSetting(key) {
147
+ const row = db.select().from(settings).where(eq(settings.key, key)).get();
148
+ return row?.value;
149
+ }
150
+ export function setSetting(key, value) {
151
+ db.insert(settings).values({ key, value })
152
+ .onConflictDoUpdate({ target: settings.key, set: { value } })
153
+ .run();
154
+ }
155
+ export function cacheModels(modelList) {
156
+ for (const m of modelList) {
157
+ db.insert(models).values({
158
+ id: m.id,
159
+ providerId: m.providerId,
160
+ modelId: m.modelId,
161
+ name: m.name,
162
+ supportsStreaming: m.supportsStreaming,
163
+ supportsTools: m.supportsTools,
164
+ supportsReasoning: m.supportsReasoning,
165
+ contextWindow: m.contextWindow,
166
+ }).onConflictDoUpdate({
167
+ target: models.id,
168
+ set: {
169
+ name: m.name,
170
+ supportsStreaming: m.supportsStreaming,
171
+ supportsTools: m.supportsTools,
172
+ supportsReasoning: m.supportsReasoning,
173
+ contextWindow: m.contextWindow,
174
+ },
175
+ }).run();
176
+ }
177
+ }
178
+ export function getCachedModels(providerId) {
179
+ const query = providerId
180
+ ? db.select().from(models).where(eq(models.providerId, providerId)).all()
181
+ : db.select().from(models).all();
182
+ return query.map(m => ({
183
+ id: m.id,
184
+ providerId: m.providerId,
185
+ modelId: m.modelId,
186
+ name: m.name,
187
+ supportsStreaming: m.supportsStreaming ?? true,
188
+ supportsTools: m.supportsTools ?? true,
189
+ supportsReasoning: m.supportsReasoning ?? false,
190
+ contextWindow: m.contextWindow ?? undefined,
191
+ }));
192
+ }
193
+ export function getActiveModelConfig() {
194
+ const providerId = getSetting('active_provider');
195
+ const modelId = getSetting('active_model');
196
+ if (!providerId || !modelId)
197
+ return null;
198
+ const provider = db.select().from(providers).where(eq(providers.id, providerId)).get();
199
+ if (!provider)
200
+ return null;
201
+ return {
202
+ provider: {
203
+ id: provider.id,
204
+ name: provider.name,
205
+ type: provider.type,
206
+ apiKey: provider.apiKey,
207
+ baseUrl: provider.baseUrl,
208
+ isEnabled: provider.isEnabled ?? true,
209
+ },
210
+ modelId,
211
+ };
212
+ }
213
+ //# sourceMappingURL=registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../src/core/providers/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,YAAY,IAAI,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtE,OAAO,EAAE,0BAA0B,EAAE,iBAAiB,EAAE,MAAM,IAAI,CAAC;AACnE,OAAO,EAAE,EAAE,EAAE,MAAM,mBAAmB,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAuBjC,oFAAoF;AACpF,SAAS,sBAAsB,C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odString;
5
+ }, "strip", z.ZodTypeAny, {
6
+ path: string;
7
+ }, {
8
+ path: string;
9
+ }>, {
10
+ content: string;
11
+ path: string;
12
+ error?: undefined;
13
+ } | {
14
+ error: any;
15
+ content?: undefined;
16
+ path?: undefined;
17
+ }> & {
18
+ execute: (args: {
19
+ path: string;
20
+ }, options: import("ai").ToolExecutionOptions) => PromiseLike<{
21
+ content: string;
22
+ path: string;
23
+ error?: undefined;
24
+ } | {
25
+ error: any;
26
+ content?: undefined;
27
+ path?: undefined;
28
+ }>;
29
+ };
30
+ writeFile: import("ai").Tool<z.ZodObject<{
31
+ path: z.ZodString;
32
+ content: z.ZodString;
33
+ }, "strip", z.ZodTypeAny, {
34
+ content: string;
35
+ path: string;
36
+ }, {
37
+ content: string;
38
+ path: string;
39
+ }>, {
40
+ success: boolean;
41
+ path: string;
42
+ error?: undefined;
43
+ } | {
44
+ error: any;
45
+ success?: undefined;
46
+ path?: undefined;
47
+ }> & {
48
+ execute: (args: {
49
+ content: string;
50
+ path: string;
51
+ }, options: import("ai").ToolExecutionOptions) => PromiseLike<{
52
+ success: boolean;
53
+ path: string;
54
+ error?: undefined;
55
+ } | {
56
+ error: any;
57
+ success?: undefined;
58
+ path?: undefined;
59
+ }>;
60
+ };
61
+ editFile: import("ai").Tool<z.ZodObject<{
62
+ path: z.ZodString;
63
+ oldText: z.ZodString;
64
+ newText: z.ZodString;
65
+ }, "strip", z.ZodTypeAny, {
66
+ path: string;
67
+ oldText: string;
68
+ newText: string;
69
+ }, {
70
+ path: string;
71
+ oldText: string;
72
+ newText: string;
73
+ }>, {
74
+ success: boolean;
75
+ path: string;
76
+ error?: undefined;
77
+ } | {
78
+ error: any;
79
+ success?: undefined;
80
+ path?: undefined;
81
+ }> & {
82
+ execute: (args: {
83
+ path: string;
84
+ oldText: string;
85
+ newText: string;
86
+ }, options: import("ai").ToolExecutionOptions) => PromiseLike<{
87
+ success: boolean;
88
+ path: string;
89
+ error?: undefined;
90
+ } | {
91
+ error: any;
92
+ success?: undefined;
93
+ path?: undefined;
94
+ }>;
95
+ };
96
+ listDirectory: import("ai").Tool<z.ZodObject<{
97
+ path: z.ZodDefault<z.ZodString>;
98
+ }, "strip", z.ZodTypeAny, {
99
+ path: string;
100
+ }, {
101
+ path?: string | undefined;
102
+ }>, {
103
+ entries: {
104
+ name: string;
105
+ type: string;
106
+ size: number;
107
+ }[];
108
+ path: string;
109
+ error?: undefined;
110
+ } | {
111
+ error: any;
112
+ entries?: undefined;
113
+ path?: undefined;
114
+ }> & {
115
+ execute: (args: {
116
+ path: string;
117
+ }, options: import("ai").ToolExecutionOptions) => PromiseLike<{
118
+ entries: {
119
+ name: string;
120
+ type: string;
121
+ size: number;
122
+ }[];
123
+ path: string;
124
+ error?: undefined;
125
+ } | {
126
+ error: any;
127
+ entries?: undefined;
128
+ path?: undefined;
129
+ }>;
130
+ };
131
+ searchFiles: import("ai").Tool<z.ZodObject<{
132
+ pattern: z.ZodString;
133
+ }, "strip", z.ZodTypeAny, {
134
+ pattern: string;
135
+ }, {
136
+ pattern: string;
137
+ }>, {
138
+ files: string[];
139
+ total: number;
140
+ error?: undefined;
141
+ } | {
142
+ error: any;
143
+ files?: undefined;
144
+ total?: undefined;
145
+ }> & {
146
+ execute: (args: {
147
+ pattern: string;
148
+ }, options: import("ai").ToolExecutionOptions) => PromiseLike<{
149
+ files: string[];
150
+ total: number;
151
+ error?: undefined;
152
+ } | {
153
+ error: any;
154
+ files?: undefined;
155
+ total?: undefined;
156
+ }>;
157
+ };
158
+ searchContent: import("ai").Tool<z.ZodObject<{
159
+ query: z.ZodString;
160
+ glob: z.ZodOptional<z.ZodString>;
161
+ }, "strip", z.ZodTypeAny, {
162
+ query: string;
163
+ glob?: string | undefined;
164
+ }, {
165
+ query: string;
166
+ glob?: string | undefined;
167
+ }>, {
168
+ matches: string[];
169
+ }> & {
170
+ execute: (args: {
171
+ query: string;
172
+ glob?: string | undefined;
173
+ }, options: import("ai").ToolExecutionOptions) => PromiseLike<{
174
+ matches: string[];
175
+ }>;
176
+ };
177
+ executeCommand: import("ai").Tool<z.ZodObject<{
178
+ command: z.ZodString;
179
+ }, "strip", z.ZodTypeAny, {
180
+ command: string;
181
+ }, {
182
+ command: string;
183
+ }>, {
184
+ error: string;
185
+ output?: undefined;
186
+ exitCode?: undefined;
187
+ } | {
188
+ output: string;
189
+ exitCode: number;
190
+ error?: undefined;
191
+ } | {
192
+ output: string;
193
+ exitCode: any;
194
+ error: any;
195
+ }> & {
196
+ execute: (args: {
197
+ command: string;
198
+ }, options: import("ai").ToolExecutionOptions) => PromiseLike<{
199
+ error: string;
200
+ output?: undefined;
201
+ exitCode?: undefined;
202
+ } | {
203
+ output: string;
204
+ exitCode: number;
205
+ error?: undefined;
206
+ } | {
207
+ output: string;
208
+ exitCode: any;
209
+ error: any;
210
+ }>;
211
+ };
212
+ gitStatus: import("ai").Tool<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>, {
213
+ staged: string[];
214
+ unstaged: string[];
215
+ untracked: string[];
216
+ clean: boolean;
217
+ error?: undefined;
218
+ } | {
219
+ error: any;
220
+ staged?: undefined;
221
+ unstaged?: undefined;
222
+ untracked?: undefined;
223
+ clean?: undefined;
224
+ }> & {
225
+ execute: (args: {}, options: import("ai").ToolExecutionOptions) => PromiseLike<{
226
+ staged: string[];
227
+ unstaged: string[];
228
+ untracked: string[];
229
+ clean: boolean;
230
+ error?: undefined;
231
+ } | {
232
+ error: any;
233
+ staged?: undefined;
234
+ unstaged?: undefined;
235
+ untracked?: undefined;
236
+ clean?: undefined;
237
+ }>;
238
+ };
239
+ gitDiff: import("ai").Tool<z.ZodObject<{
240
+ staged: z.ZodDefault<z.ZodBoolean>;
241
+ path: z.ZodOptional<z.ZodString>;
242
+ }, "strip", z.ZodTypeAny, {
243
+ staged: boolean;
244
+ path?: string | undefined;
245
+ }, {
246
+ path?: string | undefined;
247
+ staged?: boolean | undefined;
248
+ }>, {
249
+ diff: string;
250
+ truncated: boolean;
251
+ error?: undefined;
252
+ } | {
253
+ error: any;
254
+ diff?: undefined;
255
+ truncated?: undefined;
256
+ }> & {
257
+ execute: (args: {
258
+ staged: boolean;
259
+ path?: string | undefined;
260
+ }, options: import("ai").ToolExecutionOptions) => PromiseLike<{
261
+ diff: string;
262
+ truncated: boolean;
263
+ error?: undefined;
264
+ } | {
265
+ error: any;
266
+ diff?: undefined;
267
+ truncated?: undefined;
268
+ }>;
269
+ };
270
+ gitLog: import("ai").Tool<z.ZodObject<{
271
+ count: z.ZodDefault<z.ZodNumber>;
272
+ oneline: z.ZodDefault<z.ZodBoolean>;
273
+ }, "strip", z.ZodTypeAny, {
274
+ count: number;
275
+ oneline: boolean;
276
+ }, {
277
+ count?: number | undefined;
278
+ oneline?: boolean | undefined;
279
+ }>, {
280
+ commits: string[];
281
+ error?: undefined;
282
+ } | {
283
+ commits: {
284
+ hash: string;
285
+ author: string;
286
+ date: string;
287
+ message: string;
288
+ }[];
289
+ error?: undefined;
290
+ } | {
291
+ error: any;
292
+ commits?: undefined;
293
+ }> & {
294
+ execute: (args: {
295
+ count: number;
296
+ oneline: boolean;
297
+ }, options: import("ai").ToolExecutionOptions) => PromiseLike<{
298
+ commits: string[];
299
+ error?: undefined;
300
+ } | {
301
+ commits: {
302
+ hash: string;
303
+ author: string;
304
+ date: string;
305
+ message: string;
306
+ }[];
307
+ error?: undefined;
308
+ } | {
309
+ error: any;
310
+ commits?: undefined;
311
+ }>;
312
+ };
313
+ gitCommit: import("ai").Tool<z.ZodObject<{
314
+ message: z.ZodString;
315
+ files: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
316
+ }, "strip", z.ZodTypeAny, {
317
+ message: string;
318
+ files: string[];
319
+ }, {
320
+ message: string;
321
+ files?: string[] | undefined;
322
+ }>, {
323
+ success: boolean;
324
+ output: string;
325
+ error?: undefined;
326
+ } | {
327
+ error: any;
328
+ success?: undefined;
329
+ output?: undefined;
330
+ }> & {
331
+ execute: (args: {
332
+ message: string;
333
+ files: string[];
334
+ }, options: import("ai").ToolExecutionOptions) => PromiseLike<{
335
+ success: boolean;
336
+ output: string;
337
+ error?: undefined;
338
+ } | {
339
+ error: any;
340
+ success?: undefined;
341
+ output?: undefined;
342
+ }>;
343
+ };
344
+ webFetch: import("ai").Tool<z.ZodObject<{
345
+ url: z.ZodString;
346
+ maxLength: z.ZodDefault<z.ZodNumber>;
347
+ }, "strip", z.ZodTypeAny, {
348
+ url: string;
349
+ maxLength: number;
350
+ }, {
351
+ url: string;
352
+ maxLength?: number | undefined;
353
+ }>, {
354
+ content: string;
355
+ contentType: string;
356
+ truncated: boolean;
357
+ statusCode: number;
358
+ error?: undefined;
359
+ } | {
360
+ error: any;
361
+ content?: undefined;
362
+ contentType?: undefined;
363
+ truncated?: undefined;
364
+ statusCode?: undefined;
365
+ }> & {
366
+ execute: (args: {
367
+ url: string;
368
+ maxLength: number;
369
+ }, options: import("ai").ToolExecutionOptions) => PromiseLike<{
370
+ content: string;
371
+ contentType: string;
372
+ truncated: boolean;
373
+ statusCode: number;
374
+ error?: undefined;
375
+ } | {
376
+ error: any;
377
+ content?: undefined;
378
+ contentType?: undefined;
379
+ truncated?: undefined;
380
+ statusCode?: undefined;
381
+ }>;
382
+ };
383
+ runTests: import("ai").Tool<z.ZodObject<{
384
+ command: z.ZodOptional<z.ZodString>;
385
+ }, "strip", z.ZodTypeAny, {
386
+ command?: string | undefined;
387
+ }, {
388
+ command?: string | undefined;
389
+ }>, {
390
+ output: string;
391
+ exitCode: number;
392
+ command: string;
393
+ error?: undefined;
394
+ } | {
395
+ output: string;
396
+ exitCode: any;
397
+ command: string;
398
+ error: any;
399
+ }> & {
400
+ execute: (args: {
401
+ command?: string | undefined;
402
+ }, options: import("ai").ToolExecutionOptions) => PromiseLike<{
403
+ output: string;
404
+ exitCode: number;
405
+ command: string;
406
+ error?: undefined;
407
+ } | {
408
+ output: string;
409
+ exitCode: any;
410
+ command: string;
411
+ error: any;
412
+ }>;
413
+ };
414
+ };
415
+ /** Tool safety classification for human-in-the-loop approval */
416
+ export declare const TOOL_SAFETY: Record<string, 'safe' | 'destructive'>;