aieo 0.1.5 → 0.1.7
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/index.d.mts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +25 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as ai from 'ai';
|
|
2
2
|
import { CoreMessage } from 'ai';
|
|
3
|
+
export { CoreMessage } from 'ai';
|
|
3
4
|
|
|
4
5
|
interface Conversation {
|
|
5
6
|
id: string;
|
|
@@ -57,4 +58,7 @@ declare function getProviderOptions(provider: Provider): {
|
|
|
57
58
|
|
|
58
59
|
declare function callModel(provider: Provider, apiKey: string, messages: CoreMessage[], parser?: (fullResponse: string) => void): Promise<string>;
|
|
59
60
|
|
|
60
|
-
|
|
61
|
+
declare const SYSTEM = "You are an expert dev. You are given a codebase and a task. You need to write the code for the task. You can also suggest changes to the codebase if needed.\n\nAvoid assuming that certain functions are available in the codebase. Don't use to_timestamp or to_date in SQL if you don't see examples of them being used. DO NOT make up functions like a logger or other utils. Only use utility functions that you ABSOLUTELY know exist in the code.\n\nTry to write as simple and straightforward code as possible. Make a real implementation, do NOT do a mockup or add sample data. Assume there is already mock data in the database. If you see snippets of backend code, that means you have access to the backend codebase and can add new backend endpoints or other functionality as needed.\n\nYou will be provided with code snippets to edit or create. Please preserve the EXACT file paths when you make edits. Do not truncate the file paths.\n\nYou may see multiple code snippets from the same file! In that case, please organize the code properly: if you need to add an import statement, do it in the snippet that has other imports in it! Since you won't always be able to see the whole file, try to be careful and avoid adding new code just above a snippet, since you might not know exactly what other code is there.\n\nAlways remember to add correct code that will compile!!! Make sure to properly add function signatures if needed, such as to Go interfaces or Rust traits (if you see those in the code snippets).\n\nIf asked to make further changes after already writing code, use the <content> blocks from your previous edits in order to identify code snippets to replace.\n";
|
|
62
|
+
declare const OUTRO = "\nPlease write all the necessary code to fully implement the feature end-to-end. Do not make mock data or example placeholders!!!\n";
|
|
63
|
+
|
|
64
|
+
export { type Conversation, type ConversationData, ConversationStorage, MAX_CONVERSATIONS, OUTRO, PROVIDERS, type Provider, SYSTEM, callModel, getModel, getProviderOptions };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as ai from 'ai';
|
|
2
2
|
import { CoreMessage } from 'ai';
|
|
3
|
+
export { CoreMessage } from 'ai';
|
|
3
4
|
|
|
4
5
|
interface Conversation {
|
|
5
6
|
id: string;
|
|
@@ -57,4 +58,7 @@ declare function getProviderOptions(provider: Provider): {
|
|
|
57
58
|
|
|
58
59
|
declare function callModel(provider: Provider, apiKey: string, messages: CoreMessage[], parser?: (fullResponse: string) => void): Promise<string>;
|
|
59
60
|
|
|
60
|
-
|
|
61
|
+
declare const SYSTEM = "You are an expert dev. You are given a codebase and a task. You need to write the code for the task. You can also suggest changes to the codebase if needed.\n\nAvoid assuming that certain functions are available in the codebase. Don't use to_timestamp or to_date in SQL if you don't see examples of them being used. DO NOT make up functions like a logger or other utils. Only use utility functions that you ABSOLUTELY know exist in the code.\n\nTry to write as simple and straightforward code as possible. Make a real implementation, do NOT do a mockup or add sample data. Assume there is already mock data in the database. If you see snippets of backend code, that means you have access to the backend codebase and can add new backend endpoints or other functionality as needed.\n\nYou will be provided with code snippets to edit or create. Please preserve the EXACT file paths when you make edits. Do not truncate the file paths.\n\nYou may see multiple code snippets from the same file! In that case, please organize the code properly: if you need to add an import statement, do it in the snippet that has other imports in it! Since you won't always be able to see the whole file, try to be careful and avoid adding new code just above a snippet, since you might not know exactly what other code is there.\n\nAlways remember to add correct code that will compile!!! Make sure to properly add function signatures if needed, such as to Go interfaces or Rust traits (if you see those in the code snippets).\n\nIf asked to make further changes after already writing code, use the <content> blocks from your previous edits in order to identify code snippets to replace.\n";
|
|
62
|
+
declare const OUTRO = "\nPlease write all the necessary code to fully implement the feature end-to-end. Do not make mock data or example placeholders!!!\n";
|
|
63
|
+
|
|
64
|
+
export { type Conversation, type ConversationData, ConversationStorage, MAX_CONVERSATIONS, OUTRO, PROVIDERS, type Provider, SYSTEM, callModel, getModel, getProviderOptions };
|
package/dist/index.js
CHANGED
|
@@ -21,8 +21,11 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
ConversationStorage: () => ConversationStorage,
|
|
24
|
+
CoreMessage: () => import_ai2.CoreMessage,
|
|
24
25
|
MAX_CONVERSATIONS: () => MAX_CONVERSATIONS,
|
|
26
|
+
OUTRO: () => OUTRO,
|
|
25
27
|
PROVIDERS: () => PROVIDERS,
|
|
28
|
+
SYSTEM: () => SYSTEM,
|
|
26
29
|
callModel: () => callModel,
|
|
27
30
|
getModel: () => getModel,
|
|
28
31
|
getProviderOptions: () => getProviderOptions
|
|
@@ -240,11 +243,36 @@ async function callModel(provider, apiKey, messages, parser) {
|
|
|
240
243
|
}
|
|
241
244
|
return fullResponse;
|
|
242
245
|
}
|
|
246
|
+
|
|
247
|
+
// src/prompt.ts
|
|
248
|
+
var SYSTEM = `You are an expert dev. You are given a codebase and a task. You need to write the code for the task. You can also suggest changes to the codebase if needed.
|
|
249
|
+
|
|
250
|
+
Avoid assuming that certain functions are available in the codebase. Don't use to_timestamp or to_date in SQL if you don't see examples of them being used. DO NOT make up functions like a logger or other utils. Only use utility functions that you ABSOLUTELY know exist in the code.
|
|
251
|
+
|
|
252
|
+
Try to write as simple and straightforward code as possible. Make a real implementation, do NOT do a mockup or add sample data. Assume there is already mock data in the database. If you see snippets of backend code, that means you have access to the backend codebase and can add new backend endpoints or other functionality as needed.
|
|
253
|
+
|
|
254
|
+
You will be provided with code snippets to edit or create. Please preserve the EXACT file paths when you make edits. Do not truncate the file paths.
|
|
255
|
+
|
|
256
|
+
You may see multiple code snippets from the same file! In that case, please organize the code properly: if you need to add an import statement, do it in the snippet that has other imports in it! Since you won't always be able to see the whole file, try to be careful and avoid adding new code just above a snippet, since you might not know exactly what other code is there.
|
|
257
|
+
|
|
258
|
+
Always remember to add correct code that will compile!!! Make sure to properly add function signatures if needed, such as to Go interfaces or Rust traits (if you see those in the code snippets).
|
|
259
|
+
|
|
260
|
+
If asked to make further changes after already writing code, use the <content> blocks from your previous edits in order to identify code snippets to replace.
|
|
261
|
+
`;
|
|
262
|
+
var OUTRO = `
|
|
263
|
+
Please write all the necessary code to fully implement the feature end-to-end. Do not make mock data or example placeholders!!!
|
|
264
|
+
`;
|
|
265
|
+
|
|
266
|
+
// src/index.ts
|
|
267
|
+
var import_ai2 = require("ai");
|
|
243
268
|
// Annotate the CommonJS export names for ESM import in node:
|
|
244
269
|
0 && (module.exports = {
|
|
245
270
|
ConversationStorage,
|
|
271
|
+
CoreMessage,
|
|
246
272
|
MAX_CONVERSATIONS,
|
|
273
|
+
OUTRO,
|
|
247
274
|
PROVIDERS,
|
|
275
|
+
SYSTEM,
|
|
248
276
|
callModel,
|
|
249
277
|
getModel,
|
|
250
278
|
getProviderOptions
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../../node_modules/uuid/dist/esm/stringify.js","../../node_modules/uuid/dist/esm/rng.js","../../node_modules/uuid/dist/esm/native.js","../../node_modules/uuid/dist/esm/v4.js","../src/store.ts","../src/provider.ts","../src/stream.ts"],"sourcesContent":["export * from \"./store\";\nexport * from \"./provider\";\nexport * from \"./stream\";\n","import validate from './validate.js';\nconst byteToHex = [];\nfor (let i = 0; i < 256; ++i) {\n byteToHex.push((i + 0x100).toString(16).slice(1));\n}\nexport function unsafeStringify(arr, offset = 0) {\n return (byteToHex[arr[offset + 0]] +\n byteToHex[arr[offset + 1]] +\n byteToHex[arr[offset + 2]] +\n byteToHex[arr[offset + 3]] +\n '-' +\n byteToHex[arr[offset + 4]] +\n byteToHex[arr[offset + 5]] +\n '-' +\n byteToHex[arr[offset + 6]] +\n byteToHex[arr[offset + 7]] +\n '-' +\n byteToHex[arr[offset + 8]] +\n byteToHex[arr[offset + 9]] +\n '-' +\n byteToHex[arr[offset + 10]] +\n byteToHex[arr[offset + 11]] +\n byteToHex[arr[offset + 12]] +\n byteToHex[arr[offset + 13]] +\n byteToHex[arr[offset + 14]] +\n byteToHex[arr[offset + 15]]).toLowerCase();\n}\nfunction stringify(arr, offset = 0) {\n const uuid = unsafeStringify(arr, offset);\n if (!validate(uuid)) {\n throw TypeError('Stringified UUID is invalid');\n }\n return uuid;\n}\nexport default stringify;\n","import { randomFillSync } from 'crypto';\nconst rnds8Pool = new Uint8Array(256);\nlet poolPtr = rnds8Pool.length;\nexport default function rng() {\n if (poolPtr > rnds8Pool.length - 16) {\n randomFillSync(rnds8Pool);\n poolPtr = 0;\n }\n return rnds8Pool.slice(poolPtr, (poolPtr += 16));\n}\n","import { randomUUID } from 'crypto';\nexport default { randomUUID };\n","import native from './native.js';\nimport rng from './rng.js';\nimport { unsafeStringify } from './stringify.js';\nfunction v4(options, buf, offset) {\n if (native.randomUUID && !buf && !options) {\n return native.randomUUID();\n }\n options = options || {};\n const rnds = options.random ?? options.rng?.() ?? rng();\n if (rnds.length < 16) {\n throw new Error('Random bytes length must be >= 16');\n }\n rnds[6] = (rnds[6] & 0x0f) | 0x40;\n rnds[8] = (rnds[8] & 0x3f) | 0x80;\n if (buf) {\n offset = offset || 0;\n if (offset < 0 || offset + 16 > buf.length) {\n throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);\n }\n for (let i = 0; i < 16; ++i) {\n buf[offset + i] = rnds[i];\n }\n return buf;\n }\n return unsafeStringify(rnds);\n}\nexport default v4;\n","import { CoreMessage } from \"ai\";\nimport { v4 as uuidv4 } from \"uuid\";\n\nexport interface Conversation {\n id: string;\n summary: string;\n timestamp: number;\n}\n\nexport interface ConversationData {\n id: string;\n summary: string;\n messages: CoreMessage[];\n lastUpdated: number;\n}\n\nexport const MAX_CONVERSATIONS = 100;\n\nexport abstract class ConversationStorage {\n // Abstract methods to be implemented by platform-specific storage\n abstract currentConversationId(): Promise<string>;\n abstract selectConversation(conversationId: string): Promise<void>;\n abstract listConversations(): Promise<Conversation[]>;\n abstract getConversation(\n conversationId: string\n ): Promise<ConversationData | null>;\n abstract storeConversationData(\n conversationId: string,\n data: ConversationData\n ): Promise<void>;\n abstract deleteConversationData(conversationId: string): Promise<boolean>;\n\n // Shared functionality that works across platforms\n async createConversation(messages: CoreMessage[]): Promise<ConversationData> {\n const id = uuidv4();\n const initialMessage = messages.find((msg) => msg.role === \"user\");\n const summary = initialMessage\n ? this.generateSummary(initialMessage.content as string)\n : `New conversation ${new Date().toLocaleString()}`;\n const conversation: ConversationData = {\n id,\n summary,\n messages,\n lastUpdated: Date.now(),\n };\n await this.storeConversationData(id, conversation);\n await this.selectConversation(id);\n await this.pruneOldConversations();\n return conversation;\n }\n\n async addMessageToConversation(\n conversationId: string,\n message: CoreMessage\n ): Promise<ConversationData> {\n const conversation = await this.getConversation(conversationId);\n if (!conversation) {\n throw new Error(`Conversation with ID ${conversationId} not found`);\n }\n conversation.messages.push({ ...message });\n conversation.lastUpdated = Date.now();\n await this.storeConversationData(conversationId, conversation);\n return conversation;\n }\n\n async getCurrentConversation(): Promise<ConversationData | null> {\n const currentId = await this.currentConversationId();\n if (!currentId) return null;\n return await this.getConversation(currentId);\n }\n\n async getLatestConversation(): Promise<ConversationData | null> {\n const convos = await this.listConversations();\n if (!convos.length) return null;\n // Sort by most recent first\n const sortedConvos = [...convos].sort((a, b) => b.timestamp - a.timestamp);\n return await this.getConversation(sortedConvos[0].id);\n }\n\n async updateConversationSummary(\n conversationId: string,\n summary: string\n ): Promise<ConversationData> {\n const conversation = await this.getConversation(conversationId);\n if (!conversation) {\n throw new Error(`Conversation with ID ${conversationId} not found`);\n }\n conversation.summary = summary;\n conversation.lastUpdated = Date.now();\n await this.storeConversationData(conversationId, conversation);\n return conversation;\n }\n\n private async pruneOldConversations(): Promise<void> {\n const conversations = await this.listConversations();\n if (conversations.length <= MAX_CONVERSATIONS) return;\n // Sort by timestamp (oldest first)\n const sortedConversations = [...conversations].sort(\n (a, b) => a.timestamp - b.timestamp\n );\n // Calculate how many need to be deleted\n const deleteCount = sortedConversations.length - MAX_CONVERSATIONS;\n // Get the conversations to delete (the oldest ones)\n const conversationsToDelete = sortedConversations.slice(0, deleteCount);\n // Delete each conversation\n for (const convo of conversationsToDelete) {\n await this.deleteConversationData(convo.id);\n }\n }\n\n protected generateSummary(content: string): string {\n let summary = content.split(\"\\n\")[0].trim();\n if (summary.length > 50) {\n summary = summary.substring(0, 47) + \"...\";\n } else if (summary.length === 0 && content.length > 0) {\n summary = content.substring(0, Math.min(50, content.length));\n if (summary.length === 50) summary = summary + \"...\";\n } else if (summary.length === 0) {\n summary = `Conversation created on ${new Date().toLocaleString()}`;\n }\n return summary;\n }\n}\n","import { CoreMessage, streamText } from \"ai\";\nimport { createAnthropic, AnthropicProviderOptions } from \"@ai-sdk/anthropic\";\nimport {\n createGoogleGenerativeAI,\n GoogleGenerativeAIProviderOptions,\n} from \"@ai-sdk/google\";\nimport { createOpenAI, OpenAIResponsesProviderOptions } from \"@ai-sdk/openai\";\n\nexport type Provider = \"anthropic\" | \"google\" | \"openai\";\n\nexport const PROVIDERS: Provider[] = [\"anthropic\", \"google\", \"openai\"];\n\nconst SOTA = {\n anthropic: \"claude-3-7-sonnet-20250219\",\n google: \"gemini-2.5-pro-preview-05-06\",\n openai: \"gpt-4.1\",\n};\n\nexport async function getModel(provider: Provider, apiKey: string) {\n switch (provider) {\n case \"anthropic\":\n const anthropic = createAnthropic({\n apiKey,\n });\n return anthropic(SOTA[provider]);\n case \"google\":\n const google = createGoogleGenerativeAI({\n apiKey,\n });\n return google(SOTA[provider]);\n case \"openai\":\n const openai = createOpenAI({\n apiKey,\n compatibility: \"strict\",\n });\n return openai(SOTA[provider]);\n default:\n throw new Error(`Unsupported provider: ${provider}`);\n }\n}\n\nexport function getProviderOptions(provider: Provider) {\n switch (provider) {\n case \"anthropic\":\n return {\n anthropic: {\n thinking: { type: \"enabled\", budgetTokens: 24000 },\n } satisfies AnthropicProviderOptions,\n };\n case \"google\":\n return {\n google: {\n thinkingConfig: {\n thinkingBudget: 16384,\n },\n } satisfies GoogleGenerativeAIProviderOptions,\n };\n case \"openai\":\n return {\n openai: {} satisfies OpenAIResponsesProviderOptions,\n };\n default:\n throw new Error(`Unsupported provider: ${provider}`);\n }\n}\n","import { CoreMessage, streamText } from \"ai\";\nimport { Provider, getModel, getProviderOptions } from \"./provider\";\n\nexport async function callModel(\n provider: Provider,\n apiKey: string,\n messages: CoreMessage[],\n parser?: (fullResponse: string) => void\n): Promise<string> {\n const model = await getModel(provider, apiKey);\n const providerOptions = getProviderOptions(provider);\n console.log(`Calling ${provider} with options:`, providerOptions);\n const result = streamText({\n model,\n messages,\n temperature: 0,\n providerOptions: providerOptions as any,\n });\n let fullResponse = \"\";\n for await (const part of result.fullStream) {\n switch (part.type) {\n case \"error\":\n throw part.error;\n case \"text-delta\":\n if (parser) {\n parser(part.textDelta);\n }\n fullResponse += part.textDelta;\n break;\n }\n }\n return fullResponse;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,IAAM,YAAY,CAAC;AACnB,SAAS,IAAI,GAAG,IAAI,KAAK,EAAE,GAAG;AAC1B,YAAU,MAAM,IAAI,KAAO,SAAS,EAAE,EAAE,MAAM,CAAC,CAAC;AACpD;AACO,SAAS,gBAAgB,KAAK,SAAS,GAAG;AAC7C,UAAQ,UAAU,IAAI,SAAS,CAAC,CAAC,IAC7B,UAAU,IAAI,SAAS,CAAC,CAAC,IACzB,UAAU,IAAI,SAAS,CAAC,CAAC,IACzB,UAAU,IAAI,SAAS,CAAC,CAAC,IACzB,MACA,UAAU,IAAI,SAAS,CAAC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UAAU,MAAM;AAC7C,QAAM,kBAAkB,mBAAmB,QAAQ;AACnD,UAAQ,IAAI,WAAW,QAAQ,kBAAkB,eAAe;AAChE,QAAM,aAAS,sBAAW;AAAA,IACxB;AAAA,IACA;AAAA,IACA,aAAa;AAAA,IACb;AAAA,EACF,CAAC;AACD,MAAI,eAAe;AACnB,mBAAiB,QAAQ,OAAO,YAAY;AAC1C,YAAQ,KAAK,MAAM;AAAA,MACjB,KAAK;AACH,cAAM,KAAK;AAAA,MACb,KAAK;AACH,YAAI,QAAQ;AACV,iBAAO,KAAK,SAAS;AAAA,QACvB;AACA,wBAAgB,KAAK;AACrB;AAAA,IACJ;AAAA,EACF;AACA,SAAO;AACT;","names":["import_crypto"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../../node_modules/uuid/dist/esm/stringify.js","../../node_modules/uuid/dist/esm/rng.js","../../node_modules/uuid/dist/esm/native.js","../../node_modules/uuid/dist/esm/v4.js","../src/store.ts","../src/provider.ts","../src/stream.ts","../src/prompt.ts"],"sourcesContent":["export * from \"./store\";\nexport * from \"./provider\";\nexport * from \"./stream\";\nexport * from \"./prompt\";\n\nexport { CoreMessage } from \"ai\";\n","import validate from './validate.js';\nconst byteToHex = [];\nfor (let i = 0; i < 256; ++i) {\n byteToHex.push((i + 0x100).toString(16).slice(1));\n}\nexport function unsafeStringify(arr, offset = 0) {\n return (byteToHex[arr[offset + 0]] +\n byteToHex[arr[offset + 1]] +\n byteToHex[arr[offset + 2]] +\n byteToHex[arr[offset + 3]] +\n '-' +\n byteToHex[arr[offset + 4]] +\n byteToHex[arr[offset + 5]] +\n '-' +\n byteToHex[arr[offset + 6]] +\n byteToHex[arr[offset + 7]] +\n '-' +\n byteToHex[arr[offset + 8]] +\n byteToHex[arr[offset + 9]] +\n '-' +\n byteToHex[arr[offset + 10]] +\n byteToHex[arr[offset + 11]] +\n byteToHex[arr[offset + 12]] +\n byteToHex[arr[offset + 13]] +\n byteToHex[arr[offset + 14]] +\n byteToHex[arr[offset + 15]]).toLowerCase();\n}\nfunction stringify(arr, offset = 0) {\n const uuid = unsafeStringify(arr, offset);\n if (!validate(uuid)) {\n throw TypeError('Stringified UUID is invalid');\n }\n return uuid;\n}\nexport default stringify;\n","import { randomFillSync } from 'crypto';\nconst rnds8Pool = new Uint8Array(256);\nlet poolPtr = rnds8Pool.length;\nexport default function rng() {\n if (poolPtr > rnds8Pool.length - 16) {\n randomFillSync(rnds8Pool);\n poolPtr = 0;\n }\n return rnds8Pool.slice(poolPtr, (poolPtr += 16));\n}\n","import { randomUUID } from 'crypto';\nexport default { randomUUID };\n","import native from './native.js';\nimport rng from './rng.js';\nimport { unsafeStringify } from './stringify.js';\nfunction v4(options, buf, offset) {\n if (native.randomUUID && !buf && !options) {\n return native.randomUUID();\n }\n options = options || {};\n const rnds = options.random ?? options.rng?.() ?? rng();\n if (rnds.length < 16) {\n throw new Error('Random bytes length must be >= 16');\n }\n rnds[6] = (rnds[6] & 0x0f) | 0x40;\n rnds[8] = (rnds[8] & 0x3f) | 0x80;\n if (buf) {\n offset = offset || 0;\n if (offset < 0 || offset + 16 > buf.length) {\n throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);\n }\n for (let i = 0; i < 16; ++i) {\n buf[offset + i] = rnds[i];\n }\n return buf;\n }\n return unsafeStringify(rnds);\n}\nexport default v4;\n","import { CoreMessage } from \"ai\";\nimport { v4 as uuidv4 } from \"uuid\";\n\nexport interface Conversation {\n id: string;\n summary: string;\n timestamp: number;\n}\n\nexport interface ConversationData {\n id: string;\n summary: string;\n messages: CoreMessage[];\n lastUpdated: number;\n}\n\nexport const MAX_CONVERSATIONS = 100;\n\nexport abstract class ConversationStorage {\n // Abstract methods to be implemented by platform-specific storage\n abstract currentConversationId(): Promise<string>;\n abstract selectConversation(conversationId: string): Promise<void>;\n abstract listConversations(): Promise<Conversation[]>;\n abstract getConversation(\n conversationId: string\n ): Promise<ConversationData | null>;\n abstract storeConversationData(\n conversationId: string,\n data: ConversationData\n ): Promise<void>;\n abstract deleteConversationData(conversationId: string): Promise<boolean>;\n\n // Shared functionality that works across platforms\n async createConversation(messages: CoreMessage[]): Promise<ConversationData> {\n const id = uuidv4();\n const initialMessage = messages.find((msg) => msg.role === \"user\");\n const summary = initialMessage\n ? this.generateSummary(initialMessage.content as string)\n : `New conversation ${new Date().toLocaleString()}`;\n const conversation: ConversationData = {\n id,\n summary,\n messages,\n lastUpdated: Date.now(),\n };\n await this.storeConversationData(id, conversation);\n await this.selectConversation(id);\n await this.pruneOldConversations();\n return conversation;\n }\n\n async addMessageToConversation(\n conversationId: string,\n message: CoreMessage\n ): Promise<ConversationData> {\n const conversation = await this.getConversation(conversationId);\n if (!conversation) {\n throw new Error(`Conversation with ID ${conversationId} not found`);\n }\n conversation.messages.push({ ...message });\n conversation.lastUpdated = Date.now();\n await this.storeConversationData(conversationId, conversation);\n return conversation;\n }\n\n async getCurrentConversation(): Promise<ConversationData | null> {\n const currentId = await this.currentConversationId();\n if (!currentId) return null;\n return await this.getConversation(currentId);\n }\n\n async getLatestConversation(): Promise<ConversationData | null> {\n const convos = await this.listConversations();\n if (!convos.length) return null;\n // Sort by most recent first\n const sortedConvos = [...convos].sort((a, b) => b.timestamp - a.timestamp);\n return await this.getConversation(sortedConvos[0].id);\n }\n\n async updateConversationSummary(\n conversationId: string,\n summary: string\n ): Promise<ConversationData> {\n const conversation = await this.getConversation(conversationId);\n if (!conversation) {\n throw new Error(`Conversation with ID ${conversationId} not found`);\n }\n conversation.summary = summary;\n conversation.lastUpdated = Date.now();\n await this.storeConversationData(conversationId, conversation);\n return conversation;\n }\n\n private async pruneOldConversations(): Promise<void> {\n const conversations = await this.listConversations();\n if (conversations.length <= MAX_CONVERSATIONS) return;\n // Sort by timestamp (oldest first)\n const sortedConversations = [...conversations].sort(\n (a, b) => a.timestamp - b.timestamp\n );\n // Calculate how many need to be deleted\n const deleteCount = sortedConversations.length - MAX_CONVERSATIONS;\n // Get the conversations to delete (the oldest ones)\n const conversationsToDelete = sortedConversations.slice(0, deleteCount);\n // Delete each conversation\n for (const convo of conversationsToDelete) {\n await this.deleteConversationData(convo.id);\n }\n }\n\n protected generateSummary(content: string): string {\n let summary = content.split(\"\\n\")[0].trim();\n if (summary.length > 50) {\n summary = summary.substring(0, 47) + \"...\";\n } else if (summary.length === 0 && content.length > 0) {\n summary = content.substring(0, Math.min(50, content.length));\n if (summary.length === 50) summary = summary + \"...\";\n } else if (summary.length === 0) {\n summary = `Conversation created on ${new Date().toLocaleString()}`;\n }\n return summary;\n }\n}\n","import { createAnthropic, AnthropicProviderOptions } from \"@ai-sdk/anthropic\";\nimport {\n createGoogleGenerativeAI,\n GoogleGenerativeAIProviderOptions,\n} from \"@ai-sdk/google\";\nimport { createOpenAI, OpenAIResponsesProviderOptions } from \"@ai-sdk/openai\";\n\nexport type Provider = \"anthropic\" | \"google\" | \"openai\";\n\nexport const PROVIDERS: Provider[] = [\"anthropic\", \"google\", \"openai\"];\n\nconst SOTA = {\n anthropic: \"claude-3-7-sonnet-20250219\",\n google: \"gemini-2.5-pro-preview-05-06\",\n openai: \"gpt-4.1\",\n};\n\nexport async function getModel(provider: Provider, apiKey: string) {\n switch (provider) {\n case \"anthropic\":\n const anthropic = createAnthropic({\n apiKey,\n });\n return anthropic(SOTA[provider]);\n case \"google\":\n const google = createGoogleGenerativeAI({\n apiKey,\n });\n return google(SOTA[provider]);\n case \"openai\":\n const openai = createOpenAI({\n apiKey,\n compatibility: \"strict\",\n });\n return openai(SOTA[provider]);\n default:\n throw new Error(`Unsupported provider: ${provider}`);\n }\n}\n\nexport function getProviderOptions(provider: Provider) {\n switch (provider) {\n case \"anthropic\":\n return {\n anthropic: {\n thinking: { type: \"enabled\", budgetTokens: 24000 },\n } satisfies AnthropicProviderOptions,\n };\n case \"google\":\n return {\n google: {\n thinkingConfig: {\n thinkingBudget: 16384,\n },\n } satisfies GoogleGenerativeAIProviderOptions,\n };\n case \"openai\":\n return {\n openai: {} satisfies OpenAIResponsesProviderOptions,\n };\n default:\n throw new Error(`Unsupported provider: ${provider}`);\n }\n}\n","import { CoreMessage, streamText } from \"ai\";\nimport { Provider, getModel, getProviderOptions } from \"./provider\";\n\nexport async function callModel(\n provider: Provider,\n apiKey: string,\n messages: CoreMessage[],\n parser?: (fullResponse: string) => void\n): Promise<string> {\n const model = await getModel(provider, apiKey);\n const providerOptions = getProviderOptions(provider);\n console.log(`Calling ${provider} with options:`, providerOptions);\n const result = streamText({\n model,\n messages,\n temperature: 0,\n providerOptions: providerOptions as any,\n });\n let fullResponse = \"\";\n for await (const part of result.fullStream) {\n switch (part.type) {\n case \"error\":\n throw part.error;\n case \"text-delta\":\n if (parser) {\n parser(part.textDelta);\n }\n fullResponse += part.textDelta;\n break;\n }\n }\n return fullResponse;\n}\n","export const SYSTEM = `You are an expert dev. You are given a codebase and a task. You need to write the code for the task. You can also suggest changes to the codebase if needed.\n\nAvoid assuming that certain functions are available in the codebase. Don't use to_timestamp or to_date in SQL if you don't see examples of them being used. DO NOT make up functions like a logger or other utils. Only use utility functions that you ABSOLUTELY know exist in the code.\n\nTry to write as simple and straightforward code as possible. Make a real implementation, do NOT do a mockup or add sample data. Assume there is already mock data in the database. If you see snippets of backend code, that means you have access to the backend codebase and can add new backend endpoints or other functionality as needed.\n\nYou will be provided with code snippets to edit or create. Please preserve the EXACT file paths when you make edits. Do not truncate the file paths.\n\nYou may see multiple code snippets from the same file! In that case, please organize the code properly: if you need to add an import statement, do it in the snippet that has other imports in it! Since you won't always be able to see the whole file, try to be careful and avoid adding new code just above a snippet, since you might not know exactly what other code is there.\n\nAlways remember to add correct code that will compile!!! Make sure to properly add function signatures if needed, such as to Go interfaces or Rust traits (if you see those in the code snippets).\n\nIf asked to make further changes after already writing code, use the <content> blocks from your previous edits in order to identify code snippets to replace.\n`;\n\nexport const OUTRO = `\nPlease write all the necessary code to fully implement the feature end-to-end. Do not make mock data or example placeholders!!!\n`;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AA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AK;AACH,aAAO;AAAA,QACL,WAAW;AAAA,UACT,UAAU,EAAE,MAAM,WAAW,cAAc,KAAM;AAAA,QACnD;AAAA,MACF;AAAA,IACF,KAAK;AACH,aAAO;AAAA,QACL,QAAQ;AAAA,UACN,gBAAgB;AAAA,YACd,gBAAgB;AAAA,UAClB;AAAA,QACF;AAAA,MACF;AAAA,IACF,KAAK;AACH,aAAO;AAAA,QACL,QAAQ,CAAC;AAAA,MACX;AAAA,IACF;AACE,YAAM,IAAI,MAAM,yBAAyB,QAAQ,EAAE;AAAA,EACvD;AACF;;;AC/DA,gBAAwC;AAGxC,eAAsB,UACpB,UACA,QACA,UACA,QACiB;AACjB,QAAM,QAAQ,MAAM,SAAS,UAAU,MAAM;AAC7C,QAAM,kBAAkB,mBAAmB,QAAQ;AACnD,UAAQ,IAAI,WAAW,QAAQ,kBAAkB,eAAe;AAChE,QAAM,aAAS,sBAAW;AAAA,IACxB;AAAA,IACA;AAAA,IACA,aAAa;AAAA,IACb;AAAA,EACF,CAAC;AACD,MAAI,eAAe;AACnB,mBAAiB,QAAQ,OAAO,YAAY;AAC1C,YAAQ,KAAK,MAAM;AAAA,MACjB,KAAK;AACH,cAAM,KAAK;AAAA,MACb,KAAK;AACH,YAAI,QAAQ;AACV,iBAAO,KAAK,SAAS;AAAA,QACvB;AACA,wBAAgB,KAAK;AACrB;AAAA,IACJ;AAAA,EACF;AACA,SAAO;AACT;;;AChCO,IAAM,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAef,IAAM,QAAQ;AAAA;AAAA;;;ARVrB,IAAAC,aAA4B;","names":["import_crypto","import_ai"]}
|
package/dist/index.mjs
CHANGED
|
@@ -211,10 +211,35 @@ async function callModel(provider, apiKey, messages, parser) {
|
|
|
211
211
|
}
|
|
212
212
|
return fullResponse;
|
|
213
213
|
}
|
|
214
|
+
|
|
215
|
+
// src/prompt.ts
|
|
216
|
+
var SYSTEM = `You are an expert dev. You are given a codebase and a task. You need to write the code for the task. You can also suggest changes to the codebase if needed.
|
|
217
|
+
|
|
218
|
+
Avoid assuming that certain functions are available in the codebase. Don't use to_timestamp or to_date in SQL if you don't see examples of them being used. DO NOT make up functions like a logger or other utils. Only use utility functions that you ABSOLUTELY know exist in the code.
|
|
219
|
+
|
|
220
|
+
Try to write as simple and straightforward code as possible. Make a real implementation, do NOT do a mockup or add sample data. Assume there is already mock data in the database. If you see snippets of backend code, that means you have access to the backend codebase and can add new backend endpoints or other functionality as needed.
|
|
221
|
+
|
|
222
|
+
You will be provided with code snippets to edit or create. Please preserve the EXACT file paths when you make edits. Do not truncate the file paths.
|
|
223
|
+
|
|
224
|
+
You may see multiple code snippets from the same file! In that case, please organize the code properly: if you need to add an import statement, do it in the snippet that has other imports in it! Since you won't always be able to see the whole file, try to be careful and avoid adding new code just above a snippet, since you might not know exactly what other code is there.
|
|
225
|
+
|
|
226
|
+
Always remember to add correct code that will compile!!! Make sure to properly add function signatures if needed, such as to Go interfaces or Rust traits (if you see those in the code snippets).
|
|
227
|
+
|
|
228
|
+
If asked to make further changes after already writing code, use the <content> blocks from your previous edits in order to identify code snippets to replace.
|
|
229
|
+
`;
|
|
230
|
+
var OUTRO = `
|
|
231
|
+
Please write all the necessary code to fully implement the feature end-to-end. Do not make mock data or example placeholders!!!
|
|
232
|
+
`;
|
|
233
|
+
|
|
234
|
+
// src/index.ts
|
|
235
|
+
import { CoreMessage as CoreMessage2 } from "ai";
|
|
214
236
|
export {
|
|
215
237
|
ConversationStorage,
|
|
238
|
+
CoreMessage2 as CoreMessage,
|
|
216
239
|
MAX_CONVERSATIONS,
|
|
240
|
+
OUTRO,
|
|
217
241
|
PROVIDERS,
|
|
242
|
+
SYSTEM,
|
|
218
243
|
callModel,
|
|
219
244
|
getModel,
|
|
220
245
|
getProviderOptions
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../node_modules/uuid/dist/esm/stringify.js","../../node_modules/uuid/dist/esm/rng.js","../../node_modules/uuid/dist/esm/native.js","../../node_modules/uuid/dist/esm/v4.js","../src/store.ts","../src/provider.ts","../src/stream.ts"],"sourcesContent":["import validate from './validate.js';\nconst byteToHex = [];\nfor (let i = 0; i < 256; ++i) {\n byteToHex.push((i + 0x100).toString(16).slice(1));\n}\nexport function unsafeStringify(arr, offset = 0) {\n return (byteToHex[arr[offset + 0]] +\n byteToHex[arr[offset + 1]] +\n byteToHex[arr[offset + 2]] +\n byteToHex[arr[offset + 3]] +\n '-' +\n byteToHex[arr[offset + 4]] +\n byteToHex[arr[offset + 5]] +\n '-' +\n byteToHex[arr[offset + 6]] +\n byteToHex[arr[offset + 7]] +\n '-' +\n byteToHex[arr[offset + 8]] +\n byteToHex[arr[offset + 9]] +\n '-' +\n byteToHex[arr[offset + 10]] +\n byteToHex[arr[offset + 11]] +\n byteToHex[arr[offset + 12]] +\n byteToHex[arr[offset + 13]] +\n byteToHex[arr[offset + 14]] +\n byteToHex[arr[offset + 15]]).toLowerCase();\n}\nfunction stringify(arr, offset = 0) {\n const uuid = unsafeStringify(arr, offset);\n if (!validate(uuid)) {\n throw TypeError('Stringified UUID is invalid');\n }\n return uuid;\n}\nexport default stringify;\n","import { randomFillSync } from 'crypto';\nconst rnds8Pool = new Uint8Array(256);\nlet poolPtr = rnds8Pool.length;\nexport default function rng() {\n if (poolPtr > rnds8Pool.length - 16) {\n randomFillSync(rnds8Pool);\n poolPtr = 0;\n }\n return rnds8Pool.slice(poolPtr, (poolPtr += 16));\n}\n","import { randomUUID } from 'crypto';\nexport default { randomUUID };\n","import native from './native.js';\nimport rng from './rng.js';\nimport { unsafeStringify } from './stringify.js';\nfunction v4(options, buf, offset) {\n if (native.randomUUID && !buf && !options) {\n return native.randomUUID();\n }\n options = options || {};\n const rnds = options.random ?? options.rng?.() ?? rng();\n if (rnds.length < 16) {\n throw new Error('Random bytes length must be >= 16');\n }\n rnds[6] = (rnds[6] & 0x0f) | 0x40;\n rnds[8] = (rnds[8] & 0x3f) | 0x80;\n if (buf) {\n offset = offset || 0;\n if (offset < 0 || offset + 16 > buf.length) {\n throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);\n }\n for (let i = 0; i < 16; ++i) {\n buf[offset + i] = rnds[i];\n }\n return buf;\n }\n return unsafeStringify(rnds);\n}\nexport default v4;\n","import { CoreMessage } from \"ai\";\nimport { v4 as uuidv4 } from \"uuid\";\n\nexport interface Conversation {\n id: string;\n summary: string;\n timestamp: number;\n}\n\nexport interface ConversationData {\n id: string;\n summary: string;\n messages: CoreMessage[];\n lastUpdated: number;\n}\n\nexport const MAX_CONVERSATIONS = 100;\n\nexport abstract class ConversationStorage {\n // Abstract methods to be implemented by platform-specific storage\n abstract currentConversationId(): Promise<string>;\n abstract selectConversation(conversationId: string): Promise<void>;\n abstract listConversations(): Promise<Conversation[]>;\n abstract getConversation(\n conversationId: string\n ): Promise<ConversationData | null>;\n abstract storeConversationData(\n conversationId: string,\n data: ConversationData\n ): Promise<void>;\n abstract deleteConversationData(conversationId: string): Promise<boolean>;\n\n // Shared functionality that works across platforms\n async createConversation(messages: CoreMessage[]): Promise<ConversationData> {\n const id = uuidv4();\n const initialMessage = messages.find((msg) => msg.role === \"user\");\n const summary = initialMessage\n ? this.generateSummary(initialMessage.content as string)\n : `New conversation ${new Date().toLocaleString()}`;\n const conversation: ConversationData = {\n id,\n summary,\n messages,\n lastUpdated: Date.now(),\n };\n await this.storeConversationData(id, conversation);\n await this.selectConversation(id);\n await this.pruneOldConversations();\n return conversation;\n }\n\n async addMessageToConversation(\n conversationId: string,\n message: CoreMessage\n ): Promise<ConversationData> {\n const conversation = await this.getConversation(conversationId);\n if (!conversation) {\n throw new Error(`Conversation with ID ${conversationId} not found`);\n }\n conversation.messages.push({ ...message });\n conversation.lastUpdated = Date.now();\n await this.storeConversationData(conversationId, conversation);\n return conversation;\n }\n\n async getCurrentConversation(): Promise<ConversationData | null> {\n const currentId = await this.currentConversationId();\n if (!currentId) return null;\n return await this.getConversation(currentId);\n }\n\n async getLatestConversation(): Promise<ConversationData | null> {\n const convos = await this.listConversations();\n if (!convos.length) return null;\n // Sort by most recent first\n const sortedConvos = [...convos].sort((a, b) => b.timestamp - a.timestamp);\n return await this.getConversation(sortedConvos[0].id);\n }\n\n async updateConversationSummary(\n conversationId: string,\n summary: string\n ): Promise<ConversationData> {\n const conversation = await this.getConversation(conversationId);\n if (!conversation) {\n throw new Error(`Conversation with ID ${conversationId} not found`);\n }\n conversation.summary = summary;\n conversation.lastUpdated = Date.now();\n await this.storeConversationData(conversationId, conversation);\n return conversation;\n }\n\n private async pruneOldConversations(): Promise<void> {\n const conversations = await this.listConversations();\n if (conversations.length <= MAX_CONVERSATIONS) return;\n // Sort by timestamp (oldest first)\n const sortedConversations = [...conversations].sort(\n (a, b) => a.timestamp - b.timestamp\n );\n // Calculate how many need to be deleted\n const deleteCount = sortedConversations.length - MAX_CONVERSATIONS;\n // Get the conversations to delete (the oldest ones)\n const conversationsToDelete = sortedConversations.slice(0, deleteCount);\n // Delete each conversation\n for (const convo of conversationsToDelete) {\n await this.deleteConversationData(convo.id);\n }\n }\n\n protected generateSummary(content: string): string {\n let summary = content.split(\"\\n\")[0].trim();\n if (summary.length > 50) {\n summary = summary.substring(0, 47) + \"...\";\n } else if (summary.length === 0 && content.length > 0) {\n summary = content.substring(0, Math.min(50, content.length));\n if (summary.length === 50) summary = summary + \"...\";\n } else if (summary.length === 0) {\n summary = `Conversation created on ${new Date().toLocaleString()}`;\n }\n return summary;\n }\n}\n","import { CoreMessage, streamText } from \"ai\";\nimport { createAnthropic, AnthropicProviderOptions } from \"@ai-sdk/anthropic\";\nimport {\n createGoogleGenerativeAI,\n GoogleGenerativeAIProviderOptions,\n} from \"@ai-sdk/google\";\nimport { createOpenAI, OpenAIResponsesProviderOptions } from \"@ai-sdk/openai\";\n\nexport type Provider = \"anthropic\" | \"google\" | \"openai\";\n\nexport const PROVIDERS: Provider[] = [\"anthropic\", \"google\", \"openai\"];\n\nconst SOTA = {\n anthropic: \"claude-3-7-sonnet-20250219\",\n google: \"gemini-2.5-pro-preview-05-06\",\n openai: \"gpt-4.1\",\n};\n\nexport async function getModel(provider: Provider, apiKey: string) {\n switch (provider) {\n case \"anthropic\":\n const anthropic = createAnthropic({\n apiKey,\n });\n return anthropic(SOTA[provider]);\n case \"google\":\n const google = createGoogleGenerativeAI({\n apiKey,\n });\n return google(SOTA[provider]);\n case \"openai\":\n const openai = createOpenAI({\n apiKey,\n compatibility: \"strict\",\n });\n return openai(SOTA[provider]);\n default:\n throw new Error(`Unsupported provider: ${provider}`);\n }\n}\n\nexport function getProviderOptions(provider: Provider) {\n switch (provider) {\n case \"anthropic\":\n return {\n anthropic: {\n thinking: { type: \"enabled\", budgetTokens: 24000 },\n } satisfies AnthropicProviderOptions,\n };\n case \"google\":\n return {\n google: {\n thinkingConfig: {\n thinkingBudget: 16384,\n },\n } satisfies GoogleGenerativeAIProviderOptions,\n };\n case \"openai\":\n return {\n openai: {} satisfies OpenAIResponsesProviderOptions,\n };\n default:\n throw new Error(`Unsupported provider: ${provider}`);\n }\n}\n","import { CoreMessage, streamText } from \"ai\";\nimport { Provider, getModel, getProviderOptions } from \"./provider\";\n\nexport async function callModel(\n provider: Provider,\n apiKey: string,\n messages: CoreMessage[],\n parser?: (fullResponse: string) => void\n): Promise<string> {\n const model = await getModel(provider, apiKey);\n const providerOptions = getProviderOptions(provider);\n console.log(`Calling ${provider} with options:`, providerOptions);\n const result = streamText({\n model,\n messages,\n temperature: 0,\n providerOptions: providerOptions as any,\n });\n let fullResponse = \"\";\n for await (const part of result.fullStream) {\n switch (part.type) {\n case \"error\":\n throw part.error;\n case \"text-delta\":\n if (parser) {\n parser(part.textDelta);\n }\n fullResponse += part.textDelta;\n break;\n }\n }\n return fullResponse;\n}\n"],"mappings":";AACA,IAAM,YAAY,CAAC;AACnB,SAAS,IAAI,GAAG,IAAI,KAAK,EAAE,GAAG;AAC1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H,aAAO;AAAA,QACL,QAAQ;AAAA,UACN,gBAAgB;AAAA,YACd,gBAAgB;AAAA,UAClB;AAAA,QACF;AAAA,MACF;AAAA,IACF,KAAK;AACH,aAAO;AAAA,QACL,QAAQ,CAAC;AAAA,MACX;AAAA,IACF;AACE,YAAM,IAAI,MAAM,yBAAyB,QAAQ,EAAE;AAAA,EACvD;AACF;;;AChEA,SAAsB,kBAAkB;AAGxC,eAAsB,UACpB,UACA,QACA,UACA,QACiB;AACjB,QAAM,QAAQ,MAAM,SAAS,UAAU,MAAM;AAC7C,QAAM,kBAAkB,mBAAmB,QAAQ;AACnD,UAAQ,IAAI,WAAW,QAAQ,kBAAkB,eAAe;AAChE,QAAM,SAAS,WAAW;AAAA,IACxB;AAAA,IACA;AAAA,IACA,aAAa;AAAA,IACb;AAAA,EACF,CAAC;AACD,MAAI,eAAe;AACnB,mBAAiB,QAAQ,OAAO,YAAY;AAC1C,YAAQ,KAAK,MAAM;AAAA,MACjB,KAAK;AACH,cAAM,KAAK;AAAA,MACb,KAAK;AACH,YAAI,QAAQ;AACV,iBAAO,KAAK,SAAS;AAAA,QACvB;AACA,wBAAgB,KAAK;AACrB;AAAA,IACJ;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../node_modules/uuid/dist/esm/stringify.js","../../node_modules/uuid/dist/esm/rng.js","../../node_modules/uuid/dist/esm/native.js","../../node_modules/uuid/dist/esm/v4.js","../src/store.ts","../src/provider.ts","../src/stream.ts","../src/prompt.ts","../src/index.ts"],"sourcesContent":["import validate from './validate.js';\nconst byteToHex = [];\nfor (let i = 0; i < 256; ++i) {\n byteToHex.push((i + 0x100).toString(16).slice(1));\n}\nexport function unsafeStringify(arr, offset = 0) {\n return (byteToHex[arr[offset + 0]] +\n byteToHex[arr[offset + 1]] +\n byteToHex[arr[offset + 2]] +\n byteToHex[arr[offset + 3]] +\n '-' +\n byteToHex[arr[offset + 4]] +\n byteToHex[arr[offset + 5]] +\n '-' +\n byteToHex[arr[offset + 6]] +\n byteToHex[arr[offset + 7]] +\n '-' +\n byteToHex[arr[offset + 8]] +\n byteToHex[arr[offset + 9]] +\n '-' +\n byteToHex[arr[offset + 10]] +\n byteToHex[arr[offset + 11]] +\n byteToHex[arr[offset + 12]] +\n byteToHex[arr[offset + 13]] +\n byteToHex[arr[offset + 14]] +\n byteToHex[arr[offset + 15]]).toLowerCase();\n}\nfunction stringify(arr, offset = 0) {\n const uuid = unsafeStringify(arr, offset);\n if (!validate(uuid)) {\n throw TypeError('Stringified UUID is invalid');\n }\n return uuid;\n}\nexport default stringify;\n","import { randomFillSync } from 'crypto';\nconst rnds8Pool = new Uint8Array(256);\nlet poolPtr = rnds8Pool.length;\nexport default function rng() {\n if (poolPtr > rnds8Pool.length - 16) {\n randomFillSync(rnds8Pool);\n poolPtr = 0;\n }\n return rnds8Pool.slice(poolPtr, (poolPtr += 16));\n}\n","import { randomUUID } from 'crypto';\nexport default { randomUUID };\n","import native from './native.js';\nimport rng from './rng.js';\nimport { unsafeStringify } from './stringify.js';\nfunction v4(options, buf, offset) {\n if (native.randomUUID && !buf && !options) {\n return native.randomUUID();\n }\n options = options || {};\n const rnds = options.random ?? options.rng?.() ?? rng();\n if (rnds.length < 16) {\n throw new Error('Random bytes length must be >= 16');\n }\n rnds[6] = (rnds[6] & 0x0f) | 0x40;\n rnds[8] = (rnds[8] & 0x3f) | 0x80;\n if (buf) {\n offset = offset || 0;\n if (offset < 0 || offset + 16 > buf.length) {\n throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);\n }\n for (let i = 0; i < 16; ++i) {\n buf[offset + i] = rnds[i];\n }\n return buf;\n }\n return unsafeStringify(rnds);\n}\nexport default v4;\n","import { CoreMessage } from \"ai\";\nimport { v4 as uuidv4 } from \"uuid\";\n\nexport interface Conversation {\n id: string;\n summary: string;\n timestamp: number;\n}\n\nexport interface ConversationData {\n id: string;\n summary: string;\n messages: CoreMessage[];\n lastUpdated: number;\n}\n\nexport const MAX_CONVERSATIONS = 100;\n\nexport abstract class ConversationStorage {\n // Abstract methods to be implemented by platform-specific storage\n abstract currentConversationId(): Promise<string>;\n abstract selectConversation(conversationId: string): Promise<void>;\n abstract listConversations(): Promise<Conversation[]>;\n abstract getConversation(\n conversationId: string\n ): Promise<ConversationData | null>;\n abstract storeConversationData(\n conversationId: string,\n data: ConversationData\n ): Promise<void>;\n abstract deleteConversationData(conversationId: string): Promise<boolean>;\n\n // Shared functionality that works across platforms\n async createConversation(messages: CoreMessage[]): Promise<ConversationData> {\n const id = uuidv4();\n const initialMessage = messages.find((msg) => msg.role === \"user\");\n const summary = initialMessage\n ? this.generateSummary(initialMessage.content as string)\n : `New conversation ${new Date().toLocaleString()}`;\n const conversation: ConversationData = {\n id,\n summary,\n messages,\n lastUpdated: Date.now(),\n };\n await this.storeConversationData(id, conversation);\n await this.selectConversation(id);\n await this.pruneOldConversations();\n return conversation;\n }\n\n async addMessageToConversation(\n conversationId: string,\n message: CoreMessage\n ): Promise<ConversationData> {\n const conversation = await this.getConversation(conversationId);\n if (!conversation) {\n throw new Error(`Conversation with ID ${conversationId} not found`);\n }\n conversation.messages.push({ ...message });\n conversation.lastUpdated = Date.now();\n await this.storeConversationData(conversationId, conversation);\n return conversation;\n }\n\n async getCurrentConversation(): Promise<ConversationData | null> {\n const currentId = await this.currentConversationId();\n if (!currentId) return null;\n return await this.getConversation(currentId);\n }\n\n async getLatestConversation(): Promise<ConversationData | null> {\n const convos = await this.listConversations();\n if (!convos.length) return null;\n // Sort by most recent first\n const sortedConvos = [...convos].sort((a, b) => b.timestamp - a.timestamp);\n return await this.getConversation(sortedConvos[0].id);\n }\n\n async updateConversationSummary(\n conversationId: string,\n summary: string\n ): Promise<ConversationData> {\n const conversation = await this.getConversation(conversationId);\n if (!conversation) {\n throw new Error(`Conversation with ID ${conversationId} not found`);\n }\n conversation.summary = summary;\n conversation.lastUpdated = Date.now();\n await this.storeConversationData(conversationId, conversation);\n return conversation;\n }\n\n private async pruneOldConversations(): Promise<void> {\n const conversations = await this.listConversations();\n if (conversations.length <= MAX_CONVERSATIONS) return;\n // Sort by timestamp (oldest first)\n const sortedConversations = [...conversations].sort(\n (a, b) => a.timestamp - b.timestamp\n );\n // Calculate how many need to be deleted\n const deleteCount = sortedConversations.length - MAX_CONVERSATIONS;\n // Get the conversations to delete (the oldest ones)\n const conversationsToDelete = sortedConversations.slice(0, deleteCount);\n // Delete each conversation\n for (const convo of conversationsToDelete) {\n await this.deleteConversationData(convo.id);\n }\n }\n\n protected generateSummary(content: string): string {\n let summary = content.split(\"\\n\")[0].trim();\n if (summary.length > 50) {\n summary = summary.substring(0, 47) + \"...\";\n } else if (summary.length === 0 && content.length > 0) {\n summary = content.substring(0, Math.min(50, content.length));\n if (summary.length === 50) summary = summary + \"...\";\n } else if (summary.length === 0) {\n summary = `Conversation created on ${new Date().toLocaleString()}`;\n }\n return summary;\n }\n}\n","import { createAnthropic, AnthropicProviderOptions } from \"@ai-sdk/anthropic\";\nimport {\n createGoogleGenerativeAI,\n GoogleGenerativeAIProviderOptions,\n} from \"@ai-sdk/google\";\nimport { createOpenAI, OpenAIResponsesProviderOptions } from \"@ai-sdk/openai\";\n\nexport type Provider = \"anthropic\" | \"google\" | \"openai\";\n\nexport const PROVIDERS: Provider[] = [\"anthropic\", \"google\", \"openai\"];\n\nconst SOTA = {\n anthropic: \"claude-3-7-sonnet-20250219\",\n google: \"gemini-2.5-pro-preview-05-06\",\n openai: \"gpt-4.1\",\n};\n\nexport async function getModel(provider: Provider, apiKey: string) {\n switch (provider) {\n case \"anthropic\":\n const anthropic = createAnthropic({\n apiKey,\n });\n return anthropic(SOTA[provider]);\n case \"google\":\n const google = createGoogleGenerativeAI({\n apiKey,\n });\n return google(SOTA[provider]);\n case \"openai\":\n const openai = createOpenAI({\n apiKey,\n compatibility: \"strict\",\n });\n return openai(SOTA[provider]);\n default:\n throw new Error(`Unsupported provider: ${provider}`);\n }\n}\n\nexport function getProviderOptions(provider: Provider) {\n switch (provider) {\n case \"anthropic\":\n return {\n anthropic: {\n thinking: { type: \"enabled\", budgetTokens: 24000 },\n } satisfies AnthropicProviderOptions,\n };\n case \"google\":\n return {\n google: {\n thinkingConfig: {\n thinkingBudget: 16384,\n },\n } satisfies GoogleGenerativeAIProviderOptions,\n };\n case \"openai\":\n return {\n openai: {} satisfies OpenAIResponsesProviderOptions,\n };\n default:\n throw new Error(`Unsupported provider: ${provider}`);\n }\n}\n","import { CoreMessage, streamText } from \"ai\";\nimport { Provider, getModel, getProviderOptions } from \"./provider\";\n\nexport async function callModel(\n provider: Provider,\n apiKey: string,\n messages: CoreMessage[],\n parser?: (fullResponse: string) => void\n): Promise<string> {\n const model = await getModel(provider, apiKey);\n const providerOptions = getProviderOptions(provider);\n console.log(`Calling ${provider} with options:`, providerOptions);\n const result = streamText({\n model,\n messages,\n temperature: 0,\n providerOptions: providerOptions as any,\n });\n let fullResponse = \"\";\n for await (const part of result.fullStream) {\n switch (part.type) {\n case \"error\":\n throw part.error;\n case \"text-delta\":\n if (parser) {\n parser(part.textDelta);\n }\n fullResponse += part.textDelta;\n break;\n }\n }\n return fullResponse;\n}\n","export const SYSTEM = `You are an expert dev. You are given a codebase and a task. You need to write the code for the task. You can also suggest changes to the codebase if needed.\n\nAvoid assuming that certain functions are available in the codebase. Don't use to_timestamp or to_date in SQL if you don't see examples of them being used. DO NOT make up functions like a logger or other utils. Only use utility functions that you ABSOLUTELY know exist in the code.\n\nTry to write as simple and straightforward code as possible. Make a real implementation, do NOT do a mockup or add sample data. Assume there is already mock data in the database. If you see snippets of backend code, that means you have access to the backend codebase and can add new backend endpoints or other functionality as needed.\n\nYou will be provided with code snippets to edit or create. Please preserve the EXACT file paths when you make edits. Do not truncate the file paths.\n\nYou may see multiple code snippets from the same file! In that case, please organize the code properly: if you need to add an import statement, do it in the snippet that has other imports in it! Since you won't always be able to see the whole file, try to be careful and avoid adding new code just above a snippet, since you might not know exactly what other code is there.\n\nAlways remember to add correct code that will compile!!! Make sure to properly add function signatures if needed, such as to Go interfaces or Rust traits (if you see those in the code snippets).\n\nIf asked to make further changes after already writing code, use the <content> blocks from your previous edits in order to identify code snippets to replace.\n`;\n\nexport const OUTRO = `\nPlease write all the necessary code to fully implement the feature end-to-end. Do not make mock data or example placeholders!!!\n`;\n","export * from \"./store\";\nexport * from \"./provider\";\nexport * from \"./stream\";\nexport * from \"./prompt\";\n\nexport { CoreMessage } from \"ai\";\n"],"mappings":";AACA,IAAM,YAAY,CAAC;AACnB,SAAS,IAAI,GAAG,IAAI,KAAK,EAAE,GAAG;AAC1B,YAAU,MAAM,IAAI,KAAO,SAAS,EAAE,EAAE,MAAM,CAAC,CAAC;AACpD;AACO,SAAS,gBAAgB,KAAK,SAAS,GAAG;AAC7C,UAAQ,UAAU,IAAI,SAAS,CAAC,CAAC,IAC7B,UAAU,IAAI,SAAS,CAAC,CAAC,IACzB,UAAU,IAAI,SAAS,CAAC,CAAC,IACzB,UAAU,IAAI,SAAS,CAAC,CAAC,IACzB,MACA,UAAU,IAAI,SAAS,CAAC,CAAC,IACzB,UAAU,IAAI,SAAS,CAAC,CAAC,IACzB,MACA,UAAU,IAAI,SAAS,CAAC,CAAC,IACzB,UAAU,IAAI,SAAS,CAAC,CAAC,IACzB,MACA,UAAU,IAAI,SAAS,CAAC,CAAC,IACzB,UAAU,IAAI,SAAS,CAAC,CAAC,IACzB,MACA,UAAU,IAAI,SAAS,EAAE,CAAC,IAC1B,UAAU,IAAI,SAAS,EAAE,CAAC,IAC1B,UAAU,IAAI,SAAS,EAAE,CAAC,IAC1B,UAAU,IAAI,SAAS,EAAE,CAAC,IAC1B,UAAU,IAAI,SAAS,EAAE,CAAC,IAC1B,UAAU,IAAI,SAAS,EAAE,CAAC,GAAG,YAAY;AACjD;;;AC1BA,SAAS,sBAAsB;AAC/B,IAAM,YAAY,IAAI,WAAW,GAAG;AACpC,IAAI,UAAU,UAAU;AACT,SAAR,MAAuB;AAC1B,MAAI,UAAU,UAAU,S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