Observe native Claude automations and preserve pending timers

This commit is contained in:
2026-11-08 15:52:22 +00:00
parent 9d3358be47
commit 3fbfb85ace
17 changed files with 757 additions and 34 deletions
+18 -1
View File
@@ -12,6 +12,7 @@ import (
"strings"
"time"
"git.a-wan.net/alan/pipelines/internal/claudehost"
"git.a-wan.net/alan/pipelines/internal/protocol"
)
@@ -69,6 +70,7 @@ type messageBody struct {
type toolRequest struct {
Subtype string `json:"subtype"`
CallbackID string `json:"callback_id"`
ToolName string `json:"tool_name"`
DisplayName string `json:"display_name"`
Description string `json:"description"`
@@ -174,7 +176,22 @@ func (s *session) handleControlRequest(p *process, envelope lineEnvelope) {
switch request.Subtype {
case "can_use_tool":
s.receivePermission(p, envelope.RequestID, request)
case "hook_callback", "mcp_message":
case "hook_callback":
if !claudehost.IsAutomationHook(request.CallbackID) {
s.respondUnsupported(p, envelope.RequestID)
return
}
snapshot, _ := claudehost.ParseAutomationHook(request.CallbackID, s.id, request.Input, time.Now().UnixMilli())
s.mu.Lock()
s.automations = snapshot
s.automationProcess = p
s.mu.Unlock()
// A detachable host observes and acknowledges its own callback before
// the server is involved. Direct processes need the adapter response.
if p.link == nil {
_ = p.respond(envelope.RequestID, map[string]any{})
}
case "mcp_message":
s.respondUnsupported(p, envelope.RequestID)
default:
s.respondUnsupported(p, envelope.RequestID)