Skip to main content

Crate cpa_plugin

Crate cpa_plugin 

Source
Expand description

Native plugin host for CLIProxyAPI plugins (internal/pluginhost, sdk/pluginabi, sdk/pluginapi).

  • abi: C ABI 1, schema 6, method names, the JSON envelope.
  • gojson and api: Go encoding/json and the pluginapi schemas.
  • native: dlopen loading, the plugin call and host callback trampolines.
  • host: discovery, load/register/reconfigure/hot reload/unload, priority snapshot.
  • callbacks and streams: host.* callbacks and plugin-fed streams; hostauth: host.auth.* and host.affinity.lookup over the server’s hostauth::AuthManager.
  • management: plugin-declared management and resource routes.
  • store: the plugin store (registries, verified installs, store auth).

Re-exports§

pub use host::Host;
pub use host::Record;
pub use host::RegisteredPluginInfo;
pub use host::Snapshot;

Modules§

abi
sdk/pluginabi: ABI and schema versions, RPC method names and the JSON envelope.
api
sdk/pluginapi request and response schemas, field for field. Wire names are the Go field names unless Go declares a json tag. Host-only members (HTTPClient, handler interfaces) are not part of the wire format and are left out.
auth
Auth provider and frontend auth capabilities (internal/pluginhost/auth_provider.go, adapters_auth.go).
callbacks
Host callbacks (host.* methods) and callback contexts (internal/pluginhost/host_callbacks.go, callback_contexts.go).
cli
Command-line plugins (internal/pluginhost/command_line.go).
client
Plugin clients and the call guard (internal/pluginhost/client_guard.go).
config
The plugins: section as the host applies it (internal/pluginhost/config.go, internal/config/plugin_path.go, PluginInstanceConfig.UnmarshalYAML).
executor
Plugin executors at the RPC level (internal/pluginhost/adapters_executors.go, rpc_client_stream.go, executor_route.go): format negotiation, the executor’s provider, and executor.execute / execute_stream / count_tokens / http_request. Translation around the call, usage reporting and dispatch live in the server.
gojson
Go encoding/json for the plugin RPC contract.
homeplugins
Home-managed plugin installs, deletes and their status reports (Go internal/homeplugins and internal/home/plugin_status.go).
host
The plugin host lifecycle (internal/pluginhost/host.go, snapshot.go).
hostauth
host.auth.* and host.affinity.lookup callbacks (internal/pluginhost/ auth_callbacks.go, affinity_callbacks.go): plugins read and save credentials and observe session affinity through the host’s auth manager.
hostmodel
host.model.* callbacks (v8.0.35 host_callbacks.go, host_model_stream_callbacks.go and model_stream_bridge.go).
interceptors
Request, response, stream-chunk, lifecycle and WebSocket hooks (internal/pluginhost/adapters_interceptors.go).
management
Plugin-owned Management API and resource routes (internal/pluginhost/management.go, internal/htmlsanitize).
models
Model registration and executor ownership (internal/pluginhost/adapters.go RegisterModels/ModelsForAuth, adapters_executors.go RegisterExecutors).
native
The native C ABI (internal/pluginhost/loader_unix.go, host_callbacks_unix.go).
platform
Plugin file discovery and selection (internal/pluginhost/platform.go).
quota
Quota provider capability (internal/pluginhost/quota_provider.go).
routing
Scheduler and model router capabilities (internal/pluginhost/scheduler.go, model_router.go, executor_route.go).
rpc
RPC calls over a plugin client and the registration contract (internal/pluginhost/rpc_client.go, rpc_schema.go).
store
The plugin store (internal/pluginstore): registries that list installable plugins, GitHub release and direct-download installs verified by SHA-256, store authentication rules, the shared GitHub rate limiter, and the Home plugin-sync payloads.
streams
Plugin-fed streams (internal/pluginhost/stream_bridge.go).
transform
Translator hooks, thinking appliers and usage plugins (internal/pluginhost/adapters_usage_translation.go, sdk/translator/plugin_hooks.go).

Macros§

go_struct
Declares a Go struct with its wire names. Append omitempty after a name for Go’s ,omitempty.

Constants§

SUPPORT_PLUGIN
Go pluginhost.SupportPluginHeaderValue (X-CPA-SUPPORT-PLUGIN): “1” where native plugins load, as in Go’s cgo builds. ponytail: Windows DLL loading is not ported, so Windows reports “0”.

Functions§

go_preflight
Go Transport.roundTrip’s checks before anything is dialed, in its order: header names and values, the scheme, a host. The error is the *url.Error cause.
go_read_error_text
The error Go’s response body reader reports for err.
go_url_error
The *url.Error text Go’s http.Client.Do returns for a failed send (Get "url": cause), password masked.
go_url_error_text
The *url.Error text for a request Go’s client refused: Get "url": cause.