import {
AsteroidClient,
AgentsV2SDK,
executeAgent,
getExecutionFiles,
downloadExecutionFile,
uploadExecutionFiles,
} from 'asteroid-odyssey';
import { readFileSync } from 'node:fs';
const client = AsteroidClient(process.env.ASTEROID_API_KEY!);
const invoiceBytes = readFileSync('./invoice.pdf');
const invoice = new File([invoiceBytes], 'invoice.pdf', { type: 'application/pdf' });
const { data: staged } = await AgentsV2SDK.tempFilesStage({
client: client.agentsV2Client,
path: { organizationId: 'your-org-id' },
body: { files: [invoice] },
});
const executionId = await executeAgent(client, 'your-agent-id', {
dynamicData: {
task: 'Read the attached invoice and summarize it',
},
tempFiles: staged?.tempFiles,
});
await uploadExecutionFiles(client, executionId, [invoice]);
const files = await getExecutionFiles(client, executionId);
for (const file of files) {
console.log(`${file.fileName}: ${file.fileSize} bytes`);
await downloadExecutionFile(client, file, './downloads/');
}