backend

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: May 20, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package backend provides the ConnectRPC client for the Kontext AgentService. Authenticates with the user's OIDC bearer token from `kontext login`. No client secrets, no client_credentials grant.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BaseURL

func BaseURL() string

BaseURL returns the API base URL from env or default.

Types

type BootstrapCliResult added in v0.6.0

type BootstrapCliResult struct {
	Response       *agentv1.BootstrapCliResponse
	AccessMode     HostedAccessMode
	PolicySetEpoch string
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client wraps the ConnectRPC AgentService client.

func NewClient

func NewClient(baseURL string, ts TokenSource) *Client

NewClient creates a ConnectRPC client that fetches a fresh token per request.

func (*Client) BootstrapCli added in v0.3.0

func (c *Client) BootstrapCli(ctx context.Context, req *agentv1.BootstrapCliRequest) (*BootstrapCliResult, error)

BootstrapCli prepares the shared CLI application for env template sync.

func (*Client) CreateSession

CreateSession creates a governed agent session.

func (*Client) EndSession

func (c *Client) EndSession(ctx context.Context, sessionID string) error

EndSession terminates a session.

func (*Client) Heartbeat

func (c *Client) Heartbeat(ctx context.Context, sessionID string) error

Heartbeat keeps a session alive.

func (*Client) ProcessHookEvent added in v0.6.0

ProcessHookEvent sends a single hook event via the ProcessHookEvent unary RPC.

type HostedAccessMode added in v0.6.0

type HostedAccessMode string
const (
	HostedAccessModeDisabled HostedAccessMode = "disabled"
	HostedAccessModeNoPolicy HostedAccessMode = "no_policy"
	HostedAccessModeEnforce  HostedAccessMode = "enforce"
)

type ProcessHookEventResult added in v0.6.0

type ProcessHookEventResult struct {
	Response       *agentv1.ProcessHookEventResponse
	ReasonCode     string
	RequestID      string
	AccessMode     HostedAccessMode
	PolicySetEpoch string
}

type TokenSource

type TokenSource func(forceRefresh bool) (string, error)

TokenSource returns a valid access token, refreshing if necessary. If forceRefresh is true, the source must obtain a new token regardless of whether the cached one appears valid (used for retry-on-401).

func StaticToken

func StaticToken(token string) TokenSource

StaticToken returns a TokenSource that always returns the same token. Useful for tests or short-lived commands.

Jump to

Keyboard shortcuts

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