appserver

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2026 License: GPL-3.0 Imports: 17 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

This section is empty.

Types

type Connection

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

Connection binds an action to the exact app-server transport that supplied its target. Its zero value cannot authorize a write.

type Connector

type Connector interface {
	Connect(context.Context) (ReadWriteCloser, error)
}

type Incoming

type Incoming struct {
	Kind   IncomingKind
	ID     RawID
	Method string
	Params json.RawMessage
}

type IncomingKind

type IncomingKind uint8
const (
	IncomingNotification IncomingKind = iota + 1
	IncomingServerRequest
)

type InitializeResponse

type InitializeResponse struct {
	UserAgent      string `json:"userAgent"`
	PlatformFamily string `json:"platformFamily"`
	PlatformOS     string `json:"platformOs"`
}

type ItemSnapshot

type ItemSnapshot struct {
	ID     string `json:"id"`
	Type   string `json:"type"`
	Status string `json:"status,omitempty"`
}

type Manager

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

func NewManager

func NewManager(connector Connector, opts ManagerOptions) *Manager

func (*Manager) Interrupt

func (m *Manager) Interrupt(ctx context.Context, connection Connection, threadID, turnID string) error

func (*Manager) Respond

func (m *Manager) Respond(ctx context.Context, id RawID, result any) error

func (*Manager) Run

func (m *Manager) Run(ctx context.Context, events chan<- ManagerEvent) error

type ManagerEvent

type ManagerEvent struct {
	Kind         ManagerEventKind
	Connection   Connection
	Incoming     Incoming
	Initialize   InitializeResponse
	ThreadIDs    []string
	ThreadID     string
	Thread       *ThreadSnapshot
	FailureStage string
	FailureCode  string
	RateLimits   *RateLimitSnapshot
}

type ManagerEventKind

type ManagerEventKind uint8
const (
	ManagerConnected ManagerEventKind = iota + 1
	ManagerDisconnected
	ManagerIncoming
	ManagerThreadsReconciled
	ManagerThreadAttached
	ManagerThreadAttachFailed
	ManagerRateLimitsSnapshot
	ManagerRateLimitsReadFailed
)

type ManagerOptions

type ManagerOptions struct {
	PollInterval           time.Duration
	Backoff                []time.Duration
	Session                Options
	ShutdownTimeout        time.Duration
	RateLimitsEnabled      bool
	RateLimitsPollInterval time.Duration
}

type Options

type Options struct {
	MaxMessageBytes int
	RPCTimeout      time.Duration
	EventBuffer     int
}

type ProtocolError

type ProtocolError struct{ Kind ProtocolErrorKind }

func (*ProtocolError) Error

func (e *ProtocolError) Error() string

type ProtocolErrorKind

type ProtocolErrorKind string
const (
	ProtocolMalformedJSON     ProtocolErrorKind = "malformed_json"
	ProtocolMessageTooLarge   ProtocolErrorKind = "message_too_large"
	ProtocolInvalidEnvelope   ProtocolErrorKind = "invalid_envelope"
	ProtocolEventBackpressure ProtocolErrorKind = "event_backpressure"
)

type ProxyConnector

type ProxyConnector struct {
	CodexBin string
	// contains filtered or unexported fields
}

func (*ProxyConnector) Connect

func (c *ProxyConnector) Connect(ctx context.Context) (ReadWriteCloser, error)

type RPCError

type RPCError struct {
	Code    int
	Message string
}

func (*RPCError) Error

func (e *RPCError) Error() string

type RateLimitSnapshot

type RateLimitSnapshot struct {
	LimitID   string           `json:"limitId,omitempty"`
	Primary   *RateLimitWindow `json:"primary,omitempty"`
	Secondary *RateLimitWindow `json:"secondary,omitempty"`
}

func MergeRateLimits

func MergeRateLimits(current, update RateLimitSnapshot) RateLimitSnapshot

type RateLimitWindow

type RateLimitWindow struct {
	UsedPercent           int   `json:"usedPercent"`
	WindowDurationMinutes int64 `json:"windowDurationMins,omitempty"`
	ResetsAt              int64 `json:"resetsAt,omitempty"`
}

type RateLimitsResponse

type RateLimitsResponse struct {
	RateLimitsByLimitID map[string]RateLimitSnapshot `json:"rateLimitsByLimitId,omitempty"`
}

func (RateLimitsResponse) CodexSnapshot

func (response RateLimitsResponse) CodexSnapshot() (RateLimitSnapshot, bool)

type RawID

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

func ParseRawID

func ParseRawID(raw json.RawMessage) (RawID, error)

func (RawID) Equal

func (id RawID) Equal(other RawID) bool

func (RawID) Key

func (id RawID) Key() string

func (RawID) Valid

func (id RawID) Valid() bool

type ReadWriteCloser

type ReadWriteCloser interface {
	io.Reader
	io.Writer
	io.Closer
}

type Session

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

func NewSession

func NewSession(conn io.ReadWriteCloser, opts Options) *Session

func (*Session) Call

func (s *Session) Call(ctx context.Context, method string, params any, target any) error

func (*Session) Close

func (s *Session) Close() error

func (*Session) Events

func (s *Session) Events() <-chan Incoming

func (*Session) Initialize

func (s *Session) Initialize(ctx context.Context, rateLimitsEnabled bool) (InitializeResponse, error)

func (*Session) InterruptTurn

func (s *Session) InterruptTurn(ctx context.Context, threadID, turnID string) error

func (*Session) ListLoadedThreads

func (s *Session) ListLoadedThreads(ctx context.Context) ([]string, error)

func (*Session) Notify

func (s *Session) Notify(ctx context.Context, method string, params any) error

func (*Session) ReadRateLimits

func (s *Session) ReadRateLimits(ctx context.Context) (RateLimitsResponse, error)

func (*Session) Respond

func (s *Session) Respond(ctx context.Context, id RawID, result any) error

func (*Session) ResumeThreadSnapshot

func (s *Session) ResumeThreadSnapshot(ctx context.Context, threadID string) (ThreadSnapshot, error)

func (*Session) Start

func (s *Session) Start(ctx context.Context)

func (*Session) UnsubscribeThread

func (s *Session) UnsubscribeThread(ctx context.Context, threadID string) error

func (*Session) Wait

func (s *Session) Wait() error

type ThreadSnapshot

type ThreadSnapshot struct {
	ID         string
	Name       string
	Preview    string
	CWD        string
	Status     ThreadStatus
	LatestTurn *TurnSnapshot
}

type ThreadStatus

type ThreadStatus struct {
	Type        string   `json:"type"`
	ActiveFlags []string `json:"activeFlags,omitempty"`
}

type TurnSnapshot

type TurnSnapshot struct {
	ID          string          `json:"id"`
	Status      string          `json:"status"`
	Items       []ItemSnapshot  `json:"items"`
	StartedAt   *int64          `json:"startedAt,omitempty"`
	CompletedAt *int64          `json:"completedAt,omitempty"`
	DurationMS  *int64          `json:"durationMs,omitempty"`
	Error       json.RawMessage `json:"error,omitempty"`
}

Jump to

Keyboard shortcuts

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