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
This commit is contained in:
Ajax Davis 2026-01-25 05:52:52 +10:00
parent 69162682d1
commit dff523fa99
2 changed files with 4 additions and 21 deletions

View file

@ -8,12 +8,12 @@ const nextConfig: NextConfig = {
'@tpmjs/types', '@tpmjs/types',
'@tpmjs/env', '@tpmjs/env',
'@tpmjs/config', '@tpmjs/config',
'@tpmjs/registry-search',
'@tpmjs/registry-execute',
], ],
reactStrictMode: true, reactStrictMode: true,
serverExternalPackages: [ serverExternalPackages: [
'@tpmjs/package-executor', '@tpmjs/package-executor',
'@tpmjs/registry-search',
'@tpmjs/registry-execute',
], ],
async redirects() { async redirects() {
return [ return [

View file

@ -10,23 +10,9 @@
*/ */
import { Prisma, prisma } from '@tpmjs/db'; 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'; 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 { type NextRequest, NextResponse } from 'next/server';
import { z } from 'zod'; import { z } from 'zod';
import { authenticateRequest } from '~/lib/api-keys/middleware'; 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 // Build final tools object: static tools + dynamically loaded tools
// biome-ignore lint/suspicious/noExplicitAny: Dynamic tool types // biome-ignore lint/suspicious/noExplicitAny: Dynamic tool types
const tools: Record<string, any> = { const tools: Record<string, any> = {