delos-cli 5.9.22__tar.gz → 5.9.32__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 (139) hide show
  1. {delos_cli-5.9.22 → delos_cli-5.9.32}/PKG-INFO +1 -1
  2. delos_cli-5.9.32/delos_cli/_build.json +5 -0
  3. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/tools/ask_user_input.py +7 -13
  4. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/tools/edit_content.py +4 -7
  5. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/tools/todo_write.py +4 -7
  6. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/transport/chats.py +130 -6
  7. delos_cli-5.9.32/delos_cli/transport/conversation_rows.py +71 -0
  8. {delos_cli-5.9.22 → delos_cli-5.9.32}/pyproject.toml +1 -1
  9. delos_cli-5.9.22/delos_cli/_build.json +0 -5
  10. {delos_cli-5.9.22 → delos_cli-5.9.32}/.gitignore +0 -0
  11. {delos_cli-5.9.22 → delos_cli-5.9.32}/README.md +0 -0
  12. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/__init__.py +0 -0
  13. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/__main__.py +0 -0
  14. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/agent/__init__.py +0 -0
  15. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/agent/session.py +0 -0
  16. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/agent/tools.py +0 -0
  17. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/agent/transport.py +0 -0
  18. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/agent/turn.py +0 -0
  19. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/apps/__init__.py +0 -0
  20. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/apps/base.py +0 -0
  21. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/apps/chat/__init__.py +0 -0
  22. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/apps/chat/app.py +0 -0
  23. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/apps/chat/commands.py +0 -0
  24. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/apps/chat/render.py +0 -0
  25. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/apps/chat/rewind.py +0 -0
  26. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/apps/replay.py +0 -0
  27. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/auth/__init__.py +0 -0
  28. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/auth/config.py +0 -0
  29. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/auth/mfa.py +0 -0
  30. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/auth/oauth.py +0 -0
  31. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/auth/token_manager.py +0 -0
  32. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/checkpoints.py +0 -0
  33. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/commands/__init__.py +0 -0
  34. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/commands/base.py +0 -0
  35. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/commands/builtin.py +0 -0
  36. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/commands/mcp.py +0 -0
  37. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/commands/permissions.py +0 -0
  38. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/commands/prompts.py +0 -0
  39. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/commands/sandbox.py +0 -0
  40. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/context_report.py +0 -0
  41. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/ctx.py +0 -0
  42. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/file_state.py +0 -0
  43. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/git_context.py +0 -0
  44. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/hooks.py +0 -0
  45. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/loop.py +0 -0
  46. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/main.py +0 -0
  47. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/mcp/__init__.py +0 -0
  48. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/mcp/client.py +0 -0
  49. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/mcp/config.py +0 -0
  50. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/mcp/handlers.py +0 -0
  51. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/mcp/landing.py +0 -0
  52. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/mcp/manager.py +0 -0
  53. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/mcp/remote.py +0 -0
  54. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/mcp/state.py +0 -0
  55. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/permissions.py +0 -0
  56. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/project_context.py +0 -0
  57. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/public_key.py +0 -0
  58. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/sandbox/__init__.py +0 -0
  59. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/sandbox/approval.py +0 -0
  60. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/sandbox/bwrap.py +0 -0
  61. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/sandbox/config.py +0 -0
  62. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/sandbox/core.py +0 -0
  63. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/sandbox/denial.py +0 -0
  64. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/sandbox/platform.py +0 -0
  65. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/sandbox/policy.py +0 -0
  66. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/sandbox/seatbelt.py +0 -0
  67. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/sandbox/seatbelt.sbpl +0 -0
  68. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/sandbox/seatbelt_network.sbpl +0 -0
  69. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/sentry_identity.py +0 -0
  70. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/serve/__init__.py +0 -0
  71. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/serve/app.py +0 -0
  72. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/serve/confirm.py +0 -0
  73. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/serve/protocol.py +0 -0
  74. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/serve/rpc.py +0 -0
  75. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/serve/server.py +0 -0
  76. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/settings.py +0 -0
  77. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/skills.py +0 -0
  78. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/state.py +0 -0
  79. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/telemetry.py +0 -0
  80. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/tool_output.py +0 -0
  81. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/tools/__init__.py +0 -0
  82. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/tools/explore.py +0 -0
  83. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/tools/glob_tool.py +0 -0
  84. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/tools/grep.py +0 -0
  85. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/tools/read.py +0 -0
  86. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/tools/run_shell.py +0 -0
  87. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/tools/task.py +0 -0
  88. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/tools/verify.py +0 -0
  89. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/tools/write_content.py +0 -0
  90. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/transport/__init__.py +0 -0
  91. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/transport/client.py +0 -0
  92. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/transport/documents.py +0 -0
  93. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/transport/integrations.py +0 -0
  94. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/transport/models.py +0 -0
  95. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/ui/__init__.py +0 -0
  96. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/ui/banner.py +0 -0
  97. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/ui/chat_picker.py +0 -0
  98. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/ui/collapse.py +0 -0
  99. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/ui/completer.py +0 -0
  100. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/ui/lexer.py +0 -0
  101. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/ui/model_picker.py +0 -0
  102. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/ui/output.py +0 -0
  103. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/ui/repl.py +0 -0
  104. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/ui/style.py +0 -0
  105. {delos_cli-5.9.22 → delos_cli-5.9.32}/delos_cli/usage_report.py +0 -0
  106. {delos_cli-5.9.22 → delos_cli-5.9.32}/tests/__init__.py +0 -0
  107. {delos_cli-5.9.22 → delos_cli-5.9.32}/tests/agent/__init__.py +0 -0
  108. {delos_cli-5.9.22 → delos_cli-5.9.32}/tests/agent/test_hooks.py +0 -0
  109. {delos_cli-5.9.22 → delos_cli-5.9.32}/tests/agent/test_steering.py +0 -0
  110. {delos_cli-5.9.22 → delos_cli-5.9.32}/tests/conftest.py +0 -0
  111. {delos_cli-5.9.22 → delos_cli-5.9.32}/tests/context/__init__.py +0 -0
  112. {delos_cli-5.9.22 → delos_cli-5.9.32}/tests/context/test_checkpoints.py +0 -0
  113. {delos_cli-5.9.22 → delos_cli-5.9.32}/tests/context/test_permissions.py +0 -0
  114. {delos_cli-5.9.22 → delos_cli-5.9.32}/tests/context/test_project_context.py +0 -0
  115. {delos_cli-5.9.22 → delos_cli-5.9.32}/tests/context/test_skills.py +0 -0
  116. {delos_cli-5.9.22 → delos_cli-5.9.32}/tests/mcp/__init__.py +0 -0
  117. {delos_cli-5.9.22 → delos_cli-5.9.32}/tests/mcp/fake_server.py +0 -0
  118. {delos_cli-5.9.22 → delos_cli-5.9.32}/tests/mcp/test_client.py +0 -0
  119. {delos_cli-5.9.22 → delos_cli-5.9.32}/tests/mcp/test_manager.py +0 -0
  120. {delos_cli-5.9.22 → delos_cli-5.9.32}/tests/mcp/test_remote.py +0 -0
  121. {delos_cli-5.9.22 → delos_cli-5.9.32}/tests/sandbox/__init__.py +0 -0
  122. {delos_cli-5.9.22 → delos_cli-5.9.32}/tests/sandbox/test_approval.py +0 -0
  123. {delos_cli-5.9.22 → delos_cli-5.9.32}/tests/sandbox/test_bwrap.py +0 -0
  124. {delos_cli-5.9.22 → delos_cli-5.9.32}/tests/sandbox/test_config.py +0 -0
  125. {delos_cli-5.9.22 → delos_cli-5.9.32}/tests/sandbox/test_denial.py +0 -0
  126. {delos_cli-5.9.22 → delos_cli-5.9.32}/tests/sandbox/test_integration.py +0 -0
  127. {delos_cli-5.9.22 → delos_cli-5.9.32}/tests/sandbox/test_platform.py +0 -0
  128. {delos_cli-5.9.22 → delos_cli-5.9.32}/tests/sandbox/test_policy.py +0 -0
  129. {delos_cli-5.9.22 → delos_cli-5.9.32}/tests/sandbox/test_seatbelt.py +0 -0
  130. {delos_cli-5.9.22 → delos_cli-5.9.32}/tests/serve/__init__.py +0 -0
  131. {delos_cli-5.9.22 → delos_cli-5.9.32}/tests/serve/test_confirm.py +0 -0
  132. {delos_cli-5.9.22 → delos_cli-5.9.32}/tests/serve/test_steer.py +0 -0
  133. {delos_cli-5.9.22 → delos_cli-5.9.32}/tests/tools/__init__.py +0 -0
  134. {delos_cli-5.9.22 → delos_cli-5.9.32}/tests/tools/test_file_state.py +0 -0
  135. {delos_cli-5.9.22 → delos_cli-5.9.32}/tests/tools/test_run_shell.py +0 -0
  136. {delos_cli-5.9.22 → delos_cli-5.9.32}/tests/tools/test_tool_output.py +0 -0
  137. {delos_cli-5.9.22 → delos_cli-5.9.32}/tests/ui/__init__.py +0 -0
  138. {delos_cli-5.9.22 → delos_cli-5.9.32}/tests/ui/test_steering_keys.py +0 -0
  139. {delos_cli-5.9.22 → delos_cli-5.9.32}/tests/ui/test_transcript_view.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: delos-cli
