pluginremote

package
v1.15.3 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package pluginremote is the remote.Source of a service plugin that declares remote_source: Send / Receive / Done go to the plugin's internal /_wick/remote/* paths over its unix socket, and events arrive as SSE in the v1 event schema, so nothing is converted.

Index

Constants

View Source
const (
	Kind        = "plugin-remote"
	AdapterKind = "plugin"
	ProviderKey = "plugin-remote/plugin-remote"
	RowType     = "plugin-remote"
)

Persona kind, adapter kind, provider key, and agent_channels row type.

View Source
const UsageByMention = "mention"

UsageByMention marks a plugin remote agent whose mention policy decides who may reach it.

Variables

View Source
var ErrSessionStarted = errors.New("the remote session has started; start a new chat to change these values")

ErrSessionStarted is returned by SaveSessionOptions once the remote session exists: its values can no longer change (start a new chat).

Functions

func OpenValues

func OpenValues(codec Codec, values map[string]string) (map[string]string, error)

OpenValues decrypts stored values for the plugin; a token that is not encrypted passes through.

func SaveSessionOptions

func SaveSessionOptions(dir string, opts map[string]string) error

SaveSessionOptions keeps opts (empty values dropped) as the answers the session's first turn sends, until the remote session exists.

func SealValues

func SealValues(codec Codec, decl []wickentity.Config, values map[string]string) (map[string]string, error)

SealValues encrypts the values of the secret keys of decl.

func SessionOptions

func SessionOptions(dir string) (opts map[string]string, locked bool)

SessionOptions returns the session's SessionField values and whether they are locked because the remote session already exists.

Types

type Codec

type Codec interface {
	EncryptSecret(plain string) (string, error)
	DecryptSecret(token string) (string, error)
}

Codec encrypts secret values at rest — the configs codec connector secrets use.

type Config

type Config struct {
	AgentID     string `json:"agent_id"`
	OwnerUserID string `json:"owner_user_id"`
	PluginKey   string `json:"plugin_key"`
	// Usage is UsageByMention once the agent's mention policy decides who
	// may reach it; "" for a row saved before, which took no agent's turn.
	Usage string `json:"usage,omitempty"`
	// Values are the agent's RemoteConfigs answers by key. A secret's value
	// is stored encrypted (wick_cenc_); see SealValues / OpenValues.
	Values map[string]string `json:"values,omitempty"`
}

Config is a plugin remote agent's settings row.

type Source

type Source struct {
	Key string
	// AgentID and Config ride on every turn: the remote agent and its
	// per-agent config in plaintext. Set them before the first Send.
	AgentID string
	Config  map[string]string
	// contains filtered or unexported fields
}

Source is one agent's plugin adapter.

func NewSource

func NewSource(key string, t Transport) *Source

NewSource wraps plugin key.

func (*Source) Cancel

func (s *Source) Cancel(ctx context.Context, h remote.Handle) error

Cancel stops h's turn on the remote's side (Stop in wick), when the plugin's describe says "cancel": true; otherwise there is nothing to call and the remote may keep working.

func (*Source) Describe

func (s *Source) Describe(ctx context.Context) (remote.Description, error)

func (*Source) End

func (s *Source) End(h remote.Handle)

End releases h on the plugin side.

func (*Source) Inject

func (s *Source) Inject(ctx context.Context, h remote.Handle, turn remote.Turn) error

func (*Source) Kind

func (s *Source) Kind() string

func (*Source) Label

func (s *Source) Label() string

func (*Source) Limits

func (s *Source) Limits() remote.Limits

func (*Source) Listen

func (s *Source) Listen() []remote.ListenMode

func (*Source) Receive

func (s *Source) Receive(ctx context.Context, h remote.Handle) (<-chan remote.Event, error)

Receive streams h's events until the plugin closes the stream.

func (*Source) ResumeID

func (s *Source) ResumeID(dir string) string

ResumeID names the session by the plugin's conversation id.

func (*Source) Send

func (s *Source) Send(ctx context.Context, turn remote.Turn) (remote.Handle, error)

Send posts the turn (with the conversation id of earlier turns) and keeps the id the plugin answers with.

func (*Source) SessionFields

func (s *Source) SessionFields(ctx context.Context) ([]wickplugin.SessionField, error)

SessionFields asks the plugin which values a new session of this agent takes (defaults resolved from the agent's Config); nil when the plugin declares none.

func (*Source) Test

func (s *Source) Test(ctx context.Context) remote.TestResult

Test pings Describe.

type Store

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

Store keeps Config in agent_channels (type plugin-remote, name agent id).

func NewStore

func NewStore(db *gorm.DB) *Store

NewStore wraps db.

func (*Store) Load

func (s *Store) Load(agentID string) (Config, bool, error)

Load returns agentID's settings; ok=false when it has none.

func (*Store) Save

func (s *Store) Save(c Config) error

Save writes c.

func (*Store) Update

func (s *Store) Update(c Config) error

Update rewrites an existing row's settings.

type Transport

type Transport func(key string) (http.RoundTripper, error)

Transport resolves the running plugin's socket transport.

Jump to

Keyboard shortcuts

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