# @almyty/client 中文文档

规范地址：https://npmcn.com/package/%40almyty/client/

版本：1\.5\.9
npm 元数据更新时间：2026-11-06T12:42:36.325Z
中文译文更新时间：2026-11-06T14:19:50.853Z
软件包许可：Apache-2\.0

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40almyty/client
原文对照：https://npmcn.com/package/%40almyty/client/?lang=original
项目主页：https://almyty.com/
源码仓库：https://github.com/almyty-inc/almyty

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：53 kB，8 个文件
- 模块格式：ES Module
- TypeScript 类型：包内自带
- 运行依赖：0 个
- 首次发布：2026-04-21T21:13:27.179Z
- 最新版本发布：2026-11-06T12:42:35.960Z
- 近 30 天下载量：3007（2026-10-06 至 2026-11-04，npm 官方下载统计）
- 已发布版本数：13（近 12 个月 13 个）

## 中文简介

共享 HTTP 客户端和由 almyty CLIs 使用的证书解析器. 读作~/.almyty/credititives.json;通常不自行安装.

## 安装

```sh
npm install @almyty/client
```

也可以使用：`pnpm add @almyty/client`、`yarn add @almyty/client`、`bun add @almyty/client`

## README

# @almyty/客户端

共享 HTTP 客户端和所有 almyty CLI 软件包使用的证书解析器.

## 使用量

```typescript
import { AlmytyClient, resolveCredentialsOrExit } from '@almyty/client';

const creds = resolveCredentialsOrExit();
const client = new AlmytyClient(creds.url, creds.token);

const agents = await client.listAgents();
```

## 出口

-   `AlmytyClient` - API客户端(代理、运行、网关)
-   `GatewayClient` -- 网关扫描客户端(信息、流、对话)
-   `resolveCredentials()` -- -- 读 `~/.almyty/credentials.json` (如果缺少,返回无效)
-   `resolveCredentialsOrExit()` -- 相同, 但是如果缺少错误消息则退出
-   `getOrgSlugFromToken(token)` - JWT的取出箭头
-   `loadCredentials()` -- 原始文件已读取
-   `CREDENTIALS_FILE` -- 路径 `~/.almyty/credentials.json`
-   `isPermanentStreamError(err)` -- 运行流是否以某种方式失败 重试不会改变

## 跑过之后

`client.followRun(agentId, runId, handler, signal?, options?)` 和网关 `gw.streamRun(runId, handler, signal?, options?)` 一直盯着跑步直到结束. 如果连接下降,它们会自己重新连接,并沿着它们离开的地方继续 关闭: 每个事件到达 `handler` 一劳永逸 `options.onLog` 获取 运行历史 一次一个事件。 如果逃跑了,或者你没有看到,他们 立即停止, 并投出错误 `status` (400、401、403、404或410); 其它任何( 网络错误、 服务器错误) 都会经过几次重试, 等待 每次都长一点.

```typescript
const run = await client.followRun(agentId, runId, (event) => {
  if (event.type === 'llm.chunk') process.stdout.write(String(event.data.content));
}, undefined, {
  onLog: (logged) => console.error(`#${logged.seq} ${logged.type}`),
});
```

为了得到一个跑步,你已经跟随, 通过你的位置: `{ afterSeq, livePos }`,哪个 `followRunStream` 返回和 `onReconnect` 报告.

## 关于Almyty

almyty是AI代理的全高架平台,设计上不可知:任何LLM,任何 API变成工具,服务于MCP,A2A,UTCP,以及代理技能. 开源, 没有锁定.

-   网站: [https://almyty.com (中文(简体) )](https://almyty.com/)
-   文档 : [https://docs.almyty.com (英语)](https://docs.almyty.com/)
-   资料来源: [https://github.com/almyty-inc/almyty (英语)](https://github.com/almyty-inc/almyty)

Apache-2.0 阿尔米蒂公司.

## 常见问题

### @almyty/client 是什么？

共享 HTTP 客户端和由 almyty CLIs 使用的证书解析器\. 读作~/\.almyty/credititives\.json;通常不自行安装\.

### 如何安装 @almyty/client？

在项目目录运行 npm install @almyty/client，或使用 pnpm add / yarn add / bun add。

### @almyty/client 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @almyty/client 支持 ESM 还是 CommonJS？

以 ES Module 形式发布，推荐使用 import 引入。在 CommonJS 项目中，Node\.js 20\.19\+ / 22\.12\+ 可以直接 require\(\) 不含顶层 await 的 ES Module，更早的版本需要改用动态 import\(\)。

### @almyty/client 可以商用吗？

@almyty/client 使用 Apache-2\.0 许可。宽松许可：允许商业使用、修改和再分发，并附带明确的专利授权；分发时需保留许可与 NOTICE 文件，修改过的文件要注明改动。以上为概括，不构成法律意见，请以许可原文为准。

### @almyty/client 的下载量有多少？

根据 npm 官方下载统计，@almyty/client 在 2026/10/06 – 2026/11/04 这 30 天内被下载 3,007 次，日均约 100 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @almyty/client 还在维护吗？

最新版本 1\.5\.9 发布于 2026/11/06（1 天前）；至今共发布 13 个版本，其中过去 12 个月发布了 13 个；首次发布于 2026/04/22。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

