cmd_types

package
v0.0.51 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 9, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromCmd

func FromCmd(events []Event, sessionID string) []types.AgentEvent

FromCmd converts a sequence of cmd session events into the canonical AgentEvent stream. It walks the native events in order, emitting zero or more canonical events per native event. Tool results are merged into the preceding tool-call by matching toolCallId.

Types

type ContentBlock

type ContentBlock struct {
	Type       ContentBlockType `json:"type"`
	Text       string           `json:"text,omitempty"`
	ToolCallID string           `json:"toolCallId,omitempty"`
	ToolName   string           `json:"toolName,omitempty"`
	Input      json.RawMessage  `json:"input,omitempty"`
	Output     *ToolOutput      `json:"output,omitempty"`
}

ContentBlock is one element in a content array.

type ContentBlockType

type ContentBlockType string

ContentBlockType discriminates the type of a content block.

const (
	BlockTypeText       ContentBlockType = "text"
	BlockTypeReasoning  ContentBlockType = "reasoning"
	BlockTypeToolCall   ContentBlockType = "tool-call"
	BlockTypeToolResult ContentBlockType = "tool-result"
)

type Event

type Event struct {
	ID        string          `json:"id"`
	Timestamp string          `json:"timestamp"`
	SessionID string          `json:"sessionId"`
	ParentID  string          `json:"parentId"`
	Role      Role            `json:"role"`
	Content   json.RawMessage `json:"content"` // string or []ContentBlock
	GitBranch string          `json:"gitBranch,omitempty"`
	Metadata  *EventMetadata  `json:"metadata,omitempty"`
}

Event models one JSONL line from a cmd session file.

func ToCmd

func ToCmd(events []types.AgentEvent, sessionID string) []Event

ToCmd converts a canonical AgentEvent stream into cmd session events.

type EventMetadata

type EventMetadata struct {
	Timestamp   string `json:"timestamp,omitempty"`
	Source      string `json:"source,omitempty"`
	Version     int    `json:"version,omitempty"`
	Entrypoint  string `json:"entrypoint,omitempty"`
	MessageID   string `json:"messageId,omitempty"`
	IsAutomated bool   `json:"isAutomated,omitempty"`
}

EventMetadata contains optional metadata fields.

type Role

type Role string

Role discriminates the role of a cmd session event.

const (
	RoleUser      Role = "user"
	RoleAssistant Role = "assistant"
	RoleTool      Role = "tool"
)

type ToolOutput

type ToolOutput struct {
	Type  string `json:"type"`
	Value string `json:"value"`
}

ToolOutput wraps the result of a tool execution.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL