blob: 202df633f0c94afbd880726cb0800de7c03fc5c7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
// Package event defines the Event type and canonical kinds/actors for the
// task observability stream. Events are immutable, per-task, monotonically
// sequenced records persisted by internal/storage.
package event
import (
"encoding/json"
"time"
)
// Kind enumerates the canonical event types.
type Kind string
const (
KindStateChange Kind = "state_change"
KindAgentMessage Kind = "agent_message"
KindClarificationRequest Kind = "clarification_request"
KindClarificationAnswer Kind = "clarification_answer"
KindHumanMessage Kind = "human_message"
KindSummary Kind = "summary"
KindCommitMade Kind = "commit_made"
KindSubtaskSpawned Kind = "subtask_spawned"
KindCostReport Kind = "cost_report"
KindExecutionStarted Kind = "execution_started"
KindExecutionEnded Kind = "execution_ended"
// KindEscalated records a scheduler decision on a role-typed task's
// escalation ladder (internal/scheduler): either bumping it to the next
// tier, or declining to (budget denied or ladder exhausted, payload
// includes "final": true — the task stays FAILED for human attention).
// Payload shape: from_rung, to_rung, from_provider, to_provider, final.
KindEscalated Kind = "escalated"
)
// Actor identifies the originator of an event.
type Actor string
const (
ActorAgent Actor = "agent"
ActorUser Actor = "user"
ActorChatbot Actor = "chatbot"
ActorSystem Actor = "system"
ActorWebhook Actor = "webhook"
)
// Event is a single timestamped record on a task's audit/observability stream.
// Once written, events are append-only — the seq column is per-task monotonic
// and assigned by the storage layer on insert.
type Event struct {
ID string `json:"id"`
TaskID string `json:"task_id"`
Seq int64 `json:"seq"`
Timestamp time.Time `json:"timestamp"`
Kind Kind `json:"kind"`
Actor Actor `json:"actor"`
Payload json.RawMessage `json:"payload"`
}
|