agentsdk

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2026 License: MIT Imports: 10 Imported by: 0

README

Agent SDK

A minimized agent sdk that supports mcp and skills calls.

使用方式

    rcfg := &agentsdk.Config{
        SkillsDir:  os.Getenv("SKILL_DIRS"), // 指定 skills 文件夹,由于最小化,并不通用。尽可能符合 openai skill 调用方式
        MCPServers: nil,
        APIKey:     os.Getenv("OPENAI_API_KEY"),
        APIBase:    os.Getenv("OPENAI_API_BASE"),
        Model:      os.Getenv("OPENAI_API_MODE"),
        Debug:      true,
    }

    agent, e := agentsdk.New(rcfg)
    if e != nil {
        panic(e)
    }

    resp, e := agent.Run(context.Background(), os.Getenv("INPUT"))
    if e != nil {
        panic(e)
    }
    fmt.Println(resp)

参考项目

  1. goskills
  2. anna

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetContextID added in v1.0.0

func GetContextID(ctx context.Context) (id string)

func SetContextID added in v1.0.0

func SetContextID(ctx context.Context, id string) context.Context

Types

type Agent

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

Agent manages the skill discovery, selection, and execution process.

func New

func New(cfg *Config) (a *Agent, e error)

New creates and initializes a new Agent.

func (*Agent) Chat added in v1.0.0

func (a *Agent) Chat(ctx context.Context, prompt string) (content string, e error)

Chat reuse all configurations, just reset context message

func (*Agent) Messages

func (a *Agent) Messages() (lst []openai.ChatCompletionMessage)

Messages reuse all configurations, just reset context message

func (*Agent) NewChat

func (a *Agent) NewChat(history []openai.ChatCompletionMessage) (n *Agent)

NewChat reuse all configurations, just reset context message

func (*Agent) Run

func (a *Agent) Run(ctx context.Context, userPrompt string) (resp string, e error)

Run executes the main skill selection and execution logic for a single turn.

type Config

type Config struct {
	APIKey        string
	APIBase       string
	Model         string
	SkillsDir     string
	MCPServers    map[string]mcp.MCPServer
	MCPMaxRetries int
	Debug         bool
	History       []openai.ChatCompletionMessage
}

Config holds all the necessary configuration for the runner.

type OpenAIChatClient added in v1.0.0

type OpenAIChatClient interface {
	CreateChatCompletion(ctx context.Context, req openai.ChatCompletionRequest) (openai.ChatCompletionResponse, error)
}

OpenAIChatClient interface for dependency injection and testing

Directories

Path Synopsis
examples
cli command
modules
officalmcp/conformance/everything-client command
The conformance client implements features required for MCP conformance testing.
The conformance client implements features required for MCP conformance testing.
officalmcp/internal/docs
The doc package generates the documentation at /doc, via go:generate.
The doc package generates the documentation at /doc, via go:generate.
officalmcp/internal/jsonrpc2
Package jsonrpc2 is a minimal implementation of the JSON RPC 2 spec.
Package jsonrpc2 is a minimal implementation of the JSON RPC 2 spec.
officalmcp/internal/mcpgodebug
Package mcpgodebug provides a mechanism to configure compatibility parameters via the MCPGODEBUG environment variable.
Package mcpgodebug provides a mechanism to configure compatibility parameters via the MCPGODEBUG environment variable.
officalmcp/internal/readme
The readme package is used to generate README.md at the top-level of this repo.
The readme package is used to generate README.md at the top-level of this repo.
!+
!+
officalmcp/internal/xcontext
Package xcontext is a package to offer the extra functionality we need from contexts that is not available from the standard context package.
Package xcontext is a package to offer the extra functionality we need from contexts that is not available from the standard context package.
officalmcp/jsonrpc
Package jsonrpc exposes part of a JSON-RPC v2 implementation for use by mcp transport authors.
Package jsonrpc exposes part of a JSON-RPC v2 implementation for use by mcp transport authors.
officalmcp/mcp
The mcp package provides an SDK for writing model context protocol clients and servers.
The mcp package provides an SDK for writing model context protocol clients and servers.
officalmcp/oauthex
Package oauthex implements extensions to OAuth2.
Package oauthex implements extensions to OAuth2.

Jump to

Keyboard shortcuts

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