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

@asteby/metacore-ai-chat

v7.0.1

Published

Metacore copilot chat — floating widget, chat panel, draggable FAB and an injectable chat client (HTTP, permissions, branding, suggestions)

Readme

@asteby/metacore-ai-chat

Copilot chat for metacore apps: floating widget (draggable FAB), chat panel, starter prompts, proposals (approve/reject) and an injectable chat client. Everything app-specific is injected; the package imports no stores, API clients or routes.

Install

pnpm add @asteby/metacore-ai-chat @asteby/metacore-app-providers lucide-react

Tailwind must scan the package (same as other metacore UI packages):

@source "../node_modules/@asteby/metacore-ai-chat/dist/**/*.{js,mjs}";

What you inject

| Concern | How | | --- | --- | | HTTP client | createHttpChatClient(api, { basePath: '/chat' }) or your own ChatClient | | Permissions | permissions={{ canChat, canDecideProposals }} (canChat: false hides the widget and shows a denied notice in CopilotChat) | | Branding | branding={{ name, mascotSkin, avatar }}; the mascot is Mascot from @asteby/metacore-app-providers | | Suggestions | suggestions={[...]}, or omit to use useAgentSuggestions() (tenant agent_suggestions, neutral default) | | Copy | labels={{ ... }} partial override (Spanish defaults) |

Default REST contract (createHttpChatClient):

  • POST {base}/send {message, session_id, attachments} -> {success, session_id, reply|response, proposals?}
  • GET {base}/sessions, GET {base}/history/:id
  • POST {base}/proposals/:id/decide {approve}

Different backend? Implement ChatClient (send required; listSessions, loadHistory, decideProposal optional).

Proposal format

A reply may carry proposals. Both shapes are accepted and normalized (normalizeProposal) on ChatClient.send, loadHistory and the HTTP client:

// A) display shape
{ "id": "p1", "title": "Archivar hallazgo", "summary": "Motivo…", "status": "pending" }
// B) action shape: title = "action · model", summary = compact JSON of payload
{ "id": "p2", "action": "archive", "model": "finding", "payload": { "id": 7 }, "status": "pending" }

id is required (string or number, coerced to string); status is pending (default) | approved | rejected. An explicit title/summary wins over the derived ones. Rows without id or without anything to show are dropped. action, model and payload are kept on the normalized proposal so decideProposal hosts can use them.

Markdown replies

AI replies render as safe Markdown + GFM (Markdown, also exported): headings, lists, tables (horizontal scroll), blockquotes, inline/blocked code with a copy button, links and images. Raw HTML is never rendered, dangerous URL schemes are dropped, external links open with noopener noreferrer, images are limited to http(s)/same-origin. Unterminated code fences are closed while a reply is typed in. Styled with theme tokens only (no typography plugin). Pass onLinkClick to CopilotProvider to route in-app links through your router (return true when handled).

Channels: bot + agents + team

Give the widget an adapter and it becomes a unified inbox. The package knows no endpoint or socket; you map your backend:

const channels: ChannelAdapter = {
  listChannels: () => api.get('/internal-chat/channels').then(toChannels),   // kind: 'bot' | 'agent' | 'team'
  loadMessages: (id) => api.get(`/internal-chat/channels/${id}/messages`).then(toMessages),
  send: (id, body) => api.post(`/internal-chat/channels/${id}/messages`, { body }).then(toMessage),
  markRead: (id) => api.post(`/internal-chat/channels/${id}/read`),
  subscribe: (on) => ws.subscribe('INTERNAL_CHAT_MESSAGE', (e) => on({ type: 'message', message: toMessage(e.payload) })),
}
<CopilotWidget channels={channels} fullscreenHref="/agent" />
  • The bot channel (your ChatClient) is injected first (includeBot={false} to omit). An agent channel with its own client: ChatClient gets the full AI chat (proposals, history); without one it is served by the adapter like a team thread.
  • Unread counts drive a FAB badge (live even while the panel is closed); the last opened channel is remembered.
  • subscribe events: message, unread, presence, channels (refetch).

Full screen

The header's expand button turns the widget into a viewport-filling surface (list + thread side by side from md up; phones always get it). Escape steps back: expanded → floating → closed. fullscreenHref / onOpenFullscreen add an "open full view" link for apps with their own workspace route. hidden removes the widget on routes that already show it.

Demo badge

The badge shows when CopilotProvider demo / CopilotWidget demo is set, or when the backend flags a reply with demo: true (createHttpChatClient reads demo / is_demo). Never leave it permanently on for real data.

Accessibility and states

  • CopilotWidget panel is role="dialog" (aria-label = branding name, aria-modal="false": the page stays usable). Focus moves to the composer on open and returns to the FAB on close; Escape closes (any CopilotChat with onClose).
  • Controls are at least 44x44px with a visible focus ring; animations honour prefers-reduced-motion.
  • Offline (navigator.onLine) shows a status banner and disables sending. Failed turns show an alert with labels.retry; loadHistory and decideProposal failures show an alert (history with retry) instead of failing silently.
  • demo on CopilotProvider (or CopilotChat) renders the labels.demo badge ("Datos demostrativos").
  • Optional session picker: <CopilotChat sessions={list} sessionId={id} onSelectSession={setId} /> (get list from client.listSessions()).

Adopting it

ops (ERP)

import { CopilotProvider, CopilotWidget, createHttpChatClient } from '@asteby/metacore-ai-chat'
import { api } from '@/lib/api'
import { useAuthStore } from '@/stores/auth-store'

const client = createHttpChatClient(api) // ops exposes /chat/send, /chat/sessions, /chat/history/:id

export function Copilot() {
  const canChat = useAuthStore((s) => s.can('chat.use')) // adapt to your permission check
  return (
    <CopilotProvider client={client} permissions={{ canChat }}>
      <CopilotWidget />
    </CopilotProvider>
  )
}

Mount <Copilot /> in the authenticated layout, replacing AIChatWidget. Not covered by this package yet (stay in ops until follow-up): voice/live mode, file upload, guided tours, team-chat embeds, chart/choropleth embeds, Sparks pill. Use the CopilotChat panel directly (/agent page) with className="h-full".

gobiernos-ops

<CopilotProvider
  client={createHttpChatClient(api, { basePath: '/api/v1/chat' })}
  branding={{ name: 'Gobi', mascotSkin: 'gobi-navy' }}
  permissions={{ canChat: hasPermission('copilot:use') }}
  suggestions={['Resumen del tablero', 'Hallazgos pendientes de revisión']}
>
  <CopilotWidget defaultPosition={{ bottom: 24, right: 24 }} />
</CopilotProvider>

If the gobiernos backend uses a different contract, pass a custom ChatClient. Use suggestions to avoid ERP-flavored prompts; omit it to inherit tenant branding.

Also exported

useChat (state machine), chatReducer, useDraggableFab / computePanelLayout, useRevealText, and the AGENT_* surface class constants (use theme tokens --surface-*, --elevation-*).