3
- Version: 5.9.22
3
+ Version: 5.9.32
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.32",
3
+ "sha": "98d062154633d759a4a7922500b54c39e39a27b1",
4
+ "version": "5.9.32"
5
+ }
@@ -22,7 +22,7 @@ across the chat, CLI, and VSCode surfaces.
22
22
 
23
23
  from __future__ import annotations
24
24
 
25
- from typing import TYPE_CHECKING, Any, cast
25
+ from typing import TYPE_CHECKING, Any
26
26
 
27
27
  from rich.text import Text
28
28
 
@@ -43,20 +43,17 @@ def _validate(questions: Any) -> str | None:
43
43
  for idx, entry in enumerate(questions):
44
44
  if not isinstance(entry, dict):
45
45
  return f"Error: questions[{idx}] must be an object."
46
- # ty needs an explicit cast here: ``isinstance(entry, dict)`` narrows to
47
- # ``dict[Unknown, Unknown]`` whose ``.get`` rejects string keys.
48
- q = cast("dict[str, Any]", entry)
49
- qtype = q.get("type")
46
+ qtype = entry.get("type")
50
47
  if qtype not in _VALID_TYPES:
51
48
  return f"Error: questions[{idx}].type must be one of {sorted(_VALID_TYPES)}, got {qtype!r}."
52
- question_text = q.get("question")
49
+ question_text = entry.get("question")
53
50
  if not isinstance(question_text, str) or not question_text.strip():
54
51
  return f"Error: questions[{idx}].question must be a non-empty string."
55
- label = q.get("label")
52
+ label = entry.get("label")
56
53
  if label is not None and not isinstance(label, str):
57
54
  return f"Error: questions[{idx}].label must be a string when provided."
58
55
  if qtype in {"single_select", "multi_select"}:
59
- options = q.get("options")
56
+ options = entry.get("options")
60
57
  if not isinstance(options, list) or not options:
61
58
  return f"Error: questions[{idx}].options must be a non-empty list for type {qtype!r}."
62
59
  return None
@@ -64,14 +61,11 @@ def _validate(questions: Any) -> str | None:
64
61
 
65
62
  async def handle_ask_user_input(tool_input: dict[str, Any], ctx: Ctx) -> str:
66
63
  """Resolve an ``ask_user_input`` call: validate, prompt, format answers."""
67
- raw_questions = tool_input.get("questions")
64
+ raw_questions = tool_input.get("questions", [])
68
65
  error = _validate(raw_questions)
69
66
  if error:
70
67
  return error
71
- # ``_validate`` returning None guarantees ``raw_questions`` is a
72
- # non-empty list of well-formed question dicts — ty can't narrow
73
- # across the helper call, so make it explicit.
74
- questions = cast("list[dict[str, Any]]", raw_questions)
68
+ questions: list[dict[str, Any]] = raw_questions
75
69
 
76
70
  if ctx.ask_user_input is None:
77
71
  sink = ctx.output if ctx.output is not None else ctx.console
@@ -38,7 +38,7 @@ from __future__ import annotations
38
38
  import difflib
39
39
  import re
40
40
  from pathlib import Path
