mission

package
v1.0.15 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: MIT Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Missions an operator runs, each an objective with a plan the agent keeps current, persisted as session records

Index

Constants

View Source
const (
	StepPending = "pending"
	StepActive  = "active"
	StepDone    = "done"
	StepSkipped = "skipped"
)
View Source
const (
	StatusActive    = "active"
	StatusDone      = "done"
	StatusFailed    = "failed"
	StatusCancelled = "cancelled"
)
View Source
const RecordKind = "mission"

Kind of record a session keeps for every mission change

View Source
const SessionPlanKind = "session_plan"

Kind of record holding the working plan of a session with no mission attached

View Source
const ToolName = "Plan"

Name the model calls to keep its plan current

Variables

This section is empty.

Functions

func IDFrom

func IDFrom(ctx context.Context) string

Mission id carried by the context, empty when none was set

func NormalizeSteps

func NormalizeSteps(steps []Step) error

Trims step text, fills empty statuses with pending and rejects unknown statuses

func WithID

func WithID(ctx context.Context, id string) context.Context

Carries the mission a run serves so the plan tool knows which one to update

Types

type Change

type Change struct {
	Mission
	Op Op `json:"op,omitempty"`
}

One mission change as listeners and the session log see it, flat so records without an op still read as updates

type Mission

type Mission struct {
	ID        string    `json:"id"`
	Objective string    `json:"objective"`
	Plan      []Step    `json:"plan,omitempty"`
	Agents    []string  `json:"agents,omitempty"`
	Status    string    `json:"status"`
	Started   time.Time `json:"started"`
	Finished  time.Time `json:"finished,omitempty"`
	Note      string    `json:"note,omitempty"`
	// Why the mission failed or was cancelled
	Error string `json:"error,omitempty"`
}

One objective with the plan, agents and outcome attached to it

func (Mission) Current

func (m Mission) Current() (Step, bool)

Step the agent is working on, or the first pending one

func (Mission) Ended

func (m Mission) Ended() bool

Reports whether the mission has reached an end state

func (Mission) Markdown

func (m Mission) Markdown() string

Renders the mission as a Markdown checklist

func (Mission) Progress

func (m Mission) Progress() float64

Share of steps done or skipped, zero without a plan

type Op

type Op string

What happened to a mission

const (
	OpAdd    Op = "add"
	OpUpdate Op = "update"
	OpRemove Op = "remove"
)

type SessionPlan

type SessionPlan struct {
	Steps []Step `json:"steps"`
	Note  string `json:"note,omitempty"`
}

Working plan a run keeps on its session while no mission is attached

func CurrentSessionPlan

func CurrentSessionPlan(sess *session.Session) (SessionPlan, bool)

Working plan last kept on the session, false when none was

func (SessionPlan) Format added in v1.0.11

func (p SessionPlan) Format() string

Numbered steps of the plan with the share done on top, as the tool reports them

type Step

type Step struct {
	Text   string `json:"text"`
	Status string `json:"status"`
}

One item of a plan

type Store

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

Missions keyed by id with change listeners and session persistence

func New

func New() *Store

func (*Store) Assign

func (s *Store) Assign(id, agent string) (Mission, error)

Records that an agent works on the mission, writing nothing when it already is listed

func (*Store) Attach

func (s *Store) Attach(sess *session.Session)

Writes every later change into the session log

func (*Store) Create

func (s *Store) Create(objective string) (Mission, error)

Starts a mission for an objective

func (*Store) Finish

func (s *Store) Finish(id, status, reason string) (Mission, error)

Ends the mission with an outcome, keeping the time it finished

func (*Store) Get

func (s *Store) Get(id string) (Mission, bool)

func (*Store) Len

func (s *Store) Len() int

func (*Store) List

func (s *Store) List() []Mission

Missions in creation order

func (*Store) OnChange

func (s *Store) OnChange(fn func(Change))

Registers a listener called after every change outside the store lock

func (*Store) Remove

func (s *Store) Remove(id string) bool

Forgets a mission, logging the removal so it stays gone after a restore

func (*Store) Restore

func (s *Store) Restore(sess *session.Session) error

Rebuilds the store from the mission records of a session, replaying adds, updates and removes in order

func (*Store) Resume

func (s *Store) Resume(id string) (Mission, error)

Reopens a finished mission

func (*Store) SetNote

func (s *Store) SetNote(id, note string) (Mission, error)

Sets the free text note shown with the mission

func (*Store) SetPlan

func (s *Store) SetPlan(id string, steps []Step) (Mission, error)

Replaces the plan, every step pending unless given a status

func (*Store) SetStep

func (s *Store) SetStep(id string, n int, status string) (Mission, error)

Sets the status of one step by its one based position, demoting any other active step

type Tool

type Tool struct {
	// Store of the calling run
	Resolve func(context.Context) *Store
	// Session of the calling run, holding the plan while no mission is attached
	Session func(context.Context) *session.Session
}

Tool that replaces the plan of the mission the calling run serves, or of its session when no mission is attached

func (Tool) Annotations

func (Tool) Annotations() tool.Annotations

func (Tool) Definition

func (Tool) Definition() protocol.Tool

func (Tool) Run

func (t Tool) Run(ctx context.Context, args json.RawMessage) (tool.Result, error)

Jump to

Keyboard shortcuts

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