Documentation
¶
Overview ¶
Package adk adapts Google ADK agents to actorlayer behaviors.
This package is an optional adapter. It is the only public actor adapter package in Norma that imports Google ADK for actor execution. Actorlayer core packages remain independent of ADK and expose provider-neutral refs, envelopes, behaviors, delivery hooks, and runtime events.
Products decide whether and how to use this adapter. Product-owned code keeps provider configuration, session policy, tools, command delivery, retry/DLQ policy, telemetry, and persistence side effects outside actorlayer core.
Index ¶
- func Props(cfg Config) actorlayer.Props
- func Toolset(sys *actorlayer.System, opts ...ToolsetOption) (tool.Toolset, error)
- type ActionMessage
- type AddressPolicy
- type AgentBehavior
- type Codec
- type Config
- type HeaderUserPolicy
- type Message
- type ReplyMode
- type SessionPolicy
- type StaticUserPolicy
- type ToolsetConfig
- type ToolsetOption
- func WithAddressPolicy(policy AddressPolicy) ToolsetOption
- func WithDefaultAskTimeout(timeout time.Duration) ToolsetOption
- func WithDirectActorIDTargets(enabled bool) ToolsetOption
- func WithMaxAskTimeout(timeout time.Duration) ToolsetOption
- func WithMaxPayloadBytes(maxBytes int) ToolsetOption
- func WithNamedRef(name string, ref actorlayer.Ref) ToolsetOption
- func WithNamedRefs(refs map[string]actorlayer.Ref) ToolsetOption
- func WithPublishEnabled(enabled bool) ToolsetOption
- type TransferPolicy
- type UserPolicy
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Props ¶
func Props(cfg Config) actorlayer.Props
Props builds actorlayer props that host an ADK runner-backed behavior.
func Toolset ¶
func Toolset(sys *actorlayer.System, opts ...ToolsetOption) (tool.Toolset, error)
Toolset builds ADK function tools for actor_send, actor_ask, and optionally actor_publish.
Types ¶
type ActionMessage ¶
type ActionMessage struct {
Type string
Agent string
Source actorlayer.ActorID
Event *session.Event
}
ActionMessage represents an ADK transfer or escalation action.
type AddressPolicy ¶
type AddressPolicy interface {
Allowed(ctx agent.ReadonlyContext, target actorlayer.ActorID, operation string) bool
}
AddressPolicy decides whether an operation can target an actor ID.
type AgentBehavior ¶
type AgentBehavior struct {
// contains filtered or unexported fields
}
AgentBehavior hosts an ADK runner invocation behind actor behavior semantics.
func (*AgentBehavior) Receive ¶
func (b *AgentBehavior) Receive(ctx actorlayer.Context, env actorlayer.Envelope) error
Receive runs the configured ADK runner and maps events to actor replies/actions.
type Codec ¶
type Codec interface {
ToContent(env actorlayer.Envelope) (*genai.Content, error)
FromEvent(event *session.Event) (any, error)
FinalResponse(events []*session.Event) (any, bool, error)
}
Codec maps actor envelopes to ADK content and ADK events back to payloads.
func ContentCodec ¶
func ContentCodec() Codec
ContentCodec returns a codec that requires genai.Content payloads.
type Config ¶
type Config struct {
AppName string
Agent adkagent.Agent
SessionService session.Service
ArtifactService artifact.Service
MemoryService memory.Service
RunConfig adkagent.RunConfig
SessionPolicy SessionPolicy
UserPolicy UserPolicy
Codec Codec
ReplyMode ReplyMode
TransferPolicy TransferPolicy
TransferTargets map[string]actorlayer.Ref
EscalationTarget *actorlayer.Ref
TransferAskTimeout time.Duration
AutoCreateSession bool
}
Config defines how an ADK agent is hosted as an actor behavior.
type HeaderUserPolicy ¶
HeaderUserPolicy extracts user ID from envelope headers.
func (HeaderUserPolicy) UserID ¶
func (p HeaderUserPolicy) UserID(env actorlayer.Envelope) string
UserID returns header value when present, else fallback.
type Message ¶
type Message struct {
Topic string `json:"topic,omitempty"`
Payload any `json:"payload,omitempty"`
}
Message wraps tool payload with an optional topic hint.
type ReplyMode ¶
type ReplyMode int
ReplyMode defines how an ADK actor replies to incoming envelopes.
const ( // NoReply does not send any reply envelope. NoReply ReplyMode = iota // ReplyFinal sends one reply from the final ADK response. ReplyFinal // ReplyEachEvent streams one reply per ADK event. ReplyEachEvent // ReplyFinalAndPublishEvents publishes events and sends the final reply. ReplyFinalAndPublishEvents )
type SessionPolicy ¶
type SessionPolicy interface {
SessionID(env actorlayer.Envelope, self actorlayer.Ref) string
}
SessionPolicy resolves the ADK session ID for an incoming envelope.
func ConversationSession ¶
func ConversationSession(headerName string) SessionPolicy
ConversationSession resolves session IDs from a conversation header, correlation ID, or message ID.
func PerActorSession ¶
func PerActorSession() SessionPolicy
PerActorSession uses the actor ID as the session ID.
func PerMessageSession ¶
func PerMessageSession() SessionPolicy
PerMessageSession uses message ID as session ID with actor fallback.
type StaticUserPolicy ¶
type StaticUserPolicy string
StaticUserPolicy always returns a fixed user ID.
func (StaticUserPolicy) UserID ¶
func (p StaticUserPolicy) UserID(_ actorlayer.Envelope) string
UserID returns the configured static user ID.
type ToolsetConfig ¶
type ToolsetConfig struct {
Allowed AddressPolicy
DefaultAskTimeout time.Duration
MaxAskTimeout time.Duration
MaxPayloadBytes int
NamedRefs map[string]actorlayer.Ref
AllowDirectActorID bool
EnablePublish bool
}
ToolsetConfig configures actor tool exposure and safety limits.
type ToolsetOption ¶
type ToolsetOption interface {
// contains filtered or unexported methods
}
ToolsetOption mutates ToolsetConfig.
func WithAddressPolicy ¶
func WithAddressPolicy(policy AddressPolicy) ToolsetOption
WithAddressPolicy sets the allow/deny policy for actor targets.
func WithDefaultAskTimeout ¶
func WithDefaultAskTimeout(timeout time.Duration) ToolsetOption
WithDefaultAskTimeout sets the default timeout for actor_ask.
func WithDirectActorIDTargets ¶
func WithDirectActorIDTargets(enabled bool) ToolsetOption
WithDirectActorIDTargets enables raw actor ID addressing in tools.
func WithMaxAskTimeout ¶
func WithMaxAskTimeout(timeout time.Duration) ToolsetOption
WithMaxAskTimeout sets the maximum allowed actor_ask timeout.
func WithMaxPayloadBytes ¶
func WithMaxPayloadBytes(maxBytes int) ToolsetOption
WithMaxPayloadBytes sets the maximum JSON-encoded payload size.
func WithNamedRef ¶
func WithNamedRef(name string, ref actorlayer.Ref) ToolsetOption
WithNamedRef registers a single symbolic target for tools.
func WithNamedRefs ¶
func WithNamedRefs(refs map[string]actorlayer.Ref) ToolsetOption
WithNamedRefs registers multiple symbolic targets for tools.
func WithPublishEnabled ¶
func WithPublishEnabled(enabled bool) ToolsetOption
WithPublishEnabled enables actor_publish tool registration.
type TransferPolicy ¶
type TransferPolicy int
TransferPolicy controls how ADK transfer/escalation actions are handled.
const ( // TransferADKInternal leaves transfer/escalation handling inside ADK. TransferADKInternal TransferPolicy = iota // TransferToActorAsk maps transfer/escalation to actor Ask calls. TransferToActorAsk // TransferToActorTell maps transfer/escalation to actor Tell calls. TransferToActorTell // TransferReject rejects transfer/escalation actions. TransferReject )
type UserPolicy ¶
type UserPolicy interface {
UserID(env actorlayer.Envelope) string
}
UserPolicy resolves ADK user IDs from actor envelopes.
func HeaderUser ¶
func HeaderUser(headerName, fallback string) UserPolicy
HeaderUser builds a UserPolicy that reads one header with fallback.