agentclient

package
v0.0.46 Latest Latest
Warning

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

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

Documentation

Overview

Package agentclient provides a lightweight HTTP client for querying the klaus agent's /status endpoint. Unlike the MCP client, this does not require session initialization — it's a simple GET request.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StreamCompletion

func StreamCompletion(ctx context.Context, client *http.Client, baseURL, prompt string) (<-chan CompletionDelta, error)

StreamCompletion sends a prompt via POST /v1/chat/completions with stream=true and returns a channel of deltas. The channel is closed when the stream ends (either cleanly via [DONE] or due to an error).

func WaitForReady

func WaitForReady(ctx context.Context, client *http.Client, baseURL string) error

WaitForReady polls the agent's /status endpoint until it responds successfully or the context is cancelled. Uses exponential backoff from 1s to 5s with a hard 2-minute deadline.

Types

type AgentInfo

type AgentInfo struct {
	Status       string `json:"status"`
	SessionID    string `json:"session_id,omitempty"`
	MessageCount int    `json:"message_count,omitempty"`
}

AgentInfo holds the agent-level fields returned by the /status endpoint.

type CompletionDelta

type CompletionDelta struct {
	Content string
	Err     error
}

CompletionDelta is a single streaming delta from the completions endpoint. When the channel is closed the stream has ended. If the stream was interrupted by an I/O error (as opposed to a clean [DONE] or context cancellation), Err is set on the final delta before the channel closes.

type StatusResponse

type StatusResponse struct {
	Name    string    `json:"name"`
	Version string    `json:"version"`
	Agent   AgentInfo `json:"agent"`
	Mode    string    `json:"mode,omitempty"`
}

StatusResponse represents the JSON body returned by GET /status.

func FetchStatus

func FetchStatus(ctx context.Context, client *http.Client, baseURL string) (*StatusResponse, error)

FetchStatus queries the agent's HTTP /status endpoint and returns the parsed response. Returns an error if the agent is unreachable, returns a non-200 status, or returns invalid JSON.

Jump to

Keyboard shortcuts

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