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

@owllayer/react

v0.4.0

Published

OwlLayer React SDK - Hooks & Components pour UI Agentique

Readme

@owllayer/react

npm version npm downloads License: MIT TypeScript strict

React SDK for OwlLayer AI. Build Agentic UI applications with React hooks, components, real-time voice mode, tool registration, and Human-in-the-Loop (HITL) security.


Features

  • OwlLayerProvider: Context provider managing the WebSocket connection, session lifecycle, and agent state.
  • useAgentTool: Register reactive frontend tools directly within React components (auto-registered on mount, cleaned up on unmount).
  • useVoiceMode: Integrated microphone capture, PCM streaming, voice activity detection, and interrupt handling.
  • OwlLayerWidget: Turnkey floating or embedded AI chat/voice assistant widget.
  • Human-in-the-Loop (HITL): Built-in ApprovalModal and ApprovalBanner components for sensitive tool execution.
  • Specialized Hooks: useNavigationTool, useViewStateTool, useAgentContext, useOwlLayerEvent.
  • LiveKit WebRTC Integration: useOwlLayerLiveKitRoom hook for WebRTC voice rooms.

Installation

# pnpm
pnpm add @owllayer/react @owllayer/core react react-dom

# npm
npm install @owllayer/react @owllayer/core react react-dom

# yarn
yarn add @owllayer/react @owllayer/core react react-dom

Quick Start

1. Setup the Provider

Wrap your application in OwlLayerProvider:

import React from 'react';
import ReactDOM from 'react-dom/client';
import { OwlLayerProvider, OwlLayerWidget } from '@owllayer/react';
import App from './App';

ReactDOM.createRoot(document.getElementById('root')!).render(
  <React.StrictMode>
    <OwlLayerProvider
      endpoint="ws://localhost:3001/owllayer"
      apiKey="pk_dev_xxxx"
    >
      <App />
      <OwlLayerWidget agentName="Léa" agentTitle="Shopping Assistant" />
    </OwlLayerProvider>
  </React.StrictMode>
);

2. Declare Client Tools (useAgentTool)

Tools declared with useAgentTool are available to the AI only while the component is mounted:

import React, { useState } from 'react';
import { useAgentTool } from '@owllayer/react';

export function ProductDetails({ product }) {
  const [highlighted, setHighlighted] = useState(false);

  useAgentTool({
    name: 'highlight_product',
    description: 'Highlight the current product on screen',
    parameters: {
      type: 'object',
      properties: {
        color: { type: 'string', description: 'Highlight outline color' },
      },
    },
    risk: 'none',
    handler: async ({ color }) => {
      setHighlighted(true);
      return { success: true, highlighted: true };
    },
  });

  return (
    <div className={`product-card ${highlighted ? 'border-primary' : ''}`}>
      <h2>{product.name}</h2>
      <p>{product.price} €</p>
    </div>
  );
}

3. Voice Mode (useVoiceMode)

import React from 'react';
import { useVoiceMode, useAgent } from '@owllayer/react';

export function VoiceControls() {
  const { voiceState, isCapturing, isSpeaking, startVoice, stopVoice, mute } = useVoiceMode();
  const { agentState } = useAgent();

  return (
    <div>
      <p>Voice State: {voiceState}</p>
      <button onClick={isCapturing ? stopVoice : startVoice}>
        {isCapturing ? 'Stop Talking' : 'Start Voice'}
      </button>
    </div>
  );
}

4. Human-in-the-Loop (HITL) Confirmations

When a tool with risk: 'high' or risk: 'critical' is invoked, OwlLayer automatically pauses execution and requests confirmation:

import React from 'react';
import { useApproval, ApprovalModal } from '@owllayer/react';

export function SecurityOverlay() {
  const { pendingApproval, approve, deny } = useApproval();

  if (!pendingApproval) return null;

  return (
    <ApprovalModal
      request={pendingApproval}
      onApprove={() => approve(pendingApproval.id)}
      onDeny={() => deny(pendingApproval.id)}
    />
  );
}

Core Hooks & Components

Hooks

| Hook | Purpose | |---|---| | useAgent() | Access global agent state (idle, thinking, speaking, disconnected), session ID, and send messages. | | useAgentTool(definition) | Register a client-side tool with the server. | | useVoiceMode() | Full microphone capture and audio playback control. | | useAgentContext(key, data) | Sync local component state into the AI's shadow context. | | useNavigationTool() | Expose router navigation actions to the AI. | | useApproval() | Manage pending HITL approval requests. | | useOwlLayerLiveKitRoom() | Connect to a LiveKit WebRTC room with token minting. |

Components

| Component | Description | |---|---| | <OwlLayerWidget /> | Ready-to-use floating chat and voice assistant widget. | | <ApprovalModal /> | Modal overlay for confirming high-risk actions. | | <ApprovalBanner /> | Non-blocking top banner for HITL confirmation. | | <AgentIndicator /> | Visual pill showing agent connection & speaking status. | | <ShadowContainer /> | Isolated CSS container rendering inside Shadow DOM. |


License

MIT © OwlLayer