@cueloop/adapters

中文文档
0.1.0-alpha.115发布于 2026/11/03Apache-2.0ES Module构建来源已验证近 30 天下载 3005

cueloop adapters for coding agents: Claude Code, pi, and Codex

原始使用文档
文档目录6 节
  1. Controller contract
  2. Thread surface
  3. Message delivery
  4. Thread agent harness prototype
  5. Thread agent diagnostic routing
  6. Owner-hosted durable conversations

Harness adapters

Cueloop owns the Thread and review lifecycle. Claude Code, Codex, and pi only connect their session lifecycle and native messaging to it.

Harness lifecycle event
        |
        v
Harness adapter
  - identify and bind the harness session
  - submit or revise the artifact
  - open cueloop threads
  - subscribe for Messages
  - send Messages through the harness
        |
        v
Shared cueloop Thread + UX core
  - canonical Thread state
  - review lifecycle
  - Message routing and durable delivery
        |
        v
Existing cueloop TUI
  - thread panel: plan, reply, prototype
  - changes panel: diff, review

Controller contract

createHarnessThreadController().openWorkflow is the entry point for all six workflows. Plan, reply, and prototype submit Markdown to the thread panel. Diff submits a working-tree patch to the changes panel. Review imports a PR diff, opens the changes panel, and posts its Message to the forge. Refine analyzes the Thread corpus before submitting agent-drafted proposals as a plan Thread. Review and refine are workflows, not new artifact types.

The daemon alone owns Thread state, revisions, annotations, Messages, bindings, and deliveries. Adapters must not persist a second review model, parse their own copy of an artifact, or render a harness-specific review UI. A new adapter implements session identity, lifecycle interception, Thread submission through the controller, native Message injection, and reload reconciliation. It uses the same TUI, controller contract tests, and Message ID for duplicate suppression. Claude Code uses the required Mod API, Codex uses plugin hooks and MCP, and pi uses its extension API.

Thread surface

The surface port opens the built-in panel. Terminal and multiplexer launch implementations belong to their integrations.

createTerminalThreadSurfacePort selects Herdr when nested inside Ghostty and otherwise uses Ghostty on macOS. Personal config accepts [integrations.herdr] thread_surface = "tab" | "pane" | "none"; tab is the default. Ghostty accepts [integrations.ghostty] thread_surface = "tab" | "pane" | "window" | "none", also defaulting to tab. Repository config cannot trigger terminal automation. A pane opens on the right at 50 percent width. Native handles live in daemon adapter scratch, not in the Thread. If opening fails, the controller leaves the Thread pending and returns Open cueloop threads: cueloop <thread-id> to the harness.

Message delivery

The daemon persists bindings and deliveries outside the Thread. It routes a Message to the submitting binding by default and retries an unacknowledged delivery after restart. Once an approved Message is acknowledged, the same plan may pass through the shared controller unchanged one time. An adapter sends the Message through its harness API, deduplicates by Message ID with createDeliveredMessageStore, then acknowledges the delivery. Native injection uses the Message ID as an idempotency key when the harness supports one. Forge post-back also needs a Message ID journal. A crash between an external side effect and recording the ID can repeat it; delivery itself is at least once. The same Thread can later route Messages to another bound harness without changing the TUI.

Thread agent harness prototype

The fx harness adapter (src/fx/harness.ts) translates ACP into the schema's AgentHarnessAdapter contract. The CLI supplies it to the daemon; the daemon never imports this package. Provider session IDs stay paired with their adapter ID. See the prototype instructions for opt-in development and the lifecycle experiment for checked recovery laws. Harness-advertised model/reasoning choices and cueloop tool calls pass through the same contract; JSON tool arguments are parsed at the daemon boundary. Submission laws check queueing, immutable accepted input, and retry behavior.

Thread agent diagnostic routing

Harness adapters emit AgentHarnessEvent. routeHarnessOutput sends diagnostic notices to a private bounded log at <cueloop-home>/thread-agents/<encoded-thread-id>.diagnostics.ndjson, outside Thread history and subsequent model context. Unknown diagnostic severities stay intact. An advisory notice, including one with severity error, does not determine the turn outcome; prompt results and transport failures still do.

