taskmgr

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: AGPL-3.0 Imports: 30 Imported by: 0

Documentation

Overview

Package taskmgr coordinates task execution, pending prompts, attachments, and ordered runtime history import.

It sits between the HTTP adapter (internal/server) and task execution (internal/task/taskrun). Manager owns the registry of running tasks and repository checkouts; Lifecycle performs operations for one task.

Two contexts coexist here. Methods accept a request-scoped ctx that is honored for synchronous work (state checks, logging). Background goroutines that must outlive any single request use serverCtx instead — it tracks the lifetime of the Manager itself.

A task incarnation publishes one terminal result through Entry.Finish, and a purge is final for that incarnation: the runtime instance is gone, so a stop that publishes afterwards cannot replace the purged snapshot. Lifecycle operations that publish terminal results, meaning Stop, Revive, and the purge completion, hold operationMu so the result order follows the state order.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrToolUseAmbiguous reports a provider tool-use ID recorded by more than
	// one source, which a query without a source cannot resolve.
	ErrToolUseAmbiguous = errors.New("tool use ID is ambiguous; specify its source")
	// ErrToolUseNotFound reports a tool-use ID absent from the task's history.
	ErrToolUseNotFound = errors.New("tool use not found")
)
View Source
var ErrNoSession = errors.New("no active session")

ErrNoSession is a sentinel reported by Manager.SendInput when the task has no active agent session to forward input to.

The returned *NoSessionError wraps the underlying task.SendInput diagnostic and, when recovery was attempted, the reconnect failure.

Functions

This section is empty.

Types

type BotPendingTask

type BotPendingTask struct {
	TaskID      ksid.ID
	ForgeOwner  string
	ForgeRepo   string
	IssueNumber int
}

BotPendingTask is returned by ListPendingBotTasks.

type Code added in v0.12.0

type Code string

Code identifies a specific task-manager error within its broader ErrorKind.

const (
	// CodeUnknownHarness reports a coding agent harness that is unavailable.
	CodeUnknownHarness Code = "UNKNOWN_HARNESS"
	// CodeUnknownRepository reports a repository that is not registered with caic.
	CodeUnknownRepository Code = "UNKNOWN_REPOSITORY"
	// CodeUnsupportedModel reports a model unavailable from the selected harness.
	CodeUnsupportedModel Code = "UNSUPPORTED_MODEL"
	// CodeUnknownRuntime reports a runtime that is unavailable.
	CodeUnknownRuntime Code = "UNKNOWN_RUNTIME"
)

type Config

type Config struct {
	// ServerCtx tracks the Manager's own lifetime. Used as the parent for
	// background goroutines that must survive individual requests.
	ServerCtx context.Context
	Log       *slog.Logger
	// LogStore is the task-log directory the Manager appends task logs to. It
	// must be non-nil.
	LogStore *taskhistory.Store
	// Runtimes validates runtime selection and dispatches task runtime operations.
	Runtimes             *runtime.Router
	Backends             agent.Backends
	HarnessEnv           map[string][]string
	RuntimeMetadata      runtime.Metadata
	RuntimeStartTimeout  time.Duration
	EnsureSessionTimeout time.Duration
	Provider             genai.Provider // nil-safe
	// Pricer resolves per-model token pricing for cost reporting. When nil,
	// a default quota-provider pricer is used.
	Pricer quotausage.ModelPricer
	// Rollup consumes task messages for the cross-task usage rollup. Required.
	Rollup    task.RollupSink
	Checkouts *repo.Registry
}

Config holds the dependencies Manager needs at construction.

type CreateParams

type CreateParams struct {
	OwnerID           string // empty in no-auth mode
	Prompt            agent.Prompt
	Repos             []CreateRepo // first entry is primary; empty = no-repo
	Harness           harness.Name
	ResumeSessionID   string // opaque harness-native session ID; empty starts a fresh session
	Model             string // "" = harness default
	Effort            string // thinking effort; empty = default
	Tailscale         bool
	USB               bool
	Display           bool
	Sudo              bool
	GitHubToken       bool                 // inject GitHub token into the runtime environment
	RuntimeName       runtime.Name         // selected runtime backend; empty means backend default
	BaseImage         string               // resolved base image
	ContainerPlatform string               // resolved container platform; empty means use host default
	MaxCPUs           int                  // max CPU cores; 0 means use the default
	CacheMounts       []runtime.CacheMount // resolved build cache mounts
	Mounts            []runtime.Mount      // resolved runtime bind mounts
	CaicMCP           bool                 // grant this task its task-scoped CAIC MCP capability

	// ResolvedGitHubToken is the actual token string, resolved by the caller in
	// the request ctx; passed to checkout.Start. The caller resolves it (preferring
	// the logged-in user's OAuth token) because the Manager's serverCtx carries
	// no user identity.
	ResolvedGitHubToken string

	// Bot-task fields. The HTTP path leaves these zero (no-op); the bot sets them
	// so ListPendingBotTasks and commenter resolution work. When ForgeOwner is
	// non-empty, Create calls t.SetPR(ForgeOwner, ForgeRepo, 0).
	ForgeIssue int
	ForgeOwner string
	ForgeRepo  string
}

CreateParams bundles the HTTP path's task-creation parameters. The caller (Server) reads docker image, GitHub token access, and per-repo prefs from the user's preferences store before calling Create.

type CreateRepo

type CreateRepo struct {
	Name       string // relative path
	BaseBranch string // empty = checkout default
}

CreateRepo describes a repo to mount in the new task.

type Entry

type Entry struct {
	// Immutable.
	Lifecycle *Lifecycle

	// LogPath owns the current physical log path for this entry lifecycle.
	LogPath taskslog.Path
	// contains filtered or unexported fields
}

Entry is a single registered task plus its mutable lifecycle state.

Concurrency: task, lifecycle, and historyInMemory are immutable after registration. LogPath manages its own synchronization. The terminal state is an immutable snapshot published through term; see entryTerminal. pendingInput, loadedTask, monitorBranch, and cleanupOnce are guarded by mu and must only be accessed through methods. historyMemo is guarded by historyGate.

func (*Entry) Cleanup

func (e *Entry) Cleanup(fn func())

Cleanup runs fn exactly once per incarnation. Used to guard checkout.Cleanup against racing Stop/Purge calls.

func (*Entry) Done

func (e *Entry) Done() <-chan struct{}

Done returns the channel that closes when the task reaches a terminal state. Revival or clearing a result after reconnect returns a fresh channel; goroutines that captured the previous channel will see a stale (already-closed) reference.

func (*Entry) Finish

func (e *Entry) Finish(r *task.Result)

Finish records the completion result and closes the done channel in one step: the snapshot is stored before done closes, so any goroutine that observes Done() closed is guaranteed to also observe Result(). Concurrent callers race and the last store wins, except that a purged result is final: the purge removes the runtime instance, and the stop it superseded can publish its older snapshot afterwards. If the task is already terminal, Finish only refreshes the result.

func (*Entry) LoadedTask

func (e *Entry) LoadedTask() *taskhistory.LoadedTask

LoadedTask returns the on-disk log handle, or nil before a task log has been validated for stored-history reads.

func (*Entry) MonitorBranch

func (e *Entry) MonitorBranch() string

MonitorBranch returns the branch being monitored for CI, or "".

func (*Entry) PendingInput added in v0.15.0

func (e *Entry) PendingInput() *PendingInput

PendingInput returns this task's immutable pending prompt, or nil.

func (*Entry) PendingInputImage added in v0.15.0

func (e *Entry) PendingInputImage(id ksid.ID, index int) (v3.ImageData, bool)

PendingInputImage returns an original attachment only if the pending identity matches.

func (*Entry) RecordHost added in v0.15.0

func (e *Entry) RecordHost(ctx context.Context, m agent.Message) error

RecordHost commits a backend control through the entry's journal owner.

func (*Entry) RecordRepositorySummary added in v0.15.0

func (e *Entry) RecordRepositorySummary(ctx context.Context, read *repo.GitSnapshot) (bool, error)

RecordRepositorySummary commits a fresh repository observation before publishing it.

func (*Entry) Reset

func (e *Entry) Reset()

Reset prepares the entry for Revive: a fresh terminal snapshot with an open done channel and no result, plus a new cleanupOnce. Only safe when the task is in a terminal state and no goroutine is concurrently touching the entry's mutable fields.

func (*Entry) Result

func (e *Entry) Result() *task.Result

Result returns the completion result of the current incarnation, or nil if the task hasn't completed.

func (*Entry) SetLoadedTask added in v0.11.5

func (e *Entry) SetLoadedTask(lt *taskhistory.LoadedTask)

SetLoadedTask records a freshly validated on-disk log handle for stored-history reads.

func (*Entry) SetMonitorBranch

func (e *Entry) SetMonitorBranch(b string)

SetMonitorBranch records the branch to monitor for CI.

func (*Entry) Task

func (e *Entry) Task() *taskrun.Task

Task returns the underlying task. The returned *taskrun.Task is itself concurrency-safe via its own internal locking.

type Error

type Error struct {
	Kind ErrorKind
	Code Code
	Msg  string
	Err  error // wrapped underlying error, if any
}

Error is a typed error returned by Manager lifecycle methods. Kind classifies the failure; the HTTP layer maps it to a status code. An optional wrapped error is preserved for errors.Is/errors.As.

func (*Error) Error

func (e *Error) Error() string

Error implements error.

func (*Error) Unwrap

func (e *Error) Unwrap() error

Unwrap returns the wrapped error so errors.Is/errors.As traverse the chain.

type ErrorKind

type ErrorKind int

ErrorKind classifies a taskmgr.Error so the HTTP layer can map it to a status code without inspecting the message string.

const (
	// KindInternal is an unexpected or infrastructure failure (HTTP 500).
	KindInternal ErrorKind = iota
	// KindNotFound is a missing task or resource (HTTP 404).
	KindNotFound
	// KindConflict is a state/precondition violation (HTTP 409).
	KindConflict
	// KindBadRequest is invalid input (HTTP 400).
	KindBadRequest
)

func (ErrorKind) String

func (k ErrorKind) String() string

String returns the kind name.

type ForkParams

type ForkParams struct {
	OwnerID     string
	Prompt      agent.Prompt
	Harness     harness.Name // empty = use source's harness
	Model       string       // empty = use source's model
	Effort      string
	ExtraRepos  []ForkRepo
	GitHubToken bool // resolved override (handler derefs *bool, defaults to source)
	Tailscale   bool // resolved override (handler derefs *bool, defaults to source)
	USB         bool // resolved override
	Display     bool // resolved override
	Sudo        bool // resolved override

	// ResolvedGitHubToken is the actual token string, resolved by the caller in
	// the request ctx; passed to checkout.ForkTask. The caller resolves it
	// (preferring the logged-in user's OAuth token) because the Manager's
	// serverCtx carries no user identity.
	ResolvedGitHubToken string
	// contains filtered or unexported fields
}

ForkParams bundles fork task creation parameters.

The GitHubToken, Tailscale, USB, Display, and Sudo fields are resolved booleans: the HTTP handler dereferences the request's *bool overrides (falling back to the source task's value when nil) before calling Fork.

type ForkRepo

type ForkRepo struct {
	Name       string
	BaseBranch string
}

ForkRepo describes an extra repo to add to the fork.

type ImportError added in v0.14.0

type ImportError struct {
	Failed int
	Err    error
}

ImportError reports how many runtime instances failed task restoration. Instances skipped because they do not belong to caic are not failures.

func (*ImportError) Error added in v0.14.0

func (e *ImportError) Error() string

Error returns the underlying restoration diagnostics.

func (*ImportError) Unwrap added in v0.14.0

func (e *ImportError) Unwrap() error

Unwrap exposes the underlying restoration errors.

type Lifecycle added in v0.11.5

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

Lifecycle coordinates state transitions, session watching, and user operations for one entry. Manager owns the entry registry and shared state.

func (*Lifecycle) Cancel added in v0.15.0

func (r *Lifecycle) Cancel()

Cancel rejects new execution and interrupts local producers without sealing the journal.

func (*Lifecycle) CancelQueuedInput added in v0.15.0

func (r *Lifecycle) CancelQueuedInput(id ksid.ID) error

CancelQueuedInput removes a prompt only if it still belongs to this task's queue.

func (*Lifecycle) ClearContext added in v0.11.5

func (r *Lifecycle) ClearContext() error

ClearContext starts a fresh idle agent session.

func (*Lifecycle) Close added in v0.11.5

func (r *Lifecycle) Close() error

Close stops local producers and waits for lifecycle-owned recording and background work.

func (*Lifecycle) Compact added in v0.11.5

func (r *Lifecycle) Compact(ctx context.Context, instructions string) error

Compact asks the active agent session to compact its context.

func (*Lifecycle) Fork added in v0.11.5

func (r *Lifecycle) Fork(ctx context.Context, p *ForkParams) (ksid.ID, error)

Fork initializes and publishes a new task with readable history, then forks this task's retained runtime instance asynchronously.

p must be non-nil.

func (*Lifecycle) ForkDelegated added in v0.12.0

func (r *Lifecycle) ForkDelegated(ctx context.Context, p *ForkParams) (ksid.ID, error)

ForkDelegated creates a child from this task's server-owned runtime snapshot. The source task is recorded as the child's parent; callers cannot choose it.

func (*Lifecycle) ForkDelegatedFor added in v0.13.0

func (r *Lifecycle) ForkDelegatedFor(ctx context.Context, parentTaskID ksid.ID, p *ForkParams) (ksid.ID, error)

ForkDelegatedFor creates a child from this task's runtime snapshot for a server-authorized delegating task.

func (*Lifecycle) Purge added in v0.11.5

func (r *Lifecycle) Purge(ctx context.Context, delay time.Duration) error

Purge removes a stopped task immediately. Active tasks are stopped first and retain their runtime resources for delay so they can be revived.

func (*Lifecycle) QueueInput added in v0.15.0

func (r *Lifecycle) QueueInput(ctx context.Context, prompt agent.Prompt) (bool, error)

QueueInput appends to a pending prompt, or sends immediately when waiting. Otherwise it persists a new pending prompt. It reports whether the prompt was queued rather than sent.

func (*Lifecycle) Restart added in v0.11.5

func (r *Lifecycle) Restart(ctx context.Context, prompt agent.Prompt) error

Restart starts a fresh agent session with prompt.

func (*Lifecycle) Revive added in v0.11.5

func (r *Lifecycle) Revive() error

Revive restarts a stopped or crashed task.

func (*Lifecycle) SendInput added in v0.11.5

func (r *Lifecycle) SendInput(ctx context.Context, prompt agent.Prompt) error

SendInput forwards prompt to the agent session, reconnecting when needed.

func (*Lifecycle) Start added in v0.11.5

func (r *Lifecycle) Start(ctx context.Context, resolvedGitHubToken string) error

Start starts the runtime and agent session for a newly registered task.

func (*Lifecycle) Stop added in v0.11.5

func (r *Lifecycle) Stop(ctx context.Context) error

Stop transitions the task to stopping and stops its runtime without purging it. Failed and crashed tasks can retain a running instance after partial startup.

func (*Lifecycle) Sync added in v0.11.5

func (r *Lifecycle) Sync(ctx context.Context, target SyncTarget, force bool) (*SyncResult, error)

Sync pushes task commits to each repository's task or default branch and publishes refreshed diff statistics and repository state after a successful push.

type Manager

type Manager struct {
	// Immutable.
	agent.Backends

	Runtimes     *runtime.Router
	QuotaTracker *quotausage.Tracker
	Checkouts    *repo.Registry
	// contains filtered or unexported fields
}

Manager owns task lifecycle state, durable prompt queues, runtime import, session watching, and stats streaming.

func New

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

New creates a Manager. Register each repo checkout in Checkouts, then Start.

func (*Manager) BranchAssociated added in v0.12.0

func (m *Manager) BranchAssociated(repoName, branch string) bool

BranchAssociated reports whether a nonterminal task has claimed branch for repoName.

func (*Manager) Cancel added in v0.15.0

func (m *Manager) Cancel()

Cancel stops admission and signals local producers without closing their journals. App calls Cancel before joining automation; Close then joins all producers and seals the accepted task tails. Repeated cancellation is safe.

func (*Manager) ChangeSnapshot added in v0.13.0

func (m *Manager) ChangeSnapshot() (version uint64, changed <-chan struct{})

ChangeSnapshot returns the current task-change version and its notification channel. Callers that re-arm a change subscription must retain the version: it lets them install the replacement channel before handling the update that woke them, preventing another mutation in that handling window from being missed.

func (*Manager) Changed

func (m *Manager) Changed() <-chan struct{}

Changed returns a channel that is closed on task mutation.

func (*Manager) Close added in v0.11.2

func (m *Manager) Close() error

Close stops background work and waits for task lifecycles and all Manager watchers to finish.

func (*Manager) CompleteRestoration added in v0.14.0

func (m *Manager) CompleteRestoration(err error)

CompleteRestoration records the outcome after runtime and history restoration. A non-nil error leaves the registered partial subset usable, but prevents a task-list snapshot from certifying absence. Callers include errors from each restoration stage; a successful subsequent pass clears the previous error.

func (*Manager) Create

func (m *Manager) Create(ctx context.Context, p CreateParams) (ksid.ID, error)

Create initializes branch identity and history before publishing a task, then starts its runtime asynchronously. Preparation failures return without registering a task.

func (*Manager) EffectiveBaseBranch

func (m *Manager) EffectiveBaseBranch(t *taskrun.Task) string

EffectiveBaseBranch returns the branch the task was forked from.

func (*Manager) Entries added in v0.12.0

func (m *Manager) Entries() iter.Seq2[ksid.ID, *Entry]

Entries returns a point-in-time sequence of registered task entries.

The iteration order is unspecified. The sequence owns a shallow snapshot, so callers do not hold the manager lock while yielding entries.

func (*Manager) FindTasksByPR

func (m *Manager) FindTasksByPR(owner, repoName string, prNumber int) []*Entry

FindTasksByPR returns all entries matching the given forge owner/repo and PR number.

func (*Manager) FindTasksMatchingBranch

func (m *Manager) FindTasksMatchingBranch(owner, repoName, branch string) []*Entry

FindTasksMatchingBranch returns all entries for a forge owner/repo where the primary repo branch matches the given branch.

func (*Manager) FindTasksMonitoringBranch

func (m *Manager) FindTasksMonitoringBranch(owner, repoName string) []*Entry

FindTasksMonitoringBranch returns all entries that match the given forge owner/repo and have a monitor branch set.

func (*Manager) GetEntry

func (m *Manager) GetEntry(taskID ksid.ID) (*Entry, bool)

GetEntry returns the entry for taskID.

func (*Manager) HistorySource added in v0.11.5

func (m *Manager) HistorySource(entry *Entry) (*taskhistory.LoadedTask, error)

HistorySource opens a header-only raw-log reader for stopped or terminal history. It is the cold-history path: live readers should use the Task timeline rather than repeatedly reparsing its growing log.

func (*Manager) ImportInstances added in v0.11.5

func (m *Manager) ImportInstances(ctx context.Context, instances []runtime.Instance, allLogs []*taskhistory.LoadedTask) ([]*Entry, error)

