fix: pass explicit version to executor to avoid Deno cache issues
The executor was using version: 'latest' which caused Deno to cache old versions of packages. Now we pass the explicit version from the database to ensure the correct version is always loaded. Also fixed sprites-list to recognize 'cold' as a valid sprite status.
This commit is contained in:
parent
2c3cea8730
commit
c1655dd318
6 changed files with 14 additions and 4 deletions
|
|
@ -136,9 +136,11 @@ export function createToolDefinition(
|
|||
|
||||
// Execute the actual npm package using resolved executor
|
||||
// Use the actual export name from the Tool record
|
||||
// Pass explicit version to avoid Deno HTTP import cache issues with @latest
|
||||
const result = await executeWithExecutor(executorConfig ?? null, {
|
||||
packageName: tool.package.npmPackageName,
|
||||
name: tool.name, // Use actual export name (e.g., "helloWorldTool", "default")
|
||||
version: tool.package.npmVersion,
|
||||
params,
|
||||
env: envVars && Object.keys(envVars).length > 0 ? envVars : undefined,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -164,6 +164,7 @@ export async function executeWithExecutor(
|
|||
// Default: use existing package-executor (which uses SANDBOX_EXECUTOR_URL)
|
||||
const result = await executePackage(request.packageName, request.name, request.params, {
|
||||
env: request.env,
|
||||
version: request.version,
|
||||
});
|
||||
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -195,8 +195,9 @@ export async function handleToolsCall(
|
|||
};
|
||||
}
|
||||
|
||||
// Get the actual package name that matched
|
||||
// Get the actual package name and version that matched
|
||||
const actualPackageName = collectionTool.tool.package.npmPackageName;
|
||||
const actualVersion = collectionTool.tool.package.npmVersion;
|
||||
|
||||
// Resolve executor configuration (collection config only for MCP - no agent context)
|
||||
const executorConfig = parseExecutorConfig(
|
||||
|
|
@ -205,9 +206,11 @@ export async function handleToolsCall(
|
|||
);
|
||||
|
||||
// Execute via resolved executor with collection's environment variables
|
||||
// Pass explicit version to avoid Deno HTTP import cache issues with @latest
|
||||
const result = await executeWithExecutor(executorConfig, {
|
||||
packageName: actualPackageName,
|
||||
name: parsed.toolName,
|
||||
version: actualVersion,
|
||||
params: params.arguments ?? {},
|
||||
env: (collection?.envVars as Record<string, string>) ?? undefined,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -35,10 +35,11 @@ export async function executePackage(
|
|||
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
||||
|
||||
// Build request body, only include env if provided
|
||||
// Use explicit version if provided to avoid Deno HTTP import cache issues
|
||||
const requestBody: Record<string, unknown> = {
|
||||
packageName,
|
||||
name: functionName,
|
||||
version: 'latest',
|
||||
version: options.version || 'latest',
|
||||
params,
|
||||
};
|
||||
if (options.env && Object.keys(options.env).length > 0) {
|
||||
|
|
|
|||
|
|
@ -20,4 +20,6 @@ export interface ExecutorOptions {
|
|||
cacheDir?: string;
|
||||
/** Environment variables to inject during execution */
|
||||
env?: Record<string, string>;
|
||||
/** Specific version to use (defaults to 'latest') */
|
||||
version?: string;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ const SPRITES_API_BASE = 'https://api.sprites.dev/v1';
|
|||
|
||||
export interface Sprite {
|
||||
name: string;
|
||||
status: 'creating' | 'running' | 'stopped' | 'error';
|
||||
status: 'creating' | 'running' | 'stopped' | 'error' | 'cold';
|
||||
createdAt: string;
|
||||
runtime?: string;
|
||||
metadata?: Record<string, unknown>;
|
||||
|
|
@ -95,7 +95,8 @@ export const spritesListTool = tool({
|
|||
const status = sprite.status as string | undefined;
|
||||
|
||||
// Validate status is a known value
|
||||
if (status && !['creating', 'running', 'stopped', 'error'].includes(status)) {
|
||||
// Note: "cold" is returned for sprites that have been idle
|
||||
if (status && !['creating', 'running', 'stopped', 'error', 'cold'].includes(status)) {
|
||||
throw new Error(`Invalid sprite status: ${status}`);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue