Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

chore: add sentry to screenpipe-cloud and better error handling for anthropic provider

Louis Beaumont0de2a8796328
diff --git a/screenpipe-actions/ai-proxy/bun.lockb b/screenpipe-actions/ai-proxy/bun.lockb
index a989925c4..7307f9fad 100755
Binary files a/screenpipe-actions/ai-proxy/bun.lockb and b/screenpipe-actions/ai-proxy/bun.lockb differ
diff --git a/screenpipe-actions/ai-proxy/package.json b/screenpipe-actions/ai-proxy/package.json
index 5345ba484..e00de8d37 100644
--- a/screenpipe-actions/ai-proxy/package.json
+++ b/screenpipe-actions/ai-proxy/package.json
@@ -17,6 +17,7 @@
"dependencies": {
"@anthropic-ai/sdk": "^0.33.1",
"@clerk/backend": "^1.21.3",
+ "@sentry/cloudflare": "^8.51.0",
"langfuse-node": "^3.27.0"
}
}
diff --git a/screenpipe-actions/ai-proxy/src/index.ts b/screenpipe-actions/ai-proxy/src/index.ts
index 075fdde5c..3137a2638 100644
--- a/screenpipe-actions/ai-proxy/src/index.ts
+++ b/screenpipe-actions/ai-proxy/src/index.ts
@@ -2,6 +2,7 @@ import { DurableObject } from 'cloudflare:workers';
import { Langfuse } from 'langfuse-node';
import { verifyToken } from '@clerk/backend';
import { Anthropic } from '@anthropic-ai/sdk';
+import * as Sentry from '@sentry/cloudflare';
async function verifyClerkToken(env: Env, token: string): Promise<boolean> {
try {
@@ -60,412 +61,423 @@ export class RateLimiter {
}
}
-export default {
- /**
- * This is the standard fetch handler for a Cloudflare Worker
- *
- * @param request - The request submitted to the Worker from the client
- * @param env - The interface to reference bindings declared in wrangler.toml
- * @param ctx - The execution context of the Worker
- * @returns The response to be sent back to the client
- */
- async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
- const langfuse = new Langfuse({
- publicKey: env.LANGFUSE_PUBLIC_KEY,
- secretKey: env.LANGFUSE_SECRET_KEY,
- baseUrl: 'https://us.cloud.langfuse.com',
- });
-
- langfuse.debug();
- langfuse.on('error', (error) => {
- console.error('langfuse error:', error);
- });
-
- // CORS headers
- const corsHeaders = {
- 'Access-Control-Allow-Origin': '*', // Or specify your app's origin
- 'Access-Control-Allow-Methods': 'GET, POST, OPTIONS',
- 'Access-Control-Allow-Headers': 'Content-Type, Authorization, User-Agent',
- };
+export default Sentry.withSentry(
+ (env) => ({
+ dsn: 'https://60750a679399e9d0b8631c059fb7578d@o4507617161314304.ingest.us.sentry.io/4508689350983680',
+ tracesSampleRate: 0.1,
+ environment: env.NODE_ENV || 'development',
+ }),
+ {
+ /**
+ * This is the standard fetch handler for a Cloudflare Worker
+ *
+ * @param request - The request submitted to the Worker from the client
+ * @param env - The interface to reference bindings declared in wrangler.toml
+ * @param ctx - The execution context of the Worker
+ * @returns The response to be sent back to the client
+ */
+ async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
+ const langfuse = new Langfuse({
+ publicKey: env.LANGFUSE_PUBLIC_KEY,
+ secretKey: env.LANGFUSE_SECRET_KEY,
+ baseUrl: 'https://us.cloud.langfuse.com',
+ });
- // Handle CORS preflight requests
- if (request.method === 'OPTIONS') {
- return new Response(null, {
- headers: {
- ...corsHeaders,
- // Add this line to handle preflight requests for all headers
- 'Access-Control-Allow-Headers': request.headers.get('Access-Control-Request-Headers') || '',
- },
+ langfuse.debug();
+ langfuse.on('error', (error) => {
+ console.error('langfuse error:', error);
});
- }
- const ip = request.headers.get('cf-connecting-ip') || 'unknown';
- const rateLimiterId = env.RATE_LIMITER.idFromName(ip);
- const rateLimiter = env.RATE_LIMITER.get(rateLimiterId);
-
- // Check rate limit
- const rateLimitResponse = await rateLimiter.fetch(request.url);
- const rateLimitData = (await rateLimitResponse.json()) as { allowed: boolean; remaining: number; reset_in: number };
-
- if (!rateLimitData.allowed) {
- return new Response(
- JSON.stringify({
- error: 'rate limit exceeded',
- retry_after: 60, // seconds
- }),
- {
- status: 429,
+ // CORS headers
+ const corsHeaders = {
+ 'Access-Control-Allow-Origin': '*', // Or specify your app's origin
+ 'Access-Control-Allow-Methods': 'GET, POST, OPTIONS',
+ 'Access-Control-Allow-Headers': 'Content-Type, Authorization, User-Agent',
+ };
+
+ // Handle CORS preflight requests
+ if (request.method === 'OPTIONS') {
+ return new Response(null, {
headers: {
...corsHeaders,
- 'Content-Type': 'application/json',
- 'Retry-After': '60',
+ // Add this line to handle preflight requests for all headers
+ 'Access-Control-Allow-Headers': request.headers.get('Access-Control-Request-Headers') || '',
},
- }
- );
- }
+ });
+ }
- try {
- const url = new URL(request.url);
- const path = url.pathname;
+ const ip = request.headers.get('cf-connecting-ip') || 'unknown';
+ const rateLimiterId = env.RATE_LIMITER.idFromName(ip);
+ const rateLimiter = env.RATE_LIMITER.get(rateLimiterId);
+
+ // Check rate limit
+ const rateLimitResponse = await rateLimiter.fetch(request.url);
+ const rateLimitData = (await rateLimitResponse.json()) as { allowed: boolean; remaining: number; reset_in: number };
+
+ if (!rateLimitData.allowed) {
+ return new Response(
+ JSON.stringify({
+ error: 'rate limit exceeded',
+ retry_after: 60, // seconds
+ }),
+ {
+ status: 429,
+ headers: {
+ ...corsHeaders,
+ 'Content-Type': 'application/json',
+ 'Retry-After': '60',
+ },
+ }
+ );
+ }
- // Add auth check for protected routes
- if (path !== '/test') {
- const authHeader = request.headers.get('Authorization');
- if (!authHeader?.startsWith('Bearer ')) {
- return new Response(JSON.stringify({ error: 'unauthorized' }), {
- status: 401,
- headers: corsHeaders,
- });
- }
+ try {
+ const url = new URL(request.url);
+ const path = url.pathname;
+
+ // Add auth check for protected routes
+ if (path !== '/test') {
+ const authHeader = request.headers.get('Authorization');
+ if (!authHeader?.startsWith('Bearer ')) {
+ return new Response(JSON.stringify({ error: 'unauthorized' }), {
+ status: 401,
+ headers: corsHeaders,
+ });
+ }
- const token = authHeader.split(' ')[1];
- const isValid = await verifyClerkToken(env, token);
+ const token = authHeader.split(' ')[1];
+ const isValid = await verifyClerkToken(env, token);
- if (!isValid) {
- return new Response(JSON.stringify({ error: 'invalid token' }), {
- status: 401,
+ if (!isValid) {
+ return new Response(JSON.stringify({ error: 'invalid token' }), {
+ status: 401,
+ headers: corsHeaders,
+ });
+ }
+ }
+
+ if (path === '/test') {
+ return new Response('ai proxy is working!', {
+ status: 200,
headers: corsHeaders,
});
}
- }
-
- if (path === '/test') {
- return new Response('ai proxy is working!', {
- status: 200,
- headers: corsHeaders,
- });
- }
-
- if (path === '/v1/chat/completions' && request.method === 'POST') {
- const body = (await request.json()) as {
- model: string;
- messages: any[];
- stream: boolean;
- response_format?: { type: string };
- temperature?: number;
- };
- const isStreaming = body.stream === true;
- const isAnthropicModel = body.model.toLowerCase().includes('claude');
- const isGeminiModel = body.model.toLowerCase().includes('gemini');
-
- const trace = langfuse.trace({
- id: 'ai_call_' + Date.now(),
- name: 'ai_call',
- metadata: {
- expectJson: body.response_format?.type === 'json_object',
- streaming: isStreaming,
- provider: isAnthropicModel ? 'anthropic' : isGeminiModel ? 'gemini' : 'openai',
- },
- });
- const generation = trace.generation({
- name: 'completion',
- model: body.model,
- modelParameters: {
- temperature: body.temperature,
- streaming: isStreaming,
- },
- input: JSON.stringify(body.messages),
- });
+ if (path === '/v1/chat/completions' && request.method === 'POST') {
+ const body = (await request.json()) as {
+ model: string;
+ messages: any[];
+ stream: boolean;
+ response_format?: { type: string };
+ temperature?: number;
+ };
+ const isStreaming = body.stream === true;
+ const isAnthropicModel = body.model.toLowerCase().includes('claude');
+ const isGeminiModel = body.model.toLowerCase().includes('gemini');
+
+ const trace = langfuse.trace({
+ id: 'ai_call_' + Date.now(),
+ name: 'ai_call',
+ metadata: {
+ expectJson: body.response_format?.type === 'json_object',
+ streaming: isStreaming,
+ provider: isAnthropicModel ? 'anthropic' : isGeminiModel ? 'gemini' : 'openai',
+ },
+ });
- // Convert messages to Anthropic format if needed
- const anthropicMessages = isAnthropicModel
- ? {
- messages: body.messages.map((msg) => ({
- role: msg.role === 'user' ? 'user' : 'assistant',
- content: msg.content,
- })),
- model: body.model,
- stream: isStreaming,
+ const generation = trace.generation({
+ name: 'completion',
+ model: body.model,
+ modelParameters: {
temperature: body.temperature,
- max_tokens: 8192,
- }
- : null;
-
- if (isStreaming) {
- const { readable, writable } = new TransformStream();
- const writer = writable.getWriter();
-
- ctx.waitUntil(
- (async () => {
- try {
- if (isAnthropicModel) {
- const anthropic = new Anthropic({
- apiKey: env.ANTHROPIC_API_KEY,
- });
+ streaming: isStreaming,
+ },
+ input: JSON.stringify(body.messages),
+ });
- try {
- const stream = await anthropic.messages.create({
- messages: body.messages.map((msg) => ({
- role: msg.role === 'user' ? 'user' : 'assistant',
- content: msg.content,
- })),
- model: body.model,
- stream: true,
- max_tokens: 4096,
+ // Convert messages to Anthropic format if needed
+ const anthropicMessages = isAnthropicModel
+ ? {
+ messages: body.messages.map((msg) => ({
+ role: msg.role === 'user' ? 'user' : 'assistant',
+ content: msg.content,
+ })),
+ model: body.model,
+ stream: isStreaming,
+ temperature: body.temperature,
+ max_tokens: 8192,
+ }
+ : null;
+
+ if (isStreaming) {
+ const { readable, writable } = new TransformStream();
+ const writer = writable.getWriter();
+
+ ctx.waitUntil(
+ (async () => {
+ try {
+ if (isAnthropicModel) {
+ const anthropic = new Anthropic({
+ apiKey: env.ANTHROPIC_API_KEY,
});
- for await (const chunk of stream) {
- if (chunk.type === 'content_block_delta' && chunk.delta?.type === 'text_delta') {
- const openaiChunk = {
- choices: [
- {
- delta: {
- content: chunk.delta.text,
+ try {
+ const stream = await anthropic.messages.create({
+ messages: body.messages.map((msg) => ({
+ role: msg.role === 'user' ? 'user' : 'assistant',
+ content: msg.content,
+ })),
+ model: body.model,
+ stream: true,
+ max_tokens: 4096,
+ });
+
+ for await (const chunk of stream) {
+ if (chunk.type === 'content_block_delta' && chunk.delta?.type === 'text_delta') {
+ const openaiChunk = {
+ choices: [
+ {
+ delta: {
+ content: chunk.delta.text,
+ },
},
- },
- ],
- };
- await writer.write(new TextEncoder().encode(`data: ${JSON.stringify(openaiChunk)}\n\n`));
+ ],
+ };
+ await writer.write(new TextEncoder().encode(`data: ${JSON.stringify(openaiChunk)}\n\n`));
+ }
}
+
+ await writer.write(new TextEncoder().encode('data: [DONE]\n\n'));
+ } catch (error) {
+ console.error('Error in Anthropic stream:', error);
+ throw error;
}
+ } else if (isGeminiModel) {
+ const apiResponse = await fetch('https://generativelanguage.googleapis.com/v1beta/openai/chat/completions', {
+ method: 'POST',
+ headers: {
+ Authorization: `Bearer ${env.GEMINI_API_KEY}`,
+ 'Content-Type': 'application/json',
+ },
+ body: JSON.stringify(body),
+ });
- await writer.write(new TextEncoder().encode('data: [DONE]\n\n'));
- } catch (error) {
- console.error('Error in Anthropic stream:', error);
- throw error;
- }
- } else if (isGeminiModel) {
- const apiResponse = await fetch('https://generativelanguage.googleapis.com/v1beta/openai/chat/completions', {
- method: 'POST',
- headers: {
- Authorization: `Bearer ${env.GEMINI_API_KEY}`,
- 'Content-Type': 'application/json',
- },
- body: JSON.stringify(body),
- });
+ if (!apiResponse.ok) {
+ const errorData = await apiResponse.json();
+ throw new Error(`API error: ${JSON.stringify(errorData)}`);
+ }
- if (!apiResponse.ok) {
- const errorData = await apiResponse.json();
- throw new Error(`API error: ${JSON.stringify(errorData)}`);
- }
+ const reader = apiResponse.body?.getReader();
+ if (!reader) {
+ throw new Error('Failed to get reader from API response');
+ }
- const reader = apiResponse.body?.getReader();
- if (!reader) {
- throw new Error('Failed to get reader from API response');
- }
+ while (true) {
+ const { done, value } = await reader.read();
+ if (done) break;
+ await writer.write(value);
+ }
+ } else {
+ // Original OpenAI format - keep the fetch call only for OpenAI
+ const apiResponse = await fetch('https://api.openai.com/v1/chat/completions', {
+ method: 'POST',
+ headers: {
+ Authorization: `Bearer ${env.OPENAI_API_KEY}`,
+ 'Content-Type': 'application/json',
+ },
+ body: JSON.stringify(body),
+ });
- while (true) {
- const { done, value } = await reader.read();
- if (done) break;
- await writer.write(value);
- }
- } else {
- // Original OpenAI format - keep the fetch call only for OpenAI
- const apiResponse = await fetch('https://api.openai.com/v1/chat/completions', {
- method: 'POST',
- headers: {
- Authorization: `Bearer ${env.OPENAI_API_KEY}`,
- 'Content-Type': 'application/json',
- },
- body: JSON.stringify(body),
- });
+ if (!apiResponse.ok) {
+ const errorData = await apiResponse.json();
+ throw new Error(`API error: ${JSON.stringify(errorData)}`);
+ }
- if (!apiResponse.ok) {
- const errorData = await apiResponse.json();
- throw new Error(`API error: ${JSON.stringify(errorData)}`);
- }
+ const reader = apiResponse.body?.getReader();
+ if (!reader) {
+ throw new Error('Failed to get reader from API response');
+ }
- const reader = apiResponse.body?.getReader();
- if (!reader) {
- throw new Error('Failed to get reader from API response');
+ while (true) {
+ const { done, value } = await reader.read();
+ if (done) break;
+ await writer.write(value);
+ }
}
- while (true) {
- const { done, value } = await reader.read();
- if (done) break;
- await writer.write(value);
- }
+ generation.end({
+ completionStartTime: new Date(),
+ output: 'Streaming response completed',
+ });
+ } catch (error: any) {
+ console.error('Error in API stream:', error);
+ generation.end({
+ completionStartTime: new Date(),
+ output: error.message,
+ });
+ await writer.write(new TextEncoder().encode(`data: ${JSON.stringify({ error: error.message })}\n\n`));
+ } finally {
+ await writer.close();
+ }
+ })()
+ );
+
+ return new Response(readable, {
+ headers: {
+ ...corsHeaders,
+ 'Content-Type': 'text/event-stream',
+ 'Cache-Control': 'no-cache',
+ Connection: 'keep-alive',
+ },
+ });
+ } else {
+ // Non-streaming response
+ try {
+ const apiResponse = await fetch(
+ isAnthropicModel
+ ? 'https://api.anthropic.com/v1/messages'
+ : isGeminiModel
+ ? 'https://generativelanguage.googleapis.com/v1beta/openai/chat/completions'
+ : 'https://api.openai.com/v1/chat/completions',
+ {
+ method: 'POST',
+ headers: {
+ ...(isAnthropicModel
+ ? {
+ 'x-api-key': env.ANTHROPIC_API_KEY,
+ 'anthropic-version': '2023-06-01',
+ }
+ : isGeminiModel
+ ? {
+ Authorization: `Bearer ${env.GEMINI_API_KEY}`,
+ }
+ : {
+ Authorization: `Bearer ${env.OPENAI_API_KEY}`,
+ }),
+ 'Content-Type': 'application/json',
+ },
+ body: JSON.stringify(isAnthropicModel ? anthropicMessages : body),
}
+ );
- generation.end({
- completionStartTime: new Date(),
- output: 'Streaming response completed',
- });
- } catch (error: any) {
- console.error('Error in API stream:', error);
- generation.end({
- completionStartTime: new Date(),
- output: error.message,
- });
- await writer.write(new TextEncoder().encode(`data: ${JSON.stringify({ error: error.message })}\n\n`));
- } finally {
- await writer.close();
+ if (!apiResponse.ok) {
+ const errorData = await apiResponse.json();
+ throw new Error(`API error: ${JSON.stringify(errorData)}`);
}
- })()
- );
- return new Response(readable, {
- headers: {
- ...corsHeaders,
- 'Content-Type': 'text/event-stream',
- 'Cache-Control': 'no-cache',
- Connection: 'keep-alive',
- },
- });
- } else {
- // Non-streaming response
+ const data = (await apiResponse.json()) as { choices: { message: { content: string } }[] };
+
+ if (!data.choices?.length) {
+ throw new Error('no completion choices returned from api: ' + JSON.stringify(data, null, 2));
+ }
+
+ // Normalize Anthropic response to match OpenAI format
+ const normalizedResponse = isAnthropicModel
+ ? {
+ choices: [
+ {
+ message: {
+ content: data.choices[0].message.content,
+ },
+ },
+ ],
+ }
+ : data;
+
+ generation.end({
+ completionStartTime: new Date(),
+ output: normalizedResponse.choices[0]?.message?.content || '',
+ });
+
+ return new Response(JSON.stringify(normalizedResponse), {
+ headers: {
+ ...corsHeaders,
+ 'Content-Type': 'application/json',
+ },
+ });
+ } catch (error: any) {
+ console.error('Error in API request:', error);
+ generation.end({
+ completionStartTime: new Date(),
+ output: error.message,
+ });
+ return new Response(JSON.stringify({ error: error.message }), {
+ status: 500,
+ headers: {
+ ...corsHeaders,
+ 'Content-Type': 'application/json',
+ },
+ });
+ }
+ }
+ }
+
+ if (path === '/v1/listen' && request.method === 'POST') {
+ // Get the raw body instead of form data
+ const audioBuffer = await request.arrayBuffer();
+ const languages = request.headers.get('detect_language')?.split(',') || [];
+ const sampleRate = request.headers.get('sample_rate') || '16000';
try {
- const apiResponse = await fetch(
- isAnthropicModel
- ? 'https://api.anthropic.com/v1/messages'
- : isGeminiModel
- ? 'https://generativelanguage.googleapis.com/v1beta/openai/chat/completions'
- : 'https://api.openai.com/v1/chat/completions',
+ const deepgramResponse = await fetch(
+ 'https://api.deepgram.com/v1/listen?model=nova-2&smart_format=true&sample_rate=' +
+ sampleRate +
+ (languages.length > 0 ? '&' + languages.map((lang) => `detect_language=${lang}`).join('&') : ''),
{
method: 'POST',
headers: {
- ...(isAnthropicModel
- ? {
- 'x-api-key': env.ANTHROPIC_API_KEY,
- 'anthropic-version': '2023-06-01',
- }
- : isGeminiModel
- ? {
- Authorization: `Bearer ${env.GEMINI_API_KEY}`,
- }
- : {
- Authorization: `Bearer ${env.OPENAI_API_KEY}`,
- }),
- 'Content-Type': 'application/json',
+ Authorization: `Token ${env.DEEPGRAM_API_KEY}`,
+ 'Content-Type': 'audio/wav', // Set correct content type
},
- body: JSON.stringify(isAnthropicModel ? anthropicMessages : body),
+ body: audioBuffer,
}
);
- if (!apiResponse.ok) {
- const errorData = await apiResponse.json();
- throw new Error(`API error: ${JSON.stringify(errorData)}`);
+ if (!deepgramResponse.ok) {
+ const errorData = await deepgramResponse.json();
+ throw new Error(`Deepgram API error: ${JSON.stringify(errorData)}`);
}
- const data = (await apiResponse.json()) as { choices: { message: { content: string } }[] };
-
- // Normalize Anthropic response to match OpenAI format
- const normalizedResponse = isAnthropicModel
- ? {
- choices: [
- {
- message: {
- content: data.choices[0].message.content,
- },
- },
- ],
- }
- : data;
-
- generation.end({
- completionStartTime: new Date(),
- output: normalizedResponse.choices[0]?.message?.content,
- });
-
- return new Response(JSON.stringify(normalizedResponse), {
+ const data = await deepgramResponse.json();
+ return new Response(JSON.stringify(data), {
headers: {
...corsHeaders,
'Content-Type': 'application/json',
},
});
} catch (error: any) {
- console.error('Error in API request:', error);
- generation.end({
- completionStartTime: new Date(),
- output: error.message,
- });
- return new Response(JSON.stringify({ error: error.message }), {
- status: 500,
- headers: {
- ...corsHeaders,
- 'Content-Type': 'application/json',
- },
- });
+ console.error('Error in Deepgram request:', error);
+ return new Response(
+ JSON.stringify({
+ error: error.message,
+ details: error.stack,
+ }),
+ {
+ status: 500,
+ headers: {
+ ...corsHeaders,
+ 'Content-Type': 'application/json',
+ },
+ }
+ );
}
}
- }
- if (path === '/v1/listen' && request.method === 'POST') {
- // Get the raw body instead of form data
- const audioBuffer = await request.arrayBuffer();
- const languages = request.headers.get('detect_language')?.split(',') || [];
- const sampleRate = request.headers.get('sample_rate') || '16000';
- try {
- const deepgramResponse = await fetch(
- 'https://api.deepgram.com/v1/listen?model=nova-2&smart_format=true&sample_rate=' +
- sampleRate +
- (languages.length > 0 ? '&' + languages.map((lang) => `detect_language=${lang}`).join('&') : ''),
- {
- method: 'POST',
- headers: {
- Authorization: `Token ${env.DEEPGRAM_API_KEY}`,
- 'Content-Type': 'audio/wav', // Set correct content type
- },
- body: audioBuffer,
- }
- );
-
- if (!deepgramResponse.ok) {
- const errorData = await deepgramResponse.json();
- throw new Error(`Deepgram API error: ${JSON.stringify(errorData)}`);
- }
-
- const data = await deepgramResponse.json();
- return new Response(JSON.stringify(data), {
- headers: {
- ...corsHeaders,
- 'Content-Type': 'application/json',
- },
- });
- } catch (error: any) {
- console.error('Error in Deepgram request:', error);
- return new Response(
- JSON.stringify({
- error: error.message,
- details: error.stack,
- }),
- {
- status: 500,
- headers: {
- ...corsHeaders,
- 'Content-Type': 'application/json',
- },
- }
- );
- }
+ return new Response('not found', {
+ status: 404,
+ headers: corsHeaders,
+ });
+ } catch (error) {
+ console.error('error in fetch:', error);
+ return new Response('an error occurred', {
+ status: 500,
+ headers: corsHeaders,
+ });
+ } finally {
+ await langfuse.shutdownAsync();
}
-
- return new Response('not found', {
- status: 404,
- headers: corsHeaders,
- });
- } catch (error) {
- console.error('error in fetch:', error);
- return new Response('an error occurred', {
- status: 500,
- headers: corsHeaders,
- });
- } finally {
- await langfuse.shutdownAsync();
- }
- },
-} satisfies ExportedHandler<Env>;
+ },
+ } satisfies ExportedHandler<Env>
+);
interface Env {
OPENAI_API_KEY: string;
@@ -476,6 +488,7 @@ interface Env {
RATE_LIMITER: DurableObjectNamespace;
CLERK_SECRET_KEY: string;
GEMINI_API_KEY: string;
+ NODE_ENV?: string;
}
/*
@@ -490,7 +503,7 @@ HOST=https://ai-proxy.i-f9f.workers.dev
HOST=http://localhost:8787
TOKEN=foobar (check app settings)
-curl $host/test
+curl $HOST/test
curl -X POST $HOST/v1/listen \
diff --git a/screenpipe-actions/ai-proxy/wrangler.toml b/screenpipe-actions/ai-proxy/wrangler.toml
index 31ba88580..6f04bae04 100644
--- a/screenpipe-actions/ai-proxy/wrangler.toml
+++ b/screenpipe-actions/ai-proxy/wrangler.toml
@@ -2,6 +2,8 @@
name = "ai-proxy"
main = "src/index.ts"
compatibility_date = "2024-10-11"
+compatibility_flags = ["nodejs_compat"]
+upload_source_maps = true
# Workers Logs
# Docs: https://developers.cloudflare.com/workers/observability/logs/workers-logs/
@@ -24,7 +26,7 @@ enabled = true
[vars]
# add any non-secret environment variables here
-# Bind the Workers AI model catalog. Run machine learning models, powered by serverless GPUs, on Cloudflare’s global network
+# Bind the Workers AI model catalog. Run machine learning models, powered by serverless GPUs, on Cloudflare's global network
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#workers-ai
# [ai]
# binding = "AI"
@@ -39,7 +41,7 @@ enabled = true
# [browser]
# binding = "MY_BROWSER"
-# Bind a D1 database. D1 is Cloudflare’s native serverless SQL database.
+# Bind a D1 database. D1 is Cloudflare's native serverless SQL database.
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#d1-databases
# [[d1_databases]]
# binding = "MY_DB"