Claude Agent SDK TypeScript v0.3.317:移除
v0.3.317
推荐理由
v0.3.317 移除了 FileReadOutput 的 file_unchanged 变体,这是明确的破坏性接口变更。依赖该 SDK 构建 Agent 流程的开发者必须检查类型定义与逻辑分支,避免升级后编译报错或行为异常。
What's changed
变更内容
- Added onFailure to hook matchers: with "block", a hook that throws or returns invalid output blocks the action
- Added a warning message in the stream when a hook callback fails
- Added a session_writes_lost system message, sent after the last result when a full disk or disk quota kept the CLI from saving the session transcript or ~/.claude.json
- Added initialize_not_first to startup_failure_reason, for a --await-initialize launch whose first stdin line is not the initialize request
- Added task.description to the TaskCreate tool's tool_use_result: the description the task was created with
- Added lossy to readFile() utf-8 answers: true when decoding replaced bytes that are not valid UTF-8
- Removed the file_unchanged variant of FileReadOutput in sdk-tools.d.ts; a repeated Read now returns the file content
- Fixed setMcpServers closing a folder's .mcp.json and local-scope MCP servers in sessions started with prewarm() and bound with SpareProcess.claim()
- Updated to parity with Claude Code v2.1.317
- 为 hook 匹配器添加了 onFailure:使用 "block" 时,抛出异常或返回无效输出的 hook 将阻止 action 执行
- 在流中添加了 hook 回调失败时的警告消息
- 添加了 session_writes_lost 系统消息,当磁盘已满或达到配额导致 CLI 无法保存会话记录或 ~/.claude.json 时,该消息会在最后一条结果之后发送
- 在 startup_failure_reason 中添加了 initialize_not_first,用于处理 --await-initialize 启动时第一条 stdin 行不是 initialize 请求的情况
- 在 TaskCreate 工具的 tool_use_result 中添加了 task.description:创建任务时使用的描述
- 在 readFile() 的 utf-8 响应中添加了 lossy 字段:当解码过程中替换了非有效 UTF-8 字节时,该值为 true
- 从 sdk-tools.d.ts 中移除了 FileReadOutput 的 file_unchanged 变体;重复读取现在直接返回文件内容
- 修复了 setMcpServers 关闭文件夹 .mcp.json 和本地作用域 MCP 服务器的问题,这些问题出现在使用 prewarm() 启动并绑定到 SpareProcess.claim() 的会话中
- 更新以与 Claude Code v2.1.317 保持同步
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]更进一步:量化金融体系
看懂新闻只是起点——沿量化金融路径,把它变成能交付的工程能力