d25d482dc2
Publish CLI Package / publish-npm (push) Waiting to run
Publish Python SDK / publish-pypi (push) Waiting to run
Publish TypeScript SDK / publish-npm (push) Waiting to run
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
108 lines
3.0 KiB
TypeScript
108 lines
3.0 KiB
TypeScript
import type { LinqCreateAttachmentParams, LinqCreateAttachmentResult } from '@/tools/linq/types'
|
|
import type { ToolConfig } from '@/tools/types'
|
|
|
|
export const linqCreateAttachmentTool: ToolConfig<
|
|
LinqCreateAttachmentParams,
|
|
LinqCreateAttachmentResult
|
|
> = {
|
|
id: 'linq_create_attachment',
|
|
name: 'Upload Attachment',
|
|
description:
|
|
'Upload a file to Linq as a reusable attachment (max 100MB) and get an attachment ID to send in messages',
|
|
version: '1.0.0',
|
|
|
|
params: {
|
|
apiKey: {
|
|
type: 'string',
|
|
required: true,
|
|
visibility: 'user-only',
|
|
description: 'Linq API key',
|
|
},
|
|
file: {
|
|
type: 'file',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'File to upload (a UserFile from a file-upload field or a previous block)',
|
|
},
|
|
fileContent: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'hidden',
|
|
description: 'Legacy base64-encoded file content fallback',
|
|
},
|
|
filename: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'Override the file name (defaults to the uploaded file name)',
|
|
},
|
|
contentType: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'Override the MIME type (defaults to the uploaded file type)',
|
|
},
|
|
},
|
|
|
|
request: {
|
|
url: '/api/tools/linq/upload',
|
|
method: 'POST',
|
|
headers: () => ({ 'Content-Type': 'application/json' }),
|
|
body: (params) => ({
|
|
apiKey: params.apiKey,
|
|
file: params.file,
|
|
fileContent: params.fileContent,
|
|
filename: params.filename,
|
|
contentType: params.contentType,
|
|
}),
|
|
},
|
|
|
|
transformResponse: async (response): Promise<LinqCreateAttachmentResult> => {
|
|
const data = await response.json()
|
|
|
|
if (!response.ok || !data?.success) {
|
|
return {
|
|
success: false,
|
|
error: data?.error ?? 'Failed to upload attachment',
|
|
output: {
|
|
attachmentId: '',
|
|
downloadUrl: null,
|
|
filename: '',
|
|
contentType: '',
|
|
sizeBytes: 0,
|
|
status: '',
|
|
},
|
|
}
|
|
}
|
|
|
|
const output = data.output ?? {}
|
|
return {
|
|
success: true,
|
|
output: {
|
|
attachmentId: output.attachmentId ?? '',
|
|
downloadUrl: output.downloadUrl ?? null,
|
|
filename: output.filename ?? '',
|
|
contentType: output.contentType ?? '',
|
|
sizeBytes: output.sizeBytes ?? 0,
|
|
status: output.status ?? '',
|
|
},
|
|
}
|
|
},
|
|
|
|
outputs: {
|
|
attachmentId: {
|
|
type: 'string',
|
|
description: 'Reusable attachment ID to reference when sending messages or voice memos',
|
|
},
|
|
downloadUrl: {
|
|
type: 'string',
|
|
description: 'URL the attachment can be downloaded from',
|
|
optional: true,
|
|
},
|
|
filename: { type: 'string', description: 'File name' },
|
|
contentType: { type: 'string', description: 'MIME type of the file' },
|
|
sizeBytes: { type: 'number', description: 'File size in bytes' },
|
|
status: { type: 'string', description: 'Upload status' },
|
|
},
|
|
}
|