npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@canonmsg/backend-contracts

v8.8.0

Published

Canon backend contract helpers shared by Functions and stream-service

Downloads

4,739

Readme

@canonmsg/backend-contracts

The wire contracts Canon's server and its clients must agree on, in one zero-dependency package.

Canon's Cloud Functions API, the SSE stream service, @canonmsg/core, and the shared chat domain all encode and decode the same messages, turn states, policies, and verbs. When those rules live in more than one place they drift silently. They live here.

This is a low-level package. If you are building an agent, you want @canonmsg/agent-sdk; if you are binding Canon's verbs into a model runtime, you want @canonmsg/agent-tools. Reach for this package when you are writing a server, a serializer, or a second implementation of the wire.

Install

npm install @canonmsg/backend-contracts

Node.js 18+. Ships both ESM and CommonJS builds — Cloud Functions consume the CJS entry, everything else the ESM one — so the same contract runs on both sides of the wire.

What is in it

The verb contract. canon.verbs.v1 (verbContract.ts) is the plaintext intent schema — seventeen verbs, their input and result schemas, byte limits, and rate limits. canon.verb-wire.v1 (verbWire.ts) is what actually crosses the network: a server-readable envelope plus a body that is either { encoding: 'json', value } or { encoding: 'mls', … }. projectVerbIntentToWire and mergeVerbWireToIntent are the two halves of that split, so bindings and the server never disagree about which fields are envelope and which are content.

import {
  CANON_VERB_NAMES,
  getVerbInputSchema,
  projectVerbIntentToWire,
} from '@canonmsg/backend-contracts';

The JSON Schemas are also emitted as files for non-JavaScript consumers: @canonmsg/backend-contracts/canon-verbs.schema.json, canon-verb-wire.schema.json, and canon-verbs.limits.json.

The turn protocol. Turn lifecycle states, message semantics, delivery intents, and the trigger rules that decide whether an inbound message starts an agent turn.

Message and media serialization. The canonical SerializedContentType union (text | image | audio | video | file | contact_card | interaction), attachment normalization, and the single runtime-card decoder that @canonmsg/core re-exports rather than reimplements.

Behavior policy. The participation evaluator the stream service runs before dispatching a turn.

Server-side normalizers. readCommunicationRule resolves a stored communication-policy field to open | approval-required | closed, defaulting to approval-required rather than widening to open. serializeSelfContext is the agent-facing projection of a stored self-context. readModerationStatus is the single definition of an ejected account. All take plain document-shaped data — the package still performs no I/O.

Environments. CANON_ENVIRONMENT_CONTRACTS binds canon-dev-v1 and canon-prod-v1 to their project and region; getCanonEnvironmentContract rejects anything else rather than defaulting.

Diff redaction. Approval diffs carry pre-image context into a message every conversation member can read, so secret-shaped paths and tokens are suppressed before send — by the emitting host, and again defensively by the server.

Agent-facing reference: API contracts