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

@mzhub/portal-client

v0.1.1

Published

AI Agent's Eyes & Hands - Browser-side co-browsing for AI agents

Readme

@mzhub/portal-client

AI Agent's Eyes & Hands — Browser-side co-browsing infrastructure for AI agents.

Installation

npm install @mzhub/portal-client socket.io-client

Optional Dependencies

# Local LLM (in-browser inference)
npm install @xenova/transformers

# React integration
npm install react @mzhub/react

Quick Start

import { Portal } from "@mzhub/portal-client";

const portal = new Portal({
  serverUrl: "wss://your-server.com",
  overlay: { enabled: true },
  privacy: { mask: [".credit-card", ".ssn"] },
  onPermissionRequest: async (reason) => {
    return confirm(`AI wants to view your screen: ${reason}`);
  },
});

// Connect to server
await portal.connect();

// Create a semantic snapshot (only visible, actionable elements)
const snapshot = portal.snapshot("semantic");

// Highlight an element with tooltip
portal.highlight("#login-btn", "Click here to login");

// Fill a form with human-like typing
await portal.fillForm("#email", "[email protected]");

// Scroll to element
portal.scrollIntoView("#reviews-section");

// Show ghost cursor
portal.showGuidance({ x: 100, y: 200, label: "Click Here" });

HTTP Mode (Alternative to Socket)

For serverless or simple chat-style integrations:

import { Portal, executeAgentCommands } from "@mzhub/portal-client";
import axios from "axios";

const portal = new Portal({ privacy: { maskDefaults: true } });

async function chat(message: string) {
  const response = await axios.post("/api/chat", { message });

  const result = await executeAgentCommands(response.data, {
    portal,
    maxRetries: 2,
    onDomRequest: () => portal.snapshot("semantic"),
    onSendToolResult: (data) =>
      axios.post("/api/chat", data).then((r) => r.data),
  });

  return result.text; // Final reply
}

React Integration

import { useAgentPortal, PortalProvider } from "@mzhub/portal-client/react";

function App() {
  return (
    <PortalProvider options={{ serverUrl: "wss://..." }}>
      <ChatWidget />
    </PortalProvider>
  );
}

function ChatWidget() {
  const { portal, isConnected, isViewing } = useAgentPortal();

  return (
    <div>
      <p>{isConnected ? "🟢 Connected" : "⚪ Disconnected"}</p>
      {isViewing && <p>👁️ AI is viewing</p>}
    </div>
  );
}

Features

Semantic Snapshots

Creates a filtered DOM tree containing only visible, actionable elements:

const snapshot = portal.snapshot("semantic");
// Returns: { elements: [...], viewport: {...}, url, title }

Privacy Masking

Automatically redacts sensitive content before sending:

new Portal({
  privacy: {
    mask: [".credit-card", "[data-private]"],
    maskDefaults: true, // Auto-masks password inputs
  },
});

Developer Overlay

Shows when AI is actively viewing:

new Portal({
  overlay: {
    enabled: true,
    color: "rgba(128, 0, 255, 0.1)",
    message: "AI Assistant is viewing",
  },
});

Local LLM (transformers.js)

Run inference in-browser for privacy-sensitive tasks:

const result = await portal.runLocal(
  "text-classification",
  "Is this password strong?"
);

API Reference

Portal Class

| Method | Description | | ------------------------------- | --------------------------- | | connect() | Connect to WebSocket server | | disconnect() | Disconnect from server | | snapshot(type) | Create DOM snapshot | | highlight(selector, message?) | Highlight element | | scrollIntoView(selector) | Scroll to element | | fillForm(selector, value) | Fill form with typing | | click(selector) | Click element | | showGuidance(options) | Show ghost cursor | | trackScroll(callback) | Track scroll position | | trackFocus(callback) | Track focus events | | onNetworkError(callback) | Listen for network errors | | isConnected() | Check connection status | | isAIViewing() | Check if AI is viewing | | destroy() | Clean up resources |

Events

| Event | Description | | --------------------- | ------------------------ | | connected | Connected to server | | disconnected | Disconnected from server | | viewing | AI started viewing | | stopped | AI stopped viewing | | permissionRequested | Permission requested | | permissionGranted | Permission granted | | permissionDenied | Permission denied | | actionExecuted | Action completed |

License

MIT