GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — looms/examples/durable-review.ts at main · ByteSliceHQ/looms Expand file tree/ Copy pathdurable-review.tsMore file actions 47 lines (38 loc) · 1.9 KB / Copy pathdurable-review.tsFile metadata and controls47 lines (38 loc) · 1.9 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 import { mkdir } from 'node:fs/promises' import { dirname } from 'node:path' import { decision, pendingApprovals } from '@swirls/looms/approval' import { bunSqliteEventStore } from '@swirls/looms/core/bun-sqlite' import { createLooms } from '@swirls/looms/runtime' import { modules, release } from './review-definition' const path = process.env.LOOMS_DB ?? './.looms/review.sqlite' await mkdir(dirname(path), { recursive: true }) const looms = createLooms({ modules, store: bunSqliteEventStore({ path }) }) const [command = 'start', runId] = Bun.argv.slice(2) try { if (command === 'start') { const result = await looms.start(release, { topic: 'Looms launch' }) console.log(JSON.stringify({ runId: result.runId, status: result.state.status })) console.log('The process now exits. Run inspect, approve, or reject with this runId.') } else { if (!runId) { throw new Error('Usage: bun durable-review.ts <inspect|approve|reject> <runId>') } if (command === 'approve' || command === 'reject') { const reviews = await looms.project(runId, pendingApprovals) const pending = reviews.items.find((item) => item.status === 'pending') if (!pending) { throw new Error('No pending review. Inspect the run before sending another decision.') } await looms.signal(runId, [decision({ approvalId: pending.approvalId, choice: command })]) } else if (command !== 'inspect') { throw new Error(`Unknown command: ${command}`) } const state = await looms.getRun(runId) const root = state.rootThreadId ? state.threads[state.rootThreadId] : undefined console.log(JSON.stringify({ runId, status: state.status, output: root?.output }, null, 2)) console.log(JSON.stringify(await looms.project(runId, pendingApprovals), null, 2)) console.log('Events:', (await looms.getEvents(runId)).map((event) => event.type).join(' → ')) } } finally { await looms.stop() } |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |