delos-cli 5.9.74__tar.gz → 5.9.78__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. {delos_cli-5.9.74 → delos_cli-5.9.78}/PKG-INFO +1 -1
  2. delos_cli-5.9.78/delos_cli/_build.json +5 -0
  3. delos_cli-5.9.78/delos_cli/commands/catalogue.py +36 -0
  4. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/commands/sandbox.py +4 -9
  5. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/mcp/landing.py +4 -3
  6. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/sandbox/config.py +19 -1
  7. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/sandbox/core.py +11 -1
  8. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/serve/app.py +37 -0
  9. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/serve/rpc.py +179 -22
  10. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/serve/server.py +12 -10
  11. {delos_cli-5.9.74 → delos_cli-5.9.78}/pyproject.toml +1 -1
  12. {delos_cli-5.9.74 → delos_cli-5.9.78}/tests/mcp/test_remote.py +71 -0
  13. {delos_cli-5.9.74 → delos_cli-5.9.78}/tests/sandbox/test_config.py +19 -1
  14. delos_cli-5.9.78/tests/serve/test_edit_diagnostics.py +79 -0
  15. delos_cli-5.9.78/tests/test_command_catalogue.py +22 -0
  16. delos_cli-5.9.74/delos_cli/_build.json +0 -5
  17. {delos_cli-5.9.74 → delos_cli-5.9.78}/.gitignore +0 -0
  18. {delos_cli-5.9.74 → delos_cli-5.9.78}/README.md +0 -0
  19. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/__init__.py +0 -0
  20. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/__main__.py +0 -0
  21. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/agent/__init__.py +0 -0
  22. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/agent/session.py +0 -0
  23. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/agent/tools.py +0 -0
  24. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/agent/transport.py +0 -0
  25. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/agent/turn.py +0 -0
  26. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/apps/__init__.py +0 -0
  27. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/apps/base.py +0 -0
  28. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/apps/chat/__init__.py +0 -0
  29. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/apps/chat/app.py +0 -0
  30. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/apps/chat/commands.py +0 -0
  31. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/apps/chat/render.py +0 -0
  32. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/apps/chat/rewind.py +0 -0
  33. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/apps/replay.py +0 -0
  34. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/auth/__init__.py +0 -0
  35. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/auth/config.py +0 -0
  36. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/auth/mfa.py +0 -0
  37. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/auth/oauth.py +0 -0
  38. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/auth/token_manager.py +0 -0
  39. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/checkpoints.py +0 -0
  40. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/commands/__init__.py +0 -0
  41. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/commands/base.py +0 -0
  42. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/commands/builtin.py +0 -0
  43. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/commands/mcp.py +0 -0
  44. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/commands/permissions.py +0 -0
  45. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/commands/prompts.py +0 -0
  46. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/context_report.py +0 -0
  47. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/ctx.py +0 -0
  48. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/file_state.py +0 -0
  49. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/git_context.py +0 -0
  50. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/hooks.py +0 -0
  51. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/loop.py +0 -0
  52. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/main.py +0 -0
  53. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/mcp/__init__.py +0 -0
  54. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/mcp/client.py +0 -0
  55. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/mcp/config.py +0 -0
  56. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/mcp/handlers.py +0 -0
  57. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/mcp/manager.py +0 -0
  58. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/mcp/remote.py +0 -0
  59. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/mcp/state.py +0 -0
  60. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/permissions.py +0 -0
  61. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/project_context.py +0 -0
  62. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/public_key.py +0 -0
  63. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/sandbox/__init__.py +0 -0
  64. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/sandbox/approval.py +0 -0
  65. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/sandbox/bwrap.py +0 -0
  66. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/sandbox/denial.py +0 -0
  67. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/sandbox/platform.py +0 -0
  68. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/sandbox/policy.py +0 -0
  69. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/sandbox/seatbelt.py +0 -0
  70. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/sandbox/seatbelt.sbpl +0 -0
  71. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/sandbox/seatbelt_network.sbpl +0 -0
  72. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/sentry_identity.py +0 -0
  73. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/serve/__init__.py +0 -0
  74. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/serve/confirm.py +0 -0
  75. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/serve/protocol.py +0 -0
  76. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/settings.py +0 -0
  77. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/skills.py +0 -0
  78. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/state.py +0 -0
  79. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/telemetry.py +0 -0
  80. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/tool_output.py +0 -0
  81. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/tools/__init__.py +0 -0
  82. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/tools/ask_user_input.py +0 -0
  83. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/tools/edit_content.py +0 -0
  84. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/tools/explore.py +0 -0
  85. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/tools/glob_tool.py +0 -0
  86. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/tools/grep.py +0 -0
  87. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/tools/read.py +0 -0
  88. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/tools/run_shell.py +0 -0
  89. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/tools/task.py +0 -0
  90. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/tools/todo_write.py +0 -0
  91. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/tools/verify.py +0 -0
  92. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/tools/write_content.py +0 -0
  93. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/transport/__init__.py +0 -0
  94. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/transport/chats.py +0 -0
  95. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/transport/client.py +0 -0
  96. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/transport/conversation_rows.py +0 -0
  97. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/transport/documents.py +0 -0
  98. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/transport/integrations.py +0 -0
  99. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/transport/models.py +0 -0
  100. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/ui/__init__.py +0 -0
  101. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/ui/banner.py +0 -0
  102. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/ui/chat_picker.py +0 -0
  103. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/ui/collapse.py +0 -0
  104. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/ui/completer.py +0 -0
  105. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/ui/lexer.py +0 -0
  106. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/ui/model_picker.py +0 -0
  107. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/ui/output.py +0 -0
  108. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/ui/repl.py +0 -0
  109. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/ui/style.py +0 -0
  110. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/update.py +0 -0
  111. {delos_cli-5.9.74 → delos_cli-5.9.78}/delos_cli/usage_report.py +0 -0
  112. {delos_cli-5.9.74 → delos_cli-5.9.78}/tests/__init__.py +0 -0
  113. {delos_cli-5.9.74 → delos_cli-5.9.78}/tests/agent/__init__.py +0 -0
  114. {delos_cli-5.9.74 → delos_cli-5.9.78}/tests/agent/test_hooks.py +0 -0
  115. {delos_cli-5.9.74 → delos_cli-5.9.78}/tests/agent/test_steering.py +0 -0
  116. {delos_cli-5.9.74 → delos_cli-5.9.78}/tests/conftest.py +0 -0
  117. {delos_cli-5.9.74 → delos_cli-5.9.78}/tests/context/__init__.py +0 -0
  118. {delos_cli-5.9.74 → delos_cli-5.9.78}/tests/context/test_checkpoints.py +0 -0
  119. {delos_cli-5.9.74 → delos_cli-5.9.78}/tests/context/test_permissions.py +0 -0
  120. {delos_cli-5.9.74 → delos_cli-5.9.78}/tests/context/test_project_context.py +0 -0
  121. {delos_cli-5.9.74 → delos_cli-5.9.78}/tests/context/test_skills.py +0 -0
  122. {delos_cli-5.9.74 → delos_cli-5.9.78}/tests/mcp/__init__.py +0 -0
  123. {delos_cli-5.9.74 → delos_cli-5.9.78}/tests/mcp/fake_server.py +0 -0
  124. {delos_cli-5.9.74 → delos_cli-5.9.78}/tests/mcp/test_client.py +0 -0
  125. {delos_cli-5.9.74 → delos_cli-5.9.78}/tests/mcp/test_manager.py +0 -0
  126. {delos_cli-5.9.74 → delos_cli-5.9.78}/tests/sandbox/__init__.py +0 -0
  127. {delos_cli-5.9.74 → delos_cli-5.9.78}/tests/sandbox/test_approval.py +0 -0
  128. {delos_cli-5.9.74 → delos_cli-5.9.78}/tests/sandbox/test_bwrap.py +0 -0
  129. {delos_cli-5.9.74 → delos_cli-5.9.78}/tests/sandbox/test_denial.py +0 -0
  130. {delos_cli-5.9.74 → delos_cli-5.9.78}/tests/sandbox/test_integration.py +0 -0
  131. {delos_cli-5.9.74 → delos_cli-5.9.78}/tests/sandbox/test_platform.py +0 -0
  132. {delos_cli-5.9.74 → delos_cli-5.9.78}/tests/sandbox/test_policy.py +0 -0
  133. {delos_cli-5.9.74 → delos_cli-5.9.78}/tests/sandbox/test_seatbelt.py +0 -0
  134. {delos_cli-5.9.74 → delos_cli-5.9.78}/tests/serve/__init__.py +0 -0
  135. {delos_cli-5.9.74 → delos_cli-5.9.78}/tests/serve/test_confirm.py +0 -0
  136. {delos_cli-5.9.74 → delos_cli-5.9.78}/tests/serve/test_steer.py +0 -0
  137. {delos_cli-5.9.74 → delos_cli-5.9.78}/tests/test_chat_models.py +0 -0
  138. {delos_cli-5.9.74 → delos_cli-5.9.78}/tests/test_update.py +0 -0
  139. {delos_cli-5.9.74 → delos_cli-5.9.78}/tests/tools/__init__.py +0 -0
  140. {delos_cli-5.9.74 → delos_cli-5.9.78}/tests/tools/test_file_state.py +0 -0
  141. {delos_cli-5.9.74 → delos_cli-5.9.78}/tests/tools/test_run_shell.py +0 -0
  142. {delos_cli-5.9.74 → delos_cli-5.9.78}/tests/tools/test_tool_output.py +0 -0
  143. {delos_cli-5.9.74 → delos_cli-5.9.78}/tests/ui/__init__.py +0 -0
  144. {delos_cli-5.9.74 → delos_cli-5.9.78}/tests/ui/test_steering_keys.py +0 -0
  145. {delos_cli-5.9.74 → delos_cli-5.9.78}/tests/ui/test_transcript_view.py +0 -0
  146. {delos_cli-5.9.74 → delos_cli-5.9.78}/tests/ui/test_usage_report.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: delos-cli
