transcript

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	FinishReasonEndTurn       = "end_turn"
	FinishReasonToolCalls     = "tool_calls"
	FinishReasonMaxTokens     = "max_tokens"
	FinishReasonError         = "error"
	FinishReasonCanceled      = "canceled"
	FinishReasonDaemonRestart = "daemon_restart"
)

Finish reasons of assistant messages.

Variables

This section is empty.

Functions

func HasFinishReason

func HasFinishReason(message Message, reason string) bool

HasFinishReason reports whether the message has a finish part with the reason; an empty reason matches any finish part.

func RunReply

func RunReply(messages []Message, runID string) string

RunReply is the text of the run's last reply: its latest assistant text with the replies the output limit cut before it prepended, engine notes between them skipped. Replies keep the whitespace at a cut, so the parts join as they are.

Types

type Compaction

type Compaction struct {
	Summary          string   `json:"summary,omitempty"`
	Kept             []string `json:"kept,omitempty"`
	CoversThroughSeq int64    `json:"covers_through_seq"`
	RunID            string   `json:"run_id,omitempty"`
	TokensBefore     int      `json:"tokens_before,omitempty"`
	TokensAfter      int      `json:"tokens_after,omitempty"`
	Cleared          bool     `json:"cleared,omitempty"`
}

Compaction makes a message a context boundary: the model sees Summary and Kept instead of the session's messages up to CoversThroughSeq. Cleared marks a /clear, which keeps nothing. Tokens are estimates of the prompt around it.

type FinishPart

type FinishPart struct {
	Reason  string          `json:"reason,omitempty"`
	Message string          `json:"message,omitempty"`
	Details json.RawMessage `json:"details,omitempty"`
}

type ImagePart

type ImagePart struct {
	MIMEType    string `json:"mime_type,omitempty"`
	DataBase64  string `json:"data_base64,omitempty"`
	Name        string `json:"name,omitempty"`
	StoragePath string `json:"storage_path,omitempty"`
	Temporary   bool   `json:"temporary,omitempty"`
	Size        int64  `json:"size,omitempty"`
}

type Message

type Message struct {
	ID         string        `json:"id"`
	Seq        int64         `json:"seq,omitempty"`
	SessionID  string        `json:"session_id"`
	RunID      string        `json:"run_id"`
	Role       MessageRole   `json:"role"`
	Origin     Origin        `json:"origin,omitempty"`
	Content    string        `json:"content"`
	Parts      []MessagePart `json:"parts,omitempty"`
	Compaction *Compaction   `json:"compaction,omitempty"`
	Model      string        `json:"model,omitempty"`
	Provider   string        `json:"provider,omitempty"`
	CreatedAt  time.Time     `json:"created_at"`
	UpdatedAt  time.Time     `json:"updated_at"`
}

func SealInterrupted added in v0.2.1

func SealInterrupted(message Message, note string) Message

SealInterrupted ends message with a daemon_restart finish part, which keeps it out of every later request; note says why ("" for a daemon restart).

type MessagePart

type MessagePart struct {
	Kind       MessagePartKind `json:"kind"`
	Text       *TextPart       `json:"text,omitempty"`
	Image      *ImagePart      `json:"image,omitempty"`
	Reasoning  *ReasoningPart  `json:"reasoning,omitempty"`
	ToolCall   *ToolCallPart   `json:"tool_call,omitempty"`
	ToolResult *ToolResultPart `json:"tool_result,omitempty"`
	Finish     *FinishPart     `json:"finish,omitempty"`
}

func NormalizeMessageParts

func NormalizeMessageParts(content string, parts []MessagePart) []MessagePart

type MessagePartKind

type MessagePartKind string
const (
	MessagePartKindText       MessagePartKind = "text"
	MessagePartKindImage      MessagePartKind = "image"
	MessagePartKindReasoning  MessagePartKind = "reasoning"
	MessagePartKindToolCall   MessagePartKind = "tool_call"
	MessagePartKindToolResult MessagePartKind = "tool_result"
	MessagePartKindFinish     MessagePartKind = "finish"
)

type MessageRole

type MessageRole string
const (
	MessageRoleUser      MessageRole = "user"
	MessageRoleAssistant MessageRole = "assistant"
	MessageRoleSystem    MessageRole = "system"
	MessageRoleTool      MessageRole = "tool"
)

type Origin

type Origin string

Origin says who wrote a message when its role alone does not.

const (
	OriginEngine      Origin = "engine"
	OriginEngineModel Origin = "engine_model"
)

Engine notes reach the model as user text. Clients show OriginEngine notes as system notes and hide OriginEngineModel ones, which only the model needs.

func (Origin) IsEngine

func (o Origin) IsEngine() bool

IsEngine reports whether the message is an engine note of either kind.

type ReasoningPart

type ReasoningPart struct {
	Text         string `json:"text"`
	Signature    string `json:"signature,omitempty"`
	RedactedData string `json:"redacted_data,omitempty"`
}

type TextPart

type TextPart struct {
	Text string `json:"text"`
}

type ToolCallPart

type ToolCallPart struct {
	ID       string `json:"id"`
	Name     string `json:"name"`
	Input    string `json:"input"`
	Finished bool   `json:"finished,omitempty"`
	// Deferred marks a call held back behind an approval barrier; it has not started.
	Deferred bool `json:"deferred,omitempty"`
}

type ToolResultPart

type ToolResultPart struct {
	ToolCallID string          `json:"tool_call_id"`
	Name       string          `json:"name"`
	Content    string          `json:"content"`
	MIMEType   string          `json:"mime_type,omitempty"`
	Metadata   json.RawMessage `json:"metadata,omitempty"`
	// Status is success, error or neutral; empty is success.
	Status string `json:"status,omitempty"`
	// OutputPath is the file holding the full output when Content was cut.
	OutputPath string `json:"output_path,omitempty"`
}

func (ToolResultPart) IsError

func (p ToolResultPart) IsError() bool

IsError reports whether the call failed.

Jump to

Keyboard shortcuts

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