This major refactor: generated by llmgit Co-Authored-By: Claude <noreply@anthropic.com>
57 lines
2.1 KiB
Go
57 lines
2.1 KiB
Go
package core
|
|
|
|
import "time"
|
|
|
|
// Message represents a unified incoming message from any platform.
|
|
type Message struct {
|
|
SessionKey string // unique key for user context, e.g. "feishu:{chatID}:{userID}"
|
|
Platform string
|
|
UserID string
|
|
UserName string
|
|
Content string
|
|
ReplyCtx any // platform-specific context needed for replying
|
|
}
|
|
|
|
// EventType distinguishes different kinds of agent output.
|
|
type EventType string
|
|
|
|
const (
|
|
EventText EventType = "text" // intermediate or final text
|
|
EventToolUse EventType = "tool_use" // tool invocation info
|
|
EventToolResult EventType = "tool_result" // tool execution result
|
|
EventResult EventType = "result" // final aggregated result
|
|
EventError EventType = "error" // error occurred
|
|
EventPermissionRequest EventType = "permission_request" // agent requests permission via stdio protocol
|
|
EventThinking EventType = "thinking" // thinking/processing status
|
|
)
|
|
|
|
// Event represents a single piece of agent output streamed back to the engine.
|
|
type Event struct {
|
|
Type EventType
|
|
Content string
|
|
ToolName string // populated for EventToolUse, EventPermissionRequest
|
|
ToolInput string // human-readable summary of tool input
|
|
ToolInputRaw map[string]any // raw tool input (for EventPermissionRequest, used in allow response)
|
|
ToolResult string // populated for EventToolResult
|
|
SessionID string // agent-managed session ID for conversation continuity
|
|
RequestID string // unique request ID for EventPermissionRequest
|
|
Done bool
|
|
Error error
|
|
}
|
|
|
|
// HistoryEntry is one turn in a conversation.
|
|
type HistoryEntry struct {
|
|
Role string `json:"role"` // "user" or "assistant"
|
|
Content string `json:"content"`
|
|
Timestamp time.Time `json:"timestamp"`
|
|
}
|
|
|
|
// AgentSessionInfo describes one session as reported by the agent backend.
|
|
type AgentSessionInfo struct {
|
|
ID string
|
|
Summary string
|
|
MessageCount int
|
|
ModifiedAt time.Time
|
|
GitBranch string
|
|
}
|