api

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: MIT Imports: 2 Imported by: 0

README

openagent-go-plugin-api

Shared plugin API types for openagent-go .so plugins.

Overview

This module defines the interface types that .so plugins must implement. It is extracted into a standalone module so that both the host (openagent-go) and plugins can import it as a dependency, ensuring identical compilation fingerprints required by Go's plugin package.

Types

Type Description
Plugin Base interface all plugins must implement (Meta() PluginMeta)
ToolPlugin Plugin that provides a tool (Execute)
ModelProviderPlugin Plugin that provides model listings (Models)
PluginMeta Plugin metadata (type, name, description, parameters)
ModelEntry Model resource descriptor (apiKey, baseUrl, modelId, label)

Usage

package main

import api "github.com/runzhi214/openagent-go-plugin-api"

type myPlugin struct{}

func (p *myPlugin) Meta() api.PluginMeta {
    return api.PluginMeta{
        Type:        api.PluginTypeModelProvider,
        Name:        "my-plugin",
        Description: "My custom model provider",
    }
}

func NewPlugin() api.Plugin { return &myPlugin{} }

Build with:

go build -buildmode=plugin -o my-plugin.so .

License

MIT

Documentation

Index

Constants

View Source
const (
	PluginTypeTool          = "tool"
	PluginTypeModelProvider = "model_provider"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ModelEntry

type ModelEntry struct {
	ApiKey  string `json:"apiKey"`
	BaseUrl string `json:"baseUrl"`
	ModelId string `json:"modelId"`
	Label   string `json:"label"`
}

ModelEntry represents a model resource provided by a model_provider plugin.

type ModelProviderPlugin

type ModelProviderPlugin interface {
	Plugin
	Models(ctx context.Context) ([]ModelEntry, error)
}

ModelProviderPlugin is the interface for model_provider-type plugins.

type Plugin

type Plugin interface {
	Meta() PluginMeta
}

Plugin is the base interface that every .so plugin must implement.

type PluginMeta

type PluginMeta struct {
	Type        string          `json:"type"`
	Name        string          `json:"name"`
	Description string          `json:"description"`
	Parameters  json.RawMessage `json:"parameters,omitempty"`
}

PluginMeta describes a plugin.

type ToolPlugin

type ToolPlugin interface {
	Plugin
	Execute(ctx context.Context, args json.RawMessage) (string, error)
}

ToolPlugin is the interface for tool-type plugins.

Jump to

Keyboard shortcuts

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