diff --git a/apps/messaging/src/routes.ts b/apps/messaging/src/routes.ts index 0f15e68..b6b945c 100644 --- a/apps/messaging/src/routes.ts +++ b/apps/messaging/src/routes.ts @@ -1,7 +1,7 @@ import { config } from "@eda/config"; import { logger } from "@eda/logger"; import { createClient } from "@supabase/supabase-js"; -import { tasks } from "@trigger.dev/sdk/v3"; +import { configure, tasks } from "@trigger.dev/sdk/v3"; import { type Message, messageSchema, queryParamsSchema } from "./types"; // Replace Supabase client initialization @@ -10,6 +10,11 @@ const supabase = createClient( config.api_keys.supabase.service_key, ); +configure({ + secretKey: config.api_keys.trigger, + baseURL: config.services.trigger.api_url, +}); + // Replace AI API URL constant const AI_API_URL = `http://localhost:${config.ports.ai_api}`; @@ -187,15 +192,19 @@ export async function handleSendMessage(req: Request) { logger.info("Triggering monitor-api-call task"); - // Monitor API call using Trigger.dev - await tasks.trigger("monitor-api-call", { - endpoint: "/api/classifier/classify", - method: "POST", - statusCode: response.status, - duration, - timestamp: new Date().toISOString(), - sessionId: payload.sessionId, - }); + try { + // Monitor API call using Trigger.dev + await tasks.trigger("monitor-api-call", { + endpoint: "/api/classifier/classify", + method: "POST", + statusCode: response.status, + duration, + timestamp: new Date().toISOString(), + sessionId: payload.sessionId, + }); + } catch (triggerError) { + logger.error("Error triggering monitoring task:", triggerError); + } if (!response.ok) { throw new Error(data.message || "Failed to process message"); @@ -216,16 +225,23 @@ export async function handleSendMessage(req: Request) { } catch (error) { const duration = performance.now() - startTime; - // Monitor failed API calls - await tasks.trigger("monitor-api-call", { - endpoint: "/api/classifier/classify", - method: "POST", - statusCode: 500, - duration, - timestamp: new Date().toISOString(), - sessionId: payload.sessionId, // Now safe to use since payload is initialized - error: error instanceof Error ? error.message : "Unknown error", - }); + try { + // Monitor failed API calls + await tasks.trigger("monitor-api-call", { + endpoint: "/api/classifier/classify", + method: "POST", + statusCode: 500, + duration, + timestamp: new Date().toISOString(), + sessionId: payload.sessionId, + error: error instanceof Error ? error.message : "Unknown error", + }); + } catch (triggerError) { + logger.error( + "Error triggering monitoring task for failed call:", + triggerError, + ); + } const message = error instanceof Error ? error.message : "Failed to process message"; diff --git a/apps/whatsapp/package.json b/apps/whatsapp/package.json index a869bce..3521806 100644 --- a/apps/whatsapp/package.json +++ b/apps/whatsapp/package.json @@ -17,7 +17,7 @@ "typescript": "^5.0.0" }, "dependencies": { - "@trigger.dev/sdk": "3.2.1", + "@trigger.dev/sdk": "3.3.11", "@types/common-tags": "^1.8.4", "@whiskeysockets/baileys": "^6.7.9", "common-tags": "^1.8.2", diff --git a/apps/whatsapp/src/message/message.ts b/apps/whatsapp/src/message/message.ts index 06101ed..65a8317 100644 --- a/apps/whatsapp/src/message/message.ts +++ b/apps/whatsapp/src/message/message.ts @@ -1,7 +1,6 @@ -import { logger } from "@trigger.dev/sdk/v3"; +import { logger } from "@eda/logger"; import { type WAMessage, downloadMediaMessage } from "@whiskeysockets/baileys"; import { sock } from "../client"; -import { BOT_PREFIX } from "../constants"; import { getPhoneNumber, react } from "../utils"; const IMAGE_ERROR_MSG = diff --git a/bun.lockb b/bun.lockb index e264504..8e88040 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/packages/jobs/package.json b/packages/jobs/package.json index a29d3cb..86fec0a 100644 --- a/packages/jobs/package.json +++ b/packages/jobs/package.json @@ -5,7 +5,7 @@ "scripts": { "clean": "rm -rf .turbo node_modules", "lint": "biome lint ./trigger ./lib", - "dev": "bunx trigger.dev dev", + "dev": "bunx trigger.dev dev --skip-update-check", "format": "biome format --write .", "typecheck": "tsc-files --noEmit", "test": "vitest" @@ -14,10 +14,10 @@ "@eda/supabase": "workspace:*", "@eda/types": "workspace:*", "@getzep/zep-cloud": "^2.1.1", - "@trigger.dev/sdk": "3.2.1" + "@trigger.dev/sdk": "3.3.11" }, "devDependencies": { - "@trigger.dev/build": "3.2.1", + "@trigger.dev/build": "3.3.11", "vitest": "^2.1.5" } } diff --git a/packages/simulator/package.json b/packages/simulator/package.json index dec9896..9a2acde 100644 --- a/packages/simulator/package.json +++ b/packages/simulator/package.json @@ -13,7 +13,7 @@ "@cerebras/cerebras_cloud_sdk": "^1.8.0", "@eda/logger": "workspace:*", "@eda/types": "workspace:*", - "@trigger.dev/sdk": "3.2.1", + "@trigger.dev/sdk": "3.3.11", "dotenv": "^16.4.5", "groq-sdk": "^0.7.0" },