# APIs And Contracts

Matrix is primarily a local application, not a hosted SaaS API. Its public-facing technical
surfaces are local runtime procedures, local websockets, CLI commands, and typed shared packages.

## Local Runtime API

The main runtime API is the tRPC router in `flow/runtime/src/trpc/app-router.ts`.

Use these docs together:

- [Runtime API reference](runtime-api.md) for the hand-authored procedure summary
- [Generated inventory](generated/inventory.md) for the full current procedure list
- [Generated API reference](generated/api/README.md) for exported contract types

## Shared Contract Packages

- `@zonegaze/flow-contracts`: browser/runtime/platform/plugin contracts such as API inputs,
  plugin metadata, matrix ports, platform bridge types, work-type helpers, and task-board
  mutations.
- `@zonegaze/common`: pure shared plugin-service helpers such as plugin capabilities and shared AI
  model-source metadata.
- `@zonegaze/cline-sdk`: the ZoneGaze-owned boundary around the official upstream Cline SDK.

Package owner docs:

- [`flow/contracts/README.md`](../../flow/contracts/README.md)
- [`flow/common/README.md`](../../flow/common/README.md)
- [`packages/cline-sdk/README.md`](../../packages/cline-sdk/README.md)

## State Streams

The runtime also exposes local websocket streams for:

- workspace and task state fanout
- chat and task message updates
- runtime metadata and project updates
- terminal session output and resize/control messages

See [system design](../architecture/system-design.md) and [generated inventory](generated/inventory.md)
for the message categories and owner files.

## CLI Surface

The current CLI entrypoint is still the Flow-era command:

- [CLI reference](cli.md)

That CLI is one Matrix/Flow runtime surface. It does not redefine the top-level product boundary.
