monetizeapi

package
v0.10.0-rc3 Latest Latest
Warning

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

Go to latest
Published: May 19, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Group   = "obol.org"
	Version = "v1alpha1"

	ServiceOfferKind        = "ServiceOffer"
	RegistrationRequestKind = "RegistrationRequest"
	PurchaseRequestKind     = "PurchaseRequest"
	AgentKind               = "Agent"
	AgentIdentityKind       = "AgentIdentity"

	ServiceOfferResource        = "serviceoffers"
	RegistrationRequestResource = "registrationrequests"
	PurchaseRequestResource     = "purchaserequests"
	AgentResource               = "agents"
	AgentIdentityResource       = "agentidentities"

	// Default identity used for the operator's public ERC-8004 registration
	// file. The registration file can contain multiple per-chain registrations.
	AgentIdentityDefaultNamespace = "x402"
	AgentIdentityDefaultName      = "default"

	PausedAnnotation = "obol.org/paused"

	AgentRuntimeHermes = "hermes"

	AgentPhasePending      = "Pending"
	AgentPhaseProvisioning = "Provisioning"
	AgentPhaseReady        = "Ready"
	AgentPhaseFailed       = "Failed"
)

Variables

View Source
var (
	ServiceOfferGVR        = schema.GroupVersionResource{Group: Group, Version: Version, Resource: ServiceOfferResource}
	RegistrationRequestGVR = schema.GroupVersionResource{Group: Group, Version: Version, Resource: RegistrationRequestResource}
	PurchaseRequestGVR     = schema.GroupVersionResource{Group: Group, Version: Version, Resource: PurchaseRequestResource}
	AgentGVR               = schema.GroupVersionResource{Group: Group, Version: Version, Resource: AgentResource}
	AgentIdentityGVR       = schema.GroupVersionResource{Group: Group, Version: Version, Resource: AgentIdentityResource}

	ServiceGVR        = schema.GroupVersionResource{Group: "", Version: "v1", Resource: "services"}
	SecretGVR         = schema.GroupVersionResource{Group: "", Version: "v1", Resource: "secrets"}
	ConfigMapGVR      = schema.GroupVersionResource{Group: "", Version: "v1", Resource: "configmaps"}
	DeploymentGVR     = schema.GroupVersionResource{Group: "apps", Version: "v1", Resource: "deployments"}
	MiddlewareGVR     = schema.GroupVersionResource{Group: "traefik.io", Version: "v1alpha1", Resource: "middlewares"}
	HTTPRouteGVR      = schema.GroupVersionResource{Group: "gateway.networking.k8s.io", Version: "v1", Resource: "httproutes"}
	ReferenceGrantGVR = schema.GroupVersionResource{Group: "gateway.networking.k8s.io", Version: "v1beta1", Resource: "referencegrants"}
	// Used by the agent reconciler when provisioning per-namespace
	// runtime primitives. Keeping them next to the existing GVRs avoids
	// scattering schema.GroupVersionResource literals across the package.
	NamespaceGVR      = schema.GroupVersionResource{Group: "", Version: "v1", Resource: "namespaces"}
	ServiceAccountGVR = schema.GroupVersionResource{Group: "", Version: "v1", Resource: "serviceaccounts"}
	PVCGVR            = schema.GroupVersionResource{Group: "", Version: "v1", Resource: "persistentvolumeclaims"}
)

Functions

func AgentIdentityAgentIDForChain added in v0.10.0

func AgentIdentityAgentIDForChain(status AgentIdentityStatus, chain string) string

func HasAgentIdentityRegistrations added in v0.10.0

func HasAgentIdentityRegistrations(status AgentIdentityStatus) bool

Types

type Agent added in v0.10.0

type Agent struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              AgentSpec   `json:"spec,omitempty"`
	Status            AgentStatus `json:"status,omitempty"`
}

func (*Agent) EffectiveModel added in v0.10.0

func (a *Agent) EffectiveModel() string

EffectiveModel returns the model the controller should use right now: the user-pinned spec.model when set, falling back to the previously resolved status.pinnedModel. Returns "" if neither is set, signalling "first reconcile, pick top-of-rank from LiteLLM and write back to status".

func (*Agent) EffectiveRuntime added in v0.10.0

func (a *Agent) EffectiveRuntime() string

func (*Agent) IsReady added in v0.10.0

func (a *Agent) IsReady() bool

type AgentIdentity added in v0.10.0

type AgentIdentity struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              AgentIdentitySpec   `json:"spec,omitempty"`
	Status            AgentIdentityStatus `json:"status,omitempty"`
}

AgentIdentity is the durable, on-chain identity an operator controls in the ERC-8004 Identity Registry. A single AgentIdentity outlives ServiceOffers: deleting the last ServiceOffer that references it does not delete the NFT, the published registration document, or the recorded agentId; instead the renderer publishes a tombstone (active:false, x402Support:false) so external observers still see the historical record.

type AgentIdentityRegistration added in v0.10.0

type AgentIdentityRegistration struct {
	Chain   string `json:"chain,omitempty"`
	AgentID string `json:"agentId,omitempty"`
}

type AgentIdentitySpec added in v0.10.0

type AgentIdentitySpec struct {
}

type AgentIdentityStatus added in v0.10.0

type AgentIdentityStatus struct {
	Registrations []AgentIdentityRegistration `json:"registrations,omitempty"`
}

func UpsertAgentIdentityRegistration added in v0.10.0

func UpsertAgentIdentityRegistration(status AgentIdentityStatus, chain, agentID string) AgentIdentityStatus

type AgentSpec added in v0.10.0

type AgentSpec struct {
	Runtime   string      `json:"runtime,omitempty"`
	Model     string      `json:"model,omitempty"`
	Skills    []string    `json:"skills,omitempty"`
	Objective string      `json:"objective,omitempty"`
	Wallet    AgentWallet `json:"wallet,omitempty"`
}

type AgentStatus added in v0.10.0

type AgentStatus struct {
	ObservedGeneration int64       `json:"observedGeneration,omitempty"`
	Phase              string      `json:"phase,omitempty"`
	PinnedModel        string      `json:"pinnedModel,omitempty"`
	WalletAddress      string      `json:"walletAddress,omitempty"`
	Endpoint           string      `json:"endpoint,omitempty"`
	Conditions         []Condition `json:"conditions,omitempty"`
}

type AgentWallet added in v0.10.0

type AgentWallet struct {
	Create bool `json:"create,omitempty"`
}

type Condition

type Condition struct {
	Type               string      `json:"type"`
	Status             string      `json:"status"`
	Reason             string      `json:"reason,omitempty"`
	Message            string      `json:"message,omitempty"`
	LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty"`
}

type PreSignedAuth

type PreSignedAuth struct {
	ID          string                 `json:"id,omitempty"`
	Payment     map[string]interface{} `json:"payment,omitempty"`
	Signature   string                 `json:"signature"`
	From        string                 `json:"from"`
	To          string                 `json:"to"`
	Value       string                 `json:"value"`
	ValidAfter  string                 `json:"validAfter"`
	ValidBefore string                 `json:"validBefore"`
	Nonce       string                 `json:"nonce"`
}

type PurchaseAutoRefill

type PurchaseAutoRefill struct {
	Enabled   bool `json:"enabled,omitempty"`
	Threshold int  `json:"threshold,omitempty"`
	Count     int  `json:"count,omitempty"`
}

type PurchasePayment

type PurchasePayment struct {
	Network             string `json:"network"`
	PayTo               string `json:"payTo"`
	Price               string `json:"price"`
	Asset               string `json:"asset"`
	AssetSymbol         string `json:"assetSymbol,omitempty"`
	AssetDecimals       int64  `json:"assetDecimals,omitempty"`
	AssetTransferMethod string `json:"assetTransferMethod,omitempty"`
	EIP712Name          string `json:"eip712Name,omitempty"`
	EIP712Version       string `json:"eip712Version,omitempty"`
}

type PurchaseRequest

type PurchaseRequest struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              PurchaseRequestSpec   `json:"spec,omitempty"`
	Status            PurchaseRequestStatus `json:"status,omitempty"`
}

func (*PurchaseRequest) EffectiveBuyerNamespace

func (pr *PurchaseRequest) EffectiveBuyerNamespace() string

type PurchaseRequestSpec

type PurchaseRequestSpec struct {
	Endpoint       string             `json:"endpoint"`
	Model          string             `json:"model"`
	Count          int                `json:"count"`
	PreSignedAuths []PreSignedAuth    `json:"preSignedAuths,omitempty"`
	AutoRefill     PurchaseAutoRefill `json:"autoRefill,omitempty"`
	Payment        PurchasePayment    `json:"payment"`
}

type PurchaseRequestStatus

type PurchaseRequestStatus struct {
	ObservedGeneration int64       `json:"observedGeneration,omitempty"`
	Conditions         []Condition `json:"conditions,omitempty"`
	PublicModel        string      `json:"publicModel,omitempty"`
	Remaining          int         `json:"remaining,omitempty"`
	Spent              int         `json:"spent,omitempty"`
	TotalSigned        int         `json:"totalSigned,omitempty"`
	TotalSpent         string      `json:"totalSpent,omitempty"`
	ProbedAt           string      `json:"probedAt,omitempty"`
	ProbedPrice        string      `json:"probedPrice,omitempty"`
	WalletBalance      string      `json:"walletBalance,omitempty"`
	SignerAddress      string      `json:"signerAddress,omitempty"`
}

type RegistrationRequest

type RegistrationRequest struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              RegistrationRequestSpec   `json:"spec,omitempty"`
	Status            RegistrationRequestStatus `json:"status,omitempty"`
}

type RegistrationRequestSpec

type RegistrationRequestSpec struct {
	ServiceOfferName      string `json:"serviceOfferName,omitempty"`
	ServiceOfferNamespace string `json:"serviceOfferNamespace,omitempty"`
	DesiredState          string `json:"desiredState,omitempty"`
	Chain                 string `json:"chain,omitempty"`
}

type RegistrationRequestStatus

type RegistrationRequestStatus struct {
	Phase                       string `json:"phase,omitempty"`
	Message                     string `json:"message,omitempty"`
	PublishedURL                string `json:"publishedUrl,omitempty"`
	AgentID                     string `json:"agentId,omitempty"`
	RegistrationTxHash          string `json:"registrationTxHash,omitempty"`
	RegistrationOwner           string `json:"registrationOwner,omitempty"`
	RegistrationURI             string `json:"registrationUri,omitempty"`
	RegistrationSearchFromBlock int64  `json:"registrationSearchFromBlock,omitempty"`
	MetadataSynced              bool   `json:"metadataSynced,omitempty"`
}

type ServiceOffer

type ServiceOffer struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              ServiceOfferSpec   `json:"spec,omitempty"`
	Status            ServiceOfferStatus `json:"status,omitempty"`
}

func (*ServiceOffer) EffectiveHealthPath

func (o *ServiceOffer) EffectiveHealthPath() string

func (*ServiceOffer) EffectiveNamespace

func (o *ServiceOffer) EffectiveNamespace() string

func (*ServiceOffer) EffectivePath

func (o *ServiceOffer) EffectivePath() string

func (*ServiceOffer) EffectivePort

func (o *ServiceOffer) EffectivePort() int64

func (*ServiceOffer) IsAgent added in v0.10.0

func (o *ServiceOffer) IsAgent() bool

IsAgent reports whether the offer references an Agent CR for its upstream. Type=="agent" is the only signal — Ref must also be non-empty for a usable offer, but admission validation enforces that.

func (*ServiceOffer) IsInference

func (o *ServiceOffer) IsInference() bool

func (*ServiceOffer) IsPaused

func (o *ServiceOffer) IsPaused() bool

type ServiceOfferAgent added in v0.10.0

type ServiceOfferAgent struct {
	Ref ServiceOfferAgentRef `json:"ref,omitempty"`
}

ServiceOfferAgent is populated when Spec.Type == "agent". The controller resolves Ref → Agent CR, derives Upstream from Agent.status.endpoint, and surfaces the agent's model + skills in the 402 response's extra block so buyers see what they're paying for.

type ServiceOfferAgentRef added in v0.10.0

type ServiceOfferAgentRef struct {
	Name      string `json:"name,omitempty"`
	Namespace string `json:"namespace,omitempty"`
}

type ServiceOfferAgentResolution added in v0.10.0

type ServiceOfferAgentResolution struct {
	Model    string   `json:"model,omitempty"`
	Skills   []string `json:"skills,omitempty"`
	Runtime  string   `json:"runtime,omitempty"`
	Endpoint string   `json:"endpoint,omitempty"`
}

ServiceOfferAgentResolution is the controller's resolved view of an agent-type offer's referenced Agent. Populated only when Spec.Type == "agent" and the Agent CR is Ready. Read by the route source when building RouteRules so the 402 extra block surfaces what's actually running.

type ServiceOfferAsset added in v0.9.0

type ServiceOfferAsset struct {
	Address        string `json:"address,omitempty"`
	Symbol         string `json:"symbol,omitempty"`
	Decimals       int64  `json:"decimals,omitempty"`
	TransferMethod string `json:"transferMethod,omitempty"`
	EIP712Name     string `json:"eip712Name,omitempty"`
	EIP712Version  string `json:"eip712Version,omitempty"`
}

type ServiceOfferModel

type ServiceOfferModel struct {
	Name    string `json:"name,omitempty"`
	Runtime string `json:"runtime,omitempty"`
}

type ServiceOfferPayment

type ServiceOfferPayment struct {
	Scheme            string                 `json:"scheme,omitempty"`
	Network           string                 `json:"network,omitempty"`
	PayTo             string                 `json:"payTo,omitempty"`
	MaxTimeoutSeconds int64                  `json:"maxTimeoutSeconds,omitempty"`
	Asset             ServiceOfferAsset      `json:"asset,omitempty"`
	Price             ServiceOfferPriceTable `json:"price,omitempty"`
}

type ServiceOfferPriceTable

type ServiceOfferPriceTable struct {
	PerRequest string `json:"perRequest,omitempty"`
	PerMTok    string `json:"perMTok,omitempty"`
	PerHour    string `json:"perHour,omitempty"`
	PerEpoch   string `json:"perEpoch,omitempty"`
}

type ServiceOfferRegistration

type ServiceOfferRegistration struct {
	Enabled        bool                  `json:"enabled,omitempty"`
	Name           string                `json:"name,omitempty"`
	Description    string                `json:"description,omitempty"`
	Image          string                `json:"image,omitempty"`
	Services       []ServiceOfferService `json:"services,omitempty"`
	SupportedTrust []string              `json:"supportedTrust,omitempty"`
	Skills         []string              `json:"skills,omitempty"`
	Domains        []string              `json:"domains,omitempty"`
	Metadata       map[string]string     `json:"metadata,omitempty"`
}

type ServiceOfferService

type ServiceOfferService struct {
	Name     string `json:"name,omitempty"`
	Endpoint string `json:"endpoint,omitempty"`
	Version  string `json:"version,omitempty"`
}

type ServiceOfferSpec

type ServiceOfferSpec struct {
	Type         string                   `json:"type,omitempty"`
	Agent        ServiceOfferAgent        `json:"agent,omitempty"`
	Model        ServiceOfferModel        `json:"model,omitempty"`
	Upstream     ServiceOfferUpstream     `json:"upstream,omitempty"`
	Payment      ServiceOfferPayment      `json:"payment,omitempty"`
	Path         string                   `json:"path,omitempty"`
	Provenance   map[string]string        `json:"provenance,omitempty"`
	Registration ServiceOfferRegistration `json:"registration,omitempty"`
}

type ServiceOfferStatus

type ServiceOfferStatus struct {
	Conditions         []Condition                  `json:"conditions,omitempty"`
	Endpoint           string                       `json:"endpoint,omitempty"`
	AgentID            string                       `json:"agentId,omitempty"`
	RegistrationTxHash string                       `json:"registrationTxHash,omitempty"`
	ObservedGeneration int64                        `json:"observedGeneration,omitempty"`
	AgentResolution    *ServiceOfferAgentResolution `json:"agentResolution,omitempty"`
}

type ServiceOfferUpstream

type ServiceOfferUpstream struct {
	Service    string `json:"service,omitempty"`
	Namespace  string `json:"namespace,omitempty"`
	Port       int64  `json:"port,omitempty"`
	HealthPath string `json:"healthPath,omitempty"`
}

Jump to

Keyboard shortcuts

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