Documentation
¶
Overview ¶
Package registry defines the workspace registry's domain types and the Store interface that backend implementations satisfy. See design spec §2, §8.
Index ¶
- Constants
- Variables
- func ValidSessionKind(kind string) bool
- func ValidateAgentArgs(args map[string]AgentArgs) error
- func ValidateAgentModel(model string) error
- type AgentArgs
- type Attention
- type AttentionKind
- type AttentionOption
- type Confirmation
- type ConfirmationStatus
- type ConflictError
- type ConversationActivity
- type Credential
- type Dispatch
- type DispatchEvent
- type DispatchStatus
- type Environment
- type EnvironmentStatus
- type ErrorClass
- type HoldEndReason
- type HoldMode
- type HoldRelease
- type Message
- type MessageRole
- type Plugin
- type PluginSource
- type PluginStatus
- type RouterSettingsChange
- type RouterTier
- type SSHKey
- type Session
- type Store
- type Target
- type TargetAgent
- type TargetHealth
- type TargetKind
- type TargetPolicy
- type Task
- type TaskFailure
- type TaskHold
- type TaskKind
- type TaskStatus
- type TaskTurn
- type Workspace
- type WorkspaceStatus
Constants ¶
const ( ConfirmationRunCommand = "run_command" ConfirmationInstallAgent = "install_agent" ConfirmationCloneRemote = "clone_remote" ConfirmationPolicy = "policy" // ConfirmationCreateTarget creates a machine from a plugin // (LOOM-216): TargetName is the new target's name, Command the // machine on one line (plugin, size, data, egress). ConfirmationCreateTarget = "create_target" )
Confirmation kinds: what an offer will do once approved.
const ( // EventDecision: the routing model's decision — action, model and // tier, and the workspace, target or agent it named. EventDecision = "decision" // EventCommand: a shell command ran on a target (run_command). EventCommand = "command" // EventProvision: a workspace's provisioning ran on a target. EventProvision = "provision" // EventMachine: a machine was created from chat (LOOM-247): its // target, no workspace. Before LOOM-247 it was an EventProvision. EventMachine = "machine" // EventOffer: the router offered something and waits for a yes; // EventOfferAnswered: how the offer was answered. EventOffer = "offer" EventOfferAnswered = "offer_answered" // EventAgentTurn: an agent's turn in a workspace ended. EventAgentTurn = "agent_turn" // EventRelay: the relay model condensed a turn's output. EventRelay = "relay" // EventOutcome: the dispatch ended. EventOutcome = "outcome" )
Dispatch event kinds (LOOM-110): what a turn did, kept after the fact in place of pod logs, whose retention is short.
const ( // PluginTrustBundled: part of the image, trusted as the image is. PluginTrustBundled = "bundled" // PluginTrustUnsigned: nothing vouches for it; the user accepted it. PluginTrustUnsigned = "unsigned" // PluginTrustSignedPrefix starts a trust value naming the identity // whose signature verified: "signed:<identity>". PluginTrustSignedPrefix = "signed:" // PluginTrustPinnedPrefix starts a trust value naming the digest the // operator pinned the executable to: "pinned:sha256:<hex>" (LOOM-218). PluginTrustPinnedPrefix = "pinned:" )
Plugin trust values (Plugin.Trust).
const ( // SettingInstanceID is this server's instance id, generated on first // start: what labels everything a plugin makes as this server's. SettingInstanceID = "instance_id" // SettingPluginsSeedOwned is the ids of the plugin instances // LOOMUX_PLUGINS_SEED made, as a JSON array: the seed reconfigures and // prunes those only (LOOM-219, plugins/seed.go). SettingPluginsSeedOwned = "plugins_seed_owned" // SettingMachinesSeedOwned is the target ids of the machines the // seed's "machines" made, as a JSON array: the seed keeps those in // line only (LOOM-236, providers/seed.go). SettingMachinesSeedOwned = "machines_seed_owned" )
Settings keys (Store.GetSetting/SetSetting).
const ( // RelayFull: the turn's output and context go to the relay model, // and its conversations' history to the routing model. RelayFull = "full" // RelayLastMessage: only the agent's own final message for a turn // (its visible screen, for an agent with no final-message hook); the // routing model sees only those replies of its conversations. RelayLastMessage = "last_message" // RelayNone: nothing from the target reaches either model. The // agent's final message is the chat reply as it is, and the routing // model sees no message, reply or summary from its conversations. RelayNone = "none" )
What the router models may see of a target's work (TargetPolicy.Relay, user decision 2026-10-07).
const ( TargetPurposePersonal = "personal" TargetPurposeWork = "work" )
Target purposes (TargetPolicy.Purpose).
const ( // PermissionModeAuto: the agent's own classifier-gated automatic // mode (claude --permission-mode auto) — never bypass. PermissionModeAuto = "auto" // PermissionModeAcceptEdits: file edits go ahead; commands ask. PermissionModeAcceptEdits = "accept-edits" // PermissionModeManual: everything asks. PermissionModeManual = "manual" )
Target permission modes: how much an agent may do without a human approving it. Each agent-type maps them to its own CLI flags.
const ( AgentAuthLoggedIn = "logged_in" AgentAuthLoggedOut = "logged_out" // AgentAuthUnknown: the CLI was asked but its answer wasn't // recognised. AgentAuthUnknown = "unknown" )
TargetAgent.AuthStatus values (LOOM-86).
const ( // AgentAuthExpired: the sign-in ended, by its own expiry or as a turn // found it (an expired token, a refused key). AgentAuthExpired = "expired" // AgentAuthRateLimited: signed in, but a turn hit the account's usage // limit and none has finished normally since. AgentAuthRateLimited = "rate_limited" )
SignInState values beyond the AgentAuth* ones (LOOM-316).
const ( // AgentSignInExpired: the sign-in had expired ("OAuth token has // expired"). AgentSignInExpired = "expired" // AgentSignInInvalid: the credential was refused ("Invalid API key"). AgentSignInInvalid = "invalid_credentials" // AgentSignInSignedOut: the CLI isn't signed in at all (its login or // onboarding screen). AgentSignInSignedOut = "signed_out" )
TargetAgent.SignInProblem values (LOOM-316): which sign-in screen a turn stopped at, as a fixed word — never the screen's text.
const ( RouterTierPrimary = "primary" RouterTierEscalation = "escalation" )
Router model tiers (LOOM-185, docs/design/router-settings.md).
const ( RouterSettingsSet = "set" RouterSettingsClear = "clear" )
Router settings audit actions.
const ( // SessionOriginLogin: with the password, at POST /api/v1/login. SessionOriginLogin = "login" // SessionOriginLink: approved from a login session, which never saw // its token (the terminal's link flow, POST /api/v1/sessions). SessionOriginLink = "link" )
How a session was made (Session.Origin).
const ( SessionKindWeb = "web" SessionKindTUI = "tui" SessionKindApp = "app" )
The clients a session can say it is (Session.ClientKind).
const ( SSHKeyOriginGenerated = "generated" SSHKeyOriginImported = "imported" // SSHKeyOriginTarget is a key generated for one target // (generate_ssh_key), deleted when that target stops using it. SSHKeyOriginTarget = "target" )
SSHKey origins.
const AgentEffortRule = "must be 1-16 lower-case letters"
AgentEffortRule is the message for an effort the registry refuses. Each agent type further allows only its own CLI's levels.
const AgentModelRule = "must be 1-64 letters, digits, '.', '_', ':' or '-', starting with a letter or digit, " +
"optionally ending in [1m]"
AgentModelRule is the message for a model ValidateAgentModel refuses.
const MessageOriginNone = "none"
MessageOriginNone is Message.Origin for a turn that touched no target: the router's own answer.
const SSHProxyNone = "none"
SSHProxyNone is Target.SSHProxy for a managed target reached without the server's proxy.
const SignInSessionTTL = 24 * time.Hour
SignInSessionTTL is how long a sign-in session (LOOM-316) is reported as open: the orphan sweep (LOOM-93) kills a Loomux session no task owns once it is this old.
Variables ¶
var ErrConflict = errors.New("registry: conflict")
ErrConflict is returned when an operation would violate a uniqueness or referential-integrity constraint (e.g. a duplicate name, or a foreign key referencing a row that doesn't exist or still has dependents).
var ErrConversationBusy = errors.New("registry: conversation already has a dispatch in flight")
ErrConversationBusy is returned by CreateDispatch when the conversation already has a queued or running dispatch.
var ErrDispatchStateChanged = errors.New("registry: dispatch status changed")
ErrDispatchStateChanged is returned by TransitionDispatch when the job is no longer in the status the caller expected — someone else moved it first (e.g. shutdown marked it interrupted).
var ErrHoldEnded = errors.New("registry: hold has ended")
ErrHoldEnded is returned by RenewTaskHold for a hold that has ended; the hold comes back with it, saying why.
var ErrIdempotencyKeyExists = errors.New("registry: idempotency key already used")
ErrIdempotencyKeyExists is returned by CreateDispatch when another dispatch already holds the key.
var ErrNoMasterKey = errors.New("registry: no master key configured")
ErrNoMasterKey is a secret-holding operation attempted on a store that has no master key to encrypt or decrypt with.
var ErrNotFound = errors.New("registry: not found")
ErrNotFound is returned when a requested entity does not exist.
var ErrQuota = errors.New("registry: limit reached")
ErrQuota is returned when a create would take a plugin instance past its machine limit (CreateEnvironmentWithin, LOOM-244).
var ErrTaskHeld = errors.New("registry: task already has an active drive hold")
ErrTaskHeld is returned by CreateTaskHold and AcquireDriveHold when the task already has an active drive hold: there is one per task.
Functions ¶
func ValidSessionKind ¶ added in v0.3.151
ValidSessionKind reports whether kind is a known client kind, or empty (unknown).
func ValidateAgentArgs ¶ added in v0.3.161
ValidateAgentArgs is Target.Validate's check of AgentArgs: agent type names unpadded, each entry pinning something, each value well-formed. Whether an agent type exists and takes that effort is for the caller that knows the agent types (the API, and the launch itself).
func ValidateAgentModel ¶ added in v0.3.161
ValidateAgentModel checks a pinned model name: a single word that can't be read as a flag or carry a shell metacharacter. "[1m]" is Claude Code's 1M-context suffix (sonnet[1m]).
Types ¶
type AgentArgs ¶ added in v0.3.161
type AgentArgs struct {
Model string `json:"model,omitempty"`
Effort string `json:"effort,omitempty"`
}
AgentArgs pin how an agent type's CLI is launched on a target (LOOM-307): the model it runs and its effort. Each field is optional; empty leaves the CLI's (the account's) own default. They are the only launch settings a target can pin, each passed as one argument after a flag its agent type fixes, never as free text. Only the target API sets them: the router models and prompts never do.
type Attention ¶
type Attention struct {
Kind AttentionKind `json:"kind"`
// Title is the prompt's heading ("Bash command"), Detail what it is
// about (the command, the file), Question what it asks ("Do you want
// to proceed?"). Any may be empty.
Title string `json:"title,omitempty"`
Detail string `json:"detail,omitempty"`
Question string `json:"question,omitempty"`
// Options are the choices the prompt lists, in order.
Options []AttentionOption `json:"options,omitempty"`
// Selected is the index of the option the prompt's cursor is on.
Selected int `json:"selected"`
// Resets is, for AttentionUsageLimit, when the limit resets as the
// agent put it ("5pm (Europe/Berlin)", "in 2 hours"); may be empty.
// Free text, so not "resets_at" like the API's timestamps (renamed
// before 1.0, API v1 freeze review item 11); a stored attention
// written with the old key still reads (UnmarshalJSON).
Resets string `json:"resets,omitempty"`
}
Attention is a prompt read off an agent's pane (LOOM-97): what a chat client shows so the user can answer it without attaching.
func (*Attention) UnmarshalJSON ¶ added in v0.3.24
UnmarshalJSON reads an Attention, taking the reset text from the pre-1.0 "resets_at" key when "resets" isn't there: tasks stored before the rename keep it.
type AttentionKind ¶
type AttentionKind string
AttentionKind says what an agent's prompt asks a human for (LOOM-97).
const ( // AttentionPermission: approve or deny something the agent wants to // do (run a command, edit a file). AttentionPermission AttentionKind = "permission" // AttentionQuestion: the agent asks the user to pick an answer or // type one. AttentionQuestion AttentionKind = "question" // AttentionTrust: the agent asks whether to trust the workspace's // folder. AttentionTrust AttentionKind = "trust" // AttentionLogin: the agent CLI isn't signed in. Loomux never answers // this one: the task fails with ErrorClassLoginRequired. AttentionLogin AttentionKind = "login" // AttentionUsageLimit: the agent's account hit its usage limit // (LOOM-109). Nothing to answer: the task fails with // ErrorClassAgentRateLimited, saying when the limit resets. AttentionUsageLimit AttentionKind = "usage_limit" // AttentionAPIError: the agent CLI ended its turn on an API error // from its model provider (LOOM-253), a refusal included. Nothing to // answer: the task fails with ErrorClassAgentAPIError. AttentionAPIError AttentionKind = "api_error" )
type AttentionOption ¶
type AttentionOption struct {
Label string `json:"label"`
Description string `json:"description,omitempty"`
}
AttentionOption is one choice an Attention offers.
type Confirmation ¶
type Confirmation struct {
ID string
ConversationID string
// DispatchID is the turn that made the offer; empty outside a
// dispatch job.
DispatchID string
Kind string
TargetID string
TargetName string
AgentType string
// Command is the shell command or install command that would run.
Command string
// Workspace and GitRemote describe a workspace the offer would create.
Workspace string
GitRemote string
Status ConfirmationStatus
// StatusReason is why a yes was refused afterwards (LOOM-216: the
// offer changed, the name was taken, the quota was reached; or the
// target's policy was tightened since), as the chat was told; empty
// otherwise.
StatusReason string
CreatedAt time.Time
ExpiresAt time.Time
// ResolvedAt is set once Status leaves pending.
ResolvedAt *time.Time
}
Confirmation is the record of an offer the router made and is waiting on a yes for (LOOM-123): what it would do and where, for the web UI to show as a card with Approve and Deny, and how it was answered. What a yes actually runs lives with the router, in memory; this row only describes it.
type ConfirmationStatus ¶
type ConfirmationStatus string
ConfirmationStatus is where an offer awaiting the user's yes stands (LOOM-123).
const ( ConfirmationPending ConfirmationStatus = "pending" ConfirmationApproved ConfirmationStatus = "approved" // ConfirmationDenied: the user said no, or sent anything else, which // cancels an offer; or a yes was refused afterwards, as // Confirmation.StatusReason says. Nothing ran either way. ConfirmationDenied ConfirmationStatus = "denied" // ConfirmationExpired: it timed out, or Loomux restarted, which forgets // every offer (fails closed). ConfirmationExpired ConfirmationStatus = "expired" )
type ConflictError ¶
type ConflictError struct{ Reason string }
ConflictError is an ErrConflict (errors.Is matches it) carrying a reason a person can act on — what blocks the operation, worded to be shown to them as is.
func (*ConflictError) Error ¶
func (e *ConflictError) Error() string
func (*ConflictError) Is ¶
func (e *ConflictError) Is(target error) bool
Is reports whether target is ErrConflict.
type ConversationActivity ¶
type ConversationActivity struct {
ConversationID string
// LastMessageAt is the CreatedAt of the conversation's most recent
// message.
LastMessageAt time.Time
}
ConversationActivity is one conversation's footprint in the message log: every conversation with at least one logged turn has one, whether or not it ever touched a task (an answer_directly-only conversation has messages and no tasks — LOOM-62).
type Credential ¶
type Credential struct {
ID string
Name string // becomes an env var name at resolution time
// WorkspaceID scopes this credential to one workspace; empty means
// not workspace-scoped.
WorkspaceID string
// AgentType scopes this credential to one agent-type; empty means
// not agent-type-scoped.
AgentType string
// TargetID scopes this credential to one target (LOOM-178: a machine
// a plugin made, whose agents all need the same token); empty means
// not target-scoped.
TargetID string
// Value is plaintext at this domain-type level; a Store
// implementation is responsible for encrypting it at rest and
// decrypting on read.
Value string
CreatedAt time.Time
UpdatedAt time.Time
}
Credential is a secret Loomux's vault owns on behalf of a task launch (GitHub/GitLab PATs, MCP tokens, custom API keys — see design spec §7). It does NOT cover OAuth-native agent CLI sessions (Claude Code's `claude login`, etc.), which manage their own token lifecycle and are expected to already be authenticated in the target's HOME/config dir.
type Dispatch ¶
type Dispatch struct {
ID string
ConversationID string
// Message and WorkspaceHint are the request as submitted, kept so
// the job can run from the row alone.
Message string
WorkspaceHint string
// IdempotencyKey is the client's Idempotency-Key, empty when none was
// sent. Unique across dispatches when set.
IdempotencyKey string
// RequestHash fingerprints (conversation, message, hint, confirmation)
// as the client sent them — the conversation empty for a new one —
// so a reused key can be told apart from a retried request.
RequestHash string
// ConfirmationID is set when the message answers an offer from its
// card (LOOM-123): it must still be the offer awaiting an answer, or
// nothing runs.
ConfirmationID string
Status DispatchStatus
// Reply is set once the job has succeeded; Error and ErrorClass once
// it has failed or been interrupted.
Reply string
Error string
ErrorClass ErrorClass
CreatedAt time.Time
UpdatedAt time.Time
StartedAt *time.Time
FinishedAt *time.Time
}
Dispatch is one chat message's trip through the router, run as a job that outlives the HTTP request which submitted it (LOOM-80).
type DispatchEvent ¶ added in v0.3.7
type DispatchEvent struct {
ID string
ConversationID string
// DispatchID is the turn it belongs to; empty outside a dispatch job.
DispatchID string
CreatedAt time.Time
Kind string
// Model and Tier name the router model that decided or relayed
// ("primary", "escalation"), when one did.
Model string
Tier string
TargetID string
WorkspaceID string
TaskID string
// Command is the command that ran, redacted.
Command string
// Outcome is how it ended in a word or two: an action, "exit 0",
// "succeeded", "approved".
Outcome string
ErrorClass ErrorClass
Duration time.Duration
// Detail is a short free-text note (an agent type, an override).
Detail string
}
DispatchEvent is one entry of a conversation's audit trail (LOOM-110): what was decided, run and where, and how it ended. Command text is stored with credential values and secret-shaped strings redacted. Rows are append-only and deleted after the retention period.
type DispatchStatus ¶
type DispatchStatus string
DispatchStatus is where a dispatch job is in its life (LOOM-80, see docs/design/async-dispatch-design.md):
queued ──► running ──► succeeded │ ├──────► failed └──────────┴──────► interrupted
const ( DispatchStatusQueued DispatchStatus = "queued" DispatchStatusRunning DispatchStatus = "running" DispatchStatusSucceeded DispatchStatus = "succeeded" DispatchStatusFailed DispatchStatus = "failed" DispatchStatusInterrupted DispatchStatus = "interrupted" )
func (DispatchStatus) Terminal ¶
func (s DispatchStatus) Terminal() bool
Terminal reports whether s is an end state: nothing moves a job out of it.
type Environment ¶ added in v0.3.69
type Environment struct {
// ID is the short id every object the plugin makes is named from
// (lx-<id>).
ID string
TargetID string
// PluginID is the installed plugin instance that owns the machine;
// empty once it was uninstalled keeping its machines. PluginName
// and PluginVersion stay, for the "created by" badge.
PluginID string
PluginName string
PluginVersion string
Status EnvironmentStatus
StatusReason string
Size string
Persistent bool
Egress string
// Image is the reference the machine was created (or recreated)
// with; ImageDigest what runs, once known.
Image string
ImageDigest string
// HostKey is the machine's host public key (the pin's source);
// HostPrivateKey its private half, plaintext at this level and
// encrypted at rest, only filled in by GetEnvironment.
HostKey string
HostPrivateKey []byte
CreatedAt time.Time
UpdatedAt time.Time
}
Environment is one machine a plugin made for a target.
type EnvironmentStatus ¶ added in v0.3.69
type EnvironmentStatus string
EnvironmentStatus is where a machine is in its life.
const ( EnvironmentCreating EnvironmentStatus = "creating" EnvironmentStarting EnvironmentStatus = "starting" EnvironmentRunning EnvironmentStatus = "running" EnvironmentStopped EnvironmentStatus = "stopped" EnvironmentRecreating EnvironmentStatus = "recreating" EnvironmentDestroying EnvironmentStatus = "destroying" // EnvironmentLost: the plugin no longer has the machine and its data // is gone (an ephemeral one evicted). EnvironmentLost EnvironmentStatus = "lost" // EnvironmentError: creation or an operation failed; StatusReason // says why, the plugin's objects are left for inspection. EnvironmentError EnvironmentStatus = "error" // EnvironmentDetached: its plugin was uninstalled keeping the // machines; nothing manages it any more. EnvironmentDetached EnvironmentStatus = "detached" )
type ErrorClass ¶
type ErrorClass string
ErrorClass is a stable, machine-readable category for a task failure (LOOM-77) — what a client switches on to render a failure, where FailureReason is the text it shows.
const ( // ErrorClassLaunchFailed: the task's tmux session could not be // started. ErrorClassLaunchFailed ErrorClass = "launch_failed" // ErrorClassTargetUnreachable: the target couldn't be reached. ErrorClassTargetUnreachable ErrorClass = "target_unreachable" // ErrorClassSendFailed: the turn's message could not be delivered. ErrorClassSendFailed ErrorClass = "send_failed" // ErrorClassAgentExited: the agent CLI's process exited mid-turn. ErrorClassAgentExited ErrorClass = "agent_exited" // ErrorClassProvisionFailed: a provisioning script exited non-zero. ErrorClassProvisionFailed ErrorClass = "provision_failed" // ErrorClassWaitFailed: waiting for the turn to complete failed or // was abandoned (e.g. the request was cancelled). ErrorClassWaitFailed ErrorClass = "wait_failed" // ErrorClassRelayFailed: the finished turn's output could not be // captured or relayed. ErrorClassRelayFailed ErrorClass = "relay_failed" // ErrorClassTimeout: the turn hit one of its bounds — its maximum // duration, or no progress while waiting (LOOM-76). The pane is left // running. ErrorClassTimeout ErrorClass = "timeout" // ErrorClassSessionLost: the task's session was gone (reaped, // crashed, killed) when the next message arrived. ErrorClassSessionLost ErrorClass = "session_lost" // ErrorClassLoginRequired: the agent CLI asked to be signed in // (LOOM-97). Its pane is left for a human to complete the login. ErrorClassLoginRequired ErrorClass = "login_required" // ErrorClassAgentRateLimited: the agent's account hit its usage // limit (LOOM-109); its reason says when it resets. ErrorClassAgentRateLimited ErrorClass = "agent_rate_limited" // ErrorClassAgentAPIError: the agent CLI stopped on an API error // from its model provider (LOOM-253); its reason quotes the error. ErrorClassAgentAPIError ErrorClass = "agent_api_error" // ErrorClassCompactionLoop: the agent kept compacting its context // within one turn without finishing it (LOOM-109); Loomux // interrupted it. ErrorClassCompactionLoop ErrorClass = "compaction_loop" // ErrorClassTargetUnhealthy: the target failed its health probe for a // reason other than being unreachable — no tmux, its disk nearly full // (LOOM-86). ErrorClassTargetUnhealthy ErrorClass = "target_unhealthy" // ErrorClassMessageTooLarge: the message, with the context in front // of it, is over what Loomux pastes into an agent's pane // (targets.MaxPasteBytes, LOOM-111). Nothing was sent; the agent's // task is left as it was. ErrorClassMessageTooLarge ErrorClass = "message_too_large" // ErrorClassCancelled: the user cancelled the turn (LOOM-99). ErrorClassCancelled ErrorClass = "cancelled" // ErrorClassTakenOver: a person took the task over while its turn // ran (LOOM-266), which ends the turn's dispatch at once. It is the // dispatch's class, never the task's: the task stays human_takeover, // its agent isn't interrupted, and what it finishes reaches the // conversation later, as late output. ErrorClassTakenOver ErrorClass = "taken_over" // ErrorClassHeld: the message wasn't sent because a person holds the // conversation's task (LOOM-267): it is driven from a terminal, and // automation doesn't type into it until it is given or taken back. // The dispatch's error names the holder. A dispatch's class, never // a task's. ErrorClassHeld ErrorClass = "held" // ErrorClassInternal: anything else. ErrorClassInternal ErrorClass = "internal" )
const ErrorClassInterrupted ErrorClass = "interrupted"
ErrorClassInterrupted: the dispatch was cut off by the server shutting down or restarting, not by anything the turn itself did.
type HoldEndReason ¶ added in v0.3.147
type HoldEndReason string
HoldEndReason is why a hold ended.
const ( // HoldEndReleased: its holder gave it back. HoldEndReleased HoldEndReason = "released" // HoldEndExpired: its lease ran out without a heartbeat. HoldEndExpired HoldEndReason = "expired" // HoldEndTakenBack: another client ended it without taking the task // itself (Take back). HoldEndTakenBack HoldEndReason = "taken_back" // HoldEndTakenOver: another session took the task with force. HoldEndTakenOver HoldEndReason = "taken_over" // HoldEndSessionRevoked: its session was logged out, revoked or // expired. HoldEndSessionRevoked HoldEndReason = "session_revoked" // HoldEndTaskEnded: the held task ended. HoldEndTaskEnded HoldEndReason = "task_ended" )
func (HoldEndReason) Valid ¶ added in v0.3.147
func (r HoldEndReason) Valid() bool
Valid reports whether r is a known reason.
type HoldMode ¶ added in v0.3.147
type HoldMode string
HoldMode is what a hold lets its holder do (LOOM-263, docs/design/tui-client-design.md "Server awareness: holds").
const ( // HoldModeDrive: the holder types into the task's pane. At most one // active drive hold exists per task. HoldModeDrive HoldMode = "drive" // HoldModeWatch: the holder is attached read-only. Any number may be // active per task, beside at most one drive hold. HoldModeWatch HoldMode = "watch" )
type HoldRelease ¶ added in v0.3.147
type HoldRelease struct {
// Hold is the hold named, or the task's active drive hold when none
// was named, as it stands now; nil when none was named and the task
// had none.
Hold *TaskHold
// Ended reports whether this call ended Hold; false for one that had
// already ended, which keeps its own time and reason.
Ended bool
// Task is the task as it stands now, and TaskReleased whether this
// call moved it from human-takeover to awaiting-input.
Task *Task
TaskReleased bool
}
HoldRelease is what ReleaseTaskHold did.
type Message ¶
type Message struct {
ID string
// ConversationID is a bare string, the same non-FK convention as
// Task.ConversationID — a conversation isn't a stored entity.
ConversationID string
// TaskID is empty when this turn never touched a task (an
// answer_directly turn).
TaskID string
// DispatchID is the dispatch job this message belongs to (LOOM-80),
// empty for a message written outside one (e.g. the in-process CLI).
DispatchID string
// Origin is where the turn ran, recorded when it's logged so it
// survives the task's deletion: the purpose of the target it acted
// on (TargetPurposePersonal or TargetPurposeWork), MessageOriginNone
// for a turn that touched no target, or empty when unknown — a user
// message stored at submit, before routing, or one from before
// origins were recorded.
Origin string
// OriginTargetID is the target the turn acted on, when it acted on
// one: what its relay policy is read from (TargetPolicy.Relay). Empty
// for older messages, which fall back to their task's target, then
// to Origin's default.
OriginTargetID string
Role MessageRole
Content string
CreatedAt time.Time
}
Message is one entry in a conversation's chat transcript — see design spec docs/design/message-logging-design.md. Append-only: nothing in this codebase ever updates or deletes a Message once written, so there is no UpdateMessage/DeleteMessage on Store.
type MessageRole ¶
type MessageRole string
MessageRole identifies who produced a Message.
const ( MessageRoleUser MessageRole = "user" MessageRoleAssistant MessageRole = "assistant" )
type Plugin ¶ added in v0.3.68
type Plugin struct {
ID string
// Name is the manifest's name ("kubernetes"); Label the instance's,
// unique ("wysekube").
Name string
Label string
// Version and Protocol are the installed manifest's.
Version string
Protocol string
Source PluginSource
// Path is the plugin's directory, or its socket.
Path string
// Trust is one of the PluginTrust* values.
Trust string
Status PluginStatus
StatusReason string
Enabled bool
// Capabilities are the manifest's, as installed; an upgrade compares.
Capabilities []string
// Manifest is the installed manifest as JSON, so the configuration
// form and an upgrade's comparison work without the plugin's files.
Manifest json.RawMessage
// Config is the configuration without its secret fields; Secrets are
// those, plaintext at this level and encrypted at rest. Only
// GetPlugin fills Secrets in; ListPlugins never decrypts.
Config map[string]any
Secrets map[string]string
InstalledAt time.Time
UpdatedAt time.Time
}
Plugin is one installed plugin instance.
type PluginSource ¶ added in v0.3.68
type PluginSource string
PluginSource is where a plugin was found.
const ( // PluginSourceBundled: in the image's bundle directory. PluginSourceBundled PluginSource = "bundled" // PluginSourceDir: in the operator's plugin directory. PluginSourceDir PluginSource = "dir" // PluginSourceSocket: a sidecar serving a unix socket. PluginSourceSocket PluginSource = "socket" )
type PluginStatus ¶ added in v0.3.68
type PluginStatus string
PluginStatus is where an installed plugin is in its life.
const ( // PluginStatusInstalling: the row exists, the plugin hasn't passed its // first check yet. PluginStatusInstalling PluginStatus = "installing" // PluginStatusInstalled: it started, took its configuration and its // check was ok. PluginStatusInstalled PluginStatus = "installed" // PluginStatusDisabled: stopped on purpose; its row and configuration // are kept. PluginStatusDisabled PluginStatus = "disabled" // PluginStatusError: it couldn't start, or its check failed; // StatusReason says why. PluginStatusError PluginStatus = "error" )
type RouterSettingsChange ¶ added in v0.3.64
type RouterSettingsChange struct {
ID string
Tier string
Action string
// Fields are the names of the fields that changed ("provider",
// "base_url", "model", "api_key").
Fields []string
Actor string
CreatedAt time.Time
}
RouterSettingsChange is one audit entry for a router tier change: which fields changed, never their values.
type RouterTier ¶ added in v0.3.64
type RouterTier struct {
// Tier is RouterTierPrimary or RouterTierEscalation: the row's id.
Tier string
Provider string
BaseURL string
Model string
// APIKey is plaintext at this level, like SSHKey.PrivateKey: the
// store encrypts it at rest. Only ListRouterTiers fills it in.
APIKey string
// KeyFingerprint and KeyLast4 identify the key without revealing it.
KeyFingerprint string
KeyLast4 string
SetAt time.Time
}
RouterTier is a router model tier's configuration stored through Settings, overriding the environment's for that tier (LOOM-185).
type SSHKey ¶ added in v0.3.35
type SSHKey struct {
ID string
Name string
// Type is the key's algorithm as ssh names it ("ssh-ed25519").
Type string
// PublicKey is the authorized_keys line to install on a target.
PublicKey string
// Fingerprint is the SHA256 fingerprint as ssh-keygen -l prints it.
Fingerprint string
// Origin is SSHKeyOriginGenerated, SSHKeyOriginImported or
// SSHKeyOriginTarget.
Origin string
// PrivateKey is the OpenSSH-format private key. Plaintext at this
// level, like Credential.Value: the store encrypts it at rest. Only
// GetSSHKey fills it in; nothing else ever reads it back.
PrivateKey []byte
CreatedAt time.Time
}
SSHKey is an SSH key pair Loomux manages for reaching targets (LOOM-138, docs/design/target-onboarding.md): generated in-process, or imported from the deployment's mounted SSH config. A target uses one through Target.SSHKeyRef.
type Session ¶
type Session struct {
ID string
TokenHash string
CreatedAt time.Time
// LastUsedAt drives sliding-expiration: a caller (api package) treats
// a session as expired once too much time has passed since this was
// last updated, and refreshes it (TouchSession) on every authenticated
// request. registry itself has no expiration policy — that's a
// decision for the layer that knows the configured TTL, matching how
// task/workspace status transitions are decided by orchestrator/router,
// not by registry.
LastUsedAt time.Time
// Label names the device the session is on ("laptop"), ClientKind
// the client holding it (a SessionKind value, or empty when unknown),
// both for a person choosing which session to revoke (LOOM-268).
Label string
ClientKind string
// Origin is how the session was made: SessionOriginLogin or
// SessionOriginLink. Only a login session may approve a link, so a
// stolen linked token can't mint itself successors. Empty is treated
// as not a login.
Origin string
}
Session is a client's authenticated bearer-token session (design spec §9: "real login-gated auth"). TokenHash is a SHA-256 hex digest of the raw bearer token the client holds — the raw token itself is never persisted anywhere, only ever returned to the client once at login, so a database compromise alone doesn't hand out working credentials.
type Store ¶
type Store interface {
CreateTarget(ctx context.Context, t *Target) error
GetTarget(ctx context.Context, id string) (*Target, error)
ListTargets(ctx context.Context) ([]*Target, error)
UpdateTarget(ctx context.Context, t *Target) error
DeleteTarget(ctx context.Context, id string) error
// SetTargetAgent records an agent CLI probe result (LOOM-71),
// replacing any earlier one for the same target + agent type. A target
// that doesn't exist is ErrConflict; deleting a target deletes its
// probe results with it.
SetTargetAgent(ctx context.Context, a *TargetAgent) error
// ListTargetAgents returns every recorded probe result for targetID,
// ordered by agent type. A target never probed returns an empty slice.
ListTargetAgents(ctx context.Context, targetID string) ([]*TargetAgent, error)
// GetTargetAgent returns targetID's probe result for agentType, or
// ErrNotFound if it was never probed there (LOOM-316).
GetTargetAgent(ctx context.Context, targetID, agentType string) (*TargetAgent, error)
// SetAgentSignInProblem records the sign-in screen a turn of
// agentType on targetID stopped at (an AgentSignIn* value) and when;
// "" clears it (LOOM-316). SetAgentRateLimit records the usage limit
// a turn hit and its reset text; a zero at clears it.
// ClearAgentTurnIssues clears each of those observed before before (a
// turn that started then finished normally; one seen since is kept),
// and is no error when there is none. SetAgentSignInSession records the sign-in session opened for
// it and when; "" clears it. Each updates the probed row only: none
// there is ErrNotFound (except ClearAgentTurnIssues), and
// SetTargetAgent never changes what they wrote.
SetAgentSignInProblem(ctx context.Context, targetID, agentType, problem string, at time.Time) error
SetAgentRateLimit(ctx context.Context, targetID, agentType string, at time.Time, resets string) error
ClearAgentTurnIssues(ctx context.Context, targetID, agentType string, before time.Time) error
SetAgentSignInSession(ctx context.Context, targetID, agentType, session string, startedAt time.Time) error
// SetTargetHealth records a target's latest health probe (LOOM-86),
// replacing the previous one. A target that doesn't exist is
// ErrConflict; deleting a target deletes its record with it.
SetTargetHealth(ctx context.Context, h *TargetHealth) error
// GetTargetHealth returns targetID's latest health probe, or
// ErrNotFound if it has never been probed.
GetTargetHealth(ctx context.Context, targetID string) (*TargetHealth, error)
// ListTargetHealth returns every recorded health probe, one per
// probed target, in no particular order (LOOM-122: GET /targets in one
// query rather than one per target).
ListTargetHealth(ctx context.Context) ([]*TargetHealth, error)
CreateWorkspace(ctx context.Context, w *Workspace) error
GetWorkspace(ctx context.Context, id string) (*Workspace, error)
GetWorkspaceByName(ctx context.Context, name string) (*Workspace, error)
ListWorkspaces(ctx context.Context) ([]*Workspace, error)
UpdateWorkspace(ctx context.Context, w *Workspace) error
// SetWorkspaceRollingSummary replaces (never appends to) a workspace's
// rolling summary field.
SetWorkspaceRollingSummary(ctx context.Context, id, summary string) error
DeleteWorkspace(ctx context.Context, id string) error
// DeleteWorkspaceAndTasks deletes a workspace together with every
// task in it (their turns with them; messages keep their text, losing
// only the task link) in one transaction (LOOM-70). ErrNotFound for an
// unknown id; ErrConflict, deleting nothing, while a credential is
// still scoped to the workspace.
DeleteWorkspaceAndTasks(ctx context.Context, id string) error
CreateTask(ctx context.Context, t *Task) error
GetTask(ctx context.Context, id string) (*Task, error)
ListTasksByWorkspace(ctx context.Context, workspaceID string) ([]*Task, error)
// ListTasks returns every task across every workspace — a
// conversation isn't pinned to one workspace (the router can route
// the same conversation_id to a different workspace on a later
// message), so listing/grouping by conversation needs the
// unfiltered view rather than ListTasksByWorkspace.
ListTasks(ctx context.Context) ([]*Task, error)
// ListTasksByConversation returns conversationID's tasks, oldest
// first; unknown is empty (LOOM-145: a conversation's event stream
// polls this, not every task).
ListTasksByConversation(ctx context.Context, conversationID string) ([]*Task, error)
UpdateTask(ctx context.Context, t *Task) error
// TransitionTask is a compare-and-set status write (LOOM-262): it
// writes t's status and the fields that go with a status change
// (completed_at, exit_code, failure_reason, error_class, output_tail,
// attention) only while the stored status is still from, and reports
// whether it did. A status changed meanwhile — a cancel, later a
// human takeover — is never overwritten by a writer that read the
// task before the change. reaped_at is left alone: SetTaskReapedAt
// owns it. ErrNotFound for an unknown id.
TransitionTask(ctx context.Context, t *Task, from TaskStatus) (applied bool, err error)
// SetTaskReapedAt records that the idle reaper tore the task's
// session down, touching nothing else (LOOM-120): a whole-row
// UpdateTask from the reaper could revert a concurrent status change.
// ErrNotFound for an unknown id.
SetTaskReapedAt(ctx context.Context, id string, at time.Time) error
DeleteTask(ctx context.Context, id string) error
// CreateTaskTurn records one turn of a task (LOOM-91), stamping
// CreatedAt; a task that doesn't exist is ErrConflict. Deleting a
// task deletes its turns.
CreateTaskTurn(ctx context.Context, t *TaskTurn) error
// ListTaskTurns returns taskID's turns, oldest first; none (or an
// unknown task) is an empty slice.
ListTaskTurns(ctx context.Context, taskID string) ([]*TaskTurn, error)
// ListTaskTurnsPage returns up to limit of taskID's turns, the latest
// ones recorded before the turn beforeID (any, when empty), oldest
// first; more reports whether earlier ones remain (LOOM-122). An
// unknown beforeID is ErrNotFound.
ListTaskTurnsPage(ctx context.Context, taskID, beforeID string, limit int) (turns []*TaskTurn, more bool, err error)
// DeleteTaskTurnsBefore deletes every task's turns recorded before
// cutoff (retention, LOOM-122), returning how many it deleted.
DeleteTaskTurnsBefore(ctx context.Context, cutoff time.Time) (int, error)
// CreateMessage and ListMessagesByConversation store the per-turn
// chat transcript (design spec docs/design/message-logging-design.md).
// Messages are append-only — there is no update/delete here by
// design (see registry.Message's doc comment).
CreateMessage(ctx context.Context, m *Message) error
// ListMessagesByConversation returns every message for
// conversationID, oldest first (insertion order). An unknown
// conversationID returns an empty slice, not an error — mirrors
// ListTasks's own "conversation isn't a stored entity" stance;
// there's nothing to 404 on at this layer.
ListMessagesByConversation(ctx context.Context, conversationID string) ([]*Message, error)
// ListMessagesAfter returns conversationID's messages stored after
// the message afterID, in storage order (LOOM-145: a stream reads
// only what's new). An empty or unknown afterID returns them all.
ListMessagesAfter(ctx context.Context, conversationID, afterID string) ([]*Message, error)
// ListConversationActivity returns one ConversationActivity per
// distinct conversation_id in the message log, in no particular
// order; an empty log returns an empty slice. It is how a
// conversation with no tasks at all is discovered (LOOM-62).
ListConversationActivity(ctx context.Context) ([]*ConversationActivity, error)
// CreateDispatch, GetDispatch, GetDispatchByIdempotencyKey,
// ListDispatchesByConversation, ListDispatchesByStatus and
// TransitionDispatch back dispatch jobs (LOOM-80).
//
// CreateDispatch stores d (Status queued, or as given) and, when
// userMessage is non-nil, that message with DispatchID = d.ID, in one
// transaction: both or neither. It fails with ErrIdempotencyKeyExists
// when d.IdempotencyKey is already held, and ErrConversationBusy when
// d.ConversationID already has a queued or running dispatch.
CreateDispatch(ctx context.Context, d *Dispatch, userMessage *Message) error
GetDispatch(ctx context.Context, id string) (*Dispatch, error)
GetDispatchByIdempotencyKey(ctx context.Context, key string) (*Dispatch, error)
// ListDispatchesByConversation returns oldest first; unknown is empty.
ListDispatchesByConversation(ctx context.Context, conversationID string) ([]*Dispatch, error)
// ListDispatchesAfter returns conversationID's dispatches created
// after the dispatch afterID, plus those named in also, in creation
// order (LOOM-145: a stream rereads only new jobs and the ones it
// last saw unfinished). An empty or unknown afterID returns them all.
ListDispatchesAfter(ctx context.Context, conversationID, afterID string, also []string) ([]*Dispatch, error)
// ListDispatchesByStatus returns every dispatch in any of statuses.
ListDispatchesByStatus(ctx context.Context, statuses ...DispatchStatus) ([]*Dispatch, error)
// TransitionDispatch writes d's status, reply, error, error class and
// started/finished times, but only if the stored status is still
// from; otherwise ErrDispatchStateChanged (ErrNotFound if no such
// dispatch). It stamps d.UpdatedAt.
TransitionDispatch(ctx context.Context, d *Dispatch, from DispatchStatus) error
// DeleteDispatchesFinishedBefore deletes the finished dispatches
// (succeeded, failed, interrupted) that finished before cutoff
// (retention, LOOM-193), returning how many it deleted. A queued or
// running dispatch is never deleted; the messages of a deleted one
// are kept, no longer naming it. Like every retention delete it
// works in batches, and on an error still returns how many it
// deleted before it.
DeleteDispatchesFinishedBefore(ctx context.Context, cutoff time.Time) (int, error)
// CreateConfirmation, ResolveConfirmation,
// ListConfirmationsByConversation and ExpirePendingConfirmations
// record offers awaiting the user's yes (LOOM-123).
CreateConfirmation(ctx context.Context, c *Confirmation) error
// ResolveConfirmation moves a pending confirmation to status, with
// reason (Confirmation.StatusReason, may be empty); ErrConflict if it
// isn't pending any more, ErrNotFound if unknown.
ResolveConfirmation(ctx context.Context, id string, status ConfirmationStatus, reason string) error
// ListConfirmationsByConversation returns oldest first.
ListConfirmationsByConversation(ctx context.Context, conversationID string) ([]*Confirmation, error)
// ExpirePendingConfirmations marks every pending confirmation
// expired, returning how many: at startup, since a restart forgets
// the offers themselves.
ExpirePendingConfirmations(ctx context.Context) (int, error)
// DeleteConfirmationsResolvedBefore deletes the resolved
// confirmations (approved, denied, expired) resolved before cutoff
// (retention, LOOM-193), returning how many it deleted. A pending
// one is never deleted.
DeleteConfirmationsResolvedBefore(ctx context.Context, cutoff time.Time) (int, error)
// CreateTaskHold, AcquireDriveHold, GetTaskHold, GetActiveDriveHold,
// ListActiveTaskHolds, RenewTaskHold, EndTaskHold, ReleaseTaskHold,
// ExtendActiveTaskHolds and DeleteTaskHoldsEndedBefore keep holds:
// leases on a task by an API session (LOOM-263). Times are stored in
// UTC.
//
// CreateTaskHold stores h as an active hold: TTL must be positive,
// AcquiredAt is stamped now if zero, RenewedAt is AcquiredAt,
// ExpiresAt is AcquiredAt + TTL, and EndedAt and EndedReason are
// cleared. A task has at most one active drive hold: a second is
// ErrTaskHeld, and of several racing creates exactly one succeeds.
// Watch holds aren't limited. A task that doesn't exist, or an id
// already used, is ErrConflict. Deleting a task deletes its holds.
// It never touches the task; a drive hold that goes with a status
// change is AcquireDriveHold's.
CreateTaskHold(ctx context.Context, h *TaskHold) error
// AcquireDriveHold makes h (a drive hold, stamped as by
// CreateTaskHold) the task's active drive hold and writes t's status
// change, as one transaction: a human takeover. Like TransitionTask
// it is a compare-and-set on the task's status: unless the stored
// status is still from, nothing is written and applied is false.
// When t.Status differs from from, the task's status (and nothing
// else of t, which may be older than the row) is written; when they
// are equal the task is left untouched. A task
// that already has an active drive hold is ErrTaskHeld, unless
// replace is set: then that hold is ended with replace as its reason
// at h.AcquiredAt, and returned as ended. ErrNotFound for an unknown
// task; h.TaskID must be t.ID.
AcquireDriveHold(ctx context.Context, h *TaskHold, t *Task, from TaskStatus, replace HoldEndReason) (ended *TaskHold, applied bool, err error)
// GetTaskHold returns a hold, active or ended; ErrNotFound if unknown.
GetTaskHold(ctx context.Context, id string) (*TaskHold, error)
// GetActiveDriveHold returns taskID's active drive hold; ErrNotFound
// if it has none (or there is no such task).
GetActiveDriveHold(ctx context.Context, taskID string) (*TaskHold, error)
// ListActiveTaskHolds returns every hold that hasn't ended, of every
// task and mode, oldest acquired first; none is an empty slice. A
// hold past its ExpiresAt is still listed until it is ended.
ListActiveTaskHolds(ctx context.Context) ([]*TaskHold, error)
// RenewTaskHold renews an active hold at at (RenewedAt at, ExpiresAt
// at + its TTL unless it is already later: a renewal never shortens
// a lease) and returns it. An ended hold is left as it is and
// returned with ErrHoldEnded; ErrNotFound if unknown.
RenewTaskHold(ctx context.Context, id string, at time.Time) (*TaskHold, error)
// EndTaskHold ends an active hold with reason at at and returns it
// with ended true. A hold that has already ended keeps its own time
// and reason and is returned with ended false: ending is idempotent,
// and of several racing enders exactly one sees true. ErrNotFound if
// unknown. It never touches the task; see ReleaseTaskHold.
EndTaskHold(ctx context.Context, id string, reason HoldEndReason, at time.Time) (h *TaskHold, ended bool, err error)
// ReleaseTaskHold ends a hold and hands its task back to automation,
// as one transaction. With holdID it ends that hold, as EndTaskHold
// does (ErrNotFound if it is unknown or isn't taskID's); with holdID
// empty it ends taskID's active drive hold, if it has one. Then,
// unless the hold named is a watch hold: if the task is left with no
// active drive hold and is in human-takeover, it becomes
// awaiting-input and its attention is cleared. A task in any other
// status keeps it, and so does a task some other drive hold still
// holds. ErrNotFound for an unknown task.
ReleaseTaskHold(ctx context.Context, taskID, holdID string, reason HoldEndReason, at time.Time) (*HoldRelease, error)
// ExtendActiveTaskHolds gives every active hold a full lease counted
// from from: an ExpiresAt before from + the hold's TTL is moved there
// (a later one is left). It returns how many it moved. For startup,
// so that the time the server was down doesn't count against a lease.
ExtendActiveTaskHolds(ctx context.Context, from time.Time) (int, error)
// DeleteTaskHoldsEndedBefore deletes the holds that ended before
// cutoff (retention, as for confirmations), returning how many it
// deleted. An active hold is never deleted.
DeleteTaskHoldsEndedBefore(ctx context.Context, cutoff time.Time) (int, error)
// SetTargetHostKeys pins (or, with "", unpins) a target's host keys
// (LOOM-114); ErrNotFound if there's no such target.
SetTargetHostKeys(ctx context.Context, id, hostKeys string) error
// CreateDispatchEvent, ListDispatchEventsByConversation and
// DeleteDispatchEventsBefore keep the audit trail (LOOM-110).
// CreateDispatchEvent stamps CreatedAt if zero.
CreateDispatchEvent(ctx context.Context, e *DispatchEvent) error
// ListDispatchEventsByConversation returns oldest first; unknown is
// empty.
ListDispatchEventsByConversation(ctx context.Context, conversationID string) ([]*DispatchEvent, error)
// DeleteDispatchEventsBefore deletes events recorded before cutoff
// (retention), returning how many it deleted.
DeleteDispatchEventsBefore(ctx context.Context, cutoff time.Time) (int, error)
// CreateCredential, GetCredential, ListCredentials, and
// DeleteCredential are the vault (design spec §7's second half).
// Credential.Value is plaintext at this interface's boundary; a
// backend implementation is responsible for encrypting it at rest
// and decrypting on read.
CreateCredential(ctx context.Context, c *Credential) error
GetCredential(ctx context.Context, id string) (*Credential, error)
ListCredentials(ctx context.Context) ([]*Credential, error)
DeleteCredential(ctx context.Context, id string) error
// ListCredentialInfo lists every credential without its value, and
// without decrypting anything (LOOM-134): it works with no or a wrong
// master key, so rows that no longer decrypt can still be found and
// deleted.
ListCredentialInfo(ctx context.Context) ([]*Credential, error)
// SetCredentialValue replaces a credential's value (LOOM-134), keeping
// its name and scope.
SetCredentialValue(ctx context.Context, id, value string) error
// CreateSSHKey, GetSSHKey, ListSSHKeys and DeleteSSHKey keep the SSH
// keys Loomux manages (LOOM-138). CreateSSHKey stamps CreatedAt and
// encrypts PrivateKey at rest (ErrNoMasterKey without a master key);
// a duplicate name is ErrConflict. GetSSHKey decrypts it.
// ListSSHKeys returns every key without PrivateKey, ordered by name,
// decrypting nothing. DeleteSSHKey is ErrConflict while a target's
// SSHKeyRef names the key; a target can only name a key that exists
// (ErrConflict on create or update otherwise).
CreateSSHKey(ctx context.Context, k *SSHKey) error
GetSSHKey(ctx context.Context, id string) (*SSHKey, error)
ListSSHKeys(ctx context.Context) ([]*SSHKey, error)
DeleteSSHKey(ctx context.Context, id string) error
// SetRouterTier, ListRouterTiers, DeleteRouterTier and
// ListRouterSettingsChanges keep the router model tiers set through
// Settings and their audit trail (LOOM-185). SetRouterTier inserts or
// replaces t's row and records change in the same transaction,
// stamping both times; APIKey is encrypted at rest (ErrNoMasterKey
// without a master key). ListRouterTiers decrypts every row, ordered
// by tier; a row that doesn't decrypt (or any, without a master key)
// is returned without APIKey and with the error joined into err (the
// others still come back).
// DeleteRouterTier deletes the row and records change, ErrNotFound if
// there is none. ListRouterSettingsChanges returns up to limit
// entries, newest first.
SetRouterTier(ctx context.Context, t *RouterTier, change *RouterSettingsChange) error
ListRouterTiers(ctx context.Context) ([]*RouterTier, error)
DeleteRouterTier(ctx context.Context, tier string, change *RouterSettingsChange) error
ListRouterSettingsChanges(ctx context.Context, limit int) ([]*RouterSettingsChange, error)
// A session also carries its Label, ClientKind and Origin (LOOM-268),
// stored as given and returned by every read; a second session with
// a TokenHash already held is ErrConflict.
//
// CreateSession, GetSessionByTokenHash, ListSessions, TouchSession,
// and DeleteSession back client auth (design spec §9). TouchSession
// updates LastUsedAt (sliding expiration); a caller with an unknown
// id gets ErrNotFound, matching every other Update-shaped method
// here. ListSessions (LOOM-47) backs a "which devices are logged in"
// view and revoke-by-id, alongside the existing self-revoke-only
// DeleteSession (already used by /logout for the presented token).
CreateSession(ctx context.Context, s *Session) error
GetSessionByTokenHash(ctx context.Context, tokenHash string) (*Session, error)
// ListSessions returns every session, ordered most-recently-used
// first — the order a "revoke a device" UI would want a session
// list rendered in.
ListSessions(ctx context.Context) ([]*Session, error)
TouchSession(ctx context.Context, id string, lastUsedAt time.Time) error
DeleteSession(ctx context.Context, id string) error
// DeleteSessionsExpiredBefore deletes the sessions last used before
// lastUsedBefore, or created before createdBefore unless that is
// zero (retention, LOOM-193): a caller passes "expired a while ago"
// under the sliding window and the absolute lifetime. It returns
// how many it deleted.
DeleteSessionsExpiredBefore(ctx context.Context, lastUsedBefore, createdBefore time.Time) (int, error)
// CreatePlugin, GetPlugin, ListPlugins, UpdatePlugin, SetPluginConfig
// and DeletePlugin keep the installed plugins (LOOM-178). CreatePlugin
// stamps InstalledAt/UpdatedAt and encrypts Secrets at rest
// (ErrNoMasterKey if there are any and no master key); a duplicate
// label is ErrConflict. GetPlugin decrypts Secrets (a row that doesn't
// decrypt comes back with Secrets nil and ErrNoMasterKey, or the
// decryption error, joined). ListPlugins returns every plugin ordered by
// label, decrypting nothing. UpdatePlugin writes status, reason,
// enabled, version, protocol, capabilities, path and trust, never the
// configuration; SetPluginConfig replaces the configuration and the
// secrets (nil or empty secrets store none). Unknown ids are
// ErrNotFound.
CreatePlugin(ctx context.Context, p *Plugin) error
GetPlugin(ctx context.Context, id string) (*Plugin, error)
ListPlugins(ctx context.Context) ([]*Plugin, error)
UpdatePlugin(ctx context.Context, p *Plugin) error
SetPluginConfig(ctx context.Context, id string, config map[string]any, secrets map[string]string) error
DeletePlugin(ctx context.Context, id string) error
// CreateEnvironment, GetEnvironment, GetEnvironmentByTarget,
// ListEnvironments, ListEnvironmentsByPlugin, UpdateEnvironment and
// DeleteEnvironment keep the machines plugins made (LOOM-178,
// docs/design/target-providers.md §1.7). CreateEnvironment stamps
// CreatedAt/UpdatedAt and encrypts HostPrivateKey at rest
// (ErrNoMasterKey without a key); its target must exist and have no
// environment yet (ErrConflict). GetEnvironment decrypts the key;
// the list methods never do. UpdateEnvironment writes status, reason,
// plugin id and version, image and digest. Unknown ids are
// ErrNotFound; GetEnvironmentByTarget is ErrNotFound for a target
// with none. A target with an environment can't be deleted
// (ErrConflict), nor a plugin that environments still name.
// CreateEnvironmentWithin is CreateEnvironment admitting the row only
// while fewer than max environments name its plugin (ErrQuota, and
// nothing written, otherwise), the count and the insert one atomic
// step for every connection and process on the store, so two creates
// can't both take the last place (LOOM-244); max 0 is no limit.
CreateEnvironment(ctx context.Context, e *Environment) error
CreateEnvironmentWithin(ctx context.Context, e *Environment, max int) error
GetEnvironment(ctx context.Context, id string) (*Environment, error)
GetEnvironmentByTarget(ctx context.Context, targetID string) (*Environment, error)
ListEnvironments(ctx context.Context) ([]*Environment, error)
ListEnvironmentsByPlugin(ctx context.Context, pluginID string) ([]*Environment, error)
UpdateEnvironment(ctx context.Context, e *Environment) error
DeleteEnvironment(ctx context.Context, id string) error
// GetSetting and SetSetting keep server-wide settings by key
// (LOOM-178: the instance id). GetSetting is ErrNotFound for a key
// never set; SetSetting creates or overwrites.
GetSetting(ctx context.Context, key string) (string, error)
SetSetting(ctx context.Context, key, value string) error
Close() error
}
Store is the backend-agnostic interface every storage implementation satisfies. It intentionally has no SQL- or driver-specific types in its signature so a backend can be swapped without changing callers.
type Target ¶
type Target struct {
ID string
Name string
Kind TargetKind
Host string // empty for local
User string // empty for local
SSHKeyRef string // reference/identifier only; actual secret material lives in the credential vault (§7)
// WorkspaceRoot is the directory every dynamic workspace on this
// target is provisioned under (LOOM-90): an absolute, clean path.
// Empty means $HOME/loomux-workspaces on the target. Provisioning
// refuses any workspace whose resolved directory — symlinks followed —
// isn't inside it.
WorkspaceRoot string
// PermissionMode is how much the agents launched on this target may
// do without asking (one of the PermissionMode* values); empty means
// each agent-type's own default. Per-target, so policy (LOOM-89) can
// tighten it on, say, a work-only host.
PermissionMode string
// AgentArgs pin the model and effort each agent type is launched
// with on this target (LOOM-307), keyed by agent type; an agent type
// with no entry runs on its CLI's own defaults. Per-target, like
// PermissionMode: a shared work host's owner can require them.
AgentArgs map[string]AgentArgs
// Policy is what Loomux may do on this target (LOOM-89). The zero
// value allows everything, as before policies existed.
Policy TargetPolicy
// SSHPort, when non-zero, overrides the port the SSH config gives
// for this target (LOOM-114: per-target options override the
// mounted config, never replace it).
SSHPort int
// HostKeys are the known_hosts lines pinned for this target through
// the API (LOOM-114), or empty. A pinned target is checked against
// these alone; others against the mounted known_hosts. Written only
// through SetTargetHostKeys, never by UpdateTarget.
HostKeys string
// SSHProxy is, for a managed target, whether its connections go
// through the server's LOOMUX_SSH_PROXY ("", the default) or straight
// to the host (SSHProxyNone). A config-mode target's proxy is the SSH
// config's, so it must be "".
SSHProxy string
CreatedAt time.Time
UpdatedAt time.Time
// ConnectionChangedAt is when how Loomux reaches the target last
// changed (LOOM-256): its kind, host, user, port, key, proxy or
// workspace root, or its host key pin. A probe older than that says
// nothing about the target; a new name, permission mode or policy
// doesn't make one stale. Set by the store.
ConnectionChangedAt time.Time
}
Target is a host Loomux can run tmux sessions on.
type TargetAgent ¶
type TargetAgent struct {
TargetID string
AgentType string
Available bool
// Path is the absolute path the CLI resolved to on the target, and
// Version the first line its --version printed (LOOM-79). Launches
// use Path, so the version recorded is the version that runs. Empty
// when unavailable.
Path string
Version string
// AuthStatus is whether the CLI reported itself signed in when probed
// (LOOM-86): one of the AgentAuth* values, empty when not checked.
AuthStatus string
CheckedAt time.Time
// AuthMethod, AuthPlan and AuthExpiresAt are how the same auth check
// said the CLI is signed in (LOOM-316): its method ("claude.ai",
// "api_key", "chatgpt"), the account's plan ("max") and when the
// sign-in ends. Short allow-listed words only; empty or nil when the
// CLI doesn't say. Written by SetTargetAgent.
AuthMethod string
AuthPlan string
AuthExpiresAt *time.Time
// What turns saw (LOOM-316), which SetTargetAgent never touches:
// SignInProblem (an AgentSignIn* value) is the sign-in screen a turn
// last stopped at, LimitedAt and LimitResets the usage limit it last
// hit and when the agent said it resets. Cleared when a later turn
// finishes normally.
SignInProblem string
SignInProblemAt *time.Time
LimitedAt *time.Time
LimitResets string
// SignInSession is the tmux session Loomux opened for a person to
// sign the CLI in (LOOM-316), and SignInStartedAt when; empty and nil
// when none is open. Written by SetAgentSignInSession only.
SignInSession string
SignInStartedAt *time.Time
}
TargetAgent records whether an agent-type's CLI was found on a target the last time Loomux probed for it (LOOM-71) — a `command -v` of the CLI through the target's executor. Rows exist only for agent-types that have been probed; no row means "unknown", not "absent". Refreshed on every pre-launch probe and on demand.
func (*TargetAgent) OpenSignInSession ¶ added in v0.3.160
func (a *TargetAgent) OpenSignInSession(now time.Time) string
OpenSignInSession is the agent's sign-in session if one is recorded and younger than SignInSessionTTL at now, else "".
func (*TargetAgent) SignInState ¶ added in v0.3.160
func (a *TargetAgent) SignInState(now time.Time) string
SignInState is the one word a client shows for the agent's sign-in at now (LOOM-316): "" when the CLI isn't installed or wasn't asked; else logged_out if the CLI says so; else what a turn saw (expired for an expired or refused credential, logged_out for a login screen); else expired if the sign-in's own end has passed; else rate_limited after a usage limit; else what the CLI said (logged_in, unknown).
type TargetHealth ¶
type TargetHealth struct {
TargetID string
// Reachable is whether the probe could run a command on the target
// at all; Error says why not, or what else is wrong with it.
Reachable bool
Error string
// Latency is how long the probe command took, end to end.
Latency time.Duration
TmuxVersion string
// DiskFreeBytes is the space free on the filesystem holding the
// target's workspace root; -1 when unknown.
DiskFreeBytes int64
ProbedAt time.Time
}
TargetHealth is a target's latest health probe (LOOM-86), refreshed periodically and on demand. No record means never probed.
type TargetKind ¶
type TargetKind string
TargetKind identifies where a target's tmux sessions run.
const ( TargetKindLocal TargetKind = "local" TargetKindRemote TargetKind = "remote" )
type TargetPolicy ¶
type TargetPolicy struct {
// Purpose is TargetPurposePersonal or TargetPurposeWork; empty is
// personal. A work machine runs agents under the user's work logins.
Purpose string
// AllowedAgentTypes, if non-empty, are the only agent types that may
// run there.
AllowedAgentTypes []string
// NoProvision forbids creating workspaces there; NoShell forbids
// running plain shell commands.
NoProvision bool
NoShell bool
// RequireConfirmation makes new work there — a new workspace, a
// command, an agent started in a workspace — wait for the user's
// "yes" in chat to the plan.
RequireConfirmation bool
// Relay is how much of this target's work Loomux's router models (a
// third-party API) may see: RelayFull, RelayLastMessage or RelayNone.
// Empty means the purpose's default (EffectiveRelay).
Relay string
// KeepIdleSessions exempts the target's sessions from the idle
// reaper (LOOM-227): one left waiting for a follow-up stays open
// however long it waits, as a hub's own session must.
KeepIdleSessions bool
}
TargetPolicy is what Loomux may do on a target (LOOM-89), enforced by the router after the routing decision, before anything runs — never left to the routing model. Its zero value allows everything.
func (TargetPolicy) AllowsAgent ¶
func (p TargetPolicy) AllowsAgent(agentType string) bool
AllowsAgent reports whether agentType may run under p.
func (TargetPolicy) EffectiveRelay ¶ added in v0.3.11
func (p TargetPolicy) EffectiveRelay() string
EffectiveRelay is p.Relay, or the default for p's purpose: none for a work machine, full otherwise.
type Task ¶
type Task struct {
ID string
WorkspaceID string
Kind TaskKind
AgentType string // empty for shell panes
TmuxSession string
Status TaskStatus
// ConversationID identifies the chat conversation this task belongs to.
ConversationID string
CreatedAt time.Time
UpdatedAt time.Time
StartedAt *time.Time
CompletedAt *time.Time
// ReapedAt is set when the idle reaper (design spec's continuation
// model, LOOM-16) tears down this task's session for inactivity.
// Purely informational — it does not change Status or otherwise gate
// resumability: a follow-up message still finds this task via its
// (unchanged) Status, discovers the session is gone, and the router
// falls back to a fresh task (a new row, ReapedAt naturally nil)
// rather than clearing this one's marker in place.
ReapedAt *time.Time
// AgentArgs are the model and effort an agent task was launched
// with (LOOM-307): its target's pin for the agent type at launch,
// zero when nothing was pinned. Written at creation only.
AgentArgs AgentArgs
// Command is what a TaskKindCommand task ran, verbatim. Empty for
// every other kind: an agent's launch command carries injected
// credentials (credentials.ShellEnvPrefix) and is never stored.
Command string
// ExitCode is a TaskKindCommand task's exit status once its process
// has exited; nil while it is still running or for any other kind.
ExitCode *int
// FailureReason, ErrorClass and OutputTail say why a
// TaskStatusFailed task failed (LOOM-77): a human-readable reason, a
// stable machine-readable class, and the last of the pane's output
// when there was any (bounded, credentials redacted). Empty for a task
// that hasn't failed.
FailureReason string
ErrorClass ErrorClass
OutputTail string
// Attention is the prompt a TaskStatusNeedsAttention task is stopped
// at (LOOM-97); nil otherwise.
Attention *Attention
}
Task is a single tmux pane's lifecycle record, scoped to a workspace.
type TaskFailure ¶
type TaskFailure struct {
Class ErrorClass
Reason string
OutputTail string
}
TaskFailure is what a failing task records (see Task.FailureReason).
type TaskHold ¶ added in v0.3.147
type TaskHold struct {
ID string
TaskID string
// SessionID is the API session that took the hold. It is not a
// foreign key: the session may be deleted while the ended hold is
// kept.
SessionID string
// ClientKind and ClientLabel describe the holder for other clients
// ("tui", "laptop"). Either may be empty.
ClientKind string
ClientLabel string
Mode HoldMode
// PrevStatus is the task's status when the hold was taken, for
// display and audit.
PrevStatus TaskStatus
// TTL is the lease's length: the hold expires TTL after it was
// acquired or last renewed.
TTL time.Duration
AcquiredAt time.Time
RenewedAt time.Time
ExpiresAt time.Time
// EndedAt and EndedReason are set once, when the hold ends.
EndedAt *time.Time
EndedReason HoldEndReason
}
TaskHold is a lease on one task by one API session (LOOM-263): who is attached to the task's pane, since when, and until when unless renewed. The hold says who; the task's status (human-takeover) still says whether automation may type. A hold is active until EndedAt is set, and an ended one is kept as the audit trail until retention deletes it.
type TaskKind ¶
type TaskKind string
TaskKind identifies what a tmux pane is running.
const ( TaskKindAgent TaskKind = "agent" TaskKindShell TaskKind = "shell" // TaskKindCommand is a one-shot command run as the pane's own process // — an agent CLI install (LOOM-71), a direct shell command (LOOM-72). // Its completion is the process exiting (completion.TierExit), never // an idle heuristic, and the exit code is recorded on the task. TaskKindCommand TaskKind = "command" )
type TaskStatus ¶
type TaskStatus string
TaskStatus tracks a task's current lifecycle state.
const ( TaskStatusRunning TaskStatus = "running" TaskStatusAwaitingInput TaskStatus = "awaiting-input" TaskStatusHumanTakeover TaskStatus = "human-takeover" // TaskStatusNeedsAttention: the agent is stopped at a prompt only a // human can answer — an approval its permission mode still asks for, // a question, a trust dialog (LOOM-97). Task.Attention says what it // shows; the conversation's next message answers it. TaskStatusNeedsAttention TaskStatus = "needs-attention" TaskStatusCompleted TaskStatus = "completed" TaskStatusFailed TaskStatus = "failed" )
type TaskTurn ¶
type TaskTurn struct {
ID string
TaskID string
// UserMessage is the message the turn sent the agent.
UserMessage string
// AgentMessage is the agent's own final message for the turn, from
// its completion hook; empty when it saved none.
AgentMessage string
// Pane is the pane's scrollback when the turn ended, bounded.
Pane string
CreatedAt time.Time
}
TaskTurn is what one turn of a task produced (LOOM-91), kept after the task ends so a person can see what actually happened, not only the relay's summary of it. Credential values are redacted before storing.
type Workspace ¶
type Workspace struct {
ID string
Name string
Path string
TargetID string
GitRemote string // empty if none
Tags []string
Description string
// Capabilities lists the MCPs/tools available in this workspace.
Capabilities []string
Status WorkspaceStatus
IsDynamic bool
LastUsedAt *time.Time
// RollingSummary is replaced (never appended to) on each update — see
// SetWorkspaceRollingSummary.
RollingSummary string
// StatusReason says why the workspace is in its Status when that
// isn't self-explanatory — e.g. what made it failed (LOOM-77). Empty
// otherwise.
StatusReason string
CreatedAt time.Time
UpdatedAt time.Time
}
Workspace is a directory (with an optional git remote) bound to exactly one target.
type WorkspaceStatus ¶
type WorkspaceStatus string
WorkspaceStatus tracks a workspace's current lifecycle state.
const ( WorkspaceStatusIdle WorkspaceStatus = "idle" WorkspaceStatusActive WorkspaceStatus = "active" WorkspaceStatusProvisioning WorkspaceStatus = "provisioning" WorkspaceStatusArchived WorkspaceStatus = "archived" // WorkspaceStatusFailed marks a workspace whose provisioning failed // (LOOM-71). The row is kept for inspection rather than deleted, but // it is never offered to the routing model again — dispatching into a // workspace whose setup never finished would only fail later and // less legibly. WorkspaceStatusFailed WorkspaceStatus = "failed" )
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package sqlite is a registry.Store implementation backed by SQLite via the pure-Go modernc.org/sqlite driver (no cgo), so the server can still build as a single static binary.
|
Package sqlite is a registry.Store implementation backed by SQLite via the pure-Go modernc.org/sqlite driver (no cgo), so the server can still build as a single static binary. |
|
Package storetest is the backend-conformance test suite for registry.Store.
|
Package storetest is the backend-conformance test suite for registry.Store. |