fix: correct test package/tool name in executor verification
- Use @tpmjs/hello instead of @anthropic-ai/tpmjs-hello - Use helloWorldTool instead of helloWorld (correct export name) - Increase timeout to 30s to account for npm install in sandbox - Add detailed logging to Vercel executor template 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
d646e2310e
commit
6661957111
2 changed files with 30 additions and 5 deletions
|
|
@ -241,12 +241,13 @@ export async function testExecutor(
|
|||
apiKey?: string
|
||||
): Promise<{ success: boolean; executionTimeMs: number; error?: string }> {
|
||||
const testRequest: ExecuteToolRequest = {
|
||||
packageName: '@anthropic-ai/tpmjs-hello',
|
||||
name: 'helloWorld',
|
||||
params: { name: 'test' },
|
||||
packageName: '@tpmjs/hello',
|
||||
name: 'helloWorldTool',
|
||||
version: '0.0.2',
|
||||
params: { includeTimestamp: true },
|
||||
};
|
||||
|
||||
const result = await executeWithCustomUrl(url, apiKey, testRequest, 15000); // 15 second timeout for test
|
||||
const result = await executeWithCustomUrl(url, apiKey, testRequest, 30000); // 30 second timeout for test (includes npm install)
|
||||
|
||||
return {
|
||||
success: result.success,
|
||||
|
|
|
|||
|
|
@ -71,6 +71,9 @@ export async function POST(req: NextRequest): Promise<NextResponse<ExecuteToolRe
|
|||
});
|
||||
|
||||
// 1) Install the npm package
|
||||
console.log(`[executor] Installing ${packageSpec}...`);
|
||||
const installStart = Date.now();
|
||||
|
||||
const install = await sandbox.runCommand({
|
||||
cmd: 'npm',
|
||||
args: ['install', '--no-save', '--omit=dev', '--no-audit', '--no-fund', packageSpec],
|
||||
|
|
@ -78,8 +81,17 @@ export async function POST(req: NextRequest): Promise<NextResponse<ExecuteToolRe
|
|||
});
|
||||
|
||||
const installStderr = await install.stderr();
|
||||
const installStdout = await install.stdout();
|
||||
const installTime = Date.now() - installStart;
|
||||
|
||||
console.log(`[executor] npm install completed in ${installTime}ms (exit: ${install.exitCode})`);
|
||||
|
||||
if (install.exitCode !== 0) {
|
||||
const installStdout = await install.stdout();
|
||||
console.error(`[executor] npm install failed:`, {
|
||||
exitCode: install.exitCode,
|
||||
stdout: installStdout?.slice(0, 500),
|
||||
stderr: installStderr?.slice(0, 500),
|
||||
});
|
||||
return NextResponse.json({
|
||||
success: false,
|
||||
error: `npm install failed with exit code ${install.exitCode}`,
|
||||
|
|
@ -149,6 +161,9 @@ ${envSetup}
|
|||
await sandbox.writeFiles([{ path: 'execute.cjs', content: Buffer.from(script, 'utf8') }]);
|
||||
|
||||
// 4) Run the script
|
||||
console.log(`[executor] Running tool ${packageName}/${name}...`);
|
||||
const runStart = Date.now();
|
||||
|
||||
const run = await sandbox.runCommand({
|
||||
cmd: 'node',
|
||||
args: ['execute.cjs'],
|
||||
|
|
@ -158,8 +173,17 @@ ${envSetup}
|
|||
|
||||
const stdout = await run.stdout();
|
||||
const stderr = await run.stderr();
|
||||
const runTime = Date.now() - runStart;
|
||||
|
||||
console.log(`[executor] Tool execution completed in ${runTime}ms (exit: ${run.exitCode})`);
|
||||
|
||||
if (run.exitCode !== 0) {
|
||||
console.error(`[executor] Tool execution failed:`, {
|
||||
exitCode: run.exitCode,
|
||||
stdout: stdout?.slice(0, 500),
|
||||
stderr: stderr?.slice(0, 500),
|
||||
});
|
||||
|
||||
// Try to parse error from stderr
|
||||
try {
|
||||
const errorObj = JSON.parse(stderr);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue