Skip to content

Latest commit

 

History

History
 
 

schema

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

README.md

@codeworksh/schema

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";

Boundaries

  • 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 HttpApi and RpcGroup require 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.

Code Map

Every module but shell also exports itself as a namespace, the way the example above imports Door and Relay.

Working Locally

pnpm typecheck   # tsc --noEmit
pnpm build       # vp pack, into dist/pack

Learn More

  • Relay: the API, the signed machine requests and the keys behind them.
  • Server: the door, pairing and trusted proxies.