# @glyphh-ai/glyphh 中文文档

规范地址：https://npmcn.com/package/%40glyphh-ai/glyphh/

版本：3\.6\.0
npm 元数据更新时间：2026-11-01T02:12:50.382Z
中文译文更新时间：2026-11-01T06:20:44.377Z
软件包许可：MIT

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

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

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

- 包体积（解压后）：114 kB，5 个文件
- 模块格式：ES Module
- TypeScript 类型：包内自带
- Node.js 要求：\>=18
- 运行依赖：0 个
- 首次发布：2026-10-18T21:46:51.068Z
- 最新版本发布：2026-11-01T02:12:50.039Z
- 已发布版本数：8（近 12 个月 8 个）

## 中文简介

用于TypeScript和JavaScript的Ada：从您自己的先例中键入决策，来自Ada Cloud ([https://ada.glyphh.ai](https://ada.glyphh.ai/))，并附有API密钥；以及本地rrotor的客户端，即托管程序和cli的运行时。

## 安装

```sh
npm install @glyphh-ai/glyphh
```

也可以使用：`pnpm add @glyphh-ai/glyphh`、`yarn add @glyphh-ai/glyphh`、`bun add @glyphh-ai/glyphh`

## README

# @glyphh-ai / glyphh

Ada for TypeScript和JavaScript：你在Ada Cloud中的模型 `https://ada.glyphh.ai`，使用API密钥调用。 Node 18或更高版本(或任何带有 `fetch`)，没有依赖关系。

```bash
npm install @glyphh-ai/glyphh
```

```ts
import { Ada, LimitError } from "@glyphh-ai/glyphh";

const ada = new Ada();          // GLYPHH_API_KEY from the environment; or new Ada({ key: "glyphh_ak_..." })

const d = await ada.decide("tickets", { ticket: { what: { plan: "pro", text: "charged twice" } } });
if (d.ask) await sendToAPerson(d);   // a person should decide: d.outcome is the best guess, for them to see
else act(d.outcome);                 // d.probabilities, d.expected_cost, d.receipts: the precedents it stands on

const tickets = ada.model("tickets");
await tickets.record({ ticket: {...} }, "refund");              // a confirmed outcome: the next case learns from it
```

该密钥是在平台的API密钥页面([https://platform.glyphh.ai](https://platform.glyphh.ai/))，或者由克劳德通过象形文字 连接器;它在你的组织中起作用，并获得了许可。 `GLYPHH_ADA_URL` 移动地址（本地） 测试服务器)；3.0的 `GLYPHH_RUNTIME_URL` 和 `GLYPHH_RUNTIME_KEY` 仍在阅读。

## 从一无所有到做出决定

```ts
const tickets = await ada.createModel("tickets", spec);       // the spec as JSON: layers, segments, roles, output
const job = await tickets.importFile("history.csv", {          // a path (Node), or the bytes with { format }
  mapping: { Plan: "ticket.what.plan", Result: "outcome" },
  onProgress: (j) => console.log(j.state, j.percent),
});
console.log(job.result.added, job.result.refused, job.result.refusals.slice(0, 3));

const bt = await tickets.backtest([{ settings: { word_evidence: 0 }, name: "no word evidence" }], { holdout: { newest: 200 } });
await tickets.settings({ word_evidence: 0 }, { note: "cost 8% less on the last 200", backtest: bt.id });   // a new version
await tickets.activate(1);                                     // and back
await tickets.export({ to: "tickets.zip" });                   // everything, as a zip: never locked in
```

## 输入输出和联合

在 `ada-1-2-beta`，一个命名的输出 `kind` 它的答案是： `score`， `noul`， `number`， `many` 或者 `choice` （默认值），以及 `when` 使输出成为联合的分支。以各自的方式记录(`Outcome`）; 读什么 它还补充道：

```ts
await tickets.recordMany([{ data, outcomes: { kind: "billing", refund: 120, urgent: true, tags: ["web"] } }]);
const d = await ada.decide("tickets", data, { outputs: ["kind", "severity", "refund", "urgent", "tags"] });
d.outputs?.urgent.p;          // a noul's P(true)
d.outputs?.refund.value;      // a number's expected value
d.outputs?.severity.applies;  // false: a bug's severity does not arise for a billing case
d.outputs?.tags.outcome;      // a many output's list
```

## 艾达版本

每个模型版本运行一个Ada版本，命名为 `ada-<major>-<minor>` （`-beta` 对于测试版)： `ada-1-0` 是 今天最新的稳定， `ada-1-1-beta` 一个测试版。模型的答案总是由它自己的Ada版本计算出来的；移动 另一个是你的选择，在你面前做了一个回测。

```ts
const { latest_stable, versions } = await ada.ada.versions();  // newest first: name, status, dates, notes, your models on it
const tickets = await ada.createModel("tickets", spec);        // the latest stable; { ada: "ada-1-1-beta" } to opt in to a beta
const info = await tickets.info();                             // info.ada, info.ada_status, info.ada_notice; each of versions() has .ada too

const bt = await tickets.backtest([], { ada: "ada-1-1-beta" }); // the active spec, learned and scored on that Ada
console.log(bt.result.active.cost, "->", bt.result.candidates[0].cost);
const moved = await tickets.upgrade({ ada: "ada-1-1-beta", note: "2 fewer wrong on the last 200", backtest: bt.id });
await tickets.activate(info.version);                          // and back, on the Ada it ran before
```

`upgrade()` 没有 `ada` 移动到最新的马厩；旧版本是降级的，允许保留。 测试版从来不是默认的。已弃用的版本在结束日期之前仍然应答，然后将模型移动到 最新稳定为您（从未离开无法回答）；当它运行一个时，或者在它被移动之后，客户端调用 `new Ada({ onWarning })` (默认 `console.warn`（每个客户和通知一次）。被拒绝的名字永远不会被替换： `AdaVersionUnknownError`， `AdaVersionRetiredError`， `AdaVersionDeprecatedError` （用于新型号或升级版） 目标), `AdaBetaClosedError`， `AdaVersionUnavailableError`，每个都有 `ada` 和 `latest` （最新的稳定，修复）。

SDK讲契约 `SUPPORTED_CONTRACT` (5)并被提出反对 `SUPPORTED_ADA` （`ada-1-0`， `ada-1-1-beta`); 服务器列表中的新名称按原样工作。一个服务器说了一个新的合约被拒绝，永远不会被读取 half-understood: `ClientTooOldError` （`contract`， `supported`)，对 `npm install @glyphh-ai/glyphh@latest`.

|  |  |
| --- | --- |
| `Ada` | `decide(model, data, { output, outputs, include: ["facts"], clearance })` （`POST /v1/decide`); `models()`， `model(name)`， `createModel(name, spec, { ada })`， `deleteModel(name)`； `ada.versions()`， `ada.latestStable()`； `job(id)`， `wait(job, { timeout, onProgress })`， `download(job)`； `usage()` |
| `AdaModel` | `info()` （`ada`， `ada_status`， `ada_notice`)， `spec()`， `setSpec(spec, { note, backtest })`， `settings()` 和 `settings(changes, { note, backtest })`， `versions()` (每个都有 `ada`， `kernel`)， `activate(version)`， `upgrade({ ada, note, backtest, wait })`， `delete()`； `recordMany(cases)` （每条请求1000块）， `grade(id, value, { output })`， `forget(id)`； `decide(data, ...)`； `learn()`， `learnJob()`， `calibrate()`， `backtest(candidates, { ada, holdout, output })`； `importFile(path or bytes, { format, mapping, partial, learn })`， `export({ format, to })` |
| `Decision` | `outcome`， `probabilities`， `expected_cost`， `ask`， `receipts`， `facts`， `outputs`， `model`， `version`， `ada`;读起来是3.0 `Result` (`status`， `data`） |
| `AdaVersions` | `latest_stable`， `contract`， `versions` (每 `name`， `kernel`， `status`， `beta`， `open`， `released`， `deprecated`， `ends`， `changes_answers`， `aliases`， `summary`， `notes`， `models`） |
| `Job` | `id`， `model`， `kind`， `state` （`awaiting`， `queued`， `running`， `done`， `failed`)， `percent`， `result`， `error`， `download`， `upload` |
| `Usage` | `plan`， `month` (UTC) YYYY-MM `resets_at` (YYYY-MM-DD), `models`， `precedents` （`used`， `max`)， `requests` （`used`， `max`， `over`， `overage`（过去一个月的基本版、专业版和团队版，拒绝免费版）； `requests_per_second`； `null` 是合同，没有上限 |
| `AdaError` | `code`， `message`， `status`， `detail`， `retryAfter`， `traceId`;按代码输入： `AuthError`， `LimitError` （`reason`， `used`， `max`， `plan`， `upgrade`， `resetsAt`)， `RateError` （`retryAfter` 从Retry-After, `max`;在重试截止日期允许的范围内等待)， `InvalidError`， `ModelMissingError`， `JobMissingError`， `SpecError`， `SpecLimitError`， `SpecReadingError`， `FewRolesError`， `MappingError`， `BusyError`， `NotReadyError`， `NoChangeError`， `IdempotencyError`， `VersionGoneError`， `AdaTimeoutError`， `UnavailableError`， `JobFailedError` (一份结束的工作 `failed`)， `AdaVersionError` 和它的种类（上面）， `ClientTooOldError` |

