sessiontools

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: Apache-2.0 Imports: 20 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

Package sessiontools is the session group of sysml-mcp tools: named REPL sessions that keep a model, its instances, a running action or state machine and the solver's state across calls, as the sysml prompt does. Every tool takes an optional session name and answers with the data the prompt formats beside the prompt's own text.

Index

Constants

View Source
const DefaultSession = "default"

DefaultSession is the session a tool uses when the call names none.

Variables

View Source
var ErrNoSession = errors.New("no such session")

ErrNoSession reports a name no open session has.

Functions

func Register

func Register(s *mcp.Server, m *Manager)

Register adds the session tools to s over m.

Types

type AdvanceInput

type AdvanceInput struct {
	SessionName
	Time float64 `` /* 173-byte string literal not displayed */
}

AdvanceInput moves the clock.

type BreakpointsInput

type BreakpointsInput struct {
	SessionName
	Set   []string `json:"set,omitempty" jsonschema:"node names to break at; debug_continue then stops when a token reaches one"`
	Clear bool     `json:"clear,omitempty" jsonschema:"remove the breakpoints set before, before setting the new ones"`
}

BreakpointsInput sets breakpoints on the debugged action.

type ClearResult

type ClearResult struct {
	Notices []string `json:"notices" jsonschema:"what the reset discarded: objects held, debugging sessions"`
}

ClearResult is what a reset took with it.

type CommandInput

type CommandInput struct {
	SessionName
	Line string `` /* 154-byte string literal not displayed */
}

CommandInput is one prompt command line.

type CommandResult

type CommandResult struct {
	Output string `json:"output" jsonschema:"the lines the command printed"`
	Quit   bool   `json:"quit,omitempty" jsonschema:"the line was %quit, which ends a terminal and is only noted here"`
}

CommandResult is what a command printed.

type ConfigureInput

type ConfigureInput struct {
	SessionName
	Name       string   `` /* 136-byte string literal not displayed */
	Selections []string `` /* 144-byte string literal not displayed */
	All        bool     `json:"all,omitempty" jsonschema:"enumerate every consistent selection instead of one. Not with selections"`
	Limit      int      `json:"limit,omitempty" jsonschema:"with all: at most this many selections"`
}

ConfigureInput names a variation point to configure.

type DebugStartInput

type DebugStartInput struct {
	SessionName
	Kind   string `json:"kind" jsonschema:"action, or state for a state machine"`
	Name   string `` /* 146-byte string literal not displayed */
	Object string `json:"object,omitempty" jsonschema:"an object the session holds (name, #id or path) performing the behavior"`
}

DebugStartInput names the behavior to debug.

type DebugState

type DebugState struct {
	Kind      string `` /* 243-byte string literal not displayed */
	Name      string `json:"name,omitempty" jsonschema:"the behavior as named"`
	Qualified string `json:"qualified,omitempty" jsonschema:"its qualified name"`
	Performer string `json:"performer,omitempty" jsonschema:"the object performing it"`
	State     string `` /* 141-byte string literal not displayed */
	Ended     bool   `json:"ended" jsonschema:"completed or terminated"`

	PausedAt    string       `json:"pausedAt,omitempty" jsonschema:"action: the breakpoint the run last stopped at"`
	Breakpoints []string     `json:"breakpoints,omitempty" jsonschema:"action: the nodes breakpoints are set at"`
	Tokens      []Token      `json:"tokens,omitempty" jsonschema:"action: the active tokens"`
	Results     []NamedValue `json:"results,omitempty" jsonschema:"action: the values its features hold, outputs included"`

	CurrentState    string       `json:"currentState,omitempty" jsonschema:"state machine: the active state, or one per orthogonal region"`
	ActiveStates    []string     `json:"activeStates,omitempty"`
	Time            float64      `json:"time,omitempty" jsonschema:"state machine: the clock"`
	LastEventAt     float64      `json:"lastEventAt,omitempty"`
	QueuedEvents    int          `json:"queuedEvents,omitempty"`
	SignalsInFlight []string     `json:"signalsInFlight,omitempty" jsonschema:"signals sent and not yet dispatched to the machine"`
	SuspendReason   string       `json:"suspendReason,omitempty" jsonschema:"why the machine cannot progress"`
	StateStack      []string     `json:"stateStack,omitempty" jsonschema:"the active configuration, outermost first"`
	StateData       []NamedValue `json:"stateData,omitempty"`

	Text string `json:"text" jsonschema:"what the prompt printed"`
}

DebugState is where a debugging session stands.

type Diagnostic

type Diagnostic struct {
	Severity string `json:"severity" jsonschema:"error, warning or info"`
	Message  string `json:"message"`
	File     string `json:"file,omitempty" jsonschema:"the loaded file the finding is in; empty for text submitted directly"`
	Line     int    `json:"line" jsonschema:"1-based line within the file or submission"`
	Column   int    `json:"column" jsonschema:"1-based column"`
	Pass     string `json:"pass,omitempty" jsonschema:"the analysis pass that produced the finding"`
	Code     string `json:"code,omitempty" jsonschema:"the finding's code"`
}

Diagnostic is one finding about the session's model, placed in the file it was loaded from or in the typed input.

type EvalInput

type EvalInput struct {
	SessionName
	Expression string `` /* 147-byte string literal not displayed */
}

EvalInput is an expression to evaluate.

type EvalResult

type EvalResult struct {
	Expression string `json:"expression"`
	Value      any    `` /* 150-byte string literal not displayed */
	Text       string `json:"text" jsonschema:"the value as the prompt prints it"`
	Output     string `json:"output" jsonschema:"what %eval printed"`
}

EvalResult is the value an expression evaluated to.

type Evaluation

type Evaluation struct {
	Function  string   `json:"function"`
	Arguments []string `json:"arguments"`
	Result    string   `json:"result,omitempty"`
	Error     string   `json:"error,omitempty"`
	Selected  bool     `json:"selected,omitempty" jsonschema:"the case returned this argument"`
	Tied      bool     `json:"tied,omitempty" jsonschema:"passed over for one evaluating alike"`
}

Evaluation is one application a case made of its own calc as a function value.

type Factory

type Factory func() (*repl.Session, error)

Factory makes a fresh REPL session, configured as the command starting the server configures one.

type Features

type Features struct {
	Text  string `json:"text" jsonschema:"the listing as %features prints it: each feature's value and what the object's behaviors are doing"`
	Graph any    `` /* 196-byte string literal not displayed */
}

Features is an object's feature values.

type FeaturesInput

type FeaturesInput struct {
	SessionName
	Object string `json:"object" jsonschema:"an object the session holds: its name, #id, or a path such as car.fl or #1.wheels[2]"`
	Depth  *int   `` /* 131-byte string literal not displayed */
	All    bool   `json:"all,omitempty" jsonschema:"expand every nested object; overrides depth"`
}

FeaturesInput names an object to inspect.

type Instance

type Instance struct {
	Name          string `` /* 126-byte string literal not displayed */
	ID            int64  `json:"id" jsonschema:"addresses the object as #<id>"`
	Type          string `json:"type" jsonschema:"qualified name of what it instantiates"`
	DisplacedFrom string `json:"displacedFrom,omitempty" jsonschema:"the name a later instantiation took from it"`
	Life          string `json:"life,omitempty" jsonschema:"destroyed or ended when its lifetime is over"`
}

Instance is one object the session holds.

type Instances

type Instances struct {
	Instances []Instance `json:"instances"`
	Text      string     `json:"text" jsonschema:"what %instances printed"`
}

Instances are the objects a session holds.

type LoadInput

type LoadInput struct {
	SessionName
	Paths []string `` /* 175-byte string literal not displayed */
}

LoadInput names the files to load.

type LoadResult

type LoadResult struct {
	Files       []string     `json:"files" jsonschema:"the model files the paths named, in load order; files they import from beside them load too"`
	Declared    []string     `json:"declared" jsonschema:"what the load declared, as the prompt summarizes it; empty when the analysis found an error"`
	Errors      bool         `json:"errors" jsonschema:"whether the session's model now has an error"`
	Diagnostics []Diagnostic `json:"diagnostics" jsonschema:"every finding over the session's model after the load, located in its file"`
	Text        string       `json:"text" jsonschema:"what %load printed"`
}

LoadResult is what a load read and what the analysis found.

type Manager

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

Manager holds the sessions by name; the default one is made on first use. Each session answers one call at a time: a second call on it waits for the first, and a call whose context ends interrupts the command it is running.

func NewManager

func NewManager(root string, factory Factory) (*Manager, error)

NewManager returns a manager with no sessions open; root is the workspace folder, which must exist, that tool paths resolve against and stay under.

func (*Manager) Close

func (m *Manager) Close(name string) error

Close ends the session called name, releasing what it holds; a command it is running is interrupted first, and a call still waiting for the session fails rather than running on the cleared one.

func (*Manager) CloseAll

func (m *Manager) CloseAll()

CloseAll ends every session, as the server does on exit.

func (*Manager) Get

func (m *Manager) Get(name string) (*repl.Session, error)

Get returns the session called name, opening the default session on first use; any other name must have been opened and not closed since. It does not wait for the calls on the session, so it can be made from inside one; Use is how a caller has the session to itself.

func (*Manager) Guard

func (m *Manager) Guard(path string, exempt []string) error

Guard is the check every file a session reads or writes must pass, however it was named — by a typed tool, by a %load or %save through repl_command, or found by walking a directory or following a dependency: the file must lie under the workspace root as spelled and once its symlinks are followed, or really under one of the exempt directories (the library roots, for a load). A relative path is taken from the working directory, as the prompt takes it.

func (*Manager) Names

func (m *Manager) Names() []string

Names lists the open sessions, sorted.

func (*Manager) Open

func (m *Manager) Open(name string) (string, error)

Open makes a session under name; an empty name is the default session. It fails if the name is taken.

func (*Manager) Resolve

func (m *Manager) Resolve(path string) (string, error)

Resolve makes a path absolute against the workspace root and refuses one that leaves it: a tool's paths may be relative, absolute or under the user's home (`~`, expanded), but the file touched must lie under the root, as spelled and once the symlinks on the way to it are followed, so a client cannot read or write beyond the workspace it was given. Standard input is no file a tool can read, so a lone "-" is refused.

func (*Manager) Use

func (m *Manager) Use(ctx context.Context, name string, fn func(*repl.Session) error) error

Use runs fn on the session called name, after any call already running on it has finished; a session closed meanwhile is ErrNoSession. A ctx that ends while fn runs interrupts the session's command under way, so a run abandoned by the client stops at its next step.

func (*Manager) WriteFile

func (m *Manager) WriteFile(path string, content []byte) (replaced bool, err error)

WriteFile writes a file a session saves through the workspace root, so the bytes land where the root's directory handle says, not where a path resolved again at write time leads: a link repointed out of the root after Guard passed it is refused. A relative path is taken from the working directory.

type NamedValue

type NamedValue struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

NamedValue is one value a run or check produced, as the prompt prints it.

type Notation

type Notation struct {
	Text string `json:"text" jsonschema:"the notation, as %print writes it; what is printed can be submitted back"`
}

Notation is a model, or part of one, as SysML notation.

type Output

type Output struct {
	Text string `json:"text"`
}

Output is what a command printed.

type PrintInput

type PrintInput struct {
	SessionName
	Name string `json:"name,omitempty" jsonschema:"qualified name of one element to print with its body; omit for the whole model"`
}

PrintInput names what to print.

type RenderRunInput

type RenderRunInput struct {
	SessionName
	Kind string `json:"kind" jsonschema:"timeline (state occupancy per object machine over clock time) or sequence (the messages sent)"`
	Form string `` /* 158-byte string literal not displayed */
}

RenderRunInput asks for the recorded run drawn.

type RenderedRun

type RenderedRun struct {
	Kind      string  `json:"kind"`
	Form      string  `json:"form"`
	Until     float64 `json:"until" jsonschema:"the clock instant the rendering runs through"`
	Text      string  `json:"text" jsonschema:"the rendering in the form asked for"`
	Rendering any     `` /* 151-byte string literal not displayed */
}

RenderedRun is a run's trace drawn.

type Row

type Row struct {
	Inputs      []NamedValue `json:"inputs"`
	Outputs     []NamedValue `json:"outputs"`
	Verdicts    []NamedValue `json:"verdicts"`
	Evaluations []Evaluation `json:"evaluations,omitempty"`
	Millis      float64      `json:"millis" jsonschema:"how long the run took"`
	Error       string       `json:"error,omitempty" jsonschema:"what stopped the run when it failed"`
}

Row is one run of a sweep or of repeated runs.

type RunInput

type RunInput struct {
	SessionName
	Kind      string   `` /* 135-byte string literal not displayed */
	Name      string   `json:"name" jsonschema:"qualified name of the behavior"`
	Arguments []string `` /* 191-byte string literal not displayed */
	Object    string   `` /* 167-byte string literal not displayed */
	Duration  *float64 `` /* 173-byte string literal not displayed */
	Schedule  string   `` /* 156-byte string literal not displayed */
}

RunInput names a behavior to run.

type RunsInput

type RunsInput struct {
	SessionName
	Kind        string   `` /* 199-byte string literal not displayed */
	Name        string   `json:"name" jsonschema:"qualified name of the action or case"`
	Arguments   []string `json:"arguments,omitempty" jsonschema:"for case: argument expressions"`
	Object      string   `json:"object,omitempty" jsonschema:"for action: the object performing it; for case: its subject"`
	Count       int64    `json:"count" jsonschema:"how many runs"`
	Seed        *uint64  `json:"seed,omitempty" jsonschema:"seed each run's modeled randomness derives from; omit for the session's"`
	Observables []string `` /* 159-byte string literal not displayed */
}

RunsInput names an action to run repeatedly.

type Samples

type Samples struct {
	Count int64  `json:"count" jsonschema:"rows to draw"`
	Seed  uint64 `json:"seed" jsonschema:"the same seed draws the same rows"`
}

Samples is how many rows a sampled sweep draws and from what seed.

type SaveInput

type SaveInput struct {
	SessionName
	Path  string `` /* 146-byte string literal not displayed */
	Apply bool   `` /* 179-byte string literal not displayed */
}

SaveInput names the file to write the model to.

type SaveResult

type SaveResult struct {
	Path    string `json:"path" jsonschema:"the file, resolved"`
	Applied bool   `json:"applied" jsonschema:"whether the file was written; false for an empty session, which has nothing to save"`
	Content string `json:"content,omitempty" jsonschema:"without apply: the file's bytes, in the format the extension names"`
	Text    string `json:"text" jsonschema:"what %save printed: notes, warnings, and what was or would be saved"`
}

SaveResult is what a save wrote, or would write.

type SendInput

type SendInput struct {
	SessionName
	Signal    string   `json:"signal" jsonschema:"the signal's definition, qualified if needed"`
	Arguments []string `json:"arguments,omitempty" jsonschema:"the signal's feature values, written parameter=expression"`
	To        string   `` /* 127-byte string literal not displayed */
}

SendInput is a signal to send.

type SessionList

type SessionList struct {
	Sessions []string `json:"sessions" jsonschema:"names of the open sessions, sorted"`
}

SessionList is the open sessions.

type SessionListInput

type SessionListInput struct{}

SessionListInput takes no arguments.

type SessionName

type SessionName struct {
	Session string `json:"session,omitempty" jsonschema:"session name; omit for the default session"`
}

SessionName names a session; empty is the default session.

type SessionOpened

type SessionOpened struct {
	Session string `json:"session" jsonschema:"the session's name"`
}

SessionOpened reports the session a call opened or closed.

type SolveInput

type SolveInput struct {
	SessionName
	Name string `json:"name" jsonschema:"qualified name of the constraint, requirement, satisfaction, part or analysis case"`
}

SolveInput names the element a solver is asked about.

type SolveReport

type SolveReport struct {
	Subject     string `json:"subject"`
	Status      string `` /* 150-byte string literal not displayed */
	Satisfiable bool   `json:"satisfiable"`
	Solver      string `json:"solver,omitempty" jsonschema:"the solver that answered"`
	Text        string `json:"text" jsonschema:"the prompt's report: the assignment, the conflicting conditions, the optimum"`
}

SolveReport is what a solver answered about one element.

type SolveResult

type SolveResult struct {
	Reports []SolveReport `json:"reports"`
	Text    string        `json:"text"`
}

SolveResult is a solver tool's answer: one report per element asked about.

type SubmitInput

type SubmitInput struct {
	SessionName
	Text string `` /* 133-byte string literal not displayed */
}

SubmitInput is declaration text for the session.

type SubmitResult

type SubmitResult struct {
	Accepted    bool         `json:"accepted" jsonschema:"whether the text was taken into the model without an error of its own"`
	Declared    []string     `json:"declared" jsonschema:"the names this submission introduced"`
	Notices     []string     `json:"notices" jsonschema:"side effects, such as a debugging session the submission ended"`
	Diagnostics []Diagnostic `json:"diagnostics" jsonschema:"the findings about this submission, located in it"`
	Text        string       `json:"text" jsonschema:"what the prompt printed for the submission"`
}

SubmitResult is what a submission declared and what the analysis found.

type SweepInput

type SweepInput struct {
	SessionName
	Name      string   `json:"name" jsonschema:"qualified name of the calc or analysis case"`
	Arguments []string `json:"arguments,omitempty" jsonschema:"argument expressions fixed for every row, positional or parameter=expression"`
	Object    string   `json:"object,omitempty" jsonschema:"the case's subject, an object the session holds"`
	Ranges    []string `json:"ranges" jsonschema:"one per swept parameter, written parameter=from..to[:step]; the rows are the cartesian product"`
	Samples   *Samples `json:"samples,omitempty" jsonschema:"draw rows uniformly from the ranges instead of stepping them"`
}

SweepInput names an invocation to run once per row of its ranges.

type Token

type Token struct {
	ID          int64    `json:"id"`
	Node        string   `json:"node" jsonschema:"the node the token sits at"`
	ArrivedFrom string   `json:"arrivedFrom,omitempty" jsonschema:"at a join, the node the token came from"`
	Awaiting    []string `json:"awaiting,omitempty" jsonschema:"at a join, the nodes whose tokens are still awaited"`
}

Token is one token of the debugged action.

type Verdict

type Verdict struct {
	Subject       string         `json:"subject" jsonschema:"what was run or checked, as named"`
	Status        string         `` /* 152-byte string literal not displayed */
	Values        []NamedValue   `json:"values" jsonschema:"what the run produced: a calc's result, an action's outputs, a case's outputs and verdicts"`
	Verifications []Verification `json:"verifications,omitempty"`
	Rows          []Row          `json:"rows,omitempty" jsonschema:"one per run of a sweep or of repeated runs"`
	Evaluations   []Evaluation   `json:"evaluations,omitempty"`
	Text          string         `json:"text" jsonschema:"the prompt's report"`
}

Verdict is what a run, check or sweep answered: its status, the values it produced, and the prompt's report of it.

type Verification

type Verification struct {
	Case    string `json:"case"`
	Kind    string `json:"kind"`
	Detail  string `json:"detail,omitempty"`
	Subcase bool   `json:"subcase,omitempty"`
}

Verification is the verdict a verification case's body answered about the checked requirement.

Jump to

Keyboard shortcuts

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