3
- Version: 5.9.74
3
+ Version: 5.9.78
4
4
  Summary: Terminal REPL for the Delos agent — the Claude-Code-style CLI for Delos.
5
5
  Project-URL: Homepage, https://delos.so
6
6
  Project-URL: Repository, https://github.com/Delos-Intelligence/cosmos-saas
@@ -0,0 +1,5 @@
1
+ {
2
+ "release": "v5.9.78",
3
+ "sha": "3ac964bd82ba51836b333aab1b4b2086a9c0a5fd",
4
+ "version": "5.9.78"
5
+ }
@@ -0,0 +1,36 @@
1
+ """The CLI's command registry, exposed to editor clients without a second hard-coded list."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import TYPE_CHECKING, Any
6
+
7
+ from delos_cli.apps.chat.commands import CHAT_COMMANDS
8
+ from delos_cli.apps.chat.rewind import REWIND
9
+ from delos_cli.skills import skill_commands
10
+
11
+ from .builtin import GLOBAL_COMMANDS
12
+ from .prompts import PROMPT_COMMANDS
13
+
14
+ if TYPE_CHECKING:
15
+ from pathlib import Path
16
+
17
+
18
+ def command_catalogue(cwd: Path, home: Path) -> list[dict[str, Any]]:
19
+ """Describe the same built-ins, aliases and skills as the interactive chat CLI."""
20
+ builtins = {**GLOBAL_COMMANDS, **CHAT_COMMANDS, REWIND.name: REWIND}
21
+ skills = skill_commands(cwd, home, taken=set(builtins))
22
+ sends = {cmd["name"] for cmd in PROMPT_COMMANDS} | set(skills)
23
+ seen: set[str] = set()
24
+ rows: list[dict[str, Any]] = []
25
+ for spec in {**builtins, **skills}.values():
26
+ if spec.name in seen:
27
+ continue
28
+ seen.add(spec.name)
29
+ rows.append({
30
+ "name": spec.name,
31
+ "summary": spec.summary,
32
+ "aliases": list(spec.aliases),
33
+ "argsHint": spec.args_hint,
34
+ "kind": "send" if spec.name in sends else "local",
35
+ })
36
+ return rows
@@ -3,15 +3,16 @@
3
3
  from __future__ import annotations
4
4
 
5
5
  from pathlib import Path
6
- from typing import TYPE_CHECKING, Any
6
+ from typing import TYPE_CHECKING
7
7
 
8
8
  from rich.text import Text
9
9
 
10
10
  from delos_cli import sandbox
11
11
  from delos_cli.ctx import PickOption
12
+ from delos_cli.sandbox.config import update_sandbox_config
12
13
  from delos_cli.sandbox.platform import detect
13
14
  from delos_cli.sandbox.policy import build_policy
14
- from delos_cli.settings import settings_files, update_settings
15
+ from delos_cli.settings import settings_files
15
16
 
16
17
  from .base import CommandSpec
17
18
 
@@ -68,15 +69,9 @@ async def _handle_sandbox(ctx: Ctx, args: str) -> None:
68
69
  return
69
70
  key, value = change[picked]
70
71
 
71
- def _set(data: dict[str, Any]) -> None:
72
- section = data.get("sandbox")
73
- if not isinstance(section, dict):
74
- section = data["sandbox"] = {}
75
- section[key] = value
76
-
77
72
  local = next(f for f in settings_files(cwd) if f.scope == "local")
78
73
  try:
79
- update_settings(local, _set)
74
+ update_sandbox_config(cwd, {key: value})
80
75
  except OSError as e:
81
76
  sink.print(Text(f"could not save {local.path}: {e}", style="red"))
82
77
  return
@@ -55,10 +55,11 @@ def _response(status: str, body: bytes) -> bytes:
55
55
 
56
56
 
57
57
  @contextlib.asynccontextmanager
58
- async def landing_page(name: str) -> AsyncGenerator[Landing]:
58
+ async def landing_page(name: str, *, surface: str = "your terminal") -> AsyncGenerator[Landing]:
59
59
  """Serve the landing page for ``name``'s consent while the block runs."""
60
60
  landing = Landing(url="")
61
61
  label = html.escape(name)
62
+ destination = html.escape(surface)
62
63
 
63
64
  async def handle(reader: asyncio.StreamReader, writer: asyncio.StreamWriter) -> None:
64
65
  try:
@@ -77,14 +78,14 @@ async def landing_page(name: str) -> AsyncGenerator[Landing]:
77
78
  result_page(
78
79
  f"{label} connected",
79
80
  f"{label} is connected",
80
- "You can close this tab and return to your terminal.",
81
+ f"You can close this tab and return to {destination}.",
81
82
  ok=True,
82
83
  )
83
84
  if landing.outcome
84
85
  else result_page(
85
86
  "Connection failed",
86
87
  f"Could not connect {label}",
87
- "The authorization did not go through. Check the terminal and try again.",
88
+ f"The authorization did not go through. Return to {destination} and try again.",
88
89
  ok=False,
89
90
  )
90
91
  )
@@ -18,7 +18,7 @@ from dataclasses import dataclass, field
18
18
  from pathlib import Path
19
19
  from typing import Any
20
20
 
21
- from delos_cli.settings import project_root, read_settings, settings_files
21
+ from delos_cli.settings import project_root, read_settings, settings_files, update_settings
22
22
 
23
23
  from .policy import is_within, resolve
24
24
 
@@ -77,3 +77,21 @@ def load_sandbox_config(cwd: Path) -> SandboxConfig:
77
77
  required=values["required"],
78
78
  sources=sources,
79
79
  )
80
+
81
+
82
+ def update_sandbox_config(cwd: Path, changes: dict[str, bool]) -> None:
83
+ """Save user-selected options locally, preserving other settings (CLI and editor)."""
84
+ if not changes or any(
85
+ key not in {"enabled", "network"} or not isinstance(value, bool) for key, value in changes.items()
86
+ ):
87
+ msg = "sandbox options must be boolean enabled/network values"
88
+ raise ValueError(msg)
89
+
90
+ def _set(data: dict[str, Any]) -> None:
91
+ section = data.get("sandbox")
92
+ if not isinstance(section, dict):
93
+ section = data["sandbox"] = {}
94
+ section.update(changes)
95
+
96
+ local = next(file for file in settings_files(cwd) if file.scope == "local")
97
+ update_settings(local, _set)
@@ -32,7 +32,17 @@ class SandboxStatus:
32
32
 
33
33
  def asdict(self) -> dict[str, Any]:
34
34
  """For ``delos serve``'s ``ready`` message."""
35
- return {"state": self.state, "kind": self.kind, "network": self.network, "reason": self.reason}
35
+ availability = detect()
36
+ return {
37
+ "state": self.state,
38
+ "kind": self.kind,
39
+ "network": self.network,
40
+ "reason": self.reason,
41
+ "enabled": self.config.enabled,
42
+ "available": availability.kind is not None,
43
+ "availabilityReason": availability.reason,
44
+ "required": self.config.required,
45
+ }
36
46
 
37
47
  def turn_context(self) -> dict[str, Any]:
38
48
  """For the request body: rendered into the agent's ``<turn_context>``."""
@@ -10,6 +10,7 @@ bits tool handlers actually reach for: the :class:`ToolRegistry` and the
10
10
  from __future__ import annotations
11
11
 
12
12
  from dataclasses import dataclass, field
13
+ from pathlib import Path
13
14
  from typing import TYPE_CHECKING, Any, override
14
15
 
15
16
  from delos_cli.agent import ToolRegistry
@@ -36,6 +37,13 @@ VSCODE_FORWARDED_TOOLS: tuple[str, ...] = (
36
37
  "get_document_symbols",
37
38
  )
38
39
 
40
+ #: Editor request behind every successful edit (not a model tool): the edited
41
+ #: file's problems once the language servers have caught up with the write.
42
+ DIAGNOSTICS_AFTER_EDIT = "diagnostics_after_edit"
43
+
44
+ #: How ``edit_content`` / ``write_content`` report a write that landed.
45
+ _EDIT_SUCCESS_PREFIXES = ("Edited ", "Created ", "Wrote ")
46
+
39
47
 
40
48
  class HeadlessToolRegistry(ToolRegistry):
41
49
  """Registry whose fallback fails fast instead of prompting.
@@ -80,6 +88,33 @@ def _make_forwarding_handler(name: str) -> ToolHandler:
80
88
  return _handler
81
89
 
82
90
 
91
+ def _with_edit_diagnostics(handler: ToolHandler) -> ToolHandler:
92
+ """Append the edited file's editor problems to a successful edit's result.
93
+
94
+ Checking an edit used to cost the model a whole extra round-trip (an
95
+ edit, then a ``get_diagnostics`` call on its own). The editor answers
96
+ in well under the time of that round-trip, so the edit reports them
97
+ itself. An older extension that doesn't know the request (or a bridge
98
+ timeout) answers ``Error: …``: the edit result is then left as it was.
99
+ """
100
+
101
+ async def _handler(tool_input: dict[str, Any], ctx: Ctx) -> str:
102
+ result = await handler(tool_input, ctx)
103
+ forward = getattr(ctx.app, "forward_tool", None)
104
+ if forward is None or not result.startswith(_EDIT_SUCCESS_PREFIXES):
105
+ return result
106
+ # Same resolution as the handlers; no I/O worth offloading.
107
+ path = Path(str(tool_input.get("path") or "").strip()).expanduser() # noqa: ASYNC240
108
+ if not path.is_absolute():
109
+ path = Path.cwd() / path
110
+ problems = await forward(DIAGNOSTICS_AFTER_EDIT, {"path": str(path)})
111
+ if not problems or problems.startswith("Error"):
112
+ return result
113
+ return f"{result}\n\n{problems}"
114
+
115
+ return _handler
116
+
117
+
83
118
  async def _handle_ask_user_input_serve(tool_input: dict[str, Any], ctx: Ctx) -> str:
84
119
  """Relay ``ask_user_input`` to the frontend and await the user's answers.
85
120
 
@@ -110,6 +145,8 @@ def _headless_registry() -> HeadlessToolRegistry:
110
145
  reg = default_tool_registry()
111
146
  for name in VSCODE_FORWARDED_TOOLS:
112
147
  reg.handlers[name] = _make_forwarding_handler(name)
148
+ for name in ("edit_content", "write_content"):
149
+ reg.handlers[name] = _with_edit_diagnostics(reg.handlers[name])
113
150
  # The REPL's ``ask_user_input`` handler drives an in-terminal wizard via
114
151
  # ``ctx.ask_user_input`` (unset in headless mode). Swap it for a handler
115
152
  # that forwards the questions to the extension's webview form instead.
@@ -17,8 +17,14 @@ from pathlib import Path
17
17
  from typing import TYPE_CHECKING, Any
18
18
  from urllib.parse import urlencode
19
19
 
20
+ from delos_cli import sandbox
20
21
  from delos_cli.checkpoints import history_for
22
+ from delos_cli.mcp.landing import Landing, landing_page
21
23
  from delos_cli.mcp.remote import REMOTE_PREFIX, remote_rows, remove, start_connect, wait_and_enable
24
+ from delos_cli.permissions import forget, rules
25
+ from delos_cli.sandbox.config import update_sandbox_config
26
+ from delos_cli.sandbox.policy import build_policy
27
+ from delos_cli.transport.chats import delete_messages_from, fetch_rewind_points
22
28
  from delos_cli.transport.chats import fork_chat as _fork_chat
23
29
  from delos_cli.transport.documents import list_drive_documents as _list_drive_documents
24
30
  from delos_cli.transport.integrations import (
@@ -136,11 +142,69 @@ async def find_files(server: StdioServer, params: dict[str, Any]) -> list[str]:
136
142
  """
137
143
  query = str(params.get("query") or "").strip().lower()
138
144
  max_results = int(params.get("maxResults") or _FIND_FILES_DEFAULT_MAX)
145
+ workspace = server.workspace
146
+ worktrees = await _other_worktrees(workspace)
147
+ nested = [rel for rel in (_rel_inside(workspace, wt) for wt in worktrees) if rel]
148
+ primary = await _list_tree(workspace, nested)
149
+ results = _rank_paths(primary, query, max_results)
150
+ # Worktree files come second: they only fill what the workspace left over.
151
+ for wt in worktrees:
152
+ if len(results) >= max_results:
153
+ break
154
+ prefix = _rel_prefix(workspace, wt)
155
+ wt_paths = [f"{prefix}/{p}" for p in await _list_tree(wt, [])]
156
+ seen = set(results)
157
+ extra = [p for p in _rank_paths(wt_paths, query, max_results) if p not in seen]
158
+ results.extend(extra[: max_results - len(results)])
159
+ return results
160
+
161
+
162
+ async def _list_tree(root: Path, exclude: list[str]) -> list[str]:
139
163
  try:
140
- paths = await _rg_files(server.workspace)
164
+ return await _rg_files(root, exclude)
141
165
  except FileNotFoundError:
142
- paths = await asyncio.to_thread(_walk_files, server.workspace)
143
- return _rank_paths(paths, query, max_results)
166
+ return await asyncio.to_thread(_walk_files, root, exclude)
167
+
168
+
169
+ def _rel_inside(workspace: Path, other: Path) -> str | None:
170
+ try:
171
+ return other.resolve().relative_to(workspace.resolve()).as_posix()
172
+ except ValueError:
173
+ return None
174
+
175
+
176
+ async def _other_worktrees(workspace: Path) -> list[Path]:
177
+ """Linked git worktrees of the workspace's repository, excluding the workspace itself."""
178
+ try:
179
+ proc = await asyncio.create_subprocess_exec(
180
+ "git",
181
+ "worktree",
182
+ "list",
183
+ "--porcelain",
184
+ cwd=workspace,
185
+ stdout=asyncio.subprocess.PIPE,
186
+ stderr=asyncio.subprocess.DEVNULL,
187
+ )
188
+ stdout, _ = await asyncio.wait_for(proc.communicate(), _FIND_FILES_TIMEOUT_S)
189
+ except FileNotFoundError, TimeoutError, OSError:
190
+ return []
191
+ return await asyncio.to_thread(_parse_worktrees, stdout.decode(errors="replace"), workspace)
192
+
193
+
194
+ def _rel_prefix(workspace: Path, other: Path) -> str:
195
+ return Path(os.path.relpath(other, workspace)).as_posix()
196
+
197
+
198
+ def _parse_worktrees(porcelain: str, workspace: Path) -> list[Path]:
199
+ here = workspace.resolve()
200
+ found: list[Path] = []
201
+ for line in porcelain.splitlines():
202
+ if not line.startswith("worktree "):
203
+ continue
204
+ path = Path(line.removeprefix("worktree ").strip())
205
+ if path.is_dir() and path.resolve() != here and not here.is_relative_to(path.resolve()):
206
+ found.append(path)
207
+ return found
144
208
 
145
209
 
146
210
  def _is_subsequence(query: str, text: str) -> bool:
@@ -173,7 +237,7 @@ def _rank_paths(paths: list[str], query: str, max_results: int) -> list[str]:
173
237
  return [path for _, path in ranked[:max_results]]
174
238
 
175
239
 
176
- async def _rg_files(workspace: Path) -> list[str]:
240
+ async def _rg_files(workspace: Path, exclude: list[str]) -> list[str]:
177
241
  proc = await asyncio.create_subprocess_exec(
178
242
  "rg",
179
243
  "--files",
@@ -182,6 +246,7 @@ async def _rg_files(workspace: Path) -> list[str]:
182
246
  "!.git/",
183
247
  "-g",
184
248
  "!node_modules/",
249
+ *[arg for rel in exclude for arg in ("-g", f"!/{rel}/")],
185
250
  cwd=workspace,
186
251
  stdout=asyncio.subprocess.PIPE,
187
252
  stderr=asyncio.subprocess.DEVNULL,
@@ -194,19 +259,101 @@ async def _rg_files(workspace: Path) -> list[str]:
194
259
  return [line.strip() for line in stdout.decode(errors="replace").splitlines() if line.strip()]
195
260
 
196
261
 
197
- def _walk_files(workspace: Path) -> list[str]:
262
+ def _walk_files(workspace: Path, exclude: list[str]) -> list[str]:
198
263
  """rg-less fallback: walk the tree, skipping the usual heavyweight dirs."""
199
264
  skip_dirs = {".git", "node_modules", "__pycache__", ".venv", "dist"}
200
265
  found: list[str] = []
201
266
  for root, dirs, files in os.walk(workspace):
202
- dirs[:] = [d for d in dirs if d not in skip_dirs]
203
267
  rel_root = Path(root).relative_to(workspace)
268
+ dirs[:] = [d for d in dirs if d not in skip_dirs and (rel_root / d).as_posix() not in exclude]
204
269
  found.extend(str(rel_root / f) for f in files)
205
270
  if len(found) >= _WALK_FILES_CAP:
206
271
  break
207
272
  return found
208
273
 
209
274
 
275
+ async def get_sandbox(server: StdioServer, params: dict[str, Any]) -> dict[str, Any]: # noqa: RUF029 — RPC handler
276
+ """Live sandbox status, and the writable/protected paths shown by /sandbox."""
277
+ _ = params
278
+ current = sandbox.active(server.workspace)
279
+ result = current.asdict()
280
+ policy = build_policy(server.workspace, current.config)
281
+ result["writableRoots"] = [str(path) for path in policy.writable_roots]
282
+ result["protectedPaths"] = [str(path) for path in policy.protected]
283
+ return result
284
+
285
+
286
+ async def set_sandbox(server: StdioServer, params: dict[str, Any]) -> dict[str, Any]:
287
+ """Persist the explicit user's sandbox options, effective on the next command."""
288
+ if any(key not in {"enabled", "network"} for key in params):
289
+ msg = "unknown sandbox option"
290
+ raise ValueError(msg)
291
+ update_sandbox_config(server.workspace, params)
292
+ return await get_sandbox(server, {})
293
+
294
+
295
+ async def list_permissions(server: StdioServer, params: dict[str, Any]) -> list[dict[str, str]]: # noqa: RUF029 — RPC handler
296
+ """The same persisted and session-only Always approvals as CLI /permissions."""
297
+ _ = params
298
+ return [
299
+ {
300
+ "text": rule.text,
301
+ "scope": rule.file.scope if rule.file else "session",
302
+ "path": str(rule.file.path) if rule.file else "",
303
+ }
304
+ for rule in rules(server.workspace, server.always_allowed)
305
+ ]
306
+
307
+
308
+ async def remove_permission(server: StdioServer, params: dict[str, Any]) -> list[dict[str, str]]:
309
+ """Remove a currently listed rule, never an arbitrary client-supplied file."""
310
+ text = _required_str(params, "text")
311
+ scope = _required_str(params, "scope")
312
+ for rule in rules(server.workspace, server.always_allowed):
313
+ if rule.text == text and (rule.file.scope if rule.file else "session") == scope:
314
+ forget(rule, server.always_allowed)
315
+ return await list_permissions(server, {})
316
+ msg = "permission rule no longer exists — refresh the list"
317
+ raise ValueError(msg)
318
+
319
+
320
+ async def rewind_points(server: StdioServer, params: dict[str, Any]) -> list[dict[str, Any]]:
321
+ """Only live user turns can be rewound (compacted messages are excluded)."""
322
+ return await fetch_rewind_points(server.require_http(), _required_str(params, "chatId"))
323
+
324
+
325
+ async def rewind_chat(server: StdioServer, params: dict[str, Any]) -> dict[str, Any]:
326
+ """Restore code, conversation or both, without starting an agent turn."""
327
+ chat_id = _required_str(params, "chatId")
328
+ if chat_id in server.turns:
329
+ msg = "stop the running turn before rewinding"
330
+ raise ValueError(msg)
331
+ action = _required_str(params, "action")
332
+ if action not in {"both", "code", "conversation"}:
333
+ msg = "unknown rewind action"
334
+ raise ValueError(msg)
335
+ seq = params.get("seq")
336
+ if not isinstance(seq, int) or isinstance(seq, bool):
337
+ msg = "rewind seq must be an integer"
338
+ raise TypeError(msg)
339
+ points = await fetch_rewind_points(server.require_http(), chat_id)
340
+ point = next((point for point in points if point["seq"] == seq), None)
341
+ if point is None:
342
+ msg = "this message can no longer be rewound"
343
+ raise ValueError(msg)
344
+ restored: list[dict[str, str]] = []
345
+ if action in {"both", "code"}:
346
+ history = history_for(chat_id)
347
+ turns = history.turns_from(point["messageId"]) if point.get("messageId") else None
348
+ if turns is None:
349
+ msg = "no file checkpoint exists for this message"
350
+ raise ValueError(msg)
351
+ restored = [{"path": str(path), "action": operation} for path, operation in history.restore(turns)]
352
+ if action in {"both", "conversation"}:
353
+ await delete_messages_from(server.require_http(), chat_id, seq)
354
+ return {"content": point["content"], "restored": restored}
355
+
356
+
210
357
  async def list_models(server: StdioServer, params: dict[str, Any]) -> list[str] | list[dict[str, Any]]:
211
358
  """Models available to the signed-in user/org: ids, or with Gate's copy when ``locale`` is given."""
212
359
  locale = params.get("locale")
@@ -295,22 +442,32 @@ async def connect_integration(
295
442
  name = service.removeprefix(REMOTE_PREFIX)
296
443
  msg = f"unknown remote MCP server '{name}'"
297
444
  raise ValueError(msg)
298
- start = await start_connect(http, row)
299
- if start.url is not None:
300
- with contextlib.suppress(webbrowser.Error):
301
- webbrowser.open(start.url)
302
- server.spawn(_enable_when_connected(server, start.server_id))
303
- return {"service": f"mcp:{start.server_id}", "url": start.url}
304
-
305
-
306
- async def _enable_when_connected(server: StdioServer, server_id: str) -> None:
307
- try:
308
- connected = await wait_and_enable(server.require_http(), server_id)
309
- except Exception as e: # a background wait must not take the server down
310
- server.log(f"connect {server_id}: {e}")
311
- return
312
- if not connected:
313
- server.log(f"connect {server_id}: no authorization received")
445
+ async with contextlib.AsyncExitStack() as stack:
446
+ landing = await stack.enter_async_context(landing_page(row.name, surface="VSCode"))
447
+ start = await start_connect(http, row, return_to=landing.url)
448
+ if start.url is not None:
449
+ with contextlib.suppress(webbrowser.Error):
450
+ webbrowser.open(start.url)
451
+ # Keep the local confirmation page alive past the RPC response, until
452
+ # authorization completes (or fails/times out). The background task
453
+ # owns its cleanup, including when the serve process is shut down.
454
+ server.spawn(_enable_when_connected(server, start.server_id, stack.pop_all(), landing))
455
+ return {"service": f"mcp:{start.server_id}", "url": start.url}
456
+
457
+
458
+ async def _enable_when_connected(
459
+ server: StdioServer, server_id: str, stack: contextlib.AsyncExitStack, landing: Landing
460
+ ) -> None:
461
+ async with stack:
462
+ try:
463
+ connected = await wait_and_enable(
464
+ server.require_http(), server_id, gave_up=lambda: landing.outcome is False
465
+ )
466
+ except Exception as e: # a background wait must not take the server down
467
+ server.log(f"connect {server_id}: {e}")
468
+ return
469
+ if not connected:
470
+ server.log(f"connect {server_id}: {landing.error or 'no authorization received'}")
314
471
 
315
472
 
316
473
  async def remove_integration(
@@ -22,7 +22,8 @@ from delos_cli.agent.session import STEERS_UNSENT
22
22
  from delos_cli.auth import config as cfg_mod
23
23
  from delos_cli.auth.oauth import OAuthError, run_login_flow
24
24
  from delos_cli.checkpoints import history_for
25
- from delos_cli.commands.prompts import PROMPT_COMMANDS, expand_slash_command
25
+ from delos_cli.commands.catalogue import command_catalogue
26
+ from delos_cli.commands.prompts import expand_slash_command
26
27
  from delos_cli.context_report import fetch_context_report, format_report_markdown
27
28
  from delos_cli.ctx import ConfirmOutcome, Ctx
28
29
  from delos_cli.file_state import ReadLedger
@@ -30,7 +31,7 @@ from delos_cli.git_context import collect_git_context
30
31
  from delos_cli.mcp import McpManager, register_tools
31
32
  from delos_cli.permissions import remember
32
33
  from delos_cli.project_context import load_project_context
33
- from delos_cli.skills import discover_skills, expand_skill_command, skill_specs
34
+ from delos_cli.skills import expand_skill_command, skill_specs
34
35
  from delos_cli.state import PERMISSION_MODES, ReplState
35
36
  from delos_cli.transport.client import AuthedClient, TransportError
36
37
  from delos_cli.usage_report import fetch_usage, format_usage_markdown
@@ -679,15 +680,10 @@ class StdioServer:
679
680
  _ = params
680
681
  return self._auth_payload()
681
682
 
682
- async def _rpc_list_commands(self, params: dict[str, Any]) -> list[dict[str, str]]:
683
- """Slash commands the input can autocomplete (name + summary)."""
683
+ async def _rpc_list_commands(self, params: dict[str, Any]) -> list[dict[str, Any]]:
684
+ """The CLI's full command catalogue, including aliases and project skills."""
684
685
  _ = params
685
- skills = [
686
- {"name": f"/{s.name}", "summary": f"skill — {s.description}"}
687
- for s in discover_skills(self.workspace, Path.home())
688
- if all(cmd["name"] != f"/{s.name}" for cmd in PROMPT_COMMANDS)
689
- ]
690
- return [*(dict(cmd) for cmd in PROMPT_COMMANDS), *skills]
686
+ return command_catalogue(self.workspace, Path.home())
691
687
 
692
688
  async def _rpc_login(self, params: dict[str, Any]) -> dict[str, Any]:
693
689
  _ = params
@@ -785,6 +781,12 @@ _RPC_METHODS: dict[str, _RpcHandler] = {
785
781
  "restore_checkpoint": rpc.restore_checkpoint,
786
782
  "find_files": rpc.find_files,
787
783
  "list_models": rpc.list_models,
784
+ "get_sandbox": rpc.get_sandbox,
785
+ "set_sandbox": rpc.set_sandbox,
786
+ "list_permissions": rpc.list_permissions,
787
+ "remove_permission": rpc.remove_permission,
788
+ "rewind_points": rpc.rewind_points,
789
+ "rewind_chat": rpc.rewind_chat,
788
790
  "list_integrations": rpc.list_integrations,
789
791
  "toggle_integration": rpc.toggle_integration,
790
792
  "connect_integration": rpc.connect_integration,
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "delos-cli"
3
- version = "5.9.74"
3
+ version = "5.9.78"
4
4
  description = "Terminal REPL for the Delos agent — the Claude-Code-style CLI for Delos."
5
5
  readme = "README.md"
6
6
  license = { text = "MIT" }
@@ -1,11 +1,14 @@
1
1
  """Remote ``.mcp.json`` entries: config, URL matching, row states, the connect flow through Delos, and ``/mcp``."""
2
2
 
3
+ import asyncio
3
4
  import json
5
+ from collections.abc import Awaitable, Callable
4
6
  from dataclasses import dataclass, field
5
7
  from pathlib import Path
6
8
  from types import SimpleNamespace
7
9
  from typing import Any
8
10
  from unittest.mock import MagicMock
11
+ from urllib.parse import parse_qs, urlsplit
9
12
 
10
13
  import httpx
11
14
  import pytest
@@ -25,6 +28,7 @@ from delos_cli.mcp.remote import (
25
28
  start_connect,
26
29
  wait_and_enable,
27
30
  )
31
+ from delos_cli.serve import rpc
28
32
  from delos_cli.transport.integrations import (
29
33
  ConnectorState,
30
34
  fetch_connector_state,
@@ -410,6 +414,73 @@ async def test_landing_page_ignores_other_requests() -> None:
410
414
  assert landing.outcome is None
411
415
 
412
416
 
417
+ # --------------------------------------------------------------------------- VSCode RPC
418
+
419
+
420
+ @pytest.mark.parametrize("authorized", [True, False])
421
+ async def test_rpc_connect_keeps_confirmation_alive_and_enables_after_consent(
422
+ monkeypatch: pytest.MonkeyPatch,
423
+ authorized: bool, # noqa: FBT001
424
+ ) -> None:
425
+ http = FakeHttp()
426
+ tasks: list[asyncio.Task[None]] = []
427
+ logs: list[str] = []
428
+ consent = asyncio.Event()
429
+
430
+ async def wait_for_consent(client: Any, server_id: str, *, gave_up: Callable[[], bool]) -> bool:
431
+ await consent.wait()
432
+ return await wait_and_enable(client, server_id, sleep=_no_sleep, gave_up=gave_up)
433
+
434
+ def spawn(coro: Awaitable[None]) -> None:
435
+ tasks.append(asyncio.ensure_future(coro))
436
+
437
+ opened: list[str] = []
438
+ monkeypatch.setattr(rpc.webbrowser, "open", opened.append)
439
+ monkeypatch.setattr(rpc, "wait_and_enable", wait_for_consent)
440
+ server = SimpleNamespace(
441
+ require_http=lambda: http,
442
+ mcp=SimpleNamespace(config=SimpleNamespace(remote={"db": _remote("db", "https://db.example.com/mcp")})),
443
+ spawn=spawn,
444
+ log=logs.append,
445
+ )
446
+
447
+ result = await rpc.connect_integration(server, {"service": "remote:db"}) # type: ignore[arg-type]
448
+ assert result == {"service": "mcp:new-id", "url": "https://auth.example.com/authorize?state=x"}
449
+ assert opened == [result["url"]]
450
+ install = next(c for c in http.calls if "/oauth/install" in c)
451
+ return_to = parse_qs(urlsplit(install.removeprefix("GET ")).query)["return_to"][0]
452
+ assert return_to.startswith("http://localhost:")
453
+ assert "/home/" not in return_to
454
+ local_url = return_to.replace("localhost", "127.0.0.1")
455
+ outcome = "generic_mcp_new-id_connected=true" if authorized else "generic_mcp_error=access_denied"
456
+ try:
457
+ async with httpx.AsyncClient() as browser:
458
+ # The RPC has already answered, but the background task still owns the page.
459
+ response = await browser.get(f"{local_url}?{outcome}")
460
+ assert response.status_code == 200
461
+ assert "return to VSCode" in response.text if authorized else "Could not connect" in response.text
462
+ assert "settings/org/connectors" not in response.text
463
+ assert "enabled_integrations" not in http.vscode
464
+ if authorized:
465
+ http.credentials["generic_mcp_new-id"] = {"access_token": "t"}
466
+ consent.set()
467
+ await asyncio.gather(*tasks)
468
+ if authorized:
469
+ assert http.vscode["enabled_integrations"] == ["mcp_new-id"]
470
+ assert not logs
471
+ else:
472
+ assert "enabled_integrations" not in http.vscode
473
+ assert logs == ["connect new-id: access_denied"]
474
+ # Cleanup runs after both successful and refused consent.
475
+ async with httpx.AsyncClient() as browser:
476
+ with pytest.raises(httpx.ConnectError):
477
+ await browser.get(f"{local_url}?{outcome}")
478
+ finally:
479
+ for task in tasks:
480
+ task.cancel()
481
+ await asyncio.gather(*tasks, return_exceptions=True)
482
+
483
+
413
484
  # --------------------------------------------------------------------------- /mcp
414
485
 
415
486