Documentation
¶
Overview ¶
Package agentkernel provides a Go client for the agentkernel HTTP API.
Zero external dependencies — uses only the standard library.
Index ¶
- func IsAuthError(err error) bool
- func IsNotFoundError(err error) bool
- func IsServerError(err error) bool
- func IsValidationError(err error) bool
- func ParseSSE(r io.Reader) <-chan StreamEvent
- type Client
- func (c *Client) CreateSandbox(ctx context.Context, name string, opts *CreateSandboxOptions) (*SandboxInfo, error)
- func (c *Client) ExecInSandbox(ctx context.Context, name string, command []string) (*RunOutput, error)
- func (c *Client) GetSandbox(ctx context.Context, name string) (*SandboxInfo, error)
- func (c *Client) Health(ctx context.Context) (string, error)
- func (c *Client) ListSandboxes(ctx context.Context) ([]SandboxInfo, error)
- func (c *Client) RemoveSandbox(ctx context.Context, name string) error
- func (c *Client) Run(ctx context.Context, command []string, opts *RunOptions) (*RunOutput, error)
- func (c *Client) RunStream(ctx context.Context, command []string, opts *RunOptions) (<-chan StreamEvent, error)
- func (c *Client) WithSandbox(ctx context.Context, name string, opts *CreateSandboxOptions, ...) error
- type CreateSandboxOptions
- type Error
- type Options
- type RunOptions
- type RunOutput
- type SandboxInfo
- type SandboxSession
- type SecurityProfile
- type StreamEvent
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsAuthError ¶
IsAuthError returns true if the error is an authentication error.
func IsNotFoundError ¶
IsNotFoundError returns true if the error is a not-found error.
func IsServerError ¶
IsServerError returns true if the error is a server error.
func IsValidationError ¶
IsValidationError returns true if the error is a validation error.
func ParseSSE ¶
func ParseSSE(r io.Reader) <-chan StreamEvent
ParseSSE reads SSE events from r and sends them on the returned channel. The channel is closed when the stream ends or an error occurs. Errors are returned as StreamEvent with Type "error".
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the agentkernel API client.
func New ¶
New creates a new agentkernel client.
Configuration is resolved in order: explicit options > environment variables > defaults.
client := agentkernel.New(nil) // defaults + env vars
client := agentkernel.New(&agentkernel.Options{ // explicit
BaseURL: "http://localhost:9090",
APIKey: "sk-...",
})
func (*Client) CreateSandbox ¶
func (c *Client) CreateSandbox(ctx context.Context, name string, opts *CreateSandboxOptions) (*SandboxInfo, error)
CreateSandbox creates a new sandbox.
func (*Client) ExecInSandbox ¶
func (c *Client) ExecInSandbox(ctx context.Context, name string, command []string) (*RunOutput, error)
ExecInSandbox executes a command in an existing sandbox.
func (*Client) GetSandbox ¶
GetSandbox returns info about a sandbox.
func (*Client) ListSandboxes ¶
func (c *Client) ListSandboxes(ctx context.Context) ([]SandboxInfo, error)
ListSandboxes returns all sandboxes.
func (*Client) RemoveSandbox ¶
RemoveSandbox removes a sandbox.
func (*Client) RunStream ¶
func (c *Client) RunStream(ctx context.Context, command []string, opts *RunOptions) (<-chan StreamEvent, error)
RunStream executes a command with SSE streaming output. Returns a channel of StreamEvent. The channel is closed when the stream ends.
func (*Client) WithSandbox ¶
func (c *Client) WithSandbox(ctx context.Context, name string, opts *CreateSandboxOptions, fn func(session *SandboxSession) error) error
WithSandbox creates a sandbox, passes a SandboxSession to fn, and removes the sandbox when fn returns — even if fn returns an error.
type CreateSandboxOptions ¶
type CreateSandboxOptions struct {
Image string `json:"image,omitempty"`
}
CreateSandboxOptions configures sandbox creation.
type Options ¶
type Options struct {
// BaseURL is the agentkernel server URL. Default: http://localhost:18888
BaseURL string
// APIKey is the optional API key for authentication.
APIKey string
// Timeout is the HTTP request timeout. Default: 30s.
Timeout time.Duration
// HTTPClient overrides the default http.Client. Useful for testing.
HTTPClient *http.Client
}
Options configures the agentkernel client.
type RunOptions ¶
type RunOptions struct {
Image string `json:"image,omitempty"`
Profile SecurityProfile `json:"profile,omitempty"`
Fast *bool `json:"fast,omitempty"`
}
RunOptions configures a run command.
type RunOutput ¶
type RunOutput struct {
Output string `json:"output"`
}
RunOutput is the result of a run or exec command.
type SandboxInfo ¶
type SandboxInfo struct {
Name string `json:"name"`
Status string `json:"status"`
Backend string `json:"backend,omitempty"`
}
SandboxInfo describes a sandbox.
type SandboxSession ¶
type SandboxSession struct {
// contains filtered or unexported fields
}
SandboxSession provides a handle to run commands in an existing sandbox. Used within the Client.WithSandbox callback.
func (*SandboxSession) Info ¶
func (s *SandboxSession) Info(ctx context.Context) (*SandboxInfo, error)
Info returns the sandbox's current info.
type SecurityProfile ¶
type SecurityProfile string
SecurityProfile controls sandbox permissions.
const ( ProfilePermissive SecurityProfile = "permissive" ProfileModerate SecurityProfile = "moderate" ProfileRestrictive SecurityProfile = "restrictive" )
type StreamEvent ¶
type StreamEvent struct {
Type string `json:"type"`
Data map[string]interface{} `json:"data,omitempty"`
}
StreamEvent is a server-sent event from a streaming run.