agentsdk

package
v0.1.0 Latest Latest
Warning

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

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

README

Agent SDK

github.com/NeKiro-project/nekiro-sdk-go/agent is a small Go client for the managed Agent Router v1 nested invocation boundary. It carries the trusted platform context supplied by the managed transport, validates the untrusted target request, and performs one HTTP call through the Router.

The SDK does not implement a model, tool, workflow, memory, retry, cache, fallback route, or Agent Runtime. NewClient requires explicit response and SSE event byte limits; there are no size defaults. Use Invoke for JSON and InvokeStream for incremental SSE delivery. A stream must be consumed with Recv through io.EOF so the terminal event and sequence can be validated.

Router errors are accepted only when their media type, v4 Platform Error shape, trace header, HTTP status, and error code agree. The SDK exposes safe status/code/correlation fields through RouterError; it never exposes raw error response bytes.

Provider processes can use agent/registration/nacos to publish one exact Release-scoped Runtime instance under the same managed host lifecycle. That package composes Core-owned registration and lease mechanics; it does not let a Consumer discover or connect to a Provider directly.

Documentation

Overview

Package agentsdk provides a thin, runtime-neutral SDK for managed Agents to make nested invocations through the NeKiro A2A Router. It validates inherited platform context and sends exactly one request to the Agent Router v1 boundary. It contains no model, tool, workflow, memory, retry, cache, or Agent Runtime behavior.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is a thin SDK client for nested Router calls. Both limits are explicit deployment policy; no response or event-size default is supplied.

func NewClient

func NewClient(doer HTTPDoer, routerURL, token string, responseLimit, eventLimit int64) (*Client, error)

NewClient creates a nested invocation SDK client with explicit limits in bytes. The limits must be in the contract range 1..2147483647.

func (*Client) Invoke

Invoke sends one non-streaming nested invocation. Streaming requests must use InvokeStream so the caller can consume events incrementally.

func (*Client) InvokeStream

func (c *Client) InvokeStream(ctx context.Context, pc PlatformContext, nr NestedRequest) (*NestedResultStream, error)

InvokeStream sends one streaming nested invocation and returns a decoder over the live SSE body. Call Recv until io.EOF, then Close the stream.

type HTTPDoer

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

HTTPDoer is the minimal HTTP transport interface. The SDK performs exactly one request and does not follow redirects or retry.

type NestedRequest

type NestedRequest struct {
	TargetAgentID string
	Capability    string
	Input         json.RawMessage
	Stream        bool
}

NestedRequest carries the untrusted target work for a nested invocation. It contains only the fields permitted by the Agent Router v1 contract.

func (NestedRequest) Validate

func (nr NestedRequest) Validate() error

Validate checks that the NestedRequest fields are present and safe.

type NestedResult

type NestedResult struct {
	InvocationID string
	RootTaskID   string
	TraceID      string
	Status       string
	Result       json.RawMessage
}

NestedResult carries the response from a successful non-streaming nested invocation.

type NestedResultStream

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

NestedResultStream incrementally decodes and validates Agent Router SSE events. The child Invocation ID is learned from the first accepted event.

func (*NestedResultStream) Close

func (stream *NestedResultStream) Close() error

Close releases the response body. A stream that has not reached a valid terminal event is reported as interrupted rather than silently accepted.

func (*NestedResultStream) InvocationID

func (stream *NestedResultStream) InvocationID() string

InvocationID returns the child ID after the accepted event has been read.

func (*NestedResultStream) Recv

Recv reads and validates the next SSE event. io.EOF is returned only after a valid terminal event has been consumed and the stream has ended.

type PlatformContext

type PlatformContext struct {
	InvocationID string
	RootTaskID   string
	TraceID      string
	WorkspaceID  string
	AgentID      string
}

PlatformContext carries the trusted inherited Invocation identity presented by the managed transport. All fields are required safe identifiers; no value is inferred or synthesized.

func (PlatformContext) Validate

func (pc PlatformContext) Validate() error

Validate checks that all PlatformContext fields are present and safe identifiers. It fails without synthesizing identity or correlation.

type RouterError

type RouterError struct {
	StatusCode   int
	Code         contracts.PlatformErrorCode
	TraceID      contracts.TraceID
	InvocationID string
	RootTaskID   string
}

RouterError contains only validated safe error fields from the Agent Router. Raw response bytes are deliberately not retained or exposed.

func (*RouterError) Error

func (e *RouterError) Error() string

Directories

Path Synopsis
Package host provides the lifecycle boundary for a managed Agent Runtime.
Package host provides the lifecycle boundary for a managed Agent Runtime.
registration
nacos
Package nacos composes NeKiro Core registration primitives into a public Runtime-facing Nacos registration lifecycle.
Package nacos composes NeKiro Core registration primitives into a public Runtime-facing Nacos registration lifecycle.

Jump to

Keyboard shortcuts

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