optio-cursor 0.4.4__tar.gz → 0.4.6__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.
- {optio_cursor-0.4.4 → optio_cursor-0.4.6}/PKG-INFO +3 -3
- {optio_cursor-0.4.4 → optio_cursor-0.4.6}/pyproject.toml +3 -3
- {optio_cursor-0.4.4 → optio_cursor-0.4.6}/src/optio_cursor/conversation_listener.py +10 -1
- {optio_cursor-0.4.4 → optio_cursor-0.4.6}/src/optio_cursor/host_actions.py +3 -1
- {optio_cursor-0.4.4 → optio_cursor-0.4.6}/src/optio_cursor/models.py +4 -1
- {optio_cursor-0.4.4 → optio_cursor-0.4.6}/src/optio_cursor/session.py +20 -7
- {optio_cursor-0.4.4 → optio_cursor-0.4.6}/src/optio_cursor/types.py +30 -9
- {optio_cursor-0.4.4 → optio_cursor-0.4.6}/src/optio_cursor.egg-info/PKG-INFO +3 -3
- {optio_cursor-0.4.4 → optio_cursor-0.4.6}/src/optio_cursor.egg-info/SOURCES.txt +1 -0
- {optio_cursor-0.4.4 → optio_cursor-0.4.6}/src/optio_cursor.egg-info/requires.txt +2 -2
- optio_cursor-0.4.6/tests/test_auto_start_prompt.py +14 -0
- {optio_cursor-0.4.4 → optio_cursor-0.4.6}/tests/test_conversation_listener.py +30 -0
- {optio_cursor-0.4.4 → optio_cursor-0.4.6}/tests/test_models.py +35 -1
- {optio_cursor-0.4.4 → optio_cursor-0.4.6}/tests/test_prompt_threading.py +17 -1
- {optio_cursor-0.4.4 → optio_cursor-0.4.6}/tests/test_session_conversation.py +92 -0
- {optio_cursor-0.4.4 → optio_cursor-0.4.6}/tests/test_session_local.py +39 -0
- {optio_cursor-0.4.4 → optio_cursor-0.4.6}/README.md +0 -0
- {optio_cursor-0.4.4 → optio_cursor-0.4.6}/setup.cfg +0 -0
- {optio_cursor-0.4.4 → optio_cursor-0.4.6}/src/optio_cursor/__init__.py +0 -0
- {optio_cursor-0.4.4 → optio_cursor-0.4.6}/src/optio_cursor/account.py +0 -0
- {optio_cursor-0.4.4 → optio_cursor-0.4.6}/src/optio_cursor/conversation.py +0 -0
- {optio_cursor-0.4.4 → optio_cursor-0.4.6}/src/optio_cursor/cred_watcher.py +0 -0
- {optio_cursor-0.4.4 → optio_cursor-0.4.6}/src/optio_cursor/fs_allowlist.py +0 -0
- {optio_cursor-0.4.4 → optio_cursor-0.4.6}/src/optio_cursor/info.py +0 -0
- {optio_cursor-0.4.4 → optio_cursor-0.4.6}/src/optio_cursor/model_probe.py +0 -0
- {optio_cursor-0.4.4 → optio_cursor-0.4.6}/src/optio_cursor/prompt.py +0 -0
- {optio_cursor-0.4.4 → optio_cursor-0.4.6}/src/optio_cursor/seed_manifest.py +0 -0
- {optio_cursor-0.4.4 → optio_cursor-0.4.6}/src/optio_cursor/snapshots.py +0 -0
- {optio_cursor-0.4.4 → optio_cursor-0.4.6}/src/optio_cursor/verify.py +0 -0
- {optio_cursor-0.4.4 → optio_cursor-0.4.6}/src/optio_cursor.egg-info/dependency_links.txt +0 -0
- {optio_cursor-0.4.4 → optio_cursor-0.4.6}/src/optio_cursor.egg-info/top_level.txt +0 -0
- {optio_cursor-0.4.4 → optio_cursor-0.4.6}/tests/test_account.py +0 -0
- {optio_cursor-0.4.4 → optio_cursor-0.4.6}/tests/test_agent_info.py +0 -0
- {optio_cursor-0.4.4 → optio_cursor-0.4.6}/tests/test_caller_message_wiring.py +0 -0
- {optio_cursor-0.4.4 → optio_cursor-0.4.6}/tests/test_claustrum_triad.py +0 -0
- {optio_cursor-0.4.4 → optio_cursor-0.4.6}/tests/test_config.py +0 -0
- {optio_cursor-0.4.4 → optio_cursor-0.4.6}/tests/test_conversation.py +0 -0
- {optio_cursor-0.4.4 → optio_cursor-0.4.6}/tests/test_cred_watcher.py +0 -0
- {optio_cursor-0.4.4 → optio_cursor-0.4.6}/tests/test_cursor_cache.py +0 -0
- {optio_cursor-0.4.4 → optio_cursor-0.4.6}/tests/test_file_download.py +0 -0
- {optio_cursor-0.4.4 → optio_cursor-0.4.6}/tests/test_file_upload.py +0 -0
- {optio_cursor-0.4.4 → optio_cursor-0.4.6}/tests/test_fs_allowlist.py +0 -0
- {optio_cursor-0.4.4 → optio_cursor-0.4.6}/tests/test_host_actions.py +0 -0
- {optio_cursor-0.4.4 → optio_cursor-0.4.6}/tests/test_import.py +0 -0
- {optio_cursor-0.4.4 → optio_cursor-0.4.6}/tests/test_input_wiring.py +0 -0
- {optio_cursor-0.4.4 → optio_cursor-0.4.6}/tests/test_model_probe.py +0 -0
- {optio_cursor-0.4.4 → optio_cursor-0.4.6}/tests/test_model_probe_wiring.py +0 -0
- {optio_cursor-0.4.4 → optio_cursor-0.4.6}/tests/test_on_resume_refresh.py +0 -0
- {optio_cursor-0.4.4 → optio_cursor-0.4.6}/tests/test_prompt.py +0 -0
- {optio_cursor-0.4.4 → optio_cursor-0.4.6}/tests/test_sandbox_enforce.py +0 -0
- {optio_cursor-0.4.4 → optio_cursor-0.4.6}/tests/test_seed_manifest.py +0 -0
- {optio_cursor-0.4.4 → optio_cursor-0.4.6}/tests/test_session_encrypt.py +0 -0
- {optio_cursor-0.4.4 → optio_cursor-0.4.6}/tests/test_session_fs_isolation.py +0 -0
- {optio_cursor-0.4.4 → optio_cursor-0.4.6}/tests/test_session_lease.py +0 -0
- {optio_cursor-0.4.4 → optio_cursor-0.4.6}/tests/test_session_remote.py +0 -0
- {optio_cursor-0.4.4 → optio_cursor-0.4.6}/tests/test_session_resume.py +0 -0
- {optio_cursor-0.4.4 → optio_cursor-0.4.6}/tests/test_session_seed.py +0 -0
- {optio_cursor-0.4.4 → optio_cursor-0.4.6}/tests/test_snapshots.py +0 -0
- {optio_cursor-0.4.4 → optio_cursor-0.4.6}/tests/test_verify.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: optio-cursor
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.6
|
|
4
4
|
Summary: Run Cursor CLI (cursor-agent) as an optio task; local subprocess or remote via SSH; ttyd-served TUI iframe.
|
|
5
5
|
Author-email: Kristof Csillag <kristof.csillag@deai-labs.com>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -20,9 +20,9 @@ Classifier: Topic :: Software Development :: Code Generators
|
|
|
20
20
|
Classifier: Framework :: AsyncIO
|
|
21
21
|
Requires-Python: >=3.11
|
|
22
22
|
Description-Content-Type: text/markdown
|
|
23
|
-
Requires-Dist: optio-core<0.
|
|
23
|
+
Requires-Dist: optio-core<0.7,>=0.6
|
|
24
24
|
Requires-Dist: optio-host<0.4,>=0.3
|
|
25
|
-
Requires-Dist: optio-agents<0.
|
|
25
|
+
Requires-Dist: optio-agents<0.8,>=0.7
|
|
26
26
|
Requires-Dist: asyncssh>=2.14
|
|
27
27
|
Requires-Dist: aiohttp>=3.9
|
|
28
28
|
Provides-Extra: dev
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "optio-cursor"
|
|
7
|
-
version = "0.4.
|
|
7
|
+
version = "0.4.6"
|
|
8
8
|
description = "Run Cursor CLI (cursor-agent) as an optio task; local subprocess or remote via SSH; ttyd-served TUI iframe."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "Apache-2.0"
|
|
@@ -26,9 +26,9 @@ classifiers = [
|
|
|
26
26
|
"Framework :: AsyncIO",
|
|
27
27
|
]
|
|
28
28
|
dependencies = [
|
|
29
|
-
"optio-core>=0.
|
|
29
|
+
"optio-core>=0.6,<0.7",
|
|
30
30
|
"optio-host>=0.3,<0.4",
|
|
31
|
-
"optio-agents>=0.
|
|
31
|
+
"optio-agents>=0.7,<0.8",
|
|
32
32
|
"asyncssh>=2.14",
|
|
33
33
|
"aiohttp>=3.9",
|
|
34
34
|
]
|
|
@@ -8,7 +8,8 @@ optio-api widget proxy (which injects the basic-auth credential):
|
|
|
8
8
|
POST /send — {text} -> conversation.send
|
|
9
9
|
POST /interrupt — {} -> conversation.interrupt
|
|
10
10
|
POST /control — {id, value} -> conversation.set_control
|
|
11
|
-
(model change is INLINE session/set_model — no restart)
|
|
11
|
+
(model change is INLINE session/set_model — no restart);
|
|
12
|
+
403 not-allowed for an id outside allowed_controls
|
|
12
13
|
GET /download — ?path=<relpath> -> download_reader; returns the
|
|
13
14
|
bytes with Content-Disposition: attachment (Stage 7)
|
|
14
15
|
POST /permission — {request_id, behavior, updated_input?, message?}
|
|
@@ -34,6 +35,7 @@ from typing import Awaitable, Callable
|
|
|
34
35
|
from aiohttp import web
|
|
35
36
|
|
|
36
37
|
from optio_agents.conversation import ConversationClosed, PermissionDecision
|
|
38
|
+
from optio_agents.session_controls import control_allowed
|
|
37
39
|
|
|
38
40
|
_LOG = logging.getLogger(__name__)
|
|
39
41
|
|
|
@@ -52,8 +54,13 @@ class ConversationListener:
|
|
|
52
54
|
self, conversation, *, password: str,
|
|
53
55
|
download_reader: "Callable[[str], Awaitable[tuple[bytes, str]]] | None" = None,
|
|
54
56
|
max_download_bytes: int = 10_000_000,
|
|
57
|
+
allowed_controls: "list[str] | None" = None,
|
|
55
58
|
) -> None:
|
|
56
59
|
self._conversation = conversation
|
|
60
|
+
# The task's session_controls allowlist (None: every control): /control
|
|
61
|
+
# refuses any other id, so a control hidden from the widget cannot be
|
|
62
|
+
# set by posting here directly.
|
|
63
|
+
self._allowed_controls = allowed_controls
|
|
57
64
|
self._password = password
|
|
58
65
|
self._download_reader = download_reader
|
|
59
66
|
self._max_download_bytes = max_download_bytes
|
|
@@ -247,6 +254,8 @@ class ConversationListener:
|
|
|
247
254
|
control_id = payload.get("id")
|
|
248
255
|
if not isinstance(control_id, str) or not control_id:
|
|
249
256
|
return web.json_response({"ok": False, "reason": "bad-id"}, status=400)
|
|
257
|
+
if not control_allowed(control_id, self._allowed_controls):
|
|
258
|
+
return web.json_response({"ok": False, "reason": "not-allowed"}, status=403)
|
|
250
259
|
try:
|
|
251
260
|
await self._conversation.set_control(control_id, payload.get("value"))
|
|
252
261
|
except ConversationClosed:
|
|
@@ -1125,7 +1125,9 @@ async def apply_cli_config(host: "Host", cli_config: dict) -> None:
|
|
|
1125
1125
|
|
|
1126
1126
|
# Positional prompt appended to the cursor launch when ``auto_start`` is set —
|
|
1127
1127
|
# kicks the agent off without the operator typing anything.
|
|
1128
|
-
|
|
1128
|
+
# A harness message (System: prefix), like the resume notice: the agent is
|
|
1129
|
+
# not handed a turn that reads as the human typing.
|
|
1130
|
+
AUTO_START_PROMPT = f"{SYSTEM_MESSAGE_PREFIX}Read AGENTS.md and execute the task it describes"
|
|
1129
1131
|
|
|
1130
1132
|
|
|
1131
1133
|
def build_auto_start_args(
|
|
@@ -78,7 +78,10 @@ def parse_acp_models(session_models: "dict | None") -> dict:
|
|
|
78
78
|
continue
|
|
79
79
|
mid = m.get("modelId")
|
|
80
80
|
if isinstance(mid, str) and mid:
|
|
81
|
-
|
|
81
|
+
entry = {"id": mid, "label": m.get("name") or mid, "disabled": False}
|
|
82
|
+
if isinstance(m.get("description"), str) and m["description"]:
|
|
83
|
+
entry["description"] = m["description"]
|
|
84
|
+
out.append(entry)
|
|
82
85
|
if not out:
|
|
83
86
|
return _copy_fallback()
|
|
84
87
|
return {"models": out, "default": session_models.get("currentModelId")}
|
|
@@ -35,7 +35,7 @@ from optio_agents import seeds as _seeds
|
|
|
35
35
|
from optio_agents.account import EMPTY, accounts_to_metadata
|
|
36
36
|
from optio_agents.fs_grants import fs_isolation_dirs
|
|
37
37
|
from optio_agents.input_listener import serialized, start_input_listener
|
|
38
|
-
from optio_agents.session_controls import model_control
|
|
38
|
+
from optio_agents.session_controls import filter_controls, model_control
|
|
39
39
|
from optio_agents.todos import TodoTracker, extract_acp_todo
|
|
40
40
|
from optio_agents.uploads import materialize, upload_url_token
|
|
41
41
|
from optio_agents.protocol.session import _SessionFailed, run_log_protocol_session
|
|
@@ -424,6 +424,8 @@ async def run_cursor_session(ctx: ProcessContext, config: CursorTaskConfig) -> N
|
|
|
424
424
|
supports_resume=config.supports_resume,
|
|
425
425
|
fs_isolation_dirs=fs_isolation_dirs(config, host.workdir),
|
|
426
426
|
file_download=config.file_download,
|
|
427
|
+
# Every resume sends the System: resume notice.
|
|
428
|
+
check_resume_log_every_message=False,
|
|
427
429
|
),
|
|
428
430
|
)
|
|
429
431
|
# Resume-refresh (P2): on resume, run on_resume_refresh and rewrite
|
|
@@ -467,8 +469,8 @@ async def run_cursor_session(ctx: ProcessContext, config: CursorTaskConfig) -> N
|
|
|
467
469
|
# PUSH resume awareness: a System: notice appended after --continue
|
|
468
470
|
# so the resumed TUI session gets a "you have been resumed" turn
|
|
469
471
|
# (mutually exclusive with the fresh-launch kickoff above). Parity
|
|
470
|
-
# with claudecode/opencode/grok
|
|
471
|
-
#
|
|
472
|
+
# with claudecode/opencode/grok. AGENTS.md tells cursor to wait for
|
|
473
|
+
# this notice, not to poll resume.log.
|
|
472
474
|
*host_actions.build_resume_notice_args(resuming=resuming),
|
|
473
475
|
]
|
|
474
476
|
launch_env = {
|
|
@@ -665,6 +667,9 @@ async def run_cursor_session(ctx: ProcessContext, config: CursorTaskConfig) -> N
|
|
|
665
667
|
conversation, password=listener_password,
|
|
666
668
|
download_reader=_read_download,
|
|
667
669
|
max_download_bytes=config.max_download_bytes,
|
|
670
|
+
# Only the controls the widget shows may be set: none when the
|
|
671
|
+
# controls bar is off, else the session_controls allowlist.
|
|
672
|
+
allowed_controls=config.settable_controls,
|
|
668
673
|
)
|
|
669
674
|
# The listener is an in-process aiohttp app (not a remote-host
|
|
670
675
|
# process like ttyd), so it binds directly to the widget-tunnel
|
|
@@ -681,17 +686,22 @@ async def run_cursor_session(ctx: ProcessContext, config: CursorTaskConfig) -> N
|
|
|
681
686
|
current_model = config.model or model_list.get("default")
|
|
682
687
|
# The model picker is now the engine-neutral id="model" session
|
|
683
688
|
# control (probed catalogue → disabled ControlOptions carry
|
|
684
|
-
# whyDisabled for plan-gated ids). Serialized camelCase for the UI
|
|
689
|
+
# whyDisabled for plan-gated ids). Serialized camelCase for the UI,
|
|
690
|
+
# narrowed by the session_controls allowlist (cursor emits no
|
|
691
|
+
# x-optio-control-update snapshot, so this is the only one).
|
|
685
692
|
control = model_control(models=model_list["models"], current=current_model)
|
|
693
|
+
controls = filter_controls([control.to_dict()], config.session_controls)
|
|
686
694
|
# widgetData.uploadUrl token; see optio_agents.uploads.upload_url_token.
|
|
687
695
|
upload_url = upload_url_token(ctx._db.name, ctx._prefix, ctx.process_id)
|
|
688
696
|
await ctx.set_widget_data({
|
|
689
697
|
"protocol": "cursor",
|
|
690
698
|
"toolVerbosity": config.tool_verbosity,
|
|
691
699
|
"thinkingVerbosity": config.thinking_verbosity,
|
|
700
|
+
# The welcome card atop the transcript (None: no card).
|
|
701
|
+
"welcome": config.welcome_widget_data,
|
|
692
702
|
"showSessionControls": config.show_session_controls,
|
|
693
703
|
"nativeSpinner": config.native_spinner,
|
|
694
|
-
"controls":
|
|
704
|
+
"controls": controls,
|
|
695
705
|
"showFileUpload": config.show_file_upload,
|
|
696
706
|
"maxUploadBytes": config.max_upload_bytes,
|
|
697
707
|
"fileDownload": config.file_download,
|
|
@@ -788,8 +798,9 @@ async def run_cursor_session(ctx: ProcessContext, config: CursorTaskConfig) -> N
|
|
|
788
798
|
# Kickoff prompt as the first turn (headless: no positional prompt
|
|
789
799
|
# path). On resume, push a System: resume notice instead so the resumed
|
|
790
800
|
# session notices promptly (parity with claudecode/opencode/grok;
|
|
791
|
-
#
|
|
792
|
-
# always taught in the prompt, so no host_protocol gate
|
|
801
|
+
# AGENTS.md says to wait for it, not to poll resume.log). The System:
|
|
802
|
+
# convention is always taught in the prompt, so no host_protocol gate
|
|
803
|
+
# is needed here.
|
|
793
804
|
if config.auto_start and not resuming:
|
|
794
805
|
await conversation.send(host_actions.AUTO_START_PROMPT)
|
|
795
806
|
elif resuming:
|
|
@@ -1110,6 +1121,8 @@ async def _maybe_refresh_on_resume(
|
|
|
1110
1121
|
supports_resume=new_config.supports_resume,
|
|
1111
1122
|
fs_isolation_dirs=fs_isolation_dirs(new_config, host.workdir),
|
|
1112
1123
|
file_download=new_config.file_download,
|
|
1124
|
+
# Every resume sends the System: resume notice.
|
|
1125
|
+
check_resume_log_every_message=False,
|
|
1113
1126
|
)
|
|
1114
1127
|
try:
|
|
1115
1128
|
existing = await hook_ctx.read_text_from_host("AGENTS.md", silent=True)
|
|
@@ -17,7 +17,15 @@ from optio_agents import (
|
|
|
17
17
|
TOOL_VERBOSITIES,
|
|
18
18
|
ToolVerbosity,
|
|
19
19
|
)
|
|
20
|
-
from optio_agents.config_types import
|
|
20
|
+
from optio_agents.config_types import (
|
|
21
|
+
BlobCryptoConfigMixin,
|
|
22
|
+
ClaustrumConfigMixin,
|
|
23
|
+
ResumeConfigMixin,
|
|
24
|
+
SessionControlsConfigMixin,
|
|
25
|
+
WelcomeConfigMixin,
|
|
26
|
+
)
|
|
27
|
+
from optio_agents.custom_controls import CustomControlsConfigMixin
|
|
28
|
+
from optio_agents.mcp import McpConfigMixin
|
|
21
29
|
from optio_agents.protocol.session import (
|
|
22
30
|
CallerMessageCallback,
|
|
23
31
|
DeliverableCallback,
|
|
@@ -64,7 +72,11 @@ def _identity_resume_refresh(config: "CursorTaskConfig") -> "CursorTaskConfig":
|
|
|
64
72
|
|
|
65
73
|
|
|
66
74
|
@dataclass(frozen=True, kw_only=True)
|
|
67
|
-
class CursorTaskConfig(
|
|
75
|
+
class CursorTaskConfig(
|
|
76
|
+
ClaustrumConfigMixin, BlobCryptoConfigMixin, SessionControlsConfigMixin, McpConfigMixin,
|
|
77
|
+
CustomControlsConfigMixin, ResumeConfigMixin,
|
|
78
|
+
WelcomeConfigMixin,
|
|
79
|
+
):
|
|
68
80
|
"""Configuration for one optio-cursor task instance (Stage 0).
|
|
69
81
|
|
|
70
82
|
Stage 0 covers iframe/ttyd mode on the local host. Resume, seeds,
|
|
@@ -123,7 +135,7 @@ class CursorTaskConfig(ClaustrumConfigMixin, BlobCryptoConfigMixin):
|
|
|
123
135
|
ttyd_install_dir: str | None = None
|
|
124
136
|
|
|
125
137
|
# When True, a fresh launch passes a trailing positional prompt
|
|
126
|
-
# ("Read AGENTS.md and execute the task it describes") so cursor-agent
|
|
138
|
+
# ("System: Read AGENTS.md and execute the task it describes") so cursor-agent
|
|
127
139
|
# starts the task unattended. Defaults False (parity with
|
|
128
140
|
# claudecode/grok/codex): an interactive/conversation task that does not
|
|
129
141
|
# set this must NOT auto-fire a kickoff — it would start an agentic loop
|
|
@@ -207,12 +219,12 @@ class CursorTaskConfig(ClaustrumConfigMixin, BlobCryptoConfigMixin):
|
|
|
207
219
|
thinking_verbosity: ThinkingVerbosity = "hidden"
|
|
208
220
|
|
|
209
221
|
# --- conversation frontend parity (Stage 7) -------------------------
|
|
210
|
-
#
|
|
211
|
-
#
|
|
212
|
-
# (session/set_model — grok's
|
|
213
|
-
# runtime-unverified, see models.py) — no
|
|
214
|
-
# mode="conversation" and
|
|
215
|
-
|
|
222
|
+
# show_session_controls / session_controls come from
|
|
223
|
+
# SessionControlsConfigMixin. Cursor's only control is "model" (the
|
|
224
|
+
# model picker), switched inline over ACP (session/set_model — grok's
|
|
225
|
+
# live-pinned mechanism; cursor runtime-unverified, see models.py) — no
|
|
226
|
+
# process restart. The bar requires mode="conversation" and
|
|
227
|
+
# conversation_ui=True.
|
|
216
228
|
# Replace the generic working-spinner with cursor's on-brand native spinner
|
|
217
229
|
# in the conversation widget. Requires mode='conversation' and
|
|
218
230
|
# conversation_ui=True.
|
|
@@ -246,6 +258,15 @@ class CursorTaskConfig(ClaustrumConfigMixin, BlobCryptoConfigMixin):
|
|
|
246
258
|
# Shared blob-crypto pairing validation (each encrypt/decrypt pair must
|
|
247
259
|
# be set together) — see BlobCryptoConfigMixin.
|
|
248
260
|
self._validate_blob_crypto()
|
|
261
|
+
# Shared session-controls validation (a well-formed session_controls
|
|
262
|
+
# allowlist, only together with show_session_controls) — see
|
|
263
|
+
# SessionControlsConfigMixin.
|
|
264
|
+
self._validate_session_controls()
|
|
265
|
+
self._validate_welcome()
|
|
266
|
+
# This engine cannot hand MCP servers to its agent yet: refuse mcp_servers.
|
|
267
|
+
self._validate_mcp(supported=False, agent=self.agent_type)
|
|
268
|
+
# Nor can it apply custom session controls: refuse a non-empty custom_controls.
|
|
269
|
+
self._validate_custom_controls(supported=False, agent=self.agent_type)
|
|
249
270
|
if self.sandbox is not None and self.sandbox not in _VALID_SANDBOX_MODES:
|
|
250
271
|
raise ValueError(
|
|
251
272
|
f"CursorTaskConfig.sandbox={self.sandbox!r} "
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: optio-cursor
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.6
|
|
4
4
|
Summary: Run Cursor CLI (cursor-agent) as an optio task; local subprocess or remote via SSH; ttyd-served TUI iframe.
|
|
5
5
|
Author-email: Kristof Csillag <kristof.csillag@deai-labs.com>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -20,9 +20,9 @@ Classifier: Topic :: Software Development :: Code Generators
|
|
|
20
20
|
Classifier: Framework :: AsyncIO
|
|
21
21
|
Requires-Python: >=3.11
|
|
22
22
|
Description-Content-Type: text/markdown
|
|
23
|
-
Requires-Dist: optio-core<0.
|
|
23
|
+
Requires-Dist: optio-core<0.7,>=0.6
|
|
24
24
|
Requires-Dist: optio-host<0.4,>=0.3
|
|
25
|
-
Requires-Dist: optio-agents<0.
|
|
25
|
+
Requires-Dist: optio-agents<0.8,>=0.7
|
|
26
26
|
Requires-Dist: asyncssh>=2.14
|
|
27
27
|
Requires-Dist: aiohttp>=3.9
|
|
28
28
|
Provides-Extra: dev
|
|
@@ -23,6 +23,7 @@ src/optio_cursor.egg-info/requires.txt
|
|
|
23
23
|
src/optio_cursor.egg-info/top_level.txt
|
|
24
24
|
tests/test_account.py
|
|
25
25
|
tests/test_agent_info.py
|
|
26
|
+
tests/test_auto_start_prompt.py
|
|
26
27
|
tests/test_caller_message_wiring.py
|
|
27
28
|
tests/test_claustrum_triad.py
|
|
28
29
|
tests/test_config.py
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"""The auto-start kickoff is a harness message, not a human one."""
|
|
2
|
+
|
|
3
|
+
from optio_agents.context import SYSTEM_MESSAGE_PREFIX
|
|
4
|
+
from optio_cursor.host_actions import AUTO_START_PROMPT
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def test_auto_start_prompt_is_a_system_message():
|
|
8
|
+
# The kickoff comes from the harness: it carries the System: prefix every
|
|
9
|
+
# harness message has, so the agent (told that the human may not be
|
|
10
|
+
# present) is not given a turn that reads as the human typing, and the
|
|
11
|
+
# conversation widget renders it as a System row, not a user bubble.
|
|
12
|
+
assert AUTO_START_PROMPT == (
|
|
13
|
+
f"{SYSTEM_MESSAGE_PREFIX}Read AGENTS.md and execute the task it describes"
|
|
14
|
+
)
|
|
@@ -212,6 +212,36 @@ async def test_control_route_forwards_to_conversation(listener):
|
|
|
212
212
|
assert r.status == 409
|
|
213
213
|
|
|
214
214
|
|
|
215
|
+
async def _post_control(conv, body, allowed):
|
|
216
|
+
lst = ConversationListener(conv, password="pw", allowed_controls=allowed)
|
|
217
|
+
port = await lst.start("127.0.0.1")
|
|
218
|
+
try:
|
|
219
|
+
async with aiohttp.ClientSession() as s:
|
|
220
|
+
async with s.post(f"http://127.0.0.1:{port}/control", json=body,
|
|
221
|
+
headers=_auth("pw")) as r:
|
|
222
|
+
return r.status, await r.json()
|
|
223
|
+
finally:
|
|
224
|
+
await lst.stop()
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
async def test_control_route_refuses_an_id_outside_the_allowlist():
|
|
228
|
+
# allowed_controls is the task's settable_controls: a control hidden from
|
|
229
|
+
# the widget cannot be set by posting here directly; [] is the bar off.
|
|
230
|
+
for allowed in (["reasoning_effort"], []):
|
|
231
|
+
conv = FakeConversation()
|
|
232
|
+
status, body = await _post_control(
|
|
233
|
+
conv, {"id": "model", "value": "gpt-5"}, allowed,
|
|
234
|
+
)
|
|
235
|
+
assert status == 403 and body["reason"] == "not-allowed"
|
|
236
|
+
assert conv.control_changes == []
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
async def test_control_route_passes_an_allowed_id_through():
|
|
240
|
+
conv = FakeConversation()
|
|
241
|
+
status, _ = await _post_control(conv, {"id": "model", "value": "gpt-5"}, ["model"])
|
|
242
|
+
assert status == 200 and conv.control_changes == [("model", "gpt-5")]
|
|
243
|
+
|
|
244
|
+
|
|
215
245
|
async def test_permission_roundtrip_by_jsonrpc_id(listener):
|
|
216
246
|
# Cursor's PermissionRequest.raw is the full ACP session/request_permission
|
|
217
247
|
# JSON-RPC object; the listener correlates by its `id`.
|
|
@@ -6,7 +6,9 @@ a live cursor:
|
|
|
6
6
|
text — CLI format runtime-unverified, see models.py header);
|
|
7
7
|
* fetch_available_models source precedence (ACP → CLI → fallback);
|
|
8
8
|
* CursorTaskConfig.show_session_controls validation + the single `model`
|
|
9
|
-
field (harmonization C3 dropped the separate default_model)
|
|
9
|
+
field (harmonization C3 dropped the separate default_model);
|
|
10
|
+
* the session-controls settings from SessionControlsConfigMixin (the
|
|
11
|
+
session_controls allowlist, settable_controls).
|
|
10
12
|
|
|
11
13
|
The inline model-switch mechanism itself (session/set_model over ACP,
|
|
12
14
|
[grok-pinned, cursor runtime-unverified]) is covered at the conversation level
|
|
@@ -180,6 +182,27 @@ def test_show_session_controls_ok_in_conversation_ui():
|
|
|
180
182
|
assert cfg.show_session_controls is True
|
|
181
183
|
|
|
182
184
|
|
|
185
|
+
def test_the_controls_settings_come_from_the_shared_mixin():
|
|
186
|
+
from optio_agents.config_types import SessionControlsConfigMixin
|
|
187
|
+
assert issubclass(CursorTaskConfig, SessionControlsConfigMixin)
|
|
188
|
+
cfg = _cfg(mode="conversation", conversation_ui=True,
|
|
189
|
+
show_session_controls=True, session_controls=["model"])
|
|
190
|
+
assert cfg.settable_controls == ["model"]
|
|
191
|
+
# The bar off: /control may change nothing.
|
|
192
|
+
assert _cfg(mode="conversation", conversation_ui=True).settable_controls == []
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
def test_session_controls_defaults_to_offering_everything():
|
|
196
|
+
cfg = _cfg(mode="conversation", conversation_ui=True, show_session_controls=True)
|
|
197
|
+
assert cfg.session_controls is None
|
|
198
|
+
assert cfg.settable_controls is None
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
def test_session_controls_needs_show_session_controls():
|
|
202
|
+
with pytest.raises(ValueError, match="session_controls"):
|
|
203
|
+
_cfg(mode="conversation", conversation_ui=True, session_controls=["model"])
|
|
204
|
+
|
|
205
|
+
|
|
183
206
|
def test_native_spinner_requires_conversation_ui():
|
|
184
207
|
with pytest.raises(ValueError, match="native_spinner"):
|
|
185
208
|
_cfg(mode="conversation", conversation_ui=False, native_spinner=True)
|
|
@@ -203,3 +226,14 @@ def test_model_is_ungated_single_field():
|
|
|
203
226
|
assert cfg_iframe.model == "gpt-5"
|
|
204
227
|
cfg_conv = _cfg(mode="conversation", conversation_ui=True, model="gpt-5")
|
|
205
228
|
assert cfg_conv.model == "gpt-5"
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
def test_parse_acp_models_keeps_a_models_description():
|
|
233
|
+
from optio_cursor.models import parse_acp_models
|
|
234
|
+
out = parse_acp_models({"currentModelId": "a", "availableModels": [
|
|
235
|
+
{"modelId": "a", "name": "A", "description": "The default model"},
|
|
236
|
+
{"modelId": "b", "name": "B"},
|
|
237
|
+
]})
|
|
238
|
+
assert out["models"][0]["description"] == "The default model"
|
|
239
|
+
assert out["models"][1].get("description") is None
|
|
@@ -3,7 +3,7 @@ note, so it matches the fresh-start composition."""
|
|
|
3
3
|
|
|
4
4
|
import dataclasses
|
|
5
5
|
|
|
6
|
-
from optio_agents import get_protocol
|
|
6
|
+
from optio_agents import RESUME_NOTICE, SYSTEM_MESSAGE_PREFIX, get_protocol
|
|
7
7
|
|
|
8
8
|
from optio_cursor.session import _maybe_refresh_on_resume
|
|
9
9
|
from optio_cursor.types import CursorTaskConfig
|
|
@@ -36,3 +36,19 @@ async def test_refresh_threads_docs_and_sandbox_note():
|
|
|
36
36
|
assert "UPDATED" in text
|
|
37
37
|
assert "CLIENT_MESSAGE:" in text # the session's docs, not defaults
|
|
38
38
|
assert "`/tmp/fake-wd`" in text # sandbox note (fs_isolation default on)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
async def test_refresh_waits_for_the_resume_notice():
|
|
42
|
+
"""Every resume sends the System: resume notice, so the refreshed
|
|
43
|
+
AGENTS.md says to wait for it rather than read resume.log before each
|
|
44
|
+
message."""
|
|
45
|
+
cfg = CursorTaskConfig(
|
|
46
|
+
consumer_instructions="original", delivery_type="audit",
|
|
47
|
+
on_resume_refresh=lambda c: dataclasses.replace(c, consumer_instructions="UPDATED"),
|
|
48
|
+
)
|
|
49
|
+
host = _FakeHost()
|
|
50
|
+
protocol = get_protocol(browser="redirect")
|
|
51
|
+
assert await _maybe_refresh_on_resume(host, _FakeHookCtx(), cfg, protocol) == ["AGENTS.md"]
|
|
52
|
+
(_, text), = host.writes
|
|
53
|
+
assert "At the start of every new incoming user message" not in text
|
|
54
|
+
assert f"`{SYSTEM_MESSAGE_PREFIX}{RESUME_NOTICE}` message on your input channel" in text
|
|
@@ -12,13 +12,16 @@ Adapted from optio-grok's test_session_conversation.py.
|
|
|
12
12
|
from __future__ import annotations
|
|
13
13
|
|
|
14
14
|
import asyncio
|
|
15
|
+
import base64
|
|
15
16
|
import pathlib
|
|
16
17
|
import time as _time
|
|
17
18
|
|
|
19
|
+
import aiohttp
|
|
18
20
|
import pytest
|
|
19
21
|
|
|
20
22
|
from optio_core.lifecycle import Optio
|
|
21
23
|
|
|
24
|
+
from optio_agents import WelcomeCard
|
|
22
25
|
from optio_cursor import CursorTaskConfig, create_cursor_task
|
|
23
26
|
|
|
24
27
|
|
|
@@ -492,6 +495,95 @@ async def test_conversation_ui_file_upload_materialize(
|
|
|
492
495
|
await optio.shutdown(grace_seconds=1.0)
|
|
493
496
|
|
|
494
497
|
|
|
498
|
+
@pytest.mark.asyncio
|
|
499
|
+
async def test_conversation_ui_publishes_the_welcome_card(
|
|
500
|
+
shim_install_dir, task_root, mongo_db, monkeypatch,
|
|
501
|
+
):
|
|
502
|
+
"""config.welcome reaches widgetData's welcome key, its icon rooted at
|
|
503
|
+
the web app."""
|
|
504
|
+
# The ACP session/new models block feeds the model select directly (the
|
|
505
|
+
# shim does not answer the `cursor-agent models` CLI fallback).
|
|
506
|
+
monkeypatch.setenv("FAKE_CURSOR_ACP_MODELS", "m1")
|
|
507
|
+
optio = await _make_optio(mongo_db, "cuconvwelcome")
|
|
508
|
+
try:
|
|
509
|
+
task = create_cursor_task(
|
|
510
|
+
process_id="cu-conv-welcome",
|
|
511
|
+
name="Conversation welcome",
|
|
512
|
+
config=_conversation_config(
|
|
513
|
+
shim_install_dir, conversation_ui=True,
|
|
514
|
+
# A language-map title (published unresolved) and a minimum height.
|
|
515
|
+
welcome=WelcomeCard(
|
|
516
|
+
title={"en": "Hello", "hu": "Szia"}, description="Try **this**.",
|
|
517
|
+
icon="img/w.png", min_height=200,
|
|
518
|
+
),
|
|
519
|
+
),
|
|
520
|
+
)
|
|
521
|
+
await optio.adhoc_define(task)
|
|
522
|
+
conv = await optio.launch_and_await_result(
|
|
523
|
+
"cu-conv-welcome", session_id=None, timeout=60,
|
|
524
|
+
)
|
|
525
|
+
wd = await _wait_widget_data(optio, "cu-conv-welcome")
|
|
526
|
+
assert wd["welcome"] == {
|
|
527
|
+
"title": {"en": "Hello", "hu": "Szia"}, "description": "Try **this**.",
|
|
528
|
+
"icon": "/img/w.png", "minHeight": 200,
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
await conv.close()
|
|
532
|
+
await _wait_terminal(optio, "cu-conv-welcome")
|
|
533
|
+
finally:
|
|
534
|
+
await optio.shutdown(grace_seconds=1.0)
|
|
535
|
+
|
|
536
|
+
|
|
537
|
+
@pytest.mark.asyncio
|
|
538
|
+
@pytest.mark.parametrize("allowlist, shown", [
|
|
539
|
+
(["model"], ["model"]),
|
|
540
|
+
# Only a control cursor does not build: the bar offers nothing.
|
|
541
|
+
(["permission_mode"], []),
|
|
542
|
+
])
|
|
543
|
+
async def test_session_controls_allowlist_narrows_the_widget_controls(
|
|
544
|
+
shim_install_dir, task_root, mongo_db, monkeypatch, allowlist, shown,
|
|
545
|
+
):
|
|
546
|
+
"""session_controls narrows widgetData.controls to the listed ids, and
|
|
547
|
+
the listener's /control refuses an id left out (403 not-allowed)."""
|
|
548
|
+
# The ACP session/new models block feeds the model select directly (the
|
|
549
|
+
# shim does not answer the `cursor-agent models` CLI fallback).
|
|
550
|
+
monkeypatch.setenv("FAKE_CURSOR_ACP_MODELS", "m1")
|
|
551
|
+
optio = await _make_optio(mongo_db, "cuctlallow")
|
|
552
|
+
try:
|
|
553
|
+
task = create_cursor_task(
|
|
554
|
+
process_id="cu-ctl-allow",
|
|
555
|
+
name="Session controls allowlist",
|
|
556
|
+
config=_conversation_config(
|
|
557
|
+
shim_install_dir, conversation_ui=True,
|
|
558
|
+
show_session_controls=True, session_controls=allowlist,
|
|
559
|
+
),
|
|
560
|
+
)
|
|
561
|
+
await optio.adhoc_define(task)
|
|
562
|
+
conv = await optio.launch_and_await_result(
|
|
563
|
+
"cu-ctl-allow", session_id=None, timeout=60,
|
|
564
|
+
)
|
|
565
|
+
wd = await _wait_widget_data(optio, "cu-ctl-allow")
|
|
566
|
+
assert [c["id"] for c in wd["controls"]] == shown
|
|
567
|
+
|
|
568
|
+
# widgetUpstream is written before widgetData.
|
|
569
|
+
upstream = (await optio.get_process("cu-ctl-allow"))["widgetUpstream"]
|
|
570
|
+
token = base64.b64encode(
|
|
571
|
+
f"optio:{upstream['innerAuth']['password']}".encode()
|
|
572
|
+
).decode()
|
|
573
|
+
async with aiohttp.ClientSession() as session:
|
|
574
|
+
async with session.post(
|
|
575
|
+
f"{upstream['url']}/control",
|
|
576
|
+
headers={"Authorization": f"Basic {token}"},
|
|
577
|
+
json={"id": "model", "value": "m1"},
|
|
578
|
+
) as r:
|
|
579
|
+
assert r.status == (200 if "model" in allowlist else 403)
|
|
580
|
+
|
|
581
|
+
await conv.close()
|
|
582
|
+
await _wait_terminal(optio, "cu-ctl-allow")
|
|
583
|
+
finally:
|
|
584
|
+
await optio.shutdown(grace_seconds=1.0)
|
|
585
|
+
|
|
586
|
+
|
|
495
587
|
def test_config_validation_conversation_fields():
|
|
496
588
|
"""__post_init__ mirrors grok's conversation validations."""
|
|
497
589
|
# permission_gate requires conversation mode
|
|
@@ -10,11 +10,15 @@ import pathlib
|
|
|
10
10
|
|
|
11
11
|
import pytest
|
|
12
12
|
|
|
13
|
+
from optio_agents import RESUME_NOTICE, SYSTEM_MESSAGE_PREFIX
|
|
13
14
|
from optio_cursor import (
|
|
14
15
|
CursorTaskConfig,
|
|
15
16
|
create_cursor_task,
|
|
16
17
|
)
|
|
17
18
|
|
|
19
|
+
_POLL_RULE = "At the start of every new incoming user message"
|
|
20
|
+
_NOTICE_RULE = f"`{SYSTEM_MESSAGE_PREFIX}{RESUME_NOTICE}` message on your input channel"
|
|
21
|
+
|
|
18
22
|
|
|
19
23
|
# Spawns cursor-agent in a real tmux/ttyd session; the fixed tmux session name
|
|
20
24
|
# and shared workdir state make these unsafe to run concurrently. Marked
|
|
@@ -72,3 +76,38 @@ async def test_local_error_raises(
|
|
|
72
76
|
)
|
|
73
77
|
with pytest.raises(RuntimeError):
|
|
74
78
|
await task.execute(ctx)
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
@pytest.mark.asyncio
|
|
82
|
+
async def test_local_agents_md_waits_for_the_resume_notice(
|
|
83
|
+
shim_install_dir: pathlib.Path,
|
|
84
|
+
ctx_and_captures,
|
|
85
|
+
monkeypatch,
|
|
86
|
+
):
|
|
87
|
+
"""Every resume is announced with the System: resume notice, so the
|
|
88
|
+
planted AGENTS.md tells cursor to wait for it rather than read
|
|
89
|
+
resume.log before each message."""
|
|
90
|
+
ctx, *_ = ctx_and_captures
|
|
91
|
+
monkeypatch.setenv("FAKE_CURSOR_SCENARIO", "happy")
|
|
92
|
+
observed: dict[str, str] = {}
|
|
93
|
+
|
|
94
|
+
async def capture(hook_ctx):
|
|
95
|
+
observed["agents_md"] = await hook_ctx.read_text_from_host("AGENTS.md", silent=True)
|
|
96
|
+
|
|
97
|
+
task = create_cursor_task(
|
|
98
|
+
process_id="cursor-local-resume-notice",
|
|
99
|
+
name="n",
|
|
100
|
+
config=CursorTaskConfig(
|
|
101
|
+
consumer_instructions="do the thing",
|
|
102
|
+
install_dir=str(shim_install_dir),
|
|
103
|
+
ttyd_install_dir=str(shim_install_dir),
|
|
104
|
+
delivery_type="audit",
|
|
105
|
+
supports_resume=True,
|
|
106
|
+
before_execute=capture,
|
|
107
|
+
),
|
|
108
|
+
)
|
|
109
|
+
await task.execute(ctx)
|
|
110
|
+
|
|
111
|
+
assert "## Resumes" in observed["agents_md"]
|
|
112
|
+
assert _POLL_RULE not in observed["agents_md"]
|
|
113
|
+
assert _NOTICE_RULE in observed["agents_md"]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|