serve

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2026 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RuntimeStateRunning = "running"
	RuntimeStatePaused  = "paused"

	// DefaultPort is the default port for holon serve control plane and webhook/server
	DefaultPort = 8080
)
View Source
const (
	// Parse error: Invalid JSON was received by the server
	ErrCodeParseError = -32700

	// Invalid request: The JSON sent is not a valid Request object
	ErrCodeInvalidRequest = -32600

	// Method not found: The method does not exist / is not available
	ErrCodeMethodNotFound = -32601

	// Invalid params: Invalid method parameter(s)
	ErrCodeInvalidParams = -32602

	// Internal error: Internal JSON-RPC error
	ErrCodeInternalError = -32603
)

Standard JSON-RPC 2.0 error codes

View Source
const (
	ErrMsgParseError     = "Parse error"
	ErrMsgInvalidRequest = "Invalid Request"
	ErrMsgMethodNotFound = "Method not found"
	ErrMsgInvalidParams  = "Invalid params"
	ErrMsgInternalError  = "Internal error"
)

Standard error messages

View Source
const (
	// Item notification types
	ItemNotificationCreated = "created"
	ItemNotificationUpdated = "updated"
	ItemNotificationDeleted = "deleted"

	// Turn notification types
	TurnNotificationStarted     = "started"
	TurnNotificationCompleted   = "completed"
	TurnNotificationInterrupted = "interrupted"

	// Thread notification types
	ThreadNotificationStarted = "started"
	ThreadNotificationResumed = "resumed"
	ThreadNotificationPaused  = "paused"
	ThreadNotificationClosed  = "closed"

	// Notification states
	StateActive      = "active"
	StateCompleted   = "completed"
	StateInterrupted = "interrupted"
	StateRunning     = "running"
	StatePaused      = "paused"
	StateClosed      = "closed"
)

Notification constants

Variables

This section is empty.

Functions

func BuildWebhookURL

func BuildWebhookURL(port int, path string) string

BuildWebhookURL constructs the webhook URL from port and path

func GetAvailablePort

func GetAvailablePort() (int, error)

GetAvailablePort finds an available port on localhost

func IsSkipEventError

func IsSkipEventError(err error) bool

func NewSkipEventError

func NewSkipEventError(reason string) error

func ParseJSONRPCRequest

func ParseJSONRPCRequest(data []byte) (*JSONRPCRequest, *JSONRPCError)

ParseJSONRPCRequest parses a JSON-RPC request from a byte slice

func ReadJSONRPCRequest

func ReadJSONRPCRequest(r *http.Request) (*JSONRPCRequest, *JSONRPCError)

ReadJSONRPCRequest reads and parses a JSON-RPC request from an HTTP request

func WriteJSONRPCResponse

func WriteJSONRPCResponse(w http.ResponseWriter, id interface{}, result interface{}, rpcErr *JSONRPCError)

WriteJSONRPCResponse writes a JSON-RPC response to the HTTP response writer

Types

type ActionResult

type ActionResult struct {
	ID        string    `json:"id"`
	EventID   string    `json:"event_id"`
	Status    string    `json:"status"`
	Message   string    `json:"message,omitempty"`
	StartedAt time.Time `json:"started_at"`
	EndedAt   time.Time `json:"ended_at"`
}

type ActivityEmitter

type ActivityEmitter func(ItemNotification)

type ActivityEmitterRegistrar

type ActivityEmitterRegistrar interface {
	SetActivityEmitter(ActivityEmitter)
}

type Config

type Config struct {
	RepoHint string
	StateDir string
	Handler  EventHandler
}

type DecisionRecord

type DecisionRecord struct {
	ID        string    `json:"id"`
	EventID   string    `json:"event_id"`
	Type      string    `json:"type"`
	Reason    string    `json:"reason,omitempty"`
	Skipped   bool      `json:"skipped,omitempty"`
	CreatedAt time.Time `json:"created_at"`
}

type EventEnvelope

type EventEnvelope struct {
	ID        string          `json:"id"`
	Source    string          `json:"source"`
	Type      string          `json:"type"`
	At        time.Time       `json:"at"`
	Scope     EventScope      `json:"scope"`
	Subject   EventSubject    `json:"subject"`
	DedupeKey string          `json:"dedupe_key,omitempty"`
	Payload   json.RawMessage `json:"payload,omitempty"`
}

EventEnvelope is the normalized internal event format for serve mode.

type EventHandler

type EventHandler interface {
	HandleEvent(ctx context.Context, env EventEnvelope) error
}

type EventScope

type EventScope struct {
	Tenant        string `json:"tenant,omitempty"`
	Partition     string `json:"partition,omitempty"`
	Repo          string `json:"repo,omitempty"`
	WorkspaceRef  string `json:"workspace_ref,omitempty"`
	WorkspacePath string `json:"workspace_path,omitempty"`
}

type EventSubject

type EventSubject struct {
	Kind string `json:"kind,omitempty"`
	ID   string `json:"id,omitempty"`
}

type Forwarder

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

Forwarder manages gh webhook forward subprocess lifecycle

func NewForwarder

func NewForwarder(cfg ForwarderConfig) (*Forwarder, error)

NewForwarder creates a new gh webhook forward manager

func (*Forwarder) HealthCheck

func (f *Forwarder) HealthCheck() error

HealthCheck checks if the forwarder process is still alive

func (*Forwarder) IsRunning

func (f *Forwarder) IsRunning() bool

IsRunning returns true if the forwarder is currently running

func (*Forwarder) Pid

func (f *Forwarder) Pid() int

Pid returns the process ID if running, 0 otherwise

func (*Forwarder) Start

func (f *Forwarder) Start(ctx context.Context) error

Start starts the gh webhook forward subprocess

func (*Forwarder) Status

func (f *Forwarder) Status() map[string]interface{}

Status returns status information about the forwarder

func (*Forwarder) Stop

func (f *Forwarder) Stop() error

Stop stops the gh webhook forward subprocess

func (*Forwarder) Uptime

func (f *Forwarder) Uptime() time.Duration

Uptime returns how long the forwarder has been running

type ForwarderConfig

type ForwarderConfig struct {
	Port  int
	Repos []string
	URL   string // e.g., "http://127.0.0.1:8080/ingress/github/webhook"
}

ForwarderConfig holds configuration for gh webhook forward

type ItemNotification

type ItemNotification struct {
	ItemID    string                 `json:"item_id"`
	Type      string                 `json:"type"` // created, updated, deleted
	Status    string                 `json:"status"`
	Content   map[string]interface{} `json:"content,omitempty"`
	Timestamp string                 `json:"timestamp"`
	ThreadID  string                 `json:"thread_id,omitempty"`
	TurnID    string                 `json:"turn_id,omitempty"`
}

ItemNotification represents an item lifecycle notification Corresponds to Codex "item/*" notifications

func NewItemNotification

func NewItemNotification(itemID, notificationType, status string, content map[string]interface{}) ItemNotification

NewItemNotification creates a new item notification

func (ItemNotification) ToJSONRPCNotification

func (n ItemNotification) ToJSONRPCNotification() (Notification, error)

ToJSONRPCNotification converts an ItemNotification to a JSON-RPC notification

type JSONRPCError

type JSONRPCError struct {
	Code    int             `json:"code"`
	Message string          `json:"message"`
	Data    json.RawMessage `json:"data,omitempty"`
}

JSONRPCError represents a JSON-RPC 2.0 error object

func NewJSONRPCError

func NewJSONRPCError(code int, message string) *JSONRPCError

NewJSONRPCError creates a new JSON-RPC error with the given code and message

func NewJSONRPCErrorWithData

func NewJSONRPCErrorWithData(code int, message string, data interface{}) (*JSONRPCError, error)

NewJSONRPCErrorWithData creates a new JSON-RPC error with additional data

func ValidateJSONRPCRequest

func ValidateJSONRPCRequest(req *JSONRPCRequest) *JSONRPCError

ValidateJSONRPCRequest validates a JSON-RPC request envelope

type JSONRPCRequest

type JSONRPCRequest struct {
	JSONRPC string          `json:"jsonrpc"`
	ID      interface{}     `json:"id"`
	Method  string          `json:"method"`
	Params  json.RawMessage `json:"params,omitempty"`
}

JSONRPCRequest represents a JSON-RPC 2.0 request object

type JSONRPCResponse

type JSONRPCResponse struct {
	JSONRPC string          `json:"jsonrpc"`
	ID      interface{}     `json:"id"`
	Result  json.RawMessage `json:"result,omitempty"`
	Error   *JSONRPCError   `json:"error,omitempty"`
}

JSONRPCResponse represents a JSON-RPC 2.0 response object

type LogEntry

type LogEntry struct {
	Level   string    `json:"level"`
	Time    time.Time `json:"time"`
	Message string    `json:"message"`
}

LogEntry represents a single log line

type LogNotification

type LogNotification struct {
	StreamID string    `json:"stream_id"`
	Level    string    `json:"level"`
	Time     time.Time `json:"time"`
	Message  string    `json:"message"`
}

LogNotification represents a log streaming notification

type LogStreamResponse

type LogStreamResponse struct {
	StreamID string     `json:"stream_id"`
	Logs     []LogEntry `json:"logs"`
}

LogStreamResponse is the response for holon/logStream

type ManagerConfig

type ManagerConfig struct {
	AgentHome        string
	StateDir         string
	Handler          EventHandler
	WebhookPort      int // 0 means use the default port (8080)
	TurnDispatcher   TurnDispatcher
	DefaultSessionID string
	NoDefaultSession bool

	// Hot reload configuration. When unset, defaults are used.
	ReloadDebounce           time.Duration // default: 600ms
	ReloadPollInterval       time.Duration // default: 3s
	DisableHotReload         bool
	ForwarderRestartCooldown time.Duration // default: 10s

	ForwarderFactory func(ForwarderConfig) (forwarderRunner, error)
}

ManagerConfig holds configuration for SubscriptionManager

type MethodHandler

type MethodHandler func(params json.RawMessage) (interface{}, *JSONRPCError)

MethodHandler is a function that handles a JSON-RPC method call

type MethodRegistry

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

MethodRegistry holds registered JSON-RPC methods

func NewMethodRegistry

func NewMethodRegistry() *MethodRegistry

NewMethodRegistry creates a new method registry

func (*MethodRegistry) Dispatch

func (r *MethodRegistry) Dispatch(method string, params json.RawMessage) (interface{}, *JSONRPCError)

Dispatch calls the appropriate method handler based on the method name

func (*MethodRegistry) RegisterMethod

func (r *MethodRegistry) RegisterMethod(name string, handler MethodHandler)

RegisterMethod registers a new method handler

type Notification

type Notification struct {
	JSONRPC string          `json:"jsonrpc"`
	Method  string          `json:"method"`
	Params  json.RawMessage `json:"params"`
}

Notification represents a server-sent notification following Codex protocol Notifications are JSON-RPC messages sent from server to client

type NotificationBroadcaster

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

NotificationBroadcaster broadcasts notifications to multiple subscribers

func NewNotificationBroadcaster

func NewNotificationBroadcaster() *NotificationBroadcaster

NewNotificationBroadcaster creates a new notification broadcaster

func (*NotificationBroadcaster) BroadcastItemNotification

func (nb *NotificationBroadcaster) BroadcastItemNotification(n ItemNotification)

BroadcastItemNotification broadcasts an item notification to all subscribers

func (*NotificationBroadcaster) BroadcastThreadNotification

func (nb *NotificationBroadcaster) BroadcastThreadNotification(n ThreadNotification)

BroadcastThreadNotification broadcasts a thread notification to all subscribers

func (*NotificationBroadcaster) BroadcastTurnNotification

func (nb *NotificationBroadcaster) BroadcastTurnNotification(n TurnNotification)

BroadcastTurnNotification broadcasts a turn notification to all subscribers

func (*NotificationBroadcaster) BroadcastTurnProgressNotification

func (nb *NotificationBroadcaster) BroadcastTurnProgressNotification(n TurnProgressNotification)

BroadcastTurnProgressNotification broadcasts a turn/progress notification to all subscribers.

func (*NotificationBroadcaster) Subscribe

func (nb *NotificationBroadcaster) Subscribe(sw *StreamWriter) func()

Subscribe adds a new subscriber to receive notifications

func (*NotificationBroadcaster) Unsubscribe

func (nb *NotificationBroadcaster) Unsubscribe(sw *StreamWriter)

Unsubscribe removes a subscriber

type NotificationParams

type NotificationParams interface{}

NotificationParams is the base interface for notification parameters

type PauseResponse

type PauseResponse struct {
	Success bool   `json:"success"`
	Message string `json:"message"`
}

PauseResponse is the response for holon/pause

type ResumeResponse

type ResumeResponse struct {
	Success bool   `json:"success"`
	Message string `json:"message"`
}

ResumeResponse is the response for holon/resume

type Runtime

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

Runtime manages the serve runtime state

func NewRuntime

