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

@cef-ai/agent-sdk

v1.4.0

Published

Author agents for the Cere Execution Fabric: a small surface of decorators and types that maps directly to the runtime contract.

Readme

@cef-ai/agent-sdk

Author agents for the Cere Execution Fabric: a small surface of decorators and types that maps directly to the runtime contract.

Install

pnpm add @cef-ai/agent-sdk

For tests, also install the harness:

pnpm add -D @cef-ai/testing

Quickstart

An agent is a default-exported class with decorated methods. @OnEvent binds an event type to a handler; @OnStart and @OnClose are lifecycle hooks. Context is the single object the runtime threads through every call.

import {
  OnClose,
  OnEvent,
  OnStart,
  type Context,
  type Event,
  type OnCloseReason,
} from "@cef-ai/agent-sdk";

interface UserMessage {
  text: string;
}

export default class Echo {
  @OnStart
  async onStart() {
    // Logging + HTTP are plain Web globals, not ctx members:
    console.info("started");
  }

  @OnEvent("user_message")
  async onMessage(event: Event<UserMessage>, ctx: Context) {
    await ctx
      .cubby("history")
      .exec("INSERT INTO messages(text, ts) VALUES (?, ?)", [
        event.payload.text,
        event.ts,
      ]);
    await ctx.publish("ack", { for: event.id });
  }

  @OnClose
  async onClose(_ctx: Context, reason: OnCloseReason) {
    console.info("closing", { reason });
  }
}

ctx carries only the CEF-specific platform calls. For plain capabilities, use the sandbox globals directly: console.* for logging (the runtime captures it) and fetch for HTTP.

Pair the class with a cef.config.ts:

import { defineAgent } from "@cef-ai/agent-sdk/config";

export default defineAgent({
  id: "echo",
  version: "1.0.0",
  entry: "./agent.ts",
  cubbies: [{ alias: "history", migrations: "./migrations/history" }],
});

API summary

| Kind | Symbol | Notes | | --- | --- | --- | | Decorator | @OnEvent(type) | Bind an event type (string literal) to a handler. | | Decorator | @OnStart | Mark the start lifecycle hook. | | Decorator | @OnClose | Mark the close lifecycle hook. | | Type | Context | CEF-specific platform calls only — cubby, models, publish, settings, close. (Log/HTTP are the globals console / fetch.) | | Type | Event<P> | { id, type, ts, from, payload: P }. | | Type | CubbyHandle | query(sql, params) / exec(sql, params) over per-alias storage. | | Type | ModelHandle<I,O> | infer(input) / stream(input) per declared model alias. | | Type | OnCloseReason | "revoked" \| "idle_timeout" \| "closed_by_agent" \| "failed". | | Interface | KnownEventTypes | Declaration-merged event-type map populated by typegen. | | Function | defineAgent(config) | Identity helper that preserves literal types of AgentConfig. | | Type | AgentConfig | Top-level config: id, version, entry, cubbies, models, settings, fetch, publishes, lifecycle. |

How it runs (runtime model)

Per Agent Runtime ADR-001, the Cere Network runtime is a CEF-agnostic bundle executor: it exposes only Web-platform globals (fetch, console, URL, crypto, TextEncoder, timers, …) plus one opaque globalThis.context object, and dispatches invocations as globalThis.__handlers[name](event, context).

ctx is CEF-specific add-ons only — SDK code compiled into your bundle by cef build, not a runtime-provided binding:

  • ctx.publish / ctx.cubby / ctx.models[…].infer / ctx.closefetch calls to the endpoints the orchestrator places in globalThis.context (context.endpoints.*, with context.auth headers).
  • ctx.settingscontext.settings.

Plain Web-platform capabilities are not mirrored on ctx — use the sandbox globals directly: console.* for logging (captured out-of-band by the runtime) and fetch for HTTP.

You never write the shim code — you author the decorated class, and the shims (the @cef-ai/agent-sdk/runtime subpath) are bundled in automatically.

Inference usage is reported automatically. Each ctx.models[…].infer call captures the gateway's usage and the SDK folds a _modelCalls array into your handler's return value; the orchestrator reads it to record per-model token/GPU usage (ADR-004). _modelCalls is a reserved result key — don't set it yourself.

Subpath exports

| Specifier | Purpose | | --- | --- | | @cef-ai/agent-sdk | Decorators, Context, Event, KnownEventTypes, ModelHandle, CubbyHandle, OnCloseReason. | | @cef-ai/agent-sdk/config | defineAgent and the AgentConfig shape — used in cef.config.ts. | | @cef-ai/agent-sdk/runtime | Build-internal: the ctx shims + registerHandlers that cef build compiles into the bundle. Authors never import this directly. |

For testing, use @cef-ai/testing directly — import { testAgent } from "@cef-ai/testing".

Companion packages

  • @cef-ai/clicef build (esbuild + manifest), cef typegen (populates KnownEventTypes), cef inspect.
  • @cef-ai/testing — simulator harness for unit and integration tests.
  • @cef-ai/eslint-plugin — editor-time lints mirroring the build-time checks.

References

  • Agent SDK spec: ../../../company-memory-bank/specs/platform/03-components/agent-sdk.md
  • Runtime integration contract: ../../../company-memory-bank/specs/platform/03-components/sdk-runtime-integration-contract.md
  • Implementation plan: ../../../company-memory-bank/plans/2026-04-27-sdk-implementation-plan.md

The ../company-memory-bank/... paths are local references to an internal sibling repo and are not browsable from a fresh clone.