warp

package
v0.74.1 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package warp provides an adapter for Warp terminal AI that queries its SQLite database for conversation history filtered by working directory.

Index

Constants

This section is empty.

Variables

View Source
var ModelDisplayNames = map[string]string{
	"claude-4-5-opus":          "Claude Opus 4.5",
	"claude-4-5-opus-thinking": "Claude Opus 4.5 (Thinking)",
	"gpt-5-1-high-reasoning":   "GPT-5",
}

ModelDisplayNames maps Warp model IDs to display names.

Functions

func NewWatcher

func NewWatcher(dbPath string) (<-chan adapter.Event, io.Closer, error)

NewWatcher creates a watcher for Warp SQLite changes. Watches the WAL file for modifications since Warp uses WAL mode.

Types

type AIQueryRow

type AIQueryRow struct {
	ID               int
	ExchangeID       string
	ConversationID   string
	Input            string // JSON array
	OutputStatus     string
	ModelID          string
	PlanningModelID  string
	CodingModelID    string
	WorkingDirectory string
	StartTS          time.Time
}

AIQueryRow represents a row from the ai_queries table.

type Adapter

type Adapter struct {
	// contains filtered or unexported fields
}

Adapter implements the adapter.Adapter interface for Warp terminal AI sessions.

func New

func New() *Adapter

New creates a new Warp adapter.

func (*Adapter) Capabilities

func (a *Adapter) Capabilities() adapter.CapabilitySet

Capabilities returns the supported features.

func (*Adapter) Close

func (a *Adapter) Close() error

Close closes the persistent database connection.

func (*Adapter) Detect

func (a *Adapter) Detect(projectRoot string) (bool, error)

Detect checks if Warp AI sessions exist for the given project.

func (*Adapter) ID

func (a *Adapter) ID() string

ID returns the adapter identifier.

func (*Adapter) Icon

func (a *Adapter) Icon() string

Icon returns the adapter icon for badge display.

func (*Adapter) Messages

func (a *Adapter) Messages(sessionID string) ([]adapter.Message, error)

Messages returns all messages for the given session.

func (*Adapter) Name

func (a *Adapter) Name() string

Name returns the human-readable adapter name.

func (*Adapter) SearchMessages

func (a *Adapter) SearchMessages(sessionID, query string, opts adapter.SearchOptions) ([]adapter.MessageMatch, error)

SearchMessages searches message content within a session. Implements adapter.MessageSearcher interface.

func (*Adapter) Sessions

func (a *Adapter) Sessions(projectRoot string) ([]adapter.Session, error)

Sessions returns all sessions for the given project, sorted by update time.

func (*Adapter) Usage

func (a *Adapter) Usage(sessionID string) (*adapter.UsageStats, error)

Usage returns aggregate usage stats for the given session.

func (*Adapter) Watch

func (a *Adapter) Watch(projectRoot string) (<-chan adapter.Event, io.Closer, error)

Watch returns a channel that emits events when session data changes.

func (*Adapter) WatchScope

func (a *Adapter) WatchScope() adapter.WatchScope

WatchScope returns Global because warp watches a global database file (td-7a72b6f7).

type AgentConversationRow

type AgentConversationRow struct {
	ID               int
	ConversationID   string
	ConversationData string // JSON
	LastModifiedAt   time.Time
}

AgentConversationRow represents a row from agent_conversations.

type BlockAIMetadata

type BlockAIMetadata struct {
	ActionID          string          `json:"action_id"`
	ConversationID    string          `json:"conversation_id"`
	ConversationPhase json.RawMessage `json:"conversation_phase"`
}

BlockAIMetadata represents the parsed ai_metadata JSON from blocks.

type BlockRow

type BlockRow struct {
	ID              int
	PaneLeafUUID    []byte
	StylizedCommand []byte
	StylizedOutput  []byte
	PWD             string
	ExitCode        int
	StartTS         time.Time
	CompletedTS     time.Time
	AIMetadata      string // JSON, nullable
}

BlockRow represents a row from the blocks table.

type CodebaseContext

type CodebaseContext struct {
	Path string `json:"path"`
	Name string `json:"name"`
}

