Two built-in records serve data that only the selectable layouts read. Each lives in
its own feature module and mounts only while a layout that needs it is on offer:
| Record | Module | Serves layouts | Routes |
|---|---|---|---|
| builtin.run-ledger | features/run_ledger.py | command, mission | /api/runs* |
builtin.run-ledger
features/run_ledger.py
command
mission
/api/runs*
| builtin.artifacts | features/artifacts.py | chat-canvas | /api/artifacts* |
builtin.artifacts
features/artifacts.py
chat-canvas
/api/artifacts*
style: app
layout.available
aiui.set_layout(available=[...])
available: [chat-canvas] only builtin.artifacts mounts, and with available: [mission] only
available: [chat-canvas]
available: [mission]
builtin.run-ledger does.
dashboard
chat
Both records are then disabled with the reason no layout needs it in
disabled
no layout needs it
/api/plugins?origin=builtin. Their modules are never imported and their routes answer 404.
/api/plugins?origin=builtin
extensions.enabled: [builtin.run-ledger]
extensions.disabled
builtin.artifacts owns one page, artifacts (shell_only, kind: native,
artifacts
shell_only
kind: native
layouts: [chat-canvas]): every chat's artifacts, newest first, with their versions. The React
layouts: [chat-canvas]
page is layout-features/artifacts/ArtifactsPage (chunk lf-artifacts), registered lazily by the
layout-features/artifacts/ArtifactsPage
lf-artifacts
browser built-in builtin.artifacts (src/frontend/src/builtin/artifacts.ts) only while the
src/frontend/src/builtin/artifacts.ts
manifest lists the page. The shell shows it in the nav while Chat and Canvas is the frame, and its
URL (where Share links land, /artifacts?session=…&artifact=…&v=…) renders under any layout. Like
/artifacts?session=…&artifact=…&v=…
every shell_only page it reaches the app shell manifest only, never /api/pages or the
/api/pages
dashboard. builtin.run-ledger adds no page.
Every route is authenticated in all three auth modes, like any other /api/* route. None is
/api/*
public.
The ledger keeps one record per chat run: its session, agent, start and end, status
(running, waiting, completed, failed, cancelled), its steps (reasoning, tool,
running
waiting
completed
failed
cancelled
reasoning
tool
text, approval, handoff), and the tokens, cost and model of the run's usage records. It adds
text
approval
handoff
no wire event. A client reads the ledger after run_completed.
run_completed
| Route | Returns |
|---|---|
| GET /api/runs?after=&agent=&session_id=&limit= | {runs: RunSummary[], count}, newest first (limit 1–500, default 50) |
GET /api/runs?after=&agent=&session_id=&limit=
{runs: RunSummary[], count}
limit
| GET /api/runs/{run_id} | RunDetail with its steps, or 404 |
GET /api/runs/{run_id}
RunDetail
| GET /api/runs/kpis?window=today\|24h\|7d | RunKpis; any other window is 400 |
GET /api/runs/kpis?window=today\|24h\|7d
RunKpis
| GET /api/runs/agents | {agents: AgentStatus[]}, running and waiting agents first |
GET /api/runs/agents
{agents: AgentStatus[]}
The shapes are the ones in src/frontend/src/sdk/layoutTypes.ts: camelCase keys, times in epoch
src/frontend/src/sdk/layoutTypes.ts
milliseconds.
RunKpis holds:
runs
runsDelta
successRate
cost
budget
p50Ms
p95Ms
budget is finops.daily_cost_budget_usd from the runtime config (Settings, FinOps & Budgets),
finops.daily_cost_budget_usd
multiplied by 7 for the 7d window. It is left out when that value is unset or 0, or when
7d
finops.enabled is false.
finops.enabled
false
Tokens and cost per run. usage.track_usage() takes run_id=. When it is not given, it uses
usage.track_usage()
run_id=
the run the calling task is serving, from the praisonaiui.features.chat.current_run_id context
praisonaiui.features.chat.current_run_id
variable. The chat sets that variable for the whole run, and PraisonAIProvider passes it on.
PraisonAIProvider
POST /api/usage/track accepts run_id in its body. A provider that records usage without a run
POST /api/usage/track
run_id
id is joined to the run by session and time window instead, and the run then carries
approximate: true.
approximate: true
Storage. Finished runs are held in memory (the newest 1000) and appended to
<data dir>/runs/ledger.jsonl. The data dir is PRAISONAI_HOME, else AIUI_DATA_DIR, else
<data dir>/runs/ledger.jsonl
PRAISONAI_HOME
AIUI_DATA_DIR
~/.praisonaiui.
~/.praisonaiui
The append runs on a single writer thread, so the chat broadcast never waits on the disk. The
file is read back the first time a /api/runs* route is called, and it is compacted once it holds
more than twice the ring size.
The ledger is fed by a hook that any server-side code can use:
The observer sees every event that ChatManager.broadcast sends, whether or not a client is
ChatManager.broadcast
connected. After each run it also gets one run_closed event, which clients never see. By the
run_closed
time it arrives, the provider has finished and its usage is tracked. Observers run inline on the
event loop, so they must be quick and must not change event. An observer that raises is logged
event
and skipped.
The browser derives artifacts from the chat: fenced code, tables, file and media elements, and
A2UI surfaces. The extraction rules live only in the client. The server stores what the client
sends: the index for each session, so the nav can count artifacts across sessions, and the
versions the user edited.
| Route | Does |
| GET /api/artifacts?session_id=&limit= | The latest version of every key, newest first, without content: {artifacts, count, sessions} |
GET /api/artifacts?session_id=&limit=
{artifacts, count, sessions}
| GET /api/artifacts/{session_id} | Every version, with content: {sessionId, artifacts} |
GET /api/artifacts/{session_id}
{sessionId, artifacts}
| PUT /api/artifacts/{session_id}/{key} | Upserts a derived version, or adds a user edit: {artifact} |
PUT /api/artifacts/{session_id}/{key}
{artifact}
| DELETE /api/artifacts/{session_id}/{key}[?version=N] | Removes one key, or one version of it |
DELETE /api/artifacts/{session_id}/{key}[?version=N]
| DELETE /api/artifacts/{session_id} | Removes the whole session |
DELETE /api/artifacts/{session_id}
Deleting a chat (DELETE /sessions/{id}, which the chat, the Sessions page and
DELETE /sessions/{id}
aiui sessions delete use) also deletes its artifacts.
aiui sessions delete
The body of a PUT is an Artifact. kind is one of code, table, markdown, file,
PUT
Artifact
kind
code
table
markdown
file
image, pdf, video or a2ui.
image
pdf
video
a2ui
edited: true
version
refused with 409.
The limits are 512 KB of content for each version, 50 versions for each key (unedited versions
are dropped first), and 500 keys for each session.
url must be a relative or same-origin path, or an http:, https:, blob: or data:image/
url
http:
https:
blob:
data:image/
URL, the same rule chat markdown uses. The server first normalises the URL the way a browser
does: it drops tab, CR and LF, and strips leading and trailing control characters and spaces. So
java\nscript: is refused like javascript:. The normalised form is the one stored.
java\nscript:
javascript:
Each session is one JSON file under <data dir>/artifacts/, named by a hash of the session id.
<data dir>/artifacts/
Each write goes to a temporary file that is then renamed into place.