Observe native Claude automations and preserve pending timers
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user