Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions prompt.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package protocol

// MsgInteractivePromptResolved is the daemon->PWA tombstone broadcast after
// an interactive prompt answer is accepted by the daemon-side agent adapter.
const MsgInteractivePromptResolved = "interactive_prompt_resolved"

// InteractivePromptResolvedPayload is carried by MsgInteractivePromptResolved.
// The PWA records QuestionID as resolved for SessionID and clears only matching
// pending/in-flight prompt UI state. Reason is a stable, human-readable machine
// string such as "answered".
type InteractivePromptResolvedPayload struct {
QuestionID string `json:"question_id"`
SessionID string `json:"session_id"`
Reason string `json:"reason"`
ResolvedAt int64 `json:"resolved_at"`
}
45 changes: 45 additions & 0 deletions prompt_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package protocol

import (
"encoding/json"
"strings"
"testing"
)

func TestMsgInteractivePromptResolvedConstant(t *testing.T) {
t.Parallel()

if MsgInteractivePromptResolved != "interactive_prompt_resolved" {
t.Fatalf("MsgInteractivePromptResolved = %q, want %q", MsgInteractivePromptResolved, "interactive_prompt_resolved")
}
}

func TestInteractivePromptResolvedPayloadRoundtrip(t *testing.T) {
t.Parallel()

original := InteractivePromptResolvedPayload{
QuestionID: "q-123",
SessionID: "s-123",
Reason: "answered",
ResolvedAt: 1778915600123,
}

raw, err := json.Marshal(original)
if err != nil {
t.Fatalf("marshal: %v", err)
}
rawStr := string(raw)
for _, want := range []string{`"question_id"`, `"session_id"`, `"reason"`, `"resolved_at"`} {
if !strings.Contains(rawStr, want) {
t.Fatalf("marshaled JSON missing %s: %s", want, rawStr)
}
}

var decoded InteractivePromptResolvedPayload
if err := json.Unmarshal(raw, &decoded); err != nil {
t.Fatalf("unmarshal: %v", err)
}
if decoded != original {
t.Fatalf("roundtrip mismatch:\n got: %+v\n want: %+v", decoded, original)
}
}
Loading