app

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2026 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidPreview = errors.New("preview is missing, expired, invalidated, or already used; obtain and review a new preview")
	ErrSessionClosed  = errors.New("session is closed")
	ErrSessionChanged = errors.New("session authentication changed; refresh and review before continuing")
)

Functions

func Breadcrumb(action, command, description string) baseoutput.Breadcrumb

func NormalizeInputNumbers

func NormalizeInputNumbers(object map[string]any) error

NormalizeInputNumbers prepares a decoded JSON object for schema validation. The validator recognizes int/uint/float JSON numbers, but currently treats a json.Number as a string during its type check. Preserve large integer inputs rather than converting every number through float64 during the defensive copy.

Types

type App

type App struct {
	Paths        config.Paths
	Config       *config.Store
	Snapshot     schema.Snapshot
	Manifest     schema.Manifest
	SnapshotData []byte
	Global       *GlobalOptions
	Stdin        io.Reader
	Stdout       io.Writer
	Stderr       io.Writer
	// InteractiveCheck is a test seam for terminal-only command flows. Output
	// modes and explicit non-interactive controls are always enforced before it.
	InteractiveCheck   func() bool
	WorkingDirectory   func() (string, error)
	ProjectTrustPrompt func(config.ProjectProfile, config.ProjectTrustState) (ProjectTrustDecision, error)
	// contains filtered or unexported fields
}

func New

func New(snapshotData, manifestData []byte, global *GlobalOptions) (*App, error)

func (*App) AuthService

func (a *App) AuthService(allowFileCredentials bool) (*auth.Service, error)

func (*App) ExecuteTool

func (a *App) ExecuteTool(ctx context.Context, name string, arguments map[string]any) (*ToolExecution, error)

func (*App) Interactive

func (a *App) Interactive() bool

func (*App) MCP

func (a *App) MCP(ctx context.Context) (*mcpclient.Client, string, error)

func (*App) OpenSession

func (a *App) OpenSession(ctx context.Context, profile string, allowFileCredentials bool) (Session, error)

OpenSession does not resolve or persist a default profile. The command must resolve precedence/project trust before calling this explicit-profile API.

func (*App) Output

func (a *App) Output() *clioutput.Writer

func (*App) ResolveProfile

func (a *App) ResolveProfile(required bool) (string, error)

type Catalogue

type Catalogue struct {
	Tools             []SessionTool
	Resources         []*mcp.Resource
	ResourceTemplates []*mcp.ResourceTemplate
	Warnings          []string
}

type GlobalOptions

type GlobalOptions struct {
	Profile  string
	JSON     bool
	Markdown bool
	Agent    bool
	JQ       string
	Yes      bool
}

type Invocation

type Invocation struct {
	Tool           string
	Arguments      map[string]any
	SchemaRevision string
}

type OutcomeUnknownError

type OutcomeUnknownError struct {
	Tool  string
	Cause error
}

OutcomeUnknownError never means that a write failed or was cancelled. The gateway may have executed it before the connection was lost. Do not replay.

func (*OutcomeUnknownError) Error

func (e *OutcomeUnknownError) Error() string

func (*OutcomeUnknownError) Unwrap

func (e *OutcomeUnknownError) Unwrap() error

type PreviewHandle

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

PreviewHandle carries no user-editable preview ID. Valid reports whether a handle was issued; Confirm also checks whether it remains valid and unused.

func (PreviewHandle) Valid

func (h PreviewHandle) Valid() bool

type ProjectTrustDecision

type ProjectTrustDecision string
const (
	ProjectUseOnce     ProjectTrustDecision = "once"
	ProjectTrustAlways ProjectTrustDecision = "always"
	ProjectTrustCancel ProjectTrustDecision = "cancel"
)

type SchemaChangedError

type SchemaChangedError struct{ Tool SessionTool }

func (*SchemaChangedError) Error

func (e *SchemaChangedError) Error() string

type Session

type Session interface {
	Profile() string
	Catalogue(context.Context) (*Catalogue, error)
	Invoke(context.Context, Invocation) (*ToolExecution, error)
	Confirm(context.Context, PreviewHandle) (*ToolExecution, error)
	ReadResource(context.Context, string) (*mcpclient.ResourceOutcome, error)
	InvalidatePreviews()
	Close() error
}

Session is a long-lived, explicit-profile connection. It never prompts, auto-confirms, or retries an invocation. The caller owns presentation and deliberate review; the gateway remains the authorization authority.

type SessionTool

type SessionTool struct {
	Name, Title, Description, Domain, Command, SchemaRevision string
	InputSchema                                               schema.JSONSchema
	RawSchema                                                 json.RawMessage
	Reviewed, ReadOnly, Destructive                           bool
	SchemaError                                               string
}

SessionTool combines live availability with reviewed local metadata. An unreviewed or uncompileable schema is retained for inspection, never silently replaced with the embedded schema. ReadOnly is deliberately conservative.

type ToolExecution

type ToolExecution struct {
	Profile       string                 `json:"profile"`
	Preview       *mcpclient.ToolOutcome `json:"preview,omitempty"`
	Confirmation  *mcpclient.ToolOutcome `json:"confirmation,omitempty"`
	Result        *mcpclient.ToolOutcome `json:"result"`
	PreviewHandle PreviewHandle          `json:"-"`
}

func (*ToolExecution) HumanText

func (e *ToolExecution) HumanText() string

Jump to

Keyboard shortcuts

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