Examples · 04 of 06
Act on the clear requests. Hold the rest for a person.
A file of requests, one per line. What is sure runs. What needs a person is queued with its ranking, and what is nobody's stays untouched. A pattern for your app, in eleven lines.
The request and the result
01Lines in, decisions out.
The same three ops reflexes, fed a file. One line ran. One waits for a person. One fits nothing. Every line is what the terminal printed.
- 1A settled decision runs. The first line named everything and cleared the
bar, so
run()ran it. - 2An ask waits for a person. «silence db-3» named no duration. The decision carries what is missing and why, so a person can answer later.
- 3Nothing was invented. A question about the weather fits no reflex. It is queued as an abstain, with its ranking.
The operations
02Eleven lines around the same reflexes.
The app reads a line, decides, and runs what is settled. The reflexes are the ones from the ops example, installed beside the app as files.
scale checkout to 6 in staging silence db-3 what is the weather like
// The inbox as a stream. What is sure runs; the rest is queued for a person, // with the ranking or the missing pieces. import { createInterface } from "node:readline" import { load } from "@evoke-build/evoke" const ops = await load({ root: import.meta.dirname }) for await (const line of createInterface({ input: process.stdin })) { const d = await ops.decide(line) if (d.outcome === "run") console.log((await ops.run(d)).text) else console.log(`queued · ${d.outcome} · "${line}"`) }
- 1
decide()runs nothing. It returns a typed decision: run, confirm, ask or abstain. The app branches on it. - 2Only
runis acted on here. A confirm would also wait for a person in this app, since nothing answers it. Your queue decides who. - 3The decision is plain data. Keep it in any queue or table. A second process can fill or confirm it later.
One boundary
03With no terminal, a question is an exit code.
The CLI can take the same file. A line that needs an answer cannot get one from a pipe, so it exits 3 and names the command to run yourself.
$ evoke < inbox.txt scale service="checkout" env="staging" replicas="6" 0.90 deployment.apps/checkout-api scaled an ask needs a terminal → evoke "silence db-3" none 1.00 · 3 more under 0.01 [3]
Every other line is still answered. The filter exits with the first non-zero code. There is no flag that answers a question for you. Three ways in →
Before you run it
04What this pattern needs.
- Node 24.5 or newerAnd the SDK,
@evoke-build/evoke, next to the file. - Reflexes beside the appThe three from the ops example, installed with
evoke addin the app's directory, and their vocabulary. - A classifier keyOne request per line. The provider bills the use.
- Your queueThe app prints what it queued. Yours would store the decision and show it to someone.
The files above are the whole example. Copy them from this page.