bedrockagentcore

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 44 Imported by: ? 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.

README

Bedrockagentcore

Parity grade: B · SDK aws-sdk-go-v2/service/bedrockagentcore@v1.50.3 · last audited 2026-10-22 (71065ec09)

Coverage

Metric Value
PARITY entries audited 32 (32 ok)
Feature families 6 (6 ok)
Known gaps 7
Structural gaps (can't be emulated) 2
Deferred items 0
Resource leaks clean
Known gaps
  • Unserved operations: AB tests, batch evaluation, payments, recommendations, InvokeHarness, IngestData, memory extraction jobs, SaveBrowserSessionProfile, InvokeBrowser and UpdateBrowserStream have no routes
  • Retrieval: RetrieveMemoryRecords ranks with lexical BM25 only, so records sharing no term with the query are not returned
  • Runtimes: runtimes without a customJWTAuthorizer accept any caller and no IAM policy is evaluated
  • Code interpreter: executeCode runs a fresh python process per call, so variables do not persist between calls; javascript, typescript and the async task tools are rejected
  • Code interpreter: network mode, certificates and filesystem configurations are stored but not applied to the sandbox; a no-network mode would cut the sandbox off from the emulator endpoint (sandbox.go:119)
  • Browser: no automation or live-view streams, no profiles, and no browser process behind a session
  • Identity: vendor providers without a discovery document have no reachable authorization or token endpoint
Structural gaps

These do not block an A grade — no implementation could produce real data here because the underlying data source cannot exist in an emulator.

  • Semantic memory search: real retrieval embeds text with a model; the emulator has none, so ranking is lexical
  • Browser automation: a headless browser container with a CDP bridge is out of scope

More

Documentation

Overview

Package bedrockagentcore emulates the Amazon Bedrock AgentCore data plane: agent runtime invocation, memory events and records, code interpreter and browser sessions, and workload identity tokens.

Index

Constants

View Source
const (
	// EngineAuto runs containers when a container runtime is reachable.
	EngineAuto = "auto"
	// EngineNone never starts containers; invocations that need one fail.
	EngineNone = "none"
)

Variables

View Source
var (
	ErrNotFound = errors.New("resource not found")
	ErrNotReady = errors.New("resource is not ready")
)

Errors a Control reports for runtime lookups.

View Source
var ErrInvalidFederation = errors.New("invalid user federation request")

ErrInvalidFederation marks a three-legged OAuth request the control plane rejects as invalid.

Functions

func RankBM25

func RankBM25(query string, docs []string) []float64

RankBM25 scores docs against query with the lexical Okapi BM25 ranking used for retrieval.

Types

type AccessToken

type AccessToken struct {
	Expires  time.Time `json:"expires"`
	Token    string    `json:"token"`
	Account  string    `json:"account"`
	Region   string    `json:"region"`
	Workload string    `json:"workload"`
	UserID   string    `json:"userId,omitempty"`
	// UserJWT is the user token of GetWorkloadAccessTokenForJWT; held in memory only so it never reaches a snapshot.
	UserJWT string `json:"-"`
}

AccessToken is an issued workload access token.

type AuthFailure

type AuthFailure struct {
	Challenge string
	Message   string
	Status    int
}

AuthFailure is a request the runtime's inbound authorizer rejected.

type CodeInfo

type CodeInfo struct {
	// Load returns the zip package, read from the S3 location of the runtime.
	Load       func() ([]byte, error)
	Runtime    string
	EntryPoint []string
}

CodeInfo is a direct code deployment: a zip package run by a managed language runtime.

type ConfigProvider

type ConfigProvider interface {
	GetAgentCoreSettings() Settings
	GetAgentCoreEndpointURL() string
}

ConfigProvider extracts AgentCore data-plane configuration from the AppContext Config.

type ContainerRuntime

type ContainerRuntime interface {
	CreateAndStart(ctx context.Context, spec container.Spec) (string, error)
	StopAndRemove(ctx context.Context, containerID string) error
	Exec(ctx context.Context, containerID string, cmd []string) (container.ExecResult, error)
}

ContainerRuntime is the slice of container.Runtime the engine uses.

type Control

type Control interface {
	Runtime(sc Scope, ref, qualifier string) (RuntimeInfo, error)
	Memory(sc Scope, id string) (MemoryInfo, bool)
	Tool(sc Scope, kind ToolKind, id string) (ToolInfo, bool)
	WorkloadIdentity(sc Scope, name string) bool
	Provider(sc Scope, kind ProviderKind, name string) (ProviderInfo, bool)
	SecretValue(arn, jsonKey string) (string, bool)
	FederatedToken(ctx context.Context, sc Scope, req FederationRequest) (FederationResult, error)
	CompleteFederation(ctx context.Context, sc Scope, sessionURI string, user UserIdentifier) error
	VerifyUserJWT(ctx context.Context, token string) (string, error)
	VerifyWorkloadJWT(ctx context.Context, sc Scope, workload, token string) (string, error)
	// OutboundHTTP is the client for provider token endpoints; nil falls back to the engine client.
	OutboundHTTP() HTTPDoer
}

Control resolves the control-plane resources the data plane operates on.

type EngineConfig

type EngineConfig struct {
	Runtime ContainerRuntime
	// Ports hands out host ports for runtime containers; nil picks free OS ports.
	Ports *portalloc.Allocator
	// HTTP reaches agent containers; nil uses an isolated client.
	HTTP HTTPDoer
	// Host is the address published container ports are reached on; default 127.0.0.1.
	Host string
	// EndpointURL is the gopherstack URL as seen from containers (AWS_ENDPOINT_URL).
	EndpointURL string
	// RegistryHost, when set, replaces the host of ECR image URIs so images are pulled from the emulated registry.
	RegistryHost string
	// PythonImage is the code interpreter sandbox image.
	PythonImage string
	// StartTimeout bounds boot until a runtime container answers its health check.
	StartTimeout time.Duration
	PollInterval time.Duration
	StopTimeout  time.Duration
	// IdleTimeout applies to runtimes that set no idleRuntimeSessionTimeout.
	IdleTimeout time.Duration
}

EngineConfig configures container-backed runtimes and sandboxes.

type Event

type Event struct {
	Timestamp   time.Time      `json:"timestamp"`
	Metadata    map[string]any `json:"metadata,omitempty"`
	Branch      map[string]any `json:"branch,omitempty"`
	Account     string         `json:"account"`
	Region      string         `json:"region"`
	MemoryID    string         `json:"memoryId"`
	ActorID     string         `json:"actorId"`
	SessionID   string         `json:"sessionId"`
	EventID     string         `json:"eventId"`
	ClientToken string         `json:"clientToken,omitempty"`
	Payload     []any          `json:"payload"`
	Seq         uint64         `json:"seq"`
}

Event is one memory event of an actor session.

type FederationRequest

type FederationRequest struct {
	CustomParameters map[string]string
	Provider         string
	Workload         string
	UserID           string
	ReturnURL        string
	CustomState      string
	SessionURI       string
	Scopes           []string
	Audiences        []string
	Resources        []string
	Force            bool
}

FederationRequest is a USER_FEDERATION GetResourceOauth2Token call.

type FederationResult

type FederationResult struct {
	AccessToken      string
	AuthorizationURL string
	SessionURI       string
	InProgress       bool
	Failed           bool
}

FederationResult is the outcome: a token, or an authorization URL with the session to resume.

type HTTPDoer

type HTTPDoer interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPDoer is the slice of *http.Client used to reach agent containers.

type Handler

type Handler struct {
	Backend *InMemoryBackend

	DefaultRegion string
	// contains filtered or unexported fields
}

Handler serves the AgentCore data-plane REST API.

func NewHandler

func NewHandler(backend *InMemoryBackend) *Handler

NewHandler wraps a backend.

func (*Handler) ChaosOperations

func (h *Handler) ChaosOperations() []string

ChaosOperations lists the fault-injectable operations.

func (*Handler) ChaosRegions

func (h *Handler) ChaosRegions() []string

ChaosRegions lists the regions this handler serves.

func (*Handler) ChaosServiceName

func (h *Handler) ChaosServiceName() string

ChaosServiceName returns the lowercase service name for fault rules.

func (*Handler) ExtractOperation

func (h *Handler) ExtractOperation(c *echo.Context) string

ExtractOperation returns the operation name.

func (*Handler) ExtractResource

func (h *Handler) ExtractResource(c *echo.Context) string

ExtractResource returns the memory, runtime or tool the request addresses.

func (*Handler) GetSupportedOperations

func (h *Handler) GetSupportedOperations() []string

GetSupportedOperations lists every implemented operation.

func (*Handler) Handler

func (h *Handler) Handler() echo.HandlerFunc

Handler returns the echo handler.

func (*Handler) MatchPriority

func (h *Handler) MatchPriority() int

MatchPriority returns the routing priority.

func (*Handler) Name

func (h *Handler) Name() string

Name returns the service name.

func (*Handler) Reset

func (h *Handler) Reset()

Reset clears all state.

func (*Handler) Restore

func (h *Handler) Restore(ctx context.Context, data []byte) error

Restore implements persistence.Persistable.

func (*Handler) RouteMatcher

func (h *Handler) RouteMatcher() service.Matcher

RouteMatcher matches by SigV4 signing name (or the data-plane SDK user agent) plus a known path shape; the unsigned protected-resource metadata fetch matches by path alone.

func (*Handler) Shutdown

func (h *Handler) Shutdown(_ context.Context)

Shutdown stops every container the service started.

func (*Handler) Snapshot

func (h *Handler) Snapshot(ctx context.Context) []byte

Snapshot implements persistence.Persistable.

func (*Handler) StartWorker

func (h *Handler) StartWorker(ctx context.Context) error

StartWorker reaps idle runtime sessions and expired tool sessions.

type InMemoryBackend

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

InMemoryBackend is the AgentCore data-plane state; one coarse lock guards every table.

func NewInMemoryBackend

func NewInMemoryBackend(accountID, region string) *InMemoryBackend

NewInMemoryBackend creates an empty backend.

func (*InMemoryBackend) Close

func (b *InMemoryBackend) Close()

Close stops every runtime container and sandbox.

func (*InMemoryBackend) EnableEngine

func (b *InMemoryBackend) EnableEngine(cfg EngineConfig)

EnableEngine switches the backend to container-backed runtimes and sandboxes. Call it before serving.

func (*InMemoryBackend) EngineEnabled

func (b *InMemoryBackend) EngineEnabled() bool

EngineEnabled reports whether containers can be started.

func (*InMemoryBackend) ReapIdle

func (b *InMemoryBackend) ReapIdle()

ReapIdle stops runtime sessions idle past their timeout and terminates expired tool sessions.

func (*InMemoryBackend) Reset

func (b *InMemoryBackend) Reset()

Reset clears all state and stops every running runtime session and sandbox.

func (*InMemoryBackend) Restore

func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error

Restore loads a snapshot; an incompatible version is discarded. Sessions that were READY come back TERMINATED because their sandboxes did not survive the restart.

func (*InMemoryBackend) SetClock

func (b *InMemoryBackend) SetClock(now func() time.Time)

SetClock replaces the time source, which drives idle expiry and token lifetimes.

func (*InMemoryBackend) SetControl

func (b *InMemoryBackend) SetControl(c Control)

SetControl wires the control plane the data plane resolves resources from.

func (*InMemoryBackend) Snapshot

func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte

Snapshot serialises the backend state. Containers and sandboxes are not part of it.

type MemoryInfo

type MemoryInfo struct {
	ID         string
	Strategies []StrategyInfo
	ExpiryDays int
}

MemoryInfo is the control-plane definition of a memory.

type MemoryRecord

type MemoryRecord struct {
	Created    time.Time      `json:"created"`
	Metadata   map[string]any `json:"metadata,omitempty"`
	Account    string         `json:"account"`
	Region     string         `json:"region"`
	MemoryID   string         `json:"memoryId"`
	ID         string         `json:"id"`
	StrategyID string         `json:"strategyId,omitempty"`
	Text       string         `json:"text"`
	Namespaces []string       `json:"namespaces"`
	Seq        uint64         `json:"seq"`
}

MemoryRecord is a long-term memory record.

type Provider

type Provider struct{}

Provider implements service.Provider for the Bedrock AgentCore data plane.

func (*Provider) Init

Init builds the backend and handler, and enables containers when a runtime is reachable.

func (*Provider) Name

func (p *Provider) Name() string

Name returns the provider name.

type ProviderInfo

type ProviderInfo struct {
	Config       map[string]any
	Name         string
	Vendor       string
	SecretARN    string
	SecretJSONID string
}

ProviderInfo is a credential provider with the references needed to resolve its secrets.

type ProviderKind

type ProviderKind string

ProviderKind selects a credential provider family.

const (
	ProviderAPIKey ProviderKind = "apiKey"
	ProviderOAuth2 ProviderKind = "oauth2"
)

Credential provider families.

type RuntimeInfo

type RuntimeInfo struct {
	Env       map[string]string
	Authorize func(ctx context.Context, r *http.Request) *AuthFailure
	// ProtectedResource builds the RFC 9728 metadata document; nil when the runtime has no JWT authorizer.
	ProtectedResource func(r *http.Request) map[string]any
	Code              *CodeInfo
	ID                string
	ImageURI          string
	Protocol          string
	IdleSeconds       int
	MaxLifetimeS      int
}

RuntimeInfo is the deployable view of an agent runtime endpoint.

type Scope

type Scope struct{ Account, Region string }

Scope identifies the account and Region a request operates in.

type Settings

type Settings struct {
	Engine string `` //nolint:lll // config struct tags are intentionally verbose
	/* 218-byte string literal not displayed */
	RegistryHost string `` //nolint:lll // config struct tags are intentionally verbose
	/* 230-byte string literal not displayed */
	PythonImage string `` //nolint:lll // config struct tags are intentionally verbose
	/* 170-byte string literal not displayed */
	// GatewayExtraCAFile adds trusted CAs for gateway target, JWKS and OAuth requests.
	GatewayExtraCAFile string `` //nolint:lll // config struct tags are intentionally verbose
	/* 243-byte string literal not displayed */
	// AllowExternalGatewayTargets lets control-plane gateway targets reach hosts outside loopback.
	AllowExternalGatewayTargets bool `` //nolint:lll // config struct tags are intentionally verbose
	/* 316-byte string literal not displayed */
	IdleTimeout time.Duration `` //nolint:lll // config struct tags are intentionally verbose
	/* 248-byte string literal not displayed */
}

Settings holds the data-plane configuration, embedded in the root CLI command as CLI.AgentCore.

type StrategyInfo

type StrategyInfo struct{ ID, Name, Type string }

StrategyInfo is one memory strategy of a memory.

type ToolInfo

type ToolInfo struct {
	ID   string
	Mode string
}

ToolInfo is a browser or code interpreter definition.

type ToolKind

type ToolKind string

ToolKind selects the sandbox family.

const (
	ToolBrowser         ToolKind = "browser"
	ToolCodeInterpreter ToolKind = "codeInterpreter"
)

Sandbox families.

type ToolSession

type ToolSession struct {
	Created    time.Time `json:"created"`
	Updated    time.Time `json:"updated"`
	LastActive time.Time `json:"lastActive"`
	Config     doc       `json:"config,omitempty"`
	Account    string    `json:"account"`
	Region     string    `json:"region"`
	Kind       ToolKind  `json:"kind"`
	ToolID     string    `json:"toolId"`
	ID         string    `json:"id"`
	Name       string    `json:"name,omitempty"`
	Status     string    `json:"status"`
	Token      string    `json:"clientToken,omitempty"`
	TimeoutSec int       `json:"timeoutSec"`
}

ToolSession is a browser or code interpreter session.

type UserIdentifier

type UserIdentifier struct{ UserID, UserToken string }

UserIdentifier names the user of a federation session by id or by a verifiable user token.

Jump to

Keyboard shortcuts

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