每个长时间运行的调用都是一个作业，等待它的进程，除非 `{ wait: false }`． 每次写都有一个 `Idempotency-Key`，因此客户端再次发送安全的内容：读或写，而Ada对于a是不可访问的 时刻(`E_UNAVAILABLE`， `E_TIMEOUT`（502到504），任何被拒绝的都是429，后退和 `Retry-After`， 最多可达 `new Ada({ retryDeadline })` 秒（默认为30；0：不）。

SDK 3.0的调用仍然有效： `record`， `query`， `facts`， `probabilities`， `learn` 和 `call(fn, inputs)` 经历 `POST /v1/runs` 然后回答a `Result` （`run_id`， `status`， `data`,……)。云一次接一次，所以a 决策从不等待输入：它说 `ask`.

API和它的答案的形状在里面 [`contract/contract.json`](https://github.com/glyphh-ai/glyphh/tree/main/contract).

## 本地运行时：程序和cli

`Runtime` 是rrotor的客户端，您在自己的机器上安装的运行时(Docker映像，绑定到 `127.0.0.1:7777`;字形插件 `rrotor` 技能安装它从克劳德)。它不是艾达云：它托管你的 **项目** (一个 `glyphh.json` 清单和 `program.py`，沙盒，有一个本地的秘密金库，cron时间表，一个 SQLite数据库和批准)和您的 **综合领先指标** (一种程序， `"kind": "cli"`，每次运行一个命令 同样的沙盒)。字形只是授予它一个许可；没有，它就像社区一样运行。

```ts
import { Runtime } from "@glyphh-ai/glyphh";

const rt = new Runtime();                          // RROTOR_URL or http://127.0.0.1:7777; RROTOR_TOKEN or ~/.glyphh/rrotor/token
await rt.deploy({ path: "./daily_sales" });         // the folder's HEAD commit (Node), or { repo, commit, token? }
let run = await rt.call("daily_sales", "start", { day: "2026-10-30" });
if (run.status === "needs_approval") run = await rt.approve(run.run_id);   // only on the person's yes
await rt.setSecret("github", "GH_TOKEN", token);   // kept encrypted on the runtime; never read back
const out = await rt.runCli("github", ["pr", "list"]);   // out.data.exit_code, stdout, stderr
```

|  |  |
| --- | --- |
| `Runtime` | `programs()`， `program(name)`， `deploy({ path, commit? } | { repo, commit, token? } | { bundle, commit })`； `call(program, fn, inputs, { version, clearance })`， `resume(runId, answer)`， `approve(runId, approved?)`， `cancel(runId)`， `run(runId)`， `log(runId)`， `approvals()`； `secrets(program)`， `setSecret`， `deleteSecret`； `schedules()`， `pauseSchedule`， `resumeSchedule`； `clis()`， `runCli(cli, args, { stdin, files })`； `licence()`， `setLicence(key)`， `health()` |
| `Run`， `CliOutput`， `RunInfo`， `Program`， `ProgramVersion`， `Approval`， `Secret`， `Schedule`， `Cli`， `Licence` | 输入API的答案 |
| `RrotorError` | 一个 `AdaError` 太;按代码输入： `RrotorAuthError`， `RrotorForbiddenError`， `LocalOnlyError`， `ProgramMissingError`， `FunctionMissingError`， `RunMissingError`， `ScheduleMissingError`， `ManifestError`， `DeployError`， `InputsError`， `RunStateError`， `NotProgramError`， `NotCliError`， `CliDeniedError`， `NotHeadError`， `LicenceError`， `NotInPlanError`； `E_UNREACHABLE` 当旋翼不运行时 |

当r转子暂时不可达时，再次发送读取；写的从来都不是。自承载旋翼是 `new Runtime({ url: "https://rrotor.example.com", token: "<a runtime key>" })`． 它的形状是 [`contract/runtime.json`](https://github.com/glyphh-ai/glyphh/tree/main/contract)除了艾达的合同。

## 许可证

麻省理工学院(`LICENSE`）。

## 常见问题

### @glyphh-ai/glyphh 是什么？

用于TypeScript和JavaScript的Ada：从您自己的先例中键入决策，来自Ada Cloud \(https://ada\.glyphh\.ai\)，并附有API密钥；以及本地rrotor的客户端，即托管程序和cli的运行时。

### 如何安装 @glyphh-ai/glyphh？

在项目目录运行 npm install @glyphh-ai/glyphh，或使用 pnpm add / yarn add / bun add。

### @glyphh-ai/glyphh 支持 TypeScript 吗？

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

### @glyphh-ai/glyphh 支持 ESM 还是 CommonJS？

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

### @glyphh-ai/glyphh 需要什么版本的 Node\.js？

package\.json 的 engines 字段要求 Node\.js \>=18。版本不符时 npm 默认只给出警告，开启 engine-strict 后会拒绝安装。

### @glyphh-ai/glyphh 可以商用吗？

@glyphh-ai/glyphh 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @glyphh-ai/glyphh 还在维护吗？

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

