sdk

package
v0.11.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: Apache-2.0, MIT Imports: 8 Imported by: 0

Documentation

Overview

Package sdk provides a thin Go SDK for writing Overkill plugins.

A minimal plugin looks like:

func main() {
    p := sdk.New(sdk.Manifest{
        Name: "hello", Version: "0.1.0",
    })
    p.OnTool("greet", func(ctx context.Context, args json.RawMessage) (any, error) {
        return map[string]string{"text": "hi!"}, nil
    })
    p.RegisterTool(sdk.ToolDecl{Name: "greet", Description: "say hi"})
    p.Run()
}

The SDK speaks JSON-RPC 2.0 over stdio. It mirrors the wire format used by internal/plugin in the host so plugin authors don't need to read the host source.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommandDecl

type CommandDecl struct {
	ID          string `json:"id"`
	Title       string `json:"title"`
	Description string `json:"description,omitempty"`
}

CommandDecl is the schema sent via host.register_command.

type CommandHandler

type CommandHandler func(ctx context.Context, args string) error

CommandHandler runs a /command invocation.

type ContextHandler

type ContextHandler func(ctx context.Context, promptSoFar, sessionID string) []ContextSnippet

ContextHandler is called before each prompt to provide context snippets.

type ContextSnippet

type ContextSnippet struct {
	Title   string `json:"title"`
	Content string `json:"content"`
}

ContextSnippet is one item returned from a context provider.

type EventHandler

type EventHandler func(payload json.RawMessage)

EventHandler is called when the host fires a subscribed event.

type Manifest

type Manifest struct {
	Name        string      `json:"name"`
	Version     string      `json:"version"`
	Description string      `json:"description,omitempty"`
	Permissions Permissions `json:"permissions"`
}

Manifest is what the plugin returns from plugin.initialize.

type Permissions

type Permissions struct {
	ConfigKeys []string `json:"config_keys,omitempty"`
	ToolsCall  []string `json:"tools_call,omitempty"`
	Events     []string `json:"events,omitempty"`
}

Permissions is the declared scope of host capabilities the plugin needs.

type Plugin

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

Plugin is the public type plugin authors interact with.

func New

func New(m Manifest) *Plugin

New constructs a Plugin with the given manifest.

func (*Plugin) Config

func (p *Plugin) Config(ctx context.Context, key string) (any, error)

Config reads a host config value (must be declared in permissions).

func (*Plugin) OnCommand

func (p *Plugin) OnCommand(id string, h CommandHandler)

func (*Plugin) OnContext

func (p *Plugin) OnContext(h ContextHandler)

OnContext registers a context provider.

func (*Plugin) OnEvent

func (p *Plugin) OnEvent(h EventHandler)

func (*Plugin) OnTool

func (p *Plugin) OnTool(name string, h ToolHandler)

func (*Plugin) RegisterCommand

func (p *Plugin) RegisterCommand(c CommandDecl)

RegisterCommand declares a slash-command. Pair with OnCommand.

func (*Plugin) RegisterTool

func (p *Plugin) RegisterTool(t ToolDecl)

RegisterTool declares a tool. Pair with OnTool to handle invocations.

func (*Plugin) Run

func (p *Plugin) Run() error

Run drives the JSON-RPC loop until stdin closes. Blocks.

func (*Plugin) Session

func (p *Plugin) Session(ctx context.Context) (SessionInfo, error)

Session fetches the current session info from the host.

func (*Plugin) Subscribe

func (p *Plugin) Subscribe(event string)

Subscribe declares interest in an event. Use OnEvent to receive them.

func (*Plugin) Toast

func (p *Plugin) Toast(ctx context.Context, kind, text string) error

Toast asks the host to display a UI toast.

type SessionInfo

type SessionInfo struct {
	ID           string `json:"id"`
	Title        string `json:"title"`
	MessageCount int    `json:"message_count"`
}

SessionInfo is what host.session_get returns.

type ToolDecl

type ToolDecl struct {
	Name        string          `json:"name"`
	Description string          `json:"description,omitempty"`
	ArgsSchema  json.RawMessage `json:"args_schema,omitempty"`
	RiskLevel   string          `json:"risk_level,omitempty"`
}

ToolDecl is the schema sent via host.register_tool.

type ToolHandler

type ToolHandler func(ctx context.Context, args json.RawMessage) (any, error)

ToolHandler runs a tool invocation. Return either the result value or an error; the SDK serializes both.

Jump to

Keyboard shortcuts

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