optio-opencode 0.6.7__tar.gz → 0.6.8__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 (72) hide show
  1. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/PKG-INFO +3 -3
  2. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/pyproject.toml +3 -3
  3. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/src/optio_opencode/session.py +4 -2
  4. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/src/optio_opencode.egg-info/PKG-INFO +3 -3
  5. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/src/optio_opencode.egg-info/SOURCES.txt +2 -0
  6. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/src/optio_opencode.egg-info/requires.txt +2 -2
  7. optio_opencode-0.6.8/tests/test_deliverable_metadata_wiring.py +65 -0
  8. optio_opencode-0.6.8/tests/test_engine_venv.py +113 -0
  9. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/tests/test_session_hooks.py +1 -1
  10. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/README.md +0 -0
  11. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/setup.cfg +0 -0
  12. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/src/optio_opencode/__init__.py +0 -0
  13. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/src/optio_opencode/account.py +0 -0
  14. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/src/optio_opencode/conversation.py +0 -0
  15. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/src/optio_opencode/cred_watcher.py +0 -0
  16. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/src/optio_opencode/fs_allowlist.py +0 -0
  17. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/src/optio_opencode/host_actions.py +0 -0
  18. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/src/optio_opencode/info.py +0 -0
  19. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/src/optio_opencode/model_probe.py +0 -0
  20. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/src/optio_opencode/prompt.py +0 -0
  21. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/src/optio_opencode/providers/__init__.py +0 -0
  22. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/src/optio_opencode/providers/anthropic.py +0 -0
  23. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/src/optio_opencode/providers/deepseek.py +0 -0
  24. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/src/optio_opencode/providers/openai.py +0 -0
  25. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/src/optio_opencode/providers/xai.py +0 -0
  26. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/src/optio_opencode/seed_manifest.py +0 -0
  27. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/src/optio_opencode/snapshots.py +0 -0
  28. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/src/optio_opencode/todos.py +0 -0
  29. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/src/optio_opencode/types.py +0 -0
  30. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/src/optio_opencode/verify.py +0 -0
  31. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/src/optio_opencode.egg-info/dependency_links.txt +0 -0
  32. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/src/optio_opencode.egg-info/top_level.txt +0 -0
  33. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/tests/test_account.py +0 -0
  34. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/tests/test_account_xai_apikey.py +0 -0
  35. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/tests/test_agent_info.py +0 -0
  36. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/tests/test_agent_sender_opencode.py +0 -0
  37. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/tests/test_auto_start_prompt.py +0 -0
  38. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/tests/test_claustrum.py +0 -0
  39. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/tests/test_config_harmonization.py +0 -0
  40. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/tests/test_conversation_config.py +0 -0
  41. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/tests/test_conversation_driver.py +0 -0
  42. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/tests/test_conversation_session.py +0 -0
  43. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/tests/test_conversation_ui_model.py +0 -0
  44. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/tests/test_conversation_ui_session.py +0 -0
  45. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/tests/test_conversation_upload.py +0 -0
  46. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/tests/test_cred_watcher.py +0 -0
  47. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/tests/test_file_download.py +0 -0
  48. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/tests/test_file_upload.py +0 -0
  49. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/tests/test_host_actions.py +0 -0
  50. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/tests/test_host_local.py +0 -0
  51. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/tests/test_host_primitives_local.py +0 -0
  52. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/tests/test_host_primitives_remote.py +0 -0
  53. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/tests/test_host_remote_resume.py +0 -0
  54. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/tests/test_host_resume.py +0 -0
  55. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/tests/test_model_probe.py +0 -0
  56. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/tests/test_model_probe_wiring.py +0 -0
  57. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/tests/test_prompt.py +0 -0
  58. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/tests/test_provider_deepseek.py +0 -0
  59. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/tests/test_purge_seed.py +0 -0
  60. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/tests/test_sanity.py +0 -0
  61. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/tests/test_seed_config.py +0 -0
  62. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/tests/test_session_blob_hooks.py +0 -0
  63. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/tests/test_session_local.py +0 -0
  64. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/tests/test_session_remote.py +0 -0
  65. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/tests/test_session_resume.py +0 -0
  66. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/tests/test_session_seed.py +0 -0
  67. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/tests/test_session_seed_saveback.py +0 -0
  68. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/tests/test_smart_install.py +0 -0
  69. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/tests/test_snapshots.py +0 -0
  70. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/tests/test_todos.py +0 -0
  71. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/tests/test_types.py +0 -0
  72. {optio_opencode-0.6.7 → optio_opencode-0.6.8}/tests/test_verify_seed.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: optio-opencode
