mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-25 09:35:52 +00:00
feat: 实现 ACP session/delete + message-id 两个 UNSTABLE RFD
session/delete(rfds/session-delete.mdx):
- sessionCapabilities.delete: {} 能力广告(类型增强写入,SDK 0.19.0 早于该 RFD)
- extMethod 钩子路由 session/delete → unstable_deleteSession
- 硬删除 .jsonl 文件,ENOENT 视为成功(幂等)
- 未知方法抛 RequestError.methodNotFound(JSON-RPC -32601)
message-id(rfds/message-id.mdx):
- agent_message_chunk / user_message_chunk / agent_thought_chunk 携带 messageId
- forwardSessionUpdates 维护 currentAgentMessageId,lazy 生成 UUID
- streaming text/thinking chunks 与最终 assistant message 共享同一 ID
- replayHistoryMessages per-message 生成 UUID
- PromptRequest.messageId → PromptResponse.userMessageId 回显
- tool_call / plan / subagent 不带 messageId(spec 仅规定 chunk 类型)
测试:ACP service 从 176 → 191 (+15)
- bridge.test.ts: +9 个 message-id 测试
- agent.test.ts: +6 个 session/delete + userMessageId 测试
- 总测试 5851 → 5866,全通过
审计文档:新增附录 A.2 记录两个 UNSTABLE RFD 实现状态
Co-Authored-By: glm-5.2 <zai-org@claude-code-best.win>
This commit is contained in:
@@ -40,6 +40,10 @@ export function toAcpNotifications(
|
||||
parentToolUseId?: string | null
|
||||
cwd?: string
|
||||
streamingActive?: boolean
|
||||
// Per message-id.mdx RFD: UUID identifying the message these chunks
|
||||
// belong to. Only attached to agent_message_chunk / user_message_chunk /
|
||||
// agent_thought_chunk (spec scope). undefined = omit the field entirely.
|
||||
messageId?: string
|
||||
},
|
||||
): SessionNotification[] {
|
||||
const output: SessionNotification[] = []
|
||||
@@ -55,6 +59,7 @@ export function toAcpNotifications(
|
||||
update = {
|
||||
sessionUpdate:
|
||||
role === 'assistant' ? 'agent_message_chunk' : 'user_message_chunk',
|
||||
...(options?.messageId ? { messageId: options.messageId } : {}),
|
||||
content: { type: 'text', text },
|
||||
}
|
||||
break
|
||||
@@ -65,6 +70,7 @@ export function toAcpNotifications(
|
||||
const thinking = (chunk.thinking as string) ?? ''
|
||||
update = {
|
||||
sessionUpdate: 'agent_thought_chunk',
|
||||
...(options?.messageId ? { messageId: options.messageId } : {}),
|
||||
content: { type: 'text', text: thinking },
|
||||
}
|
||||
break
|
||||
@@ -78,6 +84,7 @@ export function toAcpNotifications(
|
||||
role === 'assistant'
|
||||
? 'agent_message_chunk'
|
||||
: 'user_message_chunk',
|
||||
...(options?.messageId ? { messageId: options.messageId } : {}),
|
||||
content: {
|
||||
type: 'image',
|
||||
data: source.data as string,
|
||||
@@ -237,6 +244,7 @@ export function assistantMessageToAcpNotifications(
|
||||
parentToolUseId?: string | null
|
||||
cwd?: string
|
||||
streamingActive?: boolean
|
||||
messageId?: string
|
||||
},
|
||||
): SessionNotification[] {
|
||||
const message = msg.message as Record<string, unknown> | undefined
|
||||
@@ -255,6 +263,7 @@ export function assistantMessageToAcpNotifications(
|
||||
sessionId,
|
||||
update: {
|
||||
sessionUpdate: 'agent_message_chunk',
|
||||
...(options?.messageId ? { messageId: options.messageId } : {}),
|
||||
content: { type: 'text', text: content },
|
||||
},
|
||||
},
|
||||
@@ -296,6 +305,7 @@ export function streamEventToAcpNotifications(
|
||||
clientCapabilities?: ClientCapabilities
|
||||
cwd?: string
|
||||
streamingActive?: boolean
|
||||
messageId?: string
|
||||
},
|
||||
): SessionNotification[] {
|
||||
const event = (msg as unknown as { event: Record<string, unknown> }).event
|
||||
@@ -318,6 +328,7 @@ export function streamEventToAcpNotifications(
|
||||
clientCapabilities: options?.clientCapabilities,
|
||||
parentToolUseId: msg.parent_tool_use_id as string | null | undefined,
|
||||
cwd: options?.cwd,
|
||||
messageId: options?.messageId,
|
||||
},
|
||||
)
|
||||
}
|
||||
@@ -335,6 +346,7 @@ export function streamEventToAcpNotifications(
|
||||
clientCapabilities: options?.clientCapabilities,
|
||||
parentToolUseId: msg.parent_tool_use_id as string | null | undefined,
|
||||
cwd: options?.cwd,
|
||||
messageId: options?.messageId,
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user