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

catui-protocol

v0.1.1

Published

Stable protocol contracts for Catui extensions (tools, themes, hooks, commands, permissions, lifecycle)

Downloads

441

Readme

catui-protocol

Stable protocol contracts for Catui extensions — the single, versioned surface a third-party extension (or the bundled mem-core / soul-core packages) depends on, instead of reaching into the host package catui.

Installation

npm install catui-protocol

Quick Start

import type { ExtensionAPI, ExtensionContext, ToolContract } from 'catui-protocol';

// Define a tool using the stable protocol contract
const myTool: ToolContract = {
  name: 'my-tool',
  description: 'A custom tool',
  parameters: /* TypeBox schema */,
  async execute(toolCallId, params, signal, onUpdate, ctx) {
    return {
      content: [{ type: 'text', text: 'Result' }],
    };
  },
};

// Export your extension factory
export default function myExtension(api: ExtensionAPI) {
  api.registerTool(myTool);
  
  api.on('session_start', async (event, ctx) => {
    ctx.ui.notify('Extension loaded!');
  });
}

Protocol Modules

| Module | Import | Contract | Status | |--------|--------|----------|--------| | tools | catui-protocol | Tool runtime/permission seam + ToolContract, ToolResult | ✅ | | lifecycle | catui-protocol | ExtensionAPI, ExtensionContext, ExtensionFactory, SessionManagerContract | ✅ | | commands | catui-protocol | Slash-command registration + argument-completion | ✅ | | hooks | catui-protocol | Lifecycle hook event-name vocabulary | ✅ | | flags | catui-protocol | Extension-declared CLI/config flag contracts | ✅ |

Key Types

ExtensionAPI

The registration surface a host passes to an extension factory:

interface ExtensionAPI {
  on(event: HookEventName, handler: HookHandler<ExtensionContext>): void;
  registerCommand(name: string, command: ExtensionCommand<ExtensionContext>): void;
  registerFlag(name: string, options: ExtensionFlagOptions): void;
  getFlag(name: string): ExtensionFlagValue | undefined;
  registerTool<TParams extends TSchema, TDetails>(tool: ToolContract<TParams, TDetails>): void;
}

ExtensionContext

Runtime context handed to extension hooks, commands, and tools:

interface ExtensionContext {
  cwd: string;
  hasUI: boolean;
  sessionManager: SessionManagerContract;
  ui: ExtensionUi;
}

ToolContract

The stable tool contract for registering model-facing tools:

interface ToolContract<TParams extends TSchema, TDetails> {
  name: string;
  label?: string;
  description: string;
  parameters: TParams;
  execute(toolCallId: string, params: Static<TParams>, signal?: AbortSignal, 
          onUpdate?: ToolUpdateCallback<TDetails>, ctx?: ExtensionContext): Promise<ToolResult<TDetails>>;
}

HookEventName

Available lifecycle hook events:

type HookEventName = 
  | 'session_start' | 'session_ready' | 'session_shutdown'
  | 'before_agent_start' | 'agent_start' | 'agent_end'
  | 'turn_start' | 'turn_end'
  | 'tool_call' | 'tool_result'
  | 'context' | 'input'
  // ... and more

Design Principles

  • Increment, don't break: Protocol additions never force a host major bump
  • Minimal surface: Only contracts that cross publish boundaries belong here
  • Host-agnostic: Extensions compiled against protocol work with any compliant host

Relationship to Host Package

| What | Where | |------|-------| | Protocol contracts (this package) | catui-protocol | | Host embedding SDK | catui | | Advanced internals | catui/{tools,runtime,session,...} | | Host-only rich types | catui (not public API) |

Explicitly NOT Here

The following are reserved for future evolution and do not belong in the protocol:

  • agent-profile — agent personality configuration
  • host-adapter — ACP re-export
  • tool-runtime — MCP re-export
  • a2a-bridge — agent-to-agent communication
  • Memory/soul providers — domain-specific extensions

See .dev-docs/architecture-review/evolution/PARP.md for the evolution roadmap.

License

GPL-3.0