Files
WeKnora/pluginsdk/pluginapi/stream.go
T
lyingbug 4328ab26a9 feat(plugin): code plugins — extension protocol, Go SDK, plugin host, web search and data source adapters (#3720)
* 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
2026-09-26 14:45:15 +08:00

35 lines
1.2 KiB
Go

package pluginapi
import "encoding/json"
// EventType is the kind of one NDJSON line in a streaming answer.
type EventType string
const (
// EventItem carries one result (a FetchedItem for connectors).
EventItem EventType = "item"
// EventCheckpoint carries a resumable cursor; WeKnora persists it.
EventCheckpoint EventType = "checkpoint"
// EventProgress reports progress for display.
EventProgress EventType = "progress"
// EventLog forwards a log line to WeKnora's logs.
EventLog EventType = "log"
// EventError ends the stream with an error.
EventError EventType = "error"
// EventEnd ends the stream successfully, with the final Data.
EventEnd EventType = "end"
)
// Event is one line of a streaming answer. A stream that stops without an
// "end" or "error" event was interrupted and is treated as failed.
type Event struct {
Type EventType `json:"type"`
Data json.RawMessage `json:"data,omitempty"`
// Error is set on EventError.
Error *Error `json:"error,omitempty"`
// Message is set on EventLog and EventProgress.
Message string `json:"message,omitempty"`
// Level is set on EventLog: debug, info, warn, error.
Level string `json:"level,omitempty"`
}