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

@cogstream/react

v0.1.0

Published

Plain React renderer and lifecycle bridge for CogStream dynamic surfaces.

Downloads

13

Readme

@cogstream/react

Plain React renderer and lifecycle bridge for CogStream dynamic surfaces.

@cogstream/react renders @cogstream/surfaces payloads in React applications without requiring CopilotKit, AG-UI, Vercel AI SDK, A2UI, or any other agent UI framework.

It is a bridge, not a replacement for React and not a design system.

Why this package exists

Generated UI still creates user journeys.

CogStream needs a way to render dynamic surfaces in ordinary React apps, attach CogStream metadata, observe user interaction inside those surfaces, and report whether the surface helped.

@cogstream/react provides that default React path.

Relationship to other packages

@cogstream/surfaces
  framework-neutral context, control, metadata, payload, and outcome contracts

@cogstream/react
  React renderer and lifecycle wrapper for those contracts

@cogstream/ui
  optional styled/headless components that can be registered with @cogstream/react

What it does

  • renders SurfacePayload objects
  • registers custom surface components
  • wraps surfaces with CogStream lifecycle metadata
  • emits surface interaction events
  • records SurfaceOutcome
  • applies SurfaceGenerationControl through surface policy validation
  • works without AG-UI or CopilotKit

Install

npm install @cogstream/react @cogstream/surfaces

Basic usage

import {
  CogStreamSurfaceProvider,
  SurfaceRenderer,
} from '@cogstream/react';

export function JourneyAssistSurface({ context, control, payload }) {
  return (
    <CogStreamSurfaceProvider
      context={context}
      control={control}
      onInteraction={(event) => console.log('surface event', event)}
      onOutcome={(outcome) => console.log('surface outcome', outcome)}
    >
      <SurfaceRenderer payload={payload} />
    </CogStreamSurfaceProvider>
  );
}

Register a custom surface component

import {
  registerSurfaceComponent,
  SurfaceRenderer,
  type SurfaceComponentProps,
} from '@cogstream/react';

function IdentityRepairCard({ payload, complete, dismiss }: SurfaceComponentProps) {
  return (
    <section>
      <h3>{String(payload.content.title ?? 'Fix identity upload')}</h3>
      <button onClick={() => complete({ result: 'completed', delta_progress: 1 })}>
        Done
      </button>
      <button onClick={() => dismiss({ reason: 'not_relevant' })}>
        Dismiss
      </button>
    </section>
  );
}

registerSurfaceComponent('identity_repair_card', IdentityRepairCard);

<SurfaceRenderer
  componentName="identity_repair_card"
  payload={{
    mode: 'static',
    surface_type: 'card',
    content: { title: 'Fix identity upload' },
  }}
/>;

Default surface types

The package includes minimal default renderers for:

  • cue
  • card
  • checklist
  • form
  • comparison
  • confirmation
  • handoff_panel
  • inline_guide
  • workspace
  • custom

These are intentionally plain. Product-quality styling should come from the host app or from registered components, possibly using @cogstream/ui.

Provider API

<CogStreamSurfaceProvider
  context={surfaceGenerationContext}
  control={surfaceGenerationControl}
  generatedSurface={generatedSurfaceContext}
  onInteraction={handleSurfaceInteraction}
  onOutcome={handleSurfaceOutcome}
>
  {children}
</CogStreamSurfaceProvider>

Core exports

export {
  CogStreamSurfaceProvider,
  SurfaceRenderer,
  SurfaceSlot,
  CogStreamSurfaceFrame,
  registerSurfaceComponent,
  getSurfaceComponent,
  hasSurfaceComponent,
  clearSurfaceComponents,
  createSurfaceRegistry,
  registerDefaultSurfaceComponents,
  useSurfaceContext,
  useSurfaceControl,
  useGeneratedSurface,
  useSurfaceEvents,
  useSurfaceOutcome,
};

Design principles

1. React renders. CogStream observes.

The package renders a surface and reports lifecycle events. It does not decide the full intervention strategy.

2. @cogstream/surfaces owns the contract.

The React package consumes surface contracts; it does not define them.

3. Components are replaceable.

The host app can register custom components for any surface type.

4. Outcomes matter.

A surface is not successful because it rendered. It is successful only if it helped the journey.