automation

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: Apache-2.0 Imports: 3 Imported by: 1 module, 3 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 automation exposes tools from a Go app or library to nsgo mcp.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Call

func Call(cx *core.Scope, ctx context.Context, name string, args json.RawMessage) (json.RawMessage, error)

Call runs a synchronous (Handler) tool on cx's graph and returns its JSON result. Use CallAsync for a deferred (Start) tool. Call it on the graph goroutine, such as inside nsgotest.App.Post.

func CallAsync

func CallAsync(cx *core.Scope, ctx context.Context, name string, args json.RawMessage, done func(json.RawMessage, error))

CallAsync starts a registered tool on cx's graph and delivers its JSON result or error to done once. Call it on the graph goroutine, such as inside nsgotest.App.Post. Use ctx to bound the wait; cleaning up the registering scope ends a pending call with an error.

The non-nil done callback may run before CallAsync returns or later, on any goroutine. It must not block or panic. Post back to the graph before accessing graph state from done.

func Register

func Register(cx *core.Scope, tool Tool) error

Register gives a tool to cx's graph until cx is cleaned up. Names are unique on the graph and cannot replace built-in MCP tools. Call it on the graph goroutine. Registration is active in automation and test builds.

Types

type Tool

type Tool = core.AutomationTool

Tool describes an app tool. InputSchema is a JSON Schema object with type "object". Set exactly one of Handler and Start. Both run on the owning scope's graph goroutine, receive a JSON object and answer with a JSON-encodable value or an error.

Handler returns its answer directly. It must not wait for work posted back to the graph. Start returns without waiting and calls reply when its answer is ready, from any goroutine. Replies after the first reply, cancellation or scope cleanup are ignored. Start's context is canceled when the call finishes, including on scope cleanup.

Jump to

Keyboard shortcuts

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