Documentation
¶
Overview ¶
Package oasfgenerator provides an OASF (Open Agent Specification Framework) record generator processor component for SemStreams.
Overview ¶
The OASF generator watches for agent entity changes in the ENTITY_STATES KV bucket and generates OASF records that can be used for AGNTCY directory registration. OASF is the standard format for describing agent capabilities in the AGNTCY (Internet of Agents) ecosystem.
NATS Topology ¶
The component uses the following NATS resources:
Input: - ENTITY_STATES KV Watch: Monitors for agent entity changes - oasf.generate.request: On-demand generation requests (optional) Output: - OASF_RECORDS KV Write: Stores generated OASF records - oasf.record.generated.*: Publishes generation events
Predicate Mapping ¶
The generator maps SemStreams predicates to OASF fields:
SemStreams Predicate -> OASF Field agent.capability.name -> skills[].name agent.capability.description -> skills[].description agent.capability.expression -> skills[].id agent.capability.confidence -> skills[].confidence agent.capability.permission -> skills[].permissions[] agent.intent.goal -> description agent.intent.type -> domains[].name agent.action.type -> extensions.action_types[]
Configuration ¶
Example configuration:
{
"entity_kv_bucket": "ENTITY_STATES",
"oasf_kv_bucket": "OASF_RECORDS",
"watch_pattern": "*.agent.*",
"generation_debounce": "1s",
"default_agent_version": "1.0.0",
"include_extensions": true
}
Usage ¶
The component is typically used as part of a flow configuration:
components:
- name: oasf-gen
type: oasf-generator
config:
entity_kv_bucket: ENTITY_STATES
oasf_kv_bucket: OASF_RECORDS
The generated OASF records can then be used by the directory-bridge component to register agents with AGNTCY directories.
OASF Record Structure ¶
Generated records follow the OASF schema:
{
"name": "agent-architect",
"version": "1.0.0",
"schema_version": "1.0.0",
"authors": ["system"],
"created_at": "2024-01-15T10:30:00Z",
"description": "Designs software architecture",
"skills": [
{
"id": "software-design",
"name": "Software Design",
"description": "Creates software architecture diagrams",
"confidence": 0.95,
"permissions": ["file_system_read"]
}
],
"domains": [
{
"name": "software-architecture"
}
],
"extensions": {
"semstreams_entity_id": "acme.ops.agentic.system.agent.architect",
"source": "semstreams"
}
}
See Also ¶
- ADR-019: AGNTCY Integration - docs/concepts/20-oasf-integration.md - https://docs.agntcy.org/pages/syntaxes/oasf
Package oasfgenerator provides an OASF (Open Agent Specification Framework) record generator that serializes SemStreams agent capabilities to the AGNTCY standard format.
Index ¶
- Constants
- Variables
- func NewComponent(rawConfig json.RawMessage, deps component.Dependencies) (component.Discoverable, error)
- func Register(registry RegistryInterface) error
- func SupportedPredicates() []string
- type Component
- func (c *Component) ConfigSchema() component.ConfigSchema
- func (c *Component) DataFlow() component.FlowMetrics
- func (c *Component) GenerateForEntity(ctx context.Context, entityID string) error
- func (c *Component) Health() component.HealthStatus
- func (c *Component) Initialize() error
- func (c *Component) InputPorts() []component.Port
- func (c *Component) Meta() component.Metadata
- func (c *Component) OutputPorts() []component.Port
- func (c *Component) Start(ctx context.Context) error
- func (c *Component) Stop(_ time.Duration) error
- type Config
- type EntityState
- type Generator
- type Mapper
- type Metrics
- type OASFDomain
- type OASFGeneratedEvent
- type OASFRecord
- type OASFSkill
- type RegistryInterface
Constants ¶
const CurrentSchemaVersion = "1.0.0"
CurrentSchemaVersion is the OASF schema version this implementation supports.
Variables ¶
var PredicateMapping = map[string]string{ agentic.CapabilityName: "skills[].name", agentic.CapabilityDescription: "skills[].description", agentic.CapabilityExpression: "skills[].id", agentic.CapabilityConfidence: "skills[].confidence", agentic.CapabilityPermission: "skills[].permissions[]", agentic.IntentGoal: "description", agentic.IntentType: "domains[].name", agentic.ActionType: "extensions.action_types[]", }
PredicateMapping defines how SemStreams predicates map to OASF fields. This table is for documentation and validation purposes.
Functions ¶
func NewComponent ¶
func NewComponent(rawConfig json.RawMessage, deps component.Dependencies) (component.Discoverable, error)
NewComponent creates a new OASF generator component.
func Register ¶
func Register(registry RegistryInterface) error
Register registers the OASF generator processor component with the given registry.
func SupportedPredicates ¶
func SupportedPredicates() []string
SupportedPredicates returns the list of predicates this mapper handles.
Types ¶
type Component ¶
type Component struct {
// contains filtered or unexported fields
}
Component implements the OASF generator processor.
func (*Component) ConfigSchema ¶
func (c *Component) ConfigSchema() component.ConfigSchema
ConfigSchema returns the configuration schema.
func (*Component) DataFlow ¶
func (c *Component) DataFlow() component.FlowMetrics
DataFlow returns current data flow metrics.
func (*Component) GenerateForEntity ¶
GenerateForEntity manually triggers OASF generation for an entity. This is useful for testing and on-demand generation.
func (*Component) Health ¶
func (c *Component) Health() component.HealthStatus
Health returns the current health status.
func (*Component) Initialize ¶
Initialize prepares the component.
func (*Component) InputPorts ¶
InputPorts returns configured input port definitions.
func (*Component) OutputPorts ¶
OutputPorts returns configured output port definitions.
type Config ¶
type Config struct {
// Ports defines the input/output port configuration.
Ports *component.PortConfig `json:"ports" schema:"type:ports,description:Port configuration,category:basic"`
// StreamName is the JetStream stream to subscribe to for entity changes.
StreamName string `json:"stream_name" schema:"type:string,description:JetStream stream name for entity events,category:basic,default:ENTITY"`
// EntityKVBucket is the KV bucket to watch for entity state changes.
EntityKVBucket string `json:"entity_kv_bucket" schema:"type:string,description:KV bucket for entity states,category:basic,default:ENTITY_STATES"`
// OASFKVBucket is the KV bucket to store generated OASF records.
OASFKVBucket string `json:"oasf_kv_bucket" schema:"type:string,description:KV bucket for OASF records,category:basic,default:OASF_RECORDS"`
// WatchPattern is the key pattern to watch in the entity KV bucket.
// Use ">" for all keys (including those with dots) or a specific pattern.
// Note: "*" only matches single tokens without dots, ">" matches any depth.
WatchPattern string `json:"watch_pattern" schema:"type:string,description:Key pattern to watch for entity changes,category:advanced,default:>"`
// GenerationDebounce is the debounce duration for OASF generation after entity changes.
GenerationDebounce string `json:"generation_debounce" schema:"type:string,description:Debounce duration for generation,category:advanced,default:1s"`
// ConsumerNameSuffix adds a suffix to consumer names for uniqueness in tests.
ConsumerNameSuffix string `json:"consumer_name_suffix" schema:"type:string,description:Suffix for consumer names,category:advanced"`
// DeleteConsumerOnStop enables consumer cleanup on stop (for testing).
DeleteConsumerOnStop bool `` /* 128-byte string literal not displayed */
// DefaultAgentVersion is used when an agent doesn't specify its version.
DefaultAgentVersion string `` /* 132-byte string literal not displayed */
// DefaultAuthors is used when authors aren't specified in entity metadata.
DefaultAuthors []string `json:"default_authors" schema:"type:array,description:Default authors for OASF records,category:advanced"`
// IncludeExtensions enables SemStreams-specific extensions in OASF output.
IncludeExtensions bool `json:"include_extensions" schema:"type:bool,description:Include SemStreams extensions,category:advanced,default:true"`
}
Config defines the configuration for the OASF generator component.
func (*Config) GetGenerationDebounce ¶
GetGenerationDebounce returns the debounce duration.
type EntityState ¶
type EntityState struct {
ID string `json:"id"`
Triples []message.Triple `json:"triples"`
UpdatedAt time.Time `json:"updated_at"`
}
EntityState represents the stored state of an entity in KV.
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
Generator handles the core OASF record generation logic. It maintains state for pending generations and handles debouncing.
func NewGenerator ¶
func NewGenerator(mapper *Mapper, natsClient *natsclient.Client, config Config, logger *slog.Logger) *Generator
NewGenerator creates a new OASF generator.
func (*Generator) GenerateForEntity ¶
GenerateForEntity generates an OASF record for a specific entity.
func (*Generator) Initialize ¶
Initialize sets up KV stores and coalescer for the generator.
func (*Generator) QueueGeneration ¶
QueueGeneration queues an entity for OASF generation. The actual generation happens after the coalescing window expires.
type Mapper ¶
type Mapper struct {
// contains filtered or unexported fields
}
Mapper converts SemStreams triples to OASF records. It maps agent.capability.*, agent.intent.*, and agent.action.* predicates to the OASF skills and domains format.
func (*Mapper) MapTriplesToOASF ¶
MapTriplesToOASF converts a set of triples for an agent entity into an OASF record. The triples should all be about the same agent entity (same subject).
type Metrics ¶
type Metrics struct {
// contains filtered or unexported fields
}
Metrics holds the Prometheus metrics for the OASF generator.
func (*Metrics) EntityChanged ¶
func (m *Metrics) EntityChanged()
EntityChanged records an entity change event.
func (*Metrics) KVWatchError ¶
func (m *Metrics) KVWatchError()
KVWatchError records a KV watch error.
func (*Metrics) RecordFailed ¶
func (m *Metrics) RecordFailed()
RecordFailed records a failed OASF record generation.
func (*Metrics) RecordGenerated ¶
RecordGenerated records a successful OASF record generation.
type OASFDomain ¶
type OASFDomain struct {
// Name is the domain identifier.
Name string `json:"name"`
// Description provides details about the domain.
Description string `json:"description,omitempty"`
// Priority indicates the agent's focus on this domain (higher = more focused).
Priority int `json:"priority,omitempty"`
}
OASFDomain represents a domain the agent operates in.
func (*OASFDomain) Validate ¶
func (d *OASFDomain) Validate() error
Validate checks if the OASF domain is valid.
type OASFGeneratedEvent ¶
type OASFGeneratedEvent struct {
EntityID string `json:"entity_id"`
Record *OASFRecord `json:"record"`
Timestamp time.Time `json:"timestamp"`
}
OASFGeneratedEvent is published when an OASF record is generated.
type OASFRecord ¶
type OASFRecord struct {
// Name is the human-readable name of the agent.
Name string `json:"name"`
// Version is the semantic version of the agent (e.g., "1.0.0").
Version string `json:"version"`
// SchemaVersion is the OASF schema version this record conforms to.
// Currently "1.0.0" is the supported version.
SchemaVersion string `json:"schema_version"`
// Authors lists the creators/maintainers of the agent.
Authors []string `json:"authors"`
// CreatedAt is when this OASF record was generated (RFC-3339 format).
CreatedAt string `json:"created_at"`
// Description provides a human-readable description of the agent's purpose.
Description string `json:"description"`
// Skills lists the capabilities the agent possesses.
Skills []OASFSkill `json:"skills"`
// Domains lists the domains this agent operates in.
Domains []OASFDomain `json:"domains,omitempty"`
// Extensions holds provider-specific metadata.
Extensions map[string]any `json:"extensions,omitempty"`
}
OASFRecord represents an OASF (Open Agent Specification Framework) record. This is the standard format for describing agent capabilities in the AGNTCY ecosystem. See: https://docs.agntcy.org/pages/syntaxes/oasf
func NewOASFRecord ¶
func NewOASFRecord(name, version, description string) *OASFRecord
NewOASFRecord creates a new OASF record with required fields.
func (*OASFRecord) AddAuthor ¶
func (r *OASFRecord) AddAuthor(author string)
AddAuthor adds an author to the OASF record.
func (*OASFRecord) AddDomain ¶
func (r *OASFRecord) AddDomain(domain OASFDomain)
AddDomain adds a domain to the OASF record.
func (*OASFRecord) AddSkill ¶
func (r *OASFRecord) AddSkill(skill OASFSkill)
AddSkill adds a skill to the OASF record.
func (*OASFRecord) MarshalJSON ¶
func (r *OASFRecord) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler.
func (*OASFRecord) SetExtension ¶
func (r *OASFRecord) SetExtension(key string, value any)
SetExtension sets an extension value.
func (*OASFRecord) Validate ¶
func (r *OASFRecord) Validate() error
Validate checks if the OASF record is valid.
type OASFSkill ¶
type OASFSkill struct {
// ID is a unique identifier for this skill.
ID string `json:"id"`
// Name is the human-readable name of the skill.
Name string `json:"name"`
// Description provides details about what this skill does.
Description string `json:"description,omitempty"`
// Confidence is the agent's self-assessed confidence in this skill (0.0-1.0).
Confidence float64 `json:"confidence,omitempty"`
// Permissions lists the permissions required to execute this skill.
Permissions []string `json:"permissions,omitempty"`
// Tags provide categorical labels for skill discovery.
Tags []string `json:"tags,omitempty"`
// InputSchema describes the expected input format (JSON Schema).
InputSchema map[string]any `json:"input_schema,omitempty"`
// OutputSchema describes the expected output format (JSON Schema).
OutputSchema map[string]any `json:"output_schema,omitempty"`
}
OASFSkill represents a single capability/skill in an OASF record.
type RegistryInterface ¶
type RegistryInterface interface {
RegisterWithConfig(component.RegistrationConfig) error
}
RegistryInterface defines the minimal interface needed for registration.