node

package
v0.1.0-alpha.3 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: Apache-2.0 Imports: 76 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Cache sizes
	RateLimiterSize       = 1000
	RevocationCacheSize   = 10000
	VerificationCacheSize = 1000

	// Freshness checks
	FreshnessThreshold = 5 * time.Minute

	// Key pruning
	KeyPruningInterval = 1 * time.Hour

	// Reprovide interval
	ReprovideInterval = 5 * time.Minute
)
View Source
const (
	DefaultMeshName          = "public-mesh"
	DefaultDiscoveryInterval = "30s"
	DefaultConfigFile        = "sam-node.yaml"
	DefaultHubConnectTimeout = 5 * time.Second
)
View Source
const (
	// Rate limiting defaults for peers
	PeerRateLimit = 5
	PeerBurst     = 10
)
View Source
const PeerstoreKeyPrivateIPFailed = "private_ip_failed"

PeerstoreKeyPrivateIPFailed is the key used in the libp2p Peerstore to track if a peer's private IP was previously found to be unreachable or slower than a relay. This allows the node to "try once and remember", avoiding a 15-second timeout on subsequent discovery or tool calls when dialing unroutable private networks.

Variables

View Source
var (
	// Renewal timing defaults
	DefaultRenewalFallback = (api.BiscuitTokenTTL * 8) / 10 // 80% of TTL (19.2h)
	RenewalBuffer          = api.BiscuitTokenTTL / 5        // 20% of TTL (4.8h)
	RenewalThreshold       = api.BiscuitTokenTTL / 4        // 25% of TTL (6h)
)
View Source
var ErrFatalAuth = errors.New("fatal authentication error")

Functions

func BuildPolicyRules

func BuildPolicyRules(roles []*api.PolicyRole, bindings []*api.PolicyBinding) []biscuit.Rule

func FetchHubInfo

func FetchHubInfo(ctx context.Context, hubURL string) (*api.HubInfoResponse, error)

FetchHubInfo retrieves the latest configuration from the Hub's /info endpoint.

func FetchMeshPolicy

func FetchMeshPolicy(ctx context.Context, hubURL string, biscuitToken []byte) (*api.PolicyConfigGetResponse, error)

FetchMeshPolicy retrieves the latest mesh policy from the Hub's /policies endpoint using a biscuit token.

func GetDefaultDataDir

func GetDefaultDataDir() (string, error)

func GetOrGenerateKey

func GetOrGenerateKey(s *Store) crypto.PrivKey

GetOrGenerateKey retrieves a persistent private key or creates one if it's the first run

func GetRecentLogs

func GetRecentLogs() []string

GetRecentLogs returns the most recent log lines.

func NewMCPHandler

func NewMCPHandler(node *SamNode) http.Handler

NewMCPHandler creates a new HTTP handler for the MCP server using the official SDK.

func NewMCPServer

func NewMCPServer(node *SamNode) *mcp.Server

NewMCPServer creates a new MCP server instance with all tools registered.

func NewUnauthenticatedMCPHandler

func NewUnauthenticatedMCPHandler(hubURL string) http.Handler

NewUnauthenticatedMCPHandler creates an HTTP handler for the unauthenticated MCP server.

func NewUnauthenticatedMCPServer

func NewUnauthenticatedMCPServer(hubURL string) *mcp.Server

NewUnauthenticatedMCPServer creates a minimal MCP server that instructs the client on how to authenticate.

func StartSidecarServer

func StartSidecarServer(node *SamNode, addr, token, certFile, keyFile, caFile string) (*http.Server, error)

func StartUnauthSidecarServer

func StartUnauthSidecarServer(hubURL, addr, certFile, keyFile string) (*http.Server, error)

func SyncHubConfig

func SyncHubConfig(ctx context.Context, s *Store) ([]byte, []multiaddr.Multiaddr, error)

SyncHubConfig loads the hub configuration from the store, attempts to refresh it via HTTP from the hub, and updates the store if successful. It returns the hub public key and the latest multiaddresses.

Types

type A2AService

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

A2AService is zero-override embedding. They exist so the factory produces a distinct type per ServiceType, leaving room for future per-kind behaviour without churn.

func (*A2AService) Handler

func (b *A2AService) Handler() http.Handler

func (*A2AService) Info

func (b *A2AService) Info() *api.ServiceInfo

func (*A2AService) Init

func (b *A2AService) Init(ctx context.Context) error

