channelplugin

package
v0.29.2 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: AGPL-3.0 Imports: 19 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 channelplugin executes compiled channel wire hooks. It deliberately has no database, credential, routing, filesystem or network capability.

Index

Constants

View Source
const (
	MaxSourceBytes = 256 << 10
	MaxInputBytes  = 4 << 20
	MaxResultBytes = 256 << 10
	CallTimeout    = 250 * time.Millisecond
	Concurrency    = 4
	MemoryLimit    = 16 << 20
)
View Source
const MaxDriverResultBytes = 4 << 20

Variables

View Source
var (
	ErrManifest    = errors.New("channel_plugin_manifest_invalid")
	ErrRequestKind = errors.New("channel_plugin_request_kind_unsupported")
	ErrCompile     = errors.New("channel_plugin_compile_failed")
	ErrExecution   = errors.New("channel_plugin_execution_failed")
	ErrResult      = errors.New("channel_plugin_result_invalid")
)

Functions

func SupportsMultipartProtocol

func SupportsMultipartProtocol(protocol string) bool

Types

type CatalogTemplate

type CatalogTemplate struct {
	Path            string `json:"path"`
	Auth            string `json:"auth"`
	CursorParameter string `json:"cursorParameter,omitempty"`
}

type DriverInput

type DriverInput struct {
	Protocol       string                     `json:"protocol,omitempty"`
	Body           string                     `json:"body"`
	BodyKind       string                     `json:"bodyKind,omitempty"`
	Files          []FileReference            `json:"files,omitempty"`
	Model          string                     `json:"model,omitempty"`
	Stream         bool                       `json:"stream"`
	CredentialKind string                     `json:"credentialKind"`
	TaskID         string                     `json:"taskId,omitempty"`
	Operation      string                     `json:"operation,omitempty"`
	State          json.RawMessage            `json:"state,omitempty"`
	StatusCode     int                        `json:"statusCode,omitempty"`
	Headers        http.Header                `json:"headers,omitempty"`
	Options        map[string]json.RawMessage `json:"options"`
}

The host supplies the selected identity and opaque task references. Secrets, file bytes, request handles, route selection and billing never enter JS.

type EndpointTemplate

type EndpointTemplate struct {
	Path      string `json:"path"`
	Auth      string `json:"auth"`
	ModelPath bool   `json:"modelPath,omitempty"`
	Profile   string `json:"profile,omitempty"`
}

type FileReference

type FileReference struct {
	Ref      string `json:"ref"`
	Field    string `json:"field"`
	Filename string `json:"filename"`
	MIMEType string `json:"mimeType"`
	Size     int64  `json:"size"`
}

type ImageTaskTemplate

type ImageTaskTemplate struct {
	Query  EndpointTemplate `json:"query"`
	Stream bool             `json:"stream,omitempty"`
}

type Input

type Input struct {
	Protocol string                     `json:"protocol"`
	Body     string                     `json:"body"`
	Model    string                     `json:"model"`
	Stream   bool                       `json:"stream"`
	Options  map[string]json.RawMessage `json:"options"`
}

Input contains only per-attempt wire data and manifest-validated options. JSON travels as text, so passing an untouched field through a hook cannot round a 64-bit integer, reorder members or strip native extensions.

type Manifest

type Manifest struct {
	APIVersion      int                             `json:"apiVersion"`
	Kind            string                          `json:"kind,omitempty"`
	Key             string                          `json:"key"`
	Name            string                          `json:"name"`
	Version         string                          `json:"version"`
	Protocols       []string                        `json:"protocols"`
	Hooks           []string                        `json:"hooks"`
	Options         []Option                        `json:"options,omitempty"`
	CredentialKinds []string                        `json:"credentialKinds,omitempty"`
	RequestKinds    []string                        `json:"requestKinds,omitempty"`
	Defaults        *ProviderDefaults               `json:"defaults,omitempty"`
	Observations    map[string]ProtocolObservations `json:"observations,omitempty"`
	Authentication  *contract.Authentication        `json:"authentication,omitempty"`
	TaskCapture     *string                         `json:"taskCapture,omitempty"`
	ImageTasks      map[string]ImageTaskTemplate    `json:"imageTasks,omitempty"`
}

func (Manifest) AcceptsRequestKind

func (m Manifest) AcceptsRequestKind(kind string) bool

func (Manifest) DurableTaskCapture

func (m Manifest) DurableTaskCapture() bool

func (Manifest) IsProvider

func (m Manifest) IsProvider() bool

func (Manifest) ResolveOptions

func (m Manifest) ResolveOptions(values map[string]json.RawMessage) (map[string]json.RawMessage, error)

ResolveOptions rejects unknown keys and invalid types; defaults belong to the installed manifest, not a second set maintained by a form or importer.

func (Manifest) Validate

func (m Manifest) Validate() error

type MultipartPart

type MultipartPart struct {
	Field   string  `json:"field"`
	Value   *string `json:"value,omitempty"`
	FileRef string  `json:"fileRef,omitempty"`
}

type Observation

type Observation struct {
	UsagePaths map[string]string `json:"usagePaths,omitempty"`
	ModelPath  string            `json:"modelPath,omitempty"`
	ErrorPath  string            `json:"errorPath,omitempty"`
	TaskIDPath string            `json:"taskIdPath,omitempty"`
}

Observation paths select original JSON values, independently of executable decoders. The host retains token interpretation, pricing and settlement.

type ObservationResult

type ObservationResult struct {
	Usage  json.RawMessage
	Model  json.RawMessage
	Failed bool
	TaskID json.RawMessage
}

type Option

type Option struct {
	Key     string          `json:"key"`
	Label   string          `json:"label"`
	Type    string          `json:"type"`
	Default json.RawMessage `json:"default"`
	Choices []string        `json:"choices,omitempty"`
	Min     *float64        `json:"min,omitempty"`
	Max     *float64        `json:"max,omitempty"`
}

type Program

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

func Compile

func Compile(ctx context.Context, source string) (*Program, error)

Compile evaluates metadata in the same bounded environment as request hooks. Raw engine exceptions are never returned: plugins could echo private input or credentials accidentally embedded in source into a management/log error.

func (*Program) Call

func (p *Program) Call(ctx context.Context, hook string, input Input) (Result, error)

func (*Program) CallDriver

func (p *Program) CallDriver(ctx context.Context, hook string, input DriverInput) (json.RawMessage, error)

Driver calls produce bounded JSON for the operation's owning host parser. Descriptor validation, raw usage observation and terminal validation remain mandatory at those consumers; a driver call performs no network I/O.

func (*Program) Fingerprint

func (p *Program) Fingerprint() string

func (*Program) HasDriverHook

func (p *Program) HasDriverHook(hook string) bool

func (*Program) HasImageTask

func (p *Program) HasImageTask(protocol string) bool

func (*Program) Manifest

func (p *Program) Manifest() Manifest

func (*Program) Observe

func (p *Program) Observe(protocol string, event bool, body []byte) (ObservationResult, error)

Observe uses captured metadata only: even a throwing decoder cannot remove already received usage. Missing pointers are normal for partial SSE events; malformed/ambiguous JSON is an error, never an unknown successful document.

func (*Program) StreamsImageTask

func (p *Program) StreamsImageTask(protocol string) bool

type ProtocolObservations

type ProtocolObservations struct {
	Response *Observation `json:"response,omitempty"`
	Event    *Observation `json:"event,omitempty"`
}

func (ProtocolObservations) Validate

func (o ProtocolObservations) Validate() error

type ProviderDefaults

type ProviderDefaults struct {
	Endpoints map[string]EndpointTemplate `json:"endpoints,omitempty"`
	Catalog   *CatalogTemplate            `json:"catalog,omitempty"`
}

type RequestDescriptor

type RequestDescriptor struct {
	Method      string            `json:"method"`
	Path        string            `json:"path,omitempty"`
	Body        string            `json:"body,omitempty"`
	ContentType string            `json:"contentType,omitempty"`
	Headers     map[string]string `json:"headers,omitempty"`
	Parts       []MultipartPart   `json:"parts,omitempty"`
}

A descriptor addresses an administrator-selected endpoint, not a new origin. The host injects current authentication after this validation and retains its own transport, proxy, cancellation, attempt and redirection policies.

func (RequestDescriptor) ResolveURL

func (d RequestDescriptor) ResolveURL(endpoint string) (*url.URL, error)

func (RequestDescriptor) Validate

func (d RequestDescriptor) Validate() error

type Result

type Result struct {
	Body    []requestoverride.Operation `json:"body,omitempty"`
	Headers []requestoverride.Operation `json:"headers,omitempty"`
}

Hooks calculate ordered operations rather than replacing routing, transport, credential or budget decisions. Values are JSON text, not JS Numbers.

Directories

Path Synopsis
Package contract contains plugin configuration identity rules without depending on the executable JS runtime.
Package contract contains plugin configuration identity rules without depending on the executable JS runtime.

Jump to

Keyboard shortcuts

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