improvement(files): validations (#4620)

* Fix

* Fixes
This commit is contained in:
Siddharth Ganesan
2026-05-15 15:28:48 -07:00
committed by GitHub
parent a64b338236
commit cb9c2d5452
8 changed files with 116 additions and 117 deletions
@@ -745,21 +745,11 @@ export class AgentBlockHandler implements BlockHandler {
for (let messageIndex = 0; messageIndex < messages.length; messageIndex++) {
const message = messages[messageIndex]
const normalizedFiles = normalizeFileInput(message.files)
if (!normalizedFiles || normalizedFiles.length === 0) {
if (!message.files?.length) {
continue
}
const userFiles = processFilesToUserFiles(
normalizedFiles as RawFileInput[],
requestId,
logger
)
if (userFiles.length === 0) {
throw new Error('Files must include at least one valid file object')
}
const hydratedFiles = await hydrateUserFilesWithBase64(userFiles, {
const hydratedFiles = await hydrateUserFilesWithBase64(message.files, {
requestId,
workspaceId: ctx.workspaceId,
workflowId: ctx.workflowId,
@@ -774,7 +764,7 @@ export class AgentBlockHandler implements BlockHandler {
const missingFile = hydratedFiles.find((file) => !file.base64)
if (missingFile) {
throw new Error(
`File "${missingFile.name}" could not be read for provider "${providerId}". Make sure the file is still accessible and under the provider attachment size limit.`
`File "${missingFile.name}" could not be read for provider "${providerId}". The file may exceed the attachment size limit or may no longer be accessible.`
)
}
@@ -179,7 +179,7 @@ describe('Memory', () => {
})
describe('sanitizeMessageForStorage', () => {
it('should strip file payloads and provider-only fields before memory persistence', () => {
it('should strip file payloads but preserve tool-call fields before memory persistence', () => {
const message: Message = {
role: 'user',
content: 'Analyze this file',
@@ -202,6 +202,7 @@ describe('Memory', () => {
role: 'user',
content: 'Analyze this file',
executionId: 'exec-1',
tool_calls: [{ id: 'call-1' }],
})
})
})
+2 -5
View File
@@ -123,11 +123,8 @@ export class Memory {
}
private sanitizeMessageForStorage(message: Message): Message {
return {
role: message.role,
content: message.content,
...(message.executionId && { executionId: message.executionId }),
}
const { files: _files, ...messageWithoutFiles } = message
return messageWithoutFiles
}
private applyTokenWindow(messages: Message[], maxTokens: number, model?: string): Message[] {
+9 -1
View File
@@ -3,6 +3,14 @@ import { defineRouteContract } from '@/lib/api/contracts/types'
import { getNextWorkflowColor } from '@/lib/workflows/colors'
const subBlockValuesSchema = z.record(z.string(), z.record(z.string(), z.unknown()))
const executionIdSchema = z
.string()
.min(1, 'Invalid execution ID')
.max(128, 'Execution ID too long')
.regex(
/^[A-Za-z0-9._:-]+$/,
'Execution ID can only contain letters, numbers, dots, underscores, colons, and hyphens'
)
const workflowPositionSchema = z.object({
x: z.number(),
@@ -336,7 +344,7 @@ export const executeWorkflowBodySchema = z.object({
includeFileBase64: z.boolean().optional().default(true),
base64MaxBytes: z.number().int().positive().optional(),
workflowStateOverride: workflowStateSchema.optional(),
executionId: z.string().optional(),
executionId: executionIdSchema.optional(),
triggerBlockId: z.string().optional(),
startBlockId: z.string().optional(),
stopAfterBlockId: z.string().optional(),
@@ -10,7 +10,7 @@ export interface ToolRuntimeSchemaEntry {
}
export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
['agent']: {
agent: {
parameters: {
properties: {
request: {
@@ -23,7 +23,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['auth']: {
auth: {
parameters: {
properties: {
request: {
@@ -36,7 +36,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['check_deployment_status']: {
check_deployment_status: {
parameters: {
type: 'object',
properties: {
@@ -48,7 +48,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['complete_job']: {
complete_job: {
parameters: {
type: 'object',
properties: {
@@ -61,7 +61,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['context_write']: {
context_write: {
parameters: {
type: 'object',
properties: {
@@ -78,7 +78,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['crawl_website']: {
crawl_website: {
parameters: {
type: 'object',
properties: {
@@ -113,7 +113,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['create_file']: {
create_file: {
parameters: {
type: 'object',
properties: {
@@ -149,7 +149,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
required: ['success', 'message'],
},
},
['create_file_folder']: {
create_file_folder: {
parameters: {
type: 'object',
properties: {
@@ -170,7 +170,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['create_folder']: {
create_folder: {
parameters: {
type: 'object',
properties: {
@@ -191,7 +191,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['create_job']: {
create_job: {
parameters: {
type: 'object',
properties: {
@@ -241,7 +241,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['create_workflow']: {
create_workflow: {
parameters: {
type: 'object',
properties: {
@@ -266,7 +266,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['create_workspace_mcp_server']: {
create_workspace_mcp_server: {
parameters: {
type: 'object',
properties: {
@@ -299,7 +299,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['debug']: {
debug: {
parameters: {
properties: {
context: {
@@ -318,7 +318,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['delete_file']: {
delete_file: {
parameters: {
type: 'object',
properties: {
@@ -347,7 +347,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
required: ['success', 'message'],
},
},
['delete_file_folder']: {
delete_file_folder: {
parameters: {
type: 'object',
properties: {
@@ -363,7 +363,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['delete_folder']: {
delete_folder: {
parameters: {
type: 'object',
properties: {
@@ -379,7 +379,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['delete_workflow']: {
delete_workflow: {
parameters: {
type: 'object',
properties: {
@@ -395,7 +395,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['delete_workspace_mcp_server']: {
delete_workspace_mcp_server: {
parameters: {
type: 'object',
properties: {
@@ -408,7 +408,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['deploy']: {
deploy: {
parameters: {
properties: {
request: {
@@ -422,7 +422,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['deploy_api']: {
deploy_api: {
parameters: {
type: 'object',
properties: {
@@ -496,7 +496,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
],
},
},
['deploy_chat']: {
deploy_chat: {
parameters: {
type: 'object',
properties: {
@@ -644,7 +644,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
],
},
},
['deploy_mcp']: {
deploy_mcp: {
parameters: {
type: 'object',
properties: {
@@ -760,7 +760,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
required: ['deploymentType', 'deploymentStatus'],
},
},
['download_to_workspace_file']: {
download_to_workspace_file: {
parameters: {
type: 'object',
properties: {
@@ -779,7 +779,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['edit_content']: {
edit_content: {
parameters: {
type: 'object',
properties: {
@@ -811,7 +811,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
required: ['success', 'message'],
},
},
['edit_workflow']: {
edit_workflow: {
parameters: {
type: 'object',
properties: {
@@ -850,13 +850,13 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['file']: {
file: {
parameters: {
type: 'object',
},
resultSchema: undefined,
},
['function_execute']: {
function_execute: {
parameters: {
type: 'object',
properties: {
@@ -917,7 +917,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['generate_api_key']: {
generate_api_key: {
parameters: {
type: 'object',
properties: {
@@ -935,7 +935,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['generate_image']: {
generate_image: {
parameters: {
type: 'object',
properties: {
@@ -972,7 +972,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['generate_visualization']: {
generate_visualization: {
parameters: {
type: 'object',
properties: {
@@ -1012,7 +1012,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['get_block_outputs']: {
get_block_outputs: {
parameters: {
type: 'object',
properties: {
@@ -1033,7 +1033,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['get_block_upstream_references']: {
get_block_upstream_references: {
parameters: {
type: 'object',
properties: {
@@ -1055,7 +1055,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['get_deployed_workflow_state']: {
get_deployed_workflow_state: {
parameters: {
type: 'object',
properties: {
@@ -1068,7 +1068,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['get_deployment_version']: {
get_deployment_version: {
parameters: {
type: 'object',
properties: {
@@ -1085,7 +1085,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['get_execution_summary']: {
get_execution_summary: {
parameters: {
type: 'object',
properties: {
@@ -1112,7 +1112,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['get_job_logs']: {
get_job_logs: {
parameters: {
type: 'object',
properties: {
@@ -1137,7 +1137,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['get_page_contents']: {
get_page_contents: {
parameters: {
type: 'object',
properties: {
@@ -1165,14 +1165,14 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['get_platform_actions']: {
get_platform_actions: {
parameters: {
type: 'object',
properties: {},
},
resultSchema: undefined,
},
['get_workflow_data']: {
get_workflow_data: {
parameters: {
type: 'object',
properties: {
@@ -1191,7 +1191,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['get_workflow_logs']: {
get_workflow_logs: {
parameters: {
type: 'object',
properties: {
@@ -1217,7 +1217,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['glob']: {
glob: {
parameters: {
type: 'object',
properties: {
@@ -1236,7 +1236,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['grep']: {
grep: {
parameters: {
type: 'object',
properties: {
@@ -1283,7 +1283,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['job']: {
job: {
parameters: {
properties: {
request: {
@@ -1296,7 +1296,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['knowledge']: {
knowledge: {
parameters: {
properties: {
request: {
@@ -1309,7 +1309,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['knowledge_base']: {
knowledge_base: {
parameters: {
type: 'object',
properties: {
@@ -1501,7 +1501,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
required: ['success', 'message'],
},
},
['list_file_folders']: {
list_file_folders: {
parameters: {
type: 'object',
properties: {
@@ -1513,7 +1513,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['list_folders']: {
list_folders: {
parameters: {
type: 'object',
properties: {
@@ -1525,14 +1525,14 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['list_user_workspaces']: {
list_user_workspaces: {
parameters: {
type: 'object',
properties: {},
},
resultSchema: undefined,
},
['list_workspace_mcp_servers']: {
list_workspace_mcp_servers: {
parameters: {
type: 'object',
properties: {
@@ -1545,7 +1545,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['manage_credential']: {
manage_credential: {
parameters: {
type: 'object',
properties: {
@@ -1574,7 +1574,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['manage_custom_tool']: {
manage_custom_tool: {
parameters: {
type: 'object',
properties: {
@@ -1653,7 +1653,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['manage_job']: {
manage_job: {
parameters: {
type: 'object',
properties: {
@@ -1723,7 +1723,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['manage_mcp_tool']: {
manage_mcp_tool: {
parameters: {
type: 'object',
properties: {
@@ -1774,7 +1774,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['manage_skill']: {
manage_skill: {
parameters: {
type: 'object',
properties: {
@@ -1806,7 +1806,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['materialize_file']: {
materialize_file: {
parameters: {
type: 'object',
properties: {
@@ -1840,7 +1840,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['move_file']: {
move_file: {
parameters: {
type: 'object',
properties: {
@@ -1861,7 +1861,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['move_file_folder']: {
move_file_folder: {
parameters: {
type: 'object',
properties: {
@@ -1879,7 +1879,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['move_folder']: {
move_folder: {
parameters: {
type: 'object',
properties: {
@@ -1897,7 +1897,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['move_workflow']: {
move_workflow: {
parameters: {
type: 'object',
properties: {
@@ -1917,7 +1917,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['oauth_get_auth_link']: {
oauth_get_auth_link: {
parameters: {
type: 'object',
properties: {
@@ -1931,7 +1931,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['oauth_request_access']: {
oauth_request_access: {
parameters: {
type: 'object',
properties: {
@@ -1945,7 +1945,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['open_resource']: {
open_resource: {
parameters: {
type: 'object',
properties: {
@@ -1974,7 +1974,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['read']: {
read: {
parameters: {
type: 'object',
properties: {
@@ -2001,7 +2001,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['redeploy']: {
redeploy: {
parameters: {
type: 'object',
properties: {
@@ -2069,7 +2069,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
],
},
},
['rename_file']: {
rename_file: {
parameters: {
type: 'object',
properties: {
@@ -2104,7 +2104,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
required: ['success', 'message'],
},
},
['rename_file_folder']: {
rename_file_folder: {
parameters: {
type: 'object',
properties: {
@@ -2121,7 +2121,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['rename_workflow']: {
rename_workflow: {
parameters: {
type: 'object',
properties: {
@@ -2138,7 +2138,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['research']: {
research: {
parameters: {
properties: {
topic: {
@@ -2151,7 +2151,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['respond']: {
respond: {
parameters: {
additionalProperties: true,
properties: {
@@ -2174,7 +2174,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['restore_resource']: {
restore_resource: {
parameters: {
type: 'object',
properties: {
@@ -2192,7 +2192,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['revert_to_version']: {
revert_to_version: {
parameters: {
type: 'object',
properties: {
@@ -2209,7 +2209,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['run']: {
run: {
parameters: {
properties: {
context: {
@@ -2226,7 +2226,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['run_block']: {
run_block: {
parameters: {
type: 'object',
properties: {
@@ -2258,7 +2258,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['run_from_block']: {
run_from_block: {
parameters: {
type: 'object',
properties: {
@@ -2290,7 +2290,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['run_workflow']: {
run_workflow: {
parameters: {
type: 'object',
properties: {
@@ -2318,7 +2318,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['run_workflow_until_block']: {
run_workflow_until_block: {
parameters: {
type: 'object',
properties: {
@@ -2350,7 +2350,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['scrape_page']: {
scrape_page: {
parameters: {
type: 'object',
properties: {
@@ -2371,7 +2371,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['search_documentation']: {
search_documentation: {
parameters: {
type: 'object',
properties: {
@@ -2388,7 +2388,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['search_library_docs']: {
search_library_docs: {
parameters: {
type: 'object',
properties: {
@@ -2409,7 +2409,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['search_online']: {
search_online: {
parameters: {
type: 'object',
properties: {
@@ -2450,7 +2450,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['search_patterns']: {
search_patterns: {
parameters: {
type: 'object',
properties: {
@@ -2472,7 +2472,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['set_block_enabled']: {
set_block_enabled: {
parameters: {
type: 'object',
properties: {
@@ -2494,7 +2494,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['set_environment_variables']: {
set_environment_variables: {
parameters: {
type: 'object',
properties: {
@@ -2528,7 +2528,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['set_global_workflow_variables']: {
set_global_workflow_variables: {
parameters: {
type: 'object',
properties: {
@@ -2566,7 +2566,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['superagent']: {
superagent: {
parameters: {
properties: {
task: {
@@ -2580,7 +2580,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['table']: {
table: {
parameters: {
properties: {
request: {
@@ -2593,7 +2593,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['tool_search_tool_regex']: {
tool_search_tool_regex: {
parameters: {
properties: {
case_insensitive: {
@@ -2614,7 +2614,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['update_job_history']: {
update_job_history: {
parameters: {
type: 'object',
properties: {
@@ -2632,7 +2632,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['update_workspace_mcp_server']: {
update_workspace_mcp_server: {
parameters: {
type: 'object',
properties: {
@@ -2657,7 +2657,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['user_memory']: {
user_memory: {
parameters: {
type: 'object',
properties: {
@@ -2705,7 +2705,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
},
resultSchema: undefined,
},
['user_table']: {
user_table: {
parameters: {
type: 'object',
properties: {
@@ -3034,13 +3034,13 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
required: ['success', 'message'],
},
},
['workflow']: {
workflow: {
parameters: {
type: 'object',
},
resultSchema: undefined,
},
['workspace_file']: {
workspace_file: {
parameters: {
type: 'object',
properties: {
@@ -1,3 +1,4 @@
import { randomBytes } from 'crypto'
import { createLogger } from '@sim/logger'
import { toError } from '@sim/utils/errors'
import { PDFDocument } from 'pdf-lib'
@@ -353,7 +354,7 @@ async function handleFileForOCR(
}
const timestamp = Date.now()
const uniqueId = Math.random().toString(36).substring(2, 9)
const uniqueId = randomBytes(8).toString('hex')
const safeFileName = filename.replace(/[^a-zA-Z0-9.-]/g, '_')
const customKey = `kb/${timestamp}-${uniqueId}-${safeFileName}`
@@ -650,7 +651,7 @@ async function processChunk(
try {
const timestamp = Date.now()
const uniqueId = Math.random().toString(36).substring(2, 9)
const uniqueId = randomBytes(8).toString('hex')
const safeFileName = filename.replace(/[^a-zA-Z0-9.-]/g, '_')
const chunkKey = `kb/${timestamp}-${uniqueId}-chunk${chunkIndex + 1}-${safeFileName}`
@@ -3,6 +3,7 @@
* Files uploaded at workspace level persist indefinitely and are accessible across all workflows
*/
import { randomBytes } from 'crypto'
import { db } from '@sim/db'
import { workspaceFiles } from '@sim/db/schema'
import { createLogger } from '@sim/logger'
@@ -117,7 +118,7 @@ export function parseWorkspaceFileKey(key: string): string | null {
*/
export function generateWorkspaceFileKey(workspaceId: string, fileName: string): string {
const timestamp = Date.now()
const random = Math.random().toString(36).substring(2, 9)
const random = randomBytes(8).toString('hex')
const safeFileName = sanitizeFileName(fileName)
return `workspace/${workspaceId}/${timestamp}-${random}-${safeFileName}`
}
+2 -1
View File
@@ -1,3 +1,4 @@
import { randomBytes } from 'crypto'
import { createLogger } from '@sim/logger'
import { getStorageConfig, USE_BLOB_STORAGE, USE_S3_STORAGE } from '@/lib/uploads/config'
import type { BlobConfig } from '@/lib/uploads/providers/blob/types'
@@ -294,7 +295,7 @@ export async function generatePresignedUploadUrl(
key = customKey
} else {
const timestamp = Date.now()
const uniqueId = Math.random().toString(36).substring(2, 9)
const uniqueId = randomBytes(8).toString('hex')
const safeFileName = fileName.replace(/[^a-zA-Z0-9.-]/g, '_')
key = `${context}/${timestamp}-${uniqueId}-${safeFileName}`
}