opencode-agent-sdk 0.4.10__tar.gz → 0.4.12__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 (25) hide show
  1. {opencode_agent_sdk-0.4.10 → opencode_agent_sdk-0.4.12}/PKG-INFO +1 -1
  2. {opencode_agent_sdk-0.4.10 → opencode_agent_sdk-0.4.12}/pyproject.toml +1 -1
  3. {opencode_agent_sdk-0.4.10 → opencode_agent_sdk-0.4.12}/src/opencode_agent_sdk/__init__.py +1 -1
  4. {opencode_agent_sdk-0.4.10 → opencode_agent_sdk-0.4.12}/src/opencode_agent_sdk/_internal/acp.py +17 -0
  5. {opencode_agent_sdk-0.4.10 → opencode_agent_sdk-0.4.12}/src/opencode_agent_sdk/client.py +13 -1
  6. {opencode_agent_sdk-0.4.10 → opencode_agent_sdk-0.4.12}/src/opencode_agent_sdk.egg-info/PKG-INFO +1 -1
  7. {opencode_agent_sdk-0.4.10 → opencode_agent_sdk-0.4.12}/README.md +0 -0
  8. {opencode_agent_sdk-0.4.10 → opencode_agent_sdk-0.4.12}/setup.cfg +0 -0
  9. {opencode_agent_sdk-0.4.10 → opencode_agent_sdk-0.4.12}/src/opencode_agent_sdk/_errors.py +0 -0
  10. {opencode_agent_sdk-0.4.10 → opencode_agent_sdk-0.4.12}/src/opencode_agent_sdk/_internal/__init__.py +0 -0
  11. {opencode_agent_sdk-0.4.10 → opencode_agent_sdk-0.4.12}/src/opencode_agent_sdk/_internal/http_transport.py +0 -0
  12. {opencode_agent_sdk-0.4.10 → opencode_agent_sdk-0.4.12}/src/opencode_agent_sdk/_internal/transport.py +0 -0
  13. {opencode_agent_sdk-0.4.10 → opencode_agent_sdk-0.4.12}/src/opencode_agent_sdk/_mcp_bridge.py +0 -0
  14. {opencode_agent_sdk-0.4.10 → opencode_agent_sdk-0.4.12}/src/opencode_agent_sdk/model_registry.py +0 -0
  15. {opencode_agent_sdk-0.4.10 → opencode_agent_sdk-0.4.12}/src/opencode_agent_sdk/tools.py +0 -0
  16. {opencode_agent_sdk-0.4.10 → opencode_agent_sdk-0.4.12}/src/opencode_agent_sdk/types.py +0 -0
  17. {opencode_agent_sdk-0.4.10 → opencode_agent_sdk-0.4.12}/src/opencode_agent_sdk.egg-info/SOURCES.txt +0 -0
  18. {opencode_agent_sdk-0.4.10 → opencode_agent_sdk-0.4.12}/src/opencode_agent_sdk.egg-info/dependency_links.txt +0 -0
  19. {opencode_agent_sdk-0.4.10 → opencode_agent_sdk-0.4.12}/src/opencode_agent_sdk.egg-info/requires.txt +0 -0
  20. {opencode_agent_sdk-0.4.10 → opencode_agent_sdk-0.4.12}/src/opencode_agent_sdk.egg-info/top_level.txt +0 -0
  21. {opencode_agent_sdk-0.4.10 → opencode_agent_sdk-0.4.12}/tests/test_common.py +0 -0
  22. {opencode_agent_sdk-0.4.10 → opencode_agent_sdk-0.4.12}/tests/test_model_registry.py +0 -0
  23. {opencode_agent_sdk-0.4.10 → opencode_agent_sdk-0.4.12}/tests/test_opencode_agent.py +0 -0
  24. {opencode_agent_sdk-0.4.10 → opencode_agent_sdk-0.4.12}/tests/test_runner.py +0 -0
  25. {opencode_agent_sdk-0.4.10 → opencode_agent_sdk-0.4.12}/tests/test_types.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: opencode-agent-sdk
