moduleapi

package
v0.2.12 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: Apache-2.0 Imports: 15 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 moduleapi defines the compile-time contract between the Node runtime and optional native feature modules under modules/*/node.

Core packages never import concrete feature modules; an explicit assembly package (such as internal/assembly/host) constructs an Assembly and passes it to node.StartWithOptions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildCustomTool

func BuildCustomTool(spec ToolSpec, instruction string, execute func(context.Context, canonical.ToolRequest) engine.ToolResult) (engine.Tool, error)

BuildCustomTool constructs an engine.Tool directly from a ToolSpec and custom execution hooks (used by modules such as code-index workflows, OCR listing, and memory).

Types

type Assembly

type Assembly struct {
	CodeIndex codeindexapi.Factory
	Modules   []Module
}

Assembly selects the compile-time Node modules and optional services.

func (Assembly) CommandHandlerFor

func (a Assembly) CommandHandlerFor(kind string) CommandHandler

CommandHandlerFor returns the assembled module owning the given protocol command kind, if any.

func (Assembly) LookupTool

func (a Assembly) LookupTool(name string) (ToolMeta, bool)

LookupTool resolves presentation metadata for a canonical module tool name or its legacy plugin/MCP alias.

func (Assembly) NativeSkillPackages

func (a Assembly) NativeSkillPackages() []operations.NativeSkillPackage

NativeSkillPackages returns the skill trees contributed by assembled modules.

func (Assembly) NativeSkills

func (a Assembly) NativeSkills() []protocol.NativeSkill

NativeSkills returns the protocol-facing metadata of all built-in module skills.

func (Assembly) ReplacesPlugin

func (a Assembly) ReplacesPlugin(name string) bool

ReplacesPlugin reports whether any assembled module supersedes the tool declarations of the named legacy plugin package.

type BrowserToolConfig

type BrowserToolConfig struct {
	Spec         ToolSpec
	Instruction  string
	PluginGate   string
	PrepareArgs  func(ctx context.Context, args json.RawMessage) (json.RawMessage, error)
	FormatResult func(ctx context.Context, result engine.ToolResult) engine.ToolResult
}

BrowserToolConfig configures one built-in controller browser tool.

type BuiltInSkill

type BuiltInSkill struct {
	Package string
	Skill   protocol.PluginSkill
	Tree    fs.FS
}

BuiltInSkill describes a compile-time skill bundled inside a native module.

type CatalogSpec

type CatalogSpec struct {
	Instructions string     `json:"instructions,omitempty"`
	Tools        []ToolSpec `json:"tools"`
}

CatalogSpec pairs optional module-level instructions with its tool specs.

func LoadCatalog

func LoadCatalog(raw []byte) (CatalogSpec, error)

LoadCatalog decodes an embedded module tool catalog and fills default policy, presentation and grouping values.

type CommandHandler

type CommandHandler interface {
	HandlesCommand(kind string) bool
	ExecuteCommand(ctx context.Context, host Host, caller protocol.NodeID, request protocol.Request) (protocol.Output, []protocol.Event, error)
}

CommandHandler is optionally implemented by native modules that own direct Node protocol commands (such as native memory catalog CRUD).

type ConnectionToolConfig

type ConnectionToolConfig struct {
	Spec            ToolSpec
	Instruction     string
	TurnInstruction prompt.Part
	Captured        []protocol.ConnectionResource
	PrepareArgs     func(ctx context.Context, args json.RawMessage) (json.RawMessage, error)
	FormatResult    func(ctx context.Context, preparedArgs json.RawMessage, result engine.ToolResult) engine.ToolResult
}

ConnectionToolConfig configures one native tool backed by a database or SSH connection operation.

type ExternalBrowserToolConfig

type ExternalBrowserToolConfig struct {
	Spec         ToolSpec
	Instruction  string
	Close        func() error
	PrepareArgs  func(ctx context.Context, args json.RawMessage) (json.RawMessage, error)
	FormatResult func(ctx context.Context, result engine.ToolResult) engine.ToolResult
}

ExternalBrowserToolConfig configures one managed Chromium browser tool.

type Host

type Host interface {
	WorkspaceTool(inv *store.AgentInvocation, cfg WorkspaceToolConfig) (engine.Tool, error)
	ScopedTool(inv *store.AgentInvocation, cfg ScopedToolConfig) (engine.Tool, error)
	ConnectionTool(inv *store.AgentInvocation, cfg ConnectionToolConfig) (engine.Tool, error)
	BrowserTool(inv *store.AgentInvocation, cfg BrowserToolConfig) (engine.Tool, error)
	ExternalBrowserTool(inv *store.AgentInvocation, cfg ExternalBrowserToolConfig) (engine.Tool, error)

	HasCodeIndex() bool
	RunWorkspaceOperation(ctx context.Context, inv *store.AgentInvocation, op protocol.ToolOperation, args json.RawMessage) (protocol.Output, error)
	ListLocalModels(ctx context.Context, kind protocol.ModelsKind) ([]protocol.ModelsLocalModel, error)

	ConnectionCatalog(ctx context.Context, inv *store.AgentInvocation) (store.ConnectionCatalog, error)
	CaptureConnectionTargets(inv *store.AgentInvocation, targets []protocol.ConnectionResource)

	BrowserAvailable(inv *store.AgentInvocation) bool
	ExternalBrowserAvailable() bool
	ExternalBrowserEnabled(ctx context.Context) (bool, error)
	ExternalBrowserCloseOnCancel(ctx context.Context, session protocol.SessionID) func() error

	ComputerEnabled(ctx context.Context) (bool, error)
	ConnectComputerMCP(ctx context.Context, inv *store.AgentInvocation, catalog CatalogSpec) ([]engine.Tool, error)

	PluginCaptured(inv *store.AgentInvocation, name string) (protocol.PluginReference, bool)
	PluginInstalled(ctx context.Context, name string) (installed bool, enabled bool, err error)

	PluginStorageGet(ctx context.Context, inv *store.AgentInvocation, namespace, key string) (protocol.PluginStorageEntry, error)
	PluginStorageSearch(ctx context.Context, inv *store.AgentInvocation, namespace string, query protocol.PluginStorageSearch) (protocol.PluginStorageSearchPage, error)
	PluginStorageTransaction(ctx context.Context, inv *store.AgentInvocation, namespace string, ops []protocol.PluginTransactionOperation) ([]protocol.Output, error)
	ConfigureStorageApproval(ctx context.Context, db *sql.Conn, turn protocol.TurnID, value protocol.ConversationApproval) (protocol.ConversationApproval, error)

	// Controller-scoped storage helpers for native module commands (outside an agent turn).
	StorageGet(ctx context.Context, namespace, key string) (protocol.PluginStorageEntry, error)
	StorageSearch(ctx context.Context, namespace string, query protocol.PluginStorageSearch) (protocol.PluginStorageSearchPage, error)
	StorageTransaction(ctx context.Context, namespace string, ops []protocol.PluginTransactionOperation) ([]protocol.Output, error)
	ProjectExists(ctx context.Context, id string) (bool, error)
}

Host exposes narrowly scoped Node execution services to native modules.

type Module

type Module interface {
	ID() string
	ReplacesPlugins() []string
	Catalog() []ToolMeta
	ToolsForTurn(ctx context.Context, host Host, inv *store.AgentInvocation) ([]engine.Tool, error)
}

Module is one compile-time native Node feature module.

type ScopedToolConfig

type ScopedToolConfig struct {
	Spec        ToolSpec
	Instruction string
	PrepareArgs func(ctx context.Context, args json.RawMessage) (json.RawMessage, error)
}

ScopedToolConfig configures one native tool backed by a scoped Node operation such as local model install/removal.

type SkillProvider

type SkillProvider interface {
	Skills() []BuiltInSkill
}

SkillProvider is optionally implemented by native modules that ship built-in skills (for example, web-search:research).

type ToolMeta

type ToolMeta struct {
	Name          string                    `json:"name"`
	LegacyPackage string                    `json:"legacy_package,omitempty"`
	LegacyServer  string                    `json:"legacy_server,omitempty"`
	LegacyName    string                    `json:"legacy_name,omitempty"`
	Presentation  protocol.ToolPresentation `json:"presentation,omitempty"`
	Grouping      protocol.ToolGrouping     `json:"grouping,omitempty"`
	Display       *protocol.ToolDisplay     `json:"display,omitempty"`
}

ToolMeta describes presentation, grouping, localized display metadata and legacy package-alias resolution for one native module tool.

func (ToolMeta) LegacyAlias

func (m ToolMeta) LegacyAlias() string

LegacyAlias returns the canonical alias formerly generated when this tool was owned by a bundled plugin package (or plugin MCP server), or an empty string if none applies.

type ToolSpec

type ToolSpec struct {
	Name          string                                `json:"name"`
	LegacyPackage string                                `json:"legacy_package,omitempty"`
	LegacyServer  string                                `json:"legacy_server,omitempty"`
	LegacyName    string                                `json:"legacy_name,omitempty"`
	Description   string                                `json:"description"`
	Operation     protocol.ToolOperation                `json:"operation,omitempty"`
	Action        string                                `json:"action,omitempty"`
	Parameters    json.RawMessage                       `json:"parameters"`
	Initial       bool                                  `json:"initial,omitempty"`
	ReadOnly      bool                                  `json:"read_only,omitempty"`
	Concurrent    bool                                  `json:"concurrent,omitempty"`
	StreamRead    bool                                  `json:"stream_read,omitempty"`
	Contexts      []protocol.PluginConversationResource `json:"contexts,omitempty"`
	Platforms     []string                              `json:"platforms,omitempty"`
	Presentation  protocol.ToolPresentation             `json:"presentation,omitempty"`
	Grouping      protocol.ToolGrouping                 `json:"grouping,omitempty"`
	Display       *protocol.ToolDisplay                 `json:"display,omitempty"`
}

ToolSpec holds the declarative metadata of one native module tool, typically embedded as JSON in the module package.

func (ToolSpec) Available

func (s ToolSpec) Available(inv *store.AgentInvocation) bool

Available reports whether this tool can be offered in the captured turn.

func (ToolSpec) LegacyAlias

func (s ToolSpec) LegacyAlias() string

LegacyAlias returns the former plugin-scoped alias for this tool, if any.

func (ToolSpec) Meta

func (s ToolSpec) Meta() ToolMeta

Meta converts this specification to its static presentation metadata.

func (ToolSpec) SearchLabels

func (s ToolSpec) SearchLabels() []string

SearchLabels returns sorted, deduplicated display labels for tool_search.

type WorkspaceToolConfig

type WorkspaceToolConfig struct {
	Spec            ToolSpec
	Instruction     string
	TurnInstruction prompt.Part
	ContextParts    []string
	PrepareArgs     func(ctx context.Context, args json.RawMessage) (json.RawMessage, error)
	FormatResult    func(ctx context.Context, args json.RawMessage, result engine.ToolResult) engine.ToolResult
}

WorkspaceToolConfig configures one native tool backed by a workspace operation.

Jump to

Keyboard shortcuts

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