Skip to content

Commit f513a14

Browse files
authored
Support more notifications (#370)
- **Give notification of compaction** - **Also support local command output**
1 parent c0e2cee commit f513a14

1 file changed

Lines changed: 36 additions & 9 deletions

File tree

src/acp-agent.ts

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -467,25 +467,52 @@ export class ClaudeAcpAgent implements Agent {
467467

468468
switch (message.type) {
469469
case "system":
470-
if (message.subtype === "compact_boundary") {
471-
// We don't know the exact size, but since we compacted,
472-
// we set it to zero. The client gets the exact size on the next message.
473-
lastAssistantTotalUsage = 0;
474-
}
475470
switch (message.subtype) {
476471
case "init":
477472
break;
478-
case "compact_boundary":
473+
case "status": {
474+
if (message.status === "compacting") {
475+
await this.client.sessionUpdate({
476+
sessionId: message.session_id,
477+
update: {
478+
sessionUpdate: "agent_message_chunk",
479+
content: { type: "text", text: "Compacting..." },
480+
},
481+
});
482+
}
483+
break;
484+
}
485+
case "compact_boundary": {
486+
// We don't know the exact size, but since we compacted,
487+
// we set it to zero. The client gets the exact size on the next message.
488+
lastAssistantTotalUsage = 0;
489+
await this.client.sessionUpdate({
490+
sessionId: message.session_id,
491+
update: {
492+
sessionUpdate: "agent_message_chunk",
493+
content: { type: "text", text: "\n\nCompacting completed." },
494+
},
495+
});
496+
break;
497+
}
498+
case "local_command_output": {
499+
await this.client.sessionUpdate({
500+
sessionId: message.session_id,
501+
update: {
502+
sessionUpdate: "agent_message_chunk",
503+
content: { type: "text", text: message.content },
504+
},
505+
});
506+
break;
507+
}
479508
case "hook_started":
480-
case "task_notification":
481509
case "hook_progress":
482510
case "hook_response":
483-
case "status":
484511
case "files_persisted":
485512
case "task_started":
513+
case "task_notification":
486514
case "task_progress":
487515
case "elicitation_complete":
488-
case "local_command_output":
489516
// Todo: process via status api: https://docs.claude.com/en/docs/claude-code/hooks#hook-output
490517
break;
491518
default:

0 commit comments

Comments
 (0)