@armadra/agent 0.18.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/CHANGELOG.zh-CN.md +20 -0
- package/README.md +4 -0
- package/README.zh-CN.md +4 -0
- package/dist/bundle/ama.cjs +25956 -25161
- package/dist/cli/bootstrap.js +32 -6
- package/dist/cli/compose-agents.js +2 -1
- package/dist/cli/compose-extensions-load.d.ts +20 -0
- package/dist/cli/compose-extensions-load.js +38 -0
- package/dist/cli/compose.js +1 -0
- package/dist/cli/deps.d.ts +11 -0
- package/dist/cli/runtime.d.ts +7 -0
- package/dist/cli/subcommands/doctor.js +33 -0
- package/dist/config/extension-tree-hash.d.ts +31 -0
- package/dist/config/extension-tree-hash.js +88 -0
- package/dist/config/extension-trust.d.ts +70 -0
- package/dist/config/extension-trust.js +112 -0
- package/dist/config/profile.d.ts +2 -0
- package/dist/config/profile.js +1 -0
- package/dist/config/schema-trust.d.ts +7 -0
- package/dist/config/schema-trust.js +46 -0
- package/dist/config/schema.d.ts +4 -5
- package/dist/config/schema.js +3 -25
- package/dist/config/trust.d.ts +2 -0
- package/dist/config/trust.js +5 -1
- package/dist/config/types.d.ts +13 -0
- package/dist/drivers/host-runners.d.ts +15 -4
- package/dist/drivers/host-runners.js +31 -17
- package/dist/errors.d.ts +1 -1
- package/dist/host/api-impl.d.ts +47 -4
- package/dist/host/api-impl.js +181 -20
- package/dist/host/commands.d.ts +23 -0
- package/dist/host/commands.js +76 -0
- package/dist/host/extensions.d.ts +43 -0
- package/dist/host/extensions.js +117 -0
- package/dist/host/resources.d.ts +2 -0
- package/dist/host/resources.js +5 -0
- package/dist/host/types.d.ts +41 -2
- package/dist/host/types.js +4 -2
- package/dist/i18n/catalog.d.ts +31 -0
- package/dist/i18n/messages/cli.d.ts +24 -0
- package/dist/i18n/messages/cli.js +24 -0
- package/dist/i18n/messages/drivers.d.ts +22 -0
- package/dist/i18n/messages/drivers.js +22 -0
- package/dist/i18n/messages/errors.d.ts +1 -1
- package/dist/i18n/messages/interactive-startup.d.ts +4 -0
- package/dist/i18n/messages/interactive-startup.js +4 -0
- package/dist/i18n/messages/interactive.d.ts +4 -0
- package/dist/i18n/messages/report.d.ts +12 -0
- package/dist/i18n/messages/report.js +12 -0
- package/dist/modes/acp/acp-config.d.ts +4 -2
- package/dist/modes/acp/acp-config.js +17 -3
- package/dist/modes/acp/acp-events.d.ts +2 -0
- package/dist/modes/acp/acp-events.js +4 -0
- package/dist/modes/acp/acp-server.js +6 -2
- package/dist/modes/acp/acp-sessions.d.ts +8 -1
- package/dist/modes/acp/acp-sessions.js +18 -0
- package/dist/modes/commands-core.d.ts +14 -1
- package/dist/modes/commands-core.js +34 -2
- package/dist/modes/interactive/startup-ui.js +21 -0
- package/dist/modes/interactive/status-area.js +1 -1
- package/dist/modes/print/print-mode.d.ts +3 -0
- package/dist/modes/print/print-mode.js +35 -8
- package/dist/modes/rpc/commands.d.ts +2 -0
- package/dist/modes/rpc/commands.js +22 -7
- package/dist/modes/rpc/rpc-mode.js +3 -0
- package/dist/modes/startup-ui-text.js +11 -0
- package/dist/rpc.d.ts +2 -1
- package/dist/tools/registry.d.ts +6 -0
- package/dist/tools/registry.js +13 -0
- package/dist/tools/types.d.ts +7 -0
- package/docs/README.md +1 -1
- package/docs/en/README.md +3 -3
- package/docs/en/guides/extensions.md +141 -0
- package/docs/en/reference/acp.md +1 -1
- package/docs/en/reference/host-api.md +55 -27
- package/docs/en/reference/rpc.md +9 -7
- package/docs/guides/extensions.md +136 -0
- package/docs/reference/acp.md +1 -1
- package/docs/reference/host-api.md +55 -27
- package/docs/reference/rpc.md +9 -7
- package/package.json +4 -2
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,26 @@ English · [简体中文](CHANGELOG.zh-CN.md)
|
|
|
5
5
|
> This file is in English starting with 0.6.0. Release notes for 0.1 through 0.5.1 are in Chinese in
|
|
6
6
|
> [CHANGELOG.zh-CN.md](CHANGELOG.zh-CN.md). New entries go into both files.
|
|
7
7
|
|
|
8
|
+
## 0.19.0 (2026-11-16)
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **Local extensions (#301)**: user-installed host adapters, several at once, next to the `--host` adapter. They load from `<configDir>/extensions/*.{mjs,cjs}` (sorted by file name) and then profile `extensions` (absolute paths); each gets its own `HostApi` sharing the tool registry, event bus, approval broker slot, resources and warming handlers. Tool names are first-wins, instructions append to the `host` section in load order, the first `approvals.setBroker` wins, the last `cache.onWarmingDecision` wins, status keys merge; a failing extension (load, version mismatch, `create()` error or timeout) only warns and is skipped, and all are disposed in reverse order on exit. Without extensions the system prompt and tool table are unchanged. See `docs/guides/extensions.md`.
|
|
13
|
+
- **`api.commands.register` (host-api 1.4)**: host adapters and extensions register slash commands (`name`, `description`, `args?`, `run(args, ctx)` returning `{ kind: "handled", message? }` or `{ kind: "prompt", text }`), dispatched after built-in commands and before prompt templates in interactive, line and RPC modes, and listed by `/help`, completion and RPC `get_commands` (`source: "extension"`, additive; `RPC_PROTOCOL_VERSION` unchanged). Names that clash with built-ins, aliases or other commands throw. `HOST_API_MINOR` is 4.
|
|
14
|
+
- **Extensions can provide sub-agent runners (#306)**: `runners.provide` / `runners.onDone` now go through one runner registry shared by the host adapter and extensions, so `task`, `/agents` and RPC `get_agents` use extension runners with or without a host adapter (same priority as host-injected ones; the "hosted, do not spawn external CLIs" rule still depends only on the host adapter). Across modules the first provider of an id wins and a later one throws `runner_exists` (a module providing the same id again still replaces its own); `onDone` fires only for the module's own runners; a revoked extension's runners are removed. `HOST_API_MINOR` is unchanged.
|
|
15
|
+
- **Hash trust for extensions**: `trust.json` gains an optional `extensions` section recording `{ path, sha256, trusted, at }`; interactive startup asks once for new or changed files (path and sha256), non-interactive runs skip untrusted extensions with a warning, `--no-trust` loads none, and `trustProject` does not apply. `ama doctor` lists enabled and skipped extensions with hash prefixes and reasons without running their code.
|
|
16
|
+
- **Directory extensions (#305)**: `<configDir>/extensions/<name>/index.{mjs,cjs}` loads next to single-file extensions (sorted together by entry name), and a profile `extensions` entry may be a directory. A directory extension is trusted by the sha256 of its whole tree: regular files sorted by forward-slash relative path, each hashed as relative path plus content with length prefixes, nothing skipped (`.git` included), symlinks followed and hashed by target content (cyclic or dangling links count as unreadable). More than 2000 files, 2000 directories, 32 levels or 50 MiB skips the extension with its own reason. The `trust.json` entry shape is unchanged; a change to any nested file asks again, and the interactive prompt and `ama doctor` mark directories. Single-file behaviour is unchanged.
|
|
17
|
+
|
|
18
|
+
### Fixed
|
|
19
|
+
|
|
20
|
+
- **Extension activation failures are rolled back (#304)**: when an extension's `create()` throws, times out or returns no adapter, its tools (and tool disables), event subscriptions, commands, instructions, status keys, warming handlers, broker (if it owns the slot), runners and resources are revoked, and later registration calls from that module (such as late ones after a timeout) are ignored with a warning. The system prompt and tool table end up byte-identical to running without it. Host adapter failure rules are unchanged.
|
|
21
|
+
|
|
22
|
+
- **Extension slash commands in `-p` and ACP (#303)**: a `-p` prompt or ACP `session/prompt` that is entirely `/name args` and matches an extension command is dispatched inside ama. `handled` prints `message` to stdout and exits 0 (`json` and `stream-json` print one `result` object) or, in ACP, emits it as an `agent_message_chunk` and ends with `end_turn`, with no model turn; `prompt` sends its `text`; a throwing command exits 1 in `-p` and answers an internal error in ACP. ACP `available_commands_update` lists extension commands (`args` as `input.hint`), shadowing same-name prompt templates. In `-p`, only a command-line prompt is dispatched: with piped stdin the text goes to the model unchanged.
|
|
23
|
+
|
|
24
|
+
### Maintenance
|
|
25
|
+
|
|
26
|
+
- **Host API docs**: the minor-version table now says minor 2 and 3 first shipped in 0.16.0 (they were still marked unreleased). The local-extensions design draft became a current-state guide (`docs/guides/extensions.md`, with an English translation).
|
|
27
|
+
|
|
8
28
|
## 0.18.0 (2026-11-15)
|
|
9
29
|
|
|
10
30
|
### Added
|
package/CHANGELOG.zh-CN.md
CHANGED
|
@@ -4,6 +4,26 @@
|
|
|
4
4
|
|
|
5
5
|
> 从 0.6.0 起 [CHANGELOG.md](CHANGELOG.md) 为英文,本文件保留中文记录(0.1–0.5.1 的完整历史在此)。新条目两份都要加。
|
|
6
6
|
|
|
7
|
+
## 0.19.0(2026-11-16)
|
|
8
|
+
|
|
9
|
+
### 新增
|
|
10
|
+
|
|
11
|
+
- **本地扩展(#301)**:用户自己安装、可以有多个的宿主适配器,与 `--host` 适配器并存。从 `<configDir>/extensions/*.{mjs,cjs}`(按文件名排序)与 profile 的 `extensions`(绝对路径)依次加载;每个模块有独立的 `HostApi`,共享工具注册表、事件总线、审批 broker 槽、资源注册表与保温处理器。工具名先到先得,指令按加载顺序追加到 `host` 节,`approvals.setBroker` 第一个设置者生效,`cache.onWarmingDecision` 最后注册者生效,状态键合并;扩展加载失败、版本不等、`create()` 报错或超时只记 warning 并跳过,退出时按加载逆序全部 dispose。没有扩展时系统提示与工具表不变。见 `docs/guides/extensions.md`。
|
|
12
|
+
- **`api.commands.register`(host-api 1.4)**:宿主适配器与扩展注册斜杠命令(`name`、`description`、`args?`、`run(args, ctx)` 返回 `{ kind: "handled", message? }` 或 `{ kind: "prompt", text }`),在内置命令之后、提示模板之前分派,交互、line、RPC 三种模式可用,`/help`、补全与 RPC `get_commands`(`source: "extension"`,只加不改,`RPC_PROTOCOL_VERSION` 不变)列出。与内置命令、别名或已注册命令同名时注册抛错。`HOST_API_MINOR` 为 4。
|
|
13
|
+
- **扩展可注入子 Agent runner(#306)**:`runners.provide` / `runners.onDone` 改走宿主适配器与扩展共用的一张 runner 表,`task`、`/agents` 与 RPC `get_agents` 无论有无宿主适配器都使用扩展的 runner(与宿主注入的同等优先;“有宿主时不自起外部 CLI”的判定仍只看宿主适配器)。不同模块之间同 id 先到先得,后来者抛 `runner_exists`(同一模块再次提供仍替换自己的);`onDone` 只回调本模块的 runner;被撤回的扩展其 runner 一并移除。`HOST_API_MINOR` 不变。
|
|
14
|
+
- **扩展按哈希信任**:`trust.json` 新增可选的 `extensions` 段,记录 `{ path, sha256, trusted, at }`;交互启动对新文件或内容变化的文件询问一次(列出路径与 sha256),非交互运行跳过未信任的扩展并 warning,`--no-trust` 一个都不加载,`trustProject` 不适用。`ama doctor` 列出已启用与被跳过的扩展、哈希前缀与原因,不执行扩展代码。
|
|
15
|
+
- **目录扩展(#305)**:`<configDir>/extensions/<名>/index.{mjs,cjs}` 与单文件扩展一起(按入口名排序)加载,profile 的 `extensions` 也可以给目录。目录扩展按整棵树的 sha256 信任:每个常规文件按正斜杠相对路径排序,相对路径与内容带长度前缀一起计入,不跳过任何项(包括 `.git`),符号链接跟随、按目标内容计入(成环或断开的按读不了处理)。超过 2000 个文件、2000 个目录、32 层或 50 MiB 时跳过该扩展并给出单独的原因。`trust.json` 记录形状不变;任一嵌套文件变化都重新询问,交互询问与 `ama doctor` 标出目录。单文件扩展行为不变。
|
|
16
|
+
|
|
17
|
+
### 修复
|
|
18
|
+
|
|
19
|
+
- **扩展激活失败时撤回已注册内容(#304)**:扩展的 `create()` 抛错、超时或没有返回适配器时,它注册的工具(及工具禁用)、事件订阅、命令、指令、状态键、保温处理器、broker(自己持有槽位时)、runner 与资源都会撤回;该模块之后再调用注册类方法(如超时后迟到的注册)一律忽略并 warning。系统提示与工具表回到没有该扩展时逐字节相同。宿主适配器的失败规则不变。
|
|
20
|
+
|
|
21
|
+
- **`-p` 与 ACP 分派扩展斜杠命令(#303)**:`-p` 的提示或 ACP `session/prompt` 的文本整段形如 `/名 参数` 且命中扩展命令时在 ama 内分派。`handled` 把 `message` 写到 stdout 并退出 0(`json` 与 `stream-json` 给一行 `result` 对象),ACP 下则作为 `agent_message_chunk` 发出并以 `end_turn` 结束,都不开模型回合;`prompt` 改发其 `text`;命令抛错时 `-p` 退出 1,ACP 答复 internal error。ACP 的 `available_commands_update` 列出扩展命令(`args` 作 `input.hint`),遮住同名提示模板。`-p` 只分派命令行给的提示,有管道 stdin 时原样发给模型。
|
|
22
|
+
|
|
23
|
+
### 维护
|
|
24
|
+
|
|
25
|
+
- **宿主 API 文档**:小版本表里 2、3 原标「未发布」,实际在 0.16.0 已发布,已更正。本地扩展设计草案改为现状指南(`docs/guides/extensions.md`,附英文译本)。
|
|
26
|
+
|
|
7
27
|
## 0.18.0(2026-11-15)
|
|
8
28
|
|
|
9
29
|
### 新增
|
package/README.md
CHANGED
|
@@ -231,6 +231,10 @@ pnpm run ci # typecheck, format, dependency, i18n and doc-link chec
|
|
|
231
231
|
AMA_E2E=1 pnpm test:e2e # bundle-level end-to-end tests with the free fake provider
|
|
232
232
|
```
|
|
233
233
|
|
|
234
|
+
`pnpm install` also points `core.hooksPath` at `.githooks`: before `git push`, `scripts/hooks/pre-push.mjs` checks only
|
|
235
|
+
what the push changes, the same way CI picks its jobs, and blocks the push on failure. Skip it once with
|
|
236
|
+
`git push --no-verify`, or `ARMADRA_SKIP_PREPUSH=1` (everything) / `ARMADRA_SKIP_PREPUSH=test,e2e` (named steps).
|
|
237
|
+
|
|
234
238
|
Tests use the scripted `fake` provider, never a real model. Conventions are in [AGENTS.md](AGENTS.md) and
|
|
235
239
|
[CONTRIBUTING](.github/CONTRIBUTING.md). Releases are cut by pushing a `v<version>` tag: CI creates the GitHub Release
|
|
236
240
|
and publishes to npm through trusted publishing.
|
package/README.zh-CN.md
CHANGED
|
@@ -222,6 +222,10 @@ pnpm run ci # 类型检查、格式、依赖 / i18n / 文档链接
|
|
|
222
222
|
AMA_E2E=1 pnpm test:e2e # 用免费的 fake 供应商跑 bundle 级端到端测试
|
|
223
223
|
```
|
|
224
224
|
|
|
225
|
+
`pnpm install` 同时把 `core.hooksPath` 指到 `.githooks`:`git push` 前 `scripts/hooks/pre-push.mjs` 只查这次推送带上的改动,
|
|
226
|
+
挑选规则与 CI 相同,失败就拦下推送。临时跳过用 `git push --no-verify`,或 `ARMADRA_SKIP_PREPUSH=1`(全部)/
|
|
227
|
+
`ARMADRA_SKIP_PREPUSH=test,e2e`(指定步骤)。
|
|
228
|
+
|
|
225
229
|
测试只用脚本化的 `fake` 供应商,不调真实模型。开发约定见 [AGENTS.md](AGENTS.md) 与[贡献指南](.github/CONTRIBUTING.md)。
|
|
226
230
|
发布由推送 `v<版本>` tag 触发:CI 创建 GitHub Release,并经 npm 可信发布推送。
|
|
227
231
|
|