cliorchestrate

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2026 License: AGPL-3.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultMaxTokens = 0

	// DefaultToolOwner is the default owner for orchestration tasks.
	DefaultToolOwner = "mivia"
)

Orchestration default constants.

DefaultMaxTokens is intentionally 0: when no explicit subagents max_tokens is configured, the subagent loop passes nil to the provider, letting the model use its own default response length. A hardcoded 4096 cap truncated comprehensive subagent reports mid-sentence (finish_reason="length").

View Source
const (
	// HandlerMultiStep is the wire name of the multi_step handler.
	HandlerMultiStep = "multi_step"
	// HandlerDelegate is the wire name of the delegate handler.
	HandlerDelegate = "delegate"
	// HandlerOneshot is the wire name of the oneshot handler.
	HandlerOneshot = "oneshot"
)

Tool name constants used by orchestration tools registered via RegisterOrchestrationTools and NewDispatchTasksTool.

View Source
const (
	// ToolDispatchTasks is the model-visible name of the dispatch_tasks tool.
	ToolDispatchTasks = "dispatch_tasks"
	// ToolSpawnAgent is the internal name of the spawn_agent tool.
	ToolSpawnAgent = "spawn_agent"
	// ToolJoinRun is the internal name of the join_run tool.
	ToolJoinRun = "join_run"
	// ToolInspectAgents is the internal name of the inspect_agents tool.
	ToolInspectAgents = "inspect_agents"
	// ToolCancelRun is the internal name of the cancel_run tool.
	ToolCancelRun = "cancel_run"
)
View Source
const DispatchOrchestrationSlackSec = 15

DispatchOrchestrationSlackSec is the headroom the whole-call budget gets over the longest task in the batch, so the call outlives the work it is waiting on.

Variables

View Source
var CoordinatorReposForTest = &coordinatorRepos

CoordinatorReposForTest exposes the coordinatorRepos map for cli tests.

View Source
var CoordinatorsForTest = &coordinators

CoordinatorsForTest exposes the coordinators map for cli tests that seed dispatcher-to-coordinator registrations directly.

View Source
var DefaultOrchestrationRepo = &defaultOrchestrationRepo

DefaultOrchestrationRepo exposes the fallback in-memory ledger repository for tests that inspect the default wiring.

View Source
var ErrOrchestrationSwitchActive = errors.New("model switching is unavailable while orchestration is active")

ErrOrchestrationSwitchActive is OrchestrationSwitchGuard's refusal as a value, because internal/legacytui's /effort rewrites it for a surface where "model switching" names a command the user did not type. Matching that rewrite on the text would go quiet the first time someone copy-edits this sentence, and the notice would silently revert.

View Source
var RunHandlesForTest = &runHandles

RunHandlesForTest exposes the runHandles map for cli tests that seed or inspect run-handle records directly.

Functions

func ActiveCoordinator

func ActiveCoordinator() (coordinator.Coordinator, bool)

ActiveCoordinator returns the first Coordinator registered in the package-level coordinators map, if any. Used to find a running dispatch's Coordinator from a caller that does not hold the *runtime.Dispatcher key.

func ActiveSessionCallerForTest

func ActiveSessionCallerForTest() *runtime.Caller

ActiveSessionCallerForTest exposes the active session caller pointer for tests that inspect or reset the ambient caller.

func BelowInlineThreshold

func BelowInlineThreshold(body []byte, threshold int, ref string) bool

BelowInlineThreshold reports whether body should be inlined. When body is below threshold, it is returned inline with no synopsis. When above threshold and a ref is available, the caller should emit synopsis+ref instead. When above threshold but no ref is available (INV-AG-10: content write failed), the body must still be inlined to avoid losing data.

func ClearAllCoordinators

func ClearAllCoordinators()

ClearAllCoordinators deletes all entries from the coordinators sync.Map. Used by tests to clean up between cases.

func CloseSharedSQLite

func CloseSharedSQLite(store *storage.SQLite) error

CloseSharedSQLite is the explicit owner boundary. SQLite's Close is idempotent, while the function keeps shutdown ownership visible at the CLI layer and makes the borrowed ledger adapter's contract testable.

func CoordinatorForRun

func CoordinatorForRun(runID string) coordinator.Coordinator

CoordinatorForRun returns the coordinator stored for the given runID, if any.

func CoordinatorOfHandle

func CoordinatorOfHandle(record *OrchestrationHandleForTest) coordinator.Coordinator

CoordinatorOfHandle returns the handle record's coordinator. It serves cli tests that inspect a parked run's coordinator.

func DispatchOrchestrationSec

func DispatchOrchestrationSec(defaultTimeout int, args json.RawMessage) int

DispatchOrchestrationSec picks the wall-clock budget for the whole dispatch_tasks invocation from config, batch timeout_seconds, and any per-task timeout_seconds (max wins). Always positive.

An explicit batch-level timeout_seconds is honored as the actual budget — it is not floored to the 12h default. Per-task timeout_seconds values can still raise it: a task that legitimately needs more than the batch budget extends the whole-call budget to accommodate it.

func DispatcherOfHandle

func DispatcherOfHandle(record *OrchestrationHandleForTest) *runtime.Dispatcher

DispatcherOfHandle returns the handle record's dispatcher.

func DisplayPath

func DisplayPath(p string) string

func EffectiveOrchestrationRepo

func EffectiveOrchestrationRepo(repo ledger.LedgerRepository) ledger.LedgerRepository

EffectiveOrchestrationRepo returns repo if non-nil, otherwise the default.

func EncodeOneDispatchResult

func EncodeOneDispatchResult(r subagents.Result, tasks []ledger.TaskSnapshot, threshold int) dispatchTaskResult

EncodeOneDispatchResult builds a single dispatchTaskResult from a subagent result, applying the inline-by-reference threshold for both output and error.

func FindCoordinator

func FindCoordinator() coordinator.Coordinator

FindCoordinator looks up the package-level coordinator singleton.

func FindDispatcher

func FindDispatcher() *runtime.Dispatcher

FindDispatcher looks up a dispatcher from the coordinator map.

func FormatDoctorModelInfo

func FormatDoctorModelInfo(res *config.Resolved) string

func FormatInterruptedRunReport

func FormatInterruptedRunReport(recovered []ledger.RecoveredRun, now time.Time) string

FormatInterruptedRunReport returns the single startup line describing runs a previous process left unfinished, or "" when there is nothing worth saying.

One line regardless of count: the previous code printed one per run with no cap, so a workspace with a backlog buried the startup banner.

func FormatListedRuns

func FormatListedRuns(runs []coordinator.RecoveredRun) string

FormatListedRuns formats a list of interrupted runs for display.

func FormatModelCatalog

func FormatModelCatalog(catalog []config.ProviderModelGroup, modelSep, groupSep string) string

func FormatResumeConfirmation

func FormatResumeConfirmation(info ResumeConfirmationInfo) string

FormatResumeConfirmation builds the confirmation message shown to the user before re-spending budget on a resume.

func FormatResumeError

func FormatResumeError(err error, runID string) string

FormatResumeError maps different resume errors to user-facing messages. Three distinct causes, three distinct messages:

  1. Held by another executor
  2. Already terminal
  3. Cannot be resumed (missing Input)

func FormatRunAge

func FormatRunAge(createdAt, now time.Time) string

FormatRunAge renders a coarse age for a run listing: a two-day-old run offered with no age reads as something that just broke.

func InitCoordinator

InitCoordinator lazily creates the Coordinator singleton with an in-memory or durable ledger repository and a subagent pool backed by the given dispatcher. Safe for concurrent calls; only the first invocation initialises the singleton. Subsequent calls are no-ops.

func JsonKeySynopsis

func JsonKeySynopsis(body []byte) (string, bool)

JsonKeySynopsis extracts top-level keys from a JSON object. Returns the synopsis string and true on success; returns ("", false) for non-object JSON or unparseable input.

func ListInterruptedRuns

func ListInterruptedRuns(ctx context.Context, c coordinator.Coordinator) ([]coordinator.RecoveredRun, error)

