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

@alwith/api

v0.1.6

Published

ALwith from the app side: the Runtime client, the agents you hold, and ACP session state

Downloads

777

Readme

@alwith/api

ALwith 的应用侧 TypeScript。一个包,三样东西,按名词分入口;整包 import 也行。

| 入口 | 内容 | | --- | --- | | @alwith/api/runtime | RuntimeClient 接口与帧协议类型,WebSocketRuntimeClient(alwith-runtime --listen ws://),错误 | | @alwith/api/agent | Agents / Agent(起、接管、换芯、退出)与 AgentRequests(权限与问卷的待办簿) | | @alwith/api/session | session/update 帧折成一条可渲染的会话:applyUpdateSessionStoreturns。判据见 SESSION.md | | @alwith/api/tauri | TauriRuntimeClient:宿主的 Rust 把 stdio 子进程经 Tauri 事件中转 | | @alwith/api/node | ProcessRuntimeClient:自己 spawn alwith-runtime --listen stdio:// |

三种传输都继承 FrameRuntimeClient;要自己的传输就继承它。

import { WebSocketRuntimeClient } from "@alwith/api/runtime"

const port = new WebSocketRuntimeClient(url, token)
await port.start("codex", { engine: "codex", cwd })
const { sessionId } = await port.sessionNew("codex", cwd)
const { stopReason } = await port.prompt("codex", sessionId, [{ type: "text", text: "你好" }])

你手里的 agent:Agents

起进程、接管、换芯、退出,每个 WorkBuddy 都要处理,而且做错就是事故:起了同名的第二个进程、 换芯时接回了正在退出的旧进程、进程崩了 prompt 的 await 永挂。这些收在 Agents 里,你拿到的是一个 Agent:

import { Agents } from "@alwith/api/agent"

const agents = new Agents(port, { info: { name: "my-workbuddy", version: "1.0" } })
// 有活的就接管(进程、上下文、没答的请求都还在),没有就起一个
const attached = await agents.attach(sessionId)
const agent = attached?.agent ?? (await agents.start("chat-1", launch))
attached?.info.pendingAgentRequests   // 接管时 agent 还在等答的请求,交给 AgentRequests 待办簿
agent.onNotification((method, params) => …)
await agent.request("session/prompt", { sessionId, prompt })   // 进程退出时立刻失败,不永挂
await agents.replace("chat-1", otherLaunch)                     // 换芯 = 停 → 等 exit → 起
agents.onExit(agent => …)                                       // 进程没了,与 Runtime 的 exit 事件同步

只观察不认领的面板别 attach:attach 就是认领,认领了那条会话的权限就该你答。用只读的 agentForSession(sessionId) 拿到 agentId,再按它过滤广播的 onAcpNotification / onAcpAgentRequest

Agents 只要求端口有 AgentPort 那几条(RuntimeClient 的子集),应用自己的宿主端口(比如 Tauri 中转)也能用。

协议参考是仓库根的 PROTOCOL.md;这个包是它的应用侧。

Rust SDK

从 0.1.4 起,包内 rust/ 是可嵌入消费端 workspace 的 Cargo crate,包含协议类型、Runtime 客户端及进程辅助。先用 Bun 安装此包,再配置相对于 Cargo.toml 的 path

[dependencies]
alwith-api = { path = "../node_modules/@alwith/api/rust", features = ["client"] }

上例适用于 src-tauri/Cargo.toml。根目录 Cargo.toml 使用 node_modules/@alwith/api/rust。仅需类型时使用 default-features = false。此 crate 在消费端编译,不依赖上游 Git checkout。

License and redistribution

See LICENSE and third-party notices. ALwith-owned code is proprietary, not open source. You may build, customize, host, charge for and distribute your own WorkBuddy applications under the included license, without per-application registration. This does not grant hosted-service access or rights to separately distributed Rust libraries or Runtime binaries. The npm artifact includes compiled/minified JS, declarations, necessary assets, and the Rust SDK source under rust/. It does not include the private TS/TSX implementation or source maps. Minification is not encryption.