Skip to content

feat(openworkflow, server, cli): server#466

Closed
jamescmartinez wants to merge 8 commits intomainfrom
server
Closed

feat(openworkflow, server, cli): server#466
jamescmartinez wants to merge 8 commits intomainfrom
server

Conversation

@jamescmartinez
Copy link
Copy Markdown
Contributor

@jamescmartinez jamescmartinez commented Apr 16, 2026

👉 closing this PR for now since there are a few prerequisites I want to knock out first. I'll reopen, rebase and finish when ready.

🚧 wip

Right now, openworkflow has no central server. Every worker talks directly to Postgres/SQLite, and the dashboard does too. That's fine for dev / a single-node setup, but it means every worker needs DB credentials, there's no place to put auth/rate-limiting/audit logging, and you can't run workers in environments that shouldn't have direct DB access (edge, untrusted tenants, other languages down the line).

This PR adds @openworkflow/server, an HTTP wrapper around the Backend interface, plus a matching BackendHttp client so workers and the dashboard can point at a URL instead of a database. The DB stays behind the server, and the server becomes the single place to add cross-cutting concerns later (scheduling, retention/cleanup like #370, etc.)

The full shared Backend test suite runs end-to-end against BackendHttp -> Server -> BackendPostgres to prove wire compatibility.

todo:

  • update docs (readme, public docs, and architecture; no api reference until v1)
  • cli init
  • move /metrics to the server from the dashboard
  • document lack of security for this v0 api (for now, at least)
  • (maybe) hook up google AIP linter since that was inspo for routes
  • add example

Copilot AI review requested due to automatic review settings April 16, 2026 18:11
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Introduces an HTTP server layer for OpenWorkflow by proxying the Backend interface over REST (Hono), plus an HTTP client backend implementation intended to let workers/dashboard talk to a server instead of directly to Postgres/SQLite.

Changes:

  • Added @openworkflow/server package implementing an HTTP API wrapper around Backend (including health/readiness endpoints) with validation + error mapping.
  • Added BackendHttp client that implements Backend over HTTP, including date-field parsing and BackendError rethrow semantics.
  • Updated CLI to add openworkflow server start and refactored graceful shutdown wiring.

Reviewed changes

Copilot reviewed 15 out of 17 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tsconfig.json Adds the new packages/server TS project reference.
packages/server/tsconfig.json New TS config for building the server package.
packages/server/package.json New @openworkflow/server package definition and build scripts.
packages/server/server.ts Implements the Hono server: routes for workflow runs, step attempts, and signals; verb dispatch; health endpoints; node serve().
packages/server/schemas.ts Zod request-body schemas used by the server for request validation.
packages/server/errors.ts Centralized error mapping (BackendError→HTTP, validation→400, internal scrubbing) and JSON body parsing helper.
packages/server/server.test.ts End-to-end suite: BackendHttp -> Server -> BackendPostgres, plus server-specific validation/error-path tests.
packages/openworkflow/http/backend.ts Adds BackendHttp implementation for the Backend interface over HTTP.
packages/openworkflow/internal.ts Exposes BackendError utilities and exports STEP_KINDS for runtime use.
packages/openworkflow/core/error.ts Introduces BackendError, BackendErrorCode, and runtime BACKEND_ERROR_CODES + guard.
packages/openworkflow/core/error.test.ts Adds unit test coverage for BackendError.
packages/openworkflow/core/step-attempt.ts Introduces runtime STEP_KINDS tuple and derives StepKind from it.
packages/cli/tsconfig.json Adds a TS project reference to ../server.
packages/cli/package.json Adds @openworkflow/server as a devDependency for monorepo builds/tests.
packages/cli/commands.ts Adds serverStart; refactors graceful shutdown into a shared helper.
packages/cli/cli.ts Wires the new openworkflow server start command into the CLI.
package-lock.json Links the new workspace package and updates CLI devDependencies.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/server/server.ts
Comment thread packages/cli/commands.ts Outdated
Comment thread packages/cli/commands.ts Outdated
Comment thread packages/openworkflow/http/backend.ts
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 16, 2026

Open in StackBlitz

npm i https://pkg.pr.new/openworkflowdev/openworkflow/@openworkflow/cli@466
npm i https://pkg.pr.new/openworkflowdev/openworkflow/@openworkflow/dashboard@466
npm i https://pkg.pr.new/openworkflowdev/openworkflow@466

commit: a27eab4

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copilot AI review requested due to automatic review settings April 16, 2026 22:31
- Fix TS2379/TS2375/TS2322 errors from `exactOptionalPropertyTypes` by
  normalizing zod-parsed error bodies into `SerializedError` and by
  conditionally spreading optional options.
- Cast `retryPolicy` to `RetryPolicy` and step-attempt `context` to
  `StepAttemptContext | null` at the HTTP boundary.
- Work around TS2589 deep-instantiation in Hono's `JSONParsed<T>` by
  routing complex response bodies through a `jsonResponse` helper and
  splitting step-attempt routes across sub-apps.
- Re-export `RetryPolicy`, `SerializedError`, and `StepAttemptContext`
  from `openworkflow/internal` so the server package can reference them.
- Drop unused `BACKEND_ERROR_CODES` and `HttpValidationError` exports,
  and deduplicate the worker-lease schemas to satisfy knip.
- Reformat server sources with prettier.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 19 out of 21 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/openworkflow/core/error.ts Outdated
Comment thread packages/server/server.ts
Comment thread packages/server/schemas.ts Outdated
Comment thread packages/server/schemas.ts
Comment thread packages/server/schemas.ts Outdated
Copilot AI review requested due to automatic review settings April 17, 2026 03:52
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 19 out of 21 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/cli/package.json
Comment thread packages/cli/commands.ts Outdated
Copilot AI review requested due to automatic review settings April 17, 2026 19:27
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 20 out of 22 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/server/errors.ts Outdated
Comment thread packages/cli/package.json
Comment thread packages/server/package.json
@jamescmartinez jamescmartinez marked this pull request as draft April 17, 2026 20:16
@jamescmartinez jamescmartinez marked this pull request as draft April 17, 2026 20:16
@jamescmartinez jamescmartinez deleted the server branch April 23, 2026 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants