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

@agentdeskbot/core

v0.1.0

Published

AgentDesk core shared types and widget ownership registry

Readme

@agentdeskbot/core

Shared TypeScript types for the AgentDesk widget ecosystem.

The contract layer that powers @agentdeskbot/react and @agentdeskbot/vue.

npm version bundle size license TypeScript


Table of Contents


Why @agentdeskbot/core?

The AgentDesk widget is shipped as multiple framework adapters (React, Vue, and any future adapters). To keep these adapters in lock-step — and to let you consume the same well-typed contract in your own integrations — all shared TypeScript surface lives here.

| Benefit | What it means for you | | --- | --- | | Single source of truth | Props, modes, and event payloads match across React, Vue, and any custom adapter. | | Minimal runtime | Tiny (< 3 KB) JavaScript module — tree-shakeable, only ships what you use. | | Framework-agnostic | Use it from React, Vue, Svelte, Solid, vanilla JS/TS — anything that can read .d.ts. | | Strictly typed | Built with strict: true so you get full IntelliSense and compile-time safety. |

If you just want to embed the chat widget, you probably don't need this package directly — install @agentdeskbot/react or @agentdeskbot/vue instead. This package is for adapter authors and advanced consumers building custom integrations.


Installation

# npm
npm install @agentdeskbot/core

# yarn
yarn add @agentdeskbot/core

# pnpm
pnpm add @agentdeskbot/core

Requirements

  • Node.js >= 18
  • TypeScript >= 4.7 (recommended >= 5.x)

This package ships a tiny runtime module (< 3 KB) alongside type definitions. It handles widget instance ref-counting, mode synchronization, and cross-origin postMessage. The bundle is tree-shakeable — if your bundler supports side-effect detection, unused exports will not appear in your production build.


Exports

The package exposes a single, stable surface area from its root entry:

export type WidgetMode = 'launcher' | 'inline';

export interface WidgetMessageEventData {
  type: 'agentdesk-widget-open' | 'agentdesk-widget-close';
  botId: string;
}

WidgetMode

Controls how the widget is rendered on the host page.

| Value | Behavior | | --- | --- | | 'launcher' (default) | A floating launcher bubble anchored to the bottom-right corner. Clicking it opens the chat surface. | | 'inline' | The widget fills the nearest positioned ancestor element — useful for embedding the chat directly inside a page section, modal, or side panel. |

import type { WidgetMode } from '@agentdeskbot/core';

const mode: WidgetMode = 'inline';

WidgetMessageEventData

The shape of the payload posted by the AgentDesk widget IIFE to window via postMessage whenever the user opens or closes the chat surface.

| Field | Type | Description | | --- | --- | --- | | type | 'agentdesk-widget-open' \| 'agentdesk-widget-close' | The lifecycle event being broadcast. | | botId | string | The bot ID this event pertains to — useful when multiple bots are mounted on the same page. |

import type { WidgetMessageEventData } from '@agentdeskbot/core';

window.addEventListener('message', (event: MessageEvent) => {
  if (event.origin !== window.location.origin) return;
  const data = event.data as WidgetMessageEventData;
  if (data?.botId !== 'YOUR_BOT_ID') return;

  if (data.type === 'agentdesk-widget-open') {
    console.log('Chat opened for bot', data.botId);
  } else if (data.type === 'agentdesk-widget-close') {
    console.log('Chat closed for bot', data.botId);
  }
});

Security note: Always validate event.origin and the payload shape before acting on a postMessage event. The official React and Vue adapters do this for you.


Usage

1. As a type-only dependency in your own adapter

If you are building a custom framework adapter (Svelte, Solid, vanilla, etc.) and want to stay consistent with the official ones:

// my-agentdesk-adapter/src/index.ts
import type { WidgetMode, WidgetMessageEventData } from '@agentdeskbot/core';

export interface MyAdapterProps {
  botId: string;
  mode?: WidgetMode;
  onOpen?: () => void;
  onClose?: () => void;
}

2. Listening to widget lifecycle events

import type { WidgetMessageEventData } from '@agentdeskbot/core';

function attachLifecycleListener(botId: string) {
  const handler = (event: MessageEvent) => {
    if (event.origin !== window.location.origin) return;
    const data = event.data as Partial<WidgetMessageEventData>;
    if (data?.botId !== botId) return;

    switch (data.type) {
      case 'agentdesk-widget-open':
        // chat opened
        break;
      case 'agentdesk-widget-close':
        // chat closed
        break;
    }
  };

  window.addEventListener('message', handler);
  return () => window.removeEventListener('message', handler);
}

3. Reusing the type in your own chat surface

import type { WidgetMode } from '@agentdeskbot/core';

interface ChatSurfaceProps {
  botId: string;
  mode: WidgetMode;
}

function ChatSurface({ botId, mode }: ChatSurfaceProps) {
  // ...your implementation
}

Tree-shaking & Side Effects

This package is marked "sideEffects": false in its package.json, so bundlers like Webpack, Rollup, Vite, and esbuild can safely tree-shake it. The runtime module is tiny (< 3 KB) — unused exports are dropped from your final bundle.

You can verify this for yourself:

npx bundlephobia @agentdeskbot/core

Build & Develop

The package is bundled with tsup and produces both ESM and CJS outputs with type declarations.

# Build once
npm run build

# Watch mode for local development
npm run dev

Build output (in dist/):

dist/
├── index.cjs      # CommonJS entry
├── index.js       # ESM entry
├── index.d.ts     # Type declarations
└── index.d.cts    # CJS type declarations

The dist/ folder is regenerated on every build and is the only folder published to npm. Source files under src/ are not shipped.


Versioning & Compatibility

@agentdeskbot/core follows Semantic Versioning:

  • Patch releases (e.g. 0.1.1) — internal refactors, comment/doc fixes, no API change.
  • Minor releases (e.g. 0.2.0) — backwards-compatible additions to the public type surface.
  • Major releases (e.g. 1.0.0) — breaking type changes (renamed exports, narrowed unions, removed fields).

The React and Vue adapters are versioned in lock-step with this package, so upgrading one usually means upgrading the others.


Contributing

Bug reports, feature requests, and pull requests are welcome.

  1. Open an issue describing the change.
  2. Fork the repository and create a feature branch.
  3. Run npm run build to make sure the type bundles are clean.
  4. Submit a PR with a clear description and reproduction steps.

Tip for adapter authors: If you are adding a new public type, please also update the React and Vue adapters to consume it, so the three packages stay aligned.


Related Packages

| Package | Description | | --- | --- | | @agentdeskbot/react | React & Next.js SDK for the AgentDesk widget. | | @agentdeskbot/vue | Vue 3 & Nuxt 3 SDK for the AgentDesk widget. |


License

MIT © AgentDesk