access

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package access stores validated, invocation-scoped generation access state.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidAuthenticatedInfo = errors.New("invalid authenticated generation access")

ErrInvalidAuthenticatedInfo indicates that authenticated state was incomplete or contained an unsupported value.

Functions

func WithAuthenticated

func WithAuthenticated(ctx context.Context, info AuthenticatedInfo) (context.Context, error)

WithAuthenticated validates and records authenticated generation state. On validation failure it returns the original context unchanged.

func WithDirect

func WithDirect(ctx context.Context, options ...DirectOption) context.Context

WithDirect records explicit direct generation. Direct output is always AGPL licensed; commercial output requires authenticated caller input.

Types

type AuthenticatedInfo

type AuthenticatedInfo struct {
	AccountType        shared.AccountType
	BillingAddOns      []shared.BillingAddOn
	WorkspaceCreatedAt *time.Time
	WorkspaceID        string
	TelemetryDisabled  bool
	GeneratedLicense   GeneratedLicense
}

AuthenticatedInfo contains metadata already validated or decided by the authenticating caller. It does not contain credentials or entitlement rules.

type DirectOption

type DirectOption interface {
	// contains filtered or unexported methods
}

DirectOption configures explicit direct generation.

func DisableTelemetry

func DisableTelemetry() DirectOption

DisableTelemetry explicitly opts direct generation out of usage telemetry.

type GeneratedLicense

type GeneratedLicense string

GeneratedLicense identifies the license selected for generated output.

const (
	GeneratedLicenseAGPL       GeneratedLicense = "agpl"
	GeneratedLicenseCommercial GeneratedLicense = "commercial"
)

type Mode

type Mode uint8

Mode identifies how a generation invocation was authorized.

const (
	ModeDirect Mode = iota + 1
	ModeAuthenticated
)

type State

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

State is immutable generation access state. Construct it with WithDirect or WithAuthenticated and retrieve it with StateFromContext.

func StateFromContext

func StateFromContext(ctx context.Context) (State, bool)

StateFromContext returns a defensive copy of the explicit access state.

func (State) AccountType

func (s State) AccountType() (shared.AccountType, bool)

AccountType returns authenticated account metadata. Direct state has no account type.

func (State) BillingAddOns

func (s State) BillingAddOns() []shared.BillingAddOn

BillingAddOns returns a defensive copy of authenticated billing add-ons.

func (State) GeneratedLicense

func (s State) GeneratedLicense() GeneratedLicense

GeneratedLicense returns the caller-decided generated-output license.

func (State) HasBillingAddOn

func (s State) HasBillingAddOn(addOn shared.BillingAddOn) bool

HasBillingAddOn checks authenticated billing add-ons without allocating a copy.

func (State) Mode

func (s State) Mode() Mode

Mode returns the explicitly selected invocation mode.

func (State) TelemetryDisabled

func (s State) TelemetryDisabled() bool

TelemetryDisabled reports whether usage telemetry is disabled for this invocation.

func (State) WorkspaceCreatedAt

func (s State) WorkspaceCreatedAt() *time.Time

WorkspaceCreatedAt returns a defensive copy of authenticated workspace metadata.

func (State) WorkspaceID

func (s State) WorkspaceID() (string, bool)

WorkspaceID returns authenticated workspace identity. Direct state has no workspace ID.

Jump to

Keyboard shortcuts

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