3
- Version: 0.6.7
3
+ Version: 0.6.8
4
4
  Summary: Run opencode web as an optio task; local subprocess or remote via SSH.
5
5
  Author-email: Kristof Csillag <kristof.csillag@deai-labs.com>
6
6
  License-Expression: Apache-2.0
@@ -22,8 +22,8 @@ Requires-Python: >=3.11
22
22
  Description-Content-Type: text/markdown
23
23
  Requires-Dist: optio-core<0.8,>=0.7
24
24
  Requires-Dist: optio-host<0.5,>=0.4
25
- Requires-Dist: optio-agents<0.8,>=0.7
26
- Requires-Dist: optio-claudecode<0.8,>=0.7
25
+ Requires-Dist: optio-agents<0.9,>=0.8
26
+ Requires-Dist: optio-claudecode<0.9,>=0.8
27
27
  Requires-Dist: optio-codex<0.5,>=0.4
28
28
  Requires-Dist: optio-grok<0.5,>=0.4
29
29
  Requires-Dist: asyncssh>=2.14
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "optio-opencode"
7
- version = "0.6.7"
7
+ version = "0.6.8"
8
8
  description = "Run opencode web as an optio task; local subprocess or remote via SSH."
9
9
  readme = "README.md"
10
10
  license = "Apache-2.0"
@@ -30,11 +30,11 @@ dependencies = [
30
30
  # 0.1.1 introduces the bind_addr kwarg on Host.establish_tunnel —
31
31
  # required for OPTIO_WIDGET_TUNNEL_BIND to work.
32
32
  "optio-host>=0.4,<0.5",
33
- "optio-agents>=0.7,<0.8",
33
+ "optio-agents>=0.8,<0.9",
34
34
  # The account meta-analyzer's per-provider handlers reuse the extracted
35
35
  # vendor map helpers (account_from_oauth_token / account_from_openai /
36
36
  # account_from_xai) rather than reimplement each vendor's fetch+map.
37
- "optio-claudecode>=0.7,<0.8",
37
+ "optio-claudecode>=0.8,<0.9",
38
38
  "optio-codex>=0.4,<0.5",
39
39
  "optio-grok>=0.4,<0.5",
40
40
  "asyncssh>=2.14",
@@ -30,12 +30,13 @@ from typing import AsyncIterator, Callable
30
30
  from optio_core.context import ProcessContext
31
31
  from optio_core.models import BasicAuth, TaskInstance
32
32
 
33
- from optio_agents import HookContext
33
+ from optio_agents import HookContext, agent_entries
34
34
  from optio_agents import RESUME_NOTICE, SYSTEM_MESSAGE_PREFIX
35
35
  from optio_agents.fs_grants import fs_isolation_dirs
36
36
  from optio_host.host import Host, LocalHost, ProcessHandle
37
37
  from optio_host.paths import task_dir
38
38
  from optio_agents.protocol.session import _SessionFailed, run_log_protocol_session
39
+ from optio_agents.session_env import session_env_remove
39
40
  from optio_agents.todos import TodoTracker
40
41
  from optio_agents.uploads import materialize, upload_url_token
41
42
  from optio_agents import seeds as _seeds
@@ -478,7 +479,7 @@ async def run_opencode_session(ctx: ProcessContext, config: OpencodeTaskConfig)
478
479
  opencode_executable=opencode_exec,
479
480
  hostname=opencode_hostname,
480
481
  extra_env={**(config.env or {}), **hook_ctx.browser_launch_env},
481
- env_remove=config.scrub_env,
482
+ env_remove=session_env_remove(config.scrub_env),
482
483
  claustrum_wrap=claustrum_wrap,
483
484
  )
