py-opencode-wrapper 0.1.2__py3-none-any.whl → 0.1.4__py3-none-any.whl
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.
- opencode_wrapper/client.py +10 -0
- opencode_wrapper/config.py +3 -0
- {py_opencode_wrapper-0.1.2.dist-info → py_opencode_wrapper-0.1.4.dist-info}/METADATA +9 -6
- py_opencode_wrapper-0.1.4.dist-info/RECORD +9 -0
- py_opencode_wrapper-0.1.2.dist-info/RECORD +0 -9
- {py_opencode_wrapper-0.1.2.dist-info → py_opencode_wrapper-0.1.4.dist-info}/WHEEL +0 -0
- {py_opencode_wrapper-0.1.2.dist-info → py_opencode_wrapper-0.1.4.dist-info}/top_level.txt +0 -0
opencode_wrapper/client.py
CHANGED
|
@@ -214,6 +214,16 @@ class AsyncOpenCodeClient:
|
|
|
214
214
|
# and SQLite write locks during tool execution serialize the runs (37–46s delays).
|
|
215
215
|
if self._isolate_db:
|
|
216
216
|
xdg_tmpdir = tempfile.mkdtemp(prefix="oc_xdg_")
|
|
217
|
+
# Symlink auth.json so provider API keys (stored by `opencode auth`)
|
|
218
|
+
# are visible in the isolated data dir. Without this, providers
|
|
219
|
+
# that rely on auth.json (rather than env-var keys) fail with
|
|
220
|
+
# "Model not found" because the provider never activates.
|
|
221
|
+
real_xdg = env.get("XDG_DATA_HOME", str(Path.home() / ".local" / "share"))
|
|
222
|
+
real_auth = Path(real_xdg) / "opencode" / "auth.json"
|
|
223
|
+
if real_auth.is_file():
|
|
224
|
+
iso_oc_dir = Path(xdg_tmpdir) / "opencode"
|
|
225
|
+
iso_oc_dir.mkdir(parents=True, exist_ok=True)
|
|
226
|
+
(iso_oc_dir / "auth.json").symlink_to(real_auth)
|
|
217
227
|
env = {**env, "XDG_DATA_HOME": xdg_tmpdir}
|
|
218
228
|
else:
|
|
219
229
|
xdg_tmpdir = None
|
opencode_wrapper/config.py
CHANGED
|
@@ -55,6 +55,7 @@ class RunConfig:
|
|
|
55
55
|
permission: PermissionMap | None = None
|
|
56
56
|
mcp: dict[str, Any] | None = None
|
|
57
57
|
tools: dict[str, Any] | None = None
|
|
58
|
+
instructions: list[str] | None = None
|
|
58
59
|
config_overrides: dict[str, Any] | None = None
|
|
59
60
|
|
|
60
61
|
def build_opencode_config_dict(self) -> dict[str, Any]:
|
|
@@ -68,6 +69,8 @@ class RunConfig:
|
|
|
68
69
|
merged = _deep_merge(merged, {"mcp": dict(self.mcp)})
|
|
69
70
|
if self.tools is not None:
|
|
70
71
|
merged = _deep_merge(merged, {"tools": dict(self.tools)})
|
|
72
|
+
if self.instructions is not None:
|
|
73
|
+
merged = _deep_merge(merged, {"instructions": list(self.instructions)})
|
|
71
74
|
return merged
|
|
72
75
|
|
|
73
76
|
def opencode_config_content_json(self) -> str | None:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: py-opencode-wrapper
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.4
|
|
4
4
|
Summary: Async Python wrapper for OpenCode CLI (opencode run --format json)
|
|
5
5
|
Project-URL: Homepage, https://github.com/idailylife/oc_py_wrapper
|
|
6
6
|
Project-URL: Repository, https://github.com/idailylife/oc_py_wrapper
|
|
@@ -101,12 +101,13 @@ Per-call JSON is merged and passed as `OPENCODE_CONFIG_CONTENT` (see [OpenCode c
|
|
|
101
101
|
|
|
102
102
|
| Field | Purpose |
|
|
103
103
|
|--------|---------|
|
|
104
|
-
| `permission` | `permission` map (`allow` / `
|
|
104
|
+
| `permission` | `permission` map (`allow` / `deny`, patterns) |
|
|
105
105
|
| `mcp` | MCP server definitions |
|
|
106
106
|
| `tools` | Enable/disable tools (including MCP globs) |
|
|
107
107
|
| `config_overrides` | Any extra top-level config keys to deep-merge |
|
|
108
108
|
|
|
109
109
|
Optional env tuning: `disable_autoupdate=True` sets `OPENCODE_DISABLE_AUTOUPDATE=1`.
|
|
110
|
+
Note: `ask` is intentionally rejected in subprocess mode (no interactive terminal); use `allow` or `deny`.
|
|
110
111
|
|
|
111
112
|
## CLI arguments
|
|
112
113
|
|
|
@@ -147,13 +148,15 @@ Default `pytest -q` runs **all** tests; use `-m "not integration"` in CI without
|
|
|
147
148
|
|
|
148
149
|
## Concurrency notes
|
|
149
150
|
|
|
150
|
-
When running many tasks with `asyncio.gather`,
|
|
151
|
+
When running many tasks with `asyncio.gather`, three protections are enabled by default:
|
|
151
152
|
|
|
152
|
-
**Startup serialisation** — `
|
|
153
|
+
**Startup serialisation** — `startup_concurrency=1` and `startup_delay_s=0.3` limit how many processes enter SQLite startup at once, reducing WAL-initialisation race crashes.
|
|
153
154
|
|
|
154
|
-
**
|
|
155
|
+
**DB isolation** — `isolate_db=True` gives each run a private `XDG_DATA_HOME`, so concurrent runs do not contend on the same `opencode.db` during tool execution.
|
|
155
156
|
|
|
156
|
-
|
|
157
|
+
**Automatic retry** — `async_run(max_retries=2, retry_delay_s=1.0)` retries known SQLite-startup crashes with short backoff. Non-SQLite failures still fail fast.
|
|
158
|
+
|
|
159
|
+
Set `startup_concurrency=0`, `isolate_db=False`, and `max_retries=0` to opt out.
|
|
157
160
|
|
|
158
161
|
## Notes
|
|
159
162
|
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
opencode_wrapper/__init__.py,sha256=iCkMcrh7P35jHFq8gH-GKjaKqwnvmOkGCLRfgnb0moE,1013
|
|
2
|
+
opencode_wrapper/client.py,sha256=wVVxBHyYey-uqwRn4Q6QKazWNOJ3gXrN-ltO5W66CqM,14523
|
|
3
|
+
opencode_wrapper/config.py,sha256=fu4irU22Dj__E6WIVqM2m61vc9J3nQyWV0FPp8Xo3VM,4040
|
|
4
|
+
opencode_wrapper/errors.py,sha256=zaXzzFb6ObdrNlm-PJE_7tbgvMEhoZcbeQVWNHNTkUQ,1168
|
|
5
|
+
opencode_wrapper/events.py,sha256=PHz04DcB0K0JfIRxgV8GQ3psl7VjQXZ25gIrDCOgAHQ,6478
|
|
6
|
+
py_opencode_wrapper-0.1.4.dist-info/METADATA,sha256=-7aVOAiIIWQWDoOEzjoY6Lwa7Op_siT7C2P6Zp0RgnU,5941
|
|
7
|
+
py_opencode_wrapper-0.1.4.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
8
|
+
py_opencode_wrapper-0.1.4.dist-info/top_level.txt,sha256=8LETj5bPgl1YnB83iOiueuQvGryj3RzaeEQecPVS9Q8,17
|
|
9
|
+
py_opencode_wrapper-0.1.4.dist-info/RECORD,,
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
opencode_wrapper/__init__.py,sha256=iCkMcrh7P35jHFq8gH-GKjaKqwnvmOkGCLRfgnb0moE,1013
|
|
2
|
-
opencode_wrapper/client.py,sha256=YY7K8R6AcNWrOw595KazcLf1Q--CJgHvt6IJNT9cvOQ,13846
|
|
3
|
-
opencode_wrapper/config.py,sha256=5vOlqc0YvPeFjmY9IH4DZYhhU3nKVp54Nt2KSeQaQUQ,3872
|
|
4
|
-
opencode_wrapper/errors.py,sha256=zaXzzFb6ObdrNlm-PJE_7tbgvMEhoZcbeQVWNHNTkUQ,1168
|
|
5
|
-
opencode_wrapper/events.py,sha256=PHz04DcB0K0JfIRxgV8GQ3psl7VjQXZ25gIrDCOgAHQ,6478
|
|
6
|
-
py_opencode_wrapper-0.1.2.dist-info/METADATA,sha256=oT5MX1VOFtda9apHKONfEe_scVz3Z0PdBiNhPVMGyNg,6012
|
|
7
|
-
py_opencode_wrapper-0.1.2.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
8
|
-
py_opencode_wrapper-0.1.2.dist-info/top_level.txt,sha256=8LETj5bPgl1YnB83iOiueuQvGryj3RzaeEQecPVS9Q8,17
|
|
9
|
-
py_opencode_wrapper-0.1.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|