Documentation
¶
Overview ¶
Package api is Smif's wire protocol: newline-delimited JSON-RPC 2.0 over a Unix socket (RFC 5.4), plus the request and response types of every method in RFC 7.1.
Index ¶
- Constants
- func IsCode(err error, code int) bool
- func ShortSession(id string) string
- type AgentView
- type AuditEvent
- type AuditPage
- type AuditParams
- type Auth
- type AwaitParams
- type AwaitResult
- type BlobGetResult
- type BlobPutParams
- type Caller
- type CancelResult
- type Client
- type ClosedList
- type ClosedSession
- type Counts
- type CountsParams
- type DigestItem
- type DigestParams
- type DigestResult
- type Error
- type GCResult
- type Handler
- type HealthView
- type HistoryRow
- type HumanReplyParams
- type IDParams
- type ListParams
- type MessageView
- type Metrics
- type PresenceParams
- type ProviderCheck
- type QueuedPrompt
- type ReplyView
- type Request
- type Response
- type RunView
- type SavedPrompt
- type SearchHit
- type SendParams
- type SendResult
- type Server
- type SessionActivity
- type SessionAttachParams
- type SessionFacts
- type SessionFocusParams
- type SessionNewParams
- type SessionPromptParams
- type SessionPromptResult
- type SessionQueueCancelParams
- type SessionQueueParams
- type SessionQueueResult
- type SessionReopenParams
- type SessionReopenResult
- type SessionResumeParams
- type SessionSearchParams
- type SessionSearchResult
- type SessionSendParams
- type SessionSendResult
- type SessionStats
- type SessionStep
- type SessionTail
- type SessionTailParams
- type SessionTurn
- type SessionView
- type StatsParams
- type StatsResult
- type StatsRow
- type StatusView
- type ThreadView
Constants ¶
const ( CodeParse = -32700 CodeInvalid = -32600 CodeNoMethod = -32601 CodeParams = -32602 CodeInternal = -32603 CodeAuth = -32001 CodeForbidden = -32002 CodeRejected = -32003 CodeNotFound = -32004 CodeVersion = -32006 CodeRateLimited = -32007 )
Error codes. Negative numbers below -32000 are server-defined.
const ( // CancelRejected: the item was queued, waiting or needs_human and is // rejected now (reason "cancelled"). CancelRejected = "rejected" // CancelCancelling: the item is running; its worker is told to stop // and the item stays running until the run ends (read thread.get). CancelCancelling = "cancelling" )
Values of CancelResult.State.
const MaxLine = 40 << 20
MaxLine caps one request or response line (a 25 MiB attachment in base64 plus framing).
const ProtocolVersion = "1.0"
ProtocolVersion is sent with every request; the major part must match.
Variables ¶
This section is empty.
Functions ¶
func ShortSession ¶
ShortSession is the first 8 characters of a Claude Code session id (a UUID), as `claude --resume` users know it.
Types ¶
type AgentView ¶
type AgentView struct {
ID string `json:"id"`
Repo string `json:"repo"`
Intents []string `json:"intents"`
Queued int `json:"queued"`
Running int `json:"running"`
NeedsHuman int `json:"needs_human"`
DeadLetters int `json:"dead_letters"`
BudgetUSD float64 `json:"budget_usd,omitempty"`
SpentUSD float64 `json:"spent_usd_today"`
TokensToday int64 `json:"tokens_today"`
BudgetLeft *float64 `json:"budget_left_usd,omitempty"`
Interactive bool `json:"interactive_session"`
}
AgentView is agent.list.
type AuditEvent ¶
type AuditEvent struct {
Seq int64 `json:"seq"`
TS time.Time `json:"ts"`
Event string `json:"event"`
Agent string `json:"agent,omitempty"`
MessageID string `json:"message_id,omitempty"`
RunID string `json:"run_id,omitempty"`
ThreadID string `json:"thread_id,omitempty"`
Detail map[string]any `json:"detail,omitempty"`
}
AuditEvent is one audit row (the same fields as the JSONL log).
type AuditPage ¶
type AuditPage struct {
Events []AuditEvent `json:"events"`
// Cursor is the After of the next call.
Cursor int64 `json:"cursor"`
// Head is the newest seq in the table. Head < the caller's cursor
// means a new database: start again with FromEnd.
Head int64 `json:"head"`
// More is true when rows after Cursor exist already.
More bool `json:"more"`
}
AuditPage is the audit.since result.
type AuditParams ¶
type AuditParams struct {
// After is the cursor: rows with seq > After.
After int64 `json:"after"`
// Limit caps the rows (default 200, max 1000).
Limit int `json:"limit,omitempty"`
// FromEnd returns the newest Limit rows instead (Limit 0: none) and a
// cursor at the head, so a follower starts at "now".
FromEnd bool `json:"from_end,omitempty"`
}
AuditParams is audit.since: audit rows after a cursor (human only, ADR-0008).
type Auth ¶
type Auth struct {
Agent string `json:"agent"`
Token string `json:"token"`
Origin string `json:"origin,omitempty"`
}
Auth identifies the caller.
type AwaitParams ¶
AwaitParams is message.await.
type AwaitResult ¶
type AwaitResult struct {
Ticket string `json:"ticket"`
Status string `json:"status"` // pending | answered
State string `json:"state"`
Reply *ReplyView `json:"reply,omitempty"`
}
AwaitResult carries the reply when it is in.
type BlobGetResult ¶
type BlobGetResult struct {
SHA256 string `json:"sha256"`
Size int64 `json:"size"`
MIME string `json:"mime"`
Data []byte `json:"data"`
}
BlobGetResult returns blob bytes.
type BlobPutParams ¶
type BlobPutParams struct {
Name string `json:"name"`
MIME string `json:"mime,omitempty"`
Data []byte `json:"data"` // base64 in JSON
}
BlobPutParams uploads an attachment.
type CancelResult ¶
CancelResult is the response of message.cancel: the state the item has after the call (ADR-0009).
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a connection to the daemon.
type ClosedList ¶ added in v0.2.0
type ClosedList struct {
Sessions []ClosedSession `json:"sessions"`
Reopening bool `json:"reopening,omitempty"`
Why string `json:"why,omitempty"`
}
ClosedList is session.closed: the restore list, newest first. Reopening is true while session.reopen works through it. Why says what the last reopen could not do.
type ClosedSession ¶ added in v0.2.0
type ClosedSession struct {
SessionID string `json:"session_id"`
Dir string `json:"dir"`
Name string `json:"name,omitempty"`
ClosedAt time.Time `json:"closed_at"`
// DiedWorking marks a session that was busy at the last look.
DiedWorking bool `json:"died_working,omitempty"`
}
ClosedSession is one session on the restore list: its process went away and the human did not close it alone (ADR-0021).
type Counts ¶
type Counts struct {
Agent string `json:"agent,omitempty"`
Running int `json:"running"`
Queued int `json:"queued"`
Handled int `json:"handled"`
NeedsHuman int `json:"needs_human"`
RepliesReady int `json:"replies_ready"`
DirectLock bool `json:"direct_lock,omitempty"`
GlobalNeedsHuman int `json:"global_needs_human"`
GlobalDLQ int `json:"global_dlq"`
ClaudeOK bool `json:"claude_ok"`
// The other live sessions that need the human (human callers only,
// ADR-0014): the names of those that wait in their tab, and of those
// with an answer the human has not seen (the UI's seen file).
SessionsWaiting []string `json:"sessions_waiting,omitempty"`
SessionsAnswered []string `json:"sessions_answered,omitempty"`
}
Counts is inbox.counts and smif_status.
type CountsParams ¶
type CountsParams struct {
Cwd string `json:"cwd,omitempty"`
Agent string `json:"agent,omitempty"`
// SessionID is the asking session (the status line): it is left out of
// SessionsWaiting and SessionsAnswered.
SessionID string `json:"session_id,omitempty"`
}
CountsParams is inbox.counts.
type DigestItem ¶
type DigestItem struct {
MessageID string `json:"message_id"`
ThreadID string `json:"thread_id"`
Agent string `json:"agent"`
From string `json:"from"`
Kind string `json:"kind"`
Intent string `json:"intent"`
Subject string `json:"subject"`
State string `json:"state"`
Summary string `json:"summary,omitempty"`
HumanQuestion string `json:"human_question,omitempty"`
Coalesced int `json:"coalesced_count,omitempty"`
Branch string `json:"branch,omitempty"`
RunID string `json:"run_id,omitempty"`
At time.Time `json:"at"`
}
DigestItem is one handled item.
type DigestParams ¶
type DigestParams struct {
Agent string `json:"agent,omitempty"`
Cwd string `json:"cwd,omitempty"`
Since string `json:"since,omitempty"` // "last" (default) or "all"
Advance bool `json:"advance"`
Limit int `json:"limit,omitempty"`
// Until, when above 0, keeps the items and the cursor advance at or
// below this handled seq (a DigestResult.Cursor the caller already
// showed), so items handled later are not marked read (ADR-0008).
Until int64 `json:"until,omitempty"`
}
DigestParams is digest.get.
type DigestResult ¶
type DigestResult struct {
Agents []string `json:"agents"`
Items []DigestItem `json:"items"`
Cursor int64 `json:"cursor"`
}
DigestResult is digest.get.
type GCResult ¶
type GCResult struct {
Messages int `json:"messages_deleted"`
Runs int `json:"runs_deleted"`
Transcripts int `json:"transcripts_deleted"`
Blobs int `json:"blobs_deleted"`
Branches int `json:"branches_deleted"`
AuditFiles int `json:"audit_files_compressed"`
Logs int `json:"logs_deleted"`
}
GCResult reports admin.gc.
type HealthView ¶
type HealthView struct {
OK bool `json:"ok"`
Version string `json:"version"`
SchemaVersion int `json:"schema_version"`
DB string `json:"db"`
ClaudeVersion string `json:"claude_version"`
ClaudeOK bool `json:"claude_ok"`
ClaudeProblems []string `json:"claude_problems,omitempty"`
FlagProbe []string `json:"flag_probe,omitempty"`
// Sessions checks the Claude Code files the session view reads (session
// files, transcripts; not a documented interface, ADR-0012): "ok",
// "none" (no files: hooks only) or "changed" with the detail.
Sessions string `json:"sessions"`
SessionsDetail string `json:"sessions_detail,omitempty"`
// Providers has one line per harness provider for smif doctor.
Providers []ProviderCheck `json:"providers,omitempty"`
// Background has one line per list of background sessions (ADR-0021).
Background []ProviderCheck `json:"background,omitempty"`
Remotes []ProviderCheck `json:"remotes,omitempty"`
ConfigPath string `json:"config_path"`
StartedAt time.Time `json:"started_at"`
PID int `json:"pid"`
}
HealthView is admin.health.
type HistoryRow ¶ added in v0.2.0
type HistoryRow struct {
SessionID string `json:"session_id"`
Dir string `json:"dir"`
Name string `json:"name"`
At time.Time `json:"at"`
Open bool `json:"open,omitempty"`
}
HistoryRow is one past Claude Code session (session.history, ADR-0021). Name is its title or first prompt, on one line. Open marks a session that runs now.
type HumanReplyParams ¶
type HumanReplyParams struct {
MessageID string `json:"message_id"`
Text string `json:"text"`
Data json.RawMessage `json:"data,omitempty"`
}
HumanReplyParams is message.reply.
type IDParams ¶
type IDParams struct {
ID string `json:"id"`
}
IDParams carries one message, run or thread id.
type ListParams ¶
type ListParams struct {
Agent string `json:"agent,omitempty"`
State string `json:"state,omitempty"`
MessageID string `json:"message_id,omitempty"`
Limit int `json:"limit,omitempty"`
}
ListParams filters thread.list and run.list.
type MessageView ¶
type MessageView struct {
ID string `json:"id"`
ThreadID string `json:"thread_id"`
ParentID string `json:"parent_id,omitempty"`
From envelope.From `json:"from"`
To string `json:"to"`
Kind string `json:"kind"`
Intent string `json:"intent"`
Priority string `json:"priority"`
Subject string `json:"subject"`
Body string `json:"body,omitempty"`
Data json.RawMessage `json:"data,omitempty"`
Attachments []envelope.Attachment `json:"attachments,omitempty"`
State string `json:"state"`
Hop int `json:"hop"`
Coalesced int `json:"coalesced_count"`
Recurrence bool `json:"recurrence,omitempty"`
Attempt int `json:"attempt"`
Handler string `json:"handler,omitempty"`
RuleID string `json:"rule_id,omitempty"`
Summary string `json:"summary,omitempty"`
Reason string `json:"reason,omitempty"`
HoldReason string `json:"hold_reason,omitempty"`
HumanQuestion string `json:"human_question,omitempty"`
ReplyStatus string `json:"reply_status,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
MessageView is a message summary (bodies only for the human).
type Metrics ¶
type Metrics struct {
QueueDepth int `json:"queue_depth"`
Running int `json:"running"`
SuccessRate float64 `json:"success_rate_24h"`
P50Seconds float64 `json:"run_p50_s"`
P95Seconds float64 `json:"run_p95_s"`
CostToday map[string]float64 `json:"cost_usd_today"`
TokensToday map[string]int64 `json:"tokens_today"`
DLQ int `json:"dlq"`
BudgetLeft map[string]float64 `json:"budget_left_usd"`
RunsLast24h int `json:"runs_24h"`
Coalesced24h int `json:"coalesced_24h"`
}
Metrics are the RFC 8.3 counters.
type PresenceParams ¶
type PresenceParams struct {
// Event is start | heartbeat | end, or busy (a prompt was submitted)
// and idle (the turn ended) from the hooks (ADR-0012).
Event string `json:"event"`
Cwd string `json:"cwd"`
SessionID string `json:"session_id"`
// Agent, when set ($SMIF_AGENT in the session), wins over Cwd.
Agent string `json:"agent,omitempty"`
// Where the session runs, from the hook: its terminal device, the
// claude process and $TERM_PROGRAM ("tmux" inside tmux, "herdr" in a
// herdr pane).
TTY string `json:"tty,omitempty"`
PID int `json:"pid,omitempty"`
Term string `json:"term,omitempty"`
// Title is the session's name (claude --name, /rename) and LastPrompt
// the human's last prompt (shortened), from the transcript.
Title string `json:"title,omitempty"`
LastPrompt string `json:"last_prompt,omitempty"`
}
PresenceParams is presence.update.
type ProviderCheck ¶
type ProviderCheck struct {
Name string `json:"name"`
Title string `json:"title,omitempty"` // a remote's name
Write bool `json:"write,omitempty"` // you can type into that remote
Verified bool `json:"verified"`
State string `json:"state"`
Detail string `json:"detail,omitempty"`
}
ProviderCheck is one provider's format check (ADR-0019). State is ok, none or changed for a verified provider, and unchecked for one that no real session checked.
type QueuedPrompt ¶ added in v0.2.0
type QueuedPrompt struct {
ID int64 `json:"id"`
Text string `json:"text"`
CreatedAt time.Time `json:"created_at"`
Error string `json:"error,omitempty"`
}
QueuedPrompt is one prompt that waits for its session to be idle. Error says why the last try did not type it ("" = it only waits for idle).
type ReplyView ¶
type ReplyView struct {
ID string `json:"id"`
From string `json:"from"`
Status string `json:"status"`
Text string `json:"text"`
Data json.RawMessage `json:"data,omitempty"`
Attachments []envelope.Attachment `json:"attachments,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
ReplyView is a reply as returned to its asker.
type Request ¶
type Request struct {
JSONRPC string `json:"jsonrpc"`
ID int64 `json:"id"`
Method string `json:"method"`
Params json.RawMessage `json:"params,omitempty"`
Auth Auth `json:"auth"`
ProtocolVersion string `json:"protocol_version"`
}
Request is a JSON-RPC request with Smif's auth and version members.
type Response ¶
type Response struct {
JSONRPC string `json:"jsonrpc"`
ID int64 `json:"id"`
Result json.RawMessage `json:"result,omitempty"`
Error *Error `json:"error,omitempty"`
}
Response is a JSON-RPC response.
type RunView ¶
type RunView struct {
ID string `json:"id"`
MessageID string `json:"message_id"`
Agent string `json:"agent"`
Handler string `json:"handler"`
Profile string `json:"profile,omitempty"`
Attempt int `json:"attempt"`
State string `json:"state"`
PID int `json:"pid,omitempty"`
SessionID string `json:"session_id,omitempty"`
ArchivedSession string `json:"archived_session,omitempty"`
Workspace string `json:"workspace,omitempty"`
Branch string `json:"branch,omitempty"`
HeadSHA string `json:"head_sha,omitempty"`
Diffstat string `json:"diffstat,omitempty"`
Result json.RawMessage `json:"result,omitempty"`
CostUSD float64 `json:"cost_usd"`
InputTokens int64 `json:"input_tokens"`
OutputTokens int64 `json:"output_tokens"`
Error string `json:"error,omitempty"`
Transcript string `json:"transcript,omitempty"`
Stderr string `json:"stderr,omitempty"`
StartedAt time.Time `json:"started_at"`
EndedAt *time.Time `json:"ended_at,omitempty"`
}
RunView is a run record.
type SavedPrompt ¶
SavedPrompt is one of the human's saved prompts (prompts.list, ADR-0015).
type SearchHit ¶ added in v0.2.0
type SearchHit struct {
HistoryRow
Role string `json:"role"`
Text string `json:"text"`
}
SearchHit is one record that holds the words. Role is "you" or "claude".
type SendParams ¶
type SendParams struct {
envelope.Draft
// WaitS lets message.ask wait for the reply (max 600).
WaitS int `json:"wait_s,omitempty"`
}
SendParams is message.send / message.ask / message.emit.
type SendResult ¶
type SendResult struct {
ID string `json:"id"`
ThreadID string `json:"thread_id"`
State string `json:"state"`
Coalesced bool `json:"coalesced,omitempty"`
CoalescedInto string `json:"coalesced_into,omitempty"`
Reply *ReplyView `json:"reply,omitempty"`
Ticket string `json:"ticket,omitempty"`
}
SendResult acknowledges a persisted message.
type Server ¶
type Server struct {
Auth func(a Auth) (Caller, error)
OnDenied func(method string, a Auth, err error)
Log *slog.Logger
// contains filtered or unexported fields
}
Server serves JSON-RPC over a Unix socket.
func (*Server) Close ¶
func (s *Server) Close()
Close stops accepting, cancels in-flight calls and closes connections.
type SessionActivity ¶
type SessionActivity struct {
Prompt string `json:"prompt,omitempty"`
PromptAt time.Time `json:"prompt_at,omitzero"`
Tools int `json:"tools"`
Steps []SessionStep `json:"steps,omitempty"`
Now *SessionStep `json:"now,omitempty"`
WroteAt time.Time `json:"wrote_at,omitzero"`
}
SessionActivity is the newest exchange of a session: the human's prompt it answers, its tool calls so far (the last few, oldest first) and Now, the call without a result yet: the tool that runs, or the permission or question a waiting session shows in its tab. WroteAt is when the transcript last changed: a busy session that has not written for minutes may be stuck.
type SessionAttachParams ¶ added in v0.2.0
type SessionAttachParams struct {
SessionID string `json:"session_id"`
Term string `json:"term,omitempty"`
}
SessionAttachParams is session.attach: open `claude attach` for a background session in a new tab. Term as in session.new. The call picks a session and a terminal, never the command.
type SessionFacts ¶ added in v0.2.0
type SessionFacts struct {
Files int `json:"files,omitempty"`
Commits int `json:"commits,omitempty"`
Tests string `json:"tests,omitempty"`
Dirty *int `json:"dirty,omitempty"`
ContextTokens int64 `json:"context_tokens,omitempty"`
ContextHigh bool `json:"context_high,omitempty"`
}
SessionFacts is next to an answer in the preview. The UI states these facts and does not judge the answer. Tests is passed or failed only for a test after the last edit of a non-doc file, none when no test finished after it, empty with no such edit. Dirty counts the paths `git status --porcelain` lists (nil when git gave nothing: no repo, too slow). ContextHigh is true over daemon.context_warn.
type SessionFocusParams ¶
type SessionFocusParams struct {
SessionID string `json:"session_id"`
}
SessionFocusParams is session.focus: bring the session's terminal tab to the front.
type SessionNewParams ¶
type SessionNewParams struct {
// Host starts it on another machine you may write to, in tmux there.
Host string `json:"host,omitempty"`
Dir string `json:"dir"`
Name string `json:"name,omitempty"`
Term string `json:"term,omitempty"`
Harness string `json:"harness,omitempty"`
}
SessionNewParams is session.new: open a new terminal tab that runs a coding agent in Dir (ADR-0015, ADR-0021). Harness names the agent ("" = claude); the daemon builds the command from that name, never from the call. Name reaches argv only for claude. Term picks the terminal ("Apple_Terminal", "iTerm.app", "tmux", "herdr"; "" = the daemon's default).
type SessionPromptParams ¶
type SessionPromptParams struct {
SessionID string `json:"session_id,omitempty"`
Agent string `json:"agent,omitempty"`
// Name picks the session by its name (claude --name, /rename; case
// does not matter); with no session of that name, it is an agent.
Name string `json:"name,omitempty"`
Text string `json:"text"`
// Async returns once the session is checked: the text is typed in the
// background and a session that took no turn shows Unsent.
Async bool `json:"async,omitempty"`
}
SessionPromptParams is session.prompt: the human's text typed into an idle session. SessionID wins; with Agent alone, that agent must have exactly one idle session.
type SessionPromptResult ¶
type SessionPromptResult struct {
Agent string `json:"agent"`
SessionID string `json:"session_id"`
}
SessionPromptResult names the session that got the prompt.
type SessionQueueCancelParams ¶ added in v0.2.0
type SessionQueueCancelParams struct {
ID int64 `json:"id"`
// SessionID is set for an item on another machine.
SessionID string `json:"session_id,omitempty"`
}
SessionQueueCancelParams is session.queue.cancel: remove one queued item.
type SessionQueueParams ¶ added in v0.2.0
type SessionQueueParams struct {
SessionID string `json:"session_id,omitempty"`
Name string `json:"name,omitempty"`
Text string `json:"text"`
}
SessionQueueParams is session.queue: the human's text waits until the session is idle (ADR-0021). The session is picked as in session.send.
type SessionQueueResult ¶ added in v0.2.0
type SessionQueueResult struct {
ID int64 `json:"id"`
Agent string `json:"agent"`
SessionID string `json:"session_id"`
}
SessionQueueResult names the new item and its session.
type SessionReopenParams ¶ added in v0.2.0
type SessionReopenParams struct {
Term string `json:"term,omitempty"`
}
SessionReopenParams is session.reopen: reopen the restore list. Term as in session.new.
type SessionReopenResult ¶ added in v0.2.0
SessionReopenResult says how many sessions the daemon reopens now, one each 500 ms, and how many stay on the list.
type SessionResumeParams ¶ added in v0.2.0
type SessionResumeParams struct {
SessionID string `json:"session_id"`
Term string `json:"term,omitempty"`
}
SessionResumeParams is session.resume: open `claude --resume` for a past session in a new tab. Term as in session.new. The call picks a session and a terminal, never the command.
type SessionSearchParams ¶ added in v0.2.0
type SessionSearchParams struct {
Query string `json:"query"`
}
SessionSearchParams is session.search: words to find in the text of past sessions.
type SessionSearchResult ¶ added in v0.2.0
type SessionSearchResult struct {
Hits []SearchHit `json:"hits"`
Stopped string `json:"stopped,omitempty"`
}
SessionSearchResult is what a search found. Stopped says why it ended early: "hits" at the limit of hits, "time" at the limit of time.
type SessionSendParams ¶
type SessionSendParams struct {
SessionID string `json:"session_id,omitempty"`
Name string `json:"name,omitempty"`
Text string `json:"text"`
Async bool `json:"async,omitempty"` // as in SessionPromptParams
}
SessionSendParams is session.send: the human writes to a session. An idle session gets the text typed in (session.prompt); a busy or waiting one sends it to a worker that resumes a fork of the session (ADR-0013).
type SessionSendResult ¶
type SessionSendResult struct {
Mode string `json:"mode"`
Agent string `json:"agent"`
SessionID string `json:"session_id"`
MessageID string `json:"message_id,omitempty"`
}
SessionSendResult says where the text went: "typed" into the session or to a "worker" (MessageID is its ask).
type SessionStats ¶
type SessionStats struct {
Typed int `json:"typed"`
WorkerAsks int `json:"worker_asks"`
AgentAsks int `json:"agent_asks"`
Focus int `json:"focus"`
}
SessionStats counts what the human did with sessions: prompts typed into idle ones, asks a fork of a busy one answered (from the human, from agents), and tabs brought to the front.
type SessionStep ¶
type SessionStep struct {
Tool string `json:"tool"`
Target string `json:"target,omitempty"`
At time.Time `json:"at"`
Done bool `json:"done"`
}
SessionStep is one tool call: the tool, what it works on (a command, a file, a question), when, and whether its result came back.
type SessionTail ¶
type SessionTail struct {
SessionID string `json:"session_id"`
Turns []SessionTurn `json:"turns"`
}
SessionTail is the conversation of one interactive session, for the human only (it never goes into a session or to an agent).
type SessionTailParams ¶
type SessionTailParams struct {
SessionID string `json:"session_id"`
Limit int `json:"limit,omitempty"` // default 20, at most 100
}
SessionTailParams is session.tail: the last turns of one session.
type SessionTurn ¶
type SessionTurn struct {
Role string `json:"role"`
Text string `json:"text"`
At time.Time `json:"at"`
Tools int `json:"tools,omitempty"`
From string `json:"from,omitempty"`
State string `json:"state,omitempty"`
}
SessionTurn is one prompt ("you") or answer ("claude") from a session's transcript, or a question to a fork of the session ("ask", From the asker) and its answer ("worker", with the ask's State) (ADR-0013). An answer counts its tool calls.
type SessionView ¶
type SessionView struct {
Agent string `json:"agent"`
Harness string `json:"harness"` // the coding agent: claude, codex (ADR-0019)
Level string `json:"level"` // the support level: full | herdr | listed (ADR-0019)
// Unverified marks a session whose provider no real session checked
// (ADR-0019): read only, no typing and no fork.
Unverified bool `json:"unverified,omitempty"`
// Background marks a session that `claude agents` lists (ADR-0021): it
// has no tab, takes no typing, and session.attach opens it.
Background bool `json:"background,omitempty"`
SessionID string `json:"session_id"`
Repo string `json:"repo"`
Turn string `json:"turn"` // idle | busy | waiting | unknown
TurnAt time.Time `json:"turn_at,omitzero"`
LastSeen time.Time `json:"last_seen"`
TTY string `json:"tty,omitempty"`
Term string `json:"term,omitempty"`
Title string `json:"title,omitempty"`
LastPrompt string `json:"last_prompt,omitempty"`
// LastAnswer is the final message of the session's newest answer (its
// text after the last tool call), from the transcript; LastAnswerAt is
// when it came. Empty while the first answer is still working.
LastAnswer string `json:"last_answer,omitempty"`
LastAnswerAt time.Time `json:"last_answer_at,omitzero"`
// CanPrompt is true when session.prompt would type into it now; Why
// says what is missing otherwise.
CanPrompt bool `json:"can_prompt"`
Why string `json:"why,omitempty"`
// Unsent says why the last prompt typed in the background started no
// turn (since UnsentAt; cleared by the session's next turn).
Unsent string `json:"unsent,omitempty"`
UnsentAt time.Time `json:"unsent_at,omitzero"`
// Activity is what the newest exchange does now, from the transcript
// (nil when there is none).
Activity *SessionActivity `json:"activity,omitempty"`
// Host is the ssh host of a session on another machine (ADR-0023).
Host string `json:"host,omitempty"`
HostName string `json:"host_name,omitempty"` // the name you gave that machine
Writable bool `json:"writable,omitempty"` // you allowed typing into that machine
HostDir string `json:"host_dir,omitempty"` // Repo on that machine, with no label
// Facts is what the transcript and git show from the newest human
// prompt on (ADR-0021; nil when unknown).
Facts *SessionFacts `json:"facts,omitempty"`
// Queue is what waits for this session to be idle, oldest first
// (session.list only, ADR-0021).
Queue []QueuedPrompt `json:"queue,omitempty"`
}
SessionView is one live interactive session (session.list, ADR-0012).
func (SessionView) HostLabel ¶ added in v0.3.1
func (v SessionView) HostLabel() string
HostLabel is what to call the machine a session runs on.
type StatsParams ¶
type StatsParams struct {
// Since is the start of the window (default: 14 days ago).
Since time.Time `json:"since,omitempty"`
}
StatsParams is stats.get (human only, ADR-0011): counts over a window.
type StatsResult ¶
type StatsResult struct {
Since time.Time `json:"since"`
Until time.Time `json:"until"`
Total StatsRow `json:"total"`
Agents []StatsRow `json:"agents"`
Days []StatsRow `json:"days"`
Replies int `json:"replies"`
// Sessions counts the session cockpit in the window (ADR-0012, 0013).
Sessions SessionStats `json:"sessions"`
// KeptFrom is where the retention window starts: older data is gone.
KeptFrom time.Time `json:"kept_from"`
}
StatsResult is stats.get.
type StatsRow ¶
type StatsRow struct {
Key string `json:"key"`
Inbound int `json:"inbound"`
Auto int `json:"auto"`
AutoBy map[string]int `json:"auto_by,omitempty"` // handler → count
NeededYou int `json:"needed_you"`
Answered int `json:"answered"`
Waiting int `json:"waiting"`
CancelledNeeded int `json:"cancelled_needed"`
Cancelled int `json:"cancelled"`
Dead int `json:"dead"`
Rejected int `json:"rejected"`
Expired int `json:"expired"`
InProgress int `json:"in_progress"`
Merged int `json:"merged"` // repeats coalesced into an existing message
Runs int `json:"runs"`
WorkerRuns int `json:"worker_runs"`
CommandRuns int `json:"command_runs"`
FailedRuns int `json:"failed_runs"`
InputTokens int64 `json:"input_tokens"` // incl. cache reads and writes
OutputTokens int64 `json:"output_tokens"`
CostUSD float64 `json:"cost_usd"` // as claude reports it
}
StatsRow counts one slice of the window: all, one agent or one day. Inbound = asks, tells and events created in the window (replies are counted apart). Each inbound message lands in exactly one outcome: Auto (done, never needs_human), Answered/Waiting/CancelledNeeded (it needed the human), Cancelled (rejected by the human without needing them), Dead, Rejected (by a guard or rule), Expired or InProgress.
type StatusView ¶
type StatusView struct {
Daemon HealthView `json:"daemon"`
Agents []AgentView `json:"agents"`
Running []RunView `json:"running"`
DLQ int `json:"dlq"`
Metrics Metrics `json:"metrics"`
}
StatusView is agent.status (global when no agent is given).
type ThreadView ¶
type ThreadView struct {
ThreadID string `json:"thread_id"`
Frozen bool `json:"frozen"`
FrozenReason string `json:"frozen_reason,omitempty"`
Messages []MessageView `json:"messages"`
Runs []RunView `json:"runs"`
}
ThreadView is thread.get.