The schemas that more than one part of CodeWork speaks: the ids, projects, spaces, locations, events and sandbox instances the harness persists and plugins read, the CodeWork RPC server's contract, and Relay's HTTP API, signed machine requests, pairing, the server's WebSocket door and the machine status the desktop app reads. The plugin SDK (packages/plugin), the harness, the CLI and RPC server (packages/codework), the app packages and Relay (infra/relay) all import it.
It is published to npm, with effect as a peer dependency and uuidv7 for minting ids. Each module is its own subpath, so a consumer loads only what it imports:
import { Door } from "@codeworksh/schema/door";
import { Relay } from "@codeworksh/schema/relay";- Only
effect. This code runs in Node and in the desktop renderer, a browser, so it uses Effect and WebCrypto and nothing from Node or@codeworksh/aikit. A Node import here would break the renderer. - Shapes, not services. It declares what crosses the wire and the small helpers both ends need to agree on it (signing, token checks), plus only the middleware and context tags Effect's
HttpApiandRpcGrouprequire on the contract itself (Relay.Person,Relay.PersonAuth,HostPrincipal.Current,HostPrincipal.Door). Who stores what, and how a call is handled, stays in the consumer. - One home per schema. A shape two packages share is declared here once and imported, never redeclared: a brand or class declared twice is two types, and persisted rows and wire payloads depend on its tags and identifiers.
- Fields are wire format. Machines, desktop apps and Relay update at different times, so an older peer may be on the other end. Add a new field as optional rather than renaming or removing one.
Every module but shell also exports itself as a namespace, the way the example above imports Door and Relay.
src/relay.tsdeclares Relay's HTTP API (Relay.Api) and its errors, and re-exportssrc/records.ts: its records and the signed request claims, kept apart somachinedoes not load the API.src/jws.tssigns and verifies compact Ed25519 JWS with WebCrypto, so a machine signs and Relay verifies with the same code.src/pairing.tsis how another computer pairs with a CodeWork server over HTTP.src/door.tscarries the WebSocket token as a subprotocol and checks it at the listener.src/forwarded.tsdecides whether a request reached the listener over TLS through a trusted proxy.src/machine.tsis a server's machine status and connect events as its clients see them over RPC.src/shell.tsquotes a path as one shell word.src/ids.tsmints and brands session, thread and message ids.src/project.ts,src/repo.ts,src/space.tsandsrc/location.tsdescribe where work happens.src/event.tsis the event core: ids, payloads anddefine.src/sandbox/instance.ts,driver.tsanderrors.tsare a sandbox's identity, state and lifecycle errors.src/host.tsis the CodeWork RPC server's contract (Host.Api), which the CLI, the server and the desktop app server import, re-exportingsrc/host/records.ts(the wire data records, kept apart so UI code does not load theRpcGroupor server errors), with event envelopes, message parts and the door's middleware insrc/host.src/session.ts,thread.ts,settings.ts,model.ts,mcp.ts,daemon.tsandusage.tshold the harness's errors and values that cross that contract; the harness re-exports them.src/common.tsholds the small schema helpers the rest build on (AbsolutePath,optional,withStatics).
pnpm typecheck # tsc --noEmit
pnpm build # vp pack, into dist/pack