@astropods/adapter-claude-agent-sdk

中文文档
0.6.6发布于 2026/11/04Apache-2.0TypeScriptES Module构建来源已验证近 30 天下载 3909

Drop-in replacement for @anthropic-ai/claude-agent-sdk that adds OpenTelemetry instrumentation for Astro deployments.

原始使用文档
文档目录5 节
  1. Installation
  2. Usage
  3. API
  4. query(options)
  5. Troubleshooting

@astropods/adapter-claude-agent-sdk

Drop-in replacement for @anthropic-ai/claude-agent-sdk that adds OpenTelemetry instrumentation for Astro deployments. Re-exports the entire SDK surface with query() instrumented, so query() calls, sub-agent steps, tool calls, and model invocations flow into the Astro dashboard automatically.

Installation

bun add @astropods/adapter-claude-agent-sdk

Remove any direct dependency on @anthropic-ai/claude-agent-sdk. The adapter is versioned independently and tracks @anthropic-ai/claude-agent-sdk ^0.3.142 — patches and minors within that range are supported.

Usage

Point existing imports at the adapter:

import { query, tool, AbortError, type SDKMessage } from "@astropods/adapter-claude-agent-sdk";

The full Claude Agent SDK surface is available unchanged; query() is patched to emit OpenTelemetry spans.

When deployed on Astro, OTEL_EXPORTER_OTLP_ENDPOINT is injected automatically and traces appear on the agent's detail page within ~30 seconds. The variable is unset during local development, so instrumentation is skipped there.

API

This package re-exports @anthropic-ai/claude-agent-sdk in full. Only query is wrapped; every other binding (tool, AbortError, SDKMessage, etc.) is passed through verbatim, so new SDK exports flow through automatically.

query(options)

Same signature as the upstream query(). Each call opens a parent span and emits child spans for sub-agent steps, tool calls, and model invocations. If OTEL_EXPORTER_OTLP_ENDPOINT is unset, instrumentation is a no-op and behavior is identical to the upstream SDK.

Troubleshooting

If traces don't show up in the dashboard:

  • Confirm OTEL_EXPORTER_OTLP_ENDPOINT is present in the deployed container.
  • Confirm every import of @anthropic-ai/claude-agent-sdk in your codebase has been switched to @astropods/adapter-claude-agent-sdk.
  • Check the agent container logs for OpenTelemetry export errors.

版本与发布记录

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

版本发布日期距今
0.6.6latest2026/11/043 天前
0.6.6-next.4next2026/11/043 天前
0.6.52026/11/034 天前
0.6.5-next.112026/11/034 天前
0.6.5-next.102026/11/025 天前
0.6.42026/10/1325 天前

关于 @astropods/adapter-claude-agent-sdk 的常见问题

@astropods/adapter-claude-agent-sdk 是什么?

Drop-in replacement for @anthropic-ai/claude-agent-sdk that adds OpenTelemetry instrumentation for Astro deployments.

如何安装 @astropods/adapter-claude-agent-sdk?

在项目目录运行 npm install @astropods/adapter-claude-agent-sdk,或使用 pnpm add / yarn add / bun add。

@astropods/adapter-claude-agent-sdk 支持 TypeScript 吗?

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

@astropods/adapter-claude-agent-sdk 支持 ESM 还是 CommonJS?

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

@astropods/adapter-claude-agent-sdk 可以商用吗?

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

@astropods/adapter-claude-agent-sdk 的下载量有多少?

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

@astropods/adapter-claude-agent-sdk 还在维护吗?

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