41
- from typing import TYPE_CHECKING, Any, cast
41
+ from typing import TYPE_CHECKING, Any
42
42
 
43
43
  from rich.console import Group
44
44
  from rich.padding import Padding
@@ -131,18 +131,15 @@ def _parse_edits(tool_input: dict[str, Any]) -> list[tuple[str, str, bool]] | st
131
131
  for idx, entry in enumerate(raw_edits):
132
132
  if not isinstance(entry, dict):
133
133
  return f"Error: edits[{idx}] must be an object."
134
- # ty needs an explicit cast here: ``isinstance(entry, dict)`` narrows to
135
- # ``dict[Unknown, Unknown]`` whose ``.get`` rejects string keys.
136
- item = cast("dict[str, Any]", entry)
137
- old = item.get("old_content")
138
- new = item.get("new_content")
134
+ old = entry.get("old_content")
135
+ new = entry.get("new_content")
139
136
  if not isinstance(old, str) or not isinstance(new, str):
140
137
  return f"Error: edits[{idx}] must have string 'old_content' and 'new_content'."
141
138
  if not old:
142
139
  return f"Error: edits[{idx}].old_content is empty. Use a non-empty pivot string."
143
140
  if old == new:
144
141
  return f"Error: edits[{idx}] — old_content and new_content are identical."
145
- pairs.append((old, new, item.get("replace_all") is True))
142
+ pairs.append((old, new, entry.get("replace_all") is True))
146
143
  return pairs
147
144
 
148
145
  if not isinstance(old_content, str) or not isinstance(new_content, str):
@@ -21,7 +21,7 @@ they're feedback the agent should learn from, not exceptions.
21
21
 
22
22
  from __future__ import annotations
23
23
 
24
- from typing import TYPE_CHECKING, Any, cast, get_args
24
+ from typing import TYPE_CHECKING, Any, get_args
25
25
 
26
26
  from delos_cli.state import TodoItem, TodoStatus, TodoStore
27
27
 
@@ -51,12 +51,9 @@ async def handle_todo_write(tool_input: dict[str, Any], ctx: Ctx) -> str:
51
51
  for idx, entry in enumerate(raw):
52
52
  if not isinstance(entry, dict):
53
53
  return f"Error: todos[{idx}] must be an object."
54
- # ty needs an explicit cast here: ``isinstance(entry, dict)`` narrows to
55
- # ``dict[Unknown, Unknown]`` whose ``.get`` rejects string keys.
56
- item = cast("dict[str, Any]", entry)
57
- tid = item.get("id")
58
- content = item.get("content")
59
- status = item.get("status")
54
+ tid = entry.get("id")
55
+ content = entry.get("content")
56
+ status = entry.get("status")
60
57
  if not isinstance(tid, str) or not tid:
61
58
  return f"Error: todos[{idx}].id must be a non-empty string."
62
59
  if tid in seen_ids:
@@ -24,6 +24,7 @@ from urllib.parse import urlencode
24
24
  from delos_cli import __version__ as _cli_version
25
25
 
26
26
  from .client import HTTP_ERROR_THRESHOLD, TransportError
27
+ from .conversation_rows import rows_to_messages, text_of
27
28
 
28
29
  if TYPE_CHECKING:
29
30
  from .client import AuthedClient
