adapters

package
v0.136.0 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2026 License: Apache-2.0 Imports: 18 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

This section is empty.

Variables

This section is empty.

Functions

func NewClaudeCodeClient added in v0.100.0

func NewClaudeCodeClient(cfg *config.ClaudeCodeConfig, stateManager domain.StateManager, appendSystemPrompt string) domain.SDKClient

NewClaudeCodeClient creates a new Claude Code CLI client

func NewSDKClientAdapter added in v0.99.0

func NewSDKClientAdapter(client sdk.Client) domain.SDKClient

NewSDKClientAdapter creates a new SDK client adapter

Types

type AssistantMessage added in v0.100.0

type AssistantMessage struct {
	Content []ContentBlock `json:"content"`
	Role    string         `json:"role"`
}

type ClaudeCodeClient added in v0.100.0

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

ClaudeCodeClient is a wrapper around the official Claude Code CLI It implements the SDKClient interface by spawning the claude process

func (*ClaudeCodeClient) GenerateContent added in v0.100.0

func (c *ClaudeCodeClient) GenerateContent(
	ctx context.Context,
	provider sdk.Provider,
	model string,
	messages []sdk.Message,
) (*sdk.CreateChatCompletionResponse, error)

GenerateContent makes a non-streaming request to Claude Code CLI

func (*ClaudeCodeClient) GenerateContentStream added in v0.100.0

func (c *ClaudeCodeClient) GenerateContentStream(
	ctx context.Context,
	provider sdk.Provider,
	model string,
	messages []sdk.Message,
) (<-chan sdk.SSEvent, error)

GenerateContentStream makes a streaming request to Claude Code CLI

func (*ClaudeCodeClient) TakeToolCallResults added in v0.132.1

func (c *ClaudeCodeClient) TakeToolCallResults() map[string]domain.ToolCallResult

TakeToolCallResults returns and clears the tool results claude reported during the last GenerateContent call. Implements domain.ToolCallResultProvider.

func (*ClaudeCodeClient) Wait added in v0.100.0

func (c *ClaudeCodeClient) Wait()

Wait blocks until all background goroutines have completed This should be called during shutdown to ensure clean resource cleanup

func (*ClaudeCodeClient) WithMiddlewareOptions added in v0.100.0

func (c *ClaudeCodeClient) WithMiddlewareOptions(opts *sdk.MiddlewareOptions) domain.SDKClient

WithMiddlewareOptions sets middleware options (not used in Claude Code mode)

func (*ClaudeCodeClient) WithOptions added in v0.100.0

WithOptions sets the chat completion request options

func (*ClaudeCodeClient) WithTools added in v0.100.0

func (c *ClaudeCodeClient) WithTools(tools *[]sdk.ChatCompletionTool) domain.SDKClient

WithTools sets the tools for the chat completion

type ClaudeCodeMessage added in v0.100.0

type ClaudeCodeMessage struct {
	// Common fields
	Type      string          `json:"type"`
	Subtype   string          `json:"subtype,omitempty"`
	Message   json.RawMessage `json:"message,omitempty"`
	SessionID string          `json:"session_id,omitempty"`

	// System init fields (type: system, subtype: init)
	CWD               string   `json:"cwd,omitempty"`
	ClaudeModel       string   `json:"model,omitempty"`
	PermissionMode    string   `json:"permissionMode,omitempty"`
	ClaudeCodeVersion string   `json:"claude_code_version,omitempty"`
	Tools             []string `json:"tools,omitempty"`

	// User/tool_result fields
	ToolUseResult json.RawMessage `json:"tool_use_result,omitempty"`

	// Final result fields (type: result)
	IsError           bool            `json:"is_error,omitempty"`
	DurationMS        int             `json:"duration_ms,omitempty"`
	DurationAPIMS     int             `json:"duration_api_ms,omitempty"`
	TTFTMS            int             `json:"ttft_ms,omitempty"`
	TTFTStreamMS      int             `json:"ttft_stream_ms,omitempty"`
	NumTurns          int             `json:"num_turns,omitempty"`
	Result            string          `json:"result,omitempty"`
	StopReason        string          `json:"stop_reason,omitempty"`
	TotalCostUSD      float64         `json:"total_cost_usd,omitempty"`
	TerminalReason    string          `json:"terminal_reason,omitempty"`
	PermissionDenials json.RawMessage `json:"permission_denials,omitempty"`
	Usage             *ClaudeUsage    `json:"usage,omitempty"`
}

ClaudeCodeMessage represents a JSONL line from the Claude CLI streaming output. It covers all event types: system init, assistant messages, user/tool results, final result, and hook events.

type ClaudeUsage added in v0.123.0

type ClaudeUsage struct {
	InputTokens              int64 `json:"input_tokens"`
	OutputTokens             int64 `json:"output_tokens"`
	CacheCreationInputTokens int64 `json:"cache_creation_input_tokens"`
	CacheReadInputTokens     int64 `json:"cache_read_input_tokens"`
}

ClaudeUsage is Anthropic's token breakdown as reported on the result message.

type ContentBlock added in v0.100.0

type ContentBlock struct {
	Type     string          `json:"type"`
	Text     string          `json:"text,omitempty"`
	Thinking string          `json:"thinking,omitempty"`
	ID       string          `json:"id,omitempty"`
	Name     string          `json:"name,omitempty"`
	Input    json.RawMessage `json:"input,omitempty"`
}

ContentBlock represents a content block in the assistant message

type PersistentConversationAdapter

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

PersistentConversationAdapter adapts services.PersistentConversationRepository to shortcuts.PersistentConversationRepository

func NewPersistentConversationAdapter

func NewPersistentConversationAdapter(repo *services.PersistentConversationRepository) *PersistentConversationAdapter

NewPersistentConversationAdapter creates a new adapter

func (*PersistentConversationAdapter) DeleteSavedConversation

func (a *PersistentConversationAdapter) DeleteSavedConversation(ctx context.Context, conversationID string) error

DeleteSavedConversation delegates to the underlying repository

func (*PersistentConversationAdapter) GetCurrentConversationID

func (a *PersistentConversationAdapter) GetCurrentConversationID() string

GetCurrentConversationID delegates to the underlying repository

func (*PersistentConversationAdapter) GetCurrentConversationMetadata

func (a *PersistentConversationAdapter) GetCurrentConversationMetadata() shortcuts.ConversationMetadata

GetCurrentConversationMetadata adapts the method to return shortcuts.ConversationMetadata

func (*PersistentConversationAdapter) ListSavedConversations

func (a *PersistentConversationAdapter) ListSavedConversations(ctx context.Context, limit, offset int) ([]shortcuts.ConversationSummary, error)

ListSavedConversations adapts the method to return shortcuts.ConversationSummary

func (*PersistentConversationAdapter) LoadConversation

func (a *PersistentConversationAdapter) LoadConversation(ctx context.Context, conversationID string) error

LoadConversation delegates to the underlying repository

func (*PersistentConversationAdapter) SaveConversation

func (a *PersistentConversationAdapter) SaveConversation(ctx context.Context) error

SaveConversation delegates to the underlying repository

func (*PersistentConversationAdapter) SetConversationTitle

func (a *PersistentConversationAdapter) SetConversationTitle(title string)

SetConversationTitle delegates to the underlying repository

func (*PersistentConversationAdapter) StartNewConversation

func (a *PersistentConversationAdapter) StartNewConversation(title string) error

StartNewConversation delegates to the underlying repository

type SDKClientAdapter added in v0.99.0

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

SDKClientAdapter adapts sdk.Client to domain.SDKClient interface

func (*SDKClientAdapter) GenerateContent added in v0.99.0

func (a *SDKClientAdapter) GenerateContent(ctx context.Context, provider sdk.Provider, model string, messages []sdk.Message) (*sdk.CreateChatCompletionResponse, error)

GenerateContent wraps the SDK client's GenerateContent method

func (*SDKClientAdapter) GenerateContentStream added in v0.99.0

func (a *SDKClientAdapter) GenerateContentStream(ctx context.Context, provider sdk.Provider, model string, messages []sdk.Message) (<-chan sdk.SSEvent, error)

GenerateContentStream wraps the SDK client's GenerateContentStream method

func (*SDKClientAdapter) WithMiddlewareOptions added in v0.99.0

func (a *SDKClientAdapter) WithMiddlewareOptions(opts *sdk.MiddlewareOptions) domain.SDKClient

WithMiddlewareOptions wraps the SDK client's WithMiddlewareOptions method

func (*SDKClientAdapter) WithOptions added in v0.99.0

WithOptions wraps the SDK client's WithOptions method

func (*SDKClientAdapter) WithTools added in v0.99.0

func (a *SDKClientAdapter) WithTools(tools *[]sdk.ChatCompletionTool) domain.SDKClient

WithTools wraps the SDK client's WithTools method

type ToolResultContent added in v0.100.0

type ToolResultContent struct {
	Type      string            `json:"type"`
	ToolUseID string            `json:"tool_use_id"`
	IsError   bool              `json:"is_error"`
	Content   toolResultPayload `json:"content"`
}

type ToolResultMessage added in v0.100.0

type ToolResultMessage struct {
	Role    string              `json:"role"`
	Content []ToolResultContent `json:"content"`
}

Jump to

Keyboard shortcuts

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