@contraagent/ui

中文文档
0.10.1发布于 2026/10/31MITTypeScriptES Module构建来源已验证近 30 天下载 3159

Web components for the contraagent monitor: transcripts, task tables, the journal, plans, contracts. Framework-free (Lit), typed by @contraagent/api

原始使用文档
文档目录4 节
  1. Getting it
  2. The views
  3. Use it from a checkout
  4. Documentation

@contraagent/ui

The contraagent monitor and each of its views as web components (Lit): <ca-monitor> is the whole monitor, and every view is an element of its own, from the transcript to the timeline. An element renders the data you set on its properties and reports what the reader asks for as an event; it never fetches unless it is one of the few that tail a live feed. They work in any page or framework. The data comes from @contraagent/api; the generic parts they are built from (design tokens, themes, primitives, cae-* elements) are @contraagent/elements, a package of its own for pages that need no contraagent data.

The words used here (run, task, attempt, round, element, view route, ...) are contraagent's, each with one meaning: contraagent docs concepts in the Python package.

Getting it

Every monitor serves the kit as one ES module at /app.js: the elements register themselves, and the client, store and helpers are its exports. Start the monitor with --cors-origin naming your page's origin.

<script type="module" src="http://127.0.0.1:8787/app.js"></script>
<ca-monitor base-url="http://127.0.0.1:8787" history="memory"></ca-monitor>

Install the package from the npm registry, which brings @contraagent/api and @contraagent/elements with it:

npm install @contraagent/ui

A checkout of the repository packs its own version (Use it from a checkout). In a page with a build step, import the package once: every element registers itself. Lit and Lit Localize are peer dependencies. Importing changes nothing else in the page: call configureLocales() for the languages and adoptThemes(document) for the themes, or let <ca-monitor> call both when it connects.

import '@contraagent/ui';
import { configureLocales } from '@contraagent/ui/localize';
import { adoptThemes } from '@contraagent/elements/themes';

configureLocales();
adoptThemes(document);

One view alone is a subpath; it registers its ca-* elements and the cae-* elements they render, and nothing of the other views:

import '@contraagent/ui/transcript'; // <ca-transcript>

The views are monitor, overview, pipeline-graph, task-view, transcript, task-table, journal-table, contracts, definitions, kpis, timeline and procs. adapters, words, core and localize hold functions and register nothing. @contraagent/ui/bundle is one self-contained, minified module (Lit and the translations included) for pages without a build step.

The views

Each view over a run of the demo pipeline, in the contraagent Light theme.

On the documentation site, each view is live in place of its screenshot, fed with the same run.

<ca-monitor>, the whole monitor (monitor): the run's header, its tabs, and the overview.

The monitor's overview of a finished run: 44 of 44 tasks done, no problems, all outputs passed, and the pipeline graph of a review loop

<ca-pipeline-graph> (pipeline-graph): the flow by function and loop, a mark per task.

The pipeline graph of a review loop: prepare, summarize, a loop of score, review and revise, then write_note, every task done

<ca-task-view> (task-view): one task's agent sessions, transcript, input, output and definition.

The task view of write_note · alpha, done after 1 correction: the first agent session's transcript and the two checks its output failed

<ca-journal-table> (journal-table): every attempt with its outcome, coding agent, model, tokens, cost and time.

The history of the summarize tasks: 8 attempts, all done, one with 1 correction and one after a model switch

<ca-task-table> (task-table): every task with its status.

The tasks of kind summarize: 8 tasks, all done

<ca-contracts> (contracts): every checked file and its result.

The outputs of a run: 44 checked files, all passed

<ca-definitions> (definitions): each kind's interface and its plugin's files.

The task definitions of a run: each kind with its role or Python, its tasks and attempts; for review, its plugin directory, output and role file

<ca-kpis> (kpis): the run's totals. A tile that counts tasks or attempts is a link to them, and no-highest-cost leaves the kind with the highest cost out of the cost tile, for a page that shows the cost by kind beside it.

The totals of a run: tasks, attempts, cost, tokens, failed attempts, not started, agent session time, retries, corrections and model switches

<ca-timeline> (timeline): each attempt as a bar on a time axis, a lane per kind.

The timeline of a run: the attempts of each kind as bars over 23 seconds

Use it from a checkout

In the repository's web/ (Node 22, pnpm through corepack enable):

pnpm install && pnpm tarballs

pnpm tarballs builds @contraagent/api, @contraagent/elements and @contraagent/ui and writes one .tgz file for each to web/tarballs/. A tarball names the others it depends on by their absolute path there. Then, in your project, install the three, with npm or pnpm:

npm install <checkout>/web/tarballs/*.tgz
pnpm add <checkout>/web/tarballs/*.tgz

Documentation

  • Embed the monitor: the whole monitor inside a page or an application of your own.
  • Live data: elements fed by the client, the live feeds and the store.
  • Events and the view route: what elements ask for, and how the monitor keeps the reader's place.
  • Theming: colours and fonts as --ca-* custom properties.
  • Languages: English and Japanese, and how to add a language.

Every element's properties, attributes and events are in custom-elements.json, generated from the sources with the package.

A ::code line quotes a file of the package; the documentation site shows the quoted lines in place. The same declarations, with their comments, are in dist/**/*.d.ts.

版本与发布记录

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

版本发布日期距今
0.10.1latest2026/10/3110 天前
0.10.02026/10/3111 天前
0.9.22026/10/2516 天前
0.9.12026/10/2517 天前
0.9.02026/10/2417 天前
0.8.12026/10/2318 天前

关于 @contraagent/ui 的常见问题

@contraagent/ui 是什么?

Web components for the contraagent monitor: transcripts, task tables, the journal, plans, contracts. Framework-free (Lit), typed by @contraagent/api

如何安装 @contraagent/ui?

在项目目录运行 npm install @contraagent/ui,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:lit(^3.3.3)、@lit/localize(^0.12.2)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@contraagent/ui 支持 TypeScript 吗?

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

@contraagent/ui 支持 ESM 还是 CommonJS?

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

@contraagent/ui 可以商用吗?

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

@contraagent/ui 的下载量有多少?

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

@contraagent/ui 还在维护吗?

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