Documentation
¶
Overview ¶
Package pluginapi is the versioned, platform-neutral contract for built-in plugins. Sessions must honor context cancellation and must not leave goroutines behind.
Index ¶
- Constants
- Variables
- func Redact(s string, secrets ...string) string
- func RedactingLogger(base *slog.Logger, creds Credentials) *slog.Logger
- func Register(p Plugin)
- func ValidateManifest(m Manifest) error
- func ValidateSchema(raw json.RawMessage) error
- type ArchiveManifest
- type Attachment
- type Blob
- type Capabilities
- type Channel
- type ChannelInspector
- type ChannelStatus
- type Check
- type Choice
- type CleanupBoundary
- type CleanupDriver
- type CleanupError
- type CleanupOffline
- type CleanupPolicy
- type ContentHooks
- type Credentials
- type Env
- type Event
- type EventSink
- type FileSource
- type Gap
- type Identity
- type ItemReader
- type Key
- type Link
- type Manifest
- type Message
- type Object
- type Plugin
- type Reaction
- type ReactionRenderer
- type ReactionView
- type RealtimeReporter
- type ReplyInspector
- type ReplyReaction
- type Root
- type RootRef
- type Session
- type Settings
- type SetupState
- type SetupStep
- type Snapshot
- type StepResult
- type Trigger
- type Workspace
Constants ¶
const APIVersion = 1
const MaxErrorDetail = 400
MaxErrorDetail bounds an error cause shown to users or written to logs.
Variables ¶
var ErrInvalid = errors.New("invalid content")
var ErrUnsupported = errors.New("unsupported capability")
Functions ¶
func Redact ¶
Redact makes an error cause safe to display: it removes the given secret values and anything shaped like a credential, collapses whitespace and caps the length. It is idempotent.
func RedactingLogger ¶
func RedactingLogger(base *slog.Logger, creds Credentials) *slog.Logger
RedactingLogger removes this workspace's resolved credential values from both messages and structured attributes, including nested groups and error values.
func ValidateManifest ¶
func ValidateSchema ¶
func ValidateSchema(raw json.RawMessage) error
ValidateSchema accepts only the form-rendering subset; parsing remains authoritative.
Types ¶
type ArchiveManifest ¶
type ArchiveManifest struct {
// CleanupProof links this generation to the journal whose receipts it folded.
CleanupProof string `json:"cleanup_proof,omitempty"`
Schema int `json:"schema"`
Platform string `json:"platform,omitempty"`
TeamID string `json:"team_id"`
Channel string `json:"channel"`
RootTS string `json:"root_ts"`
Permalink string `json:"permalink"`
MessageCount int `json:"message_count"`
Objects map[string]Object `json:"objects"`
Files []Attachment `json:"files"`
// Gaps lists items the source referenced but the capture could not store
// (an unreadable file or author, for example). The rest of the thread is kept.
Gaps []Gap `json:"gaps,omitempty"`
}
type Attachment ¶
type Blob ¶
type Blob struct {
Size int64
SHA256 string
Data []byte
Source *FileSource
}
Blob carries inline bytes or a confined, verified local file reference. Both forms are plain serializable data; a future RPC adapter can stream refs.
type Capabilities ¶
type Capabilities struct{ ReadHistory, Realtime, Delete bool }
type ChannelInspector ¶
type ChannelInspector interface {
InspectChannels(context.Context, []string) ([]ChannelStatus, error)
}
ChannelInspector is an optional Session extension used by diagnostics.
type ChannelStatus ¶
ChannelStatus reports whether the connected account can read a channel.
type Choice ¶
Choice is a selectable option. Glyph, Image and Group are optional display hints (for example an emoji character, a custom image URL and a picker category).
type CleanupBoundary ¶
type CleanupBoundary interface {
CleanupBoundary(Workspace, ArchiveManifest) string
}
CleanupBoundary validates source-specific workspace identity offline.
type CleanupDriver ¶
type CleanupError ¶
type CleanupError struct{ Status, Reason string }
CleanupStatus classifies safe mutation failures without leaking transport details.
func (*CleanupError) Error ¶
func (e *CleanupError) Error() string
type CleanupOffline ¶
CleanupOffline checks platform policy without credentials or network access.
type CleanupPolicy ¶
type ContentHooks ¶
type Credentials ¶
func (Credentials) LogValue ¶
func (Credentials) LogValue() slog.Value
func (Credentials) MarshalJSON ¶
func (Credentials) MarshalJSON() ([]byte, error)
type Event ¶
type Event struct{ Channel, RootTS, Kind, ItemTS string }
Event is a capture hint. ItemTS, when set and different from RootTS, names the message inside the thread that a reaction event was about (a reply); the runtime re-reads it through ItemReader before it may authorize an archive.
type FileSource ¶
type FileSource struct{ Root, Path string }
type Gap ¶
type Gap struct {
Kind string `json:"kind"`
ID string `json:"id,omitempty"`
Message string `json:"message,omitempty"`
Reason string `json:"reason"`
}
Gap is one referenced item that is missing from an archive, with a short, credential-free reason suitable for display.
type ItemReader ¶
ItemReader is an optional Session extension for realtime reply reactions: it re-reads the reactions on one message of a thread and must verify that the message belongs to rootTS. It returns a zero Root when the message is gone.
type Manifest ¶
type Manifest struct {
ID, Name, Version string
APIVersion int
Capabilities Capabilities
ClaimsLegacy bool
DefaultReactions []string
}
type Plugin ¶
type Plugin interface {
Manifest() Manifest
ConfigSchema() json.RawMessage
CredentialSchema() json.RawMessage
ParseWorkspace(context.Context, json.RawMessage, Credentials) (Settings, error)
ValidateWorkspaces(context.Context, []Settings) error
SetupFlow() []SetupStep
NewSession(context.Context, Workspace, Env) (Session, error)
NewCleanupDriver(context.Context, Workspace, Env) (CleanupDriver, error)
Content() ContentHooks
}
type ReactionRenderer ¶
type ReactionRenderer interface {
Reactions(context.Context, Message) ([]ReactionView, error)
}
ReactionRenderer is an optional ContentHooks extension for viewers.
type ReactionView ¶
type ReactionView struct {
Name, Glyph, Image string
// MatchNames are trigger names that match this reaction, supplied by the platform.
MatchNames []string
Count int
}
ReactionView describes a stored reaction for display.
type RealtimeReporter ¶
RealtimeReporter is an optional Session extension describing the live event connection. Detail is a short user-facing explanation.
type ReplyInspector ¶
type ReplyInspector interface {
ReplyReactions(context.Context, []RootRef, []string) ([]ReplyReaction, error)
}
ReplyInspector is an optional Session extension: it lists reactions placed on replies of the given roots so diagnostics can explain why they never match.
type ReplyReaction ¶
type ReplyReaction struct {
Channel, RootTS, TS, Name string
}
ReplyReaction is a reaction on a non-root message, reported by diagnostics only.
type Session ¶
type Session interface {
Capabilities() Capabilities
VerifyIdentity(context.Context) (Identity, error)
Channels(context.Context) ([]Channel, error)
History(context.Context, string, string) ([]RootRef, error)
Root(context.Context, string, string) (Root, error)
Snapshot(context.Context, string, Root, *Snapshot) (Snapshot, error)
Start(context.Context, EventSink) error
Stop(context.Context) error
Reconfigure(context.Context, Workspace) (bool, error)
}
type Settings ¶
type Settings json.RawMessage
type SetupState ¶
type SetupState map[string]json.RawMessage
type SetupStep ¶
type SetupStep struct {
ID, Title, Kind, Body string
Links []Link
Schema json.RawMessage
Run func(context.Context, SetupState, json.RawMessage, Env) (StepResult, error)
Prepare func(context.Context, SetupState, Env) (StepResult, error)
Test func(context.Context, SetupState, json.RawMessage, Env) (StepResult, error)
Skip, SkipNote string
}
SetupStep is one wizard page. Run validates a submission. Optional hooks: Prepare runs when the page is shown (dynamic links, choices); Test runs the "Test connection" action without advancing. Skip, when set, labels an explicit fallback action that clears this step's secret fields and then calls Run.
type Snapshot ¶
type Snapshot struct {
// RawDocuments contains original transport response bytes; Prepare seals them into Documents.
RawDocuments map[string][]byte
// CleanupStatus summarizes the journal state for archive readers.
CleanupStatus string `json:"cleanup_status,omitempty"`
// SourceDeletedAt projects verified journal and persisted deletion markers.
SourceDeletedAt map[string]string `json:"source_deleted_at,omitempty"`
Manifest ArchiveManifest
Messages []Message
Users map[string]Message
// RawUsers retains optional malformed non-author metadata without rendering it.
RawUsers map[string]any
Blobs map[string]Blob
Documents map[string][]byte
}
type StepResult ¶
type Trigger ¶
type Trigger struct {
Reactions []string `json:"reactions" yaml:"reactions"`
Who string `json:"who" yaml:"who"`
Owners []string `json:"owners" yaml:"owners"`
Match string `json:"match,omitempty" yaml:"match,omitempty"`
}
Trigger selects roots to archive. Match "all" (the default, kept for legacy configurations) requires every listed reaction; "any" requires at least one.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package plugintest checks contract-v1 manifests, schemas and lifecycle behavior.
|
Package plugintest checks contract-v1 manifests, schemas and lifecycle behavior. |