ListInterruptedRuns returns the list of interrupted runs from the coordinator. Used by both the slash command (no argument) and the TUI dashboard.

func LoadCoordinator

func LoadCoordinator(d *runtime.Dispatcher) (coordinator.Coordinator, bool)

LoadCoordinator returns the coordinator registered for d, if any.

func LoadCoordinatorRepo

func LoadCoordinatorRepo(d *runtime.Dispatcher) (ledger.LedgerRepository, bool)

LoadCoordinatorRepo returns the ledger repository registered for d, if any.

func ModelTaskResults

func ModelTaskResults(tasks []ledger.TaskSnapshot, results []subagents.Result, threshold int) []modelTaskResult

ModelTaskResults returns live orchestration results for model consumption. The output is included inline here while the completed run is in memory.

References come from the task records via StoredResultRefs rather than being re-minted from the in-memory bytes. The two agree on every successful run, but when a content write fails the coordinator deliberately records no reference - and re-minting here would hand the model a digest nothing was stored under (INV-AG-10). Reading the recorded value is what makes the reference honest.

threshold controls the inline-by-reference switch: results whose output body is at or below threshold bytes are inlined; above threshold, only ref+synopsis are emitted. When no ref is available (content write failed), the body is always inlined regardless of size.

func ModelTaskResultsWithRepo

func ModelTaskResultsWithRepo(repo ledger.LedgerRepository, tasks []ledger.TaskSnapshot, results []subagents.Result, threshold int) []modelTaskResult

ModelTaskResultsWithRepo is like ModelTaskResults but attaches synopsis-only messages from the run ledger when repo is non-nil.

func ModelVisibleOutput

func ModelVisibleOutput(raw json.RawMessage) any

ModelVisibleOutput returns the handler response as a JSON value when valid, otherwise as text. The accompanying reference is a resolvable handle to the persisted content, and the actual result is also included inline in this response while the completed run is in memory.

func NewCancelRunToolConfigured

func NewCancelRunToolConfigured(d *runtime.Dispatcher) *cancelRunTool

NewCancelRunToolConfigured builds a cancel_run tool bound to a dispatcher.

func NewCancelRunToolZero

func NewCancelRunToolZero() tools.Tool

NewCancelRunToolZero returns a zero-value cancel_run tool for the cli session tool catalog (schema advertising only; no runtime state).

func NewDispatchTasksTool

func NewDispatchTasksTool(d *runtime.Dispatcher, cfg config.SubagentConfig, skillReg *skills.Registry, repo ledger.LedgerRepository, agentReg *agents.AgentRegistry, providerName, model string) tools.Tool

NewDispatchTasksTool creates a dispatch_tasks tool. RegisterOrchestrationTools builds the dispatchTasksTool struct directly instead of calling this constructor; it is kept for other callers that need a standalone instance.

func NewDispatchTasksToolConfigured

func NewDispatchTasksToolConfigured(d *runtime.Dispatcher, cfg config.SubagentConfig, repo ledger.LedgerRepository, agentReg *agents.AgentRegistry) *dispatchTasksTool

NewDispatchTasksToolConfigured builds a dispatch_tasks tool bound to a dispatcher, config, repository, and agent registry. It serves cli tests that construct the tool directly.

func NewDispatchTasksToolForCatalog

func NewDispatchTasksToolForCatalog(agentReg *agents.AgentRegistry, providerName, model string) *dispatchTasksTool

NewDispatchTasksToolForCatalog builds a dispatch_tasks tool with only the catalog fields set (agent registry, provider, model). It serves schema-level tests.

func NewDispatchTasksToolForSkillPolicy

func NewDispatchTasksToolForSkillPolicy(skillReg *skills.Registry, agentReg *agents.AgentRegistry, cfg config.SubagentConfig) *dispatchTasksTool

NewDispatchTasksToolForSkillPolicy builds a dispatch_tasks tool with the skill registry, agent registry, and config a skill-policy test sets.

func NewDispatchTasksToolFull

func NewDispatchTasksToolFull(d *runtime.Dispatcher, cfg config.SubagentConfig, repo ledger.LedgerRepository, agentReg *agents.AgentRegistry, skillReg *skills.Registry) *dispatchTasksTool

NewDispatchTasksToolFull builds a dispatch_tasks tool with every field a cli test needs to set, including the skill registry.

func NewDispatchTasksToolWithCfg

func NewDispatchTasksToolWithCfg(cfg config.SubagentConfig) *dispatchTasksTool

NewDispatchTasksToolWithCfg builds a dispatch_tasks tool with only the config set (encodeResults threshold tests).

func NewDispatchTasksToolZero

func NewDispatchTasksToolZero() tools.Tool

NewDispatchTasksToolZero returns a zero-value dispatch_tasks tool for the cli session tool catalog (schema advertising only; no runtime state).

func NewInspectAgentToolConfigured

func NewInspectAgentToolConfigured(d *runtime.Dispatcher) *inspectAgentTool

NewInspectAgentToolConfigured builds an inspect_agents tool bound to a dispatcher.

func NewInspectAgentsToolZero

func NewInspectAgentsToolZero() tools.Tool

NewInspectAgentsToolZero returns a zero-value inspect_agents tool for the cli session tool catalog (schema advertising only; no runtime state).

func NewJoinRunToolConfigured

func NewJoinRunToolConfigured(d *runtime.Dispatcher) *joinRunTool

NewJoinRunToolConfigured builds a join_run tool bound to a dispatcher.

func NewJoinRunToolZero

func NewJoinRunToolZero() tools.Tool

NewJoinRunToolZero returns a zero-value join_run tool for the cli session tool catalog (schema advertising only; no runtime state).

func OpenDurableLedgerRepo

func OpenDurableLedgerRepo(cfg config.SubagentConfig, w io.Writer) (repo ledger.LedgerRepository, ownedStore *ledger.StorageLedgerRepository)

OpenDurableLedgerRepo opens a SQLite-backed ledger repository when configured, runs startup recovery, reports interrupted runs, and returns the owned store (if any) so the caller can close it on shutdown. On any open failure it falls back to the in-memory default repo and writes a warning to w; it never returns an error for an open failure.

func OpenSharedSQLite

func OpenSharedSQLite(cfg config.SubagentConfig, w io.Writer) (*storage.SQLite, error)

OpenSharedSQLite opens the single caller-owned database used when a chat session shares context checkpoints with the ledger. The caller supplies the returned pointer to NewSessionDispatcher and closes it after that dispatcher, so adapters cannot accidentally create or close a second DB.

func OrchestrationHandleAccessibleForTest

func OrchestrationHandleAccessibleForTest(ctx context.Context, record *OrchestrationHandleForTest, d *runtime.Dispatcher, repo ledger.LedgerRepository) bool

OrchestrationHandleAccessibleForTest exposes the principal check used by resume enforcement tests.

func OrchestrationRepoForDispatcher

func OrchestrationRepoForDispatcher(d *runtime.Dispatcher) ledger.LedgerRepository

OrchestrationRepoForDispatcher returns the ledger repository registered for d.

func OrchestrationSwitchGuard

func OrchestrationSwitchGuard(sessionID string) func() error

OrchestrationSwitchGuard returns a guard function that refuses model switching while an orchestration run is active for sessionID.

func ParseConfirmResponse

func ParseConfirmResponse(response string) bool

ParseConfirmResponse returns true if the user confirmed the resume.

func PoolLimitsFromConfig

func PoolLimitsFromConfig(cfg config.SubagentConfig) (maxDepth, maxFanout int)

PoolLimitsFromConfig maps the subagents config contract onto pool limits. Config zero means unlimited (see resolveSubagentConfig and the mivia.toml comments); the pool primitive would otherwise substitute its safe defaults for zero and silently cap agent-planned DAGs.

func PrincipalForTest

func PrincipalForTest(sessionID, role string) orchestrationPrincipal

PrincipalForTest builds an orchestration principal value for tests that seed handle records.

func PrincipalSessionIDOfHandle

func PrincipalSessionIDOfHandle(record *OrchestrationHandleForTest) string

PrincipalSessionIDOfHandle returns the handle record's principal session id. It serves cli tests that pin resume principal swaps.

func PromptBudgetAdvisory

func PromptBudgetAdvisory(res *config.Resolved) string

PromptBudgetAdvisory reports when the session prompt budget is unbounded: [chat] max_prompt_tokens unset and the active budget above the recommended cap. Empty means no advisory.

func ReadHint

func ReadHint(threshold int, bodyLen int, ref string) string

ReadHint returns the hint string for above-threshold results, or empty.

func RegisterOrchestrationTools

func RegisterOrchestrationTools(d *runtime.Dispatcher, reg *tools.Registry, cfg config.SubagentConfig, repo ledger.LedgerRepository, skillReg *skills.Registry, agentReg *agents.AgentRegistry, providerName, model string) error

RegisterOrchestrationTools registers the orchestration tools (dispatch_tasks, inspect_agent, join_run, cancel_run) on both the model-visible registry and the runtime dispatcher. It is called from NewSessionDispatcher. dispatch_tasks is registered first: session_tool_catalog.go documents that the resulting wire order is load-cache-stability-sensitive for OpenAI-compatible providers, so this order must not change.

func RepoOfHandle

RepoOfHandle returns the handle record's ledger repository.

func ReportInterruptedRuns

func ReportInterruptedRuns(w io.Writer, recovered []ledger.RecoveredRun, recErr error)

ReportInterruptedRuns writes the startup report for a Recover result. Shared by every construction path so the two surfaces cannot drift.

func ResumeRun

func ResumeRun(ctx context.Context, c coordinator.Coordinator, d *runtime.Dispatcher, runID string, repo ledger.LedgerRepository) (*orchestrationHandle, error)

ResumeRun is the shared resume implementation behind the /resume slash command. It calls ResumeInterruptedRun on the coordinator and registers the resumed handle with the resuming caller's principal.

If c is nil, the function looks up the coordinator from the package-level map. If d is nil, looks up a dispatcher from the coordinator map. It returns the registered handle record for callers that pin principal ownership.

func RunDoctor

func RunDoctor(args []string) error

RunDoctor runs the doctor command with the given args, writing to stdout/stderr.

func RunDoctorWithIO

func RunDoctorWithIO(args []string, stdout, stderr io.Writer) error

RunDoctorWithIO runs the doctor command with explicit writers for testability.

func RunTaskResults

func RunTaskResults(result *coordinator.RunResult, threshold int) []modelTaskResult

RunTaskResults returns the model-visible task results for a completed run, preferring the snapshot's stored references on the recovered/replay path. When repo is non-nil, synopsis-only task messages are attached (plan 53.02).

func RunTaskResultsWithRepo

func RunTaskResultsWithRepo(repo ledger.LedgerRepository, result *coordinator.RunResult, threshold int) []modelTaskResult

RunTaskResultsWithRepo is like RunTaskResults but attaches synopsis-only task messages when repo is non-nil.

func RunThroughCoordinator

RunThroughCoordinator is the compatibility seam for legacy tools. It keeps delegate and dispatch_tasks on the same ledger, pool, cancellation, and identity path as the canonical orchestration tools.

func SetActiveSessionCaller

func SetActiveSessionCaller(caller runtime.Caller)

SetActiveSessionCaller records the chat session's identity for CLI-initiated orchestration control.

func SkipValue

func SkipValue(decoder *json.Decoder) error

SkipValue advances the decoder past one JSON value (object, array, string, number, boolean, or null).

func StatusFromErr

func StatusFromErr(err error) string

StatusFromErr maps a Go error to the matching ledger task status string.

func StoreHandleForPrincipal

func StoreHandleForPrincipal(runID, sessionID, role string)

StoreHandleForPrincipal seeds a handle record carrying only a principal. It serves resume tests that pin principal overwrite behavior.

func StoreTestCoordinator

func StoreTestCoordinator(d *runtime.Dispatcher, c coordinator.Coordinator, repo ledger.LedgerRepository) func()

StoreTestCoordinator stores a coordinator and its repo in the package-level maps for the given dispatcher. Returns a cleanup func. Used by cli tests that stay in internal/cli but need to set up orchestration state.

func StoreTestRunHandle

func StoreTestRunHandle(runID string, c coordinator.Coordinator, h *coordinator.RunHandle, repo ledger.LedgerRepository, d *runtime.Dispatcher, sessionID string) func()

StoreTestRunHandle stores an orchestrationHandle for the given runID. Returns a cleanup func. Used by cli tests that need to set up run handles.

func StoredResultRefs

func StoredResultRefs(tasks []ledger.TaskSnapshot, r subagents.Result) (outputRef, errorRef string)

StoredResultRefs returns the references the ledger recorded for a result's task. It falls back to canonical minting only when the snapshot carries no record for that task at all.

func Synopsize

func Synopsize(body []byte) string

Synopsize produces a bounded, injection-inert preview of body. It is NOT a summary — it is enough context for the parent to decide whether and which range to page via ledger_read.

Rules:

  • If body is valid JSON with top-level object keys, emit a key inventory ("{\"keys\":[...],\"bytes\":N}") truncated to synopsisMaxBytes.
  • Otherwise, take the first min(synopsisMaxBytes, len(body)) bytes, cut at a UTF-8 rune boundary (never mid-rune), and append '…' if truncated.

func TaskMessageIndex

func TaskMessageIndex(ctx context.Context, repo ledger.LedgerRepository, tasks []ledger.TaskSnapshot) map[string][]messageSynopsis

TaskMessageIndex loads synopsis-only findings/questions per task for result envelopes. Best-effort: a missing repo or events yields an empty map.

func TaskRetryPolicyFromConfig

func TaskRetryPolicyFromConfig(cfg config.TaskRetryConfig) coordinator.RetryPolicy

TaskRetryPolicyFromConfig converts the [subagents.retry] TOML surface into a coordinator.RetryPolicy. internal/config cannot import internal/coordinator (coordinator already imports config), so this CLI-layer seam does the conversion. An all-zero TaskRetryConfig (the default) converts to coordinator.NoRetry, identical to today's hardcoded behavior - a deployment must opt in via [subagents.retry] max_retries > 0 to enable retry.

func TimeoutHint

func TimeoutHint() string

TimeoutHint is the model-facing guidance for timeout_seconds on the orchestration tools (dispatch_tasks, spawn_agent, delegate). It names the effective default so agents omit the parameter (or pass 0) instead of guessing a small budget, and states that an explicit value IS the budget.

func TruncateAtRuneBoundary

func TruncateAtRuneBoundary(body []byte) string

TruncateAtRuneBoundary takes the first min(synopsisMaxBytes, len(body)) bytes of body, ensuring the cut lands on a UTF-8 boundary, and appends '…' if the result was truncated.

Types

type Diagnostics

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

Diagnostics exposes bounded, privacy-safe operator views of the orchestration runtime. Sources: LedgerRepository for run state.

func NewDiagnostics

func NewDiagnostics(repo ledger.LedgerRepository, adapter *events.MetricsAdapter) *Diagnostics

NewDiagnostics creates a Diagnostics backed by the given ledger repo and metrics adapter. If repo is nil, ListRuns and ActiveHandles return zero values. If adapter is nil, MetricsSnapshot returns zero values. Does not panic.

func (*Diagnostics) ActiveHandles

func (d *Diagnostics) ActiveHandles() int

ActiveHandles returns count of non-terminal runs (running + queued + created). Derived from LedgerRepository.ListRuns with status filter. Returns 0 if no repo configured.

func (*Diagnostics) ListRuns

func (d *Diagnostics) ListRuns(ctx context.Context, limit int) ([]RunSummary, error)

ListRuns returns runs from the ledger repository, newest first. limit caps the response. limit <= 0 returns all. Returns empty slice if no repo configured.

func (*Diagnostics) MetricsSnapshot

func (d *Diagnostics) MetricsSnapshot() (counts map[string]uint64, totalEvents uint64)

MetricsSnapshot returns current counts from MetricsAdapter via Snapshot(). MetricsSnapshot returns a snapshot of event counts from the metrics adapter. Returns zero values if no adapter configured.

type DispatchTaskParamForTest

type DispatchTaskParamForTest = dispatchTaskParam

DispatchTaskParamForTest is the exported alias of the dispatch tool's task parameter type.

type DispatchTasksToolForTest

type DispatchTasksToolForTest = dispatchTasksTool

DispatchTasksToolForTest is the exported type alias for dispatchTasksTool. Use for type assertions in cli tests that receive a tools.Tool interface.

type ModelTaskResultForTest

type ModelTaskResultForTest = modelTaskResult

ModelTaskResultForTest is the exported type alias for modelTaskResult. Use in cli tests that call ModelTaskResults and need to name the element type.

type OrchestrationHandleForTest

type OrchestrationHandleForTest = orchestrationHandle

OrchestrationHandleForTest is the exported alias of the unexported orchestrationHandle record. It serves cli tests that inspect run handles.

type ResumeConfirmationInfo

type ResumeConfirmationInfo struct {
	RunID         string
	DisplayName   string
	TaskCount     int
	PriorAttempts int // total attempt count across all tasks
}

ResumeConfirmationInfo holds the information displayed before confirming a resume action.

type RunAccess

type RunAccess interface {
	// GetCoordinator returns the coordinator for this run.
	GetCoordinator() coordinator.Coordinator
	// GetHandle returns the run handle.
	GetHandle() *coordinator.RunHandle
}

RunAccess exposes the coordinator and run handle from an orchestrationHandle to callers outside this package that cannot name the unexported type.

func AccessibleOrchestrationHandle

func AccessibleOrchestrationHandle(
	ctx context.Context,
	runID string,
	dispatcher *runtime.Dispatcher,
	repo ledger.LedgerRepository,
) (RunAccess, string)

AccessibleOrchestrationHandle is the exported gate for callers outside this package. It returns the run handle as a RunAccess interface and an error JSON string. When errJSON is non-empty the record is nil and the caller should return errJSON verbatim.

type RunSummary

type RunSummary struct {
	RunID       string    `json:"run_id"`
	DisplayName string    `json:"display_name"`
	Status      string    `json:"status"`
	TaskCount   int       `json:"task_count"`
	CreatedAt   time.Time `json:"created_at"`
	Elapsed     string    `json:"elapsed"`
}

RunSummary is a bounded summary of an orchestration run.

type TaskRoute

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

TaskRoute is the result of resolving the sole model-facing agent selector. It is copied into both execution and persisted work metadata. A route with oneshot set is the agent-less case: the task runs a bare LLM call on the calling session's own model and completer (cliorchestrate.HandlerOneshot), with no tools and no agent policy - agent/digest/skill all stay zero.

func ResolveTaskRoute

func ResolveTaskRoute(reg *agents.AgentRegistry, skillReg *skills.Registry, agentName, skillName string) (TaskRoute, error)

ResolveTaskRoute resolves an agent name and optional skill into a TaskRoute. This is the ONE production resolver for every dispatched task - dispatch_tasks, spawn_agent, and referral/messaging spawning all call this function, not a package-local duplicate, so agent/skill policy can never drift between callers.

An empty agentName is valid: it resolves to the Oneshot route (a bare LLM call on the caller's own model, no tools, no policy). A skill requires an agent's policy scope to check against, so skillName set with an empty agentName is refused.

See agents.Select and cliagents.SkillScopeFromAgent for validation rules.

func (TaskRoute) Digest

func (r TaskRoute) Digest() string

Digest returns the agent definition digest for this route. Empty for a Oneshot route.

func (TaskRoute) Oneshot

func (r TaskRoute) Oneshot() bool

Oneshot reports whether this route is the agent-less case: no named agent, no tools, dispatched to cliorchestrate.HandlerOneshot instead of a per-agent handler.

Jump to

Keyboard shortcuts

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