Claude Agent SDK TypeScript v0.3.327:破坏性变更与弃用
v0.3.327
推荐理由
本次更新包含多处破坏性变更(参数类型收紧、选项校验变严)及明确的 API 弃用。依赖该 SDK 构建 Agent 的开发者必须检查 hook 配置与 query 参数,避免升级后服务中断。
What's changed
变更内容
- Breaking: Changed query(), startup() and prewarm() to refuse options that can't be sent to Claude Code, such as an agent with a circular or BigInt field. Fix the named option.
- Breaking: Changed hook options to require arrays: a hook event's value and a matcher's hooks. A Set, generator, plain object, true or number is now refused.
- Fixed task_started sending Claude Code's own text, such as a task notification, as prompt when a background subagent is woken; such an event now has no prompt
- Fixed Claude reporting a background agent as still running when its permission request had waited on canUseTool for 30 seconds or more
- Reverted 0.3.326's fix for a tool result from an SDK MCP server being lost, or delivered to another call, after a reconnect
- Changed the JSON-RPC id of requests to an SDK MCP server back from a string to a number
- Changed background retries for most MCP servers on other machines, reached by hostname over https, to go on for about a day after a drop, up from at most about 27 minutes
- Deprecated createSdkMcpServer() servers in an agent's mcpServers: ignored with a warning, and other options apply. Move them to top-level mcpServers, which gives the main session their tools.
- Updated to parity with Claude Code v2.1.327
- 破坏性更新:修改 query()、startup() 和 prewarm(),使其拒绝无法发送给 Claude Code 的选项,例如包含循环引用或 BigInt 字段的代理。修复命名选项的问题。
- 破坏性更新:修改 hook 选项,要求使用数组:即钩子事件的值和匹配器的 hooks。现在将拒绝 Set、生成器、普通对象、true 或数字类型。
- 修复了当后台子代理被唤醒时,task_started 会将 Claude Code 自身的文本(如任务通知)作为提示词发送的问题;此类事件现在不再包含提示词。
- 修复了当权限请求等待 canUseTool 超过 30 秒时,Claude 报告后台代理仍在运行的问题。
- 回退了 0.3.326 版本中关于 SDK MCP 服务器工具结果在重连后丢失或传递给其他调用的修复。
- 将对 SDK MCP 服务器的请求的 JSON-RPC id 从字符串改回为数字。
- 更改了通过 https 按主机名访问的其他机器上大多数 MCP 服务器的后台重试策略,连接中断后的重试持续时间延长至约一天,此前最多约为 27 分钟。
- 弃用在代理的 mcpServers 中创建的 createSdkMcpServer() 服务器:将被忽略并显示警告,且其他选项适用。请将其移至顶层 mcpServers,以便为主会话提供其工具。
- 更新至与 Claude Code v2.1.327 保持一致
Update
更新
代码 · 7 行
npm install @anthropic-ai/[email protected]
# or
yarn add @anthropic-ai/[email protected]
# or
pnpm add @anthropic-ai/[email protected]
# or
bun add @anthropic-ai/[email protected]更进一步:量化金融体系
看懂新闻只是起点——沿量化金融路径,把它变成能交付的工程能力