diff --git a/.github/workflows/agent-app-cross-platform.yml b/.github/workflows/agent-app-cross-platform.yml
index a4de1b4c..652b12d7 100644
--- a/.github/workflows/agent-app-cross-platform.yml
+++ b/.github/workflows/agent-app-cross-platform.yml
@@ -53,11 +53,9 @@ jobs:
- name: Linux build tools
if: matrix.os == 'linux'
working-directory: .
- # The runner's apt mirror list (Azure, then *.ubuntu.com) can stop resolving while other hosts work: try the
- # kernel.org Ubuntu mirror first, keep Ubuntu's own archive as the fallback, and retry.
- run: |
- printf 'http://mirrors.edge.kernel.org/ubuntu/\tpriority:1\nhttp://archive.ubuntu.com/ubuntu/\tpriority:2\n' | sudo tee /etc/apt/apt-mirrors.txt >/dev/null
- sudo apt-get -o Acquire::Retries=5 update && sudo apt-get -o Acquire::Retries=5 install -y --no-install-recommends build-essential python3 xvfb libgtk-3-0 libnss3 libxss1 libgbm1 libasound2t64 rpm fakeroot desktop-file-utils xdg-utils
+ # The runner's apt mirror can stop resolving, miss a package or stall: the script tries the kernel.org, Azure and
+ # Ubuntu mirrors in turn, twice, with a time limit per attempt (#876).
+ run: bash packages/agent-app/scripts/ci-apt-install.sh build-essential python3 xvfb libgtk-3-0 libnss3 libxss1 libgbm1 libasound2t64 rpm fakeroot desktop-file-utils xdg-utils
- id: electron
# Download caches only (never node_modules): keyed on OS, CPU and the locked Electron version.
@@ -227,10 +225,8 @@ jobs:
path: packages/agent-app/release-dist
- name: Install the deb with apt
run: |
- # *.ubuntu.com can stop resolving on the runners while other hosts work: use the kernel.org Ubuntu mirror.
- sed -i -E 's#http://(archive|security)\.ubuntu\.com/ubuntu/?#http://mirrors.edge.kernel.org/ubuntu/#' /etc/apt/sources.list.d/ubuntu.sources /etc/apt/sources.list 2>/dev/null || true
- apt-get -o Acquire::Retries=5 update
- DEBIAN_FRONTEND=noninteractive apt-get -o Acquire::Retries=5 install -y --no-install-recommends xvfb xauth desktop-file-utils ./release-dist/Muster-Agent-*-linux-amd64.deb
+ # A mirror can stop resolving, miss a package or stall inside the container too: the script moves to another (#876).
+ bash scripts/ci-apt-install.sh xvfb xauth desktop-file-utils ./release-dist/Muster-Agent-*-linux-amd64.deb
! dpkg -s libfuse2t64 >/dev/null 2>&1 && ! dpkg -s libfuse2 >/dev/null 2>&1 && echo "libfuse2 is not installed"
bash scripts/test-linux-install.sh
- name: Launch the installed app (as a regular user)
diff --git a/docs/spec/clauses/03-providers-models-and-accounts.md b/docs/spec/clauses/03-providers-models-and-accounts.md
index 8d50e9b1..434ed219 100644
--- a/docs/spec/clauses/03-providers-models-and-accounts.md
+++ b/docs/spec/clauses/03-providers-models-and-accounts.md
@@ -52,6 +52,8 @@ Boundaries:
| [MUS-SPEC-03-688N](03-providers-models-and-accounts.md#mus-spec-03-688n) | The saved conversation starts with a user message that holds the person's own text, stays within its limits and holds no image data. | [`saved Claude history never starts with an assistant message`](../../../packages/agent-app/tests/claude-messages-driver.test.ts) |
| [MUS-SPEC-03-688O](03-providers-models-and-accounts.md#mus-spec-03-688o) | An error event before any content is retried once and the turn completes; an error after text has streamed fails the turn without resending; every request asks for high effort. | [`an error event before any content is sent once more; after content it fails the turn`](../../../packages/agent-app/tests/claude-messages-driver.test.ts) |
| [MUS-SPEC-03-688P](03-providers-models-and-accounts.md#mus-spec-03-688p) | The turn runs over the Messages API with a native ask_user tool offered; the call returns the default at once, a non-blocking question card is posted, and the turn completes on the Messages lane. | [`a Full access Claude turn still runs over the Messages API when the service adds the ask_user server, and ask_user returns the default`](../../../packages/agent-app/tests/claude-messages-lane.test.ts) |
+| [MUS-SPEC-03-866A](03-providers-models-and-accounts.md#mus-spec-03-866a) | With the device tool server added, the turn still runs over the Messages API (the Codex client never runs), completes on the Messages lane, and the request carries no device tool and no device note. | [`a Full access Claude turn with device tools on still runs over the Messages API, without the device server or its note`](../../../packages/agent-app/tests/claude-messages-lane.test.ts) |
+| [MUS-SPEC-03-866B](03-providers-models-and-accounts.md#mus-spec-03-866b) | With the device tool server added, the turn through Claude Code loads `muster_device` in its MCP config next to the user's server. | [`with device tools on, a router Claude turn through Claude Code keeps the device server`](../../../packages/agent-app/tests/router-claude-code-730.test.ts) |
| [MUS-SPEC-03-716A](03-providers-models-and-accounts.md#mus-spec-03-716a) | When the copy of the thread is refused too, one fresh thread starts with a summary of the earlier messages; the chat ends completed on it, with one notice for the copy and one for the summary. | [`when the copy is refused too, one fresh conversation starts with a summary`](../../../packages/agent-app/tests/replay-expired-716.test.ts) |
| [MUS-SPEC-03-716B](03-providers-models-and-accounts.md#mus-spec-03-716b) | If the copy and the fresh conversation are both refused there is no fourth attempt and the error is shown through the usual recovery notice. | [`when the copy and the fresh conversation are refused with the same 409 there is no fourth attempt and the error is shown`](../../../packages/agent-app/tests/replay-expired-716.test.ts) |
| [MUS-SPEC-03-767A](03-providers-models-and-accounts.md#mus-spec-03-767a) | Through the real coding client, a router that refuses the thread's session gets the turn from a new session whose request carries every earlier user message and reply as history, with no digest; one notice says the chat continues in a copy; later turns keep working. | [`a router that refuses a thread's session continues the turn with the whole earlier conversation`](../../../packages/agent-app/tests/router-refused-session-767.test.ts) |
@@ -457,6 +459,28 @@ Boundaries:
- Known gaps: The `muster_ask` MCP server itself is dropped on this lane (it has no MCP client); the native tool takes its place.
- Evidence: UNVERIFIED
+
+#### MUS-SPEC-03-866A: Device tools do not move a Claude turn off the Messages API
+
+- Precondition: A Full access Agent chat on a router gateway route, model `cc/claude-opus-5-5`, Claude Code not installed. "Let agents use devices" is on, so the service adds the `muster_device` server and the device note to the turn, next to its usual per-chat servers.
+- Action: Send a message.
+- Expected result: The turn runs over the Messages API and the Codex client never starts. The request offers no device tool and its system text has no device note. The turn completes on the Messages lane.
+- Test: `packages/agent-app/tests/claude-messages-lane.test.ts::a Full access Claude turn with device tools on still runs over the Messages API, without the device server or its note`
+- Environment: Node test runner; the real service, computer domain and provider adapter with a fake router over fetch and a fake Codex client; no network. Every tool launcher the service reads from the environment is set or cleared by the test, so a launcher in the caller's environment (as inside Muster) does not change the result.
+- Known gaps: The Messages lane has no device tools, so the agent cannot drive a device on this route; the device server itself is not started.
+- Evidence: UNVERIFIED
+
+
+#### MUS-SPEC-03-866B: Claude Code on a router keeps the device tools
+
+- Precondition: A Workspace Agent chat on a router gateway route, model `cc/claude-opus-5-5`, with Claude Code installed (a fake `claude` executable). "Let agents use devices" is on and the chat has a user tool server.
+- Action: Send a message.
+- Expected result: The turn runs through Claude Code, and the MCP config Claude Code starts with lists `muster_device` as well as the user's server.
+- Test: `packages/agent-app/tests/router-claude-code-730.test.ts::with device tools on, a router Claude turn through Claude Code keeps the device server`
+- Environment: Node test runner; the real service, provider adapter and Claude Code adapter with a fake `claude` executable, a fake router and a fake Codex client; no network.
+- Known gaps: A guard for the route that keeps the device server: it also passes before the #866 change, which only touches the Messages lane.
+- Evidence: UNVERIFIED
+
#### MUS-SPEC-03-767A: A refused router thread continues with the whole conversation
@@ -826,7 +850,7 @@ Any agent that speaks the Agent Client Protocol (JSON-RPC over stdio) can be add
- Action: In Auto, send an edit of a file inside the folder, then "RUN npm install left-pad" and decline its card. In Full access, send "RUN npm install left-pad".
- Expected result: In Auto the edit is approved without a card and its row records the Auto rule (inside the chat's folder); the install still shows a command card with its command. In Full access the command runs with no card.
- Test: `packages/agent-app/tests/acp-route-160.test.ts::ACP in Auto: an edit inside the folder settles itself, an install still asks; Full access never asks`
-- Environment: As 160B.
+- Environment: As 160B. The fake agent ends each prompt 150 ms after its last words, and each follow-up is sent only once the previous turn has settled (#877).
- Known gaps: Auto's rules themselves are clause 05 (#841); this checks that ACP requests reach them.
- Evidence: UNVERIFIED
@@ -837,7 +861,7 @@ Any agent that speaks the Agent Client Protocol (JSON-RPC over stdio) can be add
- Action: Ask the agent to write a file outside the folder and inside it, and to read a line range; in Read only, to write and to edit; in Full access, to write outside the folder.
- Expected result: Workspace refuses the outside write (the agent gets an error naming the working folder and no file appears), writes the inside file, and returns line 2 of a file for `line: 2, limit: 1`. Read only refuses the write (error says read-only), rejects the edit's permission request without a card, leaves the file unchanged and switches the agent to its plan mode. Full access writes outside the folder.
- Test: `packages/agent-app/tests/acp-route-160.test.ts::ACP file access follows the access level: Workspace writes stay in the folder, Read only writes nothing and refuses edits`
-- Environment: As 160B.
+- Environment: As 160B. The fake agent ends each prompt 150 ms after its last words, and each follow-up is sent only once the previous turn has settled (#877).
- Known gaps: Links inside the folder are refused by the same check as the HTTP tools (MUS-SPEC-03-384E) and are not exercised again here.
- Evidence: UNVERIFIED
diff --git a/docs/spec/clauses/20-performance.md b/docs/spec/clauses/20-performance.md
index af63f6ac..66df4e10 100644
--- a/docs/spec/clauses/20-performance.md
+++ b/docs/spec/clauses/20-performance.md
@@ -19,6 +19,7 @@ Boundaries:
| [MUS-SPEC-20-553B](20-performance.md#mus-spec-20-553b) | After 20 streamed reply tokens, links in the transcript have re-rendered at most 2 times. | [`streaming 20 tokens does not re-render resource links`](../../../packages/agent-app/tests/chat-render-bounds-dom.tsx) |
| [MUS-SPEC-20-553C](20-performance.md#mus-spec-20-553c) | After 20 streamed reply tokens, the Changes view has re-rendered at most 2 times. | [`streaming 20 tokens does not re-render the changes view`](../../../packages/agent-app/tests/chat-render-bounds-dom.tsx) |
| [MUS-SPEC-20-813A](20-performance.md#mus-spec-20-813a) | A panel that opens while the window is inactive ends its fade-in at full opacity, and no animation keeps ticking while inactive; a focused window still fades in and spins. | [`a panel that opens while the window is inactive is visible, and nothing keeps animating`](../../../packages/agent-app/tests/idle-animations-813.test.ts) |
+| [MUS-SPEC-20-770A](20-performance.md#mus-spec-20-770a) | The first pass over 2,000 rows parses each timestamp once; 100 more passes over the same rows parse none, and the dividers stay the same. | [`cheap enough to run on every streamed update of a long chat`](../../../packages/agent-app/tests/day-dividers.test.ts) |
### Startup size
@@ -78,3 +79,16 @@ Boundaries:
- Environment: Headless Chrome over CDP with the real styles.css, app-shell.css and message-body.css; skipped when Chrome is not installed.
- Known gaps: windowActivity.ts, which sets the attribute, is not driven here; the test sets it directly.
- Evidence: UNVERIFIED
+
+### Day dividers on a long chat (#770)
+
+
+#### MUS-SPEC-20-770A: Day dividers do not re-parse timestamps on each streamed update
+
+- Precondition: A chat with 2,000 rows, alternating user and assistant messages one minute apart.
+- Action: Work out the day dividers once, then 100 more times over the same rows, as the chat does on every streamed update.
+- Expected result: The first pass parses each row's timestamp exactly once. The 100 later passes parse no timestamp at all and return the same dividers. As a backstop for a gross slowdown, the later passes average under 5 ms each.
+- Test: `packages/agent-app/tests/day-dividers.test.ts::cheap enough to run on every streamed update of a long chat`
+- Environment: Node test runner; the real `dividerRows` with `Date.parse` counted for the duration of the test. The main check counts work, so a busy CI runner does not change it; the time ceiling is ten times the cost seen on a loaded runner.
+- Known gaps: Only timestamp parsing is counted. Other per-row work (the day boundary of each user message) is bounded only by the time ceiling.
+- Evidence: UNVERIFIED
diff --git a/docs/spec/clauses/22-engineering-standards.md b/docs/spec/clauses/22-engineering-standards.md
index 5f37bd4b..2c6186f9 100644
--- a/docs/spec/clauses/22-engineering-standards.md
+++ b/docs/spec/clauses/22-engineering-standards.md
@@ -33,6 +33,8 @@ Boundaries:
| [MUS-SPEC-22-482A](22-engineering-standards.md#mus-spec-22-482a) | With no dist folder, the Hindsight service test file loads and the tests that use a fake core pass; only the tests that drive the real bundle are skipped. | [`unconfigured status is truthful and never includes a key`](../../../packages/agent-app/tests/hindsight-service.test.ts) |
| [MUS-SPEC-22-5A](22-engineering-standards.md#mus-spec-22-5a) | Every `tests/*.tsx` file in the repository is either a suite run by `npm run test:renderer` or excluded with a stated reason, and every listed name has a file. | [`every tests/*.tsx file is a renderer suite or is excluded with a reason`](../../../packages/agent-app/tests/renderer-suites.test.ts) |
| [MUS-SPEC-22-5B](22-engineering-standards.md#mus-spec-22-5b) | The guard names a stray DOM suite, a stale list entry, a name in both lists and a duplicate. | [`the guard names a stray suite, a stale entry, a name in both lists and a duplicate`](../../../packages/agent-app/tests/renderer-suites.test.ts) |
+| [MUS-SPEC-22-876A](22-engineering-standards.md#mus-spec-22-876a) | With the first mirror refusing the package list and the second missing a package, the script installs from the third mirror, rewriting the sources each time; when every mirror fails it exits non-zero after trying each one. | [`the apt install moves to the next mirror when one cannot find a package, and fails only after every mirror`](../../../packages/agent-app/tests/ci-apt-install.test.ts) |
+| [MUS-SPEC-22-876B](22-engineering-standards.md#mus-spec-22-876b) | The Linux build job and the Ubuntu 24.04 container job both call the script for their apt packages and no longer run apt-get install themselves. | [`both Linux jobs install their apt packages through the retrying script`](../../../packages/agent-app/tests/ci-apt-install.test.ts) |
### Case format
@@ -243,3 +245,27 @@ Boundaries:
- Environment: Node test runner; pure function over made-up lists.
- Known gaps: None known.
- Evidence: UNVERIFIED
+
+### Linux CI survives an apt mirror outage (#876)
+
+
+#### MUS-SPEC-22-876A: The apt step falls back to another mirror
+
+- Precondition: A Ubuntu apt setup (a deb822 `ubuntu.sources` and a classic `sources.list`). The first mirror fails `apt-get update`; on the second, update works but the install cannot find a package; the third works.
+- Action: Run `scripts/ci-apt-install.sh` with the packages to install.
+- Expected result: The script points the sources at each mirror in turn, refreshes the package lists and installs from the first mirror that works (the third here). When every mirror fails, it exits non-zero after trying each one, so the job fails with apt's own error.
+- Test: `packages/agent-app/tests/ci-apt-install.test.ts::the apt install moves to the next mirror when one cannot find a package, and fails only after every mirror`
+- Environment: Node test runner; the real script under bash with a stand-in `apt-get` on PATH and the apt folders in a temp directory; no network and no root.
+- Known gaps: Real mirrors are not contacted; a mirror that stalls is covered by apt's own per-request timeout and the script's time limit per attempt, which the test does not exercise.
+- Evidence: UNVERIFIED
+
+
+#### MUS-SPEC-22-876B: Both Linux jobs use the retrying apt step
+
+- Precondition: The cross-platform workflow, with the Linux build job on the runner and the Ubuntu 24.04 job inside a container.
+- Action: Read the apt steps of both jobs.
+- Expected result: Each job installs its apt packages through `scripts/ci-apt-install.sh` and does not call `apt-get install` directly.
+- Test: `packages/agent-app/tests/ci-apt-install.test.ts::both Linux jobs install their apt packages through the retrying script`
+- Environment: Node test runner; reads the real workflow file.
+- Known gaps: Checks the wiring, not a real CI run; the PR's own CI run is the end-to-end proof.
+- Evidence: UNVERIFIED
diff --git a/packages/agent-app/CHANGELOG.md b/packages/agent-app/CHANGELOG.md
index a6b0f7f3..cfd395fa 100644
--- a/packages/agent-app/CHANGELOG.md
+++ b/packages/agent-app/CHANGELOG.md
@@ -26,6 +26,7 @@ All notable changes to Muster Agent. Each `## ` section becomes the not
- A suggested follow-up after a turn, as ghost text in the empty message field: Tab or click puts it there, Cmd/Ctrl-click sends it. Off by default (Settings › Chat › Suggest a follow-up) since it is one small extra request per turn: Claude Code chats use Claude Code's own suggestion, API and gateway chats ask the same model once; Codex chats offer none. The transcript also marks where the model or effort changed between turns: "Switched to GPT-5.5 · high effort" (#401).
- Commits in the History graph have a menu (right-click, or Shift+F10 on a row): copy the SHA or message, check the commit out (detached), create a branch there, cherry-pick it onto the current branch or revert it. A picker shows another branch’s commits to pick from. Each change confirms first, saying what will happen; it is refused while tracked files have uncommitted changes, warns when a chat is running in the folder, and a conflicting pick or revert opens the conflict view. History and Changes refresh afterwards (#409).
- Automations can run once at a set date and time: pick **Once at a date and time** under Repeat. The time is in the automation's time zone and is shown with it. After it runs the automation stays in the list as Done with its run linked; a time that has already passed is refused when you save. If Muster was closed or asleep at that time, it runs once at the next start and its history says it ran late (or records it as missed when catch-up is off). Before it runs you can move it to another chat with Edit (#845).
+- **Device tools no longer push router Claude chats back to the Codex client.** With "Let agents use devices" on, a Full access Claude chat on a router runs over the router's Messages API again (without the device tools, which that route has no client for); through Claude Code it keeps them. Also steadier CI: the Linux jobs move to another apt mirror when one fails, and two timing-sensitive tests no longer flake.
## 0.3.18
diff --git a/packages/agent-app/scripts/ci-apt-install.sh b/packages/agent-app/scripts/ci-apt-install.sh
new file mode 100755
index 00000000..f28aa40d
--- /dev/null
+++ b/packages/agent-app/scripts/ci-apt-install.sh
@@ -0,0 +1,44 @@
+#!/usr/bin/env bash
+# #876: install apt packages on a CI Ubuntu machine or container, moving to another mirror when one fails.
+# A runner's mirror can stop resolving, serve a package list without a package ("Unable to locate package xvfb") or stall.
+# Each attempt points the Ubuntu sources at one mirror, refreshes the lists and installs, with a time limit; a failed
+# attempt moves to the next mirror, and the whole list is tried twice. The step fails, with apt's error, only if all do.
+#
+# Usage: ci-apt-install.sh ...
+# Environment (for tests): APT_ETC (default /etc/apt), APT_MIRRORS (space separated), APT_RETRY_PAUSE (seconds),
+# APT_SUDO=none (never use sudo).
+set -o pipefail
+[ $# -gt 0 ] || { echo "usage: $0 ..." >&2; exit 2; }
+etc="${APT_ETC:-/etc/apt}"
+mirrors="${APT_MIRRORS:-http://mirrors.edge.kernel.org/ubuntu/ http://azure.archive.ubuntu.com/ubuntu/ http://archive.ubuntu.com/ubuntu/}"
+pause="${APT_RETRY_PAUSE:-10}"
+as_root=()
+[ "$(id -u)" = 0 ] || [ "${APT_SUDO:-}" = none ] || ! command -v sudo >/dev/null 2>&1 || as_root=(sudo)
+limit=()
+command -v timeout >/dev/null 2>&1 && limit=(timeout 600)
+apt=("${as_root[@]}" "${limit[@]}" env DEBIAN_FRONTEND=noninteractive apt-get -o Acquire::Retries=3 -o Acquire::http::Timeout=30)
+
+# Every Ubuntu archive and security source (deb822 and one-line forms, including the runner's mirror+file list) -> $1.
+point_at() {
+ local mirror="$1" file
+ for file in "$etc/sources.list.d/ubuntu.sources" "$etc/sources.list"; do
+ [ -f "$file" ] || continue
+ "${as_root[@]}" sed -i.bak -E \
+ -e "s#^URIs:.*#URIs: ${mirror}#" \
+ -e "s#^(deb(-src)?( \[[^]]*\])?) (https?://[^ ]*/ubuntu/?|mirror\+file:[^ ]*) #\1 ${mirror} #" "$file"
+ "${as_root[@]}" rm -f "$file.bak"
+ done
+}
+
+for round in 1 2; do
+ for mirror in $mirrors; do
+ echo "::group::apt from ${mirror} (round ${round})"
+ point_at "$mirror"
+ if "${apt[@]}" update && "${apt[@]}" install -y --no-install-recommends "$@"; then echo "::endgroup::"; exit 0; fi
+ echo "::endgroup::"
+ echo "apt failed with ${mirror}; trying the next mirror" >&2
+ sleep "$pause"
+ done
+done
+echo "apt could not install $* from any mirror" >&2
+exit 1
diff --git a/packages/agent-app/src/runtime/claude-lane.ts b/packages/agent-app/src/runtime/claude-lane.ts
index 1c6b78b5..f6db55d8 100644
--- a/packages/agent-app/src/runtime/claude-lane.ts
+++ b/packages/agent-app/src/runtime/claude-lane.ts
@@ -15,6 +15,7 @@ import {ASK_MCP} from './ask-user.ts';
import {OFFICE_MCP, OFFICE_NOTE_PATTERN} from './office-agent-tools.ts';
import {CANVAS_MCP, CANVAS_NOTE} from './canvas-agent-tools.ts';
import {DELEGATION_MCP} from '../shared/domains/delegation-protocol.ts';
+import {DEVICE_MCP, DEVICE_NOTE} from '../shared/device-protocol.ts';
import {ClaudeConversationMemory, claudeMessagesAdapter} from './adapters/claude-messages.ts';
import {sseEvents} from './adapters/shared.ts';
import type {RunnableAdapter} from './adapters/types.ts';
@@ -27,8 +28,9 @@ const MAX_PROBES = 256;
/** Tool servers the service adds to every Agent chat. The Messages lane has no MCP client: the browser and ask_user are
* offered as native tools, the others are simply not offered (their notes are dropped). Any other server carries user or
* Project state (mailbox, terminal consent, SSH, sandbox, Project tasks, the user's own servers) and keeps the turn on Codex.
- * #44: delegation is offered to every agent chat above read-only, so it never holds a turn back; this route has no delegation tools. */
-const LANE_SERVERS: Record = {[BROWSER_MCP]: true, [CANVAS_MCP]: true, [BACKGROUND_MCP]: true, [ASK_MCP]: true, [COMPUTER_MCP]: true, [OFFICE_MCP]: true, [DELEGATION_MCP]: true};
+ * #44: delegation is offered to every agent chat above read-only, so it never holds a turn back; this route has no delegation tools.
+ * #866: the device tools ("Let agents use devices") are dropped the same way; Claude Code keeps them. */
+const LANE_SERVERS: Record = {[BROWSER_MCP]: true, [CANVAS_MCP]: true, [BACKGROUND_MCP]: true, [ASK_MCP]: true, [COMPUTER_MCP]: true, [OFFICE_MCP]: true, [DELEGATION_MCP]: true, [DEVICE_MCP]: true};
const SERVER_KEY = /^(?:secret\.)?mcp_servers\.([^.]+)\./;
/** Whether a turn may leave Codex: Full access, and no tool server or goal that only the Codex client can run. */
@@ -43,11 +45,11 @@ export function claudeLaneAllowed(access: ChatPermissionMode, overrides: Record<
/** The run's notes without those for tools the Messages lane does not offer. */
export function withoutUnavailableToolNotes(instructions: string | undefined): string | undefined {
if (!instructions) return instructions;
- const text = [CANVAS_NOTE, BACKGROUND_TOOL_NOTE, COMPUTER_USE_NOTE, MUSTER_COMPUTER_NOTE].reduce((out, note) => out.replace(note, ''), instructions).replace(OFFICE_NOTE_PATTERN, '').replace(/\n{3,}/g, '\n\n').trim();
+ const text = [CANVAS_NOTE, BACKGROUND_TOOL_NOTE, COMPUTER_USE_NOTE, MUSTER_COMPUTER_NOTE, DEVICE_NOTE].reduce((out, note) => out.replace(note, ''), instructions).replace(OFFICE_NOTE_PATTERN, '').replace(/\n{3,}/g, '\n\n').trim();
return text || undefined;
}
/** Server names the lane drops from the run's tool servers (the browser has its own native tools). */
-export const LANE_DROPPED_SERVERS: readonly string[] = [BROWSER_MCP, CANVAS_MCP, BACKGROUND_MCP, ASK_MCP, COMPUTER_MCP, OFFICE_MCP, DELEGATION_MCP];
+export const LANE_DROPPED_SERVERS: readonly string[] = [BROWSER_MCP, CANVAS_MCP, BACKGROUND_MCP, ASK_MCP, COMPUTER_MCP, OFFICE_MCP, DELEGATION_MCP, DEVICE_MCP];
export interface ClaudeLaneConfig {
/** Router base URL, e.g. https://router.example/v1 ( /messages is appended). */
diff --git a/packages/agent-app/tests/acp-route-160.test.ts b/packages/agent-app/tests/acp-route-160.test.ts
index 1e9a8a29..53eeee70 100644
--- a/packages/agent-app/tests/acp-route-160.test.ts
+++ b/packages/agent-app/tests/acp-route-160.test.ts
@@ -26,7 +26,7 @@ async function rig(t: TestContext, options: {mode: ChatPermissionMode; flags?: s
const dataDir = await realpath(await mkdtemp(join(tmpdir(), 'muster-acp-')));
const folder = join(dataDir, 'project'), outside = join(dataDir, 'outside'), logFile = join(dataDir, 'acp-log.jsonl');
await mkdir(folder); await mkdir(outside);
- const agent: AcpAgentSpec = {id: 'acp_fake', name: 'Fake ACP', command: FAKE, args: [`--log=${logFile}`, ...(options.flags ?? [])]};
+ const agent: AcpAgentSpec = {id: 'acp_fake', name: 'Fake ACP', command: FAKE, args: [`--log=${logFile}`, '--end-delay=150', ...(options.flags ?? [])]};
const route = {info: {id: 'acp_fake', name: 'Fake ACP', driver: 'acp-agent', available: true, bindingId: 'b-acp', identityMasked: 'x', models: [{id: 'acp_fake/fast', name: 'Fast'}, {id: 'acp_fake/smart', name: 'Smart'}]}, command: '', env: {}, sessionsRoot: '', adapter: acpAdapter({agent, killGraceMs: 500})};
const provider = createProviderAdapter({instances: () => [route]});
const service = createAgentService({dataDir: join(dataDir, 'data'), provider, onEvent() {}});
@@ -39,7 +39,8 @@ async function rig(t: TestContext, options: {mode: ChatPermissionMode; flags?: s
const settled = () => until(async () => { const chat_ = (await service.invoke('app.snapshot', undefined)).chats.find(entry => entry.id === chat.id); return chat_?.status !== 'running' && chat_?.status !== 'stopping'; }, 'the turn settling');
return {service, chatId: chat.id, folder, outside, items, settled,
log: () => existsSync(logFile) ? readFileSync(logFile, 'utf8').trim().split('\n').filter(Boolean).map(line => JSON.parse(line)) : [],
- async send(text) { await service.invoke('chat.send', {id: chat.id, text, requestId: randomUUID()}); await until(async () => (await items()).some(item => item.kind === 'user' && item.text === text), 'the message being recorded'); }};
+ // #877: an answer can show before the agent ends its prompt, so a follow-up first waits for the previous turn to settle.
+ async send(text) { await settled(); await service.invoke('chat.send', {id: chat.id, text, requestId: randomUUID()}); await until(async () => (await items()).some(item => item.kind === 'user' && item.text === text), 'the message being recorded'); }};
}
const said = async (r: Rig, match: RegExp) => until(async () => (await r.items()).some(item => item.kind === 'assistant' && match.test(item.text)), `an answer matching ${match}`).catch(async error => { throw new Error(`${error.message}; the chat holds: ${JSON.stringify((await r.items()).map(item => [item.kind, item.status, item.text.slice(0, 160)]))}`); });
const card = async (r: Rig) => { await until(async () => (await r.items()).some(item => item.kind === 'approval' && item.status === 'pending'), 'the approval card'); return (await r.items()).find(item => item.kind === 'approval' && item.status === 'pending')!; };
diff --git a/packages/agent-app/tests/ci-apt-install.test.ts b/packages/agent-app/tests/ci-apt-install.test.ts
new file mode 100644
index 00000000..fb20be17
--- /dev/null
+++ b/packages/agent-app/tests/ci-apt-install.test.ts
@@ -0,0 +1,73 @@
+// #876: the Linux CI jobs install their apt packages through scripts/ci-apt-install.sh, which moves to another mirror when
+// one fails. The real script runs under bash with a stand-in apt-get on PATH and the apt folders in a temp directory.
+import assert from 'node:assert/strict';
+import {test} from 'node:test';
+import {spawnSync} from 'node:child_process';
+import {mkdtempSync, mkdirSync, readFileSync, rmSync, writeFileSync, chmodSync} from 'node:fs';
+import {tmpdir} from 'node:os';
+import {join} from 'node:path';
+
+const SCRIPT = join(import.meta.dirname, '..', 'scripts', 'ci-apt-install.sh');
+const WORKFLOW = join(import.meta.dirname, '..', '..', '..', '.github', 'workflows', 'agent-app-cross-platform.yml');
+const MIRRORS = ['http://one.test/ubuntu/', 'http://two.test/ubuntu/', 'http://three.test/ubuntu/'];
+
+/** A temp apt setup and a fake apt-get that fails as `behaviour` says for the mirror the sources point at. */
+function fakeApt(behaviour: Record) {
+ const dir = mkdtempSync(join(tmpdir(), 'muster-apt-'));
+ const etc = join(dir, 'etc-apt'), bin = join(dir, 'bin'), log = join(dir, 'apt.log');
+ mkdirSync(join(etc, 'sources.list.d'), {recursive: true}); mkdirSync(bin);
+ writeFileSync(join(etc, 'sources.list.d', 'ubuntu.sources'), 'Types: deb\nURIs: http://archive.ubuntu.com/ubuntu/\nSuites: noble noble-updates\nComponents: main universe\n\nTypes: deb\nURIs: http://security.ubuntu.com/ubuntu/\nSuites: noble-security\nComponents: main universe\n');
+ writeFileSync(join(etc, 'sources.list'), 'deb http://archive.ubuntu.com/ubuntu/ noble main\n');
+ const cases = Object.entries(behaviour).map(([mirror, what]) => ` *'${mirror}'*) what=${what} ;;`).join('\n');
+ writeFileSync(join(bin, 'apt-get'), `#!/bin/bash
+sources="$(cat "${etc}/sources.list.d/ubuntu.sources" "${etc}/sources.list")"
+what=works
+case "$sources" in
+${cases}
+esac
+mirror="$(grep -m1 -o 'http://[a-z.]*/ubuntu/' "${etc}/sources.list.d/ubuntu.sources")"
+echo "$mirror $*" >> "${log}"
+for arg in "$@"; do
+ if [ "$arg" = update ] && [ "$what" = update-fails ]; then echo "E: Failed to fetch $mirror" >&2; exit 100; fi
+ if [ "$arg" = install ] && [ "$what" = install-fails ]; then echo "E: Unable to locate package xvfb" >&2; exit 100; fi
+done
+exit 0
+`);
+ chmodSync(join(bin, 'apt-get'), 0o755);
+ const run = () => spawnSync('bash', [SCRIPT, 'xvfb', 'xauth'], {encoding: 'utf8', env: {...process.env, PATH: `${bin}:${process.env.PATH}`, APT_ETC: etc, APT_MIRRORS: MIRRORS.join(' '), APT_RETRY_PAUSE: '0', APT_SUDO: 'none'}});
+ const calls = () => readFileSync(log, 'utf8').trim().split('\n');
+ return {etc, run, calls, cleanup: () => rmSync(dir, {recursive: true, force: true, maxRetries: 5, retryDelay: 200})};
+}
+
+// Spec: MUS-SPEC-22-876A (docs/spec/clauses/22-engineering-standards.md#mus-spec-22-876a)
+test('the apt install moves to the next mirror when one cannot find a package, and fails only after every mirror', t => {
+ const apt = fakeApt({'one.test': 'update-fails', 'two.test': 'install-fails'});
+ t.after(apt.cleanup);
+ const ok = apt.run();
+ assert.equal(ok.status, 0, ok.stderr);
+ const calls = apt.calls();
+ assert.ok(calls.some(call => call.startsWith('http://one.test/ubuntu/') && / update/.test(call)), 'the first mirror was tried');
+ assert.ok(calls.some(call => call.startsWith('http://two.test/ubuntu/') && / install /.test(call)), 'the second mirror was tried after the first one failed');
+ assert.match(calls.at(-1)!, /^http:\/\/three\.test\/ubuntu\/ .*install .*xvfb xauth$/, 'the packages were installed from the third mirror');
+ const sources = readFileSync(join(apt.etc, 'sources.list.d', 'ubuntu.sources'), 'utf8');
+ assert.doesNotMatch(sources, /archive\.ubuntu\.com|security\.ubuntu\.com/, 'every source points at the working mirror');
+ assert.equal((sources.match(/three\.test/g) ?? []).length, 2);
+ assert.match(readFileSync(join(apt.etc, 'sources.list'), 'utf8'), /^deb http:\/\/three\.test\/ubuntu\/ noble main$/m);
+
+ const broken = fakeApt({'one.test': 'update-fails', 'two.test': 'install-fails', 'three.test': 'install-fails'});
+ t.after(broken.cleanup);
+ const failed = broken.run();
+ assert.notEqual(failed.status, 0, 'the step fails when no mirror works');
+ assert.match(failed.stderr, /Unable to locate package xvfb/, 'with apt’s own error');
+ for (const mirror of MIRRORS) assert.ok(broken.calls().some(call => call.startsWith(mirror)), `${mirror} was tried`);
+});
+
+// Spec: MUS-SPEC-22-876B (docs/spec/clauses/22-engineering-standards.md#mus-spec-22-876b)
+test('both Linux jobs install their apt packages through the retrying script', () => {
+ const workflow = readFileSync(WORKFLOW, 'utf8');
+ const job = (name: string) => { const start = workflow.indexOf(`\n ${name}:\n`); assert.ok(start >= 0, `job ${name}`); const next = workflow.slice(start + 1).search(/\n [a-z0-9-]+:\n/); return next < 0 ? workflow.slice(start) : workflow.slice(start, start + 1 + next); };
+ const build = job('package'), container = job('ubuntu-24-04');
+ assert.ok(/ci-apt-install\.sh [^\n]*xvfb[^\n]*desktop-file-utils/.test(build), 'the Linux build job uses the script');
+ assert.ok(/ci-apt-install\.sh [^\n]*xvfb xauth desktop-file-utils/.test(container), 'the container job uses the script');
+ for (const text of [build, container]) assert.ok(!/apt-get[^\n]*install -y --no-install-recommends (?:build-essential|xvfb)/.test(text), 'no direct apt-get install of the build packages');
+});
diff --git a/packages/agent-app/tests/claude-messages-lane.test.ts b/packages/agent-app/tests/claude-messages-lane.test.ts
index ddd6957a..9c3e6baa 100644
--- a/packages/agent-app/tests/claude-messages-lane.test.ts
+++ b/packages/agent-app/tests/claude-messages-lane.test.ts
@@ -59,13 +59,20 @@ function router(backend: Record, answer?: (sent: Sent, turn: num
type RouterAnswer = (sent: Sent, turn: number) => Response | undefined;
interface Harness {service: AgentService; router: Router; codex: Array>; overrides: Array | undefined>; clock: {now: number}; dataDir: string; chat(model: string, access?: 'read-only' | 'workspace' | 'full'): Promise; send(chatId: string, text: string): Promise; items(chatId: string): Promise; snapshot(chatId: string): Promise}
-async function harness(t: TestContext, options: {backend?: Record; answer?: RouterAnswer; headers?: (force?: boolean) => Promise>; userServer?: () => boolean; askUser?: boolean} = {}): Promise {
+/** Every tool launcher the service reads from the environment. The harness sets or clears each one, so a launcher in the
+ * caller's environment (Muster sets them for the chats it runs) never changes which route a turn takes (#866). */
+const LAUNCHER_ENV = ['MUSTER_BROWSER_MCP_LAUNCHER', 'MUSTER_BACKGROUND_MCP_LAUNCHER', 'MUSTER_COMPUTER_MCP_LAUNCHER', 'MUSTER_DEVICE_MCP_LAUNCHER'] as const;
+
+async function harness(t: TestContext, options: {backend?: Record; answer?: RouterAnswer; headers?: (force?: boolean) => Promise>; userServer?: () => boolean; askUser?: boolean; devices?: boolean} = {}): Promise {
const dataDir = await mkdtemp(join(tmpdir(), 'muster-lane-'));
// The service adds the browser and background-command tool servers only when their launchers exist.
const launcher = join(dataDir, 'launcher.sh');
await writeFile(launcher, '#!/bin/sh\nexit 0\n'); await chmod(launcher, 0o700);
- const saved = {browser: process.env.MUSTER_BROWSER_MCP_LAUNCHER, background: process.env.MUSTER_BACKGROUND_MCP_LAUNCHER};
+ const saved = Object.fromEntries(LAUNCHER_ENV.map(name => [name, process.env[name]]));
+ for (const name of LAUNCHER_ENV) delete process.env[name];
process.env.MUSTER_BROWSER_MCP_LAUNCHER = launcher; process.env.MUSTER_BACKGROUND_MCP_LAUNCHER = launcher;
+ // "Let agents use devices": main sets the device launcher only while the user allows it.
+ if (options.devices) process.env.MUSTER_DEVICE_MCP_LAUNCHER = launcher;
// The background-command server also needs its token issuer (a started host registers one).
const unissue = registerChatTokenIssuer(BACKGROUND_MCP, id => `token-for-${id}`);
const fake = router(options.backend ?? {'intelligent-planner': 'claude-opus-5-5', executor: 'gpt-5.6-terra'}, options.answer);
@@ -92,7 +99,7 @@ async function harness(t: TestContext, options: {backend?: Record {
unissue();
await service.dispose(); inner.dispose();
- for (const [name, value] of [['MUSTER_BROWSER_MCP_LAUNCHER', saved.browser], ['MUSTER_BACKGROUND_MCP_LAUNCHER', saved.background]] as const) { if (value === undefined) delete process.env[name]; else process.env[name] = value; }
+ for (const name of LAUNCHER_ENV) { const value = saved[name]; if (value === undefined) delete process.env[name]; else process.env[name] = value; }
await rm(dataDir, {recursive: true, force: true});
});
const items = async (chatId: string) => (await service.invoke('chat.timeline', {id: chatId})).items;
@@ -272,3 +279,19 @@ test('a Full access Claude turn still runs over the Messages API when the servic
assert.equal(after.status, 'completed', after.error ?? 'turn did not complete');
assert.equal(after.providerThreadDriver, LANE);
});
+
+// Spec: MUS-SPEC-03-866A (docs/spec/clauses/03-providers-models-and-accounts.md#mus-spec-03-866a)
+test('a Full access Claude turn with device tools on still runs over the Messages API, without the device server or its note', async t => {
+ const h = await harness(t, {devices: true});
+ const chat = await h.chat('cc/claude-opus-5-5');
+ await h.send(chat.id, 'Check the login screen.');
+ assert.ok(Object.keys(h.overrides[0] ?? {}).some(key => key.startsWith('mcp_servers.muster_device.')), 'the service added the device tool server');
+ assert.equal(h.codex.length, 0, 'the Codex client never ran');
+ assert.equal(h.router.turns.length, 1, 'the turn went to the Messages API');
+ const request = h.router.turns[0]!;
+ assert.ok(!request.body.tools!.some(tool => tool.name.startsWith('device_')), 'no device tool is offered on this route');
+ assert.doesNotMatch(request.body.system ?? '', /muster_device|iOS Simulators/, 'no device note for tools this route lacks');
+ const after = await h.snapshot(chat.id);
+ assert.equal(after.status, 'completed', after.error ?? 'turn did not complete');
+ assert.equal(after.providerThreadDriver, LANE);
+});
diff --git a/packages/agent-app/tests/day-dividers.test.ts b/packages/agent-app/tests/day-dividers.test.ts
index 34b40d94..ecdbd99f 100644
--- a/packages/agent-app/tests/day-dividers.test.ts
+++ b/packages/agent-app/tests/day-dividers.test.ts
@@ -35,12 +35,22 @@ test('labels: Today, Yesterday, weekday within a week, then the date, with the y
assert.equal(dividerLabel(new Date(2026, 9, 18, 14, 5).getTime(), now, 'en-US').time, '2:05 PM');
});
-test('cheap enough to run on every streamed update of a long chat', () => {
+// Spec: MUS-SPEC-20-770A (docs/spec/clauses/20-performance.md#mus-spec-20-770a)
+test('cheap enough to run on every streamed update of a long chat', t => {
+ // #770: count the work (timestamp parses) instead of timing it, so a busy CI runner cannot fail this.
+ let parses = 0;
+ const parse = Date.parse;
+ Date.parse = (text: string) => { parses++; return parse(text); };
+ t.after(() => { Date.parse = parse; });
const rows = Array.from({length: 2000}, (_, i) => row(i % 2 ? 'assistant' : 'user', new Date(2026, 0, 1, 0, i).toISOString()));
- dividerRows(rows); // first projection parses every timestamp once
+ const first = dividerRows(rows);
+ assert.equal(parses, 2000, 'the first projection parses each timestamp once');
+ parses = 0;
const start = performance.now();
for (let i = 0; i < 100; i++) dividerRows(rows);
const perCall = (performance.now() - start) / 100;
- assert.ok(perCall < 0.5, `dividerRows took ${perCall.toFixed(3)} ms for 2000 rows`);
- console.log(`dividerRows: ${perCall.toFixed(3)} ms per call on 2000 rows`);
+ assert.equal(parses, 0, 're-projecting the same rows parses no timestamp');
+ assert.deepEqual(dividerRows(rows), first, 'later projections give the same dividers');
+ // Backstop for a gross slowdown only: ten times the 0.5 ms a loaded runner measured.
+ assert.ok(perCall < 5, `dividerRows took ${perCall.toFixed(3)} ms per call for 2000 rows`);
});
diff --git a/packages/agent-app/tests/fixtures/acp/fake-acp-agent.cjs b/packages/agent-app/tests/fixtures/acp/fake-acp-agent.cjs
index 06dd1a47..79155d3b 100644
--- a/packages/agent-app/tests/fixtures/acp/fake-acp-agent.cjs
+++ b/packages/agent-app/tests/fixtures/acp/fake-acp-agent.cjs
@@ -1,8 +1,10 @@
// #160: a fake Agent Client Protocol agent (JSON-RPC 2.0 over stdio, protocol version 1) for Muster's ACP route tests.
-// Flags: --log= (every message it receives, one JSON per line), --no-load, --resume, --legacy-models, --auth-required, --not-acp.
+// Flags: --log= (every message it receives, one JSON per line), --end-delay= (answer each prompt that long after
+// its last words, like an agent that still finishes up after it has spoken: #877), --no-load, --resume, --legacy-models, --auth-required, --not-acp.
// The prompt text picks the scenario: STREAM, EDIT , WRITE , READ , RUN , HANG, otherwise an echo.
const fs = require('node:fs'), readline = require('node:readline');
const flags = process.argv.slice(2), flag = (name) => flags.includes(`--${name}`), log = (flags.find(f => f.startsWith('--log=')) || '').slice(6);
+const endDelay = Number((flags.find(f => f.startsWith('--end-delay=')) || '').slice(12)) || 0;
if (flag('not-acp')) { console.log('Welcome to an interactive agent. Type /help to begin.'); process.exit(1); }
const record = (m) => { if (log) fs.appendFileSync(log, JSON.stringify(m) + '\n'); };
const send = (m) => process.stdout.write(JSON.stringify({jsonrpc: '2.0', ...m}) + '\n');
@@ -18,7 +20,7 @@ const permission = (sessionId, toolCall) => request('session/request_permission'
async function prompt(m) {
const sessionId = m.params.sessionId, text = m.params.prompt.map(block => block.text || '').join('\n'), last = text.split('\n').pop();
const say = (t) => update(sessionId, {sessionUpdate: 'agent_message_chunk', content: {type: 'text', text: t}});
- const done = (stopReason = 'end_turn', extra = {}) => send({id: m.id, result: {stopReason, ...extra}});
+ const done = (stopReason = 'end_turn', extra = {}) => { const answer = () => send({id: m.id, result: {stopReason, ...extra}}); if (endDelay && stopReason !== 'cancelled') setTimeout(answer, endDelay); else answer(); };
if (/^STREAM/.test(last)) {
update(sessionId, {sessionUpdate: 'agent_thought_chunk', content: {type: 'text', text: 'Thinking about it'}});
update(sessionId, {sessionUpdate: 'plan', entries: [{content: 'Read the notes', priority: 'high', status: 'completed'}, {content: 'Answer', priority: 'medium', status: 'in_progress'}]});
diff --git a/packages/agent-app/tests/router-claude-code-730.test.ts b/packages/agent-app/tests/router-claude-code-730.test.ts
index 09547c2a..9bb01239 100644
--- a/packages/agent-app/tests/router-claude-code-730.test.ts
+++ b/packages/agent-app/tests/router-claude-code-730.test.ts
@@ -61,12 +61,17 @@ interface Harness {
send(chatId: string, text: string): Promise; items(chatId: string): Promise; snapshot(chatId: string): Promise;
}
-async function harness(t: TestContext, options: {userServer?: boolean} = {}): Promise {
+const LAUNCHER_ENV = ['MUSTER_BROWSER_MCP_LAUNCHER', 'MUSTER_BACKGROUND_MCP_LAUNCHER', 'MUSTER_COMPUTER_MCP_LAUNCHER', 'MUSTER_DEVICE_MCP_LAUNCHER'] as const;
+
+async function harness(t: TestContext, options: {userServer?: boolean; devices?: boolean} = {}): Promise {
const dataDir = await mkdtemp(join(tmpdir(), 'muster-router-cc-'));
const launcher = join(dataDir, 'launcher.sh');
await writeFile(launcher, '#!/bin/sh\nexit 0\n'); await chmod(launcher, 0o700);
- const saved = {browser: process.env.MUSTER_BROWSER_MCP_LAUNCHER, background: process.env.MUSTER_BACKGROUND_MCP_LAUNCHER};
+ // Every launcher is set or cleared here, so one in the caller's environment does not change the result (#866).
+ const saved = Object.fromEntries(LAUNCHER_ENV.map(name => [name, process.env[name]]));
+ for (const name of LAUNCHER_ENV) delete process.env[name];
process.env.MUSTER_BROWSER_MCP_LAUNCHER = launcher; process.env.MUSTER_BACKGROUND_MCP_LAUNCHER = launcher;
+ if (options.devices) process.env.MUSTER_DEVICE_MCP_LAUNCHER = launcher;
const unissue = registerChatTokenIssuer(BACKGROUND_MCP, id => `token-for-${id}`);
const log = join(dataDir, 'claude-launches.json'), binary = join(dataDir, 'claude.cjs');
await writeFile(binary, fakeClaude(log));
@@ -105,7 +110,7 @@ async function harness(t: TestContext, options: {userServer?: boolean} = {}): Pr
t.after(async () => {
unissue();
await service.dispose(); inner.dispose();
- for (const [name, value] of [['MUSTER_BROWSER_MCP_LAUNCHER', saved.browser], ['MUSTER_BACKGROUND_MCP_LAUNCHER', saved.background]] as const) { if (value === undefined) delete process.env[name]; else process.env[name] = value; }
+ for (const name of LAUNCHER_ENV) { const value = saved[name]; if (value === undefined) delete process.env[name]; else process.env[name] = value; }
await rm(dataDir, {recursive: true, force: true});
});
const items = async (chatId: string) => (await service.invoke('chat.timeline', {id: chatId})).items;
@@ -217,3 +222,17 @@ test('a chat whose earlier turn ran on the Codex client moves to Claude Code wit
assert.equal(after.providerThreadDriver, 'claude-code-cli');
assert.equal(after.status, 'completed');
});
+
+// Spec: MUS-SPEC-03-866B (docs/spec/clauses/03-providers-models-and-accounts.md#mus-spec-03-866b)
+test('with device tools on, a router Claude turn through Claude Code keeps the device server', async t => {
+ const h = await harness(t, {userServer: true, devices: true});
+ const chat = await h.chat('cc/claude-opus-5-5', 'workspace');
+ await h.send(chat.id, 'Open the simulator.');
+ const after = await h.snapshot(chat.id);
+ assert.equal(after.status, 'completed', after.error ?? 'the turn did not complete');
+ assert.equal(after.providerThreadDriver, 'claude-code-cli', 'the turn ran through Claude Code');
+ const [run] = await h.launches();
+ const servers = Object.keys(JSON.parse(run!.mcpConfig!).mcpServers);
+ assert.ok(servers.includes('muster_device'), `Claude Code loads the device server (got ${servers.join(', ')})`);
+ assert.ok(servers.includes('projectdb'), 'and the user tool server');
+});