Documentation
¶
Index ¶
Constants ¶
const ( // PriorityLoop is the fallback registration priority used by game.Loop.Run // when a game does not attach a full pkg/mcp.Bridge. PriorityLoop = 1 // PriorityBridge is the full pkg/mcp.Bridge registration priority, // superseding any game.Loop fallback while attached. PriorityBridge = 2 )
Variables ¶
This section is empty.
Functions ¶
func IsSameOriginPath ¶
IsSameOriginPath reports whether raw is a safe same-origin absolute URL path (starts with "/" and not "//", contains no backslashes, whitespace, or control characters).
func Register ¶
func Register(Config) (unregister func())
Register is a no-op outside js/wasm web builds.
func RegisterLoop ¶
func RegisterLoop(post func(func()), c LoopControl) (unregister func())
RegisterLoop registers the fallback loop tools at PriorityLoop, running each call through post on the loop's goroutine. It returns the unregister function, a no-op outside js/wasm.
Types ¶
type Config ¶
type Config struct {
// Source identifies who registered the runtime (for example "mcp.Bridge" or "game.Loop").
Source string
// Priority selects which active registration wins when more than one is attached.
Priority int
// Post schedules fn to run on the engine/graph goroutine (typically core.Scope.Post).
// When nil, CallTool runs directly.
Post func(fn func())
// ListTools returns the tools currently exposed by this registration.
ListTools func() []ToolInfo
// CallTool invokes a named tool with JSON object arguments on the engine goroutine
// and returns its JSON-encoded result.
CallTool func(ctx context.Context, name string, args json.RawMessage) (json.RawMessage, error)
}
Config registers a runtime's MCP tool dispatcher on window.__nsgoMCP in js/wasm web builds.
type LoopControl ¶
type LoopControl struct {
Paused func() bool
SetPaused func(bool)
TimeScale func() float64
SetTimeScale func(float64)
StepSeconds func() float64
StepRate func() int
Steps func() uint64
ElapsedSeconds func() float64
StepNow func(int) int
}
LoopControl is the part of game.Loop the fallback Play-mode tools read and drive. game.Loop fills it with its own methods; it lives here so the tools build and test on every target, while Register stays a no-op outside js/wasm.
func (LoopControl) Call ¶
func (c LoopControl) Call(name string, raw json.RawMessage) (json.RawMessage, error)
Call runs the fallback loop tool name with its JSON arguments and returns its JSON result.