CodebaseContext contains project info.

type ConversationData

type ConversationData struct {
	ServerConversationToken string                     `json:"server_conversation_token"`
	UsageMetadata           *ConversationUsageMetadata `json:"conversation_usage_metadata"`
}

ConversationData represents the parsed conversation_data JSON.

type ConversationUsageMetadata

type ConversationUsageMetadata struct {
	WasSummarized         bool               `json:"was_summarized"`
	ContextWindowUsage    float64            `json:"context_window_usage"`
	CreditsSpent          float64            `json:"credits_spent"`
	CreditsSpentLastBlock float64            `json:"credits_spent_for_last_block"`
	TokenUsage            []TokenUsageItem   `json:"token_usage"`
	ToolUsageMetadata     *ToolUsageMetadata `json:"tool_usage_metadata"`
}

ConversationUsageMetadata contains usage statistics.

type CurrentTimeContext

type CurrentTimeContext struct {
	CurrentTime string `json:"current_time"`
}

CurrentTimeContext contains the timestamp.

type DiffStats

type DiffStats struct {
	Count        int `json:"count"`
	LinesAdded   int `json:"lines_added"`
	LinesRemoved int `json:"lines_removed"`
}

DiffStats contains file diff statistics.

type DirectoryContext

type DirectoryContext struct {
	PWD     string `json:"pwd"`
	HomeDir string `json:"home_dir"`
}

DirectoryContext contains the working directory info.

type ExecutionEnvironmentContext

type ExecutionEnvironmentContext struct {
	OS        *OSInfo `json:"os"`
	ShellName string  `json:"shell_name"`
}

ExecutionEnvironmentContext contains OS/shell info.

type GitContext

type GitContext struct {
	Head string `json:"head"`
}

GitContext contains git state.

type OSInfo

type OSInfo struct {
	Category string `json:"category"`
}

OSInfo contains OS category.

type ProjectRulesContext

type ProjectRulesContext struct {
	RootPath    string          `json:"root_path"`
	ActiveRules json.RawMessage `json:"active_rules"` // Complex nested structure, not parsed
}

ProjectRulesContext contains project rules.

type QueryContext

type QueryContext struct {
	Directory            *DirectoryContext            `json:",omitempty"`
	Git                  *GitContext                  `json:",omitempty"`
	ProjectRules         *ProjectRulesContext         `json:",omitempty"`
	CurrentTime          *CurrentTimeContext          `json:",omitempty"`
	ExecutionEnvironment *ExecutionEnvironmentContext `json:",omitempty"`
	Codebase             *CodebaseContext             `json:",omitempty"`
}

QueryContext represents context items in the query.

type QueryInput

type QueryInput struct {
	Query struct {
		Text                  string          `json:"text"`
		Context               []QueryContext  `json:"context"`
		ReferencedAttachments json.RawMessage `json:"referenced_attachments"`
	} `json:"Query"`
}

QueryInput represents the parsed input JSON from ai_queries. Format: [{"Query": {...}}]

type TokenUsageItem

type TokenUsageItem struct {
	ModelID              string         `json:"model_id"`
	WarpTokens           int            `json:"warp_tokens"`
	BYOKTokens           int            `json:"byok_tokens"`
	WarpTokensByCategory map[string]int `json:"warp_token_usage_by_category"`
}

TokenUsageItem contains token usage for a specific model.

type ToolStats

type ToolStats struct {
	Count            int `json:"count"`
	CommandsExecuted int `json:"commands_executed,omitempty"`
}

ToolStats contains basic tool call counts.

type ToolUsageMetadata

type ToolUsageMetadata struct {
	RunCommand      *ToolStats `json:"run_command_stats"`
	ReadFiles       *ToolStats `json:"read_files_stats"`
	Grep            *ToolStats `json:"grep_stats"`
	FileGlob        *ToolStats `json:"file_glob_stats"`
	ApplyFileDiff   *DiffStats `json:"apply_file_diff_stats"`
	ReadShellOutput *ToolStats `json:"read_shell_command_output_stats"`
}

ToolUsageMetadata contains tool call statistics.

Jump to

Keyboard shortcuts

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