Documentation
¶
Index ¶
- type CleanupRequest
- type Control
- type Event
- type EventKind
- type ListRequest
- type Manager
- func (m *Manager) Cleanup(_ context.Context, req CleanupRequest) ([]Snapshot, error)
- func (m *Manager) ClearPreviousJobs() error
- func (m *Manager) ExitReportsPending(sessionID, chatID id.ID) <-chan bool
- func (m *Manager) List(_ context.Context, req ListRequest) ([]Snapshot, error)
- func (m *Manager) PreviousJobs() (RestartJournal, error)
- func (m *Manager) Resize(_ context.Context, req ResizeRequest) (Snapshot, error)
- func (m *Manager) Running() int
- func (m *Manager) SetNotifier(notify func(Notification))
- func (m *Manager) SetRestartJournal(path string)
- func (m *Manager) Shutdown(ctx context.Context) error
- func (m *Manager) Start(ctx context.Context, req StartRequest) (Snapshot, error)
- func (m *Manager) Status(_ context.Context, req StatusRequest) (Snapshot, error)
- func (m *Manager) Subscribe(chatID id.ID) (<-chan Event, func())
- func (m *Manager) Terminate(_ context.Context, req TerminateRequest) (Snapshot, error)
- func (m *Manager) WriteStdin(ctx context.Context, req WriteStdinRequest) (Snapshot, error)
- type Notification
- type NotificationKind
- type NotifyMode
- type ResizeRequest
- type ResourceUsage
- type RestartJournal
- type Scope
- type Snapshot
- type StartRequest
- type State
- type StatusRequest
- type StreamEntry
- type StreamSource
- type TerminalSize
- type TerminateRequest
- type WriteStdinRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CleanupRequest ¶
type Control ¶
type Control interface {
Start(context.Context, StartRequest) (Snapshot, error)
Status(context.Context, StatusRequest) (Snapshot, error)
List(context.Context, ListRequest) ([]Snapshot, error)
WriteStdin(context.Context, WriteStdinRequest) (Snapshot, error)
Resize(context.Context, ResizeRequest) (Snapshot, error)
Terminate(context.Context, TerminateRequest) (Snapshot, error)
Cleanup(context.Context, CleanupRequest) ([]Snapshot, error)
}
type ListRequest ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func NewManager ¶
func NewManager() *Manager
func (*Manager) ClearPreviousJobs ¶
func (*Manager) ExitReportsPending ¶
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) PreviousJobs ¶
func (m *Manager) PreviousJobs() (RestartJournal, error)
func (*Manager) SetNotifier ¶
func (m *Manager) SetNotifier(notify func(Notification))
SetNotifier sets where exec sessions send their reports.
func (*Manager) SetRestartJournal ¶
SetRestartJournal configures durable lifecycle tracking before any jobs start.
func (*Manager) Shutdown ¶
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) WriteStdin ¶
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 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 ¶
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 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 StatusRequest ¶
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" )