Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

feat(voice): let Jarvis drive the Agentic IDE like the user does

rubenluetke10-beep746191950765
diff --git a/jarvis/agentic_ide/orchestration.py b/jarvis/agentic_ide/orchestration.py
index 2686098633..588aeb9ce4 100644
--- a/jarvis/agentic_ide/orchestration.py
+++ b/jarvis/agentic_ide/orchestration.py
@@ -48,6 +48,29 @@ _FILLER = frozenset(
_RESOLVE_TTL_S = 15 * 60
_NEAR_MISS = 3
_TARGET_KEYS = ("project_id", "workspace_id", "terminal_id")
+# A send of the same prompt to the same pane counts as a retry only this soon;
+# a later "continue" or "/compact" is a new instruction and must be typed.
+_RETRY_WINDOW_S = 120
+_PANE_ACTIONS = frozenset({"observe", "respond", "keys", "interrupt", "close"})
+_WORKSPACE_ACTIONS = frozenset({"open_workspace", "restore", "show"})
+# The keys a person presses in a pane besides typing: menus, dialogs, the
+# permission-mode cycle (Shift+Tab) and Stop (Escape). Nothing else is sendable.
+_KEY_SEQUENCES = {
+ "enter": "\r",
+ "escape": "\x1b",
+ "tab": "\t",
+ "shift+tab": "\x1b[Z",
+ "up": "\x1b[A",
+ "down": "\x1b[B",
+ "right": "\x1b[C",
+ "left": "\x1b[D",
+ "space": " ",
+ "y": "y",
+ "n": "n",
+ **{str(digit): str(digit) for digit in range(10)},
+}
+_MAX_KEYS = 10
+_KEY_GAP_S = 0.08
# An apostrophe inside a name joins, it does not split: the workspace "VM`s"
@@ -85,6 +108,18 @@ def _coding_cli(spoken: str) -> str | None:
return None
+def _default_cli() -> str | None:
+ """The first installed coding CLI, for a request that names none."""
+ from jarvis.workspace import agents as workspace_agents
+
+ from .session import agent_argv
+
+ for info in workspace_agents.coding_agents():
+ if accepts_prompts(info.name) and agent_argv(info.name) is not None:
+ return info.name
+ return None
+
+
def _score(reference: str, ids: Iterable[str], names: Iterable[str]) -> int:
"""3 = exact id/name, 2 = same words, 1 = one name's words contain the other's."""
names = [n for n in names if n]
@@ -347,8 +382,23 @@ class WorkspaceOrchestrator:
count = 1
count = max(1, min(count, MAX_TERMINALS))
name = str(args.get("name") or "").strip()
+ mixed = args.get("agents")
+ if isinstance(mixed, list) and mixed:
+ # "Five Claude Code and three Codex" in one call.
+ groups = self._groups(args)
+ if isinstance(groups, dict):
+ return groups
+ count = sum(n for _, n in groups)
try:
- if count == 1 and name:
+ if isinstance(mixed, list) and mixed:
+ created, capped = [], False
+ for group_cli, group_count in groups:
+ made, cut = await self.registry.add_terminals(
+ group_count, agent=group_cli, workspace_id=workspace["id"]
+ )
+ created.extend(made)
+ capped = capped or cut
+ elif count == 1 and name:
created = [
await self.registry.add_terminal(
workspace_id=workspace["id"], agent=cli, name=name
@@ -417,6 +467,292 @@ class WorkspaceOrchestrator:
)
return result
+ async def _announce(self, event_factory: Callable[[], Any]) -> None:
+ """Tell the open UI about a change; the change stands either way (AP-18)."""
+ if self.publish is None:
+ return
+ try:
+ await self.publish(event_factory())
+ except Exception as exc: # noqa: BLE001 - notification is not the work
+ from loguru import logger
+
+ logger.warning("Workspace change was not announced to the UI: {}", exc)
+
+ async def _pane(self, args: dict[str, Any]) -> tuple[Any, Any, dict[str, str]] | dict:
+ """The one open pane a request names, by IDs from resolve or by call-sign."""
+ if str(args.get("terminal_id") or "").strip():
+ target, _ = self._reconcile(args, "observe")
+ elif str(args.get("agent") or "").strip():
+ resolved = self.resolve(args, await asyncio.to_thread(self.graph))
+ if resolved.get("status") != "resolved":
+ return resolved
+ target = {key: resolved["target"][key] for key in _TARGET_KEYS}
+ else:
+ return {
+ "status": "needs_clarification",
+ "kind": "agent",
+ "reason": "Name the coding agent (its call-sign) or pass terminal_id.",
+ }
+ found = self.registry.find_terminal(target["terminal_id"], target["workspace_id"] or None)
+ if found is None:
+ return {
+ "status": "stale_target",
+ "target": target,
+ "reason": "That coding agent is no longer open; inspect the workspace again.",
+ }
+ owner, term = found
+ return owner, term, target
+
+ async def pane_action(self, args: dict[str, Any]) -> dict[str, Any]:
+ """Everything a person does with one open pane besides typing a task.
+
+ observe reads the screen and the newest recorded events; respond answers
+ the question or permission prompt the agent is showing; keys presses
+ keys (menus, Shift+Tab, Escape); interrupt stops the current turn
+ (Escape, the pane's Stop button); close stops and removes the pane.
+ """
+ action = str(args.get("action"))
+ picked = await self._pane(args)
+ if isinstance(picked, dict):
+ return picked
+ owner, term, target = picked
+ pane = {"workspace_id": owner.id, "terminal_id": target["terminal_id"]}
+ try:
+ if action == "observe":
+ seen = await self.sessions.run({"action": "observe", **pane})
+ return {"status": "observed", "target": target, **seen}
+ if action == "respond":
+ answer = str(args.get("prompt") or "").strip()
+ if not answer:
+ raise SessionError("Pass the answer to type as prompt.")
+ state = await self.sessions.run({"action": "input", **pane})
+ delivery = await self.sessions.run(
+ {
+ "action": "respond",
+ **pane,
+ "prompt": answer,
+ "input_token": state["input_token"],
+ "response_mode": state["response_mode"],
+ }
+ )
+ return {
+ "status": delivery.get("delivery", "uncertain"),
+ "target": target,
+ **delivery,
+ }
+ if action in {"keys", "interrupt"}:
+ keys = ["escape"] if action == "interrupt" else list(args.get("keys") or [])
+ unknown = [k for k in keys if str(k).casefold() not in _KEY_SEQUENCES]
+ if not keys or unknown or len(keys) > _MAX_KEYS:
+ raise SessionError(
+ f"Press 1-{_MAX_KEYS} keys from: {', '.join(sorted(_KEY_SEQUENCES))}."
+ )
+ for index, key in enumerate(keys):
+ if index:
+ await asyncio.sleep(_KEY_GAP_S)
+ if not self.registry.write(
+ term.name, _KEY_SEQUENCES[str(key).casefold()], owner.id
+ ):
+ raise SessionError(f"{term.name} is not running.")
+ return {"status": "pressed", "target": target, "keys": keys, "agent": term.name}
+ if action == "close":
+ from .fleet_actions import terminals_closed_event
+
+ closed, failed = await self.registry.close_terminals(
+ [term.name], workspace_id=owner.id
+ )
+ if closed:
+ await self._announce(
+ lambda: terminals_closed_event(
+ owner, closed, source_layer="agentic_ide.orchestration"
+ )
+ )
+ return {
+ "status": "closed" if closed else "not_accepted",
+ "target": target,
+ "closed": [t.name for t in closed],
+ "failed": failed,
+ }
+ except SessionError as exc:
+ return {"status": "not_accepted", "target": target, "reason": str(exc)}
+ raise ValueError("Unknown pane action.")
+
+ async def workspace_action(self, args: dict[str, Any], *, trace_id: str = "") -> dict:
+ """Open a new workspace, restore a closed one, or bring one on screen."""
+ from .session import workspace_changed_event
+
+ action = str(args.get("action"))
+ graph = await asyncio.to_thread(self.graph)
+ if action == "show":
+ picked = self._workspace(args, graph, "")
+ if isinstance(picked, dict):
+ return picked
+ project, workspace = picked
+ session = await self.registry.activate(workspace["id"])
+ await self._announce(
+ lambda: workspace_changed_event(
+ session, "activated", source_layer="agentic_ide.orchestration"
+ )
+ )
+ return {"status": "shown", "project": project["name"], "workspace": workspace["name"]}
+ if action == "restore":
+ closed = [
+ (p, w) for p in graph["projects"] for w in p["workspaces"] if w["status"] != "open"
+ ]
+ ref = str(args.get("workspace_id") or args.get("workspace") or "")
+ matched = (
+ _best(ref, closed, lambda pw: ((pw[1]["id"],), (pw[1]["name"],))) if ref else []
+ )
+ if len(matched) != 1:
+ return {
+ "status": "needs_clarification",
+ "kind": "workspace",
+ "reason": "Name one closed workspace to restore.",
+ "candidates": [
+ {"workspace_id": w["id"], "workspace": w["name"], "project": p["name"]}
+ for p, w in (matched or closed)
+ ],
+ }
+ try:
+ session = await self.registry.restore_workspace(matched[0][1]["id"])
+ except SessionError as exc:
+ return {"status": "not_accepted", "reason": str(exc)}
+ await self._announce(
+ lambda: workspace_changed_event(
+ session, "restored", source_layer="agentic_ide.orchestration"
+ )
+ )
+ return {
+ "status": "restored",
+ "workspace_id": session.id,
+ "workspace": session.name,
+ "agents": [t.name for t in session.terminals],
+ }
+ # open_workspace: a folder by path, or a known project by name.
+ folder = str(args.get("folder") or "").strip()
+ project_id: str | None = None
+ project_ref = str(args.get("project") or "").strip()
+ if not folder and project_ref:
+ owners = _best(
+ project_ref, graph["projects"], lambda p: ((p["id"], p["path"]), (p["name"],))
+ )
+ if len(owners) == 1:
+ folder, project_id = owners[0]["path"], owners[0]["id"]
+ if not folder:
+ return {
+ "status": "needs_clarification",
+ "kind": "folder",
+ "reason": (
+ "Give the folder's absolute path or a known project. To start in a folder "
+ "that does not exist yet, create it first (find-app-action 'create folder')."
+ ),
+ "candidates": [
+ {"project": p["name"], "folder": p["path"]} for p in graph["projects"]
+ ],
+ }
+ groups = self._groups(args)
+ if isinstance(groups, dict):
+ return groups
+ requested = [{"agent": cli} for cli, count in groups for _ in range(count)]
+ if len(requested) > MAX_TERMINALS:
+ return {
+ "status": "not_accepted",
+ "reason": f"A workspace holds at most {MAX_TERMINALS} terminals.",
+ }
+ try:
+ session = await self.registry.start(
+ folder,
+ requested,
+ project_id=project_id,
+ name=str(args.get("name") or "").strip() or None,
+ )
+ except SessionError as exc:
+ return {"status": "not_accepted", "reason": str(exc), "folder": folder}
+ await self._announce(
+ lambda: workspace_changed_event(
+ session, "opened", source_layer="agentic_ide.orchestration"
+ )
+ )
+ result: dict[str, Any] = {
+ "status": "opened",
+ "project_id": session.project_id,
+ "workspace_id": session.id,
+ "workspace": session.name,
+ "folder": session.folder,
+ "agents": [
+ {"terminal_id": "pane:" + t.history_id, "name": t.name, "cli": t.agent}
+ for t in session.terminals
+ ],
+ }
+ prompt = str(args.get("prompt") or "").strip()
+ if prompt:
+ result["deliveries"] = await self._brief(
+ [
+ {
+ "project_id": session.project_id,
+ "workspace_id": session.id,
+ "terminal_id": "pane:" + t.history_id,
+ }
+ for t in session.terminals
+ ],
+ prompt,
+ trace_id,
+ )
+ return result
+
+ @staticmethod
+ def _groups(args: dict[str, Any]) -> list[tuple[str | None, int]] | dict[str, Any]:
+ """``agents: [{cli, count}]`` (or one ``cli``/``count``) as (CLI, count) pairs.
+
+ "Five Claude Code and three Codex" is one request; each group keeps the
+ CLI as spoken until ``_coding_cli`` names the pane's real CLI.
+ """
+ raw = args.get("agents")
+ entries = raw if isinstance(raw, list) and raw else [args]
+ groups: list[tuple[str | None, int]] = []
+ for entry in entries:
+ if not isinstance(entry, dict):
+ continue
+ spoken = str(entry.get("cli") or "").strip()
+ cli = _coding_cli(spoken) if spoken else _default_cli()
+ if cli is None:
+ from jarvis.workspace import agents as workspace_agents
+
+ return {
+ "status": "needs_clarification",
+ "kind": "cli",
+ "reason": f"'{spoken}' is not a coding CLI this app can open.",
+ "candidates": [
+ a.name for a in workspace_agents.coding_agents() if accepts_prompts(a.name)
+ ],
+ }
+ try:
+ count = int(entry.get("count") or 1)
+ except (TypeError, ValueError):
+ count = 1
+ groups.append((cli, max(1, min(count, MAX_TERMINALS))))
+ return groups or [(_default_cli(), 1)]
+
+ async def _brief(
+ self, targets: list[dict[str, str]], prompt: str, trace_id: str
+ ) -> list[dict[str, Any]]:
+ return list(
+ await asyncio.gather(
+ *(
+ self.run(
+ {
+ "action": "send",
+ **target,
+ "request_id": self._issue(target),
+ "prompt": prompt,
+ },
+ trace_id=trace_id,
+ )
+ for target in targets
+ )
+ )
+ )
+
@staticmethod
def _choice(
kind: str, choices: list[dict], graph: dict[str, Any], *, unmatched: str = ""
@@ -490,22 +826,32 @@ class WorkspaceOrchestrator:
for rid, (target, at, sent) in issued.items()
if _distance(given["terminal_id"], target["terminal_id"]) <= _NEAR_MISS
]
- retry = [(at, rid) for at, rid, sent in same_pane if sent and sent == prompt]
+ now = time.monotonic()
+ retry = [
+ (at, rid)
+ for at, rid, sent in same_pane
+ if sent and sent == prompt and now - at <= _RETRY_WINDOW_S
+ ]
fresh = [(at, rid) for at, rid, sent in same_pane if not sent or action != "send"]
if retry or fresh:
match = max(retry or fresh)[1]
if not match:
return given, request_id
- target, _, sent = issued[match]
- if action == "send" and sent and sent != prompt:
+ target, at, sent = issued[match]
+ if (
+ action == "send"
+ and sent
+ and (sent != prompt or time.monotonic() - at > _RETRY_WINDOW_S)
+ ):
return dict(target), ""
return dict(target), match
def _mark_sent(self, request_id: str, prompt: str) -> None:
+ """Record what went out under ``request_id``; its clock now dates the send."""
with self._issued_lock:
if request_id in self._issued:
- target, at, _ = self._issued[request_id]
- self._issued[request_id] = (target, at, prompt)
+ target, _, _ = self._issued[request_id]
+ self._issued[request_id] = (target, time.monotonic(), prompt)
async def run(self, args: dict[str, Any], *, trace_id: str = "") -> dict[str, Any]:
action = args.get("action")
@@ -514,6 +860,10 @@ class WorkspaceOrchestrator:
return graph if action == "inspect" else self.resolve(args, graph)
if action == "create":
return await self.create(args, trace_id=trace_id)
+ if action in _PANE_ACTIONS:
+ return await self.pane_action(args)
+ if action in _WORKSPACE_ACTIONS:
+ return await self.workspace_action(args, trace_id=trace_id)
if action not in {"send", "context"}:
raise ValueError("Unknown workspace orchestration action.")
target, request_id = self._reconcile(args, action)
@@ -527,9 +877,10 @@ class WorkspaceOrchestrator:
if not prompt:
raise ValueError("Sending requires a prompt.")
if not _is_request_id(request_id):
- # Nothing usable to key on: derive a key so a retry of this
- # same task within ten minutes still cannot deliver twice.
- seed = f"{terminal_id}\n{prompt}\n{int(time.time() // 600)}"
+ # Nothing usable to key on: derive a key so an immediate retry
+ # of this same task cannot deliver twice, while the same words
+ # sent again minutes later are a new instruction.
+ seed = f"{terminal_id}\n{prompt}\n{int(time.time() // _RETRY_WINDOW_S)}"
request_id = hashlib.sha256(seed.encode("utf-8")).hexdigest()[:32]
self._mark_sent(request_id, prompt)
previous = await asyncio.to_thread(
diff --git a/jarvis/brain/workspace_tool.py b/jarvis/brain/workspace_tool.py
index e0a57bcf5d..66e6683df1 100644
--- a/jarvis/brain/workspace_tool.py
+++ b/jarvis/brain/workspace_tool.py
@@ -18,6 +18,15 @@ class WorkspaceOrchestrationTool:
"Claude Code agents in the VMs workspace'), call create: it opens count new panes of "
"the named cli in the named or visible workspace and, with prompt, hands each the "
"task. Never reuse an existing agent and never use spawn_worker for that. "
+ "Mixed CLIs in one request ('five Claude Code and three Codex') go in agents: "
+ "[{cli, count}, ...]. open_workspace opens a NEW workspace for folder (absolute "
+ "path) or a known project, with agents and an optional prompt; restore reopens a "
+ "closed workspace; show brings one on screen. For one pane (by agent call-sign or "
+ "terminal_id): observe reads its screen, question and newest events; respond types "
+ "the answer to the question or permission prompt it shows (prompt = the answer); keys "
+ "presses keys such as enter, escape, up/down, digits, shift+tab (permission mode); "
+ "interrupt stops its current turn; close removes it. These are the user's own app "
+ "actions: run them when asked, without asking back. "
"Inspect the current graph; "
"resolve explicit project/workspace/agent references (names or IDs) before sending. "
"With no named workspace resolve uses the visible workspace, and selects an idle agent "
@@ -37,7 +46,21 @@ class WorkspaceOrchestrationTool:
"properties": {
"action": {
"type": "string",
- "enum": ["inspect", "resolve", "send", "context", "create"],
+ "enum": [
+ "inspect",
+ "resolve",
+ "send",
+ "context",
+ "create",
+ "open_workspace",
+ "restore",
+ "show",
+ "observe",
+ "respond",
+ "keys",
+ "interrupt",
+ "close",
+ ],
},
**{
key: {"type": "string"}
@@ -73,7 +96,32 @@ class WorkspaceOrchestrationTool:
},
"name": {
"type": "string",
- "description": "create: optional name for a single new agent.",
+ "description": (
+ "create: optional name for a single new agent; open_workspace: the new "
+ "workspace's tab name."
+ ),
+ },
+ "agents": {
+ "type": "array",
+ "maxItems": 8,
+ "description": "create/open_workspace: several CLIs at once, one entry per CLI.",
+ "items": {
+ "type": "object",
+ "properties": {
+ "cli": {"type": "string"},
+ "count": {"type": "integer", "minimum": 1, "maximum": 16},
+ },
+ },
+ },
+ "folder": {
+ "type": "string",
+ "description": "open_workspace: absolute path of the folder to open.",
+ },
+ "keys": {
+ "type": "array",
+ "maxItems": 10,
+ "description": "keys: e.g. ['down', 'enter'] or ['shift+tab'].",
+ "items": {"type": "string"},
},
},
"required": ["action"],
@@ -83,7 +131,8 @@ class WorkspaceOrchestrationTool:
self.gateway = gateway
def risk_tier_for_args(self, args: dict) -> str:
- return "safe" if args.get("action") in {"inspect", "resolve", "context"} else "monitor"
+ reads = {"inspect", "resolve", "context", "observe"}
+ return "safe" if args.get("action") in reads else "monitor"
def describe_args(self, args: dict) -> dict:
return {
diff --git a/jarvis/live/tools.py b/jarvis/live/tools.py
index e271d7cf4d..770bb37396 100644
--- a/jarvis/live/tools.py
+++ b/jarvis/live/tools.py
@@ -20,7 +20,6 @@ log = logging.getLogger(__name__)
# A session.started event includes its declarations. Keep room for prompts and
# history inside the 64 KiB message limit of smaller WebRTC clients.
_CATALOG_BYTE_BUDGET = 24_000
-_DISCOVERY_PAGE_SIZE = 8
_BUILTIN_TOOLS = frozenset({"discover_tools", "call_tool", "confirm_action", "end_call"})
# An approval is a short answer made only of go-ahead words: "Ja, send ihn"
# approves (refused live 2026-10-01 by an exact-phrase list), while "yes,
@@ -41,6 +40,8 @@ _GO_AHEAD_WORDS = frozenset(
}
) # fmt: skip
_APPROVAL_LOCALES = ("de", "en", "es")
+# Declared before every other tool so the size budget never drops them.
+_PRIORITY_TOOLS = frozenset({"workspace-orchestrate", "find-app-action", "run-app-action"})
_APPROVAL_NEXT_STEP = (
"Ask the user to approve this action. After an explicit yes, call confirm_action "
"directly (not through call_tool) with this approval_id. A yes is never a hang-up."
@@ -169,7 +170,11 @@ class LiveTools:
return definitions
# Count alone is insufficient: an imported tool may carry a large schema.
used_bytes = _wire_size(definitions)
- for descriptor in sorted(self.catalog(), key=lambda d: d.name):
+ # The tools that steer the app itself go first: sorted by name alone,
+ # workspace-orchestrate fell past the budget and voice could not open
+ # or brief a coding agent (live 2026-10-01).
+ ordered = sorted(self.catalog(), key=lambda d: (d.name not in _PRIORITY_TOOLS, d.name))
+ for descriptor in ordered:
alias = "jarvis_" + hashlib.sha256(descriptor.name.encode()).hexdigest()[:20]
definition = {
"type": "function",
@@ -268,35 +273,16 @@ class LiveTools:
self.end_requested = True
return {"success": True, "status": "closing_voice"}
if name == "discover_tools":
- if self._defer_catalog:
- from jarvis.live.discovery import discover
-
- return discover(
- self.catalog(), str(args.get("query", "")), int(args.get("offset", 0))
- )
- query = str(args.get("query", "")).casefold().split()
- matches = [
- d
- for d in sorted(self.catalog(), key=lambda d: d.name)
- if all(word in (d.name + " " + d.description).casefold() for word in query)
- ]
- offset = max(0, int(args.get("offset", 0)))
- page: list[dict] = []
- for descriptor in matches[offset : offset + _DISCOVERY_PAGE_SIZE]:
- item = {
- "name": descriptor.name,
- "description": descriptor.description,
- "parameters": descriptor.input_schema,
- }
- if page and _wire_size([*page, item]) > _CATALOG_BYTE_BUDGET:
- break
- page.append(item)
- next_offset = offset + len(page)
- return {
- "tools": page,
- "total": len(matches),
- "next_offset": next_offset if next_offset < len(matches) else None,
- }
+ # One ranked search for every provider. The native path's old rule
+ # (every query word in one tool) found nothing for "die Jarvis
+ # Agenten" and Jarvis told the user they did not exist (2026-09-20).
+ from jarvis.live.discovery import discover
+
+ try:
+ offset = max(0, int(args.get("offset") or 0))
+ except (TypeError, ValueError):
+ offset = 0
+ return discover(self.catalog(), str(args.get("query", "")), offset)
if name == "confirm_action":
approval_id = str(args.get("approval_id", ""))
if approval_id not in self._pending and len(self._pending) == 1:
@@ -305,7 +291,16 @@ class LiveTools:
approval_id = next(iter(self._pending))
pending = self._pending.get(approval_id)
if pending is None or self.revision <= pending[3] or not self._user_approved():
- return {"success": False, "error": "This action has not been explicitly approved."}
+ # Say why, or the model asks the same question again and again.
+ return {
+ "success": False,
+ "error": "This action has not been explicitly approved.",
+ "reason": "no pending approval"
+ if pending is None
+ else "the user's latest words are not a plain yes",
+ "approval_ids": list(self._pending),
+ "next_step": "Ask for a plain yes or no, then call confirm_action again.",
+ }
trace, _, _, _ = self._pending.pop(approval_id)
from jarvis.core.model_selection import ModelSelection, use_operation_model
@@ -318,9 +313,17 @@ class LiveTools:
canonical = self._names.get(name, name)
if name == "call_tool":
canonical = str(args.get("name", ""))
- args = json.loads(args.get("arguments_json", "{}"))
+ try:
+ args = json.loads(args.get("arguments_json") or "{}")
+ except ValueError:
+ args = None
if not isinstance(args, dict):
- return {"success": False, "error": "Tool arguments must be an object."}
+ return {
+ "success": False,
+ "executed": False,
+ "retryable": True,
+ "error": "arguments_json must be a JSON object. Correct it and call again.",
+ }
descriptor = next((d for d in self.catalog() if d.name == canonical), None)
if descriptor is None:
return {
diff --git a/tests/contract/test_gpt_live.py b/tests/contract/test_gpt_live.py
index 5d8773cb02..0a4ff3f75f 100644
--- a/tests/contract/test_gpt_live.py
+++ b/tests/contract/test_gpt_live.py
@@ -1096,3 +1096,32 @@ async def test_live_usage_keeps_the_calls_model_after_a_settings_change(ledger):
assert ledger._db.execute("SELECT model FROM live_backend_usage").fetchone() == (
"starting-model",
)
+
+
+async def test_native_tool_search_ranks_instead_of_requiring_every_word(ledger):
+ # 2026-09-20: "die Jarvis Agenten" found nothing on the native path because
+ # every query word had to occur in one tool; Jarvis said none existed.
+ runtime = LiveTools(Gateway(), ledger, "s", language="en", backend_model="")
+ runtime.declarations()
+ result = await runtime.execute("d", "discover_tools", {"query": "please write the file"}, 0)
+ assert [tool["name"] for tool in result["tools"]] == ["write-file"]
+
+
+def test_steering_tools_are_declared_before_the_size_budget_runs_out(ledger):
+ class Crowded(Gateway):
+ def catalog(self):
+ filler = tuple(
+ SupervisorToolDescriptor(
+ f"a-tool-{index:02d}", "x" * 900, {"type": "object"}, "safe"
+ )
+ for index in range(60)
+ )
+ steering = SupervisorToolDescriptor(
+ "workspace-orchestrate", "Route coding tasks", {"type": "object"}, "monitor"
+ )
+ return (*filler, steering)
+
+ runtime = LiveTools(Crowded(), ledger, "s", language="en", backend_model="")
+ declared = runtime.declarations()
+ assert "workspace-orchestrate" in {runtime._names.get(d["name"]) for d in declared}
diff --git a/tests/contract/test_workspace_orchestration.py b/tests/contract/test_workspace_orchestration.py
index ffd80bdbae..4843c8522d 100644
--- a/tests/contract/test_workspace_orchestration.py
+++ b/tests/contract/test_workspace_orchestration.py
@@ -34,6 +34,8 @@ class Sessions:
raise SessionError("The selected coding agent is busy; nothing was sent.")
if self.fail:
raise RuntimeError("transport interrupted after possible write")
+ if args["action"] in {"input", "observe"}:
+ return {"input_token": "token-1", "response_mode": "dialog", "screen_excerpt": "?"}
return {"delivery": "accepted", "submitted": True, "completed": False}
@@ -436,3 +438,123 @@ def test_create_is_a_logged_action_with_a_valid_live_schema(rig):
jsonschema.validate(args, tool.schema)
assert tool.risk_tier_for_args(args) == "monitor"
assert tool.describe_args(args)["agent"] == "3 new Codex"
+
+
+async def test_mixed_clis_open_in_one_call(rig, runnable):
+ # The maintainer's benchmark: "five Claude Code and three Codex" at once.
+ orchestrator, registry, _ = rig
+ owner = registry.sessions[0]
+ before = len(owner.terminals)
+ result = await orchestrator.run(
+ {
+ "action": "create",
+ "workspace": "Personal Jarvis",
+ "agents": [{"cli": "Claude Code", "count": 5}, {"cli": "Codex", "count": 3}],
+ }
+ )
+ assert result["status"] == "created", result
+ assert [a["cli"] for a in result["agents"]] == ["claude"] * 5 + ["codex"] * 3
+ assert len(owner.terminals) == before + 8
+
+
+async def test_open_workspace_creates_a_new_workspace_with_mixed_agents(rig, runnable, tmp_path):
+ orchestrator, registry, _ = rig
+ folder = tmp_path / "Fresh"
+ folder.mkdir()
+ published = []
+
+ async def publish(event):
+ published.append(event)
+
+ orchestrator.publish = publish
+ result = await orchestrator.run(
+ {
+ "action": "open_workspace",
+ "folder": str(folder),
+ "agents": [{"cli": "claude", "count": 2}, {"cli": "codex", "count": 1}],
+ }
+ )
+ assert result["status"] == "opened", result
+ assert [a["cli"] for a in result["agents"]] == ["claude", "claude", "codex"]
+ assert registry.get(result["workspace_id"]) is not None
+ assert published
+
+
+async def test_open_workspace_without_a_folder_lists_known_projects(rig):
+ result = await rig[0].run({"action": "open_workspace"})
+ assert result["status"] == "needs_clarification" and result["kind"] == "folder"
+ assert {c["project"] for c in result["candidates"]} == {"Personal Jarvis", "Other project"}
+
+
+async def test_respond_answers_the_question_a_pane_shows(rig):
+ orchestrator, registry, sessions = rig
+ name = registry.sessions[0].terminals[0].name
+ result = await orchestrator.run(
+ {"action": "respond", "workspace": "Personal Jarvis", "agent": name, "prompt": "1"}
+ )
+ assert result["status"] == "accepted", result
+ respond = sessions.calls[-1]
+ assert respond["action"] == "respond" and respond["prompt"] == "1"
+ assert respond["input_token"] == "token-1" and respond["response_mode"] == "dialog" # noqa: S105 - a fake input token
+
+
+async def test_keys_and_interrupt_press_only_whitelisted_keys(rig, monkeypatch):
+ orchestrator, registry, _ = rig
+ pressed = []
+ monkeypatch.setattr(
+ registry, "write", lambda key, data, workspace_id=None: pressed.append(data) or True
+ )
+ owner = registry.sessions[0]
+ args = {"workspace": "Personal Jarvis", "agent": owner.terminals[0].name}
+ assert (await orchestrator.run({"action": "keys", **args, "keys": ["down", "enter"]}))[
+ "status"
+ ] == "pressed"
+ assert (await orchestrator.run({"action": "interrupt", **args}))["status"] == "pressed"
+ assert pressed == ["\x1b[B", "\r", "\x1b"]
+ refused = await orchestrator.run({"action": "keys", **args, "keys": ["rm -rf /"]})
+ assert refused["status"] == "not_accepted"
+ assert len(pressed) == 3
+
+
+async def test_close_removes_one_named_pane(rig):
+ orchestrator, registry, _ = rig
+ owner = registry.sessions[0]
+ owner.terminals.append(Terminal("t2", "Nova", "codex", "Codex", 1, status="live"))
+ result = await orchestrator.run(
+ {"action": "close", "workspace": "Personal Jarvis", "agent": "Nova"}
+ )
+ assert result["status"] == "closed", result
+ assert [t.name for t in owner.terminals] == ["Alex"]
+
+
+async def test_show_brings_a_background_workspace_on_screen(rig):
+ orchestrator, registry, _ = rig
+ background = next(s for s in registry.sessions if s.id != registry.active_id)
+ result = await orchestrator.run({"action": "show", "workspace": background.name})
+ assert result["status"] == "shown", result
+ assert registry.active_id == background.id
+
+
+async def test_the_same_words_later_are_a_new_instruction(rig):
+ from jarvis.agentic_ide import orchestration
+
+ resolved = await target(rig)
+ args = {"action": "send", **resolved, "prompt": "continue"}
+ assert (await rig[0].run(args))["status"] == "accepted"
+ assert (await rig[0].run(args))["status"] == "accepted"
+ assert len(rig[2].calls) == 1 # an immediate repeat is a retry
+ issued = rig[0]._issued
+ for request_id, (pane, at, sent) in list(issued.items()):
+ issued[request_id] = (pane, at - orchestration._RETRY_WINDOW_S - 1, sent)
+ assert (await rig[0].run(args))["status"] == "accepted"
+ assert len(rig[2].calls) == 2
+
+
+def test_pane_reads_are_safe_and_every_new_action_validates(rig):
+ import jsonschema
+
+ tool = WorkspaceOrchestrationTool(rig[0])
+ assert tool.risk_tier_for_args({"action": "observe"}) == "safe"
+ for action in ("respond", "keys", "interrupt", "close", "open_workspace", "restore", "show"):
+ jsonschema.validate({"action": action}, tool.schema)
+ assert tool.risk_tier_for_args({"action": action}) == "monitor"