@@ -77,8 +78,49 @@ async def list_recent(
77
78
  if resp.status_code >= HTTP_ERROR_THRESHOLD:
78
79
  msg = f"HTTP {resp.status_code}: {resp.text[:400]}"
79
80
  raise TransportError(msg)
80
- rows = resp.json()
81
- return [_row_to_item(r) for r in rows]
81
+ items = [_row_to_item(r) for r in resp.json()]
82
+ items += await _list_conversations(http, org_uuid, folder=folder, limit=limit)
83
+ items.sort(key=lambda item: item.updated_at, reverse=True)
84
+ return items[:limit]
85
+
86
+
87
+ async def _list_conversations(
88
+ http: AuthedClient,
89
+ org_uuid: str,
90
+ *,
91
+ folder: str | None,
92
+ limit: int,
93
+ ) -> list[ChatListItem]:
94
+ """The signed-in user's unified ``conversations`` of the CLI, titled by their Drive node."""
95
+ params = {
96
+ "select": "id,message_count,last_message_at",
97
+ "org_id": f"eq.{org_uuid}",
98
+ "app": "eq.cli",
99
+ "parent_id": "is.null",
100
+ "expires_at": "is.null",
101
+ "message_count": "gt.0",
102
+ "order": "last_message_at.desc",
103
+ "limit": str(limit),
104
+ }
105
+ # RLS also lets Drive shares read a conversation; the picker lists only the user's own.
106
+ if http.cfg.user_id:
107
+ params["user_id"] = f"eq.{http.cfg.user_id}"
108
+ if folder is not None:
109
+ params["scope_id"] = f"eq.{folder}"
110
+ resp = await http.supabase_get(f"/rest/v1/conversations?{urlencode(params)}")
111
+ if resp.status_code >= HTTP_ERROR_THRESHOLD:
112
+ msg = f"HTTP {resp.status_code}: {resp.text[:400]}"
113
+ raise TransportError(msg)
114
+ rows = resp.json() or []
115
+ if not rows:
116
+ return []
117
+ ids = ",".join(str(r["id"]) for r in rows)
118
+ resp = await http.supabase_get(f"/rest/v1/app_drive?{urlencode({'select': 'id,name', 'id': f'in.({ids})'})}")
119
+ if resp.status_code >= HTTP_ERROR_THRESHOLD:
120
+ msg = f"HTTP {resp.status_code}: {resp.text[:400]}"
121
+ raise TransportError(msg)
122
+ names = {str(r["id"]): r.get("name") for r in resp.json() or []}
123
+ return [_row_to_item({**r, "name": names.get(str(r["id"])), "updated_at": r.get("last_message_at")}) for r in rows]
82
124
 
83
125
 
84
126
  # ---------------------------------------------------------------------------
@@ -101,7 +143,28 @@ async def fetch_messages(http: AuthedClient, chat_id: str) -> list[dict[str, Any
101
143
  if resp.status_code >= HTTP_ERROR_THRESHOLD:
102
144
  msg = f"HTTP {resp.status_code}: {resp.text[:400]}"
103
145
  raise TransportError(msg)
104
- return [_message_row_to_openai(r) for r in (resp.json() or [])]
146
+ rows = resp.json() or []
147
+ if rows:
148
+ return [_message_row_to_openai(r) for r in rows]
149
+ return await _fetch_conversation_messages(http, chat_id)
150
+
151
+
152
+ async def _fetch_conversation_messages(http: AuthedClient, conversation_id: str) -> list[dict[str, Any]]:
153
+ """Active items of a unified conversation, mapped to OpenAI format, oldest first."""
154
+ params = {
155
+ "select": (
156
+ "id,seq,revision,type,call_id,tool_name,arguments,superseded_by,created_at,"
157
+ "conversations_parts(position,kind,text,file_id,name,mime)"
158
+ ),
159
+ "conversation_id": f"eq.{conversation_id}",
160
+ "superseded_by": "is.null",
161
+ "order": "seq.asc",
162
+ }
163
+ resp = await http.supabase_get(f"/rest/v1/conversations_messages?{urlencode(params)}")
164
+ if resp.status_code >= HTTP_ERROR_THRESHOLD:
165
+ msg = f"HTTP {resp.status_code}: {resp.text[:400]}"
166
+ raise TransportError(msg)
167
+ return rows_to_messages(resp.json() or [])
105
168
 
106
169
 
107
170
  async def fetch_rewind_points(http: AuthedClient, chat_id: str) -> list[dict[str, Any]]:
@@ -221,8 +284,7 @@ async def fork_chat(
221
284
  raise TransportError(msg)
222
285
  rows = resp.json() or []
223
286
  if not rows:
224
- msg = f"chat {source_chat_id} not found"
225
- raise TransportError(msg)
287
+ return await _fork_conversation(http, source_chat_id, user_message_count)
226
288
  src = rows[0]
227
289
 
228
290
  params = {
@@ -275,6 +337,52 @@ async def fork_chat(
275
337
  return new_id, title
276
338
 
277
339
 
340
+ async def _fork_conversation(http: AuthedClient, conversation_id: str, user_message_count: int) -> tuple[str, str]:
341
+ """Fork a unified conversation through the item before its ``user_message_count + 1``-th user message."""
342
+ params = {
343
+ "select": "id,seq,type,conversations_parts(kind,text)",
344
+ "conversation_id": f"eq.{conversation_id}",
345
+ "superseded_by": "is.null",
346
+ "order": "seq.asc",
347
+ }
348
+ resp = await http.supabase_get(f"/rest/v1/conversations_messages?{urlencode(params)}")
349
+ if resp.status_code >= HTTP_ERROR_THRESHOLD:
350
+ msg = f"failed to read messages: HTTP {resp.status_code}: {resp.text[:400]}"
351
+ raise TransportError(msg)
352
+ items = _prefix_until_user_item(resp.json() or [], user_message_count)
353
+ if not items:
354
+ msg = f"chat {conversation_id} has nothing to fork"
355
+ raise TransportError(msg)
356
+ created = await http.json_post(
357
+ f"/conversations/{http.cfg.org_uuid}/{conversation_id}/fork",
358
+ {"through_item_id": str(items[-1]["id"])},
359
+ )
360
+ new_id = str(created["id"])
361
+ resp = await http.supabase_get(f"/rest/v1/app_drive?{urlencode({'select': 'name', 'id': f'eq.{new_id}'})}")
362
+ if resp.status_code >= HTTP_ERROR_THRESHOLD:
363
+ msg = f"failed to read fork: HTTP {resp.status_code}: {resp.text[:400]}"
364
+ raise TransportError(msg)
365
+ nodes = resp.json() or []
366
+ title = f"{(nodes[0].get('name') if nodes else None) or 'Chat'} (fork)"
367
+ await rename_chat(http, new_id, title)
368
+ return new_id, title
369
+
370
+
371
+ def _prefix_until_user_item(items: list[dict[str, Any]], user_message_count: int) -> list[dict[str, Any]]:
372
+ """Items up to (excluding) the ``user_message_count + 1``-th user message with text."""
373
+ if user_message_count <= 0:
374
+ return list(items)
375
+ kept: list[dict[str, Any]] = []
376
+ seen = 0
377
+ for item in items:
378
+ if item.get("type") == "user_message" and text_of(item.get("conversations_parts") or []):
379
+ seen += 1
380
+ if seen > user_message_count:
381
+ break
382
+ kept.append(item)
383
+ return kept
384
+
385
+
278
386
  def _prefix_until_user(
279
387
  messages: list[dict[str, Any]],
280
388
  user_message_count: int,
@@ -339,10 +447,18 @@ async def rename_chat(http: AuthedClient, chat_id: str, name: str) -> None:
339
447
  if resp.status_code >= HTTP_ERROR_THRESHOLD:
340
448
  msg = f"failed to rename chat: HTTP {resp.status_code}: {resp.text[:400]}"
341
449
  raise TransportError(msg)
450
+ resp = await http.supabase_patch(
451
+ f"/rest/v1/app_drive?{_conversation_node(chat_id)}",
452
+ body,
453
+ prefer="return=minimal",
454
+ )
455
+ if resp.status_code >= HTTP_ERROR_THRESHOLD:
456
+ msg = f"failed to rename conversation: HTTP {resp.status_code}: {resp.text[:400]}"
457
+ raise TransportError(msg)
342
458
 
343
459
 
344
460
  async def delete_chat(http: AuthedClient, chat_id: str) -> None:
345
- """DELETE one ``app_cli`` row.
461
+ """DELETE one ``app_cli`` row, or the Drive node of a unified conversation (a trigger deletes the conversation).
346
462
 
347
463
  ``app_cli_messages`` rows cascade away via the FK constraint; RLS
348
464
  again scopes the DELETE to the owner.
@@ -351,6 +467,14 @@ async def delete_chat(http: AuthedClient, chat_id: str) -> None:
351
467
  if resp.status_code >= HTTP_ERROR_THRESHOLD:
352
468
  msg = f"failed to delete chat: HTTP {resp.status_code}: {resp.text[:400]}"
353
469
  raise TransportError(msg)
470
+ resp = await http.supabase_delete(f"/rest/v1/app_drive?{_conversation_node(chat_id)}")
471
+ if resp.status_code >= HTTP_ERROR_THRESHOLD:
472
+ msg = f"failed to delete conversation: HTTP {resp.status_code}: {resp.text[:400]}"
473
+ raise TransportError(msg)
474
+
475
+
476
+ def _conversation_node(conversation_id: str) -> str:
477
+ return urlencode({"id": f"eq.{conversation_id}", "represents": "eq.conversation"})
354
478
 
355
479
 
356
480
  # ---------------------------------------------------------------------------
@@ -0,0 +1,71 @@
1
+ """Rows of the unified ``conversations_messages`` table as the OpenAI-style messages replay expects."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from operator import itemgetter
6
+ from typing import Any
7
+
8
+ COMPACTION_SUMMARY_KIND = "compaction_summary"
9
+ ASSISTANT_ITEMS = frozenset({"reasoning", "assistant_message", "function_call"})
10
+
11
+
12
+ def text_of(parts: list[dict[str, Any]]) -> str:
13
+ """The item's visible text, pasted text included, in block order."""
14
+ texts = [p.get("text") or "" for p in parts if p.get("kind") in {"text", "pasted_text"}]
15
+ return "\n\n".join(t for t in texts if t)
16
+
17
+
18
+ def add_to_turn(turn: dict[str, Any], item: dict[str, Any], parts: list[dict[str, Any]]) -> None:
19
+ """Fold one assistant-side item into its turn's single message."""
20
+ kind = item["type"]
21
+ if kind == "reasoning":
22
+ turn["reasoning"] = text_of(parts)
23
+ elif kind == "assistant_message":
24
+ turn["content"] = text_of(parts)
25
+ else:
26
+ call = {
27
+ "id": item.get("call_id") or item["id"],
28
+ "type": "function",
29
+ "function": {"name": item.get("tool_name") or "unknown", "arguments": item.get("arguments") or "{}"},
30
+ }
31
+ turn.setdefault("tool_calls", []).append(call)
32
+
33
+
34
+ def item_to_message(item: dict[str, Any], parts: list[dict[str, Any]], tool_names: dict[str, str]) -> dict[str, Any]:
35
+ """One user, compaction or tool-output item as an OpenAI-style message."""
36
+ kind = item["type"]
37
+ if kind == "user_message":
38
+ return {"role": "user", "content": text_of(parts)}
39
+ if kind == "compaction":
40
+ return {"role": "user", "kind": COMPACTION_SUMMARY_KIND, "content": text_of(parts)}
41
+ call_id = item.get("call_id") or item["id"]
42
+ return {
43
+ "role": "tool",
44
+ "tool_call_id": call_id,
45
+ "name": item.get("tool_name") or tool_names.get(call_id, ""),
46
+ "content": text_of(parts),
47
+ }
48
+
49
+
50
+ def rows_to_messages(items: list[dict[str, Any]]) -> list[dict[str, Any]]:
51
+ """Active items, each carrying its embedded ``conversations_parts``, in timeline order."""
52
+ active = sorted((i for i in items if i.get("superseded_by") is None), key=itemgetter("seq"))
53
+ messages: list[dict[str, Any]] = []
54
+ tool_names: dict[str, str] = {}
55
+ turn: dict[str, Any] | None = None
56
+ turn_revision: int | None = None
57
+ for item in active:
58
+ parts = sorted(item.get("conversations_parts") or [], key=itemgetter("position"))
59
+ if item["type"] in ASSISTANT_ITEMS:
60
+ # One stored assistant message is one batch, and a batch shares one revision.
61
+ if turn is None or turn_revision != item.get("revision"):
62
+ turn = {"role": "assistant", "content": None}
63
+ turn_revision = item.get("revision")
64
+ messages.append(turn)
65
+ if item["type"] == "function_call":
66
+ tool_names[item.get("call_id") or item["id"]] = item.get("tool_name") or "unknown"
67
+ add_to_turn(turn, item, parts)
68
+ continue
69
+ turn = None
70
+ messages.append(item_to_message(item, parts, tool_names))
71
+ return messages
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "delos-cli"
3
- version = "5.9.22"
3
+ version = "5.9.32"
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,5 +0,0 @@
1
- {
2
- "release": "v5.9.22",
3
- "sha": "59899e681d29fb2663a1a001088b1fd478f9727f",
4
- "version": "5.9.22"
5
- }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes