execruntime

package
v0.0.0-...-63ae334 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CleanupRequest

type CleanupRequest struct {
	SessionID id.ID
	ChatID    id.ID
	Scope     Scope
	MaxBytes  int
}

type Event

type Event struct {
	Kind     EventKind
	Snapshot Snapshot
	Delta    string
}

type EventKind

type EventKind string
const (
	EventKindOutput EventKind = "output"
	EventKindInput  EventKind = "input"
	EventKindState  EventKind = "state"
)

type ListRequest

type ListRequest struct {
	SessionID id.ID
	ChatID    id.ID
	Scope     Scope
	MaxBytes  int
}

type Manager

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

func NewManager

func NewManager() *Manager

func (*Manager) Cleanup

func (m *Manager) Cleanup(_ context.Context, req CleanupRequest) ([]Snapshot, error)

func (*Manager) ClearPreviousJobs

func (m *Manager) ClearPreviousJobs() error

func (*Manager) ExitReportsPending

func (m *Manager) ExitReportsPending(sessionID, chatID id.ID) <-chan bool

ExitReportsPending returns nil when no session in the chat may still report its exit. Otherwise the channel receives once all of them have ended: true when at least one sent a report, false when each ended without one, for example because a tool result showed the exit or it was stopped on request.

func (*Manager) List

func (m *Manager) List(_ context.Context, req ListRequest) ([]Snapshot, error)

func (*Manager) PreviousJobs

func (m *Manager) PreviousJobs() (RestartJournal, error)

func (*Manager) Resize

func (m *Manager) Resize(_ context.Context, req ResizeRequest) (Snapshot, error)

func (*Manager) Running

func (m *Manager) Running() int

Running counts the processes still running in any session.

func (*Manager) SetNotifier

func (m *Manager) SetNotifier(notify func(Notification))

SetNotifier sets where exec sessions send their reports.

func (*Manager) SetRestartJournal

func (m *Manager) SetRestartJournal(path string)

SetRestartJournal configures durable lifecycle tracking before any jobs start.

func (*Manager) Shutdown

func (m *Manager) Shutdown(ctx context.Context) error

Shutdown records and stops jobs after chat runtimes have drained. Keeping the final journal lets the next process explain exactly what shutdown interrupted.

func (*Manager) Start

func (m *Manager) Start(ctx context.Context, req StartRequest) (Snapshot, error)

func (*Manager) Status

func (m *Manager) Status(_ context.Context, req StatusRequest) (Snapshot, error)

func (*Manager) Subscribe

func (m *Manager) Subscribe(chatID id.ID) (<-chan Event, func())

func (*Manager) Terminate

func (m *Manager) Terminate(_ context.Context, req TerminateRequest) (Snapshot, error)

func (*Manager) WriteStdin

func (m *Manager) WriteStdin(ctx context.Context, req WriteStdinRequest) (Snapshot, error)

type Notification

type Notification struct {
	SessionID id.ID
	ChatID    id.ID
	ProcessID string
	Kind      NotificationKind
	Text      string
}

Notification is a report an exec session sends to its chat.

type NotificationKind

type NotificationKind string

NotificationKind distinguishes output events from the final exit report.

const (
	NotificationExit  NotificationKind = "exit"
	NotificationLines NotificationKind = "lines"
	NotificationAge   NotificationKind = "age"
)

type NotifyMode

type NotifyMode string

NotifyMode says what an exec session reports to its chat on its own after exec_command has returned.

const (
	// NotifyExit reports the exit once, unless a tool result already showed it.
	NotifyExit NotifyMode = "exit"
	// NotifyLines reports each batch of new output lines, then the exit.
	NotifyLines NotifyMode = "lines"
)

func ParseNotifyMode

func ParseNotifyMode(value string) (NotifyMode, error)

ParseNotifyMode reads a notify argument; empty means NotifyExit.

type ResizeRequest

type ResizeRequest struct {
	SessionID id.ID
	ChatID    id.ID
	ProcessID string
	Size      TerminalSize
	MaxBytes  int
}

type ResourceUsage

type ResourceUsage struct {
	CPUSeconds float64 `json:"cpu_seconds"`
	CPUPercent float64 `json:"cpu_average_percent"`
	RSSBytes   uint64  `json:"rss_bytes,omitempty"`
	Processes  int     `json:"process_count,omitempty"`
}

ResourceUsage is a best-effort aggregate over the command's process tree. CPUPercent is the lifetime average: 100% means one fully occupied core.

type RestartJournal

type RestartJournal struct {
	RecordedAt time.Time
	Terminated bool
	Jobs       []Snapshot
}

RestartJournal records jobs owned by the previous Koder process, never handles that can be reattached to the new manager.

func (RestartJournal) ChatNotice

func (j RestartJournal) ChatNotice(chatID id.ID) string

type Scope

type Scope string
const (
	ScopeChat    Scope = "chat"
	ScopeSession Scope = "session"
)

type Snapshot

type Snapshot struct {
	PID        int
	Elapsed    time.Duration
	Resources  *ResourceUsage
	ProcessID  string
	SessionID  id.ID
	ChatID     id.ID
	ToolCallID string
	Command    string
	// Label is the user-facing description the command was started with.
	Label       string
	Workdir     string
	Shell       string
	TTY         bool
	State       State
	ExitCode    *int
	StartedAt   time.Time
	EndedAt     time.Time
	TimeoutMS   int64
	Output      string
	OutputBytes int
	// Omitted counts bytes of this snapshot's output range left out of
	// Output by the size limit; the kept part is the end.
	Omitted     int
	Stream      []StreamEntry
	Drained     bool
	StdinClosed bool
	Lost        bool
	// ExitReported is set once the exit has been sent to the chat as a
	// notification, together with the output not shown before.
	ExitReported bool
}

type StartRequest

type StartRequest struct {
	AllowDuplicate bool
	SessionID      id.ID
	ChatID         id.ID
	ToolCallID     string
	Command        string
	Workdir        string
	SessionRoot    string
	Shell          string
	Login          bool
	TTY            bool
	Timeout        time.Duration
	YieldTime      time.Duration
	PreviewBytes   int
	AccessSettings accesssettings.Settings
	// Label is the user-facing description shown in notifications.
	Label  string
	Notify NotifyMode
}

type State

type State string
const (
	StateRunning    State = "running"
	StateCompleted  State = "completed"
	StateFailed     State = "failed"
	StateTerminated State = "terminated"
	StateLost       State = "lost"
)

type StatusRequest

type StatusRequest struct {
	SessionID id.ID
	ChatID    id.ID
	ProcessID string
	MaxBytes  int
}

type StreamEntry

type StreamEntry struct {
	Source StreamSource
	Text   string
}

type StreamSource

type StreamSource string
const (
	StreamSourceOutput StreamSource = "output"
	StreamSourceStdout StreamSource = "stdout"
	StreamSourceStderr StreamSource = "stderr"
	StreamSourceInput  StreamSource = "input"
)

type TerminalSize

type TerminalSize struct {
	Rows int
	Cols int
}

type TerminateRequest

type TerminateRequest struct {
	SessionID id.ID
	ChatID    id.ID
	ProcessID string
	MaxBytes  int
}

type WriteStdinRequest

type WriteStdinRequest struct {
	SessionID  id.ID
	ChatID     id.ID
	ProcessID  string
	Chars      string
	CloseStdin bool
	MaxBytes   int
	YieldTime  time.Duration
}

Jump to

Keyboard shortcuts

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