The fx adapter advertises ACP v1 session notices and handles structured notice updates. After observing a structured notice, it preserves assistant chunks without text matching for that connection. The inspected fx 0.0.12 transport does not supply notice provenance. FxLegacyStartupMessages is an isolated fallback for its known complete startup lines, with at most 128 tracked IDs and 32 KiB per pending notice. It never classifies an entire message ID: later HTTP errors under the same ID remain visible. Changed or unfinished notice wording is preserved. An exact assistant quotation of a legacy notice can still be misclassified; upstream structured provenance is required to remove that ambiguity.

Pi consumers can import parsePiHarnessOutput from @cueloop/adapters/pi/harness-output at their RPC or SDK boundary. It validates frames, retains assistant text without prefix matching, separates notices and extension errors, and distinguishes cancellation, failure, activity, and agent_settled. Callers assign message identities and track turn outcomes across retries; neither a prompt acknowledgement nor agent_end means the turn settled. This provides the output normalization seam, not a new pi subprocess harness.

Owner-hosted durable conversations

New Thread agents use the Pi Durable adapter. One Harness owns each Thread's conversation in <cueloop-home>/pi-conversations/<session-id>. Models, credentials, durable Storage, and ExecutionEnv are separate host dependencies. The supplied environment runs on the owner machine; it is not a sandbox. Existing fx conversations retain their adapter and session identity. Set CUELOOP_AGENT_HARNESS=fx to select fx for new conversations.

The Pi adapter reads the owner's ~/.pi/agent/auth.json credentials and the provider's supported environment credentials. Refreshes are persisted in cueloop's private model-credentials.json, leaving the imported source unchanged. Credentials are never included in share blobs or relay frames. Provider login remains a local operation.

With [experimental] herdr_acp = true and a user-installed hc 0.1.15 or newer, the fx ACP process is started inside a herdr-core terminal. The daemon speaks ACP through a private relay socket, so a daemon restart can reattach to an in-flight prompt and let it finish. The flag defaults off. A missing or older hc keeps the ACP process as a child of the daemon. cueloop does not install or update hc. Set CUELOOP_HERDR_ACP=0 to keep that child process even when the flag is on. When HC_SESSION is set, cueloop uses that herdr session. Otherwise it uses the session name cueloop, so agent terminals stay out of the default session. Removing the Thread shuts the relay down. With no client attached, a finished relay exits after 60 seconds (HERDR_ACP_IDLE_MS) and an in-flight prompt is kept for 10 minutes (HERDR_ACP_ABANDON_MS) so a restarted daemon can reattach. Finished hc terminals are removed. The relay transcript is mode 0600.

With [experimental] thread_agent = true, the share wizard offers Allow agent messages, off by default. Enabled collaborators use the owner's conversation and model account. Ctrl+Enter submits agent input; Option+Enter keeps comments inline and editable. A disabled link still supports ordinary comment threads.

The gateway persists input before showing it queued and keeps the request until the owner daemon acknowledges a persisted operation receipt. If the owner is disconnected, the artifact stays readable and the Thread shows Owner offline. An authenticated owner connection receives requests over cueloop-agent SSH, merges their annotations into the local Thread, and streams agent state back. Reconnect reuses operation IDs; changed payloads cannot reuse an accepted ID. The gateway runs no model or workspace tools. Hosting execution elsewhere would require supplying Storage, Models and an isolated ExecutionEnv on that host.

版本与发布记录

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

版本发布日期距今
0.1.0-alpha.115latest2026/11/037 天前
0.1.0-alpha.1142026/11/029 天前
0.1.0-alpha.1132026/11/029 天前
0.1.0-alpha.1122026/11/029 天前
0.1.0-alpha.1112026/11/0110 天前
0.1.0-alpha.1102026/10/2516 天前

关于 @cueloop/adapters 的常见问题

@cueloop/adapters 是什么?

cueloop adapters for coding agents: Claude Code, pi, and Codex

如何安装 @cueloop/adapters?

在项目目录运行 npm install @cueloop/adapters,或使用 pnpm add / yarn add / bun add。

@cueloop/adapters 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/cueloop__adapters 是否存在。

@cueloop/adapters 支持 ESM 还是 CommonJS?

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

@cueloop/adapters 需要什么版本的 Node.js?

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

@cueloop/adapters 可以商用吗?

@cueloop/adapters 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@cueloop/adapters 的下载量有多少?

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

@cueloop/adapters 还在维护吗?

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