From dff523fa99cab57101aae1eb1d4afeda3fd31714 Mon Sep 17 00:00:00 2001 From: Ajax Davis Date: Sun, 25 Jan 2026 05:52:52 +1000 Subject: [PATCH] fix(omega): move registry packages to transpilePackages for ESM support - @tpmjs/registry-search and @tpmjs/registry-execute use ESM syntax - Move from serverExternalPackages to transpilePackages so Next.js properly bundles and transpiles them - Revert to static imports now that packages are bundled correctly --- apps/web/next.config.ts | 4 ++-- .../conversations/[id]/messages/route.ts | 21 ++----------------- 2 files changed, 4 insertions(+), 21 deletions(-) diff --git a/apps/web/next.config.ts b/apps/web/next.config.ts index a23bf53..4254dcb 100644 --- a/apps/web/next.config.ts +++ b/apps/web/next.config.ts @@ -8,12 +8,12 @@ const nextConfig: NextConfig = { '@tpmjs/types', '@tpmjs/env', '@tpmjs/config', + '@tpmjs/registry-search', + '@tpmjs/registry-execute', ], reactStrictMode: true, serverExternalPackages: [ '@tpmjs/package-executor', - '@tpmjs/registry-search', - '@tpmjs/registry-execute', ], async redirects() { return [ diff --git a/apps/web/src/app/api/omega/conversations/[id]/messages/route.ts b/apps/web/src/app/api/omega/conversations/[id]/messages/route.ts index 696de60..ce70aa8 100644 --- a/apps/web/src/app/api/omega/conversations/[id]/messages/route.ts +++ b/apps/web/src/app/api/omega/conversations/[id]/messages/route.ts @@ -10,23 +10,9 @@ */ import { Prisma, prisma } from '@tpmjs/db'; +import { registryExecuteTool } from '@tpmjs/registry-execute'; +import { registrySearchTool } from '@tpmjs/registry-search'; import { jsonSchema, wrapLanguageModel, type ModelMessage } from 'ai'; - -// Registry tools - lazy loaded to avoid module resolution issues in serverless -let _registryExecuteTool: typeof import('@tpmjs/registry-execute').registryExecuteTool | null = null; -let _registrySearchTool: typeof import('@tpmjs/registry-search').registrySearchTool | null = null; - -async function getRegistryTools() { - if (!_registryExecuteTool) { - const { registryExecuteTool } = await import('@tpmjs/registry-execute'); - _registryExecuteTool = registryExecuteTool; - } - if (!_registrySearchTool) { - const { registrySearchTool } = await import('@tpmjs/registry-search'); - _registrySearchTool = registrySearchTool; - } - return { registryExecuteTool: _registryExecuteTool, registrySearchTool: _registrySearchTool }; -} import { type NextRequest, NextResponse } from 'next/server'; import { z } from 'zod'; import { authenticateRequest } from '~/lib/api-keys/middleware'; @@ -431,9 +417,6 @@ export async function POST(request: NextRequest, context: RouteContext): Promise ); } - // Load registry tools (lazy loaded to avoid module issues in serverless) - const { registrySearchTool, registryExecuteTool } = await getRegistryTools(); - // Build final tools object: static tools + dynamically loaded tools // biome-ignore lint/suspicious/noExplicitAny: Dynamic tool types const tools: Record = {