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

@bodhiapp/ext-types

v0.0.1

Published

Shared types and constants for Bodhi Browser extension communication protocol

Downloads

14

Readme

@bodhiapp/ext-types

Shared types and constants for Bodhi Browser extension communication protocol.

Overview

This package provides the core protocol definitions used by:

  • bodhi-browser-ext: Chrome extension that bridges web pages to local LLM services
  • @bodhiapp/bodhijs: JavaScript library for web applications and external extensions

Installation

npm install @bodhiapp/ext-types

Usage

Constants

import { MESSAGE_TYPES, BODHI_STREAM_PORT } from '@bodhiapp/ext-types';

// Message types for extension communication
console.log(MESSAGE_TYPES.API_REQUEST); // 'BODHI_API_REQUEST'
console.log(MESSAGE_TYPES.STREAM_REQUEST); // 'BODHI_STREAM_REQUEST'

// Port name for streaming connections
const port = chrome.runtime.connectExternal(extensionId, {
  name: BODHI_STREAM_PORT
});

Types

import type {
  ApiRequestMessage,
  ApiResponseMessage,
  ApiRequest,
  ApiResponse
} from '@bodhiapp/ext-types';

// Create a typed API request
const request: ApiRequestMessage = {
  type: MESSAGE_TYPES.API_REQUEST,
  requestId: 'unique-id',
  request: {
    method: 'POST',
    endpoint: '/v1/chat/completions',
    body: {
      model: 'llama3',
      messages: [{ role: 'user', content: 'Hello!' }]
    }
  }
};

// Handle typed response
function handleResponse(response: ApiResponseMessage) {
  const { status, body } = response.response;
  console.log('Status:', status);
  console.log('Body:', body);
}

Communication Patterns

Web Page → Extension (3-layer)

inject.js → content.js → background.js

Uses window.postMessage and chrome.runtime.sendMessage internally.

Extension → Extension (Direct)

External Extension → background.js

Uses chrome.runtime.sendMessageExternal and chrome.runtime.connectExternal.

Message Types

  • API_REQUEST / API_RESPONSE: One-time REST API calls
  • STREAM_REQUEST / STREAM_CHUNK: Streaming responses (SSE)
  • STREAM_ERROR / ERROR: Error responses
  • GET_EXTENSION_ID / SET_EXTENSION_ID: Extension detection
  • TEST_CONNECTION / TEST_CONNECTION_RESPONSE: Backend testing

Streaming

For streaming communication, use:

import { BODHI_STREAM_PORT, MESSAGE_TYPES } from '@bodhiapp/ext-types';

// Create streaming connection
const port = chrome.runtime.connectExternal(extensionId, {
  name: BODHI_STREAM_PORT
});

// Send streaming request
port.postMessage({
  type: MESSAGE_TYPES.STREAM_REQUEST,
  requestId: 'stream-id',
  request: {
    method: 'POST',
    endpoint: '/v1/chat/completions',
    body: { stream: true, ... }
  }
});

// Handle chunks
port.onMessage.addListener((message: StreamChunkMessage) => {
  if (message.type === MESSAGE_TYPES.STREAM_CHUNK) {
    const chunk = message.response.body;
    if (chunk.done) {
      port.disconnect();
    } else {
      // Process chunk
    }
  }
});

Server State

import type { ServerStateInfo } from '@bodhiapp/ext-types';

// Server state from /bodhi/v1/info endpoint
const serverState: ServerStateInfo = {
  status: 'ready',
  version: '1.0.0',
  url: 'http://localhost:1135'
};

// Possible status values:
// - 'setup': Server requires initial setup
// - 'ready': Server ready for requests
// - 'resource-admin': Server needs resource configuration
// - 'error': Server encountered an error
// - 'unreachable': Cannot connect to server

Architecture

This package is the single source of truth for:

  • Message type constants
  • Request/response formats
  • Streaming protocols
  • Error structures
  • Server state definitions

Both bodhi-browser-ext and @bodhiapp/bodhijs depend on this package to ensure consistent communication.

License

MIT

Repository

https://github.com/BodhiSearch/bodhi-browser