client

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StringField

func StringField(m map[string]any, keys ...string) string

StringField extracts a nested string value from a map.

Types

type AgentDetail

type AgentDetail map[string]any

AgentDetail is the full agent object returned by the API.

type AgentSummary

type AgentSummary struct {
	Name    string `json:"name"`
	Model   string `json:"model,omitempty"`
	Runtime string `json:"runtime,omitempty"`
	Active  int    `json:"activeTasks"`
}

AgentSummary is a lightweight representation of an agent for list display.

type ArtifactMetadata

type ArtifactMetadata struct {
	Filename    string `json:"filename"`
	ContentType string `json:"contentType"`
	Size        int64  `json:"size"`
	CreatedAt   string `json:"createdAt"`
}

ArtifactMetadata describes a stored artifact.

type ChatConfigResponse

type ChatConfigResponse struct {
	Enabled        bool     `json:"enabled"`
	Provider       string   `json:"provider"`
	Model          string   `json:"model"`
	AvailableTools []string `json:"availableTools"`
}

ChatConfigResponse is the response from GET /api/v1/chat/config.

type ChatRequest

type ChatRequest struct {
	Message   string `json:"message"`
	SessionID string `json:"sessionId,omitempty"`
	Namespace string `json:"namespace,omitempty"`
	Agent     string `json:"agentRef,omitempty"`
	Model     string `json:"model,omitempty"`
	Provider  string `json:"provider,omitempty"`
}

ChatRequest is the request body for POST /api/v1/chat.

type ChatUsage

type ChatUsage struct {
	InputTokens  int `json:"inputTokens"`
	OutputTokens int `json:"outputTokens"`
}

ChatUsage holds token usage statistics from a chat response.

type Client

type Client struct {
	BaseURL    string
	Token      string
	TxnToken   string
	Namespace  string
	HTTPClient *http.Client
}

Client is an HTTP client for the Orka API.

func NewWithNamespace

func NewWithNamespace(baseURL, token, namespace string) *Client

NewWithNamespace creates a new Orka API client with a default namespace.

func (*Client) AuthValidate

func (c *Client) AuthValidate(ctx context.Context) (any, error)

AuthValidate validates the current credentials.

func (*Client) AuthWhoAmI

func (c *Client) AuthWhoAmI(ctx context.Context) (any, error)

AuthWhoAmI returns the sanitized authenticated identity.

func (*Client) CreateSkill

func (c *Client) CreateSkill(ctx context.Context, body []byte) (*SkillDetail, error)

CreateSkill creates a new skill via the API.

func (*Client) CreateTaskRaw

func (c *Client) CreateTaskRaw(ctx context.Context, body []byte) (*TaskDetail, error)

CreateTaskRaw creates a task from a JSON request body.

func (*Client) DeleteAgent

func (c *Client) DeleteAgent(ctx context.Context, name string, opts GetOptions) error

DeleteAgent deletes an agent by name.

func (*Client) DeleteResource

func (c *Client) DeleteResource(ctx context.Context, path string, query map[string]string) error

DeleteResource deletes a resource path.

func (*Client) DeleteSkill

func (c *Client) DeleteSkill(ctx context.Context, name string, opts GetOptions) error

DeleteSkill deletes a skill by name.

func (*Client) DeleteTask

func (c *Client) DeleteTask(ctx context.Context, name string, opts GetOptions) error

DeleteTask deletes a task by name.

func (*Client) DoJSON

func (c *Client) DoJSON(ctx context.Context, method, path string, query map[string]string, body []byte) (any, error)

DoJSON sends an HTTP request with an optional JSON body and decodes the JSON response into a generic value.

func (*Client) DownloadArtifact

func (c *Client) DownloadArtifact(
	ctx context.Context,
	taskName, filename string,
	opts GetOptions,
) ([]byte, string, error)

DownloadArtifact downloads a specific artifact and returns the raw bytes and content type.

func (*Client) GetAgent

func (c *Client) GetAgent(ctx context.Context, name string, opts GetOptions) (*AgentDetail, error)

GetAgent returns full details for a single agent.

func (*Client) GetChatConfig

func (c *Client) GetChatConfig(ctx context.Context) (*ChatConfigResponse, error)

GetChatConfig fetches the chat configuration from the server.

func (*Client) GetRaw

func (c *Client) GetRaw(ctx context.Context, path string, query map[string]string) ([]byte, string, error)

GetRaw gets a raw response body and content type.

func (*Client) GetSkill

func (c *Client) GetSkill(ctx context.Context, name string, opts GetOptions) (*SkillDetail, error)

GetSkill returns full details for a single skill.

func (*Client) GetTask

func (c *Client) GetTask(ctx context.Context, name string, opts GetOptions) (*TaskDetail, error)

GetTask returns full details for a single task.

func (*Client) GetTaskChildren

func (c *Client) GetTaskChildren(ctx context.Context, name string, opts GetOptions) (any, error)

GetTaskChildren gets child tasks for a task as a generic list response.

func (*Client) GetTaskLogs

func (c *Client) GetTaskLogs(ctx context.Context, name string, opts GetOptions) (*TaskLogsResponse, error)

GetTaskLogs gets logs for a task.

func (*Client) GetTaskPlan

func (c *Client) GetTaskPlan(ctx context.Context, name string, opts GetOptions) (any, error)

GetTaskPlan gets the plan for a task as a generic JSON value.

func (*Client) GetTaskResult

func (c *Client) GetTaskResult(ctx context.Context, name string, opts GetOptions) (*TaskResultResponse, error)

GetTaskResult gets the result of a task.

func (*Client) HealthCheck

func (c *Client) HealthCheck(ctx context.Context) (bool, error)

HealthCheck calls GET /healthz and returns true if healthy.

func (*Client) ListAgents

func (c *Client) ListAgents(ctx context.Context, opts ListOptions) ([]AgentSummary, error)

ListAgents returns all agents from the API.

func (*Client) ListArtifacts

func (c *Client) ListArtifacts(ctx context.Context, taskName string, opts GetOptions) ([]ArtifactMetadata, error)

ListArtifacts returns artifacts for a task.

func (*Client) ListModels

func (c *Client) ListModels(ctx context.Context, compat string) (any, error)

ListModels lists compatibility models for the requested API compatibility surface.

func (*Client) ListSkills

func (c *Client) ListSkills(ctx context.Context, opts ListOptions) ([]SkillSummary, error)

ListSkills returns all skills from the API.

func (*Client) ListTasks

func (c *Client) ListTasks(ctx context.Context, opts ListTasksOptions) ([]TaskSummary, error)

ListTasks returns tasks from the API.

func (*Client) ListTasksPage

func (c *Client) ListTasksPage(ctx context.Context, opts ListTasksOptions) (*ListTasksResult, error)

ListTasksPage returns one task page from the API, including pagination metadata.

func (*Client) ReadyCheck

func (c *Client) ReadyCheck(ctx context.Context) (bool, error)

ReadyCheck calls GET /readyz and returns true if ready.

func (*Client) Stream

func (c *Client) Stream(ctx context.Context, path string, query map[string]string) (io.ReadCloser, error)

Stream opens a streaming GET request for Server-Sent Events. The caller must close the returned body.

func (*Client) StreamChat

func (c *Client) StreamChat(ctx context.Context, req ChatRequest) (*SSEReader, *http.Response, error)

StreamChat sends a chat message and returns an SSE reader for streaming the response.

func (*Client) StreamTaskLogs

func (c *Client) StreamTaskLogs(ctx context.Context, name string, opts StreamLogsOptions) error

StreamTaskLogs streams live logs for a running task via SSE.

type CreateTaskRequest

type CreateTaskRequest struct {
	Name      string   `json:"name"`
	Namespace string   `json:"namespace"`
	Type      string   `json:"type"`
	Image     string   `json:"image,omitempty"`
	Command   []string `json:"command,omitempty"`
	Args      []string `json:"args,omitempty"`
	Env       []struct {
		Name  string `json:"name"`
		Value string `json:"value,omitempty"`
	} `json:"env,omitempty"`
	Priority *int32  `json:"priority,omitempty"`
	Prompt   string  `json:"prompt,omitempty"`
	Timeout  string  `json:"timeout,omitempty"`
	Schedule string  `json:"schedule,omitempty"`
	TimeZone *string `json:"timeZone,omitempty"`
	Suspend  *bool   `json:"suspend,omitempty"`
	AgentRef *struct {
		Name string `json:"name"`
	} `json:"agentRef,omitempty"`
	AgentRuntime *corev1alpha1.AgentRuntimeSpec `json:"agentRuntime,omitempty"`
	AI           *struct {
		ProviderRef *struct {
			Name string `json:"name"`
		} `json:"providerRef,omitempty"`
		Model  string `json:"model,omitempty"`
		Prompt string `json:"prompt,omitempty"`
	} `json:"ai,omitempty"`
}

