Help us shape the future of Go! Take the 2026 Go Developer Survey

connectors

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 8, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package connectors defines the adapter contracts used by the trusted platform service (§10). External credentials stay inside the platform process; seats only reach connectors through the capability gateway.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrAmbiguous means the request may have been accepted but the response
	// was lost. The gateway must not blindly retry.
	ErrAmbiguous = errors.New("outcome unknown")
	// ErrRetryable means the request was definitely not applied (e.g. rate
	// limited or rejected before processing) and can be retried.
	ErrRetryable = errors.New("retryable")
	// ErrPermanent means the request was rejected and will not succeed on retry.
	ErrPermanent = errors.New("permanent failure")
	// ErrUnauthorized means credentials are missing, expired or insufficient.
	ErrUnauthorized = errors.New("unauthorized")
)

Outcome errors. Adapters wrap one of these so the gateway can decide whether a retry is safe (§10.3).

Functions

This section is empty.

Types

type Communication

type Communication interface {
	// Verify checks authentication (e.g. auth.test) without sending messages.
	Verify(ctx context.Context) error
	// VerifyUser checks that an external user exists in the authorised account.
	VerifyUser(ctx context.Context, userID string) error
	// Run receives events until ctx is cancelled. It reports connection health
	// through Healthy.
	Run(ctx context.Context, sink IngressSink) error
	// Healthy reports whether the ingress connection is currently established.
	Healthy() (bool, string)
	// Send delivers a message and returns the external receipt (e.g. message ts).
	Send(ctx context.Context, msg OutboundMessage) (string, error)
}

Communication is a human communication adapter (e.g. Slack).

type Config

type Config struct {
	OrganizationID string
	Key            string // connection key
	Adapter        string
	AccountID      string
	// Endpoint overrides the service base URL (used for fakes and self-hosted).
	Endpoint string
	Secret   map[string]string
	Extra    map[string]string
	// Model describes a model connection's endpoint (compiled defaults applied).
	Model *spec.ModelEndpoint
	// ModelUses are the models and APIs seats use through a model
	// connection; readiness checks them.
	ModelUses []ModelUse
	HTTP      *http.Client
}

Config is what an adapter factory receives for one declared connection.

type Credential added in v0.2.0

type Credential struct {
	Username  string
	Token     string
	ExpiresAt time.Time
	Revocable bool
	// Data is a non-token credential, e.g. a browser storage state.
	Data json.RawMessage
}

Credential is a credential delivered to a sandbox.

type CredentialIssuer added in v0.2.0

type CredentialIssuer interface {
	IssueCredential(ctx context.Context, scope CredentialScope) (Credential, error)
	// RevokeCredential invalidates an issued credential where the service
	// supports it (Credential.Revocable).
	RevokeCredential(ctx context.Context, token string) error
}

CredentialIssuer is implemented by connections that deliver a credential into a sandbox (github, browser_session). The platform calls it only for a seat whose access grants sandbox delivery on the connection.

type CredentialScope added in v0.2.0

type CredentialScope struct {
	Repos       []string
	Permissions map[string]string
}

CredentialScope narrows an issued credential.

type HTTPIngress added in v0.4.0

type HTTPIngress interface {
	Handler() http.Handler
}

HTTPIngress is implemented by communication adapters whose humans connect to the platform instead of the platform dialling out. The platform mounts the handler under /v1/channels/{organization}/{connection}/ with that prefix removed; the handler authenticates every request itself.

type InboundEvent

type InboundEvent struct {
	// EventID is the provider's stable event identity for deduplication.
	EventID string
	// AccountID is the verified installation or workspace identity.
	AccountID string
	UserID    string
	ChannelID string
	// ThreadRef identifies the external conversation (e.g. channel or thread ts).
	ThreadRef string
	Text      string
	MessageTS string
}

InboundEvent is a verified event from a communication service.

type IngressSink

type IngressSink interface {
	Accept(ctx context.Context, connection string, ev InboundEvent) error
}

IngressSink persists an inbound event. It must return nil only after the event is durably accepted (or recognised as a duplicate); the adapter acknowledges the external event afterwards (§9.2).

type Model

type Model interface {
	Verify(ctx context.Context) error
	// Proxy returns a handler serving the provider API with the credential
	// injected. The incoming request path has the platform prefix removed.
	Proxy() http.Handler
}

Model is a model-serving connection. The platform proxies inference so the credential never enters the sandbox (§5.2).

type ModelUse added in v0.2.0

type ModelUse struct{ ID, API string }

ModelUse is a model requested over an API.

type OutboundMessage

type OutboundMessage struct {
	ExternalUserID string
	ChannelID      string
	ThreadRef      string
	Text           string
	// IdempotencyKey is the platform operation id.
	IdempotencyKey string
}

OutboundMessage is a reply to a human through a channel binding.

type Resolved added in v0.2.0

type Resolved struct {
	Values map[string]string
	// Version identifies the stored version (Kubernetes resourceVersion,
	// Vault KV version). It is not secret and may change without the
	// content changing, for example on a metadata-only update.
	Version string
	// Digest identifies the content: it changes exactly when a value
	// changes. It is a hash, safe to keep in memory, never logged.
	Digest string
}

Resolved is the current content of a secret reference.

type Result

type Result struct {
	Receipt string          `json:"receipt"`
	Data    json.RawMessage `json:"data"`
}

Result is the outcome of a tracker operation.

type SecretWatcher added in v0.2.0

type SecretWatcher interface {
	Watch(ctx context.Context, notify func(ref string)) error
}

SecretWatcher is implemented by resolvers that can report changes as they happen. notify receives the reference that may have changed; the caller resolves it again to find out. Watch blocks until ctx is cancelled.

type Secrets

type Secrets interface {
	Resolve(ctx context.Context, ref string) (Resolved, error)
}

Secrets resolves a secret reference (vault:<path> or k8s:<name>) into its key/value pairs. Values never leave the platform process.

type Tracker

type Tracker interface {
	Verify(ctx context.Context) error
	// Invoke performs an operation. operationID is embedded in created records
	// where the API has no idempotency key, so FindByOperation can read back.
	Invoke(ctx context.Context, operation string, params json.RawMessage, operationID string) (Result, error)
	// FindByOperation looks for the effect of a previous attempt of operationID.
	FindByOperation(ctx context.Context, operation string, params json.RawMessage, operationID string) (*Result, error)
	// ReadOnly reports whether an operation has no side effects.
	ReadOnly(operation string) bool
}

Tracker is a work-tracker adapter (e.g. Linear).

Directories

Path Synopsis
Package browsersession holds a signed-in browser session for the browser access plugin: a Playwright storage state (cookies and local storage), secret key storage_state.
Package browsersession holds a signed-in browser session for the browser access plugin: a Playwright storage state (cookies and local storage), secret key storage_state.
Package github is the GitHub connector.
Package github is the GitHub connector.
internal
httpx
Package httpx holds HTTP helpers shared by connector adapters: a transport that records whether a request reached the wire, so that a failure can be classified as "definitely not applied" or "outcome unknown" (§10.3).
Package httpx holds HTTP helpers shared by connector adapters: a transport that records whether a request reached the wire, so that a failure can be classified as "definitely not applied" or "outcome unknown" (§10.3).
Package linear is the Linear work-tracker adapter (ADR-0003).
Package linear is the Linear work-tracker adapter (ADR-0003).
Package model is the model-serving connector for the anthropic, openai and model adapters.
Package model is the model-serving connector for the anthropic, openai and model adapters.
Package secretref resolves connection secret references (docs/architecture.html#secrets): "k8s:<name>" reads a Secret in the control-plane namespace and "vault:<path>" reads Vault KV v2 using Kubernetes auth.
Package secretref resolves connection secret references (docs/architecture.html#secrets): "k8s:<name>" reads a Secret in the control-plane namespace and "vault:<path>" reads Vault KV v2 using Kubernetes auth.
Package slack is the Slack communication adapter (ADR-0003).
Package slack is the Slack communication adapter (ADR-0003).
Package terminal is the bare-bones command-line communication adapter.
Package terminal is the bare-bones command-line communication adapter.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL