client

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Deprecated: Use github.com/axsh/arctic-tern/client/v1 instead.

Deprecated: Use github.com/axsh/arctic-tern/client/v1 instead.

Deprecated: Use github.com/axsh/arctic-tern/client/v1 instead.

Deprecated: Use github.com/axsh/arctic-tern/client/v1 instead.

Deprecated: Use github.com/axsh/arctic-tern/client/v1 instead.

Deprecated: Use github.com/axsh/arctic-tern/client/v1 instead.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

type Agent struct {
	Name string `json:"name"`
}

Agent describes an available coding agent.

type Client

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

Client is a tern API client.

func New

func New(baseURL string, opts ...ClientOption) *Client

New creates a new Client for the given server URL.

func (*Client) CreateSession

func (c *Client) CreateSession(ctx context.Context, req SessionRequest) (*Session, error)

CreateSession creates a new session and returns a Session object.

func (*Client) GetSession

func (c *Client) GetSession(ctx context.Context, sessionID string) (*SessionInfo, error)

GetSession fetches session details by ID. Does not change work_dir, session_dir, or agent_session_id.

func (*Client) Health

func (c *Client) Health(ctx context.Context) (*HealthResponse, error)

Health checks if the server is healthy.

func (*Client) ListAgents

func (c *Client) ListAgents(ctx context.Context) ([]Agent, error)

ListAgents returns the available coding agents.

func (*Client) ListModels

func (c *Client) ListModels(ctx context.Context) (*ModelsResponse, error)

ListModels returns the available models.

func (*Client) UpdateSessionConfigDir added in v0.1.8

func (c *Client) UpdateSessionConfigDir(ctx context.Context, sessionID, configDir string) (*SessionInfo, error)

UpdateSessionConfigDir sets config_dir on an existing session via PATCH. Pass an empty configDir to clear (disable overlay on subsequent launches; for Codex this restores --ignore-user-config on later launches).

Semantics:

  • Does not change work_dir, session_dir, or agent_session_id.
  • Overlay applies on the next SendMessage / SendText / Send, not immediately.
  • Do not Terminate between turns merely to switch config_dir; terminate is only for forced teardown / cleanup after the demo.

type ClientOption

type ClientOption func(*Client)

ClientOption configures the Client.

func WithHTTPClient

func WithHTTPClient(hc *http.Client) ClientOption

WithHTTPClient sets a custom HTTP client.

func WithNoTimeout added in v0.1.1

func WithNoTimeout() ClientOption

WithNoTimeout disables the HTTP client timeout. This is required for SSE streaming connections that may run for extended periods. Without this, the default 30s timeout will terminate long-running SSE streams.

type Event

type Event struct {
	Type     EventType
	Text     string
	ToolName string
	Error    string
}

Event is a single streaming event from the server.

type EventType

type EventType string

EventType identifies the type of streaming event.

const (
	EventText           EventType = "text"
	EventToolUse        EventType = "tool_use"
	EventToolResult     EventType = "tool_result"
	EventToolResultPart EventType = "tool_result_part"
	EventSystem         EventType = "system"
	EventResult         EventType = "result"
	EventError          EventType = "error"
	EventNodeStart      EventType = "node_start"
	EventNodeComplete   EventType = "node_complete"
	EventNodeFailed     EventType = "node_failed"
	EventProgress       EventType = "progress"
)

type HealthResponse

type HealthResponse struct {
	Status string `json:"status"`
}

HealthResponse is the response from the health endpoint.

type ModelInfo

type ModelInfo struct {
	Provider string `json:"provider"`
	Model    string `json:"model"`
}

ModelInfo describes an available model.

type ModelsResponse

type ModelsResponse struct {
	Models       []ModelInfo `json:"models"`
	DefaultModel *ModelInfo  `json:"default_model"`
}

ModelsResponse is the response from the models endpoint.

type Session

type Session struct {
	ID string
	// contains filtered or unexported fields
}

Session represents an active coding agent session.

func ResumeSession

func ResumeSession(c *Client, sessionID string) *Session

ResumeSession creates a Session handle for an existing session ID. No server call is made; this merely wraps the ID for subsequent operations.

func (*Session) SendMessage

func (s *Session) SendMessage(ctx context.Context, message string) (*Stream, error)

SendMessage sends a message to the session and returns a Stream.

func (*Session) Terminate

func (s *Session) Terminate(ctx context.Context) error

Terminate terminates the session.

func (*Session) UpdateConfigDir added in v0.1.8

func (s *Session) UpdateConfigDir(ctx context.Context, configDir string) (*SessionInfo, error)

UpdateConfigDir updates config_dir for this session (see UpdateSessionConfigDir).

type SessionInfo added in v0.1.8

type SessionInfo struct {
	ID             string    `json:"id"`
	AgentName      string    `json:"agent_name"`
	Model          string    `json:"model"`
	Status         string    `json:"status"`
	Error          string    `json:"error,omitempty"`
	WorkDir        string    `json:"work_dir"`
	AgentSessionID string    `json:"agent_session_id"`
	SessionDir     string    `json:"session_dir"`
	ConfigDir      string    `json:"config_dir,omitempty"`
	CreatedAt      time.Time `json:"created_at"`
	UpdatedAt      time.Time `json:"updated_at"`
}

SessionInfo is the typed session record returned by GetSession and UpdateSessionConfigDir. Field names match the CAWA JSON (snake_case tags).

type SessionRequest

type SessionRequest struct {
	Agent      string `json:"agent"`
	Model      string `json:"model,omitempty"`
	WorkDir    string `json:"work_dir"`
	SessionDir string `json:"session_dir,omitempty"`
	ConfigDir  string `json:"config_dir,omitempty"`
}

SessionRequest is the request to create a session.

type Stream

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

Stream processes SSE events from a session message.

func (*Stream) Events

func (s *Stream) Events() <-chan Event

Events returns a channel of raw events for full control.

func (*Stream) OnError

func (s *Stream) OnError(fn func(err string)) *Stream

OnError sets a custom handler for error events.

func (*Stream) OnResult

func (s *Stream) OnResult(fn func(ev Event)) *Stream

OnResult sets a custom handler for result events.

func (*Stream) OnText

func (s *Stream) OnText(fn func(text string)) *Stream

OnText sets a custom handler for text events.

func (*Stream) OnToolUse

func (s *Stream) OnToolUse(fn func(toolName string)) *Stream

OnToolUse sets a custom handler for tool_use events.

func (*Stream) Output

func (s *Stream) Output(w io.Writer) error

Output writes all text events to the given writer and blocks until completion. Returns error if an error event is received.

func (*Stream) Run

func (s *Stream) Run() error

Run executes the stream with the configured handlers. Blocks until the stream is completed.

Directories

Path Synopsis
internal
ssechunk
Package ssechunk reassembles chunked SSE tool_result_part events.
Package ssechunk reassembles chunked SSE tool_result_part events.

Jump to

Keyboard shortcuts

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