mirror of
https://github.com/simstudioai/sim.git
synced 2026-02-13 16:05:09 -05:00
* improvement(collab): do not refetch active workflow id * progress on files * more integrations * separate server and client logic * consolidate more code * fix integrations * fix types * consolidate more code * fix tests * fix more bugbot comments * fix type check * fix circular impport * address more bugbot comments * fix ocr integrations * fix typing * remove leftover type * address bugbot comment * fix file block adv mode * fix * normalize file input * fix v2 blocmks for ocr * fix for v2 versions * fix more v2 blocks * update single file blocks * make interface simpler * cleanup fireflies * remove file only annotation * accept all types * added wand to ssh block * user files should be passed through * improve docs * fix slack to include successful execs * fix dropbox upload file * fix sendgrid * fix dropbox * fix * fix * update skills * fix uploaded file --------- Co-authored-by: waleed <walif6@gmail.com>
139 lines
3.5 KiB
TypeScript
139 lines
3.5 KiB
TypeScript
import type { SftpUploadParams, SftpUploadResult } from '@/tools/sftp/types'
|
|
import type { ToolConfig } from '@/tools/types'
|
|
|
|
export const sftpUploadTool: ToolConfig<SftpUploadParams, SftpUploadResult> = {
|
|
id: 'sftp_upload',
|
|
name: 'SFTP Upload',
|
|
description: 'Upload files to a remote SFTP server',
|
|
version: '1.0.0',
|
|
|
|
params: {
|
|
host: {
|
|
type: 'string',
|
|
required: true,
|
|
visibility: 'user-only',
|
|
description: 'SFTP server hostname or IP address',
|
|
},
|
|
port: {
|
|
type: 'number',
|
|
required: true,
|
|
visibility: 'user-only',
|
|
description: 'SFTP server port (default: 22)',
|
|
},
|
|
username: {
|
|
type: 'string',
|
|
required: true,
|
|
visibility: 'user-only',
|
|
description: 'SFTP username',
|
|
},
|
|
password: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-only',
|
|
description: 'Password for authentication (if not using private key)',
|
|
},
|
|
privateKey: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-only',
|
|
description: 'Private key for authentication (OpenSSH format)',
|
|
},
|
|
passphrase: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-only',
|
|
description: 'Passphrase for encrypted private key',
|
|
},
|
|
remotePath: {
|
|
type: 'string',
|
|
required: true,
|
|
visibility: 'user-or-llm',
|
|
description: 'Destination directory on the remote server',
|
|
},
|
|
files: {
|
|
type: 'file[]',
|
|
required: false,
|
|
visibility: 'hidden',
|
|
description: 'Files to upload',
|
|
},
|
|
fileContent: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'Direct file content to upload (for text files)',
|
|
},
|
|
fileName: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'File name when using direct content',
|
|
},
|
|
overwrite: {
|
|
type: 'boolean',
|
|
required: false,
|
|
visibility: 'user-only',
|
|
description: 'Whether to overwrite existing files (default: true)',
|
|
},
|
|
permissions: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-only',
|
|
description: 'File permissions (e.g., 0644)',
|
|
},
|
|
},
|
|
|
|
request: {
|
|
url: '/api/tools/sftp/upload',
|
|
method: 'POST',
|
|
headers: () => ({
|
|
'Content-Type': 'application/json',
|
|
}),
|
|
body: (params) => ({
|
|
host: params.host,
|
|
port: Number(params.port) || 22,
|
|
username: params.username,
|
|
password: params.password,
|
|
privateKey: params.privateKey,
|
|
passphrase: params.passphrase,
|
|
remotePath: params.remotePath,
|
|
files: params.files,
|
|
fileContent: params.fileContent,
|
|
fileName: params.fileName,
|
|
overwrite: params.overwrite !== false,
|
|
permissions: params.permissions,
|
|
}),
|
|
},
|
|
|
|
transformResponse: async (response: Response) => {
|
|
const data = await response.json()
|
|
|
|
if (!response.ok) {
|
|
return {
|
|
success: false,
|
|
output: {
|
|
success: false,
|
|
},
|
|
error: data.error || 'SFTP upload failed',
|
|
}
|
|
}
|
|
|
|
return {
|
|
success: true,
|
|
output: {
|
|
success: true,
|
|
uploadedFiles: data.uploadedFiles,
|
|
message: data.message,
|
|
},
|
|
}
|
|
},
|
|
|
|
outputs: {
|
|
success: { type: 'boolean', description: 'Whether the upload was successful' },
|
|
uploadedFiles: {
|
|
type: 'json',
|
|
description: 'Array of uploaded file details (name, remotePath, size)',
|
|
},
|
|
message: { type: 'string', description: 'Operation status message' },
|
|
},
|
|
}
|