CreateTaskRequest is the request body for creating a task.

type GetOptions

type GetOptions struct {
	Namespace string
}

GetOptions contains options for get operations.

type ListOptions

type ListOptions struct {
	Namespace string
}

ListOptions contains options for list operations.

type ListTasksOptions

type ListTasksOptions struct {
	Namespace string
	Limit     int
	Continue  string
	All       bool
}

ListTasksOptions contains options for listing tasks.

type ListTasksResult

type ListTasksResult struct {
	Items              []TaskSummary
	Continue           string
	RemainingItemCount *int64
}

ListTasksResult contains a page of task summaries and pagination metadata.

type SSEEvent

type SSEEvent struct {
	Event string
	Data  string
}

SSEEvent represents a parsed Server-Sent Event.

type SSEEventData

type SSEEventData struct {
	// status event
	SessionID string `json:"sessionId,omitempty"`

	// message event
	Content string `json:"content,omitempty"`

	// tool_call / tool_result event
	Name string          `json:"name,omitempty"`
	Args json.RawMessage `json:"args,omitempty"`

	// tool_result event — raw JSON (may be object or string)
	Result json.RawMessage `json:"result,omitempty"`

	// error event
	Error string `json:"error,omitempty"`

	// done event
	Usage *ChatUsage `json:"usage,omitempty"`
}

SSEEventData holds the parsed data payload from an SSE event.

type SSEReader

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

SSEReader reads Server-Sent Events from a stream.

func NewSSEReader

func NewSSEReader(r io.Reader) *SSEReader

NewSSEReader creates a new SSE reader from an io.Reader.

func (*SSEReader) Err

func (r *SSEReader) Err() error

Err returns any error from the underlying scanner.

func (*SSEReader) Next

func (r *SSEReader) Next() (SSEEvent, bool)

Next reads the next SSE event from the stream. Returns the event and true if an event was read, or a zero value and false at EOF.

type SkillDetail

type SkillDetail map[string]any

SkillDetail is the full skill object returned by the API.

type SkillSummary

type SkillSummary struct {
	Name        string   `json:"name"`
	DisplayName string   `json:"displayName,omitempty"`
	Description string   `json:"description"`
	Version     string   `json:"version,omitempty"`
	Author      string   `json:"author,omitempty"`
	Tags        []string `json:"tags,omitempty"`
	Phase       string   `json:"phase,omitempty"`
}

SkillSummary is a lightweight representation of a skill for list display.

type StreamLogsOptions

type StreamLogsOptions struct {
	Namespace string
	Writer    io.Writer
}

StreamLogsOptions contains options for streaming task logs.

type TaskDetail

type TaskDetail map[string]any

TaskDetail is the full task object returned by the API.

type TaskLogsResponse

type TaskLogsResponse struct {
	Logs    string `json:"logs,omitempty"`
	Message string `json:"message,omitempty"`
	JobName string `json:"jobName,omitempty"`
}

TaskLogsResponse is the response for getting task logs.

type TaskResultResponse

type TaskResultResponse struct {
	Result string `json:"result"`
}

TaskResultResponse is the response for getting task results.

type TaskSummary

type TaskSummary struct {
	Name          string `json:"name" yaml:"name"`
	Namespace     string `json:"namespace,omitempty" yaml:"namespace,omitempty"`
	Type          string `json:"type,omitempty" yaml:"type,omitempty"`
	Phase         string `json:"phase,omitempty" yaml:"phase,omitempty"`
	Age           string `json:"age,omitempty" yaml:"age,omitempty"`
	Iteration     int    `json:"iteration,omitempty" yaml:"iteration,omitempty"`
	TransactionID string `json:"transactionId,omitempty" yaml:"transactionId,omitempty"`
	ParentTask    string `json:"parentTask,omitempty" yaml:"parentTask,omitempty"`
}

TaskSummary is a lightweight representation of a task for list display.

Jump to

Keyboard shortcuts

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