core

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RequestCWD

func RequestCWD(value string) string

Types

type ActiveRunError

type ActiveRunError struct {
	RunID string
}

ActiveRunError signals the session already has a run in flight.

func (ActiveRunError) Error

func (e ActiveRunError) Error() string

type BrowseEntry

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

type BrowseResult

type BrowseResult struct {
	Root    string        `json:"root"`
	Path    string        `json:"path"`
	Current string        `json:"current"`
	Entries []BrowseEntry `json:"entries"`
	Error   string        `json:"error"`
}

type CancelRunResponse

type CancelRunResponse struct {
	Status string         `json:"status"`
	Run    map[string]any `json:"run"`
}

type ChatInputBlock

type ChatInputBlock struct {
	Type         string `json:"type"`
	Text         string `json:"text"`
	Path         string `json:"path"`
	Data         string `json:"data"`
	MIMEType     string `json:"mime_type"`
	Name         string `json:"name"`
	IsAttachment bool   `json:"is_attachment"`
}

type ChatRequest

type ChatRequest struct {
	SessionID       string           `json:"session_id"`
	Message         string           `json:"message"`
	Input           []ChatInputBlock `json:"input"`
	Provider        string           `json:"provider"`
	Model           string           `json:"model"`
	CWD             string           `json:"cwd"`
	APIKey          string           `json:"api_key"`
	APIBase         string           `json:"api_base"`
	ReasoningEffort string           `json:"reasoning_effort"`
	RewindTo        *int             `json:"rewind_to"`
}

type ChatResponse

type ChatResponse struct {
	Run     map[string]any `json:"run"`
	Session any            `json:"session"`
}

type DecideRequest

type DecideRequest struct {
	RequestID string `json:"request_id"`
	Decision  string `json:"decision"`
}

type DecideResponse

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

type EventPayload

type EventPayload struct {
	RunID     string         `json:"run_id"`
	SessionID string         `json:"session_id"`
	Event     map[string]any `json:"event"`
}

EventPayload is what desktop adapters consume.

type EventSink

type EventSink func(EventPayload)

type Options

type Options struct {
	Store *mycode.SessionStore
	Runs  *RunManager
	Sink  EventSink
}

type RunEvent

type RunEvent struct {
	Seq  int
	Type string
	Data map[string]any
}

RunEvent is one stored run event with the sequence owned by core.

func (RunEvent) Payload

func (e RunEvent) Payload() map[string]any

Payload returns the SSE-compatible event payload shape.

type RunEventBatch

type RunEventBatch struct {
	Events   []RunEvent
	Finished bool
}

RunEventBatch is the replay result for one after cursor.

type RunManager

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

func NewRunManager

func NewRunManager(sink EventSink) *RunManager

type Service

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

func NewService

func NewService(opts Options) (*Service, error)

func (*Service) CancelRun

func (s *Service) CancelRun(runID string) (CancelRunResponse, error)

func (*Service) ClearSession

func (s *Service) ClearSession(sessionID string) error

func (*Service) Config

func (s *Service) Config(cwd string) (map[string]any, error)

func (*Service) CreateSession

func (s *Service) CreateSession(req SessionCreateRequest) (mycode.SessionData, error)

func (*Service) DecideRun

func (s *Service) DecideRun(runID string, req DecideRequest) (DecideResponse, error)

func (*Service) DeleteSession

func (s *Service) DeleteSession(sessionID string) error

func (*Service) ListSessions

func (s *Service) ListSessions(cwd string) (SessionsResponse, error)

func (*Service) LoadSession

func (s *Service) LoadSession(sessionID string) (SessionResponse, error)

func (*Service) RunEventsAfter

func (s *Service) RunEventsAfter(runID string, after int) (RunEventBatch, error)

func (*Service) Settings

func (s *Service) Settings() (map[string]any, error)

func (*Service) StartChat

func (s *Service) StartChat(req ChatRequest) (ChatResponse, error)

func (*Service) UpdateSettings

func (s *Service) UpdateSettings(req SettingsRequest) (map[string]any, error)

func (*Service) WorkspaceBrowse

func (s *Service) WorkspaceBrowse(root, path string) (BrowseResult, error)

func (*Service) WorkspaceRoots

func (s *Service) WorkspaceRoots() map[string]any

type SessionCreateRequest

type SessionCreateRequest struct {
	CWD string `json:"cwd"`
}

type SessionListItem

type SessionListItem struct {
	ID        string `json:"id"`
	Title     string `json:"title"`
	CWD       string `json:"cwd"`
	CreatedAt string `json:"created_at"`
	UpdatedAt string `json:"updated_at"`
	IsRunning bool   `json:"is_running"`
}

type SessionResponse

type SessionResponse struct {
	Session       any              `json:"session"`
	Messages      []mycode.Message `json:"messages"`
	ActiveRun     any              `json:"active_run"`
	PendingEvents []map[string]any `json:"pending_events"`
}

type SessionsResponse

type SessionsResponse struct {
	Sessions []SessionListItem `json:"sessions"`
}

type SettingsRequest

type SettingsRequest struct {
	Config json.RawMessage `json:"config"`
}

type StatusError

type StatusError struct {
	Status int
	Detail any
}

func (*StatusError) Error

func (e *StatusError) Error() string

Jump to

Keyboard shortcuts

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