ImportInstances registers preexisting runtime instances as tasks. Failures return an ImportError counting affected instances alongside successful entries.

func (*Manager) Insert

func (m *Manager) Insert(id ksid.ID, entry *Entry)

Insert registers a pre-built entry. Production task creation goes through Create/Fork; Insert is retained for tests (in internal/tasks and internal/server) that seed the registry without a real checkout.

func (*Manager) LastAgentMessage added in v0.15.0

func (m *Manager) LastAgentMessage(ctx context.Context, entry *Entry) (agent.Message, error)

LastAgentMessage returns the newest text, question, or result message the task's agent produced outside a child source, or nil when it produced none.

Live and adopted tasks read their in-memory timeline. Restored cold tasks decode their log once and retain the answer until the log changes, because a whole-log decode costs seconds on a large task.

func (*Manager) Len

func (m *Manager) Len() int

Len returns the number of registered entries.

func (*Manager) ListPendingBotTasks

func (m *Manager) ListPendingBotTasks() []BotPendingTask

ListPendingBotTasks returns non-terminal tasks that have a ForgeIssue set.

func (*Manager) LoadPurgedTasks

func (m *Manager) LoadPurgedTasks(purged []*taskhistory.LoadedTask) error

LoadPurgedTasks registers settled task logs selected by the taskslog settled scan, which already caps entries per repo before a full decode.

func (*Manager) LoadUnsettledTasks added in v0.11.6

func (m *Manager) LoadUnsettledTasks(plain []*taskhistory.LoadedTask) error

LoadUnsettledTasks loads plain (uncompressed) task logs into the registry without any per-repo cap. Plain logs are the working set: live tasks, terminal logs not yet compressed, and abandoned logs. The caller scans with the retention cutoff, so only recent logs arrive here.

func (*Manager) NewEntry added in v0.11.5

func (m *Manager) NewEntry(t *taskrun.Task, lt *taskhistory.LoadedTask) *Entry

NewEntry creates an unregistered entry with its immutable lifecycle.

func (*Manager) NotifyTaskChange

func (m *Manager) NotifyTaskChange()

NotifyTaskChange signals that task data may have changed.

func (*Manager) Range

func (m *Manager) Range(fn func(id ksid.ID, e *Entry) bool)

Range iterates over every registered entry. It snapshots the registry under m.mu and invokes fn unlocked, so fn may safely call back into the Manager (e.g. Checkout). The entry set is a point-in-time snapshot; Entry pointers are stable and carry their own locking. Stops iteration if fn returns false.

func (*Manager) RegisteredLogPaths added in v0.11.6

func (m *Manager) RegisteredLogPaths() map[string]struct{}

RegisteredLogPaths returns the set of cleaned log paths currently owned by registered entries. Maintenance passes use it to exclude logs owned by entries so they yield to the per-task terminal compression path.

func (*Manager) RestorationStatus added in v0.14.0

func (m *Manager) RestorationStatus() (loading bool, err string)

RestorationStatus reports the background task-restoration state atomically: loading is true until CompleteRestoration runs, and error is non-empty only after a failed pass. Both fields are read under one lock so a concurrent CompleteRestoration cannot interleave between two separate reads.

func (*Manager) SetTaskMonitorBranch

func (m *Manager) SetTaskMonitorBranch(entry *Entry, branch string)

SetTaskMonitorBranch sets the CI monitor branch on a task entry. Equivalent to entry.SetMonitorBranch; kept for backend.Backend interface symmetry.

func (*Manager) Start

func (m *Manager) Start(scoper TaskMCPScoper) error

Start activates m with its task-scoped MCP authority and starts its runtime event and stats watchers. It subscribes to events before startup inventory is listed, and ImportInstances applies any buffered events after registration.

func (*Manager) SudoPassword

func (m *Manager) SudoPassword(ctx context.Context, t *taskrun.Task) string