3
- Version: 0.4.10
3
+ Version: 0.4.12
4
4
  Summary: Open-source Agent SDK backed by OpenCode ACP (drop-in replacement for claude_agent_sdk)
5
5
  Author: OpenCode
6
6
  License: MIT
@@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
6
6
  name = "opencode-agent-sdk"
7
7
 
8
8
 
9
- version = "0.4.10"
9
+ version = "0.4.12"
10
10
  description = "Open-source Agent SDK backed by OpenCode ACP (drop-in replacement for claude_agent_sdk)"
11
11
  readme = "README.md"
12
12
  requires-python = ">=3.10"
@@ -31,4 +31,4 @@ __all__ = [
31
31
  "tool",
32
32
  ]
33
33
 
34
- __version__ = "0.4.10"
34
+ __version__ = "0.4.12"
@@ -8,6 +8,7 @@ from __future__ import annotations
8
8
 
9
9
  import asyncio
10
10
  import logging
11
+ import time
11
12
  import uuid
12
13
  from typing import Any, AsyncIterator
13
14
 
@@ -98,7 +99,23 @@ class ACPSession:
98
99
  async def _read_loop(self) -> None:
99
100
  """Read messages from transport and route them."""
100
101
  try:
102
+ _msg_count = 0
103
+ _first_ts: float | None = None
101
104
  async for msg in self._transport.read_messages():
105
+ _msg_count += 1
106
+ now = time.monotonic()
107
+ if _first_ts is None:
108
+ _first_ts = now
109
+ method = msg.get("method", "")
110
+ if method in ("session/update", "sessionUpdate"):
111
+ params = msg.get("params", {})
112
+ update = params.get("update", params)
113
+ utype = update.get("sessionUpdate", "")
114
+ elapsed = now - _first_ts
115
+ logger.info(
116
+ "ACP msg #%d t=%.3fs type=%s",
117
+ _msg_count, elapsed, utype,
118
+ )
102
119
  await self._handle_message(msg)
103
120
  except Exception as exc:
104
121
  logger.debug("Reader loop ended: %s", exc)
@@ -66,6 +66,7 @@ class SDKClient:
66
66
  self._http_mode = bool(options.server_url)
67
67
  self._pending_parts: dict[str, Any] | None = None
68
68
  self._mcp_bridge: Any = None # McpHttpBridge for SDK MCP servers
69
+ self._prompt_task: Any = None # Background task for subprocess prompt
69
70
 
70
71
  async def connect(self) -> None:
71
72
  """Connect to opencode — either via HTTP or subprocess ACP."""
@@ -208,7 +209,13 @@ class SDKClient:
208
209
  # Subprocess mode: send via ACP session
209
210
  if self._session is None:
210
211
  raise ProcessError("Not connected. Call connect() first.", exit_code=1)
211
- await self._session.prompt(parts)
212
+ # Launch prompt as a background task so receive_response() can
213
+ # start consuming sessionUpdate notifications immediately
214
+ # (streaming). If we awaited prompt() here, all notifications
215
+ # would queue up and only be drained after the full turn
216
+ # completes, defeating streaming.
217
+ import asyncio
218
+ self._prompt_task = asyncio.create_task(self._session.prompt(parts))
212
219
 
213
220
  async def receive_response(
214
221
  self,
@@ -251,6 +258,11 @@ class SDKClient:
251
258
  async for msg in self._session.receive_messages():
252
259
  yield msg
253
260
 
261
+ # Await the background prompt task to propagate any errors
262
+ if self._prompt_task is not None:
263
+ await self._prompt_task
264
+ self._prompt_task = None
265
+
254
266
 
255
267
  def _build_mcp_servers(servers: dict[str, Any]) -> list[dict[str, Any]]:
256
268
  """Convert the mcp_servers dict to ACP mcpServers wire format.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: opencode-agent-sdk
3
- Version: 0.4.10
3
+ Version: 0.4.12
4
4
  Summary: Open-source Agent SDK backed by OpenCode ACP (drop-in replacement for claude_agent_sdk)
5
5
  Author: OpenCode
6
6
  License: MIT