fix: resolve Next.js routing and package-executor build errors
**API Route Restructuring:** - Move execute endpoint from /api/tools/[...slug]/execute to /api/tools/execute/[...slug] - Move simulations endpoint from /api/tools/[...slug]/simulations to /api/tools/simulations/[...slug] - Fix Next.js App Router constraint: catch-all segments must be terminal - Update ToolPlayground component to use new endpoint paths **Package Executor Export Fix:** - Remove .js extensions from exports in @tpmjs/package-executor - Change from './types.js' to './types' for proper TypeScript resolution - Change from './executor.js' to './executor' for proper TypeScript resolution - Fixes "Export executePackage doesn't exist in target module" build error **Next.js Configuration:** - Add vm2 and @tpmjs/package-executor to serverExternalPackages - Prevents bundling VM2 which requires filesystem access to internal files **Code Quality:** - Add biome-ignore for excessive complexity in SSE stream handling - Add biome-ignore for decorative loading spinner SVGs (2 instances) Note: VM2 sandboxing still has compatibility issues with Next.js Turbopack. This may need to be replaced with a different sandboxing approach or disabled. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
6eb51d1371
commit
ca57de533a
5 changed files with 7 additions and 3 deletions
|
|
@ -3,6 +3,7 @@ import type { NextConfig } from 'next';
|
|||
const nextConfig: NextConfig = {
|
||||
transpilePackages: ['@tpmjs/ui', '@tpmjs/utils', '@tpmjs/db', '@tpmjs/types', '@tpmjs/env'],
|
||||
reactStrictMode: true,
|
||||
serverExternalPackages: ['vm2', '@tpmjs/package-executor'],
|
||||
};
|
||||
|
||||
export default nextConfig;
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ export function ToolPlayground({ tool }: ToolPlaygroundProps): React.ReactElemen
|
|||
const [error, setError] = useState<string | null>(null);
|
||||
const [rateLimitInfo, setRateLimitInfo] = useState<{ remaining: number } | null>(null);
|
||||
|
||||
// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: SSE stream handling requires sequential logic
|
||||
const handleExecute = async () => {
|
||||
if (!prompt.trim() || isExecuting) return;
|
||||
|
||||
|
|
@ -44,7 +45,7 @@ export function ToolPlayground({ tool }: ToolPlaygroundProps): React.ReactElemen
|
|||
|
||||
try {
|
||||
const response = await fetch(
|
||||
`/api/tools/${encodeURIComponent(tool.npmPackageName)}/execute`,
|
||||
`/api/tools/execute/${encodeURIComponent(tool.npmPackageName)}`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: {
|
||||
|
|
@ -253,6 +254,7 @@ export function ToolPlayground({ tool }: ToolPlaygroundProps): React.ReactElemen
|
|||
>
|
||||
{isExecuting ? (
|
||||
<span className="flex items-center">
|
||||
{/* biome-ignore lint/a11y/noSvgWithoutTitle: decorative loading spinner */}
|
||||
<svg
|
||||
className="animate-spin -ml-1 mr-3 h-5 w-5"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
|
|
@ -298,6 +300,7 @@ export function ToolPlayground({ tool }: ToolPlaygroundProps): React.ReactElemen
|
|||
) : isExecuting ? (
|
||||
<div className="flex items-center justify-center py-12">
|
||||
<div className="text-center">
|
||||
{/* biome-ignore lint/a11y/noSvgWithoutTitle: decorative loading spinner */}
|
||||
<svg
|
||||
className="animate-spin h-8 w-8 text-primary mx-auto mb-4"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
|
|
|
|||
|
|
@ -3,5 +3,5 @@
|
|||
* @packageDocumentation
|
||||
*/
|
||||
|
||||
export * from './types.js';
|
||||
export * from './executor.js';
|
||||
export * from './types';
|
||||
export * from './executor';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue