Documentation
¶
Overview ¶
Package agentclient is the runtime-side client to the daemon's agent-to-agent linking RPCs. It exposes the four agent-facing calls the LLM tools (agent_list / agent_info / agent_chat / agent_exec) need; the daemon enforces "target ∈ JWT.Links" on every call.
Configuration parallels pkg/jobsclient — OTTERSD_URL + OTTERS_AGENT_TOKEN planted in the spawn env by the executor. Both clients share the underlying gRPC channel topology and auth shape; the package boundary just keeps each client focused on one daemon surface (jobs vs links) for readability.
Index ¶
- Constants
- type AgentCreateFromSourceInput
- type AgentCreateInput
- type AgentCreateResult
- type AgentInfoView
- type AgentView
- type Client
- func (c *Client) AgentCreate(ctx context.Context, in AgentCreateInput) (AgentCreateResult, error)
- func (c *Client) AgentCreateFromSource(ctx context.Context, in AgentCreateFromSourceInput) (AgentCreateResult, error)
- func (c *Client) AgentDelete(ctx context.Context, ref string) error
- func (c *Client) AgentExec(ctx context.Context, ref, prompt, sessionID string) (string, string, error)
- func (c *Client) AgentInfo(ctx context.Context, ref string) (AgentInfoView, error)
- func (c *Client) AgentList(ctx context.Context) ([]AgentView, error)
- func (c *Client) BinList(ctx context.Context) ([]ImageRowView, error)
- func (c *Client) Close() error
- func (c *Client) ImageList(ctx context.Context) ([]ImageRowView, error)
- func (c *Client) SelfReload(ctx context.Context) (bool, error)
- type Config
- type ImageRowView
Constants ¶
const ( EnvDaemonURL = "OTTERSD_URL" // EnvAgentToken is the spawn-env var that carries the agent's // JWT. The string is an env-var NAME, not a credential — the // actual token value lives only in process memory. EnvAgentToken = "OTTERS_AGENT_TOKEN" //nolint:gosec // G101: env var name, not a literal credential. )
Env names — same vars jobsclient reads. Re-exported so tests don't pull jobsclient in just for the constant.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AgentCreateFromSourceInput ¶
type AgentCreateFromSourceInput struct {
Agentfile string `json:"agentfile"`
Name string `json:"name,omitempty"`
Model string `json:"model,omitempty"`
Envs map[string]string `json:"envs,omitempty"`
Links []string `json:"links,omitempty"`
Description string `json:"description,omitempty"`
}
AgentCreateFromSourceInput carries an inline Agentfile body (utf-8 text) in place of a ref. All other fields mirror AgentCreateInput.
type AgentCreateInput ¶
type AgentCreateInput struct {
Ref string `json:"ref"`
Name string `json:"name,omitempty"`
Model string `json:"model,omitempty"`
Envs map[string]string `json:"envs,omitempty"`
Links []string `json:"links,omitempty"`
Description string `json:"description,omitempty"`
}
AgentCreateInput mirrors the proto AgentCreateRequest so the tool layer can pass typed values without re-importing daemonv1.
type AgentCreateResult ¶
type AgentCreateResult struct {
ID string `json:"id"`
Name string `json:"name"`
Status string `json:"status"`
}
AgentCreateResult is the trimmed daemon response surfaced to the LLM — id, name, status. Enough for the tool result; the caller follows up with agent_info / agent_exec when it needs more.
type AgentInfoView ¶
type AgentInfoView struct {
AgentView
Description string `json:"description,omitempty"`
Capabilities []string `json:"capabilities,omitempty"`
}
AgentInfoView is the richer payload for agent_info. Adds description (the target's `description` label) + the list of capabilities the target exposes so the calling agent can decide whether it's the right delegate.
type AgentView ¶
type AgentView struct {
ID string `json:"id"`
Name string `json:"name"`
Model string `json:"model"`
Status string `json:"status"`
}
AgentView is the agent-facing snapshot of one linked agent. Mirrors the proto LinkedAgent with JSON tags so the runtime can return it directly as the tool response payload.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps daemonv1.RuntimeClient with bearer-token injection and lazy dialing. Safe for concurrent use.
func (*Client) AgentCreate ¶
func (c *Client) AgentCreate(ctx context.Context, in AgentCreateInput) (AgentCreateResult, error)
AgentCreate spawns a new agent from an existing image ref. Equivalent to the operator's `otters run <ref>` flow but mounts aren't supported — that surface stays operator-only.
func (*Client) AgentCreateFromSource ¶
func (c *Client) AgentCreateFromSource( ctx context.Context, in AgentCreateFromSourceInput, ) (AgentCreateResult, error)
AgentCreateFromSource builds a fresh image from the inline Agentfile body and spawns an agent from it. The daemon tags the generated image with a recognizable `from-agent-<creator>:...` prefix so image_list can surface provenance.
func (*Client) AgentDelete ¶
AgentDelete removes an agent by ref. No creator-scope filter — any authenticated agent caller can delete any target.
func (*Client) AgentExec ¶
func (c *Client) AgentExec( ctx context.Context, ref, prompt, sessionID string, ) (string, string, error)
AgentExec sends a prompt to the target and blocks until the target's turn finishes. sessionID is optional; pass an empty string for a fresh session, or thread the returned id through subsequent calls to preserve history on the target. Returns (response, returnedSessionID, err).
(agent_chat existed as a separate threaded variant in alpha.82–.84; folded back into AgentExec in alpha.85 — one shape covers both use cases.)
func (*Client) AgentInfo ¶
AgentInfo returns the target's metadata + capabilities. PermissionDenied if the target isn't in the caller's JWT.Links.
func (*Client) AgentList ¶
AgentList returns every agent the caller is linked to. The daemon resolves the caller from the JWT — the request body has no agent_id field, so this is unspoofable.
func (*Client) BinList ¶
func (c *Client) BinList(ctx context.Context) ([]ImageRowView, error)
BinList returns the BIN-image catalogue.
func (*Client) ImageList ¶
func (c *Client) ImageList(ctx context.Context) ([]ImageRowView, error)
ImageList returns the agent-image catalogue.
func (*Client) SelfReload ¶
SelfReload re-issues the caller's JWT against the current link table and bounces the runtime. Side effect: kills the current LLM turn — the runtime process restarts, the in-flight RPC connection closes mid-response. Use as the last tool of a turn after agent_create with self-linking.