productcapability

package
v1.1.35 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2026 License: AGPL-3.0 Imports: 31 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrOperationNotFound = sql.ErrNoRows

Functions

func RegisterBuiltinCapabilities

func RegisterBuiltinCapabilities(registry *Registry, _ interface{}) error

RegisterBuiltinCapabilities is intentionally retired. Product capabilities are now built only by NewRegistryWithInvokerChecked, which binds every descriptor to ProductCore/Matrix and validates canonical schemas and scope metadata before publication. Keeping a compatibility symbol lets old integrations fail explicitly instead of silently publishing the historical test echo or incomplete direct-SQL descriptors.

Types

type Channel

type Channel struct {
	ChannelID   string    `json:"channel_id"`
	Name        string    `json:"name"`
	Description string    `json:"description"`
	Type        string    `json:"type"`
	CreatedAt   time.Time `json:"created_at"`
}

type ChannelsCapability

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

func NewChannelsCapability

func NewChannelsCapability(db *sql.DB) *ChannelsCapability

func (*ChannelsCapability) DescriptorID

func (c *ChannelsCapability) DescriptorID() string

func (*ChannelsCapability) HandleRead

func (c *ChannelsCapability) HandleRead(ctx context.Context, operation string, input []byte) ([]byte, error)

type Config

type Config struct {
	// ListenAddr 是监听地址
	ListenAddr string

	// TLS 配置
	CACertFile     string
	ServerCertFile string
	ServerKeyFile  string

	// TokenFile 是 Agent→MS 方向的 token 文件路径
	TokenFile string

	// InstanceID 是 message-server 实例 ID
	InstanceID string

	// PeerInstanceID is the Agent instance permitted on this connection. Empty
	// means the peer must still provide an instance id, but no fixed id is
	// configured (useful for single-instance development).
	PeerInstanceID string
	// PeerCommonName binds the Agent mTLS client certificate to this service.
	// The local development certificate convention remains the default.
	PeerCommonName string

	// ExpectedAccountGeneration fences a deleted/recreated owner account. A
	// non-positive value disables the fixed generation check.
	ExpectedAccountGeneration int64
	// ServiceOwnerID and RecordAgentExecutionCompletion form the private,
	// service-originated terminal callback boundary. The owner and generation
	// are local deployment facts and are never accepted from request JSON.
	ServiceOwnerID                 string
	RecordAgentExecutionCompletion func(context.Context, dirextalkdomain.AgentExecutionCompletionReceipt) (replayed bool, err error)

	// GrantPublicKey verifies the opaque Ed25519 grant-v1 supplied by Agent
	// calls. Product is the message-server-owned capability boundary, so it
	// also signs short-lived operation-control grants with GrantPrivateKey;
	// the Agent process is never given this private key.
	GrantPublicKey  []byte
	GrantPrivateKey []byte
	GrantCodec      capv1.GrantCodec

	// DB is the shared PostgreSQL handle used for durable Product operations.
	DB *sql.DB
	// PreparedMatrixStore stages exact signed Matrix PDUs before SendEvents.
	// Production wiring supplies the shared PostgreSQL implementation; a nil
	// value with a nil DB is retained for in-memory protocol tests only.
	PreparedMatrixStore dirextalktransport.PreparedMatrixMutationStore

	// 连接池配置
	MaxConcurrentRead     int // 默认 64
	MaxConcurrentMutation int // 默认 16
}

Config 是 ProductCapabilityService 的配置

type Contact

type Contact struct {
	ID        string
	OwnerID   string
	Name      string
	Email     string
	Phone     string
	Avatar    string
	Metadata  map[string]interface{}
	CreatedAt time.Time
	UpdatedAt time.Time
}

type ContactsCapability

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

ContactsCapability implements product.contacts.v1

func NewContactsCapability

func NewContactsCapability(db *sql.DB) *ContactsCapability

func (*ContactsCapability) DescriptorID

func (c *ContactsCapability) DescriptorID() string

func (*ContactsCapability) HandleMutation

func (c *ContactsCapability) HandleMutation(ctx context.Context, operation string, input []byte) ([]byte, error)

func (*ContactsCapability) HandleRead

func (c *ContactsCapability) HandleRead(ctx context.Context, operation string, input []byte) ([]byte, error)

type Member

type Member struct {
	UserID     string    `json:"user_id"`
	RoomID     string    `json:"room_id"`
	Membership string    `json:"membership"`
	EventID    string    `json:"event_id"`
	JoinedAt   time.Time `json:"joined_at,omitempty"`
}

type MembersCapability

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

func NewMembersCapability

func NewMembersCapability(db *sql.DB) *MembersCapability

func (*MembersCapability) DescriptorID

func (c *MembersCapability) DescriptorID() string

func (*MembersCapability) HandleMutation

func (c *MembersCapability) HandleMutation(ctx context.Context, operation string, input []byte) ([]byte, error)

func (*MembersCapability) HandleRead

func (c *MembersCapability) HandleRead(ctx context.Context, operation string, input []byte) ([]byte, error)

type Message

type Message struct {
	EventID   string    `json:"event_id"`
	RoomID    string    `json:"room_id"`
	Sender    string    `json:"sender"`
	Type      string    `json:"type"`
	Content   string    `json:"content"`
	Timestamp time.Time `json:"timestamp"`
}

type MessagesCapability

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

MessagesCapability implements product.messages.v1

func NewMessagesCapability

func NewMessagesCapability(db *sql.DB) *MessagesCapability

func (*MessagesCapability) DescriptorID

func (c *MessagesCapability) DescriptorID() string

func (*MessagesCapability) HandleMutation

func (c *MessagesCapability) HandleMutation(ctx context.Context, operation string, input []byte) ([]byte, error)

func (*MessagesCapability) HandleRead

func (c *MessagesCapability) HandleRead(ctx context.Context, operation string, input []byte) ([]byte, error)

type Post

type Post struct {
	PostID    string                 `json:"post_id"`
	ChannelID string                 `json:"channel_id"`
	UserID    string                 `json:"user_id"`
	Content   map[string]interface{} `json:"content"`
	CreatedAt time.Time              `json:"created_at"`
	UpdatedAt time.Time              `json:"updated_at"`
}

type ProductInvoker

type ProductInvoker func(context.Context, string, map[string]any) (any, error)

ProductInvoker is the domain-owned ProductCore/Matrix boundary. The capability layer never reaches product tables directly; the p2p service supplies this callback from its existing MCP/domain modules.

type Provider

type Provider struct {
	Descriptor *capv1.CapabilityDescriptor
	Handler    ProviderFunc
}

Provider 定义了一个 capability 提供者

type ProviderFunc

type ProviderFunc func(ctx context.Context, input []byte) ([]byte, error)

ProviderFunc 是 capability 提供者函数类型

type Registry

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

Registry 管理所有注册的 Product capabilities

func NewRegistry

func NewRegistry() *Registry

NewRegistry 创建新的 registry

func NewRegistryWithInvoker

func NewRegistryWithInvoker(invoker ProductInvoker) *Registry

NewRegistryWithInvoker builds the production capability catalog on top of the existing ProductCore and Matrix implementation. It preserves the historical no-error constructor for tests and callers that do not need startup diagnostics; production startup should use the Checked variant.

func NewRegistryWithInvokerAndOptionsChecked

func NewRegistryWithInvokerAndOptionsChecked(invoker ProductInvoker, options RegistryOptions) (*Registry, error)

func NewRegistryWithInvokerChecked

func NewRegistryWithInvokerChecked(invoker ProductInvoker) (*Registry, error)

NewRegistryWithInvokerChecked is the production constructor. It validates every descriptor (including canonical JSON schemas and unique operation IDs) before returning a registry, so a catalog registration error prevents the Product Capability server from starting with a partial surface.

func (*Registry) Get

func (r *Registry) Get(capabilityID string) (*Provider, bool)

Get 获取一个 capability

func (*Registry) List

func (r *Registry) List() []*capv1.CapabilityDescriptor

List 列出所有 capabilities

func (*Registry) Operation

func (r *Registry) Operation(capabilityID, operationID string) (*capv1.OperationDescriptor, bool)

func (*Registry) Register

func (r *Registry) Register(provider *Provider) error

Register 注册一个 capability

type RegistryOptions

type RegistryOptions struct {
	MatrixMutationReady bool
}

RegistryOptions controls optional write descriptors whose implementation depends on a durable Matrix prepared-event port. Read-only capabilities are always registered; unsafe write fallbacks are omitted when false.

type Room

type Room struct {
	RoomID      string    `json:"room_id"`
	RoomVersion string    `json:"room_version"`
	Name        string    `json:"name,omitempty"`
	Topic       string    `json:"topic,omitempty"`
	JoinedAt    time.Time `json:"joined_at,omitempty"`
}

type RoomsCapability

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

RoomsCapability implements product.rooms.v1

func NewRoomsCapability

func NewRoomsCapability(db *sql.DB) *RoomsCapability

func (*RoomsCapability) DescriptorID

func (c *RoomsCapability) DescriptorID() string

func (*RoomsCapability) HandleRead

func (c *RoomsCapability) HandleRead(ctx context.Context, operation string, input []byte) ([]byte, error)

type Server

type Server struct {
	capv1.UnimplementedProductCapabilityServiceServer
	// contains filtered or unexported fields
}

Server 实现 ProductCapabilityService

func New

func New(config *Config, registry *Registry) (*Server, error)

New 创建新的 ProductCapabilityService 服务器

func (*Server) CancelOperation

func (*Server) ExchangeProductDelegation

ExchangeProductDelegation is the private Agent→message-server broker. The parent grant is the Agent-bound grant issued by message-server; this method never forwards it to Product handlers. It verifies that parent grant at the actual Product route, checks that the requested Product operation is within the parent's scopes, and signs a fresh child grant bound to the exact Product descriptor, schema, request digest and outer root operation.

func (*Server) GetOperation

func (*Server) IsReady

func (s *Server) IsReady() bool

IsReady 返回 readiness 状态

func (*Server) Query

func (s *Server) Query(ctx context.Context, req *capv1.QueryRequest) (*capv1.QueryResponse, error)

func (*Server) SetReady

func (s *Server) SetReady(ready bool)

SetReady 设置 readiness 状态

func (*Server) Start

func (s *Server) Start() error

Start 启动服务器

func (*Server) StartOperation

func (*Server) Stop

func (s *Server) Stop(ctx context.Context) error

Stop 停止服务器

Jump to

Keyboard shortcuts

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