Documentation
¶
Overview ¶
Package adaptersdk provides a lightweight SDK for building deploy adapters. It exposes a JSON-RPC 2.0 server over stdio so that adapter authors can implement the deploy.Provider interface and call Serve() to run.
Index ¶
- Constants
- func GenerateAgentCards(pack *prompt.Pack) map[string]*a2a.AgentCard
- func GenerateAgentResourcePlan(pack *prompt.Pack) []deploy.ResourceChange
- func GenerateToolGatewayPlan(tools []ToolInfo, targets ToolTargetMap) []deploy.ResourceChange
- func IsMultiAgent(pack *prompt.Pack) bool
- func ParsePack(packJSON []byte) (*prompt.Pack, error)
- func Serve(provider deploy.Provider) error
- func ServeIO(provider deploy.Provider, r io.Reader, w io.Writer) error
- func SummarizeChanges(changes []deploy.ResourceChange) string
- type AgentInfo
- type ProgressReporter
- type ResourcePlan
- type ToolInfo
- type ToolPolicyInfo
- type ToolTargetMap
Constants ¶
const ( MethodGetProviderInfo = "get_provider_info" MethodValidateConfig = "validate_config" MethodPlan = "plan" MethodApply = "apply" MethodDestroy = "destroy" MethodStatus = "status" MethodImport = "import" )
JSON-RPC method names recognized by the adapter protocol.
const ( CodeParseError = -32700 CodeInvalidRequest = -32600 CodeMethodNotFound = -32601 CodeInternalError = -32603 )
Standard JSON-RPC 2.0 error codes.
Variables ¶
This section is empty.
Functions ¶
func GenerateAgentCards ¶
GenerateAgentCards re-exports agentcard.GenerateAgentCards for adapter convenience.
func GenerateAgentResourcePlan ¶
func GenerateAgentResourcePlan(pack *prompt.Pack) []deploy.ResourceChange
GenerateAgentResourcePlan creates resource changes for deploying a multi-agent pack. For each member it emits an agent_runtime and a2a_endpoint resource. For the entry agent it also emits a gateway resource. Returns nil if the pack is not multi-agent.
func GenerateToolGatewayPlan ¶
func GenerateToolGatewayPlan(tools []ToolInfo, targets ToolTargetMap) []deploy.ResourceChange
GenerateToolGatewayPlan creates resource changes for tools that have target mappings.
func IsMultiAgent ¶
IsMultiAgent returns true if the pack has an agents section with members.
func Serve ¶
Serve reads JSON-RPC requests from stdin, dispatches them to the given deploy.Provider, and writes responses to stdout. It runs until stdin is closed or an unrecoverable I/O error occurs.
func ServeIO ¶
ServeIO is like Serve but reads from r and writes to w, allowing tests to substitute stdin/stdout. If r or w is nil the function returns an error.
func SummarizeChanges ¶
func SummarizeChanges(changes []deploy.ResourceChange) string
SummarizeChanges generates a human-readable summary of resource changes. Example: "3 to create, 1 to update, 1 to delete"
Types ¶
type AgentInfo ¶
type AgentInfo struct {
Name string `json:"name"`
Description string `json:"description"`
IsEntry bool `json:"is_entry"`
Tags []string `json:"tags,omitempty"`
InputModes []string `json:"input_modes"`
OutputModes []string `json:"output_modes"`
}
AgentInfo provides a simplified view of an agent member for deploy adapters.
func ExtractAgents ¶
ExtractAgents returns agent info for all members in the pack's agents section. Returns nil if the pack is not multi-agent. Defaults: text/plain for missing input/output modes, description falls back to the corresponding prompt description.
type ProgressReporter ¶
type ProgressReporter struct {
// contains filtered or unexported fields
}
ProgressReporter wraps a deploy.ApplyCallback and provides convenient methods for emitting progress, resource, and error events.
func NewProgressReporter ¶
func NewProgressReporter(callback deploy.ApplyCallback) *ProgressReporter
NewProgressReporter creates a ProgressReporter that sends events through the given ApplyCallback.
func (*ProgressReporter) Error ¶
func (pr *ProgressReporter) Error(err error) error
Error emits an error event.
func (*ProgressReporter) Progress ¶
func (pr *ProgressReporter) Progress(message string, pct float64) error
Progress emits a progress event with a human-readable message and a completion percentage (0.0 to 1.0).
func (*ProgressReporter) Resource ¶
func (pr *ProgressReporter) Resource(result *deploy.ResourceResult) error
Resource emits a resource result event.
type ResourcePlan ¶
type ResourcePlan struct {
Changes []deploy.ResourceChange
Tools []ToolInfo
Targets ToolTargetMap
Policy *ToolPolicyInfo
}
ResourcePlan holds the combined plan result.
func GenerateResourcePlan ¶
func GenerateResourcePlan(packJSON, arenaConfigJSON, deployConfigJSON string) (*ResourcePlan, error)
GenerateResourcePlan builds a combined resource plan from PlanRequest fields. It extracts agent resources from the pack, tool resources from ArenaConfig, filters by tool policy blocklist, and matches tools against deploy targets. Adapters can call this directly from their Plan() method for a complete plan, or use the individual functions for custom logic.
type ToolInfo ¶
type ToolInfo struct {
Name string `json:"name"`
Description string `json:"description"`
Mode string `json:"mode"` // "mock", "live", "mcp", "a2a"
HasSchema bool `json:"has_schema"`
InputSchema interface{} `json:"input_schema,omitempty"`
HTTPURL string `json:"http_url,omitempty"`
HTTPMethod string `json:"http_method,omitempty"`
}
ToolInfo holds tool metadata extracted from ArenaConfig for deploy planning.
func ExtractToolInfo ¶
ExtractToolInfo parses an ArenaConfig JSON string and returns tool info for deploy planning. It reads from both inline ToolSpecs and loaded tool data.
func FilterBlocklistedTools ¶
func FilterBlocklistedTools(tools []ToolInfo, policy *ToolPolicyInfo) []ToolInfo
FilterBlocklistedTools removes tools whose names appear in the policy blocklist.
type ToolPolicyInfo ¶
type ToolPolicyInfo struct {
Blocklist []string `json:"blocklist,omitempty"`
}
ToolPolicyInfo holds tool policy from scenarios for deploy planning.
func ExtractToolPolicies ¶
func ExtractToolPolicies(arenaConfigJSON string) (*ToolPolicyInfo, error)
ExtractToolPolicies returns a merged ToolPolicyInfo from all scenarios in the ArenaConfig.
type ToolTargetMap ¶
type ToolTargetMap map[string]json.RawMessage
ToolTargetMap is an opaque map of tool name → adapter-specific target config. Each adapter defines its own target schema; the SDK only tracks which tools have targets.
func ParseDeployToolTargets ¶
func ParseDeployToolTargets(deployConfigJSON string) (ToolTargetMap, error)
ParseDeployToolTargets extracts the tool_targets map from the opaque deploy config JSON. Returns raw JSON per tool so each adapter can unmarshal into its own target type.