-
Notifications
You must be signed in to change notification settings - Fork 22
Open
Description
问题描述
在 Windows 环境下运行单元测试时,遇到 ENOENT: no such file or directory, mkdir 错误,无法创建
目录。
复现步骤
- 在 Windows 环境下克隆项目
- 安装依赖:
npm install - 运行单元测试:
npm run test:unit - 观察到多个测试失败,报告无法创建目录
根本原因
Windows 文件系统不允许文件/目录名包含冒号 :,但代码中多处使用冒号作为标识符分隔符:
- Agent ID:
agt:01KCGMTE419G1ED239ZJ2AKNW9 - Fork ID:
fork:1765790723759 - Snapshot ID:
sfp:0 - Checkpoint ID:
agentId:timestamp
这些标识符被用作目录/文件名,导致在 Windows 上通过 Node.js 创建目录时失败。
影响范围
- ❌ Windows 用户无法运行测试
- ❌ Windows 用户使用 SDK 时可能遇到运行时错误
- ✅ Linux/macOS 用户不受影响(这些系统允许文件名包含冒号)
解决方案
已在分支 fix/windows-compatibility 中修复,将所有标识符中的冒号 : 替换为连字符 -:
agt:→agt-fork:→fork-sfp:→sfp-:${Date.now()}→-${Date.now()}
同时修复了相关的 TypeScript 编译错误和测试适配问题。
测试结果
✅ 所有 58 个单元测试在 Windows 环境下通过 (100%)
Breaking Change
- 旧的持久化数据(使用冒号格式的 Agent ID)无法直接与新版本兼容
- 建议作为主版本更新发布 (v3.0.0)
相关 PR
#[PR 编号] - 等待创建
环境信息:
- 操作系统: Windows 10/11
- Node.js 版本: v22.14.0
- SDK 版本: 2.7.0
📊 修复详情
修改的文件 (14个):
- src/utils/agent-id.ts - Agent ID 格式
- src/core/agent.ts - Agent ID 和 Fork ID
- src/utils/session-id.ts - Fork ID 和 Snapshot ID
- src/core/checkpointer.ts - Checkpoint ID
- src/core/checkpointers/file.ts - Checkpoint ID
- src/core/checkpointers/redis.ts - Checkpoint ID
- src/tools/mcp.ts - TypeScript 类型错误
- src/tools/tool.ts - TypeScript 类型错误
- src/tools/type-inference.ts - TypeScript 类型错误
- tests/unit/tools/todo.test.ts - 测试框架适配
- tests/helpers/fixtures.ts - 测试路径修复
- examples/03-room-collab.ts - 示例代码更新
- examples/nextjs-api-route.ts - 示例代码更新
- tests/integration/collaboration/room-collab.test.ts - 集成测试更新
Metadata
Metadata
Assignees
Labels
No labels