# Admin backend spec (v2 M5) What the management app's screens (`docs/v2/desktop-app.md`) stand on: the data folder, editing the settings, the stored secrets and the logs. Plain Rust in the app crate, with no window: the Tauri shell (M5, later step) only calls these, so every rule here is tested on any OS. ## Principles - **One folder.** Everything the app keeps lives in the data folder the user chose (`desktop-app.md`, "데이터 폴더 구조"); outside it there is only the file that remembers where it is. - **The file stays the user's.** Settings edits change only the keys they name, write only values that differ from the default, keep keys the app does not know, and never leave a half-written file. - **Secrets never reach a log, a copy or an export.** - **Logs carry no conversation text** (already the rule for every log line, `discord_core.spec.md`, `voice_worker.spec.md`); exports still mask secrets. ## Data folder (`app/src/datadir.rs`) The location file is `%APPDATA%\JarvisBot\location.json` on Windows and `$XDG_CONFIG_HOME/jarvis-bot/location.json` (else `~/.config/jarvis-bot/location.json`) elsewhere: `{"dataDir": ""}`. `JARVIS_DATA_DIR` set in the environment wins over it (tests, development). No location (no file, no variable) means the first-run wizard has not finished. `DataDir::create(path)` makes the layout below inside an existing or new folder and returns it; it never deletes anything. `DataDir::choose(path)` creates it and writes the location file (atomically). ``` config/ runtime/ models/llm models/stt models/tts models/vad memory/ browser/ collect/ cache/ logs/ models/hf models/nltk ``` `free_bytes(path)` reports the free space of the disk holding the folder (or its nearest existing parent); the wizard compares it with `RECOMMENDED_FREE_BYTES` (200 GB) and warns below it. A path that is not absolute, or is a file, is refused with a message. ## Settings editing (`app/src/settings_edit.rs`) `config/settings.json` keeps the format of `discord_core.spec.md` and `conversation.spec.md`. - `fields()` describes every key the screens edit: its dotted path (`call.mode`), screen (`bot`, `channels`, `chat`, `memory`, `model`, `features`, `collect`, `schedule`, `pcControl`, `game`, `app`), kind (bool, integer with a range, number with a range, text, text list, choice with its values, Discord ID, Discord ID list, ID to number map, chat channel list, MCP server list, collection target list, free object), its default and a Korean label. The screens are built from this list, so a key is added in one place. - `view(dir)` returns every field's current value: the file's value, or the default when the file does not set it. A file that does not parse is reported, not overwritten. - `apply(dir, changes)` takes `{path: value}`. Each value is checked against its field; a value equal to the default removes the key (and a section left empty), any other value is set. Keys the app does not know are kept as they were. The whole result must pass the app's own settings check (`parse_settings`); only then is it written (temporary file, then rename). A refused change names the key and changes nothing. - `memory` (new section): the worker's memory settings (`voice_worker.spec.md`, "Memory settings": `chat`, `others`, `off`, `since_days`, `recent_minutes`, `recent_records`, `matches`, `budget_tokens`), sent in the worker `hello` as `memory`. Default `{}` (the worker's defaults). ## Features and MCP servers (`app/src/features.rs`) `docs/v2/desktop-app.md`, "기능". The 기능 screen turns the brain's built-in features on and off and manages the MCP servers it connects. - `features` (new section): `weather` (`getWeather`), `webSearch` (`webSearch`, `fetchWebPage`) and `meals` (`logMeal`, `fetchMeals`, `deleteMeal`), each on by default; `collect` (background collection, below, and the brain tool `collectedNews`) and `browser` (the bot browser, below "Bot browser", and its brain tool `botBrowser`, `src/jarvis/tools/builtin/bot_browser.spec.md`), also on by default; `browserShare` (봇용 크롬창 화면공유 선택 표시, the bot browser on the virtual monitor, below "Virtual monitor"), off by default; `schedule` (reminders and scheduled tasks, below "Schedules", and the brain tool `schedule`), on by default; `notes` (personal notes, below "Personal notes", and the brain tool `personalNotes`), on by default; `screen` (화면 보기, below "Screen viewing", and the brain tool `screenView`), on by default. The tools of a feature that is off go into the brain's `disabled_tools`: they are neither offered nor run (`voice_worker.spec.md`, "Tools"). PC control comes with its milestone (M7). - `mcpServers` (new list): each `{name, command, args, env, enabled}`. `name` is 1-32 letters, digits, `-` or `_` without `__` (the brain names a server's tools `__`), not listed twice; `command` is not empty; `args` a list of strings; `env` the names of the environment variables the server gets (each a letter or `_`, then letters, digits or `_`; not listed twice); `enabled` on by default. Only enabled servers reach the brain's `mcps` (stdio). - **Environment values are secrets** (API keys): never in the settings file or `config/brain.json`. Each is stored in the secrets as `mcp::` (`mcp_env_set`, only for a server and name already saved; an empty value removes it), shown on the screen only as stored or not, and masked in logs like every secret. Saving `mcpServers` removes the values of servers and names no longer listed. On start the app passes the enabled servers' stored values to the worker in its environment, `JARVIS_MCP_ENV` (`{server: {NAME: value}}`); the brain takes that variable out of its own environment and gives each server only its own values. - Each server's outcome (its tool count, or why it failed) is a worker line in the LLM log tab, also without debug logging. MCP servers are programs the PC runs; the screen says to add only trusted ones. ## Background collection (`app/src/collect.rs`) `docs/v2/desktop-app.md`, "백그라운드 수집", and `docs/v2/pc-features.md`. The frame for collecting sites, search words and RSS feeds on a schedule; there are **no targets by default**. - `collect` (new section): `keepDays` (1-365, default 30) and `targets` (default empty), each `{name, kind, value, everyMinutes, enabled}`. `name` is 1-32 letters, digits, `-` or `_` (any script; it names the target's folder, so not a Windows device name like `con` or `nul`), not listed twice, also not in another case (`News` and `news` would share one Windows folder); `kind` is `site`, `search` or `rss`; `value` is an http(s) address for `site` and `rss` (at most 2,000 characters) and the words for `search` (1-200 characters); `everyMinutes` 15-10080 (default 60); `enabled` on by default. - On every start the app writes `config/collect.json` (the folder `collect/`, `keepDays` and the enabled targets, none with `features.collect` off) and passes it to the worker as `JARVIS_COLLECT_PATH`. Without targets the worker collects nothing but still deletes results older than `keepDays`. The worker collects while the services run (`voice_worker.spec.md`, "Background collection"); results stay in `collect//.jsonl` in the data folder only. - `results(data, target, limit)` reads them newest first (the newest day file first, its last line first), each item with its `target`; a name that is not a valid target name is refused, so no other folder is read. Lines that do not parse are skipped. ## Schedules (`app/src/schedule.rs`) `docs/v2/proactive.md` (제안 1). People ask Jarvis by voice or chat to remind them, set a timer or check something at a time or regularly; the brain's `schedule` tool (`src/jarvis/tools/builtin/schedule.spec.md`) asks the app, which keeps, fires and delivers them. - **Store**: `config/schedules.json` in the data folder, `{nextId, items}`; each item `{id, user, name, kind, text, repeat, next, via, channel, created, last}`. Read and written whole, one change at a time in the process (the services' loop and the screen share it). Text 1-500 characters (whitespace collapsed), `kind` `remind|task`, `repeat` `none|daily|weekdays|weekly`, `via` `voice|chat` (chat needs the channel it was asked in), at most 50 per person. A one-off time that has passed is refused; a repeating one starts at its first time after now (`weekdays` skips Saturday and Sunday, `weekly` keeps the weekday). Repeats keep the local wall time. - **The brain's actions** (`schedule_action`, `voice_worker.spec.md`, "Schedules") are done for the person named in it only: `add` (named as Discord shows them now), `list` (their schedules that still fire, soonest first), `delete` (one of theirs). The answer carries `{id, kind, text, next, repeat}`; a refusal says why. With `features.schedule` off the tool is not offered; schedules already kept still fire and can be deleted on the screen. - **Firing**: while the services run, every 5 s the due ones are taken. A repeating one is judged by its latest time up to now (earlier ones passed while the app was off are skipped, not sent in a row) and moves on to its next time at once; a one-off one stops firing. One whose (latest) time is more than 15 minutes ago (the app was off, the PC asleep) is not delivered and is kept as missed. A schedule taken is marked as being delivered until its outcome is recorded; one still marked at the next start (the app stopped while delivering it) gets a failed outcome then. Each delivery runs on its own task, and stopping the services stops the loop and every delivery it started. - **Delivery**: a `task` first runs in the brain (`reply` `via: "task"`: read-only tools, its own short-term memory, at most 300 s); no answer is a failure. The text sent is `님, `. Asked by voice: spoken when the person is in Jarvis's voice channel and counted only when the speech ends played to the end (at most 120 s, queued behind what is being said; when no end comes by then the speech is cancelled, waiting or playing, so it never plays after the post); otherwise, or when it failed or was stopped, posted in `schedule.chatChannel`; asked in chat: posted in that channel. Posts ping nobody and need the channel's send switch. A delivered one-off schedule is removed; one that failed, or was missed, stays (not firing again) with its outcome `last: {at, ok, note}` for the screen, and a repeating one keeps its latest outcome. - `schedule.chatChannel` (new section, null by default): a registered chat channel with sending on (anything else is refused), for voice schedules whose person is not in the voice channel. Null: those are not delivered (and the screen says so). - Logs (tab `conversation`): ids, kinds, repeats, channel ids, counts and outcomes, never the text. ## PC control permissions (`app/src/permissions.rs`) `docs/v2/pc-features.md` ("키보드·마우스 제어와 안티치트") and `docs/v2/proactive.md` (제안 3; user decision 2026-11-14). What Jarvis may do on this PC and for whom; the PC control module (M7) asks `decide(settings, user, action)` before every action and gets allow, ask or refuse with a reason. - `pcControl` (new section): `allowedUsers` (Discord user IDs, empty by default) and a level per kind of action that can be changed, each `auto`, `ask` or `never`: `view` (seeing the screen, a monitor or a window, and the window list; default `auto`), `click` (buttons, menu items, a point on the screen; `ask`), `type` (text and keys; `ask`) and `run` (starting a program; `ask`). - Only people in `allowedUsers` may ask for anything, screen viewing too (the screen may show anything); with nobody listed nobody may. `ask` means the action is done only once the person agrees in their next message (checked by the PC control tool like the chat delete consent). - Never done, whatever the settings: payments, passwords and other secrets, deleting files, and anything that needs administrator rights. They have no setting. - The PC 제어 screen edits the section and shows, read-only, what is never done and each registered chat channel's send and delete switches (changed on the 채팅 채널 screen). ## Screen viewing (`app/src/screen.rs`) `docs/v2/pc-features.md` ("화면 보기", "화면 질문을 빠르게"). The brain's `screenView` tool (`src/jarvis/tools/builtin/screen_view.spec.md`) sees all monitors as one picture, one monitor, or one window; the app captures and decides who may. - **Available** only on Windows with `features.screen` on, someone in `pcControl.allowedUsers` and `pcControl.view` not `never`. Otherwise `screenView` is in the brain's `disabled_tools` and the LLM reads no pictures (`--vision off`, below "LLM"). Settings apply on the next start. - **Who**: every `screen_action` (`voice_worker.spec.md`, "Screen viewing") is decided for its asker by `permissions::decide(View)`: people not registered are refused ("PC 제어 화면에 등록된 사람만 화면을 볼 수 있습니다"), and so is viewing at `ask` until the PC control tool brings the next-message consent (M7, next step). Viewing works while an anti-cheat game runs (it only reads). - **Capture**: Windows Graphics Capture (D3D11, no cursor, no yellow border where Windows allows it), one session per request, the first frame within 2 s. Monitors are numbered as Windows numbers them (`\\.\DISPLAY`); the bot browser's virtual monitor ("Virtual monitor") is left out of the list and of the whole screen. `screen` puts all monitors in one picture as they are placed; `window` takes the visible top-level window whose title or program name contains the text (case-insensitive; the one nearest the front when several do), also when others cover it; a minimised window is refused ("최소화되어 있어 볼 수 없습니다"). - **Exclusions**: `pcControl.screenExclude` (program file names, ".exe" may be left out; default `1Password`, `Bitwarden`, `KeePass`, `KeePassXC`). Their windows are never captured or listed, and in a monitor or whole-screen picture their area is painted black before anything leaves the capture. A window whose program cannot be told (its process refuses the query) counts as excluded. The excluded windows are read before and after each monitor or whole-screen capture; when they differ (one moved, was brought back or opened), that capture is thrown away and taken again, at most 3 times, then refused ("보면 안 되는 창이 움직이는 중이라 지금은 볼 수 없습니다"). Known limit: a window brought back and hidden again within one capture (about 0.1 s) looks the same before and after, so the comparison does not catch it; tracking window events during the capture (`SetWinEventHook`) may close this with the PC control step. - **Pictures**: scaled down (area average) so the long side is at most 768 px (`fast`), 1280 px (`normal`) or, for `detailed`, cut in four parts of at most 1280 px each (a picture whose long side is at most 1600 px stays one part at full size); JPEG quality 80. At most 3 MiB of pictures per answer, else refused. A picture that is all black is refused ("화면이 검게 나와 볼 수 없습니다", protected video, exclusive full screen). Pictures go only into the `screen_action_result`: never saved, never logged. - **List**: monitors `{number, width, height, main}` and visible windows `{program, title, minimised}`, front first, at most 30, without excluded programs and the app's own windows. - **Activity**: each capture is `screen.view` with the target (`전체 화면`, `모니터 `, `창`; never a title), who asked and whether it worked ("Activity"). - Logs carry the action, target kind, size and time taken, never a title or a picture. ## Personal notes (`app/src/notes.rs`) `docs/v2/proactive.md` (제안 4). Each person's standing instructions for how Jarvis answers them, saved by the brain's `personalNotes` tool (`src/jarvis/tools/builtin/personal_notes.spec.md`) and editable on the 사람별 지침 screen. - **Store**: `config/notes.json`, `{nextId, items}`; each `{id, user, name, text, created}`. Text 1-300 characters (whitespace collapsed), at most 20 per person. Read and written whole, one change at a time in the process. - **The brain's actions** (`note_action`, `voice_worker.spec.md`, "Personal notes") are done for the person named in it only: `add` (named as Discord shows them now), `list`, `delete` (one of theirs). - **Sent with replies**: every voice answer, chat answer and scheduled task carries the asker's notes (`reply` `notes`), oldest first; nobody else's. With `features.notes` off (on by default) none are sent and the tool is not offered; the notes stay and can be edited. - `notes_list` (everyone's, by person, IDs as strings), `note_update` `{id, text}` and `note_delete` `{id}` serve the screen. Logs carry note ids only, never their text. ## Conversations (`app/src/history_view.rs`) What people said, what Jarvis answered and how it made each answer, for the 대화 screen. Read only, from the worker's history store `memory/history.sqlite` (`src/jarvis/memory/history.spec.md`, records and "Traces"), so it works while the services are stopped. Nothing it reads goes to a log. - Each item is `said` (a voice transcript, or a chat message by someone other than Jarvis), `answered` (a spoken answer, or Jarvis's own chat message; to whom, when it answers someone) or `thought` (a trace: the question, the answer or none, how long it took and its steps so far, at the time it was asked; `pending` while the answer is being made, with `ms` 0 until it ends). Jarvis's chat messages are known by the bot's user id (the first part of the stored token is that id in base64) and by the author of any chat answer to someone. - `history_query` `{said, answered, thought, via, person, channel, find, since, until, session, before, from, limit}`: the three kinds (each on unless false), where (`voice`, `chat`, `task`; a task has traces only), a person (their records, answers to them and traces of their questions), a channel, text the record or the trace's question, answer or steps contains (records folded like the store: NFKC, lower case), Unix seconds from (inclusive) and to (exclusive), `session` (only items from when the latest service start of this app run began; none before the first start), the cursors `before` (only items older than it) and `from` (it and newer), each an item's `{at, key}`, and `limit` (1-2000, default 200). Items are ordered by time, then records before traces, then id, so paging by cursor never skips or repeats an item, even at equal times. Answers `{items, more, people, channels}`: the newest `limit` items in time order, whether older ones were left out, the people who spoke (their latest name) and the channels with records (with the name given a chat channel in the settings), and `session`, when the latest start began (Unix seconds, null before the first). Without the file: no items and `missing: true`. - `history_stamp`: `{stamp}`, a string that changes when a record or trace is added and as a trace still being made gets a step or ends (the newest ids, and the number and length of the steps of the traces being made), cheap enough to ask twice a second; not logged. ## Activity (`app/src/activity.rs`) `docs/v2/proactive.md` (제안 5). What Jarvis did outside its answers, for the 로그 screen's 한 일 view: each chat channel action the brain's tool asked for (`chat.send`, `chat.edit`, `chat.react`, `chat.delete`, `chat.pin`, `chat.unpin`), each schedule delivery (`schedule.remind`, `schedule.task`) and each news notification (`collect.notify`), each screen capture (`screen.view`, "Screen viewing"), done or failed. The other PC control actions join it with M7. Ordinary answers are not recorded. - One JSON line per action in `activity/.jsonl` (the folder is made at the first one): `{at, kind, target, by, ok, note}`. `target` is the channel (and message) id or `예약 `; `by` is who asked, ` ` (the brain's `chat_action` carries the asker, voice_worker.spec.md); `note` is why a schedule delivery failed, or the fixed `채팅 동작 실패` for a chat action (its error may quote what the model wrote). **Never the text** of a message, reminder or answer: an id that is not digits is recorded as `(잘못된 ID)` and an unknown chat action as `chat.other`. - Day files older than 30 days are deleted when the services or the screen open the log, and on the first record of each new day while it runs. A failed write is a warning in the log and never stops the action. - `activity_list` `{limit}` (1-1000, default 200) reads the newest first. ## News notifications (`app/src/collect_notify.rs`) `docs/v2/proactive.md` (제안 2). New items of the background collection announced in a chat channel, titles and links only (no LLM, nothing Jarvis writes about them). - Each collection target has `notify` (`off` by default, `now`, `daily`); `collect.notifyChannel` (a registered chat channel with sending on, anything else refused; null by default: nothing is announced) and `collect.digestHour` (0-23, default 9, local time). Nothing is announced with `features.collect` off. - While the services run, every minute: a target whose notifications just began only marks what it has as seen (nothing old is announced; its first digest still comes that day); a `now` target posts what is new since its last post; a `daily` target posts once a day in the digest hour what came since its last digest (nothing when nothing came). The state is `config/collect-notify.json` (per target the newest item announced and the day of its last digest), saved before anything is posted: a round whose state cannot be saved posts nothing (else it would post the same items every minute) and the next round tries again. - A post is `수집 소식: 새 글 N건` (`수집 소식 하루 요약: ...` for the digest), then at most 10 items as `- <link>` (titles at most 200 characters; the link in `<>` so Discord shows no preview), then `외 N건`. Posts ping nobody. Each is recorded in the activity (`collect.notify`, target `수집 <name> → 채널 <id>`, outcome); a failed post is not tried again. - The 백그라운드 수집 screen has the channel, the hour and a "새 글 알림" column in the targets table. - The brain's `collectedNews` tool reads the same results (`src/jarvis/tools/builtin/collected_news.spec.md`); it is behind `features.collect` too. ## Secrets (`app/src/secrets.rs`) `config/secrets.dat` holds a JSON object of named secrets (`discordToken`, the MCP servers' environment values `mcp:<server>:<NAME>`). On Windows the bytes are encrypted with DPAPI for the current Windows user (`CryptProtectData`, no prompt), so the file is useless copied to another account or PC. Elsewhere (development only) the file is plain JSON with owner-only permissions (0600). Writes are atomic. `get`, `set`, `remove`, `names`; `masked(value)` shows only the last 4 characters for the screens (`••••abcd`). The app's token comes from the secrets (`discordToken`), else from `JARVIS_DISCORD_TOKEN` (tests, headless runs). ## Logs (`app/src/logs.rs`) `debug_log!` and `error_log!` keep printing to stderr and also feed the log hub once the app installs one (`logs::install`). Each line has a time, a level (`error`, `warn`, `info`, `debug`), a service tab and its text. The tab comes from the line's category: `app`, `discord` (`voice`, `receive`, `play`, `discord`), `chat`, `conversation` (also `schedule`), `worker` (the voice worker's own lines; its STT, LLM and TTS lines go to `stt`, `llm`, `tts` by their worker category), `browser`, `capture`, `game` (the last three from M6-M7). Unknown categories go to `app`. - Memory: the last 5,000 lines for the log screen (`query`: tab, lowest level, text to find, and the lines after a given sequence number, for live follow). - Files: `logs/<tab>-<YYYY-MM-DD>.log`, one line per entry; files older than 14 days are removed at start and once a day. - `recent_error_report()`: the last error with up to 30 lines before and 10 after it (all tabs, in order), the app version and a short PC summary (OS, CPU count, memory); `None` without an error. When it is over 2,000 characters (Discord's message limit) the screen offers a download instead. - `export_zip(from, to, out)`: the log files of those days in a zip, at most 10 MB (Discord's file limit): when larger, the oldest lines by the time they were logged, across every tab's file, are left out and a note says how many. - Every line runs through `redact` before it is kept or written to a file, and every copy and export again: each stored secret's value, and anything shaped like a Discord bot token (also with sentence dots around it), becomes `[비밀값]`. So a secret replaced or removed later never shows on the screen, in a copy, a file or an export, also after a restart. The values masked are the stored secrets and the ones the running services were started with (the bot token, the MCP servers' values; `set_secrets_in_use` on each start): a key replaced or removed while the services run stays masked in their late lines (the worker and MCP servers keep it until they are restarted), until the next start gives them only the current values. - Errors the voice worker reports to the app (`error` messages: code and request id) are always logged, debug logging or not, so the log screen and the error report show them. - Saves the user asks for on the 로그 screen, each a file in `logs/` whose path comes back (kept until the user removes it, like the zip; the 14-day cleanup takes only `<tab>-<day>.log`): - `logs_save_text {text}`: the lines the 로그 view shows, masked again, as `jarvis-log-view-<YYYYMMDD-HHMMSS>.txt`. - `history_export {from, to}`: every item of the 대화 screen on those local days, in time order, as `jarvis-talk-<from>-<to>.txt` (`history_view::export_text`): each record (time, who with their ID, voice or chat and channel, the text), each answer (to whom), and each trace in full: the question, the records and notes it was given (every line), the tools offered, the plan, the model's thinking, every tool call (arguments, success, failure or skipped and why, the whole result) and the answer. Conversation text, so never a log line; masked like an export. - `voice_export {from, to}`: the recordings of those days (`recordings/<day>/`, `voice_worker.spec.md`, "Recordings") as `jarvis-voice-<from>-<to>.zip`: the WAV files under `<day>/`, each day's `index.jsonl`, and `index.txt` listing every file in time order with its length, who said it and the transcript (or Jarvis's spoken text, and whether it was stopped partway). No recordings: a zip whose `index.txt` says so. ## Service control (`app/src/control.rs`) The dashboard's start and stop buttons, and the app binary itself, run the services through one `Controller` for the data folder: states `stopped`, `starting`, `running`, `stopping`, `failed` (with the error, secrets masked). `start` from stopped or failed only, `stop` from running or starting; `restart` is stop then start. A start that fails leaves nothing running. A stop while starting cancels the start (the LLM's model download or load stops and its server is cleared) and ends in `stopped` without an error; if the start finished anyway, what came up is stopped again. The screens' `service_start` and `service_restart` return as soon as the state is `starting` (restart stops first) and the start runs in the background (the first start downloads the model); the dashboard shows how it goes, a stop right after the answer cancels the start and a second start is refused. A stop that cannot confirm everything ended (the LLM's server still answers) ends in `failed` with the reason, not `stopped`; a start (Strata's `--restart`) can follow. The same goes for a cancelled start that could not clear the server. Starting reads the settings and the stored token again, so saved changes take effect on the next start. Each start gets a new dashboard fed by that run's events; `stop` ends the feeding (and waits for it) before the dashboard is forgotten, so an event queued before the stop, or sent by an earlier run, never reaches the screen. ## Dashboard data (`app/src/dashboard.rs`) `Controller::snapshot()` is everything the dashboard shows, as one JSON-ready value: - `state` and `error` (above); `discord`: the bot's tag once connected; `worker`: connected, STT and TTS ready (from the worker's `hello_ok`), restarts of its process. - `voice`: the voice channel Jarvis is in and the people there (ID and display name), as the core reports them to the worker. - `captions`: live captions, the last 30 lines: a speaker's partial transcript is replaced by their next partial and then by the final. A transcript belongs to the voice session its utterance started in (`Heard.session`, `discord_core.spec.md`): only the current session's are shown, so one arriving after Jarvis left, or after it moved to another channel, is not. On the screen only: never logged, never written, cleared when Jarvis leaves the voice channel or the services stop. - `latency`: the last 20 voice answers, each split into its stages: speech end to final transcript, the brain (answer asked to answer text), the voice (answer text to the first sound) and the total; with the median of each. The core's `AnswerAsked { id, user, ended_at, final_at }` event carries the speech id and the request's own times (when its speech ended, when its final arrived), so a second question waiting behind the first does not change the first's times. - `missed`: the conversation's missed requests (`conversation.spec.md`), newest first, at most 20: who, why and how long ago, never the text. - `system`: memory in use and total, and per NVIDIA GPU its use and VRAM (from `nvidia-smi`, missing when there is none); sampled when the snapshot is taken, at most once a second. - `browser`: the bot browser's `{state, note}` ("Bot browser"). - `llm`: the LLM's state (`off`, `starting`, `ready`, `failed`), whether the app runs it (`managed`), and while starting Strata's last line and how far that line says it got (its percentage, or `X of Y GB` for the model download; none on a line without progress), also before the services are up; a failure's reason in `note`. - `game`: the game that game mode is on for, `{name, reason}` (below, "Game detection"), or null. - `performance`: `{stage, gameRoomMib}` from the LLM: `normal`, `gaming` (with the graphics memory the game gets) or `paused` (below, "Performance stages"); null before the services run. The dashboard's state is built from the core's events alone (`Dashboard::on_event` with the time), so it is tested with made-up events. ## Install (`app/src/install.rs`, `app/src/download.rs`) The wizard's model step installs the runtime into the data folder with the recipe the M0 kit used on the game PC (`scripts/m0`). The steps, in order: | Step | What | |---|---| | `uv` | `uv` 0.11.20, downloaded with resume and checked against the release's SHA-256, into `runtime/uv` | | `worker_env` | Python 3.12 venv `runtime/venvs/worker` with `src/voice_worker/requirements.txt` and `requirements-brain.txt` (the v2 brain only; the repository's `requirements.txt` is v1's desktop app) | | `melo_env` | Python 3.11 venv `runtime/venvs/melo`: PyTorch 2.11 cu128 (pinned so later installs keep it), MeloTTS at a pinned commit, `python-mecab-ko` instead of the Japanese MeCab | | `stt_model` | Whisper `large-v3-turbo` (faster-whisper) | | `tts_model` | the NLTK data MeloTTS's English g2p reads, then the worker's own `melo_child.py` loads the Korean voice once (downloading it) and must say its warm-up sentence | | `strata` | Strata's own installer (`install.ps1`, `install.sh` elsewhere) with Strata's state, engine and components under `runtime/strata` and no PATH change | | `browser` | the bot's Chrome: Chrome for Testing 157.0.8103.78 (win64, linux64), downloaded with resume and checked against its pinned SHA-256, unpacked into `runtime/chrome` (below, "Bot browser") | | `settings` | `voiceWorker` in the settings pointed at the worker venv's Python with `--melo-python <melo venv> --history memory/history.sqlite --brain` (other settings kept); the install is done only once this is written | The LLM itself (Qwen3.6-35B-A3B, about 23 GB) is downloaded by Strata on its first start (below). - A finished step leaves `runtime/.done/<id>` holding its version (the pin; for `worker_env` a hash of its requirement files), so later runs skip it and a new pin runs it again. Steps run one at a time; a failure stops the run and the next run starts at that step; cancel stops the running command and every process it started (one process group, a job tree on Windows) or the download, also while a server sends nothing (a download's part file stays, so the next try continues it). - Folders go to commands as arguments or as the working folder, never inside a script's text. - Every command runs with the layout's environment: `uv`'s cache and Pythons, `HF_HOME` (`models/hf`), `NLTK_DATA` (`models/nltk`), temp files (`cache/tmp`) and Strata's folders (on Windows also `APPDATA` and `LOCALAPPDATA`, where Strata and the NVIDIA shader cache write whatever `STRATA_*` says), all inside the data folder. Python comes from `uv` only. Output lines go to the `install` log tab. A line that is not UTF-8 (a Windows PC without the UTF-8 option prints in its code page, CP949 for Korean) is read in the PC's OEM code page, never ending the reading. - Downloads go to `<file>.part`, continue with an HTTP range after a break (a server without ranges starts over), and are checked against the pinned SHA-256; a wrong checksum deletes the part. - When every step is done, `uv`'s download cache is cleaned (the venvs hold copies). - With the install complete, the services start the worker with the same environment (models, caches and temp files in the data folder; on Linux also the CUDA wheels' library folders). ## Bot browser (`app/src/browser.rs`) `docs/v2/pc-features.md`, "백그라운드 크로미움으로 정보 수집" and "봇용 크롬창과 디스코드 화면공유". The bot's own Chrome, in the data folder, driven over the Chrome DevTools Protocol (CDP). It runs in the background (headless), or with `features.browserShare` in a window on the virtual monitor (below). - `features.browser` (브라우저 제어, on by default). With it on and the `browser` step installed, the services start the bot browser after the LLM and before the worker, and stop it after the worker. Without it (off, or not installed) nothing starts. A browser that does not start is a warning on the dashboard and in the `browser` log tab; the services run on without it. - Chrome runs with its own profile `browser/profile` (`--user-data-dir`), headless, no first-run, sync, component updates, translation (also turned off in the profile's preferences before each start, keeping the others, since Chrome no longer reads the switch) or background networking, and CDP on a free loopback port (`--remote-debugging-port=0`; the port is read from the profile's `DevToolsActivePort`, which is removed before each start, and `/json/version` must answer within 30 s). The worker gets `JARVIS_BROWSER_CDP` = `http://127.0.0.1:<port>`. - Video and sound start when a page starts them (`--autoplay-policy=no-user-gesture-required`): the botBrowser tool clicks with page scripts, which Chrome does not count as a user's gesture, so a video page opened for "play X" stayed paused (live, 2026-11-16). - **Egress proxy**: every Chrome connection goes through the app's proxy on a free loopback port (`--proxy-server`, and `--proxy-bypass-list=<-loopback>` so not even loopback is direct; QUIC off, WebRTC only through the proxy). The proxy takes `CONNECT host:port` (HTTPS, WebSocket) and plain HTTP requests with an absolute `http://` address. It resolves the name once (at most 10 s), refuses with 403 unless every address is public (IPv4: not loopback, private, link-local, CGNAT, documentation, benchmarking, multicast, reserved or unspecified; IPv6: only global unicast `2000::/3` without `2001::/23`, documentation and 6to4, and an IPv4-mapped address as its IPv4), and connects only to those addresses, so Chrome can never reach the PC or the local network. Plain HTTP goes on with `Connection: close` and without proxy headers. A request it cannot read is a 400. It logs no host or address, only that it refused one. - Stop: CDP `Browser.close`, then up to 5 s for the process to end, else it and the processes it started are killed. Then the proxy stops taking connections, closes every open one (tunnels included) and the stop waits until they are gone. - Dashboard `browser`: `{state, note}` with `state` off, ready, failed (the note says why) or exited (it ended on its own). - Linux (development only): Ubuntu's AppArmor refuses Chrome's sandbox; `JARVIS_CHROME_NO_SANDBOX=1` in the app's environment adds `--no-sandbox`. Windows always runs it sandboxed, with `--do-not-de-elevate`: started by an app running as administrator, Chrome would otherwise start again as the user and end the process the app holds, so the app could neither see nor stop it. ## Virtual monitor (`app/src/vdisplay.rs`) `docs/v2/pc-features.md`, "봇용 크롬창과 디스코드 화면공유". With `features.browserShare` the bot browser's window sits on a monitor that exists only for it, so the user can pick that monitor in Discord's screen share ("화면" tab) while no real monitor shows the window. Windows only; elsewhere the browser runs headless with a note. - **Driver**: the open-source Virtual Display Driver 25.7.23 (MIT, signed by the SignPath Foundation), its `MttVDD.inf`, `mttvdd.cat` and `MttVDD.dll` in `display-driver/` next to `jarvis.exe` (`package.sh` downloads the release zip and checks its SHA-256). Installing and removing need the administrator once: the app starts itself elevated (`jarvis.exe --display-driver install|uninstall --result FILE`, Windows asks), waits, and reads why it failed from FILE. Install writes the driver's settings to `%ProgramData%\JarvisBot\display-driver\vdd_settings.xml` (the driver runs as a system service that cannot read the data folder, so this is the one place outside it; readable by users and LOCAL SERVICE, writable only by the system and administrators), points the driver at it (`HKLM\SOFTWARE\MikeTheTech\VirtualDisplayDriver` `VDDPATH`), creates the device (`Root\MttVDD`, display class) and installs the driver; Windows then asks once whether to install software from the SignPath Foundation. The new monitor is taken off the desktop at once. A failed install, also the person answering no to that question ("취소했습니다"), undoes what that attempt made: the device it created and, when the driver was not ours before, the driver package, and only when no device and no package are left, the registry value and settings folder. If something stays, the registry value stays too (so it is still ours) and the error says both why the install failed and that something is left to remove. The status says `installed` when the driver is ours and its monitor is there, `leftover` when it is ours without a usable monitor (a removal or clean-up that did not finish), `other` for another program's copy, and `action`, the button the screen offers: `uninstall` for installed or leftover, `install` when nothing is ours, none for another program's copy. Devices are found by the hardware ID among all root devices, whatever their class (a device whose driver was declined has none). The settings: one monitor, one mode (1280x720 at 30 Hz), no custom EDID. When another program's copy of the same driver is installed (its `VDDPATH` is not ours) the app refuses to install or remove and never touches its monitors; the elevated half asked to remove a driver that is not ours (another program's, or none) does nothing and exits with code 2, which the app and the uninstaller take as nothing to remove. Uninstall removes the device, then the driver package (one not in the driver store counts as gone), and only then the registry key, which makes it ours, and the settings folder; when a device or the package stays, it fails with the reason and keeps the registry key, so a retry is still allowed. - **Never under running services**: installing or removing is refused unless the services are stopped (or failed, which has stopped the bot browser already), so the monitor never vanishes under the bot browser's window; while one runs, a service start or restart is refused, and a second driver task too. - **On only while used**: a service start first takes the monitor off the desktop (left over from a run that ended badly). With `browserShare` it then attaches the monitor (no administrator needed) right of and below the rightmost real monitor, touching it only at that monitor's bottom-right corner, so the mouse hardly reaches it and no real monitor overlaps it. The stop closes the browser first and then takes the monitor off, so Windows never moves the window onto a real monitor. - **The window**: Chrome starts with `--no-startup-window` (no headless), and the app opens its one window over CDP in the background (`Target.createTarget` with a new window at the monitor's place and size), so it never takes the focus from the game or program the user is in. The window then becomes a tool window (not in Alt+Tab, Win+Tab or the taskbar), fills the monitor's work area (Windows may give the monitor a taskbar of its own) and goes behind all other windows, all without activating it. It keeps drawing when covered (`--disable-backgrounding-occluded-windows`, `--disable-renderer-backgrounding`, `--disable-background-timer-throttling`). The window holds the first page, which the bot never closes. The bot's pages open in windows of their own (bot_browser.spec.md), behind and at this window's place, because a tab brought to the front takes the keyboard focus. While the browser runs, the app looks for new windows every 200 ms and settles each the same way, the newest in front of the older ones, so the shared screen shows the page the bot opened last. - If the monitor or the window cannot be made, the browser runs headless and the dashboard's `browser` note says why ("가상 모니터 없이 실행: ..."). ## Game detection (`app/src/game.rs`) `docs/v2/pc-features.md`, "게임 감지 기준". Whether a game runs, for the performance stages (next in M7). While the services run, the app looks at the foreground window every 2 s (Windows only; elsewhere it never sees a game). It never looks at the game's screen. - `game` (new section): `detect` (게임 감지, on by default), `games` (programs that are games, as file names, ".exe" may be left out) and `notGames` (programs that are never games); each list at most 100 names, no folders; `otherRoomGb` (0-8, default 1), the graphics memory the normal placement leaves for programs opened later (above, "LLM"); `reserveGb` (0-32, default 8), the graphics memory a game gets; `revertSeconds` (0-600, default 30), how long after a game ends the normal stage comes back; `pauseInGame` (default off), stop the LLM while a game runs. Read when the services start. ## Performance stages (`app/src/perf.rs`, `app/src/services.rs`) `docs/v2/pc-features.md`, "단계" and "전환 규칙". While the services run, the app moves the LLM between the normal placement and the game placement as games come and go (not with `llm.url`). - The stage wanted (checked every second): a game (game mode on) means the game stage at once, or pause with `pauseInGame`; when it ends the normal stage comes back once `revertSeconds` have passed with no game, so quitting and starting a game again does not move the model back and forth. - A change: the brain is told the LLM switches, with a notice for the first spoken request that waits ("잠깐만요, 게임 모드로 바꾸는 중이에요", or "잠깐만요, 평소 모드로 돌아가는 중이에요" on the way back; `voice_worker.spec.md`, "LLM switches"); the app waits until the brain has written the answers in progress (at most 2 minutes; the switch is numbered, so an idle report for an earlier switch that came late does not count), restarts the LLM in the new stage and tells the brain it is ready (or paused). The worker client keeps that latest state and sends it again first on every connection (`ready` says whether the game stage runs, so the worker holds partial transcription while an answer is written in a game); keeping, sending and a connection becoming ready share one lock, so a state set while a worker connects is never lost. A restart that fails brings back the stage that ran before and tells the brain ready; the failed stage is tried again 60 s after that is over, three times at most, and the count starts over whenever another stage is wanted (also when the game ends and the normal stage already runs), so the next game tries again. When the stage before does not come back either, the LLM shows `failed` and the brain is told paused (requests fail at once instead of waiting). - The game stage: context 16,384 (or the settings' smaller one), one request at a time, half the engine's CPU threads (read from its log at the normal start, else a quarter of the logical CPUs), and the game placement (`placement.rs`: the reserve beside more than 2 GiB of experts, else 2 GiB, else 0 GiB, else pause), measured once at that context like the normal one. Other programs' memory is what the card holds after the LLM stopped, less the STT worker's model while it is loaded (1300 MiB), read afresh at every placement. A normal placement made with no game running keeps its reading; one made while a game runs (the way back from a failed game stage) keeps the earlier one. The game stage counts other programs as that kept reading and leaves a reserve of at least what has grown since (the game and any program opened after that reading), so nothing is counted twice and nothing that grew is missed. When a game already ran as the services started, there is no such reading: game detection looks once before the LLM starts, at the window in front and at every running program (one in a launcher's game folder or the person's games list counts, also behind other windows; how a window looks is not known there). Then the game stage counts what the card holds now, the game included, and leaves only the room for other programs. The dashboard shows the stage that runs, also on a fallback placement without experts. - Pause: the LLM stops (`llm` off, "게임 중 일시정지"); the brain answers nothing until the stage changes. - The foreground program is a game, in this order: in `notGames`: no; in `games`: yes (`registered`); a browser (also the bot's Chrome), video player, the desktop, Discord, a launcher's own window or this app: no; under a launcher's game folder (the folder after `steamapps\common`, `Epic Games` or `Riot Games`) or inside a Battle.net game's install folder: yes (`launcher`, with the launcher's name). Battle.net installs anywhere, so its games come from the machine's uninstall entries (64- and 32-bit), read when the watch starts: entries removed by its "Blizzard Uninstaller" or published by Blizzard Entertainment, with an install folder, not Battle.net itself. Paths are compared part by part (folder names, ASCII case ignored), never cut by byte positions, so any letters in a path are fine; Windows reports a full-screen Direct3D program (`fullscreen`): yes; its window covers one monitor completely, has no title bar or sizing border, and its process uses at least 10% of the GPU's 3D engine (`borderless`, the M0 check's rule): yes. - Once seen, game mode stays until that game's process ends, also while another window is in front; with `detect` off it is off. The name is the game's folder under the launcher folder, else the program's name without ".exe" (a Battle.net game: its uninstall entry's name). The `game` log tab gets "game mode on: name (reason)" and "game mode off". ## LLM (`app/src/strata.rs`) The brain answers with one model, Qwen3.6-35B-A3B UD-Q4_K_XL through Strata (M0). The services start it first, so nothing answers before the brain can, and stop it last. - **Strata from the data folder** (the default): `strata launch --family qwen36 --model ud-q4_k_xl --data-dir models/llm --context <llm.context> --vision <off|gpu|cpu> --parallel <n> --access local --port <llm.port> --no-api-key --restart --yes --no-tui`, run like an install command (the layout's environment, `runtime/strata` as the working folder, one process group, lines to the `llm` log tab). It downloads the model on the first start, starts the engine and returns; the app then waits (up to 30 minutes) until `/v1/models` lists the model and takes its id. `--restart` replaces a server left with other choices; the same choices are reused. `--parallel` is 1 (faster on a 16 GB card, M0) and 2 when a chat channel answers every message, so its answers do not wait behind voice answers. Pictures (`--vision`) are off unless screen viewing is available ("Screen viewing"): then `gpu` in the normal stage and `cpu` in the game stage (M0). Stopping the services runs `strata launch --stop` (ended after 2 minutes, with everything it started) and then checks that the port refuses connections; so does a failed or cancelled start, so nothing half-started keeps graphics memory (each check waits up to 10 s to connect: Windows refuses a closed local port only after about 2 s). Stopped means the port refuses connections (a stop command that fails while it does counts as stopped); a timeout, an error status (a server still loading answers 503) or an answer that cannot be read is not a confirmed stop: the LLM is `failed` with the reason, and the stop or the start reports it. The start's cancel is armed when the controller accepts the start (`Host::prepare_start`), never by the start itself, so a stop between accepting and running the start cancels it before Strata runs anything. Not installed: the start fails and says to run the install. - **Placement** (`app/src/placement.rs`, `docs/v2/pc-features.md` "PC마다 값을 계산"): with an NVIDIA card (`nvidia-smi`) the app sets the routed experts' graphics memory itself, `--set expert-vram=<GiB> --set prefill=2048`, as the M0 kit did; Strata's own placement fills the card and leaves the speech-to-text worker no room, and its qwen36 engine takes no reserve. Experts get what is left of the card after what it holds before the start (other programs), the model without experts, the STT worker's share (2740 MiB: its model and ten speakers at once, M0 `stt`), the engine's margin (768 MiB) and the room for programs opened later (`game.otherRoomGb`, default 1 GB); the budget first holds the long-prompt staging, rounded down to 0.1 GiB, 0 when nothing is left. What the model holds without experts is measured once per context, number of requests at once and card (its NVIDIA UUID): the first-run self-check, a start with `expert-vram=0`, one short answer, then the card's memory again and the staging from the engine log; kept in `config/llm-probe.json` under `<context>/<parallel>` (`<context>/<parallel>/vision` with pictures on the card), and the real start then replaces that server. A measurement whose answer or second reading fails (or shows nothing more held) is not kept: the model starts with `expert-vram=0` and the next start measures again. Before the card is read, `strata launch --stop` always runs and the start's port must refuse connections, so a server left from a run that ended badly (answering, still loading with 503, or silent) is never counted as other programs' memory; when that stop is not confirmed, nothing is read or kept and the model starts with `expert-vram=0`. Without a card nothing is set. The game placement (used by the switching that comes next) takes the reserve when it fits beside more than 2 GiB of experts, else 2 GiB and the room that leaves, else 0 GiB and its room, else pause. The `llm` log tab gets the placement and what it came from. - **A server the app does not start**: with `llm.url` (an OpenAI-compatible `/v1` address, in the settings file only) the app starts nothing; that server must list a model within 30 seconds. - **Settings**: `llm.context` (default 32768 tokens per request, 4096-262144) and `llm.port` (default 8080) on the model screen; `llm.url` (default none). `brain.location` (기본 위치, on the model screen, default `대한민국`, up to 100 characters, empty: the brain detects it): where the people Jarvis answers are, for the time line, weather without a place and searches (`src/jarvis/utils/location.spec.md`). - **The brain's settings**: on every start the app writes `config/brain.json` (it owns the file): `ollama_base_url` the LLM's `/v1`, `ollama_chat_model` the listed id, `db_path` `memory/jarvis.db`, `disabled_tools` and `mcps` (above, "Features and MCP servers"), `location_name` (`brain.location`, null when empty); the worker gets it as `JARVIS_CONFIG_PATH`. Loading it writes nothing to the home folder. ## Chat channel names and topics (`app/src/channel_sync.rs`) `docs/v2/conversation.md`, "채널 이름·주제 반영". A chat channel with `syncDiscord` (on by default) keeps its Discord name and topic in step with its `name` and `description`: - Registering a channel fills empty name and description with the channel's Discord name and topic (`discord_channel_info`); an answer that arrives after the ID was changed is dropped. - `settings_apply` with `chatChannels` first refuses a description over Discord's topic limit (1,024 characters) of a syncing channel, saving nothing. After saving, each syncing channel that is new, or whose name or description changed, is compared with Discord and edited where they differ (a new channel never clears a Discord name or topic with an empty field, also when its edit is retried later). Edits go one at a time, so a later save waits for an earlier one and Discord ends with the later. Discord's form of the name (spaces become `-`) is written back to the settings so the screen shows it, only while the settings still hold the name that was sent. The results come back in `sync` (`applied` with the name, `pending` with the wait, `failed` with the reason) and stay readable with `channel_sync_status`. - Discord allows about two name or topic edits per channel in ten minutes. A refused edit is `pending` and tried again by itself after the wait Discord names, with what the settings hold then; saving again while waiting adds no second retry. - Without the Manage Channels permission (or any other refusal) the edit is `failed` with the reason; the app keeps what the user wrote. - The two calls go to Discord's REST API directly with the stored token (serenity's client would wait out the rate limit itself, up to ten minutes). ## Admin commands (`app/src/admin_api.rs`) `AdminApi::call(command, args)` is the one entry point of the screens, JSON in and out; errors come back as Korean messages for the screen. The Tauri shell passes the screens' `invoke("admin", {command, args})` to it; the development server (below) does the same over loopback HTTP. | Command | Does | |---|---| | `app_status` | version, data folder, whether a token is stored, `wizardStep`; `firstRun` until the wizard's last step was reached (a stored token alone does not finish it) | | `wizard_step` `{step}` / `wizard_finish` | remember the wizard step reached / mark it done (needs a stored token); both in `config/setup.json` | | `folder_check` `{path}` / `folder_choose` `{path}` | free space against the recommendation / create the folder and remember it | | `pc_check` | OS, CPU threads, RAM, NVIDIA GPUs, the driver version and whether it is 580 or newer, free disk | | `token_check` `{token}` | the bot's tag and IDs, whether the Message Content intent is on, the invite link (REST only, nothing stored) | | `token_save` `{token}` / `token_status` | store it (masked from then on in logs) / `set` and the masked form, never the token | | `discord_guilds` / `discord_channels` `{guildId}` | the bot's servers / a server's voice and text channels, for the pickers | | `settings_fields` / `settings_view` / `settings_apply` `{changes}` | the settings editor above; `restartNeeded` when the services run and something other than `voice.tts.speed` changed (the speed reaches the running worker at once, `discord_core.spec.md`); `sync` with the chat channels sent to Discord (below) | | `service_start` / `service_stop` / `service_restart` / `dashboard` | the controller and its snapshot; start and restart run in the background, stop also cancels a start | | `discord_channel_info` `{id}` / `channel_sync_status` | a channel's Discord name and topic / each synced chat channel's last result (above) | | `notes_list` / `note_update` `{id, text}` / `note_delete` `{id}` | everyone's personal notes (above) / change one's text / delete one | | `history_query` `{said, answered, thought, via, person, channel, find, since, until, session, before, from, limit}` | the 대화 screen's records and answer traces (above, "Conversations") | | `history_stamp` | `{stamp}`: changes when what the 대화 screen shows may have changed (above, "Conversations") | | `activity_list` `{limit}` | what Jarvis did (above, "Activity"), newest first | | `schedules_list` / `schedule_delete` `{id}` | every person's schedules (above), soonest first, with IDs as strings / delete one | | `collect_results` `{target, limit}` | `{targets, items}`: every target folder with results, and the collected items newest first (`target` null: every target; `limit` 1-500, default 100) | | `mcp_env_status` / `mcp_env_set` `{server, name, value}` | which MCP environment values are stored (`{server: {NAME: bool}}`, never the values) / store one (an empty value removes it); only for a saved server and name | | `display_driver_status` / `display_driver_install` / `display_driver_uninstall` | the virtual monitor's driver: `{supported, installed, leftover, other, action}` (Windows only, above) / install or remove it elevated (above), then its status; refused unless the services are stopped or failed, and `service_start` / `service_restart` are refused meanwhile | | `install_status` / `install_start` / `install_cancel` | the install steps and their state, bytes and last line / run what is not done in the background / stop it | | `logs_query` `{tab, level, find, after, limit}` / `logs_error_report` / `logs_export` `{from, to}` | the log hub; the zip goes to `logs/` and its path comes back | | `logs_save_text` `{text}` / `history_export` `{from, to}` / `voice_export` `{from, to}` | the 로그 screen's saves (above, "Logs"): the lines shown / the days' conversation as text (`{path, items}`) / the days' voice recordings as a zip (`{path, files, bytes}`), each in `logs/` | | `update_status` / `update_check` / `update_download` / `update_install` | updates (below): `{current, phase, latest, error, done, total}` / look for a newer release / download it in the background / stop what runs, start the installer and answer `{exit: true}`, on which the window quits without asking | The invite link asks for: view channels, send messages, read history, add reactions, manage messages, manage channels, connect, speak, voice activity, and the slash command scope; never administrator. Stored secrets are masked in the log hub from the moment the app finds or chooses its data folder, and again after each one is saved. The log hub writes to the data folder's `logs/` as soon as a folder is chosen (`folder_choose` points it there; before that, memory only). ## Screens (`app/ui/`) Plain HTML, CSS and an ES module, no build step, dark theme after `DESIGN.md`. All text is Korean. The side menu has 대화 right under 대시보드 and 앱 last; there is no separate update screen (updates are on the 앱 screen) and no separate 한 일 screen (it is a view of the 로그 screen). - **First-run wizard** (while `firstRun`): data folder (free space, warning under 200 GB), PC check, the model to download, Discord bot (token check with the Message Content state and the invite link, then save), server and auto-join voice channel pickers, wake words, then start (which says the first start downloads the LLM). The model step shows the install (each step's state, download bytes and last line; start, cancel, retry) and goes on only once everything is installed. Each step reached is saved, so a reload or a restart resumes at that step; only the last step's start finishes it. A stored token lets the bot step go on without entering it again. - **Dashboard**: the snapshot every second; while the LLM starts, a card with its percentage and Strata's last line, and stop in the header; the header with start, restart and stop is rebuilt only when the state changes, so a click is never lost to the refresh. Every screen change starts a new generation: an answer that arrives after the user moved to another screen is dropped. - **Settings screens** (봇, 채널·호출, 채팅 채널, 대화 기억, 모델, 기능, 백그라운드 수집, 예약, PC 제어, 게임 모드, 앱): built from `settings_fields`; only changed fields are sent; the server and voice channel are pickers (choosing another server clears the voice channel and lists only that server's channels); the chat channels are a table with their switches; the bot screen also changes the token; the 기능 screen has the feature switches and one card per MCP server (name, command, arguments and environment variable names one per line, on/off, delete), and for a saved server a password box per environment variable that stores its value on its own; on Windows also a card for the virtual monitor's driver (its state and the button its `action` names, so a leftover can always be removed). The 백그라운드 수집 screen has the targets (a table: name, kind, address or words, interval in minutes, on/off, delete), the keep days, and the results (the newest 100, filtered by any target that has results, each with its time, title, link and the start of its text shown as plain text). The 예약 screen has `schedule.chatChannel` and every person's schedules (next time or "다시 울리지 않음", repeat, who and how they asked, kind and text as plain text, the last outcome, delete). The 앱 screen has the update card (below) first, then `app.closeButton` (완전 종료 or 트레이로 최소화) with a note that the tray icon opens the window again and its menu quits; saving it needs no restart. - **사람별 지침**: every person's notes (name and ID, the text in a box, save and delete). - **대화**: what people said, Jarvis's answers and how each answer was made, in time order with a date line between days; people's words on the left, Jarvis's on the right with whom it answered, each with its time, voice or chat and channel, and a copy button. A trace is a closed card (whose question, how many tool calls, seconds, no answer) that opens to the question, the records and notes it was given, the tools offered, the plan, the model's thinking, each tool call (name, arguments, success, failure or skipped and why, its result) and the answer. A trace sits at the time it was asked and is there while the answer is made (`pending`, "답을 만드는 중"): it fills in step by step, and one seen being made is open and stays open with its answer unless the user closes it. Filters: the three kinds as chips, "현재 세션" (off by default: only items since the bot was last started, `session`; the count line starts with that start's date and time, and with no start yet in this app run the list says so; a new start while it is on starts the list over from that start), where (음성, 채팅, 정기 작업), person, channel, one day and text; "실시간" (on by default) asks for `history_stamp` twice a second and re-reads the live window at once when it changed (so a trace shows from its question on, before a quick answer ends), and every 3 seconds anyway: every item from its first one on (`from`, up to 2,000). Only items in that window change on screen, an edited message included; items paged back past it stay as they were loaded (edits and deletes there show after a reload of the screen). The screen redraws only when an item changed, keeping the cards the user opened open and the scroll where it was unless it was at the end. When more new items arrive than the window holds, the shown items it no longer reaches join the pages kept as loaded, so nothing on screen disappears. "이전 기록 더 보기" adds the 200 items before the oldest loaded (`before`), one request at a time (the button is off meanwhile, and an item already loaded is never added again), with no end to how far back it goes; a filter change drops every answer to a request made before it, and a live answer older than the newest one asked is dropped; "생각 모두 펼치기/접기"; a count of each kind shown. The paging is `app/ui/talk.js`, pure, checked by `node --test app/tests/ui/talk.test.mjs`. - **업데이트** (a card on the 앱 screen, re-read every second while it is shown): the version here, the state, "다시 확인", "받기" (with its percentage) and "설치하고 다시 시작", and the release's notes as plain text. The app checks once when the main screens open; a newer release renames the 앱 button "앱 (새 버전)" and says so once. - **Logs** (로그): four views switched at the top, 로그, 대화, 목소리 and 한 일. 한 일 is the activity (time, kind, target, who asked, outcome and why it failed), newest 200, read when the view opens, with a refresh button; there is no separate 한 일 screen. 로그 has tab, level and text filters, pause, live follow (lines after the last seen), "최근 오류 복사" (to the clipboard; over 2,000 characters it suggests the zip), "보이는 글 txt로 저장" (`logs_save_text` with the lines shown), and the zip export by days. 대화 saves the 대화 screen's content of a range of days (today by default) as text (`history_export`). 목소리 has the `voice.record` switch (saved at once; it says the bot's next start applies it, and that other people's voices in the channel are kept too, for 7 days) and saves a range of days' recordings as a zip (`voice_export`; over 10 MB it says Discord's file limit is passed). `jarvis-admin-dev [--port N] [--ui DIR] [--location FILE]` (development only) serves `app/ui` and the commands on 127.0.0.1; every command needs the random token it prints (`#token=` in the page URL), so other local programs cannot drive it. ## Updates (`app/src/update.rs`) The app updates itself from the project's Gitea releases (`https://git.tkrmagid.kr/api/v1/repos/tkrmagid/javis_bot/releases`; `JARVIS_UPDATE_SOURCE` points a test at another server). A release of this app is tagged `app-v<version>` and carries the two files `installer.sh` writes, `Jarvis-Setup-<version>.exe` and its `.sha256`; publishing one is uploading both to a release with that tag. The repository's other releases (v1's `v1.x`) are skipped. - **Check**: the release list (50 newest); drafts, prereleases, other tags, releases without both files, and files on another server than the list are skipped; the newest version above the app's own (dotted numbers, "0.2" equals "0.2.0") is offered. HTTPS only (plain HTTP only to 127.0.0.1 or localhost). A failure keeps its reason for the screen and the `app` log tab. - **Download**: the `.sha256` first (64 hex digits, for that file name), then the installer into the data folder's `cache/updates` through the install's resumable, checked download; a mismatch deletes it and fails. Once it is there, earlier installers in that folder are removed. Checking again keeps a downloaded release ready. - **Install**: the file is hashed again, then what runs is stopped as when the window closes (a failure stops here), then the installer starts with `/S /RUN` as administrator (Windows asks) without waiting, and the app quits. The installer waits for it to close, replaces it and starts it again (above, "Installer"). Declining the administrator question keeps the app open with the services stopped and says so. - The app's version is the one in `app/Cargo.toml` and `app/shell/Cargo.toml` (kept equal; the program file's version comes from the latter, `tauri.conf.json` sets none). ## Window and Windows build (`app/shell/`) - `jarvis.exe` (crate `jarvis-shell`, Tauri 2 on the WebView2 Windows already has) opens one window with the screens (`app/ui`) and passes `invoke("admin", {command, args})` to `AdminApi::call`. `--location FILE` replaces the default location file (`%APPDATA%\JarvisBot\location.json`). The window's own browser data (WebView2) goes in the data folder (`cache/webview`); before the first-run wizard chose one it is a scratch folder in the system temp folder (`JarvisBot-webview-<process id>`), which WebView2 holds until the process ends, so the next start removes it. Nothing goes under `%LOCALAPPDATA%`, and `%APPDATA%\JarvisBot` holds only the location file. - Closing the window first runs `AdminApi::shutdown` and closes only when it succeeds: an install in progress is cancelled and waited for (its commands and their children end), the services stop (a start in progress is cancelled and waited for, up to 150 s), and after a failed run what may be left is cleared (`Controller::shutdown`: the LLM's server stopped and confirmed gone). While that runs the window says so; if it fails the window stays open with the reason, and closing it again quits anyway. Quitting another way (the system shutting down) runs the same shutdown. - The close button (X) quits as above, or, when `app.closeButton` is `"tray"` (`"quit"` by default, read each time it is pressed; no data folder or settings that do not parse: quit), only hides the window: the bot and services keep running. A tray icon (`icons/tray.png`, tooltip "Jarvis") is always there: a left click shows the window again, its menu has 열기 and 완전 종료 (the quit above, with the window shown while it runs). - One Jarvis at a time (`tauri-plugin-single-instance`): starting it again while it runs shows the running one's window (hidden or minimised) and the new start exits. - The icon (`icons/icon.ico` for the program file, window, taskbar and installer, 16-256 px; `icons/icon.png` 512 px): voice bars in a ring on the accent colour's gradient; at 32 px and below only three thicker bars, so it stays readable in the taskbar and tray. - `app/shell/package.sh <folder>` builds it on Linux (`x86_64-pc-windows-gnu`, mingw-w64) and lays out `Jarvis/`: `jarvis.exe`, `WebView2Loader.dll`, `python-src/` (the `voice_worker` and `jarvis` packages, no caches or specs) and `display-driver/` (the virtual monitor's driver). The worker's sources are `python-src` next to the executable when it is there, also over a `voiceWorker.cwd` the settings keep (another install's first-run setup may have written its own folder there, and an update must never run those older sources); without shipped sources `voiceWorker.cwd`, else the repository's `src/`. The install reads its requirement files from the same place. The folder also runs as it is. ## Installer (`app/shell/installer.nsi`, `app/shell/installer.sh`) `docs/v2/architecture.md` ("설치 파일: NSIS"). `installer.sh <folder>` runs `package.sh` and makensis 3 (on Linux; `NSISDIR` when it is not installed system-wide) and writes `Jarvis-Setup-<version>.exe` with its `.sha256`. The installer is about 10 MB; models and runtimes come with the first-run wizard into the data folder, which the installer never touches. - Program Files (`Jarvis`), or where Jarvis is already installed (`HKLM\Software\JarvisBot` `InstallDir`, 64-bit view; a folder given with `/D` wins), one administrator prompt, 64-bit Windows 10/11 only; Korean pages: folder, components, progress, finish ("Jarvis 실행", started through Explorer so the app runs as the signed-in user, not as administrator). - Components: Jarvis (always), start menu shortcut (on), desktop shortcut (off), the virtual monitor's driver (on, so it comes with the app; the app's elevated half, `jarvis.exe --display-driver install`, so Windows asks the SignPath question once; a failure says it can be installed later from the features screen, with the reason the app wrote (UTF-8), and the app is installed all the same; never in a silent install, so an update neither asks nor brings back a driver the person removed). Shortcuts are for every user of the PC. Their icon is a file next to `jarvis.exe` named by its content (`jarvis-<sha256 prefix>.ico`; the old one is deleted), because Windows keeps an icon it has shown by its path and a changed icon under the old path stays old on the desktop and in search. After the shortcuts, every `.lnk` to `jarvis.exe` on the desktops and in the start menus and their folders (the installing user's and every user's, the person's own and an earlier version's included) gets this icon file (the paths reach PowerShell through the environment, so any folder name works; a failure is a line in the details), and Explorer is told to redraw (`SHCNE_ASSOCCHANGED`). A shortcut to the `jarvis.exe` of another folder that holds a Jarvis install (`uninstall.exe` and `python-src` next to it: a copy left behind when an update before 0.1.12 installed into Program Files instead of the chosen folder) is pointed at this install's `jarvis.exe` (and its working folder at this folder), so it starts the Jarvis that is kept up to date, and a start while it runs shows the running window instead of a second, old Jarvis. The old copy itself is not touched. - The WebView2 runtime is installed with Microsoft's bootstrapper (inside the installer) only when the PC has none, before any file is copied. When it is still missing afterwards the installer asks to retry or cancel; silently it stops with exit code 3, nothing installed and nothing started. - While it installs, updates or removes, the installer holds the named mutex `Global\JarvisBotSetup` (`setup_lock.rs`) from its start until every change is done (a last hidden section closes it, before `/RUN` and the finish page start the app); `jarvis.exe` started meanwhile says so in a message box and exits (code 3) before any window or service. Another installer or uninstaller finding the lock taken (or unable to make it) stops at once with a message, silently with exit code 5, so two never run together. Before copying or removing, the installer also waits for `jarvis.exe` to close: it asks with a retry, or silently waits up to 60 s (an update closes the app itself), then gives up. - `/S` installs silently with the default components but the driver; `/S /RUN` starts the app again afterwards (the app's updates). The uninstall entry has the version, size and a quiet uninstall string. - Uninstall: the driver goes first when this app installed it (`--display-driver uninstall`: 0 removed, 2 nothing of ours to remove; the elevated half refuses another program's copy). Any other result stops the uninstall with everything kept, so it can be run again (silently exit code 4). Then only what the installer put there goes: `installer.sh` lists every file of `python-src/` and `display-driver/` for the uninstaller (`uninstall-list.nsh`) and folders are removed only when empty, so a folder the person chose keeps its other things. Then the shortcuts and the registry keys. The data folder stays. ## Tests `cargo test`: data folder layout, location file and the environment override, a refused relative path, free space; settings view with defaults, apply writing only non-defaults, removing a key set back to its default, keeping unknown keys, refusing a bad value or a result `parse_settings` refuses without touching the file; secrets round trip, file permissions on Unix, masking; log tabs from categories, query filters and follow, files per day and retention, error report bounds, zip size cap, redaction of stored secrets and token-shaped text; the controller's state rules with a fake service starter, a stop while starting (cancelled, or finished and stopped again); the LLM (launch arguments from the settings and inside the data folder, the second request slot for a chat channel answering everything, the download percentage, the brain's settings file, a given server used without Strata, Strata missing, a fake Strata that reports progress, returns, serves and is stopped, is cancelled during its download and cleared, or fails with its last line, a stop that fails or hangs while the server still answers, holds connections silently or answers 503 (failed, not off, also through the controller) and one that fails while the port refuses connections (off); a stop right after a background start running no launch at all, and the next start not cancelled; closing the app (the controller's shutdown after a failed stop: clean-up failing keeps it failed, succeeding stops it; an install in progress cancelled and waited for); command output that is not UTF-8 read on to the end; the window data folder (data folder, or a scratch folder removed later); updates (the newest release of this app picked past v1's, prerelease, incomplete and other-server releases; the checksum file read for its own file only; a fake Gitea on 127.0.0.1 found, downloaded, checked and handed over with earlier installers removed, a ready download kept by a new check, a file changed after the download refused, a wrong checksum never offered, an unreachable or plain HTTP server failing with a reason; the install command refused before a download, keeping the app when the administrator question is declined, and starting the installer after stopping what runs; one version in both Cargo.toml files and none in tauri.conf.json); the TTS speed reaching the worker's arguments; features and MCP servers (read and refused with the key, the feature tools named as the brain names them, only enabled servers in the brain's settings without values, stored values passed for enabled servers only, values of removed servers and names deleted, a value refused for an unsaved server, kept out of the settings file and masked in logs, also by a new app on the same folder, and a value replaced or removed later still masked in lines written before and in lines the running services print afterwards, until the next start); chat channel names and topics (only new or edited syncing channels sent, the topic limit refused before saving, Discord's form of the name written back, a missing permission failing with the reason and the text kept, a rate-limited edit pending and retried once with the latest text, a new channel never clearing Discord (also on its retry), a slow first save never overwriting a later one, unchanged ones not edited; through `settings_apply` too); a background start that is starting at once, so a stop right after it cancels it and a second start is refused, also through the admin commands; a failed stop reported as failed; the brain's config loaded without writing to the home folder, `tests/test_config_db_path.py`); the dashboard from made-up events (captions replaced and cleared, latency stages and medians, an answer matched to its asker's final, missed requests without text); the admin commands (first run: folder then token, the token never returned whole, the wizard resumed at its step until finished, log files and the zip from the folder choice on, settings and logs through their modules, the dashboard before anything runs), the invite link's permissions and the Message Content flags. The screens are checked in a browser against the development server with the real services (wizard, dashboard start, restart and stop, settings save, chat channels, logs, export). On Windows (the win-ci VM, `x86_64-pc-windows-gnu` build): the unit tests (DPAPI, data folder, downloads, install steps, logs; the Unix-only process tests excepted), and the window by hand: the wizard's folder, PC check and install (`uv` and the worker venv installed, a cancel leaving no `uv` or Python process), the token stored DPAPI-encrypted, a start failing with its reason, the log screen, error copy, zip export, and closing the window ending the process with nothing written to `%APPDATA%` or `%LOCALAPPDATA%`. The virtual monitor (`tests/vdisplay_elevated.rs`, no harness: started elevated, the same program is the elevated half; `tests/bot_browser.rs` with a screen): the driver installed through the elevated start (Windows' SignPath question answered once) with the settings folder's permissions, a declined install leaving no device, package, registry key or settings folder and the next install giving one working device, the monitor off after install, on at the rightmost monitor's corner while the bot browser runs and off after, one Chrome window there filling the work area, then the bot's own window (opened as the tool opens it, loading a public page) in front of it, the focus staying in the program the user types into also with the user idle past Windows' focus lock, no taskbar or Alt+Tab entry for either, no Chrome left after the stop, and the uninstall leaving no device, driver package, registry key or settings folder. Game detection (`tests/game_watch.rs`): a program started from a Steam game folder (also under a path with non-ASCII letters) or from a Battle.net game's install folder (a test uninstall entry) turns game mode on with its name and off once it ends. Screen viewing (`tests/screen_windows.rs`, `JARVIS_TEST_SCREEN=1`): the monitors and Notepad's window are listed, the window, each monitor and the whole screen come back as JPEG pictures of their size, and with Notepad excluded it is neither picked nor listed and its area is black on the whole screen; someone not registered is refused. On every system with a fake screen: refusals before any capture, monitors by number, the whole screen as placed with excluded areas black (also at another display scale), an excluded window that moves or is brought back during the capture never shown (taken again, or refused while it keeps moving), a window of a program that cannot be told treated as excluded, windows by title or program front first (never excluded, secondary or the app's own), minimised and black pictures refused, the detail sizes and parts; the worker protocol test carries a 4K capture's pictures to a fake brain and back. Performance stages (on every system, with a fake Strata and card): a game moves the LLM to the game placement (measured once at 16K and one request, 2 GiB on the game PC's numbers, half the 16 engine threads) and back after the wait, pause stops it, a card with no room for a game pauses, the normal stage counts a program opened since, the game stage does not count the game twice and counts what grew since the normal reading, a game running as the services start does not pause the LLM, the way back to normal from a failed game stage while the game runs keeps the reading from before the game, a game program behind other windows is found at the start (win-ci VM: a minimised program in a Steam game folder), a fallback game placement still shows as the game stage, and the stage loop tells the brain switching (with the notice), waits, restarts and tells it ready, also on the way back; a game stage that cannot start goes back to normal each time and is tried three times; after that a new game tries again, and the next try waits from when the failed switch was over. The worker client ignores a late idle of an earlier switch and sends the latest LLM state first when a worker connects again. On every system: game detection's rules (a borderless game, a maximised program, a browser's full-screen video, exclusive full screen, launcher folders and their own windows, Battle.net games by install folder and their uninstall entries, non-ASCII paths, the person's lists first, staying on until the game ends, detection off) and its settings. A removal forgets the driver only when no device is left and the package is gone or was not in the store; a failed install forgets it only under the same rule (and never when it was ours before), reporting both reasons otherwise; a leftover offers removal; driver tasks refused while the services start, and a start (and a second task) refused while one runs, also after it failed; removing a driver that is not ours says there is nothing to remove. The installer (by hand on a Windows VM): with the default components the driver is installed (Windows' question answered yes), and answered no the app is installed all the same and the message gives the reason in readable Korean; installing into a folder that holds other files and uninstalling keeps them; a driver removal that fails stops the uninstall with the files and entry kept, and nothing to remove lets it finish; with no WebView2 and its installer failing nothing is installed or started; an update end to end (0.1.0 installed, a release server on 127.0.0.1 offering `app-v0.2.0`: the screen finds it at the start, downloads it, and "설치하고 다시 시작" leaves 0.2.0 installed and running); with the lock held the app shows its message and exits after OK, and starts normally once released; `/S /RUN` (fresh, and over a running app that closes) and the finish page's "Jarvis 실행" start the app's window; a silent install while the uninstaller's window is open, and a silent uninstall while the installer's is, stop with code 5 and change nothing. On Linux the same window test runs on an X display (one window at the given place and size, the bot's own window at the same place).