Workflow execution is structured as a layered pipeline. In the REST execution path, a POST to /api/workflows/run reaches a controller that streams events using Vercel AI SDK’s pipeDataStreamToResponse. It registers a logging sink for streaming logs, then calls runWorkflow(name, input), which delegates to executeWorkflow(workflow, options). executeWorkflow spins up a browser (per invocation), optionally authenticates via the human-in-the-loop gate, runs the workflow function, and normalizes outcomes into a typed WorkflowResult containing SUCCESS/FAILED/SKIPPED plus artifact data.
In the CLI execution path, npx tsx src/runners/<name>.ts invokes executeWorkflow directly, using HEADED and WORKFLOW_RETRIES from env; it logs to stdout and sets process.exitCode = 1 on failure.
AI intent routing works by converting registered workflow functions into AI SDK tools with JSON Schema parameter validation. The intent endpoint maps a natural language prompt to tool selection using generateText with toolChoice: auto; the selected tool executes the corresponding service function and returns the result in the stream alongside tool-call metadata. If the model does not select a tool, the system falls back to keyword-based inference.
Authentication uses a session-state file persisted to storage/sessions/internal-ops.json. On executeWorkflow calls with requiresAuth: true, authentication navigates to the dashboard. If the heading indicates the user is logged in, it proceeds immediately. Otherwise it navigates to /login, detects the login heading, and blocks on page.waitForURL until the dashboard URL pattern is matched; it then persists session state for subsequent runs.
Testing is layered as well: unit tests cover domain guards, state constants, and filter functions; integration tests cover adapter functions (selectors, actions, assertions, verifications) using Vitest with mock page objects; Playwright tests in tests/example.spec.ts act as a baseline runner check against the Playwright docs site.