@almyty/客户端
共享 HTTP 客户端和所有 almyty CLI 软件包使用的证书解析器.
使用量
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.jsonisPermanentStreamError(err)-- 运行流是否以某种方式失败 重试不会改变
跑过之后
client.followRun(agentId, runId, handler, signal?, options?) 和网关
gw.streamRun(runId, handler, signal?, options?) 一直盯着跑步直到结束.
如果连接下降,它们会自己重新连接,并沿着它们离开的地方继续
关闭: 每个事件到达 handler 一劳永逸 options.onLog 获取
运行历史 一次一个事件。 如果逃跑了,或者你没有看到,他们
立即停止, 并投出错误 status (400、401、403、404或410);
其它任何( 网络错误、 服务器错误) 都会经过几次重试, 等待
每次都长一点.
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://docs.almyty.com (英语)
- 资料来源: https://github.com/almyty-inc/almyty (英语)
Apache-2.0 阿尔米蒂公司.