Documentation
¶
Overview ¶
Package channelplugin executes compiled channel wire hooks. It deliberately has no database, credential, routing, filesystem or network capability.
Index ¶
- Constants
- Variables
- func SupportsMultipartProtocol(protocol string) bool
- type CatalogTemplate
- type DriverInput
- type EndpointTemplate
- type FileReference
- type ImageTaskTemplate
- type Input
- type Manifest
- type MultipartPart
- type Observation
- type ObservationResult
- type Option
- type Program
- func (p *Program) Call(ctx context.Context, hook string, input Input) (Result, error)
- func (p *Program) CallDriver(ctx context.Context, hook string, input DriverInput) (json.RawMessage, error)
- func (p *Program) Fingerprint() string
- func (p *Program) HasDriverHook(hook string) bool
- func (p *Program) HasImageTask(protocol string) bool
- func (p *Program) Manifest() Manifest
- func (p *Program) Observe(protocol string, event bool, body []byte) (ObservationResult, error)
- func (p *Program) StreamsImageTask(protocol string) bool
- type ProtocolObservations
- type ProviderDefaults
- type RequestDescriptor
- type Result
Constants ¶
const ( MaxSourceBytes = 256 << 10 MaxInputBytes = 4 << 20 MaxResultBytes = 256 << 10 CallTimeout = 250 * time.Millisecond Concurrency = 4 MemoryLimit = 16 << 20 )
const MaxDriverResultBytes = 4 << 20
Variables ¶
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 ¶
Types ¶
type CatalogTemplate ¶
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 FileReference ¶
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 (Manifest) DurableTaskCapture ¶
func (Manifest) IsProvider ¶
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.
type MultipartPart ¶
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 Program ¶
type Program struct {
// contains filtered or unexported fields
}
func Compile ¶
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) 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 (*Program) HasDriverHook ¶
func (*Program) HasImageTask ¶
func (*Program) Observe ¶
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 ¶
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.