A local-first multi-agent app development platform, built on PenguinHarness
Workflows: an Agent's own page and server code, hot-reloaded and versioned
- Date: 2026-08-30
- Type: feature
- Scope:
core,server,web,cli,skills - PR: #718
An Agent can now keep workflows in its own directory: workflows/<id>/ holds a plugin package — package.json#penguin.modules manifests, an index.ts whose default export pairs them with code, its pages under ui/ — that the server boots as a module tree of its own. It is the same mechanism the server is built from and that plugins use, and everything is checked before any of the workflow's code runs: a workflow that does not type-check, that was written against an interface version this server no longer fits, or whose manifests do not hold together fails to load with the problem named, and the previous version keeps serving.
Contract
The root module Workflow requires WorkflowHost (published by the server as module Host: the SDK's verbs scoped to the Project — listAgents(), createSession({ agentId? }) for this Agent or another of the same Project, run(sessionId, [{ text: "…" }]) for a turn in a new or existing Session, queued as a follow-up when it is busy — plus sessionStatus, getState / setState over the workflow's state.json, log) and provides WorkflowMain — a handler handle({ method, path, query, headers, body, bytes? }) the server mounts at /api/projects/:p/agents/:a/workflows/:id/api/*. JSON is the default in both directions; a request body of any other content type reaches the handler as bytes (50 MB at most; the app's cookie and authorization headers are withheld), and a response that names a content-type in headers is sent as written — body as a string, bytes as binary, stream (an async iterable of strings or bytes) chunk by chunk as it is produced, so server-sent events and a relayed streaming answer are not held back until the end; location with a 3xx for a redirect (set-cookie is dropped). So a handler can take an upload, answer a page or a download, or relay a program it runs on its own machine, which a page cannot reach when the browser is elsewhere. The workflow's ui/ is served at …/workflows/:id/ui/*. Nothing is added to any Agent's system prompt: the penguin-sdk skill carries the layout and the contract, loaded when an Agent is asked for a workflow.
TypeScript, checked by the server
A workflow is TypeScript — index.ts; a folder with index.js or index.mjs is refused. The server builds one compiler program from the entry under options it fixes itself (strict; a tsconfig.json in the folder is not consulted), and also assigns the default export to WorkflowPackage, so the shape is checked whether or not the author wrote satisfies WorkflowPackage. Any diagnostic fails the load, reported as file, line, column and reason; a clean program is emitted into <workflow>/.build/<revision>/, a dot-directory that is no part of the revision, the recorded versions or what the watcher reacts to, and that is what gets imported. The compiler is the one the plugin interface check made a runtime dependency and ships with a hot push (#808); an installation without it loads no workflow and says so.
Types from the harness, compared across generations
A workflow installs nothing: one machine can run several harnesses — a release, a checkout, a pushed platform with interfaces of its own — and none of them is a version on npm. The first load writes <workflow>/.harness/, rendered from THIS platform's interface table: plugin.d.ts, which @prismshadow/penguin-server/plugin resolves to for that workflow, and ifaces.json, the slice of the table it was rendered from. It is then left alone — the record of what the workflow was written against — until someone deletes it. That record is what makes the interface comparison real: looking a required interface up in the platform's own table compares a declaration with itself, which can never fail, so each side brings its own — the workflow's .harness/ifaces.json, the platform's table — each is rendered as a self-contained .d.ts, and the TypeScript compiler decides, in both directions: the platform's interface must be assignable to what the workflow requires, and what the workflow provides must be assignable to what the platform asks for. A host method the workflow was written against that has since gone is a load error naming it; an addition on the platform's side breaks nothing. A table that cannot be read is a problem and never a pass; an expression the renderer cannot write as TypeScript is refused by name rather than widened. It is the comparison a plugin package gets at load (#808), with one difference: a workflow's table is written by the harness and is complete, so an interface it holds no copy of is a load error rather than a line in the log.
Tabs are contributions
A workflow's manifest contributes its tabs to WebModule.sessionTabs — the slot a plugin contributes to, written the same way, which the host publishes into the workflow's tree and scopes to the Agent: key, title / titleZh, and a renderer whose iframe.src is a file under ui/. Several entries are several tabs; none is a server-only workflow; a slot the host has not opened is refused by name. The list returns them as tabs, each page's URL resolved, and keeps the serving instance's tabs while a broken edit is reported. The slot's shape gains title / titleZh and its renderer drops the unused namespace. ui/ no longer has a default document: a tab names its page.
Reload and rollback
The server watches the Agent's workflows/ folder and reloads a workflow when its files change (also POST …/:id/reload); the emitted code lives under the folder's content hash, so an edited module is a new import URL and never served from the module cache. Loads of one workflow run one at a time, since each now takes a compiler run. Every load writes its result to <workflow>/.build/status.json (ok, revision, checkedAt, error, tabs, hints), so the Agent that wrote the workflow — which has its files and no session with the HTTP API — reads whether its edit loaded, and the compiler's message if it did not; hints (also on the workflow in the API) names what loaded but is probably not what was meant, with the edit that settles it — today, pages under ui/ that no tab shows, with the WebModule.sessionTabs entry to add. The harness also writes .harness/README.md, its own contract in brief (files, the manifest, tabs, the status file), because an Agent's installed SDK skill is a copy a push does not refresh; and an Agent's first workflows/ folder is noticed when it appears, not only when somebody lists the workflows again. Every successful load is recorded under workflows-history/<id>/<revision>/ (twenty kept, GET …/:id/history), and POST …/:id/rollback { revision } restores that version's files — state.json untouched — and reloads. DELETE …/:id removes the workflow together with its versions. Users of the Project hear workflow_updated and workflow_removed on their event stream, so a tab appears, refreshes or disappears without a reload.
Web App
Each contributed tab sits beside Chat at the top of the chat page, titled in the user's language; the tab shows its page in an iframe (reloaded when the UI's revision changes, the chat staying mounted underneath), with the workflow's version and revision, its load error when the current files do not boot, a Reload button, a History fold with a Restore button per recorded version, and a two-click Remove.
Filling the app
A page can be the whole app: /app/:projectId/:agentId/:workflowId[/:tabKey] shows one workflow page — the tab that key names, or the workflow's first — with no sidebar, chat or tab strip. The tab's Fill the app button navigates there, the page itself can ask with parent.postMessage({ type: "penguin:fill-app" }, "*"), and penguin web --app <project>/<agent>/<workflow>[/<tab>] opens the browser straight onto it (Invalid --app before anything starts when the spec is not three or four segments). The route has no chrome to leave by on purpose; the command palette is the way out — it now answers Ctrl+Shift+P as well as Ctrl+P (⌘ on macOS), so a page that takes one chord for itself cannot trap the user — and on that route carries Exit full page (back to chat), which remembers the Project and Agent and lands on their chat.
Theme
A workflow page is its own document, so the app's stylesheet reaches none of it. The frame now stamps light / dark on the page's root, copies the app's resolved tokens onto it — the gray scale, the accent pair, the font stack, the root font size — and injects /workflow-ui.css first in its head: a base stylesheet that styles plain HTML (headings, lists, forms, tables, code) to match the app and exposes --wf-bg, --wf-fg, --wf-muted, --wf-border, --wf-surface, --wf-accent, --wf-accent-fg plus the classes wf-primary, wf-card, wf-rows, wf-row, wf-muted. The page's own rules still win, and the palette keeps one definition: the app copies what it already resolved instead of the stylesheet restating it. Switching theme or accent re-themes an open page without reloading it. The skill asks for markup written against those variables, so a workflow an Agent writes matches the user's theme in both directions.
The penguin-sdk skill documents the layout and the contract. The new-chat page's Build and optimize agents examples gain Build a custom workflow UI: mission control — a workflow that dispatches one task to several of the Project's Agents in parallel and shows every Session's live status, with a second tab of statistics and a fill-the-app view — in place of the Claude Code docs RAG example.
Interface checks parse once per process
Every module-tree boot — a workflow's, a plugin's, the platform's own — checks each wire and contribution against its interface, and each leaf comparison and slot schema was parsed by arktype afresh. arktype files every parse in a registry that lives as long as the process and never shrinks, so each boot added thousands of entries: a long-running server grew with every hot push, plugin load and workflow reload, and a test worker booting hundreds of apps stalled outright. A leaf comparison is now decided once per process and remembered, and a slot's schema is parsed once per definition; both come from interface tables, so there are only so many.