@action-state-group/capsule-viewer

中文文档
0.18.3发布于 2026/11/05Apache-2.0 AND BSD-3-ClauseTypeScriptES Module构建来源已验证近 30 天下载 3404

capsule-viewer page emitter and presentation builder, under the Agent Action Capsule presentation contract

原始使用文档

@action-state-group/capsule-viewer

capsule-viewer's page emitter and presentation builder: they turn an Agent Action Capsule Evidence Bundle into a self-contained HTML page under AAC's presentation contract (spec/presentation-contract-v0.md). The Go twin, github.com/action-state-group/capsule-viewer/go/emitter, emits the same bytes; both are held to shared goldens in go/emitter/testdata.

import {
  buildPresentation,
  emitEvidenceGraphHtml,
} from "@action-state-group/capsule-viewer";

The in-browser renderer (renderEvidenceGraph) ships bundled as dist/evidence-graph.iife.js, for a page's core runtime slot, and the Go module ships the same build as go/pageruntime. Bundle verification comes from @action-state-group/agent-action-capsule. Besides registerPresentation, the runtime's global EvidenceGraph carries the verifier functions a presentation module may call: buildResultRoot, disclosureOf, ed25519Available, verifiedPayload, verifyDisclosureEnvelope and verifyProducerEnvelope. It also carries the History card's witness check, which the module calls and does not run itself: readerAnchorWitness (the snapshot's witness Receipts under the reader's own witness list, with agent-action-capsule's checkAnchorWitnessed) and readerWitnessPolicy and setReaderWitnessPolicy (the reader's list, empty by default, kept in the page's memory only). The History card's signature line asks readerCardSignature, which reads the context's own strict verdict for the card's record and names the key it is signed with on a pass.

The code moved here from agent-action-capsule (agent-action-capsule#281) and keeps its BSD-3-Clause license (LICENSE-BSD-3-Clause); the rest of the package is Apache-2.0 (LICENSE).

Tuning the contract-report module's words

The contract-report module (src/contract-report.ts) resolves on contract-report/v1 (agent-action-capsule spec/contract-report-v1.md), registered in place of aac.builtin.result-contract-report/v0. It draws one of two layouts -- lines (the Outcomes report) or groups (the EU AI Act Results) -- each with its own bundled default wording pack (src/wording/contract-report-outcomes.en.json, src/wording/contract-report-eu-ai-act.en.json). A host passes its own pack as the page's wording; its entries replace the default pack's, entry by entry.

The module's own keys sit under card.* (shared by both layouts: the front block, dating, the proofs), lines.* (the Outcomes report only) and groups.* (the EU AI Act Results only) -- plus the shared prov.*, chat.*, case.* and judge.* prefixes. These are never contract-report/v1 section 3 keys: a pack cannot use them to set something section 3 owns, and the module never uses a section 3 prefix for its own concepts. card.pf.* is the per-claim proofs line (card.pf.assurance, card.pf.assurance.line, card.pf.wording, card.pf.wording.refused, ...); card.wording.refused is the visible notice a refused host layer draws.

The section 3 keys this module reads, and where each shows:

KeyShows
report.titleThe card's heading (aliased onto lines.title / groups.kicker).
report.summaryOne line under the title, drawn only when set (reportSummary, report-levels.ts).
group.<segment>.titleA group's heading -- the part of a row's requirement_ref before its first . (EU AI Act obligation headings; the Outcomes report's check groups).
row.<requirement_ref>.labelA row's name, in place of the producer's label or the id made readable.
row.<requirement_ref>.detailA row's explanation, drawn beside its name when set.
row.<requirement_ref>.not_evaluableThe note shown when a row's claims are not evaluable, in place of the module's own note.
verdict.met, .not_met, .not_evaluable, .out_of_scopeAliased onto the layout's own verdict words (lines.verdict.* / groups.verdict.*, and the Outcomes proofs' lines.pf.verdict.*): every pill and cell that draws that verdict.
tier.recomputed, .judgedAliased onto the layout's own tier badge words.
grade.self-attested, .witnessed, .countersignedEach claim's assurance line in its proofs (assuranceRow); locked, like sufficiency.* and status.*.
sufficiency.satisfied, .gap, .insufficient, .unknownThe same assurance line.
status.<value>The same assurance line (the claim's carrier status, lowercased).

A word with no entry, in any layer, is shown as its raw token or identifier -- nothing is guessed. The default layer always words the title (lines.title / groups.kicker, which report.title aliases). Until the default EU pack carries group.* and row.* words, the EU card names obligations and tests with the producer's labels, in italics as the producer's text.

A Result whose claims the card cannot place one by one (a requirement judged more than once in one conversation, claims under more than one contract, claims of another type or id shape) is drawn as the generic Result page, with a note, so no claim is merged or left out.

A Result that opts into contract-report/v1 and carries neither Outcomes nor EU AI Act data draws the module's generic view (generic-report-view.ts): rows from its claims, groups from the requirement_ref prefix, every tally with its denominator. Its words are wording/contract-report-generic.en.json under a host pack's report.*, row.*, group.* and the other section 3 keys.

The single-contract rule. row.* and group.* apply only when every claim in the Result cites the same contract_ref (citesOneContract, contract-report.ts): a pack is written for one contract, and two contracts can reuse one requirement_ref for different requirements. A Result that cites more than one contract is drawn as the generic Result page (see above), so the rule is a second guard for callers that draw a card directly.

The refused-layer rule. Each wording layer is checked on its own (digest, shape, then fit against this module's words). A layer that does not check is refused: it contributes no words, and the card draws with the default layer alone, a visible card.wording.refused line (data-wording="refused") naming the reason, and a card.pf.wording.refused proofs line naming the refused digest and the base layer that was applied instead. The presentation builder (buildPresentation, presentation-builder.ts) still refuses to write a page whose pack does not fit -- the graceful degrade above is only the live renderer's behaviour.

Releases follow RELEASING.md.

版本与发布记录

@action-state-group/capsule-viewer 共发布 21 个版本,首次发布于 2026/10/16;过去 12 个月发布了 21 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.18.3latest2026/11/051 天前
0.18.22026/11/042 天前
0.18.12026/11/042 天前
0.18.02026/11/033 天前
0.17.02026/11/033 天前
0.16.02026/11/033 天前

关于 @action-state-group/capsule-viewer 的常见问题

@action-state-group/capsule-viewer 是什么?

capsule-viewer page emitter and presentation builder, under the Agent Action Capsule presentation contract

如何安装 @action-state-group/capsule-viewer?

在项目目录运行 npm install @action-state-group/capsule-viewer,或使用 pnpm add / yarn add / bun add。

@action-state-group/capsule-viewer 支持 TypeScript 吗?

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

@action-state-group/capsule-viewer 支持 ESM 还是 CommonJS?

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

@action-state-group/capsule-viewer 需要什么版本的 Node.js?

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

@action-state-group/capsule-viewer 可以商用吗?

@action-state-group/capsule-viewer 使用 Apache-2.0 AND BSD-3-Clause 许可。声明的许可为 Apache-2.0 AND BSD-3-Clause,请阅读许可原文确认使用条件。以上为概括,不构成法律意见,请以许可原文为准。

@action-state-group/capsule-viewer 的下载量有多少?

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

@action-state-group/capsule-viewer 还在维护吗?

最新版本 0.18.3 发布于 2026/11/05(1 天前);至今共发布 21 个版本,其中过去 12 个月发布了 21 个;首次发布于 2026/10/16。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。