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

@agentified/fe-client

v0.0.9

Published

Run agent tools in the browser. Stream everything.

Readme

@agentified/fe-client

Run agent tools in the browser. Stream everything.

Frontend client for Agentified — connects to an AG-UI agent backend, handles streaming events, manages frontend tool execution, and exposes full inspector state.

Install

npm install @agentified/fe-client

Quick Start

import { AgentifiedClient } from "@agentified/fe-client";

const client = new AgentifiedClient({
  agentUrl: "http://localhost:3003/api/chat",
});

// Subscribe to state changes
client.subscribe((state) => {
  console.log("Messages:", state.messages);
  console.log("Loading:", state.isLoading);
  console.log("Tools:", state.agentified.currentTools);
});

// Register a frontend tool handler
client.registerToolHandler("navigate_to_page", async (args) => {
  window.location.href = args.path;
  return { success: true };
});

// Send a message (streams AG-UI events from backend)
await client.sendMessage("Show me the dashboard");

API Reference

new AgentifiedClient(config)

interface AgentifiedClientConfig {
  agentUrl: string;                    // AG-UI agent backend URL
  headers?: Record<string, string>;    // custom HTTP headers
  contextWindowSize?: number;          // reserved for future use
  maxEventLogSize?: number;            // reserved for future use
}

client.subscribe(listener)

Subscribe to state changes. Returns an object with unsubscribe().

const sub = client.subscribe((state: InspectorState) => {
  // called on every state change
});
sub.unsubscribe();

client.sendMessage(content)

Sends a user message and streams the agent response.

await client.sendMessage("What employees are on leave?");

client.run(input)

Lower-level: runs the agent with full message history and optional context.

await client.run({
  messages: [{ role: "user", content: "Hello" }],
  context: [{ description: "Current page", value: "/dashboard" }],
});

context is Context[] from @ag-ui/client.

client.registerToolHandler(name, handler)

Registers a frontend tool handler. When the agent calls this tool, the handler runs client-side.

client.registerToolHandler("open_modal", async (args) => {
  openModal(args.modalId);
  return { opened: true };
});

client.unregisterToolHandler(name)

client.unregisterToolHandler("open_modal");

client.setSharedContext(ctx)

Sets shared context (page, modals, active tab) sent with each agent request.

client.setSharedContext({ page: "/employees", openModals: [], activeTab: "list" });

client.getMessages()

Returns current message history.

client.getState()

Returns the full InspectorState snapshot.

client.getAvailableFrontendToolNames()

Returns names of registered frontend tool handlers.

client.reset()

Resets all state (messages, events, tools, connection status).

State Model

The client maintains an InspectorState that tracks everything:

interface InspectorState {
  connection: ConnectionStatus;  // "idle" | "connecting" | "connected" | "disconnected" | "error"
  run: RunInfo;                  // runId, threadId, startedAt, durationMs
  agentified: {
    prefetchResults: PrefetchResult[];
    discoveries: DiscoveryResult[];
    currentTools: AgentifiedTool[];
  };
  tokens: TokenState;            // input, output, cached, reasoning, contextWindowPercent
  streaming: StreamingMetrics;   // messageCount, toolCallCount, timeToFirstTokenMs
  toolCalls: ToolCallDetail[];   // all tool calls with timing
  events: EventLogEntry[];       // full event log
  messages: Message[];
  isLoading: boolean;
  error: string | null;
  frontendTools: string[];
  sharedContext?: SharedContext;
}

Frontend Tool Handling

The client handles frontend tools automatically:

  1. Agent calls a tool with metadata.location === "frontend"
  2. Client intercepts it and runs the registered handler
  3. Tool result is injected back into the conversation
  4. Agent continues with up to 5 iterations of frontend tool calls

Links

License

MIT