- approval cards: one plain question per tool call (server/agent/ask.mjs maps commands and files to sentences; src/lib/ask.ts holds the translated templates), a compact calm card, the exact command under Details - Tasks: the opened task shows schedule, what it may do, last result, instructions and last answer; back link before the title like the chat's navbar; pause/resume and delete icons, Edit, Run now; pause and play icons added to the sprite - Models: 'This computer' shows graphics memory and RAM bars with what the chosen version takes, and one plain line about the SSD (src/lib/native-fit.ts, from the catalog's memory_gb and the hardware report; the n-gram table is not counted) - Models: one-line version list: Recommended (the fixed four), Swift, GSQ-RCO, NVFP4, Gyro, Unsloth groups, Use your own GGUF; RAM+VRAM in bold, download size muted, 'Uses SSD N GB' only where it applies - Tune: five steps with their own animated icons and states, a live speed readout and sparkline, a result card with the gain and what it was saved as; reduced motion respected; the tuner now reports each measurement's speed - catalog: memory_gb and mem_total per version (tools/strata_mcp.py) - tests: ask, native-fit, tune-phase, autotune speeds, memory figures; headless checks (ui-flows ui2/ui2d, scripts/approval-flow.mjs), light and dark
Agent bridge (Strata chats as DeepSeek Harness sessions)
The Harness is a separate, pinned component (DSH 0.2.1-alpha.3, commit 57190202, MIT). The host finds it through
STRATA_HARNESS_DIR (or <STRATA_COMPONENTS_DIR>/harness), starts one dsh --profile web process on a loopback port,
and talks to its Gateway. Nothing here downloads or builds anything.
| File | Job |
|---|---|
harness-runtime.mjs |
locate the component, start/stop the process, scrub its environment, clean up a leftover process from a dead host |
gateway-client.mjs |
HTTP RPC plus the remote.mux WebSocket ($events, session/follow) |
profile.mjs |
generate the Harness profile: one route per ready local instance and per saved API connection; credential names only |
task-run.mjs |
a scheduled task as the agent |
events.mjs |
pure projection of Harness session events into the chat's NDJSON frames |
children.mjs |
pure projection of one helper agent's events into its row and its approval card |
preset.mjs |
the agent preset (which tools the chat has) |
plugins/strata-gate.mjs |
the Manual-mode approval gate (a Harness plugin, loaded by path) |
agent-bridge.mjs |
the chat-to-session map, turns, approvals, Stop, status |
Frames sent on /api/chat/stream for an agent turn
queued, start (agent:true), reasoning, delta, agent-tool (new: upserts a tool card by call id with
running | proposed | done | denied | error), done (usage, finishReason, cancelled), error, and notice
(why a chat is not using the agent). The chat UI renders them with its existing components.
Routes
GET /api/agent/status: component, routes, active turns, pending approvals (no tokens, no keys)POST /api/chat/approval {sessionId, toolId, decision: approve|deny}POST /api/chat/stop {sessionId}: cancels that chat's Harness session and answers once the turn has endedGET /api/agent/pending?chatId=
Behaviour worth knowing
- Stop is per chat.
session/cancelis only an admission; the bridge waits for the durableturn/end. Stop before the prompt reached the Harness cancels the start. The process is never killed to implement Stop. - A closed tab is not Stop. The turn keeps running; an approval it needs stays pending until someone answers.
- Resume. The chat id maps to a Harness session id (
<data>/agent/sessions.json). Reopening prompts that session; the Harness resumes it from its own record, so nothing is replayed. (session/createwith a started id returns a new session, so it is never used for resume.) - Models. Each chat sends its choice; the bridge calls
session/selectModelfor that route before the prompt. A route that is gone is a typedmodel-unavailableerror, never another model. Keys travel as environment variables named byapiKeyEnv; the agent's shell does not inherit them, and logs are redacted. - No answerer, no hang. The agent's own questions (
ask_user_question) are declared unanswerable until the app has a surface for them. - Fallback. Without the component the host says so (
/api/agent/status, anoticeframe) and the chat runs on the direct path with the model the user picked.
Modes (the Mode menu)
The chat's Mode menu is real Harness behaviour. Each turn the page sends the chat's mode (mode in the /api/chat/stream body); before the prompt reaches the Harness the bridge puts that chat's session into the matching permission preset with the Harness's own /permission command (commands/execute), reads the permissions projection back, and refuses to start the turn (typed error mode-unavailable) if it does not match. The preset table is ours (profile entry permission).
| Menu | Preset | Sandbox | Approval | What it means |
|---|---|---|---|---|
| Manual (default) | strata-manual |
open (danger-full-access) |
ask |
The Strata gate (plugins/strata-gate.mjs) asks BEFORE any change runs: one Approve/Deny card, nothing has happened when it appears, no blocked attempt, no sandbox or PowerShell error. Reads and read-only commands run without a question; anything the gate cannot prove read-only asks. |
| Plan | strata-plan |
read-only |
never |
Nothing can change. A request is rejected without asking anyone, so no Approve card is shown; the card ends "Not allowed in this mode". |
| Bypass | strata-bypass |
danger-full-access |
never |
Full access without prompts, as before. |
- Manual relies on the gate, so a Manual turn does not start unless the bridge has confirmed the gate is loaded (
/strata-gatecommand): without it Manual would be an open sandbox that nobody asks about. - The gate listens to
tools/pre-execute(the seam the Harness's own Auto-review layer uses) and returns anaskdecision; the Harness's approval service then asks, runs the tool only afterallowed-once, and records the answer. Read-only tools and a short allowlist of look-only shell commands (Get-ChildItem, git status, ...) run unasked; MCP and unknown tools ask. - The mode is read once per turn; an unknown or missing value is Manual.
Tools
preset.mjs is the agent preset: the Harness standard preset minus the scheduler (Tasks is the only one), web search (needs a key the app has none of; search: true switches it on), the agent's own question tool (no place to answer) and the Harness's plan mode. tests/agent-tools.test.mjs compares the list with the pinned Harness's own preset file and the tools it actually offers. The model's tool servers (Settings, Tools) are connected as Harness MCP client rows (mcpRows in profile.mjs); their secrets travel in the agent's environment, never in the profile file.
Helper agents (subagents)
- A Harness
subagent/catalogevent on the chat's session creates a row;children.mjsfolds the helper'ssession/follow(address{kind:'subagent', parentSessionId, childSessionId}) into{type:'agent', agent:{id,name,description,status,durationMs,tokens,updatedAt}}, the shape the Subagents popover already reads. The delegation tools have no card. - A helper's request for approval is the same card (state
proposed, id<helper session>:<call>), answered with the same/api/chat/approval; a chat can only answer its own helpers. - The run (the chat's one NDJSON response) stays open until the parent is idle, every helper has finished and reported back, and no armed goal is waiting;
doneis sent then. - Stop: pauses an active goal, interrupts every helper (
subagents/interruptByParent;session/cancelon a helper session is refused by the Harness), cancels the parent, waits; a report that would wake the parent afterwards is cancelled too. - The number of helpers at once equals the engine's request slots (
maxActiveSubagentsin the profile); the Harness refuses more with a message the model reads.
/goal
/goal typed in a chat goes to bridge.goalCommand: nothing = show the goal, clear, pause, resume, edit <text>, complete, anything else = a new goal (one unfinished goal at a time). Create/resume use the Harness goal Remotes (goals/create|get|resume|pause|edit|clear|complete); the Harness's goal driver runs the rounds and they stream into the chat ("Working on the goal, step N"); the run ends when the goal stops (complete, paused, blocked, round limit - the default cap is the Harness's 256, a run with maxRounds is capped) and says how in plain words. After a restart an active goal stays disarmed until /goal resume.
Thinking and the output budget
- A local route is reasoning-capable (
reasoning: true) withcompat.thinkingFormat: 'chat-template': the request carrieschat_template_kwargs {enable_thinking, reasoning_effort}, which the Strata server reads (a top-levelenable_thinkingis ignored by it, which is why pi-ai'sqwenformat left the model thinking). The chat's Reasoning menu travels asthinkingin the stream body; the bridge sends it withsession/selectModel(reasoningEffort) whenever the model or the level changed; a level a route does not have is dropped (never an error). API routes keep the provider default (the menu is disabled for them in the UI). localOutputBudget(context)= context minus 4096 (it was context/4 capped at 8192, which cut big answers off at exactly 8192 tokens); pi-ai sends the window minus the prompt. App-loaded models getfit_max_tokens: trueso the engine clamps instead of answering 400. Sampling is not set here: the Harness sends none, so the server's own defaults apply.
Tasks
task-run.mjs runs a scheduled task as the agent: a Harness session of its own (task:<id>, dropped after every run), the task's mode (plan default, manual, bypass), and a result built by ../task-report.mjs. Nobody is at the screen: an approval request is answered "no" at once and reported ("Nothing was changed"). server/tasks.mjs stays the only scheduler; it sends a task event when a run ends (the page shows a toast).
Plain words
Failures the person sees are plain sentences with a next step (AgentUnavailable.message); the technical text is in .details / the details field of error and notice frames, and in /api/agent/status detail. A failed tool's card result is a plain sentence followed by "Details: ".
Tests
tests/agent-events.test.mjs (pure), tests/agent-bridge.test.mjs, tests/agent-modes.test.mjs and tests/agent-host.test.mjs (need a built Harness:
STRATA_HARNESS_DIR=<checkout>, otherwise they skip and say so). The model in those tests is tests/helpers/scripted-worker.mjs.
scripts/agent-flow.mjs drives the real app in Chrome and takes screenshots.