Documentation
¶
Index ¶
- Constants
- Variables
- func CapabilityHTTPStatus(code capv1.ErrorCode) int
- func ValidateActionRequest(action string, params map[string]any) error
- func ValidateCatalog(catalog *capv1.DescribeCapabilitiesResponse, requirements []CatalogRequirement) error
- type CapabilityError
- type CatalogRequirement
- type Client
- func (c *Client) CancelOperation(ctx context.Context, operationID string, permission *capv1.PermissionContext, ...) (*capv1.CancelOperationResponse, error)
- func (c *Client) Close() error
- func (c *Client) DescribeCapabilities(ctx context.Context, callContexts ...*capv1.CallContext) (*capv1.DescribeCapabilitiesResponse, error)
- func (c *Client) GetOperation(ctx context.Context, operationID string, permission *capv1.PermissionContext, ...) (*capv1.GetOperationResponse, error)
- func (c *Client) Query(ctx context.Context, operationID, capabilityID, operation string, ...) (*capv1.QueryResponse, error)
- func (c *Client) SetAccountGeneration(generation int64)
- func (c *Client) StartOperation(ctx context.Context, operationID, capabilityID, operation string, ...) (*capv1.StartOperationResponse, error)
- func (c *Client) WatchOperation(ctx context.Context, operationID string, afterSequence int64, ...) (capv1.AgentCapabilityService_WatchOperationClient, error)
- type Config
- type InvalidActionRequestError
- type Runner
- func (r *Runner) Apply(ctx context.Context, action string) error
- func (r *Runner) Invoke(ctx context.Context, action string, params map[string]any) (map[string]any, error)
- func (r *Runner) ProbeCatalog(ctx context.Context, requirements []CatalogRequirement) error
- func (r *Runner) Stream(ctx context.Context, action string, params map[string]any, ...) error
- type RunnerConfig
Constants ¶
const ( KnowledgeQuotaExceededCode = "knowledge_quota_exceeded" ExtensionInstallBusyCode = "extension_install_busy" ExtensionInstallationLimitCode = "extension_installation_limit" ExtensionNodeStorageQuotaCode = "extension_node_storage_quota" )
const AgentCapabilityMinConnectTimeout = 3 * time.Second
AgentCapabilityMinConnectTimeout is the minimum initial transport connection window that readiness probes must cover.
Variables ¶
var ErrCatalogInvalid = errors.New("native agent capability catalog is invalid")
ErrCatalogInvalid marks a peer that is reachable but cannot safely serve the configured ProductCore Native Agent surface. Callers should keep readiness failed until a fresh catalog probe succeeds.
var ErrInvalidActionRequest = errors.New("native agent action request is invalid")
ErrInvalidActionRequest marks ProductCore parameters that cannot be sent to the external Agent capability. It is intentionally separate from a capability INVALID_ARGUMENT response: these failures are rejected before a catalog lookup, grant, or operation is created.
var ErrInvalidActionResult = errors.New("native agent action result is invalid")
ErrInvalidActionResult marks a successful Agent operation whose payload violates the public ProductCore response contract. Callers must surface the failure instead of converting a malformed payload into a successful empty projection.
var ErrUnsupportedAction = errors.New("native agent action is unsupported")
ErrUnsupportedAction is returned before any capability RPC is attempted when a legacy ProductCore action has no explicit Core v1 mapping. Keeping a sentinel lets the HTTP/WS facade expose a stable not-implemented response instead of misclassifying a contract gap as a transient gateway failure.
var ErrWatchIdleTimeout = errors.New("agent operation watch was idle; execution continues and can be reattached")
ErrWatchIdleTimeout ends only the current observation attachment after a prolonged period without persisted events. The durable Agent operation is not cancelled and can be observed again from its last sequence cursor.
Functions ¶
func CapabilityHTTPStatus ¶
CapabilityHTTPStatus translates the structured Agent error taxonomy to the stable ProductCore HTTP semantics. Unknown codes fail closed as 502.
func ValidateActionRequest ¶
ValidateActionRequest enforces the request-side parts of the frozen Native Agent ProductCore contract. It is safe to call from both the HTTP/WS module and the capability gateway; the validation is side-effect free.
func ValidateCatalog ¶
func ValidateCatalog(catalog *capv1.DescribeCapabilitiesResponse, requirements []CatalogRequirement) error
ValidateCatalog checks the immutable protocol/digest envelope and every required action binding. Optional capabilities are deliberately omitted from requirements so a disabled deployment does not poison overall readiness.
Types ¶
type CapabilityError ¶
CapabilityError is the safe, structured error returned when Agent rejects a capability operation. The upstream message is deliberately discarded; Agent providers may include credential-bearing details in that field.
func (*CapabilityError) Error ¶
func (e *CapabilityError) Error() string
type CatalogRequirement ¶
type CatalogRequirement struct {
Action string
// InputSchemaDigest, ResultSchemaDigest, and EventSchemaDigest pin the exact Agent descriptor
// schema identities expected for this action. Empty values retain the
// generic self-consistency proof for optional/extension actions; required
// baseline actions with a known Agent contract are populated by
// NewCatalogRequirement.
InputSchemaDigest []byte
ResultSchemaDigest []byte
EventSchemaDigest []byte
// RequireSchemaPin makes an empty expected digest a configuration error.
// Readiness baseline actions set this flag so a missing generated pin fails
// closed instead of silently degrading to self-consistency only. Optional
// extension actions may leave it false.
RequireSchemaPin bool
// RequireEventSchemaPin applies the same fail-closed rule to a durable
// stream's progress-event contract.
RequireEventSchemaPin bool
}
CatalogRequirement is a public action that must be represented by one advertised, ready Agent capability operation before message-server can report external Native Agent readiness.
func NewCatalogRequirement ¶
func NewCatalogRequirement(action string) CatalogRequirement
NewCatalogRequirement binds a public action to the current Agent schema identities when one is part of the readiness proof. Unknown/optional actions still receive the normal self-consistency check in ValidateCatalog.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client 是 AgentCapabilityService 的客户端(message-server 端)
func (*Client) CancelOperation ¶
func (c *Client) CancelOperation(ctx context.Context, operationID string, permission *capv1.PermissionContext, callContexts ...*capv1.CallContext) (*capv1.CancelOperationResponse, error)
CancelOperation cancels a durable Agent operation using the same caller supplied call context as Start/Watch/Get. It is intentionally not derived from a fresh operation id so the Agent can validate one chain and grant binding across the complete lifecycle.
func (*Client) DescribeCapabilities ¶
func (c *Client) DescribeCapabilities(ctx context.Context, callContexts ...*capv1.CallContext) (*capv1.DescribeCapabilitiesResponse, error)
DescribeCapabilities fetches the Agent catalog over the authenticated connection. Callers use the returned operation descriptor to compute the canonical request digest; no action name is tunneled through the wire.
func (*Client) GetOperation ¶
func (c *Client) GetOperation(ctx context.Context, operationID string, permission *capv1.PermissionContext, callContexts ...*capv1.CallContext) (*capv1.GetOperationResponse, error)
GetOperation returns a persisted operation status from the Agent.
func (*Client) Query ¶
func (c *Client) Query(ctx context.Context, operationID, capabilityID, operation string, requestJSON []byte, permission *capv1.PermissionContext, callContexts ...*capv1.CallContext) (*capv1.QueryResponse, error)
Query executes a read-only Agent capability. Mutations and durable streams must use StartOperation so their idempotency ledger is preserved.
func (*Client) SetAccountGeneration ¶
SetAccountGeneration updates the outbound fence without rebuilding the gRPC connection. It is called by the Service when a portal generation changes after account deletion/recreation.
func (*Client) StartOperation ¶
func (c *Client) StartOperation( ctx context.Context, operationID, capabilityID, operation string, requestJSON []byte, requestDigest []byte, expectedRevision int64, permission *capv1.PermissionContext, callContexts ...*capv1.CallContext, ) (*capv1.StartOperationResponse, error)
StartOperation 启动一个 Agent operation
func (*Client) WatchOperation ¶
func (c *Client) WatchOperation(ctx context.Context, operationID string, afterSequence int64, permission *capv1.PermissionContext, callContexts ...*capv1.CallContext) (capv1.AgentCapabilityService_WatchOperationClient, error)
WatchOperation watches a persisted Agent operation. The caller owns the returned stream and must drain or cancel it before releasing its request.
type Config ¶
type Config struct {
// ServerAddr 是 Agent 的 AgentCapabilityService 地址
ServerAddr string
// TLS 配置
CACertFile string
ClientCertFile string
ClientKeyFile string
// TokenFile 是 MS→Agent 方向的 token 文件路径
TokenFile string
// InstanceID 是 message-server 实例 ID
InstanceID string
// ServerName is the TLS SNI/verification name of the Agent endpoint. It is
// explicit so production deployments do not depend on a hard-coded
// certificate name; the default is kept for local compatibility.
ServerName string
// AccountGeneration is the current owner account generation. It is sent
// with every call so the peer can fence a deleted/recreated account.
AccountGeneration int64
// 连接池配置
MaxConcurrentQuery int // 默认 32
MaxConcurrentWatch int // 默认 64
// WatchIdleTimeout bounds a silent observation attachment, not the durable
// operation. Every persisted event resets it. A detached client can resume
// from after_sequence without replaying the operation.
WatchIdleTimeout time.Duration
}
Config 是 AgentCapability 客户端配置
type InvalidActionRequestError ¶
InvalidActionRequestError carries only a field name and a stable reason. It never includes the value of a write-only field (for example api_key).
func (*InvalidActionRequestError) Error ¶
func (e *InvalidActionRequestError) Error() string
func (*InvalidActionRequestError) Unwrap ¶
func (e *InvalidActionRequestError) Unwrap() error
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
Runner adapts the capability operation protocol to the legacy Native Agent runner contract used by ProductCore and the realtime websocket facade. Native Agent execution happens in dirextalk-agent; message-server only admits, watches and translates the operation stream.
func NewRunner ¶
func NewRunner(client *Client, config RunnerConfig) *Runner
func (*Runner) ProbeCatalog ¶
func (r *Runner) ProbeCatalog(ctx context.Context, requirements []CatalogRequirement) error
ProbeCatalog performs one bounded, authenticated catalog probe. The operation map remains owned by Runner, so callers cannot accidentally send an action name over the wire or validate a different capability/operation pair than Invoke would use.
type RunnerConfig ¶
type RunnerConfig struct {
OwnerID func() string
AccountGeneration func() int64
GrantCodec capv1.GrantCodec
GrantPrivateKey []byte
GrantScopes func(action string) []string
}
RunnerConfig contains only server-derived identity data. No caller/model parameter is allowed to override OwnerID or AccountGeneration.