@jinba-browserflow/sdk
v0.2.0
Published
Fluent type-safe builder that lowers to a FlowSpec.
Maintainers
Readme
@jinba-browserflow/sdk
Fluent, type-safe builder for Browserflow flows. You
describe a flow as a chain of typed steps; the SDK lowers it to a FlowSpec — the
deterministic IR the engine compiles and runs.
Install
npm i @jinba-browserflow/sdk zodExample
import { flow, browser, http, transform } from "@jinba-browserflow/sdk";
import { z } from "zod";
export const dailyPriceWatch = flow("daily-price-watch")
.input("query", z.string())
.input("threshold", z.number())
.input("webhook", z.string().url(), { secret: true })
.step("lookup", browser.tool<number>("[email protected]").with((c) => ({ query: c.input.query })))
.step("shape", transform((c) => ({ price: c.steps.lookup.output, at: c.now })))
.branch("dropped?", (c) => c.steps.shape.output.price < c.input.threshold, {
yes: (f) => f.step("notify", http.post((c) => c.secret.webhook, (c) => c.steps.shape.output)),
no: (f) => f.noop("unchanged"),
})
.output((c) => ({ price: c.steps.shape.output.price }));Compile and run the resulting FlowSpec with @jinba-browserflow/core,
or drive everything from the @jinba-browserflow/cli.
License
Apache-2.0
