897 lines
35 KiB
Python
897 lines
35 KiB
Python
"""Small mutation / misc envelopes (ui state, models, accounts, workers,
|
||
spawn/upload results, meta) and the deploy status banner."""
|
||
from __future__ import annotations
|
||
|
||
from typing import Literal, Optional, Union
|
||
|
||
from .base import Schema
|
||
from .conversations import ConvMeta
|
||
|
||
__all__ = [
|
||
"ServiceGoal",
|
||
"ServiceIndexEntry",
|
||
"ServicesIndexResponse",
|
||
"UiStateValue",
|
||
"OkResponse",
|
||
"ModelInfo",
|
||
"ModelsResponse",
|
||
"PendingLogin",
|
||
"AccountStatus",
|
||
"LoginCodeResult",
|
||
"Account",
|
||
"AccountsResponse",
|
||
"Worker",
|
||
"WorkerClaudeProxy",
|
||
"WorkerOpencodeProxy",
|
||
"WorkersResponse",
|
||
"OpenRouterModel",
|
||
"OpenRouterModelsResponse",
|
||
"SpawnResult",
|
||
"CodeModeRunner",
|
||
"CodeModeStatus",
|
||
"InterruptResult",
|
||
"UploadedFile",
|
||
"UploadResult",
|
||
"ConversationMetaResponse",
|
||
"MetaUpdateResult",
|
||
"ArchiveOldResult",
|
||
"BannerStep",
|
||
"BannerStatus",
|
||
]
|
||
|
||
|
||
# ── small mutation / misc envelopes ───────────────────────────────────────────
|
||
class UiStateValue(Schema):
|
||
value: Optional[str] = None
|
||
|
||
|
||
class OkResponse(Schema):
|
||
ok: bool
|
||
|
||
|
||
class ModelInfo(Schema):
|
||
"""One pickable model (a model tag in the composer)."""
|
||
id: str # the exact `--model` argument
|
||
displayName: str
|
||
family: str # opus | sonnet | haiku | fable | qwen
|
||
version: str # "4.8", "5", … (within the family)
|
||
alias: Optional[str] = None # CLI shorthand, only on a family's newest
|
||
latest: bool = False
|
||
# Which agent harness runs sessions on this model: "claude" (the claude
|
||
# CLI), "pi" (the pi.dev runner), "opencode" (opencode on the ChatGPT
|
||
# seat) or "agy" (Antigravity's CLI on the Google AI Pro plan). Picking
|
||
# the chip picks the harness.
|
||
harness: Optional[str] = None
|
||
# pi: "openrouter" (hosted) or "evox2" (local LM Studio); opencode:
|
||
# "openai"; agy: "google".
|
||
provider: Optional[str] = None
|
||
# opencode / agy: the reasoning levels the model takes (none…max) — the
|
||
# composer's effort select for it.
|
||
efforts: Optional[list[str]] = None
|
||
# opencode: a priority-tier variant (`-fast` / `-ultrafast`, 2× / 6× price).
|
||
fast: Optional[bool] = None
|
||
# Optional short chip label ("qwen 3.6 local"); the frontend derives one
|
||
# from the id when absent.
|
||
label: Optional[str] = None
|
||
# Context-window size in tokens (`max_input_tokens` from the Anthropic
|
||
# Models API, with a static per-family fallback). Drives the conversation
|
||
# page's context-fill gizmo.
|
||
contextWindow: Optional[int] = None
|
||
# Why this model can't take a run right now (an OpenRouter pi model while
|
||
# the key is refused): the composer greys the chip out with this as its hint.
|
||
unavailable: Optional[str] = None
|
||
# The model this entry is one harness's (or one GPT tier's) way of running
|
||
# (models/presets.py key_of): a Claude family, a pi id, a GPT base id.
|
||
key: Optional[str] = None
|
||
# anthropic | google | openai | evox2 | openrouter — the picker's groups.
|
||
vendor: Optional[str] = None
|
||
# A GPT tier variant's tier: fast | ultrafast.
|
||
fastMode: Optional[str] = None
|
||
|
||
|
||
class ModelPreset(Schema):
|
||
"""What a run on a model starts with (Settings → Models, models/presets.py)."""
|
||
harness: str
|
||
effort: str = ""
|
||
thinking: bool = True
|
||
fast: str = ""
|
||
favorite: bool = False
|
||
guests: Optional[bool] = None # the owner's view only: in the guest pool
|
||
|
||
|
||
class ModelsResponse(Schema):
|
||
models: list[ModelInfo]
|
||
default: str # model a run uses when nothing is picked
|
||
presets: dict[str, ModelPreset] = {} # by model key
|
||
|
||
|
||
class ModelPresetResponse(Schema):
|
||
key: str
|
||
preset: ModelPreset
|
||
|
||
|
||
class PendingLogin(Schema):
|
||
"""A headless login waiting on the user: ``claude auth login`` waiting for
|
||
the code its sign-in page shows (sidecar/claude_cli.py), or — ``flow:
|
||
"device"`` — opencode's ChatGPT device flow waiting for ``userCode`` to be
|
||
entered at ``url`` (sidecar/opencode_cli.py)."""
|
||
loginId: Optional[str] = None # claude only
|
||
account: str
|
||
url: Optional[str] = None # the sign-in page to open
|
||
userCode: Optional[str] = None # device flow: the code to enter there
|
||
flow: Optional[str] = None # "device" | None (paste-the-code)
|
||
startedAt: int # epoch seconds
|
||
expiresAt: int # the CLI is killed after this
|
||
|
||
|
||
class LoginState(Schema):
|
||
"""Where a device-code login stands (``GET /api/accounts/{id}/login``)."""
|
||
state: str # pending | complete | failed | none
|
||
message: Optional[str] = None # failed: the CLI's last line
|
||
url: Optional[str] = None
|
||
userCode: Optional[str] = None
|
||
loggedIn: Optional[bool] = None
|
||
email: Optional[str] = None
|
||
|
||
|
||
class UsageRead(Schema):
|
||
"""The sidecar's last read of an opencode account's ChatGPT usage (or an
|
||
agy account's Antigravity quota)."""
|
||
at: Optional[float] = None
|
||
ok: Optional[bool] = None
|
||
error: Optional[str] = None
|
||
planType: Optional[str] = None
|
||
limitReached: Optional[bool] = None
|
||
# agy: every quota group of the reading (Gemini, Claude+GPT, Argon on Pro),
|
||
# each ``{name, description, buckets: [{id, name, window,
|
||
# remaining_fraction, reset_time}]}`` — the Accounts card lists them.
|
||
groups: Optional[list[dict]] = None
|
||
|
||
|
||
class AccountStatus(Schema):
|
||
"""An account's live login, from ``claude auth status`` under its config
|
||
dir (via the sidecar). ``configured`` False ⇒ the sidecar doesn't declare
|
||
the account (or couldn't be reached — then ``error`` says so)."""
|
||
configured: bool
|
||
loggedIn: bool
|
||
email: Optional[str] = None
|
||
orgName: Optional[str] = None
|
||
subscriptionType: Optional[str] = None
|
||
authMethod: Optional[str] = None
|
||
error: Optional[str] = None
|
||
# A `claude auth login` started from Settings and still waiting for its
|
||
# code (None when none is pending).
|
||
pendingLogin: Optional[PendingLogin] = None
|
||
# opencode / agy: the login can read the plan's usage % (the Codex
|
||
# method; agy's `/usage`), and the last read of it.
|
||
usageTracking: Optional[bool] = None
|
||
usage: Optional[UsageRead] = None
|
||
credentialsAt: Optional[str] = None
|
||
|
||
|
||
class LoginCodeResult(Schema):
|
||
"""The account's fresh login after a code/logout (``claude auth status``)."""
|
||
id: str
|
||
loggedIn: bool
|
||
email: Optional[str] = None
|
||
orgName: Optional[str] = None
|
||
subscriptionType: Optional[str] = None
|
||
authMethod: Optional[str] = None
|
||
message: Optional[str] = None
|
||
|
||
|
||
|
||
class AccountRunner(Schema):
|
||
id: Optional[str] = None
|
||
name: Optional[str] = None
|
||
|
||
|
||
class AccountHost(Schema):
|
||
"""One machine's own login of an account several machines declare (agy:
|
||
the lab and the personal Mac each sign the same Google account in) —
|
||
``id`` "local" = the lab, else the worker id; pass it as ``?worker=`` to
|
||
the login / logout routes."""
|
||
id: str
|
||
name: str
|
||
online: bool = True
|
||
loggedIn: bool = False
|
||
email: Optional[str] = None
|
||
error: Optional[str] = None
|
||
pendingLogin: Optional[PendingLogin] = None
|
||
credentialsAt: Optional[str] = None
|
||
|
||
|
||
class Account(Schema):
|
||
"""An account a session can run on (backend/accounts — hard-coded;
|
||
Settings only owns its plan/price presentation): a Claude login, a
|
||
ChatGPT one the opencode harness runs on, or a Google one agy runs on."""
|
||
id: str # "personal" | "work" | "chatgpt-work" | "google-personal"
|
||
label: str
|
||
description: str
|
||
color: str # a TAG_COLORS key
|
||
harness: str = "claude" # the harness its runs go through
|
||
provider: str = "anthropic" # whose models it bills
|
||
# No login at all (opencode-lab): its models bring their own credentials,
|
||
# so it has nothing to sign in to and no plan to meter.
|
||
keyless: bool = False
|
||
planWindows: list[str] = [] # the plan's usage windows: week, h5 (the live plan's)
|
||
# The tier the login is on (usage/plans.py), e.g. "Max 20×"; None until read.
|
||
planLabel: Optional[str] = None
|
||
planTier: Optional[str] = None
|
||
excludeFromTotals: bool # left out of aggregated totals by default
|
||
default: bool
|
||
status: Optional[AccountStatus] = None # only with ?health=1
|
||
# with ?health=1: the paired worker an opencode account lives on (its
|
||
# login and its runs are there); None = the lab.
|
||
runner: Optional[AccountRunner] = None
|
||
# with ?health=1, an agy account: each machine that declares it and its
|
||
# own login there (the lab first).
|
||
hosts: Optional[list[AccountHost]] = None
|
||
|
||
|
||
class AccountsResponse(Schema):
|
||
accounts: list[Account]
|
||
default: str
|
||
|
||
|
||
class AccountHealthConversation(Schema):
|
||
"""A conversation whose run failed on the signed-out account."""
|
||
sessionId: str
|
||
title: Optional[str] = None
|
||
owner: Optional[str] = None # a guest's id; None = the owner's
|
||
|
||
|
||
class AccountHealth(Schema):
|
||
"""Can the account run a prompt right now (accounts/health.py)? ``status``
|
||
``signed_out`` locks the composers that would bill it; ``reason``
|
||
``expired`` = runs fail on a dead OAuth session, ``logged_out`` = the CLI
|
||
has no login at all."""
|
||
id: str
|
||
status: Literal["ok", "signed_out", "unknown"]
|
||
reason: Optional[Literal["expired", "logged_out"]] = None
|
||
since: Optional[str] = None
|
||
message: Optional[str] = None
|
||
failedRuns: int = 0
|
||
conversations: list[AccountHealthConversation] = []
|
||
email: Optional[str] = None
|
||
subscriptionType: Optional[str] = None
|
||
refreshExpiresAt: Optional[str] = None
|
||
pendingLogin: bool = False
|
||
# A guest's own login that hit its usage limit lately: their runs go to
|
||
# the owner's account until the hold passes (accounts/health.py).
|
||
limited: bool = False
|
||
guest: Optional[str] = None # set on a guest's own login
|
||
checkedAt: Optional[str] = None
|
||
# An agy account: each machine's own login of it (the lab first) — the
|
||
# account's own status is the lab's.
|
||
hosts: Optional[list[AccountHost]] = None
|
||
|
||
|
||
class WorkerLoginHealth(Schema):
|
||
"""A worker in ``own`` mode runs on its machine's own Claude login (a
|
||
Mac's Keychain), not the hub's copy of the account: its health, from its
|
||
runs' auth errors and its ``/health`` ``ownLogin`` (accounts/health.py
|
||
``_compute_workers``). Fixed by signing in on that machine —
|
||
``POST /api/accounts/{account}/login?worker=<id>``."""
|
||
id: str
|
||
name: str
|
||
account: Optional[str] = None
|
||
status: Literal["ok", "signed_out", "unknown"]
|
||
reason: Optional[Literal["expired", "logged_out"]] = None
|
||
since: Optional[str] = None
|
||
message: Optional[str] = None
|
||
failedRuns: int = 0
|
||
conversations: list[AccountHealthConversation] = []
|
||
email: Optional[str] = None
|
||
subscriptionType: Optional[str] = None
|
||
credentialsAt: Optional[str] = None # last written (sign-in or token refresh)
|
||
refreshExpiresAt: Optional[str] = None # the login can't be renewed after
|
||
reported: bool = False # its sidecar reports its login at all
|
||
checkedAt: Optional[str] = None
|
||
|
||
|
||
class AccountsHealthResponse(Schema):
|
||
accounts: list[AccountHealth]
|
||
# The owner's own-login workers (empty for a guest).
|
||
workers: list[WorkerLoginHealth] = []
|
||
|
||
|
||
class AccountCheckResult(Schema):
|
||
"""*Check again*: the probe's verdict and the account's health after it."""
|
||
ok: bool
|
||
kind: Optional[str] = None
|
||
message: Optional[str] = None
|
||
health: AccountHealth
|
||
|
||
|
||
class ProfileRunner(Schema):
|
||
"""One runner of a profile: the Homelab (``local``) or a paired worker,
|
||
with what a run there defaults to within the profile."""
|
||
id: str # "local" = the Homelab, else a worker id
|
||
accounts: dict[str, str] # ★ login per harness ({"claude": "personal"})
|
||
cwd: Optional[str] = None # where a run there starts; None = its own
|
||
# The logins the machine holds right now, per harness (computed).
|
||
logins: dict[str, list[str]] = {}
|
||
|
||
|
||
class Profile(Schema):
|
||
"""A profile (backend/profiles/): which runners its conversations run on
|
||
— a conversation belongs to its runner's profile — its default runner
|
||
(the first), each runner's ★ logins and start dir, and its projects."""
|
||
id: str
|
||
label: str
|
||
icon: str # a key of PROFILE_ICONS (frontend)
|
||
color: str # an ACCOUNT_THEME_COLORS key
|
||
workers: list[ProfileRunner] # each runner in one profile; default first
|
||
retired: list[str] = [] # unpaired workers, kept for their history
|
||
projects: list[str] # ~/projects slugs; each in one profile
|
||
default: bool
|
||
# "guests" = the built-in Guests profile: no runners/projects —
|
||
# its conversations are the ones guests started. None = a runner profile.
|
||
kind: Optional[str] = None
|
||
# Only the Guests profile can be off (its conversations then follow
|
||
# their runner — Personal, for the lab).
|
||
enabled: bool = True
|
||
# The Guests profile: the guests' ids (Settings → Users), its members.
|
||
members: Optional[list[str]] = None
|
||
|
||
|
||
class ProfilesResponse(Schema):
|
||
profiles: list[Profile]
|
||
default: str
|
||
|
||
|
||
class WorkerClaudeProxy(Schema):
|
||
"""Where the worker's copy of the Claude proxy config stands."""
|
||
mode: str = "own" # proxy | own (its machine's login)
|
||
accounts: list[str] = [] # what it bills through the proxy
|
||
default: Optional[str] = None # what a terminal `claude` there bills
|
||
# current | outdated | failed | unsupported (sidecar from before) | off
|
||
status: str = "unknown"
|
||
held: Optional[list[str]] = None # the accounts its sidecar runs proxied
|
||
settingsDefault: Optional[dict] = None # its settings.json default, as it reports it
|
||
error: Optional[str] = None
|
||
lastUsedAt: Optional[str] = None # its last model call through the proxy
|
||
|
||
|
||
class WorkerOpencodeProxy(Schema):
|
||
"""Where the worker's copy of the opencode proxy config stands."""
|
||
accounts: list[str] = [] # the Homelab's opencode accounts it bills
|
||
# current | outdated | failed | unsupported | no_opencode | off
|
||
status: str = "unknown"
|
||
held: Optional[list[str]] = None
|
||
available: Optional[bool] = None # is opencode installed there
|
||
error: Optional[str] = None
|
||
lastUsedAt: Optional[str] = None
|
||
|
||
|
||
class WorkerTool(Schema):
|
||
"""One row of a worker's *Setup* checklist (its ``/health`` ``tools``,
|
||
sidecar tools_check.py): a CLI there, installed and signed in."""
|
||
installed: Optional[bool] = None
|
||
signedIn: Optional[bool] = None
|
||
path: Optional[str] = None
|
||
version: Optional[str] = None
|
||
login: Optional[str] = None # gh's login name, claude's email
|
||
proxied: Optional[bool] = None # claude: runs bill the hub's logins
|
||
loggedIn: Optional[bool] = None # claude: the machine's own login
|
||
configured: Optional[bool] = None # ask-form: set up (admin token)
|
||
running: Optional[bool] = None # ask-form: its serve answers
|
||
# opencode / agy: the service runs that harness (an account declared),
|
||
# and which account its sign-in is for (Settings → Accounts ?worker=)
|
||
harness: Optional[bool] = None
|
||
account: Optional[str] = None
|
||
# gh / pi: the worker (tools.sh, or brew) installed it — *Update* moves it
|
||
managed: Optional[bool] = None
|
||
error: Optional[str] = None
|
||
|
||
|
||
class WorkerToolJob(Schema):
|
||
"""The last install / update of one tool from the Setup checklist (the
|
||
worker's /health ``toolJobs``, sidecar tools_install.py)."""
|
||
action: Optional[str] = None # install | update
|
||
# queued | running | done | failed | interrupted (its batch died)
|
||
state: Optional[str] = None
|
||
startedAt: Optional[str] = None
|
||
finishedAt: Optional[str] = None
|
||
error: Optional[str] = None
|
||
# The last lines of its log, while it runs and once it failed.
|
||
tail: Optional[list[str]] = None
|
||
|
||
|
||
class WorkerToolInstall(Schema):
|
||
"""What the Setup checklist may install / update on this machine (None:
|
||
a sidecar from before — no buttons)."""
|
||
tools: list[str] = []
|
||
update: list[str] = []
|
||
|
||
|
||
class GhLogin(Schema):
|
||
"""gh's device-code sign-in on a worker (workers/tools.py): enter
|
||
``userCode`` at ``url``; GET follows it — pending | complete | failed | none."""
|
||
state: Optional[str] = None
|
||
account: Optional[str] = None
|
||
url: Optional[str] = None
|
||
userCode: Optional[str] = None
|
||
flow: Optional[str] = None
|
||
startedAt: Optional[int] = None
|
||
expiresAt: Optional[int] = None
|
||
message: Optional[str] = None
|
||
|
||
|
||
class Worker(Schema):
|
||
"""A paired remote runner (backend/workers.py): the same sidecar on
|
||
another machine, driven over the tailnet. No token here — it never leaves
|
||
the backend."""
|
||
id: str
|
||
name: str
|
||
# Its tailnet address — none for a computer on the worker link.
|
||
host: Optional[str] = None
|
||
port: Optional[int] = None
|
||
url: str
|
||
# A guest's own computer (users/computers.py): whose, and that it dials
|
||
# out (workers/link.py) — ``pending`` until the link has paired it.
|
||
owner: Optional[str] = None
|
||
link: bool = False
|
||
pending: bool = False
|
||
paused: bool = False
|
||
account: Optional[str] = None # the hub account its own login is, if any
|
||
email: Optional[str] = None # its own `claude` login, if any
|
||
orgName: Optional[str] = None
|
||
hostname: Optional[str] = None
|
||
platform: Optional[str] = None # "darwin" | "linux"
|
||
machine: Optional[str] = None
|
||
version: Optional[str] = None
|
||
cwd: Optional[str] = None # where a new run starts there
|
||
permissionMode: Optional[str] = None
|
||
pairedAt: Optional[str] = None
|
||
# The account's new runs go here whenever it is online. Off: only runs the
|
||
# composer pins to this worker (the lab stays the default runner).
|
||
autoRoute: bool = False
|
||
# The opencode accounts (ChatGPT logins) it hosts besides its Claude login.
|
||
opencodeAccounts: Optional[list[str]] = None
|
||
# The agy (Antigravity CLI) Google logins it holds — its own sign-in of
|
||
# each (the lab may hold the same account too).
|
||
agyAccounts: Optional[list[str]] = None
|
||
# Version (workers/updates.py): the commit its checkout is on, whether it
|
||
# can update itself, and where it stands against the hub's own commit —
|
||
# current | outdated | ahead | updating | failed | unsupported | unknown.
|
||
commit: Optional[str] = None
|
||
updatable: bool = False
|
||
autoUpdate: bool = True
|
||
hubCommit: Optional[str] = None
|
||
updateStatus: str = "unknown"
|
||
update: Optional[dict] = None # its last auto-update (update.json)
|
||
updateError: Optional[str] = None # the hub's last /update call failing
|
||
status: str # online | offline | unauthorized | unknown
|
||
lastSeen: Optional[str] = None
|
||
lastError: Optional[str] = None
|
||
running: int = 0 # live runs it launched
|
||
mirrored: int = 0 # transcripts mirrored since boot
|
||
syncing: bool = False
|
||
# Lab sync (workers/labsync.py): the homelab's portable skills and agents
|
||
# it holds — current | outdated | failed | unsupported | unknown — its own
|
||
# report ({hash, syncedAt, skills, agents, conflicts}) and the hub's last
|
||
# /sync call failing.
|
||
labSyncStatus: str = "unknown"
|
||
labSync: Optional[dict] = None
|
||
labSyncError: Optional[str] = None
|
||
# How it runs Claude Code: `proxy` (the hub's logins, through the Claude
|
||
# proxy — claudeproxy/) or `own` (its machine's login), and the Claude
|
||
# accounts it can bill that way (Settings → Profiles ticks them).
|
||
claudeMode: str = "own"
|
||
claudeAccounts: list[str] = []
|
||
claudeProxy: Optional[WorkerClaudeProxy] = None
|
||
# The Homelab's opencode accounts it bills through the opencode proxy.
|
||
opencodeProxyAccounts: list[str] = []
|
||
opencodeProxy: Optional[WorkerOpencodeProxy] = None
|
||
# The Setup checklist — claude / gh / opencode / agy / pi / ask-form,
|
||
# installed and signed in (its /health ``tools``; None from a sidecar from
|
||
# before), what it can install from there and how each install went
|
||
# (workers/tools.py).
|
||
tools: Optional[dict[str, WorkerTool]] = None
|
||
toolsCheckedAt: Optional[int] = None
|
||
toolInstall: Optional[WorkerToolInstall] = None
|
||
toolJobs: Optional[dict[str, WorkerToolJob]] = None
|
||
# Repo plugins (workers/repoplugins.py): its cwd repo's marketplace and
|
||
# which plugins are on ({checkedAt, configDir, marketplace, known,
|
||
# plugins}; None from a sidecar from before) — current | outdated | failed
|
||
# | unsupported | none | unknown.
|
||
repoPlugins: Optional[dict] = None
|
||
repoPluginsStatus: str = "unknown"
|
||
repoPluginsError: Optional[str] = None
|
||
|
||
|
||
class WorkersResponse(Schema):
|
||
workers: list[Worker]
|
||
|
||
|
||
class LabSyncItem(Schema):
|
||
"""One homelab skill or agent on a worker's *Lab skills & agents* list."""
|
||
key: str # "skill:<name>" | "agent:<name>"
|
||
kind: str # skill | agent
|
||
name: str
|
||
description: str = ""
|
||
portable: bool = False # its frontmatter's `portable: true`
|
||
account: Optional[str] = None # `portable: <account>`: that account's workers only
|
||
default: bool = False # what this worker gets without an override
|
||
override: Optional[bool] = None # this worker's tick/untick, if any
|
||
enabled: bool = False # what it gets: the override, else the default
|
||
|
||
|
||
class RepoPlugin(Schema):
|
||
"""A Claude Code plugin some worker's repo offers through its own
|
||
marketplace (``<repo>/.claude-plugin/marketplace.json``)."""
|
||
id: str # "<plugin>@<marketplace>"
|
||
name: str
|
||
marketplace: str
|
||
description: Optional[str] = None
|
||
repo: Optional[str] = None # the checkout's directory name
|
||
|
||
|
||
class RepoPluginCell(Schema):
|
||
"""One plugin on one worker."""
|
||
installed: bool = False
|
||
enabled: bool = False
|
||
desired: Optional[bool] = None # what the hub wants; None = left alone
|
||
override: Optional[bool] = None # this worker's tick/untick, if any
|
||
|
||
|
||
class RepoPluginWorker(Schema):
|
||
id: str
|
||
name: Optional[str] = None
|
||
account: Optional[str] = None
|
||
# current | outdated | failed | unsupported (sidecar from before) | none
|
||
# (no marketplace in its cwd) | unknown (offline)
|
||
status: str = "unknown"
|
||
error: Optional[str] = None
|
||
repo: Optional[str] = None
|
||
marketplace: Optional[str] = None
|
||
checkedAt: Optional[int] = None
|
||
cells: dict[str, RepoPluginCell] = {}
|
||
|
||
|
||
class RepoPluginsView(Schema):
|
||
"""Repo plugins × workers, and each account's picks."""
|
||
plugins: list[RepoPlugin]
|
||
workers: list[RepoPluginWorker]
|
||
accounts: list[str]
|
||
picks: dict[str, list[str]]
|
||
|
||
|
||
class WorkerLabSync(Schema):
|
||
"""A worker's lab sync (workers/labsync.py): the checklist, the bundle the
|
||
hub would send it, and the worker's own report of what it holds."""
|
||
items: list[LabSyncItem]
|
||
hash: str
|
||
skipped: list[str] = [] # files left out (too big / over the cap)
|
||
status: str = "unknown" # current | outdated | failed | unsupported | unknown
|
||
held: Optional[dict] = None # {hash, syncedAt, skills, agents, conflicts}
|
||
error: Optional[str] = None
|
||
|
||
|
||
|
||
class OpenRouterModel(Schema):
|
||
"""One OpenRouter model a pi.dev session can be spawned on.
|
||
|
||
The catalogue behind it is APPE's (models.dev, synced daily) — see
|
||
`backend/plugins/providers.py` (`appe_catalogue`). Prices are USD per **million** tokens.
|
||
"""
|
||
id: str # the `--model` argument, e.g. "openai/gpt-oss-20b"
|
||
name: str # display name ("GPT OSS 20B")
|
||
vendor: str # the id's first segment ("openai")
|
||
description: str = ""
|
||
inputCost: float
|
||
outputCost: float
|
||
# Cache-read price. None = the model has no prompt cache (a cache read is
|
||
# then billed as a fresh read), which is a different fact from a free cache.
|
||
cacheCost: Optional[float] = None
|
||
contextWindow: Optional[int] = None
|
||
# Parameters in billions, mined from the id/name by APPE. None for models
|
||
# that publish no size (most closed ones).
|
||
modelSize: Optional[float] = None
|
||
tags: list[str] = [] # vision | reasoning | tools | opensource | …
|
||
tier: str = "" # small | medium | big (blended-price heuristic)
|
||
license: str = ""
|
||
speedTps: Optional[float] = None # median output tokens/sec
|
||
|
||
|
||
class OpenRouterModelsResponse(Schema):
|
||
models: list[OpenRouterModel] # cheapest first (blended 3:1 in:out)
|
||
source: str # the APPE URL the catalogue came from
|
||
generatedAt: str = "" # when APPE generated it (ISO 8601)
|
||
|
||
|
||
class SpawnResult(Schema):
|
||
sessionId: str
|
||
pid: Optional[int] = None
|
||
# "inbox" when a follow-up was delivered into the still-running session
|
||
# through its inbox socket instead of restarting it on the new prompt.
|
||
delivered: Optional[str] = None
|
||
|
||
|
||
class CodeModeRunner(Schema):
|
||
"""Can a run on this runner start in Claude Code's Code Mode (runs/codemode.py)."""
|
||
ok: bool
|
||
# Its claude CLI's version, when its sidecar said.
|
||
cli: Optional[str] = None
|
||
# Why not, when it can't (shown on the greyed chip).
|
||
reason: Optional[str] = None
|
||
|
||
|
||
class CodeModeStatus(Schema):
|
||
"""``GET /api/code-mode`` — the composer's *Code β* chip."""
|
||
# May the caller start conversations in Code Mode (a guest's Access switch).
|
||
allowed: bool
|
||
# "local" (the lab) and, for the owner, each paired worker's id.
|
||
runners: dict[str, CodeModeRunner]
|
||
|
||
|
||
class InterruptResult(Schema):
|
||
sessionId: str
|
||
ok: bool
|
||
|
||
|
||
class UploadedFile(Schema):
|
||
name: str
|
||
size: int
|
||
contentType: str
|
||
# Repo-relative path the composer injects into the prompt (read by the session).
|
||
repoPath: str
|
||
# Backend serve route the thread viewer renders the file from.
|
||
url: str
|
||
|
||
|
||
class UploadResult(Schema):
|
||
files: list[UploadedFile]
|
||
|
||
|
||
class ConversationMetaResponse(Schema):
|
||
meta: dict[str, ConvMeta]
|
||
|
||
|
||
class MetaUpdateResult(Schema):
|
||
id: str
|
||
meta: ConvMeta
|
||
|
||
|
||
class AutoArchiveItem(Schema):
|
||
sessionId: str
|
||
id: Optional[str] = None
|
||
kind: Literal["cron", "test"]
|
||
title: Optional[str] = None
|
||
|
||
|
||
class AutoArchiveResult(Schema):
|
||
archived: int # how many were archived (0 on a dry run)
|
||
items: list[AutoArchiveItem] # what the sweep picked
|
||
|
||
|
||
class ArchiveOldResult(Schema):
|
||
archived: int # how many conversations were newly archived
|
||
cutoff: str # UTC start-of-yesterday used as the age threshold
|
||
|
||
|
||
# ── home usage tiles (provides: home.tiles) ─────────────────────────────────
|
||
class HomeTileDay(Schema):
|
||
date: str
|
||
value: float
|
||
label: Optional[str] = None
|
||
|
||
|
||
class HomeTile(Schema):
|
||
"""One declarative tile of the home usage strip, from a plugin's
|
||
``home.tiles`` action (``plugins/home_tiles.py``). Which fields are set
|
||
depends on ``kind``: ``arc`` (pct, resetsAt, goal), ``burn`` (usdPerHour,
|
||
pctPerHour, neededUsdPerHour, neededPctPerHour, projected, goal,
|
||
windowMinutes, noReading), ``stat`` (value, valueUsd, subUsdPerDay),
|
||
``sparkline`` (days, isCost), ``bar`` (value as a number, max, text,
|
||
over). ``to`` is the tile's link (none: no link), ``stashLabel`` its name
|
||
on the bench when that differs from ``label``."""
|
||
id: str
|
||
pluginId: str
|
||
kind: Literal["arc", "burn", "stat", "sparkline", "bar"]
|
||
label: str
|
||
stashLabel: Optional[str] = None
|
||
fixed: bool = False
|
||
defaultBench: bool = False
|
||
stale: bool = False
|
||
to: Optional[str] = None
|
||
title: Optional[str] = None
|
||
sub: Optional[str] = None
|
||
pct: Optional[float] = None
|
||
resetsAt: Optional[float] = None
|
||
goal: Optional[float] = None
|
||
usdPerHour: Optional[float] = None
|
||
pctPerHour: Optional[float] = None
|
||
neededUsdPerHour: Optional[float] = None
|
||
neededPctPerHour: Optional[float] = None
|
||
projected: Optional[float] = None
|
||
windowMinutes: Optional[int] = None
|
||
noReading: Optional[bool] = None
|
||
value: Optional[Union[str, float]] = None
|
||
valueUsd: Optional[float] = None
|
||
subUsdPerDay: Optional[float] = None
|
||
days: Optional[list[HomeTileDay]] = None
|
||
isCost: Optional[bool] = None
|
||
max: Optional[float] = None
|
||
text: Optional[str] = None
|
||
over: Optional[bool] = None
|
||
|
||
|
||
class HomeTilesResponse(Schema):
|
||
tiles: list[HomeTile] = []
|
||
|
||
|
||
# ── the homelab services catalogue (provides: services.index) ────────────────
|
||
class ServiceGoal(Schema):
|
||
done: int
|
||
total: int
|
||
|
||
|
||
class ServiceIndexEntry(Schema):
|
||
"""One ``services/<dir>`` as the services plugin indexes it
|
||
(``plugins/services_bridge.py``) — everything but ``dir`` / ``name`` /
|
||
``description`` is optional (a dir with no compose file has no containers)."""
|
||
dir: str
|
||
name: str
|
||
description: str = ""
|
||
goal: Optional[ServiceGoal] = None
|
||
updatedAt: Optional[str] = None
|
||
icon: Optional[str] = None
|
||
group: Optional[str] = None
|
||
urls: Optional[list[str]] = None
|
||
containers: Optional[list[str]] = None
|
||
containerCount: Optional[int] = None
|
||
images: Optional[list[str]] = None
|
||
profiles: Optional[list[str]] = None
|
||
auth: Optional[Literal["auth", "public", "api", "mixed"]] = None
|
||
hasCompose: Optional[bool] = None
|
||
hasTraefik: Optional[bool] = None
|
||
routerCount: Optional[int] = None
|
||
|
||
|
||
class ServicesIndexResponse(Schema):
|
||
services: list[ServiceIndexEntry] = []
|
||
|
||
|
||
# ── what opens on its own as the app opens (provides: app.launch) ────────────
|
||
class AppLaunchModal(Schema):
|
||
"""One of a plugin's ``app.modal`` slots to open now (plugins/launch.py)."""
|
||
pluginId: str
|
||
slotId: str
|
||
init: dict = {}
|
||
# run as the caller once the modal closes, whichever way
|
||
closeAction: str | None = None
|
||
|
||
|
||
class AppLaunchResponse(Schema):
|
||
open: list[AppLaunchModal] = []
|
||
|
||
|
||
# ── plugin status banner (provides: app.banner) ──────────────────────────────
|
||
class BannerStep(Schema):
|
||
n: int
|
||
label: str
|
||
state: Literal["pending", "active", "done", "failed"]
|
||
|
||
|
||
class BannerStatus(Schema):
|
||
"""The owner's floating status banner, answered by the plugin providing
|
||
``app.banner`` (``plugins/banner.py``), or ``null`` — e.g. the
|
||
``blue-green-deploy`` plugin's deploy timeline; ``conversationId`` /
|
||
``convTitle`` / ``convUrl`` are resolved by the host from ``sessionId``."""
|
||
active: bool
|
||
title: Optional[str] = None
|
||
label: Optional[str] = None
|
||
status: Literal["running", "done", "failed", "info"]
|
||
phaseNum: int = 0
|
||
totalPhases: int = 0
|
||
phase: Optional[str] = None
|
||
steps: list[BannerStep] = []
|
||
startedAt: Optional[int] = None
|
||
updatedAt: Optional[int] = None
|
||
sessionId: Optional[str] = None
|
||
conversationId: Optional[str] = None
|
||
convTitle: Optional[str] = None
|
||
convUrl: Optional[str] = None
|
||
# A maintenance window: guest-job push delivery waits it out.
|
||
maintenance: bool = False
|
||
|
||
|
||
class MachineAttentionItem(Schema):
|
||
"""One thing on one of the owner's machines that waits for him, from the
|
||
plugin providing ``machine.attention`` (``plugins/machine_attention.py``)
|
||
— e.g. the ``mcp-servers`` plugin's "2 MCP servers need a sign-in"."""
|
||
pluginId: str
|
||
machine: str # ``local`` = the Homelab, else a worker id
|
||
key: str
|
||
title: str
|
||
detail: Optional[str] = None
|
||
tone: Literal["warn", "error"] = "warn"
|
||
|
||
|
||
class MachineAttention(Schema):
|
||
items: list[MachineAttentionItem] = []
|
||
|
||
|
||
class WakeableMachine(Schema):
|
||
"""One worker the plugin providing ``machine.wake`` can wake
|
||
(``plugins/machine_wake.py``) — the ``wake-on-lan`` plugin's settings."""
|
||
configured: bool = False
|
||
mac: Optional[str] = None
|
||
broadcast: Optional[str] = None
|
||
autoWake: bool = False
|
||
timeoutSec: Optional[int] = None
|
||
lastWokenAt: Optional[str] = None
|
||
|
||
|
||
class MachinesWakeable(Schema):
|
||
"""``GET /api/machines/wakeable``: worker id → what the plugin says."""
|
||
machines: dict[str, WakeableMachine] = {}
|
||
|
||
|
||
class MachineWakeResult(Schema):
|
||
"""``POST /api/machines/{id}/wake``: the plugin's answer (extra keys kept)."""
|
||
ok: bool = False
|
||
sent: bool = False
|
||
configured: bool = False
|
||
autoWake: bool = False
|
||
timeoutSec: Optional[int] = None
|
||
machineId: Optional[str] = None
|
||
error: Optional[str] = None
|
||
|
||
|
||
# ── local-model generation progress ──────────────────────────────────────────
|
||
class GenProgressPoint(Schema):
|
||
"""One earlier llm-server reading of a run, in its ``trail`` — the keys that
|
||
move from one poll to the next."""
|
||
phase: Literal["loading", "prefill", "decode", "idle", "unreachable"]
|
||
since: Optional[float] = None
|
||
promptTokens: Optional[int] = None
|
||
promptCached: Optional[int] = None
|
||
promptDone: Optional[int] = None
|
||
decoded: Optional[int] = None
|
||
cap: Optional[int] = None
|
||
tokPerS: Optional[float] = None
|
||
tool: Optional[str] = None
|
||
toolRunning: Optional[bool] = None
|
||
at: Optional[float] = None
|
||
|
||
|
||
class GenProgress(Schema):
|
||
"""What a live local-model run's llm-server slot is doing (sidecar
|
||
provider-evox2's ``gen_progress.py`` → ``runs/genprogress.py``): its transcript stays silent
|
||
while the model streams, this doesn't."""
|
||
phase: Literal["loading", "prefill", "decode", "idle", "unreachable"]
|
||
model: Optional[str] = None
|
||
# Epoch the current phase (this request's prefill / decode) began —
|
||
# back-dated by the run's known rate when first seen.
|
||
since: Optional[float] = None
|
||
# The request's prompt: all of it, the part reused from the cache, and how
|
||
# much of the rest is read so far.
|
||
promptTokens: Optional[int] = None
|
||
promptCached: Optional[int] = None
|
||
promptDone: Optional[int] = None
|
||
# Tokens written so far, against the request's output cap.
|
||
decoded: Optional[int] = None
|
||
cap: Optional[int] = None
|
||
# Smoothed rate of the current phase (decode, or prefill).
|
||
tokPerS: Optional[float] = None
|
||
# opencode: the tool call being streamed (``write``, ``edit``, ``shell``…).
|
||
tool: Optional[str] = None
|
||
# The transcript ends on a tool call still running.
|
||
toolRunning: Optional[bool] = None
|
||
# Epoch since which neither the server nor the transcript moved (None = busy).
|
||
idleSince: Optional[float] = None
|
||
at: Optional[float] = None
|
||
# The previous few readings (1 s apart, oldest first): the hub relays every
|
||
# 2 s, and the viewer replays them all on the conversation's clock.
|
||
trail: Optional[list[GenProgressPoint]] = None
|
||
|
||
|
||
class GenProgressSnapshot(Schema):
|
||
"""Every live local-model run's reading, by session id — also the payload
|
||
of the ``gen-progress`` SSE event."""
|
||
progress: dict[str, GenProgress]
|