Skip to content

feat: add Workflows automations to OpenWork server and app#1606

Draft
benjaminshafii wants to merge 12 commits intodevfrom
feat/inngest-automations
Draft

feat: add Workflows automations to OpenWork server and app#1606
benjaminshafii wants to merge 12 commits intodevfrom
feat/inngest-automations

Conversation

@benjaminshafii
Copy link
Copy Markdown
Member

@benjaminshafii benjaminshafii commented Apr 29, 2026

Summary

Adds a Workflows system to OpenWork: users can create, trigger, edit, schedule, and delete automations from the Settings > Automations tab. Each workflow runs a prompt in OpenCode by creating a session and sending the configured prompt.

The server exposes a generic REST API (/workspace/:id/automations). The app has no knowledge of the execution engine — it can be swapped without touching the frontend.

What this adds

Server (apps/server)

  • src/automations.ts — automation store, CRUD, trigger, recurring scheduler
  • REST endpoints:
    • GET /workspace/:id/automations — list
    • POST /workspace/:id/automations — create
    • GET /workspace/:id/automations/:autoId — get
    • PATCH /workspace/:id/automations/:autoId — update (name, prompt, schedule)
    • DELETE /workspace/:id/automations/:autoId — delete
    • POST /workspace/:id/automations/:autoId/trigger — run now
  • Recurring scheduler: setInterval in the server process, checks every 10s, fires automations whose interval has elapsed
  • Trigger creates an OpenCode session via fetchOpencodeJson and sends the prompt with prompt_async
  • Inngest SDK installed — durable functions defined but only used when the Inngest dev server is reachable; otherwise falls back to direct OpenCode calls

App (apps/app)

  • WorkflowsPanel component in the Automations settings tab
  • Create/Edit modal with name, description, prompt, and schedule picker
  • Schedule options: Manual, Every 30s (test), 1m, 5m, 15m, 1h, 6h, 24h
  • Workflow cards show status badge (Success/Running/Failed), last run time, run count
  • Edit button to change prompt or schedule on existing workflows
  • Delete and Run buttons
  • Auto-refresh every 15s to pick up recurring status changes
  • No implementation-specific branding in the UI — generic "Workflows" surface

Evals (evals/workflow-automations.md)

  • 7 flows: create, trigger + OpenCode execution, edit schedule, recurring execution, delete, create from preset, server-disconnect graceful degradation

Architecture

App (React)                     Server (v1, automations.ts)          OpenCode
    |                               |                                    |
    |-- REST /automations -------->|  (CRUD: in-memory store)           |
    |                               |                                    |
    |-- POST .../trigger --------->|                                    |
    |                               |                                    |
    |                          ┌────┴──── try inngest.send() ──────┐    |
    |                          │    (if Inngest dev server on :8288)│    |
    |                          │                                    │    |
    |                          │  Inngest Dev Server (optional)     │    |
    |                          │  ┌───────────────────────────┐    │    |
    |                          │  │ Durable execution:        │    │    |
    |                          │  │  step 1: create-session   │────┼───>|
    |                          │  │  step 2: send-prompt      │────┼───>|
    |                          │  │  (retries, observability) │    │    |
    |                          │  └───────────────────────────┘    │    |
    |                          │                                    │    |
    |                          └──── OR fallback: direct call ─────┘    |
    |                               |                                    |
    |                               |-- POST /session ----------------->|
    |                               |<-- { id: "ses_..." } ------------|
    |                               |-- POST /session/:id/prompt_async->|
    |                               |<-- 204 --------------------------|
    |                               |                                    |
    |<-- { sessionId } ------------|                                    |
    |                               |                                    |
    |                          Recurring scheduler                       |
    |                          (setInterval 10s in server process)       |
    |                          checks each automation's interval,        |
    |                          fires direct call path when elapsed        |

Two execution paths, same outcome:

Path When What you get
Inngest Inngest dev server running on :8288 Durable steps with per-step retries, Inngest dashboard observability, event-driven
Direct Default / Inngest unreachable Simple fetch calls to OpenCode, no retries, works out of the box

The recurring scheduler always uses the direct path. The Inngest path is opt-in by starting npx inngest-cli@latest dev alongside the server.

Testing

Electron dev flow (Chrome MCP on CDP port 9823):

Step Action Result
1 Open Settings > Automations Workflows panel loads, presets visible
2 Click New Workflow, fill form Modal with schedule picker
3 Create "Daily potato facts" Appears in list with Run/Edit/Delete
4 Click Run Status: Success, Last run: Just now
5 Delete automation Removed from list
6 Create "Recurring potato writer" (Every 1m) Schedule badge shows "Every 1m"
7 Wait ~2 minutes Runs: 2 (scheduler fired automatically)
8 Wait ~6 minutes Runs: 7 (recurring confirmed)
9 Click Edit, change schedule to 5m Badge updates to "Every 5m"

API-level verification:

  • Created automation via curl, triggered it, verified OpenCode session was created and agent responded with content

Typecheck: pnpm tsc --noEmit passes for apps/server and apps/app

Future work

  • Persist automations to SQLite (currently in-memory, lost on server restart)
  • Multi-step workflows (chain multiple prompts/actions)
  • Cron expression support (in addition to interval-based scheduling)
  • Inngest Cloud integration for production (replaces dev server)

- Add inngest dependency and create client/functions/service
- Inngest functions: run-automation and scheduled-automation
- REST API: /workspaces/:id/automations (CRUD + trigger)
- Inngest serve endpoint at /api/inngest
- Direct execution fallback when Inngest dev server is offline
- In-memory automation store for initial integration
- WorkflowsPanel component with create/trigger/delete UI
- Preset workflow templates (Open Chrome to Facebook, standup, etc.)
- Integrated into settings-route automations tab
- Calls server-v2 /workspaces/:id/automations REST endpoints
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Apr 29, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
openwork-app Ready Ready Preview, Comment Apr 29, 2026 3:56pm
openwork-den Ready Ready Preview, Comment Apr 29, 2026 3:56pm
openwork-den-worker-proxy Ready Ready Preview, Comment Apr 29, 2026 3:56pm
openwork-landing Ready Ready Preview, Comment, Open in v0 Apr 29, 2026 3:56pm
openwork-share Ready Ready Preview, Comment Apr 29, 2026 3:56pm

@github-actions
Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

…ion service directly

- prompt_async expects { parts: [{ type: 'text', text: prompt }] } not { content: prompt }
- Direct execution fallback now uses WorkspaceSessionService instead of HTTP self-call
- Verified end-to-end: automation creates session + sends prompt + agent responds
…r test evidence

- Fix /api/inngest route to call InngestCommHandler correctly
- Inngest dev server discovers 2 functions: run-automation, scheduled-automation
- E2E: trigger -> Inngest event -> create-session step -> send-prompt step -> agent responds
- Screenshots of Inngest dev server showing completed run with step trace
- Create apps/server/src/inngest.ts with automation CRUD + trigger
- Add routes to server.ts: GET/POST/DELETE /workspace/:id/automations
- Trigger creates OpenCode session and sends prompt via fetchOpencodeJson
- Update WorkflowsPanel to use v1 URL pattern (/workspace/ not /workspaces/)
- Install inngest in apps/server package.json
Tested against running Electron app (CDP port 9823) with server-v1 sidecar:
1. Settings > Automations shows Workflows panel with presets
2. Created 'Daily potato facts' automation via New Workflow modal
3. Automation appears in list with name, description, prompt, Run/Delete buttons
4. Clicked Run -> status shows 'Success', 'Last run: Just now'
5. Clicked Delete -> automation removed, presets shown again
Server:
- PATCH /workspace/:id/automations/:autoId for updating name/prompt/schedule
- Recurring scheduler: checks every 10s, fires automations whose interval elapsed
- runCount tracking on automations
- startScheduler() called at route init time

App:
- Schedule dropdown in create/edit modal (Manual, 30s, 1m, 5m, 15m, 1h, 6h, 24h)
- Edit button on automation cards opens modal with current values
- Purple recurring badge for scheduled automations
- Run count display
- Auto-refresh every 15s to pick up recurring status changes

Tested via Chrome MCP against Electron dev:
- Created 'Recurring potato writer' with Every 1 minute schedule
- Observed Runs counter increment to 7 (recurring scheduler working)
- Edited schedule from 1m to 5m via Edit modal
- Schedule badge updated correctly
@vercel vercel Bot requested a deployment to Preview – openwork-den April 29, 2026 15:01 Abandoned
The app now shows a generic 'Workflows' surface with no mention of
Inngest. The server-side implementation can be swapped in the future
without any app changes. Removed:
- 'Inngest' badge from Workflows header
- 'Powered by Inngest' from modal footer -> 'OpenWork Workflows'
- 'Inngest-powered' from description text
- 'Connect to use Inngest-powered workflows' -> generic wording
Covers: create, trigger + OpenCode execution, edit schedule,
recurring execution, delete, create from preset, server-disconnect
graceful degradation. Follows the same format as react-session-flows.md
with Chrome DevTools MCP tool recipes.
The Electron app uses server-v1. Server-v2 changes were premature —
revert all server-v2 modifications to their dev branch state.
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.

1 participant