sessionplan

package
v1.91.0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package sessionplan provides a per-session plan tracker for the "draft, review, execute" workflow. One markdown plan per session, stored at <data-dir>/session_plans/<session-id>.md. The toolset is a metadata stub — the runtime owns the handlers (pkg/runtime/sessionplan_handlers.go) so they can reach the live session.

Complementary to pkg/tools/builtin/plan, which models shared, named plans multiple agents collaborate on. Tool names are deliberately distinct (write_session_plan / read_session_plan vs. write_plan / read_plan) so the two toolsets can coexist on the same agent without colliding.

Index

Constants

View Source
const (
	ToolNameWriteSessionPlan = "write_session_plan"
	ToolNameReadSessionPlan  = "read_session_plan"
	ToolNameExitPlanMode     = "exit_plan_mode"
)

Variables

View Source
var (
	ErrInvalidSessionID = errors.New("invalid session ID")
	ErrPlanNotFound     = errors.New("session plan not found")
)

Functions

func CreateToolSet

func CreateToolSet() (tools.ToolSet, error)

func DefaultDir

func DefaultDir() string

func Path

func Path(dir, sessionID string) (string, error)

func ReadContent

func ReadContent(dir, sessionID string) (content, path string, err error)

ReadContent returns ErrPlanNotFound (with the path so callers can include it in user-facing messages) on ENOENT, distinguishing "plan missing" from a real read failure such as a permission error.

func Sweep

func Sweep(dir string, now time.Time, maxAge time.Duration) error

Sweep is best-effort: a permission glitch on one file should not block cleaning the rest, but the first error encountered is returned so callers can surface it.

func WriteContent

func WriteContent(dir, sessionID, content string) (string, error)

WriteContent uses atomicfile.Write so a concurrent reader — in this process or another — sees either the old or the new file, never a partial one, and so an existing symlink is replaced rather than followed.

Types

type ToolSet

type ToolSet struct{}

func New

func New() *ToolSet

New builds a toolset without running the startup sweep, for tests and embedders that want predictable filesystem behaviour.

func (*ToolSet) Instructions

func (t *ToolSet) Instructions() string

func (*ToolSet) Tools

func (t *ToolSet) Tools(context.Context) ([]tools.Tool, error)

Tools advertises the metadata only; Handler is intentionally nil so the runtime's toolMap takes over (same pattern as handoff and transfer_task).

type WriteSessionPlanArgs

type WriteSessionPlanArgs struct {
	Content string `json:"content" jsonschema:"The full plan content as markdown. Replaces the existing plan for this session."`
}

Jump to

Keyboard shortcuts

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