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

@kestrel-agents/protocol

v0.6.0

Published

Canonical public protocol contracts for Kestrel runner services

Downloads

326

Readme

@kestrel-agents/protocol

Canonical wire contracts shared by Kestrel runner services and public clients.

The protocol package owns versioned commands, events, health responses, streaming correlation, terminal-result parsing, tool metadata, and project actions. Local Core and hosted runners serialize through these contracts; clients parse them rather than trusting unvalidated JSON.

Most application code should use @kestrel-agents/sdk. Depend on the protocol directly when implementing a compatible runner, transport, gateway, or contract-aware diagnostic tool.

Install

pnpm add @kestrel-agents/[email protected]

Use the same release line as the runtime and SDK. Check 0.6 Beta release status before pinning a production dependency.

Contract Families

| Contract | Responsibility | | --- | --- | | Execution | Complete command/event registry and aggregate protocol version | | Commands | Parsed discriminated envelopes for run, job, operator, project, session, and workspace actions | | Events | Parsed lifecycle, progress, reasoning, tool, log, console, interaction, and terminal events | | Health | Runner identity, service version, exact contract versions, and advertised capabilities | | Tooling | Model-visible and presentation-aware tool descriptors | | Project actions | Validated project and task mutation requests |

Check Runner Compatibility

import {
  EXECUTION_PROTOCOL_VERSION,
  RUNNER_COMMAND_CONTRACT_VERSION,
  RUNNER_EVENT_CONTRACT_VERSION,
  parseRunnerHealthV1,
} from "@kestrel-agents/protocol";

const response = await fetch(`${runnerUrl}/health`, {
  headers: { authorization: `Bearer ${runnerToken}` },
});

const health = parseRunnerHealthV1(await response.json());

if (
  health.contracts.execution !== EXECUTION_PROTOCOL_VERSION ||
  health.contracts.command !== RUNNER_COMMAND_CONTRACT_VERSION ||
  health.contracts.events !== RUNNER_EVENT_CONTRACT_VERSION
) {
  throw new Error("Kestrel runner contract mismatch");
}

parseRunnerHealthV1() rejects an unversioned, malformed, or incompatible response. The advertised capabilities array lets clients hide or disable controls the runner cannot honor.

Parse Unknown Wire Data

import {
  parseRunnerCommandV2,
  parseRunnerEventV2,
} from "@kestrel-agents/protocol";

const command = parseRunnerCommandV2(untrustedCommandJson);
const event = parseRunnerEventV2(untrustedEventJson);

Never cast untrusted HTTP, stream, queue, or persisted JSON directly to a protocol type. Parse it at the boundary before routing or mutation.

Execution Protocol v3

The 0.6 line uses the aggregate execution-protocol-v3 contract. It includes:

  • complete command and event registries
  • discriminated wire envelopes and payload parsers
  • streaming-command classification
  • command and event correlation
  • explicit runner capabilities
  • normalized run and job terminal results
  • application-owned system/developer instructions
  • distinct provider reasoning and committed agent-progress channels

Terminal results

Terminal run results carry assistantText independently from finalizedPayload. The protocol trims non-empty assistant text at the wire boundary and preserves structured payloads, including explicit null, without inference.

Durable jobs carry the same result contract inside job output. A caller must not scrape user-facing text from a structured payload or infer success from the last streamed event.

Streaming

Streams are correlated to the originating command ID and the event set allowed for that command. Job streams may include job lifecycle, runtime diagnostics, provider reasoning, committed agent progress, logs, console output, and tool activity.

Provider reasoning and agent progress are separate channels. Provider reasoning may be live-only; committed agent progress is durable.

Application instructions

Application-owned system and developer instructions use the explicit turn.systemInstructions field. Conversation history remains user, assistant, and tagged runtime waiting-prompt entries.

Errors

Invalid wire data throws RunnerProtocolContractError with a machine-readable code. Treat these failures as boundary or compatibility errors and keep them visible; do not silently coerce the payload into an older shape.

Development

pnpm run protocol:test
pnpm run protocol:build
pnpm run protocol:release-check

Related Docs