Daemon contract & TS types
Esta página aún no está disponible en tu idioma.
crates/chronos-contract is the wire contract between chronosd and its clients. It has two halves: ipc — plain serializable message DTOs, the source of the generated TypeScript types — and transport — a framed, cross-platform local transport (Unix socket on macOS, named pipe on Windows). Like chronos-core, the crate depends on nothing else in the workspace, so the CLI can depend on the contract without pulling in the daemon’s internals.
Rust → TS flow
Section titled “Rust → TS flow”The TypeScript package packages/contract-ts (@aluxion/chronos-contract) is generated from the Rust source of truth by typeshare, from the #[typeshare]-annotated DTOs:
cargo install typeshare-cli # one-time, if not already on PATHjust gen-contract # writes packages/contract-ts/src/generated.tssrc/generated.ts is committed so consumers don’t need the Rust toolchain — but it is generated output: never edit it by hand. The dashboard and any future cloud client consume these types instead of hand-rolling DTOs, so panel and daemon never drift.
Typecheck the package with:
pnpm install && pnpm typecheckWhat the contract covers
Section titled “What the contract covers”- All
*Viewdata types —WorkspaceView,SessionView,InsightsView,AgentEventView,FileEntryView,FileChangeView,CheckResultView,McpView,ContextView,MemoryView,ScriptOutcomeView, and the rest. - The
Responseframe — an adjacently tagged ({ kind, data }) discriminated union, matching exactly what the daemon emits and the dashboard switches on.
Why Request is not generated
Section titled “Why Request is not generated”Request is intentionally not exported to TS: it is internally tagged ({ op, ...fields }, the shape the web client posts to /rpc), and typeshare only models adjacently tagged enums. Forcing it through typeshare would change the wire format and break the existing client for no gain.
Rules for changing the contract
Section titled “Rules for changing the contract”Whenever you change types in chronos-contract:
- Edit the Rust DTOs in
crates/chronos-contract. - Run
just gen-contractto regeneratepackages/contract-ts/src/generated.ts. - Update the dashboard and API consumers in the same PR.
The regenerated types and every consumer update land together — a PR that changes the contract without regenerating, or regenerates without updating consumers, is incomplete.