Three APIs. One declarative flow. Parse documents, run deep research, generate content — as a single pipeline.
const { Trilogy } = require('trilogy-framework'); const t = new Trilogy({ docmind: 'dm_p_...', deep: 'deep_p_...', flux: 'flux_p_...', }); // Receipt → research the merchant → write a blog about it const result = await t.pipeline() .name('receipt-to-blog') .parseReceipt('./receipt.jpg') .research(ctx => `Tell me about ${ctx.document.merchant}`) .blog(ctx => `Expense spotlight: ${ctx.document.merchant}`) .run(); console.log(result.content); // blog post console.log(result.document); // parsed receipt data console.log(result.research); // merchant research console.log(result._pipeline); // { total_ms, steps: [...] }
// One-liners — 15 pre-built pipelines // Research → Twitter thread const thread = await t.researchToThread('Why AI agents are replacing SaaS').run(); // Compare → blog post const blog = await t.compareToBlog( ['React', 'Vue', 'Svelte'], ['performance', 'ecosystem', 'DX'] ).run(); // Raw draft → SEO + improve + repurpose into 5 formats const blitz = await t.contentBlitz(myDraft).run(); // Contract → research terms → summary email const email = await t.contractToEmail('./contract.pdf').run(); // Fact-check → debunking thread const facts = await t.factCheckToThread([ 'The Great Wall is visible from space', 'Humans use 10% of their brain', ]).run();
// Research once → generate blog + thread + social in parallel const result = await t.pipeline() .research('MCP protocol — what developers need to know') .parallel( p => p.blog(ctx => ({ topic: 'MCP Deep Dive', context: ctx.research })), p => p.thread(ctx => ({ topic: 'MCP Explained', context: ctx.research })), p => p.social(ctx => ({ topic: 'MCP is here', context: ctx.research })), ) .run(); // All three generated simultaneously from the same research
// Only research if receipt total > $100 const result = await t.pipeline() .parseReceipt('./receipt.jpg') .when( ctx => ctx.document.total > 100, p => p.research(ctx => `Is ${ctx.document.merchant} overcharging?`) ) .blog(ctx => `Expense report: ${ctx.document.merchant}`) .run(); // Loop over URLs await t.pipeline() .context({ urls: ['https://a.com', 'https://b.com'] }) .each('urls', p => { p.extract(ctx => ctx.item) .blog(ctx => ({ topic: ctx.item, context: ctx.extracted })); }) .run();
const result = await t.pipeline() .name('tracked-pipeline') .onStep(event => { console.log(`[${event.phase}] ${event.step} — ${event.index + 1}/${event.total}`); // [input] parse.receipt — 1/3 // [intelligence] research — 2/3 // [output] generate.blog — 3/3 }) .onError((err, step) => { console.error(`Step "${step.name}" failed: ${err.message}`); // Pipeline continues — non-fatal }) .parseReceipt('./receipt.jpg') .research(ctx => ctx.document.merchant) .blog(ctx => ctx.document.merchant) .run(); console.log(result._pipeline.total_ms); // 8432 console.log(result._pipeline.steps); // full timeline
Three APIs unified into one declarative framework
Chain input, intelligence, and output steps into one readable flow. No callbacks. No glue code. Just .parseReceipt().research().blog().run()
Each step's output merges into shared context. Later steps access earlier results via ctx => functions. Zero boilerplate.
One-liner pipelines for common flows. researchToThread(), contentBlitz(), contractToEmail() — just call and .run().
Generate blog + thread + social simultaneously from the same research. .parallel() runs branches concurrently and merges results.
Conditionals with .when(), loops with .each(), transforms with .transform(), side effects with .tap().
Step events, error handlers, execution timelines. Every pipeline returns _pipeline metadata with per-step timing and status.
Each phase maps to a dedicated API
.parseReceipt().parseInvoice().parseBankStatement().parseContract().chat().research().researchDeep().factCheck().compare().extract().seo().blog().thread().social().email().ads().product().landing().repurpose().improve()Common flows as one-liners