Documentation
¶
Overview ¶
Package agents mounts the Hanzo Cloud /v1/agents surface: per-org autonomous agent definitions and their runs. An agent is a model + a system prompt (instructions) + a set of tool names; running one executes a real chat completion through the in-process AI client (the SAME gateway path the rest of the console uses) and records the run. Tenant isolation is the gateway-minted X-Org-Id (HIP-0026) enforced as the org column on every query, so one tenant can never read, run, or delete another's agents.
Surface (all org-scoped; console2's AgentsModule reads {agents:[...]}):
GET /v1/agents list agents for the org -> {agents:[...]}
POST /v1/agents create an agent -> Agent
GET /v1/agents/:name agent detail + recent runs -> AgentDetail
PATCH /v1/agents/:name update an agent -> Agent
DELETE /v1/agents/:name delete an agent (+ its runs)
POST /v1/agents/:name/run run the agent {input} -> RunResult
GET /v1/agents/:name/runs run history -> {runs:[...]}
The store is SQLite in deps.DataDir (Base/SQLite-only). It holds definitions and run I/O only — never a secret; tool credentials live in KMS by reference.
Index ¶
- func Mount(app *zip.App, deps cloud.Deps) error
- func Shutdown() error
- type Agent
- type Run
- type Store
- func (s *Store) Close() error
- func (s *Store) CountRuns(ctx context.Context, org, agent string) (int, error)
- func (s *Store) Create(ctx context.Context, a Agent) error
- func (s *Store) Delete(ctx context.Context, org, name string) (bool, error)
- func (s *Store) Get(ctx context.Context, org, name string) (Agent, error)
- func (s *Store) InsertRun(ctx context.Context, r Run) error
- func (s *Store) List(ctx context.Context, org string) ([]Agent, error)
- func (s *Store) ListRuns(ctx context.Context, org, agent string, limit int) ([]Run, error)
- func (s *Store) Update(ctx context.Context, a Agent) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Agent ¶
type Agent struct {
ID string
Org string
Name string
Model string
Instructions string
Description string
Tools []string
Status string
CreatedAt int64
UpdatedAt int64
}
Agent is the org-scoped definition of an autonomous worker: a model, a system prompt (instructions), and a set of tool names it may call. Tenant isolation is the org column, enforced on every query. It never stores a secret — tool credentials live in KMS and are referenced by name at run time.
type Run ¶
type Run struct {
ID string
Org string
AgentName string
Status string
Model string
Input string
Output string
Error string
DurationMs int64
CreatedAt int64
}
Run is one execution of an agent: the input, the produced output (or error), which model served it, and how long it took. Real history — every row is a call that actually happened.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is the agents database. ONE SQLite file ({DataDir}/agents.db) holds every org's records; tenancy is the org column.
func (*Store) Create ¶
Create inserts one agent. A UNIQUE(org,name) violation surfaces as errConflict.