Something went wrong. Try again.
Experimental TypeScript workflow DSL for the Letta Agent SDK
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980/* * Public Knowledge batch: draft and review public-source articles in fresh, * tool-free conversations on one existing Letta agent. * * Usage: * bun examples/public-knowledge-batch.ts manifest.json [--out DIR] [--concurrency 3] [--dry-run] * * The flow never publishes, commits, deploys, or writes into a site checkout. * It emits private candidate drafts and receipts under publication-runs/. */
import type { FlowEvent } from "../src/index.js";import { defaultOutputDirectory, publicationRunSummary, runPublicationBatch,} from "./public-knowledge-batch-lib.js";
const manifestPath = process.argv[2];if (!manifestPath || manifestPath.startsWith("--")) { throw new Error( "Usage: bun examples/public-knowledge-batch.ts manifest.json [--out DIR] [--concurrency N] [--dry-run]", );}
const outputDirectory = stringFlag("out") ?? defaultOutputDirectory(manifestPath);const concurrency = numberFlag("concurrency", 3);const dryRun = process.argv.includes("--dry-run");
const result = await runPublicationBatch({ manifestPath, outputDirectory, outputRoot: "publication-runs", concurrency, dryRun, onEvent: renderEvent,});
console.log(`\n${publicationRunSummary(result)}`);if (!dryRun && result.entries.some((entry) => !entry.readyForIntegration)) process.exitCode = 1;
function renderEvent(event: FlowEvent): void { switch (event.type) { case "phase.started": process.stderr.write(`\n[${event.name}]\n`); break; case "operation.started": process.stderr.write(` start ${event.label ?? event.operationId}\n`); break; case "operation.completed": { const label = event.result.run.label ?? event.result.run.operationId; process.stderr.write( ` ${event.result.ok ? "done " : "fail "}${label} (${event.result.run.durationMs} ms)\n`, ); break; } case "cleanup.failed": process.stderr.write(` cleanup failed for ${event.operationId ?? "flow session"}\n`); break; default: break; }}
function numberFlag(name: string, fallback: number): number { const index = process.argv.indexOf(`--${name}`); if (index < 0) return fallback; const value = Number(process.argv[index + 1]); if (!Number.isInteger(value) || value <= 0) throw new Error(`--${name} requires a positive integer`); return value;}
function stringFlag(name: string): string | undefined { const index = process.argv.indexOf(`--${name}`); if (index < 0) return undefined; const value = process.argv[index + 1]; if (!value || value.startsWith("--")) throw new Error(`--${name} requires a value`); return value;}