484
485
  launched_handle = handle
@@ -720,6 +721,7 @@ async def run_opencode_session(ctx: ProcessContext, config: OpencodeTaskConfig)
720
721
  protocol=protocol,
721
722
  agent_sender=_agent_sender,
722
723
  keywords=config.host_protocol,
724
+ deliverable_metadata=lambda: agent_entries(config, AGENT_INFO),
723
725
  )
724
726
  except _SessionFailed as fail:
725
727
  session_error = fail
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: optio-opencode
3
- Version: 0.6.7
3
+ Version: 0.6.8
4
4
  Summary: Run opencode web as an optio task; local subprocess or remote via SSH.
5
5
  Author-email: Kristof Csillag <kristof.csillag@deai-labs.com>
6
6
  License-Expression: Apache-2.0
@@ -22,8 +22,8 @@ Requires-Python: >=3.11
22
22
  Description-Content-Type: text/markdown
23
23
  Requires-Dist: optio-core<0.8,>=0.7
24
24
  Requires-Dist: optio-host<0.5,>=0.4
25
- Requires-Dist: optio-agents<0.8,>=0.7
26
- Requires-Dist: optio-claudecode<0.8,>=0.7
25
+ Requires-Dist: optio-agents<0.9,>=0.8
26
+ Requires-Dist: optio-claudecode<0.9,>=0.8
27
27
  Requires-Dist: optio-codex<0.5,>=0.4
28
28
  Requires-Dist: optio-grok<0.5,>=0.4
29
29
  Requires-Dist: asyncssh>=2.14
@@ -39,6 +39,8 @@ tests/test_conversation_ui_model.py
39
39
  tests/test_conversation_ui_session.py
40
40
  tests/test_conversation_upload.py
41
41
  tests/test_cred_watcher.py
42
+ tests/test_deliverable_metadata_wiring.py
43
+ tests/test_engine_venv.py
42
44
  tests/test_file_download.py
43
45
  tests/test_file_upload.py
44
46
  tests/test_host_actions.py
@@ -1,7 +1,7 @@
1
1
  optio-core<0.8,>=0.7
2
2
  optio-host<0.5,>=0.4
3
- optio-agents<0.8,>=0.7
4
- optio-claudecode<0.8,>=0.7
3
+ optio-agents<0.9,>=0.8
4
+ optio-claudecode<0.9,>=0.8
5
5
  optio-codex<0.5,>=0.4
6
6
  optio-grok<0.5,>=0.4
7
7
  asyncssh>=2.14
