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

agent-remote-core

v0.1.0

Published

Shared protocol types and transport contracts for agent-remote.

Readme

agent-remote-core

语言:English | 简体中文

agent-remote-core 提供 Agent Remote 协议的共享类型、消息工厂、结构校验和传输层接口。所有浏览器端、服务端和传输层包都依赖它来保持同一套 agent_remote:* 协议。

安装

npm install agent-remote-core

适用场景

  • 编写自定义 transport、服务端 adapter 或客户端封装。
  • 创建或校验 agent_remote:* 协议消息。
  • 复用 ToolDefinitionToolCallToolResult 等公共类型。

关键导出

  • AGENT_REMOTE_PROTOCOL_VERSION: 当前协议版本,当前值为 0.1.0
  • PROTOCOL_MESSAGE_TYPES: 标准 agent_remote:* 消息类型常量。
  • PROTOCOL_ERROR_CODES: 标准错误码,例如 incompatible_protocoltool_execution_rejected
  • createHelloMessage, createHelloAckMessage: WebSocket 握手消息工厂。
  • createRegisterToolsMessage: 创建浏览器工具注册消息。
  • createToolCallMessage, createToolResultMessage: 创建工具调用与工具结果消息。
  • createUserMessage, createAssistantMessage, createErrorMessage: 创建用户、assistant 和错误消息。
  • validateProtocolMessage: 校验协议消息结构。
  • validateToolDefinition: 校验工具定义结构。
  • TransportConnection: transport 需要实现的统一接口。
  • ToolDefinition, ToolCall, ToolResult: 工具注册、调用和结果类型。

基础用法

import {
  createRegisterToolsMessage,
  createToolResultMessage,
  validateProtocolMessage,
  type ToolDefinition
} from "agent-remote-core";

const tools: ToolDefinition[] = [
  {
    name: "change_background",
    description: "Change the page background color.",
    parameters: {
      type: "object",
      properties: {
        color: { type: "string" }
      },
      required: ["color"]
    },
    risk: "low",
    domain: "ui",
    tags: ["demo"]
  }
];

const registerTools = createRegisterToolsMessage(tools);
const validation = validateProtocolMessage(registerTools);

if (!validation.ok) {
  throw new Error(validation.errors.map((error) => error.message).join(", "));
}

const result = createToolResultMessage({
  callId: "call-1",
  ok: true,
  result: { color: "blue" }
});

协议类型

  • agent_remote:hello: WebSocket 握手。
  • agent_remote:hello_ack: WebSocket 握手确认。
  • agent_remote:register_tools: 工具注册。
  • agent_remote:user_message: 用户文本消息。
  • agent_remote:assistant_message: assistant 文本消息。
  • agent_remote:tool_call: 服务端请求浏览器执行工具。
  • agent_remote:tool_result: 浏览器返回工具结果。
  • agent_remote:error: 错误消息。

ToolDefinition 字段

  • name: 工具名称,必须是非空字符串。
  • description: 给 LLM 和开发者看的工具说明。
  • parameters: JSON Schema 风格的参数描述。
  • level: 可选工具等级,L1L2L3
  • risk: 可选风险等级,lowmediumhigh
  • domain: 可选业务域,例如 uidocumentbilling
  • tags: 可选标签列表,用于工具搜索。

注意事项

  • 校验逻辑是轻量结构校验,不会验证 parameters 内部 JSON Schema 语义。
  • normalizeToolDefinition 会在缺省时把 level 设置为 L1
  • 如果消息携带不兼容的 protocolVersionvalidateProtocolMessage 会返回校验错误。