mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-23 08:45:50 +00:00
fix: ACP NewSessionResponse 恢复返回 models 字段
67fdd4ca 那次合规审计误将 models 从响应里移除,但 SDK 0.19.2 的 schema 实际允许 models?: SessionModelState | null(标注 UNSTABLE 仅表示"未来可能变",并非 "agent 禁止返回")。标准 ACP 客户端(Cursor/Zed/VS Code/RCS)依赖此字段填充 模型选择器 —— 缺失会导致客户端 supportsModelSelection=false,模型切换 UI 不可用。 - createSessionMethod: return 里加回 models - sessionLifecycle: getOrCreateSession 两处 return 透传 models(resume/load 路径) - agent.test: 更新过时的 "models omitted for v1 compliance" 断言 Co-Authored-By: glm-5.2 <zai-org@claude-code-best.win>
This commit is contained in:
@@ -325,13 +325,17 @@ describe('AcpAgent', () => {
|
||||
expect(res.sessionId.length).toBeGreaterThan(0)
|
||||
})
|
||||
|
||||
test('returns modes and configOptions (models omitted for v1 compliance)', async () => {
|
||||
test('returns modes, configOptions, and models (clients need models to populate selector)', async () => {
|
||||
const agent = new AcpAgent(makeConn())
|
||||
const res = await agent.newSession({ cwd: '/tmp' } as any)
|
||||
expect(res.modes).toBeDefined()
|
||||
expect(res.configOptions).toBeDefined()
|
||||
// Stable v1 NewSessionResponse does not define `models`
|
||||
expect((res as any).models).toBeUndefined()
|
||||
// SDK 0.19.2 marks NewSessionResponse.models as UNSTABLE but the schema allows it, and
|
||||
// standard clients (Cursor/Zed/VS Code) read it to populate the model selector. Omitting
|
||||
// it forces supportsModelSelection=false on the client.
|
||||
expect(res.models).toBeDefined()
|
||||
expect(Array.isArray(res.models!.availableModels)).toBe(true)
|
||||
expect(typeof res.models!.currentModelId).toBe('string')
|
||||
})
|
||||
|
||||
test('each call returns a unique sessionId', async () => {
|
||||
@@ -865,8 +869,8 @@ describe('AcpAgent', () => {
|
||||
} as any)
|
||||
expect(agent.sessions.has(requestedId)).toBe(true)
|
||||
expect(res.modes).toBeDefined()
|
||||
// models is omitted for v1 compliance
|
||||
expect((res as any).models).toBeUndefined()
|
||||
// resume also returns models so clients can render the selector after reconnect.
|
||||
expect(res.models).toBeDefined()
|
||||
})
|
||||
|
||||
test('reuses existing session when sessionId matches and fingerprint unchanged', async () => {
|
||||
|
||||
Reference in New Issue
Block a user