@@ -0,0 +1,65 @@
1
+ """Deliverable metadata wiring: the driver gets the base entries.
2
+
3
+ ``run_opencode_session`` must hand ``run_log_protocol_session`` a
4
+ ``deliverable_metadata`` provider that returns the agent type and the agent's
5
+ name. Pure wiring test: ``_build_host``, ``get_protocol`` and
6
+ ``run_log_protocol_session`` are stubbed so nothing is spawned and no MongoDB is
7
+ needed. With the driver stubbed, the outer shell awaits only ``host.connect``
8
+ and, in its ``finally``, ``host.cleanup_taskdir`` and ``host.disconnect``.
9
+ """
10
+
11
+ from __future__ import annotations
12
+
13
+ from unittest.mock import patch
14
+
15
+ from optio_agents import KEY_AGENT_NAME, KEY_AGENT_TYPE, SOURCE_CONFIG
16
+ from optio_agents.deliverable_meta import entry
17
+ from optio_opencode import OpencodeTaskConfig
18
+ from optio_opencode import session as opencode_session
19
+ from optio_opencode.info import AGENT_INFO
20
+
21
+
22
+ class _FakeHost:
23
+ async def connect(self):
24
+ pass
25
+
26
+ async def disconnect(self):
27
+ pass
28
+
29
+ async def cleanup_taskdir(self, aggressive=False):
30
+ pass
31
+
32
+
33
+ class _FakeCtx:
34
+ process_id = "p"
35
+
36
+ def should_continue(self):
37
+ return True
38
+
39
+
40
+ async def _capture_wiring(config):
41
+ """Run run_opencode_session with stubs; return (protocol_kwargs, run_kwargs)."""
42
+ captured: dict = {}
43
+
44
+ def _fake_get_protocol(**kwargs):
45
+ captured["protocol"] = kwargs
46
+ return object() # opaque; run_log is stubbed so it is never inspected
47
+
48
+ async def _fake_run_log(host, ctx, **kwargs):
49
+ captured["run"] = kwargs
50
+
51
+ with patch.object(opencode_session, "_build_host", lambda c, pid: _FakeHost()), \
52
+ patch.object(opencode_session, "get_protocol", _fake_get_protocol), \
53
+ patch.object(opencode_session, "run_log_protocol_session", _fake_run_log):
54
+ await opencode_session.run_opencode_session(_FakeCtx(), config)
55
+ return captured["protocol"], captured["run"]
56
+
57
+
58
+ async def test_the_driver_gets_the_base_deliverable_entries(): # RF5
59
+ config = OpencodeTaskConfig(consumer_instructions="x", delivery_type="audit")
60
+ _proto, run = await _capture_wiring(config)
61
+ assert run["deliverable_metadata"]() == [
62
+ entry(KEY_AGENT_TYPE, config.agent_type, SOURCE_CONFIG),
63
+ entry(KEY_AGENT_NAME, AGENT_INFO.name, SOURCE_CONFIG),
64
+ ]
65
+ assert config.agent_type == AGENT_INFO.slug
@@ -0,0 +1,113 @@
1
+ """Agent sessions never inherit the engine's virtualenv (optio_agents.session_env).
2
+
3
+ The engine is made to look like it runs from a venv (sys.prefix /
4
+ sys.base_prefix / VIRTUAL_ENV monkeypatched, the venv's bin leading PATH). The
5
+ real session runs up to ``opencode web``'s launch; that launch is recorded and
6
+ replaced by ``/usr/bin/env`` under the same env and env_remove, so the test
7
+ reads the environment LocalHost really builds for the child, then the session
8
+ stops.
9
+ """
10
+
11
+ from __future__ import annotations
12
+
13
+ import asyncio
14
+ import os
15
+ import sys
16
+
17
+ import pytest
18
+ import pytest_asyncio
19
+ from bson import ObjectId
20
+
21
+ from optio_core.context import ProcessContext
22
+ from optio_host.host import LocalHost, proc_wait
23
+
24
+ from optio_opencode import host_actions
25
+ from optio_opencode.session import run_opencode_session
26
+ from optio_opencode.types import OpencodeTaskConfig
27
+
28
+ pytestmark = pytest.mark.serial
29
+
30
+ _LAUNCH = LocalHost.launch_subprocess
31
+
32
+
33
+ class _Launched(Exception):
34
+ """Raised in place of the agent launch once it is recorded."""
35
+
36
+
37
+ @pytest_asyncio.fixture
38
+ async def ctx(mongo_db):
39
+ oid = ObjectId()
40
+ await mongo_db["test_processes"].insert_one({
41
+ "_id": oid, "processId": "p", "name": "P", "params": {}, "metadata": {},
42
+ "parentId": None, "rootId": None, "depth": 0, "order": 0, "adhoc": False,
43
+ "ephemeral": False, "status": {"state": "running"},
44
+ "progress": {"percent": None, "message": None}, "log": [],
45
+ })
46
+ return ProcessContext(
47
+ process_oid=oid, process_id="p", root_oid=oid, depth=0, params={}, services={},
48
+ db=mongo_db, prefix="test", cancellation_flag=asyncio.Event(),
49
+ child_counter={"next": 0},
50
+ )
51
+
52
+
53
+ @pytest.fixture
54
+ def engine_venv(tmp_path, monkeypatch) -> str:
55
+ venv = tmp_path / "engine-venv"
56
+ (venv / "bin").mkdir(parents=True)
57
+ monkeypatch.setattr(sys, "prefix", str(venv))
58
+ monkeypatch.setattr(sys, "base_prefix", "/opt/base-python")
59
+ monkeypatch.setenv("VIRTUAL_ENV", str(venv))
60
+ monkeypatch.setenv("PYTHONPATH", os.pathsep.join(
61
+ p for p in (str(venv / "lib"), os.environ.get("PYTHONPATH")) if p))
62
+ monkeypatch.setenv("PATH", f"{venv}/bin:{os.environ['PATH']}")
63
+ return f"{venv}/bin"
64
+
65
+
66
+ async def _child_env(host, kw) -> dict[str, str]:
67
+ probe = await _LAUNCH(host, "/usr/bin/env", env=kw.get("env"), env_remove=kw.get("env_remove"))
68
+ out = b"".join([chunk async for chunk in probe.stdout])
69
+ await proc_wait(probe)
70
+ env: dict[str, str] = {}
71
+ for line in out.decode("utf-8", "replace").splitlines():
72
+ name, sep, value = line.partition("=")
73
+ if sep and name.isidentifier():
74
+ env.setdefault(name, value)
75
+ return env
76
+
77
+
78
+ def _capture_launch(monkeypatch, is_agent) -> dict:
79
+ seen: dict = {}
80
+
81
+ async def _launch(self, command, **kw):
82
+ if seen or not is_agent(command):
83
+ return await _LAUNCH(self, command, **kw)
84
+ seen["command"] = command
85
+ seen["env"] = await _child_env(self, kw)
86
+ raise _Launched(command)
87
+
88
+ monkeypatch.setattr(LocalHost, "launch_subprocess", _launch)
89
+ return seen
90
+
91
+
92
+ async def test_the_web_launch_inherits_no_engine_venv(engine_venv, ctx, monkeypatch):
93
+ async def _ensure(host, **kwargs):
94
+ return "opencode"
95
+
96
+ async def _version(host, *, opencode_executable="opencode"):
97
+ return None
98
+
99
+ monkeypatch.setattr(host_actions, "ensure_opencode_installed", _ensure)
100
+ monkeypatch.setattr(host_actions, "opencode_version", _version)
101
+ seen = _capture_launch(monkeypatch, lambda cmd: " web --port=0" in cmd)
102
+ config = OpencodeTaskConfig(
103
+ consumer_instructions="do it", fs_isolation=False, supports_resume=False,
104
+ )
105
+ try:
106
+ await run_opencode_session(ctx, config)
107
+ except Exception: # noqa: BLE001 - the recorded launch stops the session
108
+ pass
109
+
110
+ assert seen, "opencode was never launched"
111
+ path = seen["env"]["PATH"].split(":")
112
+ assert engine_venv not in path and "/usr/bin" in path
113
+ assert not {"VIRTUAL_ENV", "PYTHONPATH"} & set(seen["env"])
@@ -259,7 +259,7 @@ async def test_on_deliverable_receives_hook_ctx_and_can_use_host_primitives(tmp_
259
259
  from optio_agents import HookContext
260
260
 
261
261
  queue = asyncio.Queue()
262
- await queue.put(("/wd/deliverables/x.txt", "x.txt"))
262
+ await queue.put(("/wd/deliverables/x.txt", "x.txt", []))
263
263
 
264
264
  # Patch host.fetch_bytes_from_host to return canned content; the
265
265
  # free fetch_deliverable_text helper used by _deliverable_fetch_loop
File without changes
File without changes