mirror of
https://github.com/Tencent/WeKnora.git
synced 2026-10-13 08:50:22 +08:00
* feat(pluginsdk): extension protocol v1, Go SDK and conformance suite * feat(plugin): run code plugins in an embedded plugin host * feat(plugin): remote adapters for web search and data sources * fix(plugin): show plugin errors by their message * feat(frontend): plugin connectors and web search providers in the UI * docs(pluginsdk): how to write, package, test and install a plugin * fix(plugin): gofmt two files and read openapi.yaml line-ending agnostic * fix(plugin): mark a host plugin ready before Activate returns
33 lines
1.4 KiB
Go
33 lines
1.4 KiB
Go
// Package pluginapi is version 1 of the WeKnora extension protocol: the
|
|
// messages WeKnora and a code plugin exchange over HTTP. It has no
|
|
// dependencies so that plugins and WeKnora share one definition; openapi.yaml
|
|
// in this directory describes the same protocol for other languages.
|
|
//
|
|
// Every call is a POST whose body is an Envelope and whose successful answer
|
|
// is {"output": ...}. Streaming calls answer with NDJSON Events instead. A
|
|
// failed call answers with a non-2xx status and an ErrorBody. Within a major
|
|
// version the protocol only grows: new optional fields and new endpoints.
|
|
// Both sides ignore fields they do not know.
|
|
package pluginapi
|
|
|
|
// ProtocolVersion is the major version this package speaks; it travels in
|
|
// the ProtocolHeader of every request.
|
|
const ProtocolVersion = "1"
|
|
|
|
// APIVersion is the manifest apiVersion of plugins speaking this protocol.
|
|
const APIVersion = "weknora.plugin/v1"
|
|
|
|
// Request headers.
|
|
const (
|
|
ProtocolHeader = "X-WeKnora-Protocol"
|
|
RequestIDHeader = "X-Request-Id"
|
|
// SignatureHeader and TimestampHeader authenticate calls to remote
|
|
// plugins: hex HMAC-SHA256 over "<timestamp>.<body>" with the shared
|
|
// secret. Host plugins get a bearer token instead.
|
|
SignatureHeader = "X-WeKnora-Signature"
|
|
TimestampHeader = "X-WeKnora-Timestamp"
|
|
)
|
|
|
|
// NDJSONContentType is the content type of streaming answers.
|
|
const NDJSONContentType = "application/x-ndjson"
|