- Add EXECUTOR_SPECIFICATION.md with formal v1.0 protocol spec - Add executor-openapi.yaml (OpenAPI 3.0 specification) - Create @tpmjs/executor-test compliance test package (15 tests) - Update Railway executor to v1.0 compliance (15/15 tests pass) - Update Unsandbox executor to v1.0 compliance (15/15 tests pass) - Update Vercel executor to v1.0 compliance - Add /info endpoint with capability advertisement to all executors - Add structured error codes (PACKAGE_NOT_FOUND, TOOL_NOT_FOUND, etc.) - Add protocolVersion and implementationVersion to /health responses - Add X-TPMJS-Protocol-Version header support - Add EXECUTOR_COMPLIANCE.md with test results documentation
77 lines
2 KiB
TypeScript
77 lines
2 KiB
TypeScript
/**
|
|
* Info Endpoint - Capability Advertisement
|
|
*
|
|
* GET /api/info
|
|
* Returns executor capabilities for intelligent routing
|
|
*/
|
|
|
|
import { NextResponse } from 'next/server';
|
|
|
|
export const runtime = 'nodejs';
|
|
export const dynamic = 'force-dynamic';
|
|
|
|
const PROTOCOL_VERSION = '1.0';
|
|
const IMPLEMENTATION_VERSION = '1.0.0';
|
|
|
|
interface InfoResponse {
|
|
name: string;
|
|
version: string;
|
|
protocolVersion: string;
|
|
capabilities: {
|
|
isolation: 'none' | 'process' | 'container' | 'vm';
|
|
executionModes: string[];
|
|
maxExecutionTimeMs: number;
|
|
maxRequestBodyBytes: number;
|
|
supportsStreaming: boolean;
|
|
supportsCallbacks: boolean;
|
|
supportsCaching: boolean;
|
|
};
|
|
runtime?: {
|
|
platform?: string;
|
|
nodeVersion?: string;
|
|
region?: string;
|
|
};
|
|
}
|
|
|
|
export async function GET(): Promise<NextResponse<InfoResponse>> {
|
|
return NextResponse.json(
|
|
{
|
|
name: 'Vercel Sandbox Executor',
|
|
version: IMPLEMENTATION_VERSION,
|
|
protocolVersion: PROTOCOL_VERSION,
|
|
capabilities: {
|
|
isolation: 'vm',
|
|
executionModes: ['sync'],
|
|
maxExecutionTimeMs: 120000,
|
|
maxRequestBodyBytes: 10485760,
|
|
supportsStreaming: false,
|
|
supportsCallbacks: false,
|
|
supportsCaching: false,
|
|
},
|
|
runtime: {
|
|
platform: 'linux',
|
|
nodeVersion: '22.x',
|
|
region: process.env.VERCEL_REGION || undefined,
|
|
},
|
|
},
|
|
{
|
|
headers: {
|
|
'Access-Control-Allow-Origin': '*',
|
|
'Access-Control-Allow-Methods': 'GET, OPTIONS',
|
|
'Access-Control-Allow-Headers': 'Content-Type, Authorization, X-TPMJS-Protocol-Version',
|
|
},
|
|
}
|
|
);
|
|
}
|
|
|
|
// Handle OPTIONS for CORS preflight
|
|
export async function OPTIONS(): Promise<NextResponse> {
|
|
return new NextResponse(null, {
|
|
status: 200,
|
|
headers: {
|
|
'Access-Control-Allow-Origin': '*',
|
|
'Access-Control-Allow-Methods': 'GET, OPTIONS',
|
|
'Access-Control-Allow-Headers': 'Content-Type, Authorization, X-TPMJS-Protocol-Version',
|
|
},
|
|
});
|
|
}
|