@assemblyline/lib-factory
v0.53.0
Published
The runtime for Assembly Line factories: factory sessions, stations, bins, workpieces and watchers
Maintainers
Readme
lib-factory
The runtime for Assembly Line factories: a factory repo depends on it
to define stations with defineStation(), run a factory session against the Orchestrator, and
run one station locally with npx factory.
Install
npm install @assemblyline/lib-factoryA new factory starts from factory-template, which already depends on it.
Example
A station that counts the words in each workpiece in its input/ bin, from
src/stations/EX1__count_words/station.js:
import { defineStation, countWords, renderLocal } from '@assemblyline/lib-factory';
import { z } from 'zod';
export default defineStation({
code: 'EX1',
configSchema: z.object({
batch_size: z.number().int().positive().default(10),
concurrency: z.number().int().positive().default(1),
}),
async execute(config, ctx) {
const { results, counts } = await ctx.eachWorkpiece(async (wp) => {
const words = countWords(wp.readText('document.txt'));
if (words === 0) throw new Error('Empty document: nothing to count'); // → failed/
wp.writeJson('result.json', { words });
return { words }; // → output/
});
await ctx.attachReport(renderLocal(import.meta.url, './report.md', { results }));
return { done_count: counts.done, failed_count: counts.failed };
},
});Run it on your machine, from the factory's root:
npx factory stations run EX1Docs
- assemblyline.sh/docs: the method, the quickstart and the guides
- Reference:
defineStation, the station context, the workpiece, the.factory/folder, the entry point, environment variables and thefactorycommand - For agents: assemblyline.sh/llms.txt
- How the lib works inside:
docs/architecture/
License
MIT
