Skip to content

Commit ff99c84

Browse files
authored
feat(core): Add parse-file tool for structured attachments (no-changelog) (n8n-io#28251)
1 parent 153fae2 commit ff99c84

16 files changed

Lines changed: 1590 additions & 28 deletions

File tree

packages/@n8n/api-types/src/schemas/instance-ai.schema.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -545,17 +545,17 @@ export type InstanceAiFilesystemResponse = z.infer<typeof instanceAiFilesystemRe
545545
// ---------------------------------------------------------------------------
546546

547547
const instanceAiAttachmentSchema = z.object({
548-
data: z.string(),
549-
mimeType: z.string(),
550-
fileName: z.string(),
548+
data: z.string().max(700_000), // ~512 KB decoded + base64 overhead
549+
mimeType: z.string().max(100),
550+
fileName: z.string().max(300),
551551
});
552552

553553
export type InstanceAiAttachment = z.infer<typeof instanceAiAttachmentSchema>;
554554

555555
export class InstanceAiSendMessageRequest extends Z.class({
556-
message: z.string().min(1),
556+
message: z.string().default(''),
557557
researchMode: z.boolean().optional(),
558-
attachments: z.array(instanceAiAttachmentSchema).optional(),
558+
attachments: z.array(instanceAiAttachmentSchema).max(10).optional(),
559559
timeZone: TimeZoneSchema,
560560
pushRef: z.string().optional(),
561561
}) {}

packages/@n8n/instance-ai/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"@n8n/workflow-sdk": "workspace:*",
4040
"linkedom": "^0.18.9",
4141
"luxon": "catalog:",
42+
"csv-parse": "5.5.0",
4243
"nanoid": "catalog:",
4344
"p-limit": "^3.1.0",
4445
"pdf-parse": "^1.1.1",

packages/@n8n/instance-ai/src/index.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,3 +178,12 @@ export type { StartedWorkflowBuildTask } from './tools/orchestration/build-workf
178178
export type { StartedBackgroundAgentTask } from './tools/orchestration/data-table-agent.tool';
179179
export type { DetachedDelegateTaskResult } from './tools/orchestration/delegate.tool';
180180
export type { StartedResearchAgentTask } from './tools/orchestration/research-with-agent.tool';
181+
export {
182+
classifyAttachments,
183+
buildAttachmentManifest,
184+
isStructuredAttachment,
185+
} from './parsers/structured-file-parser';
186+
export type {
187+
ClassifiedAttachment,
188+
ParseableFormat,
189+
} from './parsers/structured-file-parser';

0 commit comments

Comments
 (0)