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

@aalis/api-session-protocol

v0.3.0

Published

会话协议契约(实验性):owner 客户端与守护进程之间的 JSON-RPC 帧、会话、条目与审批的 zod schema,以及 session-protocol 服务描述符

Readme

@aalis/api-session-protocol

会话协议契约(实验性):owner 的客户端与守护进程之间的线上格式。JSON-RPC 2.0 帧、握手、错误码,会话列表与增量、订阅与条目、回合控制、在场与审批,全部写成 zod schema,类型由 schema 推导。不含服务实现,默认实现是 @aalis/plugin-session-server。

角色

  • SESSION_PROTOCOL_VERSION:协议版本(现为 0.2.0),握手时比的部分不同即断开。
  • 给人看的文字字段(会话标题、场所名、分组名、通知条目的文字、原因、设置项的标签与说明等)是产出方的形状:服务端交出字符串或文字对象(@aalis/schema-i18n 的 TextRef),发出前按全局层的语言(读者是 owner 自己)渲染成字符串,日期与时间按服务进程的时区,线上一律是字符串。读线上的一方按 Localized<…> 读。错误帧的 message 只描述线上:服务端内部的 ProtocolError 与 failure 收文字对象,线上是渲染后的字符串。
  • sessionMethods / sessionNotifications:方法与推送的 schema 表,服务端据它校验收到的帧,客户端照它实现。
  • RequestFrameSchema、ResultFrameSchema、ErrorFrameSchema、NotificationFrameSchema,RPC_ERROR_CODES 与业务错误码 ErrorCodeSchema。
  • sessionProtocol:服务描述符,接口为 connect(peer, send) → { receive(frame), close() }。传输层(WebUI 的 WebSocket 等)认证之后把连接接到这里,对端带着传输层经 @aalis/api-approval 登记的审批面。

标 experimental。协议号只跟协议自己的变化走,不跟包版本:没到 1.0 写成 0.x 三段,不兼容的修改升第二位,只做加法升第三位,握手比前两段;1.0 以后不兼容的修改升第一位,握手比第一段。对象 schema 不拒多余的键,旧客户端读到新加的字段照常解析。

安装

pnpm add @aalis/api-session-protocol

使用

import { approvals } from '@aalis/api-approval';
import { sessionProtocol } from '@aalis/api-session-protocol';

// uses: { sessionProtocol: optional(sessionProtocol), approvals: optional(approvals) }
const surface = caps.approvals.use.registerSurface('webui');
const conn = caps.sessionProtocol.use.connect(
  { identity: { platform: 'webui', userId: 'console' }, surface, disconnect: reason => socket.close(1000, reason) },
  frame => socket.send(frame),
);
socket.on('message', data => void conn.receive(String(data)));
socket.on('close', () => conn.close());

详见 docs/api/api-session-protocol.md。