SudoPassword returns the cached sudo password for a task, fetching it from the instance on first access.

Returns "" when the task does not use sudo or has no instance yet. The fetched password is cached on the task so subsequent calls avoid the SSH round-trip. A lookup failure is logged and returns "".

func (*Manager) TaskListComplete added in v0.14.0

func (m *Manager) TaskListComplete() bool

TaskListComplete reports whether task-list absence is authoritative. Runtime import must have released its startup fence and all restoration stages must have completed successfully. Read before assembling the task-list snapshot.

func (*Manager) TaskMCPAvailable added in v0.12.0

func (m *Manager) TaskMCPAvailable() bool

TaskMCPAvailable reports whether new tasks can receive the bounded MCP capability.

func (*Manager) ToolInput added in v0.15.0

func (m *Manager) ToolInput(ctx context.Context, entry *Entry, query *ToolInputQuery) (*agent.ToolUseMessage, error)

ToolInput resolves the recorded input of one tool invocation. A zero query source accepts any owner but reports ErrToolUseAmbiguous instead of guessing, and a cold task retains a bounded number of answers so revisiting a tool does not decode its whole log again.

func (*Manager) WaitForRuntimeImport added in v0.14.0

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

WaitForRuntimeImport waits until startup restores live task ownership. It returns immediately before Start or after import completion. Callers remain cancellation-aware while creation or an unresolved lookup is fenced.

func (*Manager) WatchTaskCompletion

func (m *Manager) WatchTaskCompletion(ctx context.Context, taskID ksid.ID) (state, result string, err error)

WatchTaskCompletion blocks until the task reaches a terminal state.

type NoSessionError

type NoSessionError struct {
	Err          error // underlying task.SendInput diagnostic error
	ReconnectErr error // reconnect failure, if recovery was attempted
}

NoSessionError wraps the underlying task.SendInput error when there is no active agent session.

func (*NoSessionError) Error

func (e *NoSessionError) Error() string

Error returns the diagnostic message, including reconnect failure if present.

func (*NoSessionError) Is

func (e *NoSessionError) Is(target error) bool

Is reports a match against the ErrNoSession sentinel.

func (*NoSessionError) Unwrap

func (e *NoSessionError) Unwrap() []error

Unwrap returns the underlying errors for errors.Is/errors.As traversal.

type PendingInput added in v0.15.0

type PendingInput struct {
	ID         ksid.ID
	Prompt     agent.Prompt
	Delivering bool
	Error      string
	Delivered  bool
}

PendingInput is an immutable pending prompt and its delivery state.

Callers must not modify its fields or Prompt.Images. State changes publish a new value so a retained pointer remains safe to read.

type SyncResult

type SyncResult struct {
	Status       string // "synced", "empty", "blocked"
	Branch       string
	DiffStat     v3.DiffStat
	SafetyIssues []repo.SafetyIssue
}

SyncResult holds the outcome of a Sync operation.

type SyncTarget

type SyncTarget string

SyncTarget specifies where to push changes.

const (
	// SyncTargetOrigin pushes to the task's own branch on origin.
	SyncTargetOrigin SyncTarget = "origin"
	// SyncTargetDefault pushes to the repo's default branch.
	SyncTargetDefault SyncTarget = "default"
)

type TaskMCPScoper added in v0.12.0

type TaskMCPScoper interface {
	ForTask(id ksid.ID) mcp.Registry
}

TaskMCPScoper derives a server-authorized MCP registry for a task.

The task manager supplies only its trusted task ID. The server owns the authorization policy that turns that ID into an MCP capability.

type ToolInputQuery added in v0.15.0

type ToolInputQuery struct {
	// ToolUseID is the provider-reported tool ID.
	ToolUseID string
	// Source scopes the ID to one provider origin. Its zero value accepts any
	// origin and reports ErrToolUseAmbiguous instead of guessing.
	Source agent.MessageSource
}

ToolInputQuery selects one recorded tool invocation.

Jump to

Keyboard shortcuts

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