Init builds the ingress handler for the backend. URL -> reverse-proxy, Command -> StdioBridge. MCPService extends this; it does not replace it.

func (*A2AService) Teardown

func (b *A2AService) Teardown() error

Teardown kills the child process if any. Safe to call when cmd is nil or already dead.

type CallRemoteToolParams

type CallRemoteToolParams struct {
	PeerID    string         `json:"peer_id" jsonschema:"The Peer ID of the target agent"`
	ToolName  string         `json:"tool_name" jsonschema:"The name of the server to call"`
	Arguments map[string]any `` /* 177-byte string literal not displayed */
}

CallRemoteToolParams defines the parameters for the call_remote_tool tool.

Arguments is a JSON object whose shape matches the target server's input_schema (use describe_remote_tool to fetch it). Earlier revisions took a stringified JSON blob here; that footgun is gone.

type CheckConnectivityParams

type CheckConnectivityParams struct {
	PeerID string `json:"peer_id,omitempty" jsonschema:"Optional peer ID to ping."`
}

CheckConnectivityParams defines the parameters for the check_connectivity tool.

type ConnectPeerParams

type ConnectPeerParams struct {
	PeerAddr string `json:"peer_addr" jsonschema:"The full multiaddress of the peer to connect to"`
}

ConnectPeerParams defines the parameters for the connect_peer tool.

type DescribeRemoteToolParams

type DescribeRemoteToolParams struct {
	PeerID   string `json:"peer_id" jsonschema:"Peer ID of the node hosting the server. Required."`
	ToolName string `` /* 135-byte string literal not displayed */
}

DescribeRemoteToolParams defines parameters for the describe_remote_tool sidecar tool.

type DiscoverRemoteServicesParams

type DiscoverRemoteServicesParams struct {
	Type   string `json:"type" jsonschema:"Service type (mcp, inference, a2a)"`
	Name   string `json:"name,omitempty" jsonschema:"Optional service name. Omit to list all services of the given type."`
	Limit  int    `json:"limit,omitempty" jsonschema:"Optional limit for pagination. Defaults to 20."`
	Offset int    `json:"offset,omitempty" jsonschema:"Optional offset for pagination. Defaults to 0."`
}

DiscoverRemoteServicesParams defines the parameters for the discover_remote_services tool.

type FindRemoteToolsParams

type FindRemoteToolsParams struct {
	Intent      string `` /* 170-byte string literal not displayed */
	PeerID      string `json:"peer_id,omitempty" jsonschema:"Restrict the search to a single peer. Empty means search the whole mesh."`
	ServiceName string `` /* 166-byte string literal not displayed */
}

FindRemoteToolsParams defines the parameters for the find_remote_tools tool.

type GetMeshInfoParams

type GetMeshInfoParams struct{}

GetMeshInfoParams defines the parameters for the get_mesh_info tool.

type GetNetworkInfoParams

type GetNetworkInfoParams struct{}

GetNetworkInfoParams defines parameters for the get_network_info tool.

type GetRecentLogsParams

type GetRecentLogsParams struct{}

GetRecentLogsParams defines parameters for the get_recent_logs tool.

type GetTokenInfoParams

type GetTokenInfoParams struct{}

GetTokenInfoParams defines parameters for the get_token_info tool.

type InferenceService

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

InferenceService provides intelligent LLM gateway features: traffic routing and token usage tracking for OpenAI-compatible endpoints.

func (*InferenceService) Handler

func (b *InferenceService) Handler() http.Handler

func (*InferenceService) Info

func (b *InferenceService) Info() *api.ServiceInfo

func (*InferenceService) Init

func (s *InferenceService) Init(ctx context.Context) error

func (*InferenceService) Teardown

func (b *InferenceService) Teardown() error

Teardown kills the child process if any. Safe to call when cmd is nil or already dead.

type ListLocalServicesParams

type ListLocalServicesParams struct {
	Type string `json:"type,omitempty" jsonschema:"Optional service type filter (mcp, inference, a2a). Empty means all types."`
}

ListLocalServicesParams defines the parameters for the list_local_services tool.

type MCPService

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

MCPService extends baseService to handle MCP protocol proxying.

func (*MCPService) HandleStreamPassThrough

func (m *MCPService) HandleStreamPassThrough(s network.Stream)

HandleStreamPassThrough connects to the backend and proxies JSON-RPC messages.

func (*MCPService) Handler

func (b *MCPService) Handler() http.Handler

func (*MCPService) Info

func (b *MCPService) Info() *api.ServiceInfo

func (*MCPService) Init

func (m *MCPService) Init(ctx context.Context) error

Init initializes the base service.

func (*MCPService) Teardown

func (m *MCPService) Teardown() error

Teardown chains to baseService.Teardown.

type MeshPubsubBroadcastParams

type MeshPubsubBroadcastParams struct {
	Topic   string `json:"topic" jsonschema:"GossipSub topic name"`
	Payload string `json:"payload" jsonschema:"Payload to publish"`
}

MeshPubsubBroadcastParams defines the parameters for the mesh_pubsub_broadcast tool.

type NodeConfigComplete

type NodeConfigComplete struct {
	Policies []biscuit.Policy
	Checks   []biscuit.Check
	Rules    []biscuit.Rule
	Services []api.ServiceConfig
}

func LoadNodeConfig

func LoadNodeConfig(path string) (*NodeConfigComplete, error)

LoadNodeConfig loads the node configuration from the specified path. If the file is missing, it returns an empty initialized config.

type Options

type Options struct {
	PrivKey              crypto.PrivKey
	HubPubKey            ed25519.PublicKey
	HubAddrs             []multiaddr.Multiaddr
	Store                *Store
	MeshID               string
	DiscoveryInterval    string
	ListenAddrs          []string
	EnableRelay          bool
	NodeConfig           *NodeConfigComplete
	KeyGracePeriod       time.Duration
	AllowLoopback        bool
	MonitorBootstrap     time.Duration
	MonitorInterval      time.Duration
	AutoRelayMinInterval time.Duration
	AutoRelayBootDelay   time.Duration
	AutoRelayBackoff     time.Duration
	// HubConnectTimeout bounds each hub address's dial (connect + stream open).
	HubConnectTimeout time.Duration
	// DHT Options
	DHTProviderAddrTTL   time.Duration
	DHTMaxRecordAge      time.Duration
	DHTLookupLimit       int
	DiscoveryConcurrency int
	// RequiredRole restricts enrollment and startup to only accept tokens containing this role.
	RequiredRole string
	// PolicySyncInterval specifies how often the node syncs the mesh policy from the Hub.
	PolicySyncInterval time.Duration
}

Options holds all configuration options for a SamNode.

func (*Options) Default

func (o *Options) Default()

Default applies default values to Options if they are not specified.

func (*Options) Validate

func (o *Options) Validate() error

Validate verifies that the required options are provided and valid.

type PeerRateLimiter

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

PeerRateLimiter tracks rate limits per peer using an LRU cache.

func NewPeerRateLimiter

func NewPeerRateLimiter(size int) (*PeerRateLimiter, error)

NewPeerRateLimiter creates a new PeerRateLimiter with specified cache size.

func (*PeerRateLimiter) Allow

func (prl *PeerRateLimiter) Allow(peerID string) bool

Allow checks if the peer is allowed to perform an action.

type PollMessagesParams

type PollMessagesParams struct {
	Topic string `json:"topic" jsonschema:"GossipSub topic name"`
}

PollMessagesParams defines the parameters for the poll_messages tool.

type RefreshError

type RefreshError struct {
	StatusCode int
	Message    string
}

func (*RefreshError) Error

func (e *RefreshError) Error() string

type RequestContext

type RequestContext struct {
	PeerID   peer.ID
	User     string
	Group    string
	Protocol string
	Target   string
}

RequestContext carries the security metadata for a specific stream request

type RingBufferSink

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

RingBufferSink implements zap.Sink to capture logs in memory.

func (*RingBufferSink) Close

func (s *RingBufferSink) Close() error

Close implements zap.Sink

func (*RingBufferSink) Sync

func (s *RingBufferSink) Sync() error

Sync implements zap.Sink

func (*RingBufferSink) Write

func (s *RingBufferSink) Write(p []byte) (n int, err error)

Write implements io.Writer

type SamNode

type SamNode struct {
	Host      host.Host
	DHT       *dht.IpfsDHT
	PubSub    *pubsub.PubSub
	Store     *Store
	HubPeerID peer.ID

	LocalPolicy *NodeConfigComplete

	MeshPolicyRules []biscuit.Rule
	MeshPolicyMu    sync.RWMutex

	BoundHTTPAddr string
	AllowLoopback bool

	BiscuitTimeout time.Duration
	// contains filtered or unexported fields
}

func NewSamNode

func NewSamNode(cfg Options) (*SamNode, error)

NewSamNode creates a new Agent instance secured with the 4-layer pipeline. NewSamNode initializes options and structures without starting background tasks or network interfaces.

func (*SamNode) Authorize

func (n *SamNode) Authorize(rawToken []byte, req RequestContext, pubKey ed25519.PublicKey) error

func (*SamNode) CallMCPTool

func (n *SamNode) CallMCPTool(ctx context.Context, targetPeer peer.ID, toolName string, params any) (*mcp.CallToolResult, error)

CallMCPTool opens a stream to a remote peer, performs the handshake, and calls a tool.

func (*SamNode) ConnectAndAuthWithHub

func (n *SamNode) ConnectAndAuthWithHub(ctx context.Context, addr multiaddr.Multiaddr) error

func (*SamNode) ConnectMCPSession

func (n *SamNode) ConnectMCPSession(ctx context.Context, targetPeer peer.ID, targetService string) (*mcp.ClientSession, func(), error)

func (*SamNode) DiscoverEndpoints

func (n *SamNode) DiscoverEndpoints(ctx context.Context, issuerURL string) (tokenURL, authURL string, err error)

DiscoverEndpoints discovers both token and authorization endpoints.

func (*SamNode) DiscoverRemoteServices

func (n *SamNode) DiscoverRemoteServices(ctx context.Context, serviceType api.ServiceType, serviceName string) ([]*api.DiscoveredProvider, error)

DiscoverRemoteServices dispatches to the named or type-only path based on whether serviceName is provided.

func (*SamNode) DiscoverRemoteServicesStream

func (n *SamNode) DiscoverRemoteServicesStream(ctx context.Context, serviceType api.ServiceType, serviceName string) (<-chan *api.DiscoveredProvider, error)

DiscoverRemoteServicesStream performs service discovery and streams results down the returned channel. The channel is closed automatically when discovery completes or the context is cancelled.

func (*SamNode) DiscoverTokenURL

func (n *SamNode) DiscoverTokenURL(ctx context.Context, issuerURL string) (string, error)

DiscoverTokenURL discovers the token URL from the OIDC issuer.

func (*SamNode) Enroll

func (n *SamNode) Enroll(ctx context.Context, hubURL string, jwt string) error

func (*SamNode) EnrollBootstrap

func (n *SamNode) EnrollBootstrap(ctx context.Context, hubURL string, bootstrapToken string) error

EnrollBootstrap enrolls the node with the control plane using a pre-shared bootstrap token. If the enrollment status is PENDING, it polls the status endpoint until approved or rejected.

func (*SamNode) FetchJWT

func (n *SamNode) FetchJWT(ctx context.Context, tokenURL, clientID, clientSecret string) (string, error)

FetchJWT fetches a JWT token using the Client Credentials flow.

func (*SamNode) FindProvidersByName

func (n *SamNode) FindProvidersByName(ctx context.Context, serviceType api.ServiceType, serviceName string) ([]peer.AddrInfo, error)

FindProvidersByName returns peers hosting a specific {type, name} service.

func (*SamNode) FindProvidersByType

func (n *SamNode) FindProvidersByType(ctx context.Context, serviceType api.ServiceType) ([]peer.AddrInfo, error)

FindProvidersByType returns peers hosting at least one service of the given type.

func (*SamNode) GetIdentity

func (n *SamNode) GetIdentity() []byte

GetIdentity returns the node's biscuit identity, caching it in memory.

func (*SamNode) HandleAuthHandshake

func (n *SamNode) HandleAuthHandshake(s network.Stream)

HandleAuthHandshake is the core libp2p stream handler for /sam/auth/1.0.0. This is the "Admission Office" of the mesh node.

func (*SamNode) HandleMCPStream

func (n *SamNode) HandleMCPStream(s network.Stream, reqCtx RequestContext)

HandleMCPStream is the libp2p stream handler for the MCP protocol. It routes the authenticated stream to the appropriate backend service, or serves the internal MCP catalog if the TargetService is empty/catalog.

func (*SamNode) InteractiveLogin

func (n *SamNode) InteractiveLogin(ctx context.Context, authURL, tokenURL, clientID, audience string, requestRefresh bool, headless bool) (string, error)

InteractiveLogin prompts the user to go to a URL and enter a code.

func (*SamNode) IsConnected

func (n *SamNode) IsConnected() bool

func (*SamNode) IsServiceRegistered

func (n *SamNode) IsServiceRegistered(serviceName string) bool

func (*SamNode) ListLocalServices

func (n *SamNode) ListLocalServices(typeFilter api.ServiceType) []*api.ServiceInfo

ListLocalServices returns services registered on this node. If typeFilter is SERVICE_TYPE_UNSPECIFIED, all services are returned.

func (*SamNode) LoadHubConfig

func (n *SamNode) LoadHubConfig() ([]byte, []string, error)

func (*SamNode) LoadHubURL

func (n *SamNode) LoadHubURL() (string, error)

func (*SamNode) RefreshEnrollment

func (n *SamNode) RefreshEnrollment(ctx context.Context) error

RefreshEnrollment trades the expiring biscuit token for a new one using a cryptographic challenge.

func (*SamNode) RefreshJWT

func (n *SamNode) RefreshJWT(ctx context.Context, tokenURL, clientID, clientSecret, refreshToken string) (string, string, error)

RefreshJWT refreshes the OIDC token using the stored refresh token.

func (*SamNode) RegisterService

func (n *SamNode) RegisterService(ctx context.Context, req *api.RegisterServiceRequest) error

func (*SamNode) RegisterStaticServices

func (n *SamNode) RegisterStaticServices(ctx context.Context, services []api.ServiceConfig) error

func (*SamNode) SaveHubConfig

func (n *SamNode) SaveHubConfig(pubKey []byte, addrs []string) error

func (*SamNode) SetIdentityCache

func (n *SamNode) SetIdentityCache(b []byte)

SetIdentityCache explicitly updates the cached identity.

func (*SamNode) Start

func (n *SamNode) Start(ctx context.Context) error

Start initializes the libp2p host, DHT, connects to the hub, and starts runtime components.

func (*SamNode) StartIngressServer

func (n *SamNode) StartIngressServer(ctx context.Context) error

func (*SamNode) StartRenewalLoop

func (n *SamNode) StartRenewalLoop(ctx context.Context, issuerURL, clientID, clientSecret, jwtPath string)

func (*SamNode) Teardown

func (n *SamNode) Teardown() error

Teardown detaches all registered services and closes the libp2p host. Store is owned by the caller and is not closed here.

func (*SamNode) UnregisterService

func (n *SamNode) UnregisterService(ctx context.Context, serviceName string) error

func (*SamNode) UpdateRelays

func (n *SamNode) UpdateRelays(addrs []multiaddr.Multiaddr)

UpdateRelays updates the current relays used by AutoRelay.

func (*SamNode) VerifyBiscuitToken

func (n *SamNode) VerifyBiscuitToken(biscuitBytes []byte, reqCtx RequestContext) error

VerifyBiscuitToken checks revocation, cache, and evaluates the token against trusted keys and local policies.

func (*SamNode) WithBiscuitAuth

func (n *SamNode) WithBiscuitAuth(next func(network.Stream, RequestContext)) network.StreamHandler

WithBiscuitAuth enforces a Protobuf handshake on a stream before calling the next handler.

type SendMessageParams

type SendMessageParams struct {
	PeerID  string `json:"peer_id" jsonschema:"The Peer ID of the target agent"`
	Message string `json:"message" jsonschema:"The message content"`
}

SendMessageParams defines the parameters for the send_message tool.

type Service

type Service interface {
	Info() *api.ServiceInfo
	Init(ctx context.Context) error
	Handler() http.Handler
	Teardown() error
}

Service is the contract the ServiceRegistry and ingress server use. Implementations own all type-specific behaviour; the registry stays type-agnostic.

func NewServiceFromRequest

func NewServiceFromRequest(req *api.RegisterServiceRequest) (Service, error)

type ServiceRegistry

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

ServiceRegistry is the type-agnostic owner of registered services.

func NewServiceRegistry

func NewServiceRegistry(d dhtProvider) *ServiceRegistry

func (*ServiceRegistry) Get

func (r *ServiceRegistry) Get(name string) (Service, bool)

Get returns the service registered under name, if any.

func (*ServiceRegistry) List

func (r *ServiceRegistry) List(typeFilter api.ServiceType) []*api.ServiceInfo

List returns the ServiceInfo for every registered service, optionally filtered by type. SERVICE_TYPE_UNSPECIFIED means "all types."

func (*ServiceRegistry) Register

func (r *ServiceRegistry) Register(ctx context.Context, svc Service) error

Register initialises a service, advertises it on the DHT, and inserts it into the map. Init runs before Provide so a failed handler-build never briefly advertises an unservable name.

func (*ServiceRegistry) ReprovideAll

func (r *ServiceRegistry) ReprovideAll(ctx context.Context)

ReprovideAll re-provides all registered services to the DHT.

func (*ServiceRegistry) TeardownAll

func (r *ServiceRegistry) TeardownAll()

TeardownAll calls Teardown on every registered service and clears the map. Per-service errors are logged; iteration continues.

func (*ServiceRegistry) Unregister

func (r *ServiceRegistry) Unregister(ctx context.Context, name string) error

Unregister removes the service from the map and calls Teardown. Unknown names are a no-op.

type ServiceRequest

type ServiceRequest struct {
	ServiceName string `json:"service_name"`
}

type StdioBridge

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

func (*StdioBridge) Send

func (b *StdioBridge) Send(data []byte) error

Send writes data to the child's stdin, appending a newline.

func (*StdioBridge) ServeHTTP

func (b *StdioBridge) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*StdioBridge) Start

func (b *StdioBridge) Start()

func (*StdioBridge) Subscribe

func (b *StdioBridge) Subscribe() (<-chan string, func())

Subscribe registers a new subscriber channel for stdout lines and returns it along with an idempotent unsubscribe function. Buffered (cap 10); drops on slow consumers match the SSE behaviour in ServeHTTP.

type Store

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

func NewStore

func NewStore(dir string) (*Store, error)

func (*Store) Close

func (s *Store) Close() error

func (*Store) IsBanned

func (s *Store) IsBanned(p peer.ID) bool

IsBanned checks local store to see if this peer is banned.

func (*Store) LoadHubConfig

func (s *Store) LoadHubConfig() ([]byte, []string, error)

func (*Store) LoadHubURL

func (s *Store) LoadHubURL() (string, error)

func (*Store) LoadIdentity

func (s *Store) LoadIdentity() ([]byte, error)

func (*Store) LoadIdentityExpiration

func (s *Store) LoadIdentityExpiration() (int64, error)

func (*Store) LoadKey

func (s *Store) LoadKey() ([]byte, error)

func (*Store) LoadOIDCConfig

func (s *Store) LoadOIDCConfig() (string, string, string, error)

func (*Store) LoadRefreshToken

func (s *Store) LoadRefreshToken() (string, error)

func (*Store) SaveHubConfig

func (s *Store) SaveHubConfig(pubKey []byte, addrs []string) error

func (*Store) SaveHubURL

func (s *Store) SaveHubURL(url string) error

func (*Store) SaveIdentity

func (s *Store) SaveIdentity(biscuit []byte) error

func (*Store) SaveIdentityExpiration

func (s *Store) SaveIdentityExpiration(exp int64) error

func (*Store) SaveKey

func (s *Store) SaveKey(key []byte) error

func (*Store) SaveOIDCConfig

func (s *Store) SaveOIDCConfig(issuer, clientID, audience string) error

func (*Store) SaveRefreshToken

func (s *Store) SaveRefreshToken(token string) error

type StreamTransport

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

StreamTransport implements the mcp.Transport interface for a libp2p stream.

func NewStreamTransport

func NewStreamTransport(s network.Stream) *StreamTransport

NewStreamTransport creates a new StreamTransport for the given stream.

func (*StreamTransport) Close

func (t *StreamTransport) Close() error

Close closes the stream.

func (*StreamTransport) Connect

func (t *StreamTransport) Connect(ctx context.Context) (mcp.Connection, error)

Connect satisfies the mcp.Transport interface. For a stream, it's already connected.

func (*StreamTransport) Read

Read reads a message from the stream.

func (*StreamTransport) Send

func (t *StreamTransport) Send(data []byte) error

Send sends a message over the stream.

func (*StreamTransport) SessionID

func (t *StreamTransport) SessionID() string

SessionID satisfies the mcp.Connection interface.

func (*StreamTransport) Write

func (t *StreamTransport) Write(ctx context.Context, msg jsonrpc.Message) error

Write writes a message to the stream.

type SubscribeTopicParams

type SubscribeTopicParams struct {
	Topic string `json:"topic" jsonschema:"GossipSub topic name"`
}

SubscribeTopicParams defines the parameters for the subscribe_topic tool.

type TrustedKey

type TrustedKey struct {
	Key        ed25519.PublicKey
	ReceivedAt time.Time
}

Jump to

Keyboard shortcuts

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