> ## Documentation Index
> Fetch the complete documentation index at: https://docs.wandb.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# wrapClaudeAgentSdk

> TypeScript SDK reference

# wrapClaudeAgentSdk

▸ **wrapClaudeAgentSdk**\<`T`>(`sdk`): `T`

Manually instrument the `@anthropic-ai/claude-agent-sdk` module.

Reach for this when automatic instrumentation doesn't apply — e.g. a bundler
whose module loading the CJS/ESM hooks can't observe, or an import path they
don't cover. Requires `@anthropic-ai/claude-agent-sdk` >= 0.3.178. Returns a
view of the module whose `query` export is traced; use the returned object
rather than the original import (the SDK's `query` is a getter-only export,
so the original binding can't be patched in place):

#### Type parameters

| Name |
| :--- |
| `T`  |

#### Parameters

| Name  | Type |
| :---- | :--- |
| `sdk` | `T`  |

#### Returns

`T`

`Example`

```ts twoslash theme={null}
// @noErrors
import * as claudeAgentSdk from '@anthropic-ai/claude-agent-sdk';
import { wrapClaudeAgentSdk } from 'weave';

const { query } = wrapClaudeAgentSdk(claudeAgentSdk);
for await (const message of query({ prompt: 'hi' })) {
  // ...traced
}
```

#### Defined in

[src/integrations/claudeAgentSdk.ts:209](https://github.com/wandb/weave/blob/9591aba8a5e77309ee0858e5ba94d31c1bd7e404/sdks/node/src/integrations/claudeAgentSdk.ts#L209)

***
