okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

albedocmake: strata_kernels links strata_kernels_cpu (iq_kernels.cu reads the latent colscale table from expert_layout.cpp; strata-q36ref failed to link)a4af4df61

main
1 folder28 files

files

plugins/
README.md23.4 KiB
agent-bridge.mjs97.6 KiB
ask.mjs8.8 KiB
browser-probe.mjs3.3 KiB
children.mjs8.3 KiB
context-budget.mjs10.0 KiB
context-fit.mjs7.4 KiB
custom-command-run.mjs6.1 KiB
custom-tools-mcp.mjs3.8 KiB
deliverables.mjs14.0 KiB
engine-progress.mjs765 B
engine-speed.mjs2.2 KiB
events.mjs30.6 KiB
gateway-client.mjs6.5 KiB
harness-runtime.mjs9.2 KiB
llm-shape.mjs6.6 KiB
model-routes.mjs9.0 KiB
plan.mjs15.0 KiB
preset.mjs9.1 KiB
profile.mjs27.6 KiB
reply-cut.mjs7.6 KiB
skills-used.mjs2.4 KiB
status.mjs8.8 KiB
task-run.mjs2.3 KiB
tools-catalog.mjs3.2 KiB
tools-settings.mjs11.8 KiB
turn-guard.mjs6.0 KiB
user-questions.mjs2.4 KiB

Agent bridge (Strata chats as DeepSeek Harness sessions)

This page is for developers who work on the app host's agent code. It lists the files, the frames and routes, and the rules the bridge enforces. Tests are listed at the end.

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.

FileJob
harness-runtime.mjslocate the component, start/stop the process, scrub its environment, clean up a leftover process from a dead host
gateway-client.mjsHTTP RPC plus the remote.mux WebSocket ($events, session/follow)
profile.mjsgenerate the Harness profile: one route per ready local instance and per saved API connection; credential names only
task-run.mjsa scheduled task as the agent
events.mjspure projection of Harness session events into the chat's NDJSON frames
children.mjspure projection of one helper agent's events into its row and its approval card
preset.mjsthe agent preset (which tools the chat has)
plugins/strata-gate.mjsthe Manual-mode approval gate (a Harness plugin, loaded by path)
plugins/strata-search.mjs, plugins/strata-models.mjsthe app's web search registered with the Harness; helper agents on a named model
plugins/strata-context.mjs, context-budget.mjs, context-fit.mjsmeasured context pressure, summaries that fit the window, the check before a message goes out
agent-bridge.mjsthe 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 (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

Behaviour worth knowing

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).

MenuPresetSandboxApprovalWhat it means
Manual (default)strata-manualopen (danger-full-access)askThe 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.
Planstrata-planread-onlyneverNothing can change. A request is rejected without asking anyone, so no Approve card is shown; the card ends "Not allowed in this mode".
Bypassstrata-bypassdanger-full-accessneverFull access without prompts, as before.

Tools

preset.mjs is the agent preset: the Harness standard preset minus the scheduler (Tasks is the only one), 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 file, so a Harness update that adds or renames a plugin fails a test instead of silently dropping a tool.

Settings -> Tools

What the person chose is saved by tools-settings.mjs (inside the host's settings file) and shown by src/components/SettingsTools.tsx (GET/PUT /api/agent/tools, POST/PATCH/DELETE /api/agent/tools/custom[/id]). A change reaches the agent from the next message: the profile carries a toolsSignature, and the bridge restarts the Harness (after the running turns end) when it differs.

Helper agents (subagents)

/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…", with no step counter); 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

The Harness staging script (apps/desktop/scripts/stage-harness.mjs) applies Strata's guarded pi-ai 1.1.0 patch to its staged copy (harness-budget.mjs, #3684): below 64K the context safety room is at most min(4096, floor(contextWindow / 16)) and never more than half the estimated remaining room, so an 8K window keeps output room after a tool result instead of ending with a one-token cap. The caller's output cap and the one-token floor remain; windows of 64K or more keep the previous calculation. BUNDLE.json.patches records the patch identity, the dependency version and the before/after SHA-256. Unknown dependency bytes stop staging for review. Source and already-installed Harness copies are not changed.

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: <original text>".

Tests

tests/agent-events.test.mjs (pure), tests/agent-tools-settings.test.mjs (Settings -> Tools, web search, the browser and the person's own tools; the Harness-backed ones need STRATA_HARNESS_DIR and the browser one also Chrome or Edge), 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.

Helper agents on a named model (plugins/strata-models.mjs, model-routes.mjs)

The Harness's subagent tool takes an exact provider route key and model id. The profile enables the Harness's subagent-model-selection-settings with every route the app can reach (local instances and saved API models), and the strata-models plugin wraps the two tool definitions the Harness registers for each chat (subagent, list_subagent_models) in place:

If a Harness update renames those tools the wrapping does nothing and tests/agent-subagent-models.test.mjs (real Harness) fails.

Reasoning for API models

A model on OpenRouter whose model list names reasoning in supported_parameters gets reasoning: true and the efforts {off: none, low, medium, high, max: xhigh} and the openrouter thinking format, so the Reasoning menu works and the choice reaches OpenRouter as reasoning: { effort }. Other API models keep the provider's own default (the menu stays greyed).

Pictures

Pictures are on by default for every model that can read them: an API model reads them unless the person switched it off (Settings > Models > "Read pictures with this model") or its server says it cannot; a local model reads them when it was loaded with Read pictures (on by default). src/lib/pictures.ts is the one answer used by the composer and by Send; the agent route declares image input from the same flag.

Turn guard (turn-guard.mjs)

A turn that keeps failing the same way is stopped by the app, never left to the model.

Context: measured pressure, summaries that fit, the check before a message goes out

History / older measurements