@agent-relay/harnesses

中文文档
17.2.1发布于 2026/11/07Apache-2.0TypeScriptES Module构建来源已验证近 30 天下载 5.8万

Pre-built harness definitions for Agent Relay.

原始使用文档
文档目录4 节
  1. Runtime selection
  2. Native harness attach
  3. Observability
  4. Local-host security and troubleshooting

@agent-relay/harnesses

Pre-built harness definitions for local coding agents. Requires Node.js 22 or newer.

Use this package with @agent-relay/harness-driver when Agent Relay should create or supervise managed sessions.

Runtime selection

Claude Code, Codex, and OpenCode offer both an official AI SDK native harness runtime and the existing PTY runtime. Their adapters begin as experimental, so auto continues to select PTY until each adapter passes its promotion gates.

import { claude } from '@agent-relay/harnesses';

await claude.create({ relay }); // auto: PTY while the adapter is experimental
await claude.create({ relay, runtime: 'native' }); // explicit native harness runtime
await claude.create({ relay, runtime: 'pty' }); // explicit terminal runtime

Runtime selection is final before the session starts. Relay does not switch a running session between PTY and AI SDK.

HarnessAI SDK adapterPTYInitial selection
Claude Code@ai-sdk/[email protected]yesPTY; native is explicit and experimental
Codex@ai-sdk/[email protected]yesPTY; native is explicit and experimental
OpenCode@ai-sdk/[email protected]yesPTY; native is explicit and experimental
Pi@ai-sdk/[email protected]noexplicit experimental native
Deep Agents@ai-sdk/[email protected]noexplicit experimental native
DevinnoneyesPTY with approval prompts preserved
Other built-insnoneyesPTY

See Devin CLI setup and limitations for authentication, workspace trust, and isolated MCP configuration.

Pi and Deep Agents require runtime: 'native' while experimental. Deep Agents does not advertise manual compaction, and stopping its current adapter does not preserve in-memory conversation.

Harness execution is pty or native. The broker may internally wrap native harnesses and attached app servers as headless processes, but headless is not an observability mode. Both execution paths publish the same normalized AgentEvent contract.

Native sessions receive authenticated Agent Relay host tools and collaboration instructions at startup. They can discover agents and channels, check or search messages, send DMs, post to channels, and reply to threads without relying on a provider-global MCP configuration or extra prompting from the user.

Native harness attach

AI SDK sessions expose agent-event history and live events instead of terminal bytes:

agent-relay node agent attach my-agent --mode view
agent-relay node agent attach my-agent --mode drive
agent-relay node agent attach my-agent --mode view --json
agent-relay node agent attach my-agent --mode view --reasoning --diagnostics

view is read-only. drive sends each input line after broker acknowledgement; /interrupt, /approve <id>, /reject <id>, and /detach are local controls. passthrough is unavailable because a native harness session has no terminal byte stream. --json writes normalized NDJSON to stdout. Reasoning and diagnostics stay hidden unless requested.

Observability

The AI SDK stream is Relay's reference observability profile. Relay publishes portable agent events and the activities starting, thinking, typing, using_tool, waiting, idle, and error. Every event carries its source and either exact or inferred fidelity.

PTY sessions use the same capability matrix. Today the broker provides exact startup and runtime failure plus inferred busy and idle boundaries. Signals that terminal bytes cannot prove, including reasoning, text blocks, tools, approvals, files, and compaction, are reported as unavailable rather than guessed.

Another Relay application can inspect events successfully accepted into Relaycast's durable agent log through the messaging surface:

const activity = await relay.messaging.sessionEvents?.list('my-agent', {
  type: 'activity.changed',
  limit: 100,
});

The broker owns PTY publication for every spawn surface. A managed create({ relay }) call additionally mirrors those broker events into listeners on that local AgentRelay instance.

Hosted publication is operational observability, not a lossless audit ledger. The broker preserves order through a bounded publisher queue and logs queue, timeout, and Relaycast failures locally; events can be absent during a sustained outage or broker crash.

Local-host security and troubleshooting

The AI SDK local-host provider is a process and filesystem lifecycle boundary, not an operating-system sandbox. It rejects lexical traversal and static symlink escapes on a best-effort basis for adapter file operations, holds bridge ports on loopback until handing them to the adapter process, and terminates only child processes it started. Concurrent filesystem mutation by another process is outside this boundary, so the path guard is not TOCTOU-safe and must not be used as isolation for untrusted code.

The local-host AI SDK runtime currently supports macOS and Linux. On Windows, use the PTY runtime; an explicit native selection fails with a typed platform error instead of attempting POSIX adapter bootstrap commands. Preflight checks the platform, Node.js 22, pnpm, workspace access, cache access, and loopback port allocation. If startup fails, verify those commands and permissions first. Bootstrap work is cached by stable adapter identity under the runtime cache; deleting unrelated workspace files is never part of cleanup.

Adapter upgrades must keep the @ai-sdk/[email protected] family coherent and pass the registry, lifecycle, agent-event replay, observability, real-CLI, and 100-cycle soak contracts before changing an adapter's rollout state.

版本与发布记录

@agent-relay/harnesses 共发布 156 个版本,首次发布于 2026/06/04;过去 12 个月发布了 156 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
17.2.1latest2026/11/07今天
17.2.02026/11/071 天前
17.1.02026/11/061 天前
17.0.02026/11/052 天前
16.0.02026/11/043 天前
15.1.12026/11/044 天前

其他发布通道:next → 15.0.2-next.0。

关于 @agent-relay/harnesses 的常见问题

@agent-relay/harnesses 是什么?

Pre-built harness definitions for Agent Relay.

如何安装 @agent-relay/harnesses?

在项目目录运行 npm install @agent-relay/harnesses,或使用 pnpm add / yarn add / bun add。

@agent-relay/harnesses 支持 TypeScript 吗?

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

@agent-relay/harnesses 支持 ESM 还是 CommonJS?

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

@agent-relay/harnesses 需要什么版本的 Node.js?

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

@agent-relay/harnesses 可以商用吗?

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

@agent-relay/harnesses 的下载量有多少?

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

@agent-relay/harnesses 还在维护吗?

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