Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
d4f2586
TD-5233: the session-preset slug test reads no host keychain and no n…
captcrock Nov 20, 2026
741d555
TD-5237: duplicate, rename and remove a model in Settings
captcrock Nov 20, 2026
80afb2c
TD-5234: a model carries its own context settings
captcrock Nov 20, 2026
3710bda
TD-5239: a model can name its engine, and a Grok one needs no model o…
captcrock Nov 20, 2026
1d56021
TD-5258: add Grok to your models from Settings → Engine
captcrock Nov 20, 2026
430de26
TD-5235: one click switches this chat and the model new chats use
captcrock Nov 20, 2026
254123a
TD-5236: Local, API and Grok sections in the picker, and a shortcut p…
captcrock Nov 20, 2026
015091f
TD-5240: the picker says when a model cannot run yet
captcrock Nov 20, 2026
169d579
TD-5241: Settings → Model edits the model you choose
captcrock Nov 20, 2026
717cf38
TD-5242: the model picker on a paired phone
captcrock Nov 20, 2026
462bcbe
TD-5260: the README and the shipped comments say what the code does
captcrock Nov 20, 2026
02d1dba
TD-5265: a delegated child's call limit is a setting
captcrock Nov 20, 2026
d7ce470
TD-5261: the shell sandbox works in a session's own worktree
captcrock Nov 20, 2026
bc83a24
TD-5276: only the computer changes its MCP servers
captcrock Nov 20, 2026
085769c
TD-5266: every frame in the window is sandboxed
captcrock Nov 20, 2026
7607348
TD-5266: check the mounted Grok preview frame carries its sandbox
captcrock Nov 20, 2026
6005d15
TD-5262: an HTML artifact preview cannot reach out, even on a click
captcrock Nov 20, 2026
2029c08
TD-5267: an MCP server does not get the daemon's secrets from its env…
captcrock Nov 20, 2026
d6e6c44
TD-5268: an approval card says which child is asking
captcrock Nov 20, 2026
8cceb70
TD-5269: one count of calls per model server, across the daemon
captcrock Nov 20, 2026
0f5087f
TD-5270: fs_edit replaces every occurrence, or several things in one …
captcrock Nov 20, 2026
472a613
TD-5277: tests that fail when an MCP server key is left off a list
captcrock Nov 20, 2026
76fa87a
TD-5278: the worktree fix holds for a symlinked data dir, and git's o…
captcrock Nov 20, 2026
5257ec6
TD-5269: an abandoned stream is closed at once, not when collected
captcrock Nov 20, 2026
55ef89d
TD-5279: a paired phone changes MCP servers only if the computer said so
captcrock Nov 20, 2026
9fd42f6
TD-5259: memory distill runs on the chat's own model
captcrock Nov 20, 2026
29eaa4c
TD-5280: a cache write is charged at its own price
captcrock Nov 20, 2026
b7c164c
TD-5281: a child's approval card never offers Always allow
captcrock Nov 20, 2026
4fdc221
TD-5282: a new install limits a local model to two calls at once
captcrock Nov 20, 2026
f577f1a
TD-5278: say in the code why --disable-userns is not passed yet
captcrock Nov 20, 2026
6e29055
TD-5283: a paired phone turns approvals off only if the computer said so
captcrock Nov 20, 2026
cc546b3
TD-5254: the agent can show something to read in the Artifacts pane
captcrock Nov 20, 2026
54cd2cf
TD-5284: every verb is placed for a phone, and a new one starts refused
captcrock Nov 20, 2026
ebc84fb
TD-5253: import MCP servers from pasted JSON
captcrock Nov 20, 2026
4da96cd
TD-5293: read_text_file no longer takes the caller's word for the wor…
captcrock Nov 21, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
482 changes: 482 additions & 0 deletions DECISIONS.md

Large diffs are not rendered by default.

21 changes: 19 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,18 @@ directives in [`AGENTS.md`](AGENTS.md) §2 and enforced in code.
of that socket, and the other half of this repo.
- **No subscription.** You pay your model provider per token and nobody else. There is no
billing code in this repository because there is nothing to bill.
- **No telemetry.** No analytics, no phone-home, no crash reporting. The only outbound HTTP the
daemon makes is to the `base_url` you configured: there is exactly one chat client
- **No telemetry.** No analytics, no phone-home, no crash reporting. Nothing is sent to the
authors of TST Desk or to a service of ours, because there is none. Every host the daemon
does contact is named in your `config.yaml`:
- each model's `base_url`, for chat and, once a day, to re-read that model's price and
context size (`model_refresh`; `auto: false` turns it off);
- the search pages `web_search` reads (`search.base_url` and its fallbacks) and the pages
`web_fetch` opens, under the same approval rules as any other tool call;
- what you switch on yourself: notification channels, connectors, and an MCP server you
marked `allow_remote`.

The packaged app, not the daemon, also asks GitHub releases for a newer version when it
opens and every four hours ([Updates](#updates)). There is exactly one chat client
([`provider.py`](core/tstd/provider.py)), and its endpoint comes from config, never from a
literal in the source. Model discovery refuses any non-loopback endpoint *before* it sends
([`discovery.py`](core/tstd/discovery.py)).
Expand Down Expand Up @@ -212,6 +222,13 @@ directives in [`AGENTS.md`](AGENTS.md) §2 and enforced in code.
original. The copy is your file verbatim; it is not redacted, and it never goes to a log or
the audit database. Limits: 512 MiB per file and 4 GiB per session
(`session.send_file_max_bytes`, `session.send_file_session_max_bytes`).
- **What the agent shows in the Artifacts pane is text it was allowed to read, or text it
wrote.** `show_artifact` either points at a text file inside the workspace (no copy is made)
or keeps text the agent hands over under `<user data dir>/sessions/<session id>/artifacts/`,
owner-only, under a name the daemon makes. It writes nowhere else and contacts no host. An
HTML artifact is shown as a static picture of itself: no scripts, no links, no remote
images. Limits: 2 MiB per artifact and 200 per session
(`session.artifact_max_bytes`, `session.artifact_max_count`).
- **The agent cannot rewrite its own rules.** `AGENTS.md`, `CLAUDE.md` and `.tst/rules/**` are
refused by the filesystem tool itself ([`tools/boundary.py`](core/tstd/tools/boundary.py)),
ahead of the workspace check and ahead of any approval — so no `writable_paths` grant can open
Expand Down
10 changes: 10 additions & 0 deletions android/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ Still works as a fallback. On the computer, turn on **Allow remote attach** in S

The shell refuses any host that is not a Tailscale address (`100.64.0.0/10`, `fd7a:115c:a1e0::/48`) or a `*.ts.net` name. It does not listen on the network. The UI is served to the WebView on `127.0.0.1` only, on the same port each launch when it is free.

Some things stay with the computer and are refused from a phone: the raw Settings →
Configuration editor, trusting a workspace's own config, accepting an instruction-file
edit, and removing a model.

Adding, changing or removing an MCP server or its token is off for phones unless you turn
it on at the computer (**Settings → Phones and devices → What paired phones may change**).
An MCP server is a command the computer runs, so read what that switch says before
turning it on. While it is off the phone shows the MCP list read-only. A phone cannot turn
it on, and the computer's window is told each time a phone changes a server (TD-5279).

## Build

Needs JDK 17+, the Android SDK (platform 35, build-tools 35), and the UI's `npm` dependencies.
Expand Down
73 changes: 73 additions & 0 deletions core/scripts/generate_protocol_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from tstd.protocol import (
CHUNK_MAX,
PROTOCOL_VERSION,
AddGrokPreset,
AddMachine,
AddModel,
AddPin,
Expand Down Expand Up @@ -49,6 +50,7 @@
CharterDocument,
CheckCuPermissions,
CheckpointNotice,
CheckPresets,
CloseWorktree,
CommandEntry,
CommandList,
Expand All @@ -74,6 +76,7 @@
DeleteJobTemplate,
DeleteMcpSecret,
DeleteMcpServer,
DeletePreset,
DeleteSession,
Deny,
DenyVerify,
Expand All @@ -85,6 +88,7 @@
DiagnosticsReport,
Drain,
DrainResult,
DuplicatePreset,
EmailTestResult,
EndpointModel,
EndpointModels,
Expand All @@ -100,6 +104,7 @@
GetConfigEditor,
GetHooks,
GetInstructionStack,
GetPresetRoles,
GetSessionJobSource,
GetSetupState,
GetUsage,
Expand All @@ -125,6 +130,7 @@
HookInfo,
HookRun,
HooksState,
ImportMcpServers,
InstructionFileEntry,
InstructionFiles,
InstructionStack,
Expand Down Expand Up @@ -157,6 +163,10 @@
LoosenedSetting,
MachineList,
MachineSummary,
McpImportChoice,
McpImportPreview,
McpImportServer,
McpImportValue,
McpServerSummary,
McpValueSummary,
MemoryAccept,
Expand All @@ -180,12 +190,17 @@
PairingCode,
PairingCompleted,
ParseJob,
PhoneChange,
Ping,
PlanPinned,
PlanReview,
PlanReviewed,
PolicyRules,
PolicyRuleSummary,
PresetReadiness,
PresetReady,
PresetRoles,
PreviewMcpImport,
PreviewRestoreFiles,
Question,
QuestionAnswer,
Expand Down Expand Up @@ -247,8 +262,10 @@
SetLoadGlobalMemory,
SetMcpSecret,
SetMcpServer,
SetPhonePermission,
SetPlan,
SetPreset,
SetPresetLabel,
SetRemoteAttach,
SetSessionPreset,
SetSessionStar,
Expand Down Expand Up @@ -277,6 +294,7 @@
StopCheck,
StopCheckItem,
SubmitLineComments,
SwitchPreset,
TaskList,
TaskListItem,
TestEmail,
Expand Down Expand Up @@ -582,6 +600,19 @@
),
"test_model": TestModel(),
"set_preset": SetPreset(name="tst-default"),
# TD-5237: copy, relabel and remove a catalog entry
"duplicate_preset": DuplicatePreset(source="tst-default", label="My copy"),
"set_preset_label": SetPresetLabel(
name="tst-default", label="House model", description="General coding and chat"
),
"delete_preset": DeletePreset(name="budget"),
"check_presets": CheckPresets(),
# TD-5241: the roles of the entry Settings → Model is editing
"get_preset_roles": GetPresetRoles(name="budget"),
# TD-5235: this chat, the model new chats use, or both
"switch_preset": SwitchPreset(name="budget", session_id="sess-1", make_default=True),
# TD-5258: put the Grok CLI on the model list
"add_grok_preset": AddGrokPreset(),
"set_engine": SetEngine(kind="grok"),
"set_grok_mode": SetGrokMode(session_id="sess-1", mode="plan"),
"run_grok_command": RunGrokCommand(session_id="sess-1", name="compact", argument="keep tests"),
Expand Down Expand Up @@ -627,6 +658,16 @@
"start_pairing": StartPairing(),
"cancel_pairing": CancelPairing(),
"remove_remote_device": RemoveRemoteDevice(device_id="dev_0123456789ab"),
# Pasted MCP JSON (TD-5253). The text here holds no token.
"preview_mcp_import": PreviewMcpImport(text='{"mcpServers": {"files": {"command": "uvx"}}}'),
"import_mcp_servers": ImportMcpServers(
text='{"mcpServers": {"files": {"command": "uvx"}}}',
servers=[McpImportChoice(source_name="files", id="files")],
),
# What a paired phone may change (TD-5279): on for an hour.
"set_phone_permission": SetPhonePermission(
capability="mcp_servers", enabled=True, expires_in_seconds=3600
),
# Other computers (TD-5015). Loopback only; the code is a placeholder.
"add_machine": AddMachine(link="tstdesk://pair?h=100.64.1.5&p=39079&c=ABCD2345&n=tower"),
"add_machine_address": AddMachine(host="100.64.1.5", port=39079, code="ABCD-2345"),
Expand Down Expand Up @@ -1567,6 +1608,21 @@
id="dev_0123456789ab", name="Pixel", paired_at="2026-10-14T10:41:00Z"
)
),
"mcp_import_preview": McpImportPreview(
servers=[
McpImportServer(
source_name="GitHub",
id="github",
command=["npx", "-y", "server-github"],
values=[McpImportValue(name="GITHUB_TOKEN", target="env", disposition="keychain")],
)
]
),
"phone_change": PhoneChange(
device_name="Pixel",
capability="mcp_servers",
summary="added MCP server 'files': npx files-server",
),
# One connected computer and one self-pair that is unreachable (TD-5015).
"machine_list": MachineList(
machines=[
Expand Down Expand Up @@ -1622,6 +1678,23 @@
error="The server refused the key. Check it and try again.",
),
"model_tested": ModelTested(preset="tst-default", ok=True, reply="I am working."),
"preset_roles": PresetRoles(
preset="budget",
tier_slugs={"brain": "vendor/model-a", "worker": None},
tier_credentials={"brain": "openrouter", "worker": None},
tier_loopback={"brain": False, "worker": True},
),
# TD-5240: whether each model on the picker can run right now
"preset_readiness": PresetReadiness(
rows=[
PresetReady(preset="tst-default", status="ready"),
PresetReady(
preset="local",
status="server_down",
detail="Nothing is answering at 127.0.0.1:11434. Start the model server.",
),
]
),
# TD-5203: a two-model slice of the editor's schema, and an edit's ack.
"config_editor": ConfigEditor(
root="ModelConfig",
Expand Down
164 changes: 164 additions & 0 deletions core/tests/test_add_grok_preset.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
"""Put the Grok CLI on the model list from Settings → Engine (TD-5258).

One narrow verb writes an entry that is ``engine: grok`` and nothing else
(TD-5239). It is offered only where the Grok CLI is found, and once.
"""

from __future__ import annotations

from pathlib import Path

import pytest

from tests.catalog_helpers import catalog_config_yaml
from tests.test_add_model import _ask, _start, _stop
from tstd.config import ConfigError, default_config_yaml, load_config
from tstd.mock import MockProvider, Script
from tstd.peer_policy import MACHINE_PEER_VERBS
from tstd.preset_write import add_grok_preset

DESCRIPTION = "The Grok CLI, with its own model"


def _write(tmp_path: Path, text: str) -> Path:
path = tmp_path / "config.yaml"
path.write_text(text, encoding="utf-8")
return path


class TestTheWriter:
def test_into_the_shipped_empty_catalog(self, tmp_path: Path) -> None:
shipped = default_config_yaml()
path = _write(tmp_path, shipped)
add_grok_preset("grok", "Grok", DESCRIPTION, path)
block = (
'\npresets:\n grok:\n label: "Grok"\n'
f' description: "{DESCRIPTION}"\n engine: grok\n'
)
assert path.read_text(encoding="utf-8") == shipped.replace("\npresets: {}\n", block, 1)
config = load_config(path)
entry = config.presets["grok"]
assert entry.engine == "grok" and entry.has_tiers is False
assert entry.label == "Grok" and entry.description == DESCRIPTION
# The only entry, so the loader makes it the one new chats use.
assert config.active_preset == "grok" and config.has_model() is True
assert config.requires_api_key() is False

def test_after_the_last_entry_of_a_catalog_and_nothing_else_changes(
self, tmp_path: Path
) -> None:
before = catalog_config_yaml()
path = _write(tmp_path, before)
was_active = load_config(path).active_preset
add_grok_preset("grok", "Grok", DESCRIPTION, path)
after = path.read_text(encoding="utf-8").split("\n")
start = after.index(" grok:")
assert after[start : start + 4] == [
" grok:",
' label: "Grok"',
f' description: "{DESCRIPTION}"',
" engine: grok",
]
assert "\n".join(after[:start] + after[start + 4 :]) == before
config = load_config(path)
assert list(config.presets)[-1] == "grok"
assert config.active_preset == was_active

def test_a_file_with_no_catalog_at_all(self, tmp_path: Path) -> None:
path = _write(tmp_path, default_config_yaml().replace("\npresets: {}\n", "\n", 1))
add_grok_preset("grok", "Grok", "", path)
entry = load_config(path).presets["grok"]
assert entry.engine == "grok" and entry.description is None

def test_a_label_cannot_inject_yaml(self, tmp_path: Path) -> None:
path = _write(tmp_path, default_config_yaml())
add_grok_preset("grok", 'G"\n engine: native', DESCRIPTION, path)
entry = load_config(path).presets["grok"]
assert entry.label == 'G"\n engine: native' and entry.engine == "grok"

def test_once_is_enough(self, tmp_path: Path) -> None:
path = _write(tmp_path, default_config_yaml())
add_grok_preset("grok", "Grok Build", DESCRIPTION, path)
text = path.read_text(encoding="utf-8")
with pytest.raises(ConfigError, match=r"already one of your models \(Grok Build\)"):
add_grok_preset("grok-2", "Grok", DESCRIPTION, path)
assert path.read_text(encoding="utf-8") == text

@pytest.mark.parametrize(
("name", "label", "says"),
[
("local", "Grok", "already exists"),
("Not A Slug", "Grok", "lowercase slug"),
("grok", " ", "Give the model a name"),
],
)
def test_refusals_write_nothing(self, tmp_path: Path, name: str, label: str, says: str) -> None:
path = _write(tmp_path, catalog_config_yaml())
with pytest.raises(ConfigError, match=says):
add_grok_preset(name, label, DESCRIPTION, path)
assert path.read_text(encoding="utf-8") == catalog_config_yaml()


def _mock() -> MockProvider:
return MockProvider(default=Script(kind="text"))


def _grok(monkeypatch: pytest.MonkeyPatch, *, found: bool) -> None:
result = (Path("/usr/bin/grok"), True) if found else (None, False)
monkeypatch.setattr("tstd.daemon._probe_grok", lambda _configured: result)


class TestOverTheWire:
async def test_it_adds_the_entry_and_leaves_the_active_model(
self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch
) -> None:
_grok(monkeypatch, found=True)
daemon, task, ws = await _start(tmp_path, _mock())
try:
before = await _ask(ws, {"type": "get_setup_state"}, "setup_state")
assert before["preset_engines"] == {}
state = await _ask(ws, {"type": "add_grok_preset"}, "setup_state")
assert state["type"] == "setup_state"
assert state["presets"] == sorted([*before["presets"], "grok"])
assert state["preset_engines"] == {"grok": "grok"}
assert state["preset_labels"]["grok"] == "Grok"
assert state["preset_descriptions"]["grok"] == DESCRIPTION
assert state["active_preset"] == before["active_preset"]
assert state["engine"] == before["engine"]
on_disk = load_config(daemon.config_path).presets["grok"]
assert on_disk.engine == "grok" and on_disk.has_tiers is False
finally:
await _stop(task, ws)

async def test_a_second_ask_is_refused(
self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch
) -> None:
_grok(monkeypatch, found=True)
daemon, task, ws = await _start(tmp_path, _mock())
try:
await _ask(ws, {"type": "add_grok_preset", "label": "Grok Build"}, "setup_state")
text = daemon.config_path.read_text(encoding="utf-8")
reply = await _ask(ws, {"type": "add_grok_preset"}, "setup_state")
assert reply["type"] == "error" and reply["code"] == "bad_request"
assert "already one of your models (Grok Build)" in reply["message"]
assert daemon.config_path.read_text(encoding="utf-8") == text
finally:
await _stop(task, ws)

async def test_it_is_refused_where_the_grok_cli_is_not_found(
self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch
) -> None:
_grok(monkeypatch, found=False)
daemon, task, ws = await _start(tmp_path, _mock())
try:
text = daemon.config_path.read_text(encoding="utf-8")
reply = await _ask(ws, {"type": "add_grok_preset"}, "setup_state")
assert reply["type"] == "error" and reply["code"] == "grok_unavailable"
assert "not found" in reply["message"]
assert daemon.config_path.read_text(encoding="utf-8") == text
finally:
await _stop(task, ws)


def test_another_computers_hub_may_not_send_it() -> None:
assert "add_grok_preset" not in MACHINE_PEER_VERBS
Loading
Loading