func NewRuntime(stateDir string) (*Runtime, error)

NewRuntime creates a new runtime manager

func NewRuntimeWithOptions

func NewRuntimeWithOptions(stateDir string, opts RuntimeOptions) (*Runtime, error)

func (*Runtime) GetState

func (rt *Runtime) GetState() RuntimeState

GetState returns a copy of the current runtime state

func (*Runtime) HandleLogStream

func (rt *Runtime) HandleLogStream(logPath string) func(json.RawMessage) (interface{}, *JSONRPCError)

HandleLogStream is the JSON-RPC handler for holon/logStream

func (*Runtime) HandlePause

func (rt *Runtime) HandlePause(params json.RawMessage) (interface{}, *JSONRPCError)

HandlePause is the JSON-RPC handler for holon/pause

func (*Runtime) HandleResume

func (rt *Runtime) HandleResume(params json.RawMessage) (interface{}, *JSONRPCError)

HandleResume is the JSON-RPC handler for holon/resume

func (*Runtime) HandleStatus

func (rt *Runtime) HandleStatus(params json.RawMessage) (interface{}, *JSONRPCError)

HandleStatus is the JSON-RPC handler for holon/status

func (*Runtime) HandleThreadStart

func (rt *Runtime) HandleThreadStart(params json.RawMessage) (interface{}, *JSONRPCError)

HandleThreadStart is the JSON-RPC handler for thread/start This maps to starting/resuming the controller session in Holon

func (*Runtime) HandleTurnAck

func (rt *Runtime) HandleTurnAck(turnID string, success bool, message string) bool

HandleTurnAck completes or interrupts an active turn from external runtime acknowledgements. Returns true when the ack matched an active turn.

func (*Runtime) HandleTurnInterrupt

func (rt *Runtime) HandleTurnInterrupt(params json.RawMessage) (interface{}, *JSONRPCError)

HandleTurnInterrupt is the JSON-RPC handler for turn/interrupt This maps to pausing event processing in Holon

func (*Runtime) HandleTurnProgress

func (rt *Runtime) HandleTurnProgress(record TurnAckRecord) bool

HandleTurnProgress emits non-terminal progress updates for an active turn.

func (*Runtime) HandleTurnStart

func (rt *Runtime) HandleTurnStart(params json.RawMessage) (interface{}, *JSONRPCError)

HandleTurnStart is the JSON-RPC handler for turn/start This maps to starting a new turn (event processing cycle) in Holon

func (*Runtime) HandleTurnSteer

func (rt *Runtime) HandleTurnSteer(params json.RawMessage) (interface{}, *JSONRPCError)

HandleTurnSteer is the JSON-RPC handler for turn/steer.

func (*Runtime) IsPaused

func (rt *Runtime) IsPaused() bool

IsPaused returns true if the runtime is paused

func (*Runtime) Pause

func (rt *Runtime) Pause() error

Pause pauses the runtime

func (*Runtime) RecordEvent

func (rt *Runtime) RecordEvent(eventID string)

RecordEvent records that an event was processed

func (*Runtime) Resume

func (rt *Runtime) Resume() error

Resume resumes the runtime

func (*Runtime) SetBroadcaster

func (rt *Runtime) SetBroadcaster(b *NotificationBroadcaster)

SetBroadcaster injects a notification broadcaster for turn/thread/item events.

func (*Runtime) SetSessionID

func (rt *Runtime) SetSessionID(sessionID string)

SetSessionID sets the current runtime session ID

func (*Runtime) SetTurnDispatcher

func (rt *Runtime) SetTurnDispatcher(dispatcher TurnDispatcher)

SetTurnDispatcher injects the runtime dispatcher for turn/start requests.

func (*Runtime) SetTurnInterruptDispatcher

func (rt *Runtime) SetTurnInterruptDispatcher(interruptor TurnInterruptDispatcher)

SetTurnInterruptDispatcher injects the runtime dispatcher for turn/interrupt requests.

type RuntimeOptions

type RuntimeOptions struct {
	// DefaultSessionID is the thread/session id that will be created on startup
	// when no persisted SessionID exists.
	// If empty, "main" is used.
	DefaultSessionID string
	// NoDefaultSession disables creating/loading a default session id.
	NoDefaultSession bool
}

type RuntimeState

type RuntimeState struct {
	State           string    `json:"state"` // running, paused
	EventsProcessed int64     `json:"events_processed"`
	LastEventAt     time.Time `json:"last_event_at"`
	SessionID       string    `json:"session_id"`
	PausedAt        time.Time `json:"paused_at,omitempty"`
	ResumedAt       time.Time `json:"resumed_at,omitempty"`
	// contains filtered or unexported fields
}

RuntimeState tracks the current state of the serve runtime

type Service

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

func New

func New(cfg Config) (*Service, error)

func (*Service) Close

func (s *Service) Close() error

func (*Service) InjectEvent

func (s *Service) InjectEvent(ctx context.Context, env EventEnvelope) error

func (*Service) Run

func (s *Service) Run(ctx context.Context, r io.Reader, maxEvents int) error

type SkipEventError

type SkipEventError struct {
	Reason string
}

SkipEventError indicates the event is valid but should not trigger execution.

func (*SkipEventError) Error

func (e *SkipEventError) Error() string

type StatusResponse

type StatusResponse struct {
	State           string    `json:"state"`
	EventsProcessed int64     `json:"events_processed"`
	LastEventAt     time.Time `json:"last_event_at"`
	SessionID       string    `json:"session_id"`
	PausedAt        time.Time `json:"paused_at,omitempty"`
	ResumedAt       time.Time `json:"resumed_at,omitempty"`
}

StatusResponse is the response for holon/status

type StreamHandler

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

StreamHandler handles bidirectional streaming for JSON-RPC

func NewStreamHandler

func NewStreamHandler(runtime *Runtime) *StreamHandler

NewStreamHandler creates a new stream handler

func (*StreamHandler) HandleStream

func (sh *StreamHandler) HandleStream(ctx context.Context, w http.ResponseWriter, r *http.Request) error

HandleStream processes a streaming connection This implements server-sent events style streaming over NDJSON

type StreamWriter

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

StreamWriter handles writing notifications to a streaming connection

func NewStreamWriter

func NewStreamWriter(w io.Writer) *StreamWriter

NewStreamWriter creates a new stream writer for NDJSON streaming

func (*StreamWriter) Close

func (sw *StreamWriter) Close() error

Close closes the stream writer

func (*StreamWriter) WriteItemNotification

func (sw *StreamWriter) WriteItemNotification(n ItemNotification) error

WriteItemNotification writes an item notification to the stream

func (*StreamWriter) WriteKeepAlive

func (sw *StreamWriter) WriteKeepAlive() error

WriteKeepAlive writes a blank NDJSON separator line to keep long-lived stream connections open through intermediaries.

func (*StreamWriter) WriteNotification

func (sw *StreamWriter) WriteNotification(n Notification) error

WriteNotification writes a notification to the stream

func (*StreamWriter) WriteThreadNotification

func (sw *StreamWriter) WriteThreadNotification(n ThreadNotification) error

WriteThreadNotification writes a thread notification to the stream

func (*StreamWriter) WriteTurnNotification

func (sw *StreamWriter) WriteTurnNotification(n TurnNotification) error

WriteTurnNotification writes a turn notification to the stream

type SubscriptionManager

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

SubscriptionManager manages active subscriptions and their transport

func NewSubscriptionManager

func NewSubscriptionManager(cfg ManagerConfig) (*SubscriptionManager, error)

NewSubscriptionManager creates a new subscription manager

func (*SubscriptionManager) GetWebhookPort

func (sm *SubscriptionManager) GetWebhookPort() int

GetWebhookPort returns the webhook port if running, 0 otherwise

func (*SubscriptionManager) InjectEvent

func (sm *SubscriptionManager) InjectEvent(ctx context.Context, env EventEnvelope) error

InjectEvent injects an event into the webhook server (for timer ticks, etc)

func (*SubscriptionManager) IsRunning

func (sm *SubscriptionManager) IsRunning() bool

IsRunning returns true if the subscription manager is running

func (*SubscriptionManager) Start

func (sm *SubscriptionManager) Start(ctx context.Context) error

Start starts the subscription manager and all configured subscriptions

func (*SubscriptionManager) Status

func (sm *SubscriptionManager) Status() map[string]interface{}

Status returns the current status of the subscription manager

func (*SubscriptionManager) Stop

func (sm *SubscriptionManager) Stop() error

Stop stops the subscription manager and all active subscriptions

func (*SubscriptionManager) SubscribedRepos

func (sm *SubscriptionManager) SubscribedRepos() []string

SubscribedRepos returns the repos declared in agent.yaml subscriptions.

func (*SubscriptionManager) WriteStatusFile

func (sm *SubscriptionManager) WriteStatusFile() error

WriteStatusFile writes the current status to a file in the state directory

type ThreadNotification

type ThreadNotification struct {
	ThreadID  string `json:"thread_id"`
	Type      string `json:"type"` // started, resumed, paused, closed
	State     string `json:"state"`
	StartedAt string `json:"started_at,omitempty"`
	Message   string `json:"message,omitempty"`
}

ThreadNotification represents a thread lifecycle notification Corresponds to Codex "thread/*" notifications

func NewThreadNotification

func NewThreadNotification(threadID, notificationType, state string) ThreadNotification

NewThreadNotification creates a new thread notification

func (ThreadNotification) ToJSONRPCNotification

func (n ThreadNotification) ToJSONRPCNotification() (Notification, error)

ToJSONRPCNotification converts a ThreadNotification to a JSON-RPC notification

type ThreadStartRequest

type ThreadStartRequest struct {
	ThreadID string `json:"thread_id,omitempty"`
	// ExtendedContext is optional context for the thread
	ExtendedContext map[string]interface{} `json:"extended_context,omitempty"`
}

ThreadStartRequest represents parameters for thread/start

type ThreadStartResponse

type ThreadStartResponse struct {
	ThreadID string `json:"thread_id"`
	// Holon maps thread concept to controller session
	SessionID string `json:"session_id"`
	StartedAt string `json:"started_at"`
}

ThreadStartResponse is the response for thread/start

type TurnAckRecord

type TurnAckRecord struct {
	EventID       string `json:"event_id,omitempty"`
	TurnID        string `json:"turn_id,omitempty"`
	ThreadID      string `json:"thread_id,omitempty"`
	Status        string `json:"status"`
	Message       string `json:"message,omitempty"`
	At            string `json:"at,omitempty"`
	WorkspaceRef  string `json:"workspace_ref,omitempty"`
	WorkspacePath string `json:"workspace_path,omitempty"`
}

TurnAckRecord carries turn completion status from the controller runtime back into the serve runtime.

type TurnAckSource

type TurnAckSource interface {
	TurnAcks() <-chan TurnAckRecord
}

TurnAckSource exposes an in-memory stream of turn ack events.

type TurnDispatcher

type TurnDispatcher func(ctx context.Context, req TurnStartRequest, turnID string) error

TurnDispatcher handles user turn input and forwards it to the real controller runtime.

type TurnInputContentPart

type TurnInputContentPart struct {
	Type string `json:"type,omitempty"`
	Text string `json:"text,omitempty"`
}

TurnInputContentPart represents one message content fragment.

type TurnInputMessage

type TurnInputMessage struct {
	Type    string                 `json:"type,omitempty"`
	Role    string                 `json:"role,omitempty"`
	Content []TurnInputContentPart `json:"content,omitempty"`
}

TurnInputMessage represents a user message item for turn/start or turn/steer.

type TurnInterruptDispatcher

type TurnInterruptDispatcher func(ctx context.Context, turnID, threadID, reason string) error

TurnInterruptDispatcher handles targeted turn interruption and propagates cancellation to the backend controller runtime.

type TurnInterruptRequest

type TurnInterruptRequest struct {
	TurnID string `json:"turn_id,omitempty"`
	Reason string `json:"reason,omitempty"`
}

TurnInterruptRequest represents parameters for turn/interrupt

type TurnInterruptResponse

type TurnInterruptResponse struct {
	TurnID        string `json:"turn_id"`
	State         string `json:"state"`
	InterruptedAt string `json:"interrupted_at"`
	Message       string `json:"message"`
}

TurnInterruptResponse is the response for turn/interrupt

type TurnNotification

type TurnNotification struct {
	TurnID      string `json:"turn_id"`
	Type        string `json:"type"` // started, completed, interrupted
	State       string `json:"state"`
	ThreadID    string `json:"thread_id,omitempty"`
	StartedAt   string `json:"started_at,omitempty"`
	CompletedAt string `json:"completed_at,omitempty"`
	Message     string `json:"message,omitempty"`
}

TurnNotification represents a turn lifecycle notification Corresponds to Codex "turn/*" notifications

func NewTurnNotification

func NewTurnNotification(turnID, notificationType, state string) TurnNotification

NewTurnNotification creates a new turn notification

func (TurnNotification) ToJSONRPCNotification

func (n TurnNotification) ToJSONRPCNotification() (Notification, error)

ToJSONRPCNotification converts a TurnNotification to a JSON-RPC notification

type TurnProgressNotification

type TurnProgressNotification struct {
	TurnID    string `json:"turn_id"`
	ThreadID  string `json:"thread_id,omitempty"`
	State     string `json:"state"`
	Message   string `json:"message,omitempty"`
	EventID   string `json:"event_id,omitempty"`
	UpdatedAt string `json:"updated_at,omitempty"`
	ElapsedMS int64  `json:"elapsed_ms,omitempty"`
}

TurnProgressNotification represents non-terminal turn lifecycle updates. Corresponds to Codex "turn/progress" notifications.

func NewTurnProgressNotification

func NewTurnProgressNotification(turnID, state string) TurnProgressNotification

NewTurnProgressNotification creates a new non-terminal turn progress notification.

func (TurnProgressNotification) ToJSONRPCNotification

func (n TurnProgressNotification) ToJSONRPCNotification() (Notification, error)

ToJSONRPCNotification converts a TurnProgressNotification to a JSON-RPC notification.

type TurnStartRequest

type TurnStartRequest struct {
	ThreadID string             `json:"thread_id,omitempty"`
	Input    []TurnInputMessage `json:"input,omitempty"`
	// ExtendedContext is optional context for the turn
	ExtendedContext map[string]interface{} `json:"extended_context,omitempty"`
}

TurnStartRequest represents parameters for turn/start

type TurnStartResponse

type TurnStartResponse struct {
	TurnID string `json:"turn_id"`
	// In Holon, a turn maps to an event processing cycle
	State     string `json:"state"`
	StartedAt string `json:"started_at"`
}

TurnStartResponse is the response for turn/start

type TurnSteerRequest

type TurnSteerRequest struct {
	TurnID string             `json:"turn_id,omitempty"`
	Input  []TurnInputMessage `json:"input,omitempty"`
	// ExtendedContext is optional context for steering
	ExtendedContext map[string]interface{} `json:"extended_context,omitempty"`
}

TurnSteerRequest represents parameters for turn/steer

type TurnSteerResponse

type TurnSteerResponse struct {
	TurnID        string `json:"turn_id"`
	State         string `json:"state"`
	AcceptedItems int    `json:"accepted_items"`
	AcceptedAt    string `json:"accepted_at"`
}

TurnSteerResponse is the response for turn/steer.

type WebSocketMessageHandler

type WebSocketMessageHandler func(ctx context.Context, raw []byte) error

type WebSocketSource

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

func NewWebSocketSource

func NewWebSocketSource(cfg WebSocketSourceConfig) *WebSocketSource

func (*WebSocketSource) Start

func (*WebSocketSource) Status

func (s *WebSocketSource) Status() map[string]interface{}

func (*WebSocketSource) Stop

func (s *WebSocketSource) Stop() error

type WebSocketSourceConfig

type WebSocketSourceConfig struct {
	URL string
}

type WebhookConfig

type WebhookConfig struct {
	Port             int
	RepoHint         string
	StateDir         string
	Handler          EventHandler
	TurnDispatcher   TurnDispatcher
	DefaultSessionID string
	NoDefaultSession bool
	ReadTimeout      time.Duration
	WriteTimeout     time.Duration
	IdleTimeout      time.Duration
	MaxBodySize      int64
	ChannelTimeout   time.Duration
}

WebhookConfig configures the webhook server

type WebhookServer

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

WebhookServer handles incoming GitHub webhook HTTP requests

func NewWebhookServer

func NewWebhookServer(cfg WebhookConfig) (*WebhookServer, error)

NewWebhookServer creates a new webhook server for GitHub events

func (*WebhookServer) Close

func (ws *WebhookServer) Close() error

Close stops the webhook server and closes log files

func (*WebhookServer) InjectEvent

func (ws *WebhookServer) InjectEvent(ctx context.Context, env EventEnvelope) error

InjectEvent allows internal producers (e.g. timer source) to route events through the same webhook processing pipeline.

func (*WebhookServer) Port

func (ws *WebhookServer) Port() int

Port returns the port the webhook server is listening on

func (*WebhookServer) Start

func (ws *WebhookServer) Start(ctx context.Context) error

Start begins accepting webhook requests

Jump to

Keyboard shortcuts

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