;; lib/flow/api.sx — flow runtime entry points. ;; ;; Builds a Scheme env preloaded with the flow combinators (lib/flow/spec.sx) ;; plus the public flow API, and provides SX helpers to run flow programs. ;; ;; Scheme-level API (available inside flow programs): ;; (flow/start flow input) — run a flow with the given input, return result ;; ;; SX-level helpers (for hosts and tests): ;; (flow-make-env) — fresh standard env + combinators + api ;; (flow-run src) — eval a Scheme program string in a fresh flow env ;; (flow-run-in env src) — eval a Scheme program string in a given env (define flow-api-src "(define (flow/start flow input) (flow input))") (define flow-make-env (fn () (let ((env (scheme-standard-env))) (flow-load-combinators! env) (scheme-eval-program (scheme-parse-all flow-api-src) env) env))) (define flow-run-in (fn (env src) (scheme-eval-program (scheme-parse-all src) env))) (define flow-run (fn (src) (flow-run-in (flow-make-env) src)))