mirror of
https://github.com/simstudioai/sim.git
synced 2026-02-04 11:45:07 -05:00
address bugbot comments
This commit is contained in:
@@ -7,7 +7,7 @@ const baseToolLogger = createLogger('BaseClientTool')
|
||||
|
||||
const DEFAULT_TOOL_TIMEOUT_MS = 5 * 60 * 1000
|
||||
|
||||
export const WORKFLOW_EXECUTION_TIMEOUT_MS = 5 * 60 * 1000
|
||||
export const WORKFLOW_EXECUTION_TIMEOUT_MS = 10 * 60 * 1000
|
||||
|
||||
// Client tool call states used by the new runtime
|
||||
export enum ClientToolCallState {
|
||||
|
||||
@@ -51,37 +51,13 @@ export function getExecutionTimeout(
|
||||
return EXECUTION_TIMEOUTS[plan || 'free'][type]
|
||||
}
|
||||
|
||||
export function getExecutionTimeoutSeconds(
|
||||
plan: SubscriptionPlan | undefined,
|
||||
type: 'sync' | 'async' = 'sync'
|
||||
): number {
|
||||
return Math.floor(getExecutionTimeout(plan, type) / 1000)
|
||||
}
|
||||
|
||||
export function getMaxExecutionTimeout(): number {
|
||||
return EXECUTION_TIMEOUTS.enterprise.async
|
||||
}
|
||||
|
||||
export const DEFAULT_EXECUTION_TIMEOUT_MS = EXECUTION_TIMEOUTS.free.sync
|
||||
|
||||
export class ExecutionTimeoutError extends Error {
|
||||
constructor(
|
||||
public readonly timeoutMs: number,
|
||||
public readonly plan?: SubscriptionPlan
|
||||
) {
|
||||
const timeoutSeconds = Math.floor(timeoutMs / 1000)
|
||||
const timeoutMinutes = Math.floor(timeoutSeconds / 60)
|
||||
const displayTime =
|
||||
timeoutMinutes > 0
|
||||
? `${timeoutMinutes} minute${timeoutMinutes > 1 ? 's' : ''}`
|
||||
: `${timeoutSeconds} seconds`
|
||||
super(`Execution timed out after ${displayTime}`)
|
||||
this.name = 'ExecutionTimeoutError'
|
||||
}
|
||||
}
|
||||
|
||||
export function isTimeoutError(error: unknown): boolean {
|
||||
if (error instanceof ExecutionTimeoutError) return true
|
||||
if (!(error instanceof Error)) return false
|
||||
|
||||
const name = error.name.toLowerCase()
|
||||
@@ -96,18 +72,7 @@ export function isTimeoutError(error: unknown): boolean {
|
||||
)
|
||||
}
|
||||
|
||||
export function createTimeoutError(
|
||||
timeoutMs: number,
|
||||
plan?: SubscriptionPlan
|
||||
): ExecutionTimeoutError {
|
||||
return new ExecutionTimeoutError(timeoutMs, plan)
|
||||
}
|
||||
|
||||
export function getTimeoutErrorMessage(error: unknown, timeoutMs?: number): string {
|
||||
if (error instanceof ExecutionTimeoutError) {
|
||||
return error.message
|
||||
}
|
||||
|
||||
if (timeoutMs) {
|
||||
const timeoutSeconds = Math.floor(timeoutMs / 1000)
|
||||
const timeoutMinutes = Math.floor(timeoutSeconds / 60)
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { NextResponse } from 'next/server'
|
||||
import { DEFAULT_EXECUTION_TIMEOUT_MS, getExecutionTimeout } from '@/lib/core/execution-limits'
|
||||
import type { SubscriptionPlan } from '@/lib/core/rate-limiter/types'
|
||||
import { DEFAULT_EXECUTION_TIMEOUT_MS } from '@/lib/core/execution-limits'
|
||||
import type { McpApiResponse } from '@/lib/mcp/types'
|
||||
import { isMcpTool, MCP } from '@/executor/constants'
|
||||
|
||||
@@ -13,10 +12,6 @@ export const MCP_CONSTANTS = {
|
||||
MAX_CONSECUTIVE_FAILURES: 3,
|
||||
} as const
|
||||
|
||||
export function getMcpExecutionTimeout(plan?: SubscriptionPlan): number {
|
||||
return getExecutionTimeout(plan, 'sync')
|
||||
}
|
||||
|
||||
/**
|
||||
* Core MCP tool parameter keys that are metadata, not user-entered test values.
|
||||
* These should be preserved when cleaning up params during schema updates.
|
||||
|
||||
Reference in New Issue
Block a user