Documentation
¶
Overview ¶
Package daemonclient is the CLI's HTTP client for a running kram-daemon: creating sessions and sending messages. The CLI itself never persists anything or talks to an LLM provider — it's purely a view over what the daemon already owns.
Index ¶
- type Client
- func (c *Client) AnswerApproval(ctx context.Context, sessionID, approvalID, decision string) error
- func (c *Client) AnswerQuestion(ctx context.Context, sessionID, questionID, answer string) error
- func (c *Client) CreateSession(ctx context.Context, title string) (Session, error)
- func (c *Client) GetContext(ctx context.Context, sessionID string) (ContextUsage, error)
- func (c *Client) GetSession(ctx context.Context, id string) (Session, []Message, error)
- func (c *Client) ListSessions(ctx context.Context) ([]Session, error)
- func (c *Client) ListTools(ctx context.Context) ([]ToolInfo, []Skill, error)
- func (c *Client) SendMessageStream(ctx context.Context, sessionID, content string, images []string) (*MessageStream, error)
- type ContextCategory
- type ContextUsage
- type Message
- type MessageStream
- type RouteCall
- type RouteTrace
- type Session
- type Skill
- type StreamEvent
- type ToolActivity
- type ToolInfo
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 talks to a kram-daemon instance.
func New ¶
New builds a client pointed at a running daemon (e.g. http://127.0.0.1:20130).
func (*Client) AnswerApproval ¶
AnswerApproval delivers a decision ("once", "always", or "deny") to a pending permission-policy approval — same blocking shape as AnswerQuestion, but a distinct endpoint/id space (see server.go).
func (*Client) AnswerQuestion ¶
AnswerQuestion delivers an answer to a pending ask_question call — the SSE stream that produced the "question" event stays open and blocked server-side the whole time; this is a separate HTTP request that unblocks it, not a message sent over the stream itself.
func (*Client) CreateSession ¶
CreateSession starts a new session with the given title.
func (*Client) GetContext ¶
GetContext fetches a session's current context-window usage breakdown.
func (*Client) GetSession ¶
GetSession returns a session and its full message history.
func (*Client) ListSessions ¶
ListSessions returns every known session, most recently active first.
func (*Client) ListTools ¶
ListTools fetches every registered tool and discovered skill from the daemon, enabled or not — the source of truth the toggle screen renders from, rather than a hardcoded duplicate list in the CLI.
func (*Client) SendMessageStream ¶
func (c *Client) SendMessageStream(ctx context.Context, sessionID, content string, images []string) (*MessageStream, error)
SendMessageStream posts a user message (with optional image data: URLs) and returns a live stream of what the agent loop does to answer it — text deltas as they're generated, tool activity, notices, ending in one "done" (or "error") event.
type ContextCategory ¶
ContextCategory is one real contributor to a session's context-window usage.
type ContextUsage ¶
type ContextUsage struct {
Budget int `json:"budget"`
Used int `json:"used"`
Free int `json:"free"`
Categories []ContextCategory `json:"categories"`
}
ContextUsage is a session's current context-window breakdown.
type Message ¶
type Message struct {
ID int64 `json:"id"`
SessionID string `json:"session_id"`
Role string `json:"role"`
Content string `json:"content"`
Provider string `json:"provider,omitempty"`
CreatedAt int64 `json:"created_at"`
}
Message mirrors the daemon's persisted message shape.
type MessageStream ¶
type MessageStream struct {
// contains filtered or unexported fields
}
MessageStream is an open connection to a running agent turn — read it with Next until it reports done, then Close it.
func (*MessageStream) Close ¶
func (s *MessageStream) Close() error
Close releases the underlying HTTP connection.
func (*MessageStream) Next ¶
func (s *MessageStream) Next() (evt StreamEvent, done bool, err error)
Next blocks until the next SSE event arrives. done is true once the stream has logically ended (a "done"/"error" event, EOF, or a read error) — the caller should stop calling Next at that point, though it remains safe to call again (it will just report done with a zero event).
type RouteCall ¶
type RouteCall struct {
Index int `json:"index"`
Combo string `json:"combo"`
Strategy string `json:"strategy"`
Attempts []openai.AttemptInfo `json:"attempts"`
Ranking []openai.RankedProviderInfo `json:"ranking,omitempty"`
Winner string `json:"winner,omitempty"`
}
RouteCall mirrors agent.RouteCall — one model call's full routing story within a run.
type RouteTrace ¶
type RouteTrace struct {
Combo string `json:"combo"`
Strategy string `json:"strategy"`
Calls []RouteCall `json:"calls"`
}
RouteTrace mirrors agent.RouteTrace — every model call a run made, in order, each with its own complete fallback trail. Distinct from StreamEvent.Attempts (the last call's trail only, kept for the simple footer view): RouteTrace is what a full route-trace UI (Ctrl+R) needs.
type Session ¶
type Session struct {
ID string `json:"id"`
Title string `json:"title"`
CreatedAt int64 `json:"created_at"`
UpdatedAt int64 `json:"updated_at"`
}
Session mirrors the daemon's persisted session shape.
type Skill ¶
type Skill struct {
Name string `json:"name"`
Description string `json:"description"`
Scope string `json:"scope"`
Disabled bool `json:"disabled"`
}
Skill mirrors the daemon's tools.Skill.
type StreamEvent ¶
type StreamEvent struct {
Type string `json:"type"`
Content string `json:"content,omitempty"`
Name string `json:"name,omitempty"`
Args string `json:"args,omitempty"`
Result string `json:"result,omitempty"`
OK bool `json:"ok,omitempty"`
Text string `json:"text,omitempty"`
QuestionID string `json:"question_id,omitempty"`
Question string `json:"question,omitempty"`
Options []string `json:"options,omitempty"`
ApprovalID string `json:"approval_id,omitempty"`
Tool string `json:"tool,omitempty"`
Subject string `json:"subject,omitempty"`
RouteCall *RouteCall `json:"route_call,omitempty"`
Message Message `json:"message,omitempty"`
Attempts []openai.AttemptInfo `json:"attempts,omitempty"`
RouteTrace RouteTrace `json:"route_trace,omitempty"`
Usage openai.Usage `json:"usage,omitempty"`
ToolActivity []ToolActivity `json:"tool_activity,omitempty"`
Compactions int `json:"compactions,omitempty"`
ImageNotice string `json:"image_notice,omitempty"`
Error string `json:"error,omitempty"`
}
StreamEvent is one event from a message stream. Type selects which other fields are meaningful: "delta" (Content), "tool_start" (Name, Args), "tool_result" (Name, Result, OK), "notice" (Text), "question" (QuestionID, Question, Options), "approval" (ApprovalID, Tool, Subject, Options), "route_start" (none), "route_done" (RouteCall), "done" (Message, Attempts, RouteTrace, Usage, ToolActivity, Compactions, ImageNotice), or "error" (Error).
type ToolActivity ¶
type ToolActivity struct {
Name string `json:"name"`
Args string `json:"args"`
Result string `json:"result"`
OK bool `json:"ok"`
Running bool `json:"-"`
}
ToolActivity mirrors one tool call the daemon's agent loop made while producing this reply. Running is CLI-only UI state (never sent over the wire) — true from the moment a tool_start event arrives until its matching tool_result lands.