overcode 0.6.2__py3-none-any.whl → 0.6.5__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.
- overcode/agent_files.py +18 -3
- overcode/agent_identity.py +16 -0
- overcode/agent_io.py +63 -6
- overcode/backends/__init__.py +4 -0
- overcode/backends/base.py +102 -0
- overcode/backends/claude_code.py +7 -0
- overcode/backends/codex.py +23 -1
- overcode/backends/grok.py +11 -0
- overcode/backends/grok_stats.py +2 -2
- overcode/backends/hermes.py +10 -0
- overcode/backends/opencode.py +65 -2
- overcode/backends/opencode2.py +62 -19
- overcode/backends/opencode2_stats.py +23 -2
- overcode/backends/opencode_stats.py +126 -8
- overcode/backends/shell.py +2 -0
- overcode/background_shells.py +331 -0
- overcode/budget_gate.py +189 -0
- overcode/bundled_skills.py +37 -0
- overcode/child_lifecycle.py +78 -4
- overcode/claude_bg.py +85 -17
- overcode/cli/__init__.py +4 -0
- overcode/cli/_shared.py +16 -0
- overcode/cli/agent.py +403 -28
- overcode/cli/archive.py +227 -0
- overcode/cli/budget.py +126 -8
- overcode/cli/config.py +31 -0
- overcode/cli/doctor.py +7 -0
- overcode/cli/gateway.py +463 -0
- overcode/cli/jobs.py +98 -4
- overcode/cli/monitoring.py +1 -3
- overcode/cli/perms.py +14 -0
- overcode/cli/quota.py +0 -2
- overcode/cli/shells.py +144 -0
- overcode/cli/spend.py +428 -0
- overcode/cli/view.py +3 -3
- overcode/columns/column.py +20 -0
- overcode/columns/context.py +112 -2
- overcode/columns/emoji.py +5 -5
- overcode/columns/hover.py +174 -10
- overcode/columns/layout.py +23 -1
- overcode/columns/registry.py +202 -17
- overcode/columns/render_git.py +11 -3
- overcode/columns/render_identity.py +41 -0
- overcode/columns/render_performance.py +49 -0
- overcode/columns/render_supervision.py +39 -3
- overcode/columns/render_usage.py +86 -2
- overcode/columns/render_virtual.py +24 -0
- overcode/command_palette.py +95 -2
- overcode/config.py +317 -2
- overcode/daemon_housekeeping.py +83 -1
- overcode/daemon_process_probe.py +4 -0
- overcode/daemon_shell_probe.py +148 -0
- overcode/daemon_stats_sync.py +3 -2
- overcode/data/keymaps/classic.yaml +27 -0
- overcode/data_export.py +1 -1
- overcode/docs/README.md +34 -15
- overcode/docs/advanced-features.md +16 -8
- overcode/docs/backends.md +19 -13
- overcode/docs/children.md +58 -0
- overcode/docs/claude-session-files.md +1 -1
- overcode/docs/cli-reference.md +99 -2
- overcode/docs/configuration.md +151 -13
- overcode/docs/design/483-484/00_overview.md +1 -1
- overcode/docs/design/README.md +58 -84
- overcode/docs/design/agent-agnostic-backends-opencode.md +4 -4
- overcode/docs/design/agent-backends-codex-grok.md +8 -8
- overcode/docs/design/agent-observability-0.6.1.md +42 -0
- overcode/docs/design/{acp-agent-integration-analysis.md → archive/acp-agent-integration-analysis.md} +3 -1
- overcode/docs/design/{bakeoffs → archive/bakeoffs}/README.md +2 -0
- overcode/docs/design/{bakeoffs → archive/bakeoffs}/SYNTHESIS.md +2 -0
- overcode/docs/design/{bakeoffs → archive/bakeoffs}/candidates.md +2 -0
- overcode/docs/design/{bakeoffs → archive/bakeoffs}/overcode-vs-bernstein.md +2 -0
- overcode/docs/design/{bakeoffs → archive/bakeoffs}/overcode-vs-bobbit.md +2 -0
- overcode/docs/design/{bakeoffs → archive/bakeoffs}/overcode-vs-ccmanager.md +2 -0
- overcode/docs/design/{bakeoffs → archive/bakeoffs}/overcode-vs-claude-squad.md +3 -1
- overcode/docs/design/{bakeoffs → archive/bakeoffs}/overcode-vs-cmux.md +2 -0
- overcode/docs/design/{bakeoffs → archive/bakeoffs}/overcode-vs-composio.md +2 -0
- overcode/docs/design/{bakeoffs → archive/bakeoffs}/overcode-vs-dmux.md +2 -0
- overcode/docs/design/{bakeoffs → archive/bakeoffs}/overcode-vs-gastown.md +2 -0
- overcode/docs/design/{bakeoffs → archive/bakeoffs}/overcode-vs-kagan.md +2 -0
- overcode/docs/design/{bakeoffs → archive/bakeoffs}/overcode-vs-orca.md +2 -0
- overcode/docs/design/{bakeoffs → archive/bakeoffs}/overcode-vs-superset.md +2 -0
- overcode/docs/design/{bakeoffs → archive/bakeoffs}/overcode-vs-vibe-kanban.md +2 -0
- overcode/docs/design/{bakeoffs → archive/bakeoffs}/zellij-vs-tmux.md +2 -0
- overcode/docs/design/archive/budget-columns-review.md +97 -0
- overcode/docs/design/archive/code-quality-audit-2026-03.md +596 -0
- overcode/docs/design/{opencode-parity.md → archive/opencode-parity.md} +8 -4
- overcode/docs/design/{opencode-stats-reader-performance.md → archive/opencode-stats-reader-performance.md} +2 -0
- overcode/docs/design/{quality-review-2026-10.md → archive/quality-review-2026-10.md} +2 -0
- overcode/docs/design/{scaling-audit-2026-09-22.md → archive/scaling-audit-2026-09-22/scaling-audit-2026-09-22.md} +3 -1
- overcode/docs/{tui-refactoring-plan.md → design/archive/tui-refactoring-plan.md} +2 -0
- overcode/docs/{ux-performance-analysis-2026-03-09.md → design/archive/ux-performance-analysis-2026-03-09.md} +2 -0
- overcode/docs/design/background-shell-classification.md +42 -1
- overcode/docs/design/billing-code-ids.md +2 -2
- overcode/docs/design/cost-model-0.6.1.md +1 -1
- overcode/docs/design/e2e-devcontainer-testing.md +3 -3
- overcode/docs/design/experiment-billing.md +408 -0
- overcode/docs/experiment-billing.md +290 -0
- overcode/docs/getting-started.md +1 -1
- overcode/docs/release-notes-0.6.1.md +6 -47
- overcode/docs/{release-notes-0.5.1.md → releases/release-notes-0.5.1.md} +1 -1
- overcode/docs/{release-notes-0.6.0.md → releases/release-notes-0.6.0.md} +1 -1
- overcode/docs/releases/release-notes-0.6.1.md +49 -0
- overcode/docs/releases/release-notes-0.6.3.md +51 -0
- overcode/docs/releases/release-notes-0.6.4.md +46 -0
- overcode/docs/releases/release-notes-0.6.5.md +33 -0
- overcode/docs/skill-profiles.md +2 -2
- overcode/docs/tui-guide.md +96 -27
- overcode/doctor.py +53 -0
- overcode/engine_recorders.py +13 -7
- overcode/engine_wake.py +19 -0
- overcode/ext_spend_view.py +99 -0
- overcode/external_spend.py +586 -0
- overcode/follow_mode.py +224 -7
- overcode/gateway.py +559 -0
- overcode/gateway_server.py +908 -0
- overcode/gateway_supervisor.py +262 -0
- overcode/git_context.py +97 -33
- overcode/heartbeat_sender.py +92 -0
- overcode/hook_handler.py +75 -5
- overcode/hook_status_detector.py +86 -6
- overcode/job_launcher.py +45 -14
- overcode/journey.py +3 -1
- overcode/keymap.py +1 -1
- overcode/launcher.py +73 -8
- overcode/ledger.py +80 -28
- overcode/lifecycle.py +193 -41
- overcode/monitor_daemon.py +257 -42
- overcode/monitor_daemon_state.py +47 -5
- overcode/paths.py +11 -0
- overcode/quota_calibration.py +1 -40
- overcode/quota_engine.py +21 -44
- overcode/quota_model.py +0 -4
- overcode/secrets_store.py +185 -0
- overcode/session_manager.py +219 -9
- overcode/settings.py +9 -3
- overcode/sister_controller.py +8 -0
- overcode/sister_poller.py +5 -0
- overcode/spend_client.py +211 -0
- overcode/status_constants.py +22 -7
- overcode/status_detector_factory.py +16 -0
- overcode/status_history.py +65 -9
- overcode/summarizer_client.py +25 -3
- overcode/summarizer_component.py +177 -39
- overcode/summary_columns.py +5 -3
- overcode/summary_groups.py +3 -3
- overcode/swarm.py +178 -10
- overcode/swarm_files.py +28 -15
- overcode/swarm_publisher.py +5 -1
- overcode/swarm_view.py +13 -5
- overcode/tmux_utils.py +59 -2
- overcode/transcript_archive.py +1605 -0
- overcode/transcript_queue.py +112 -0
- overcode/tui.py +76 -37
- overcode/tui.tcss +8 -0
- overcode/tui_actions/command_bar.py +3 -1
- overcode/tui_actions/daemon.py +41 -2
- overcode/tui_actions/dialogs.py +83 -2
- overcode/tui_actions/input.py +2 -1
- overcode/tui_actions/new_shell.py +64 -0
- overcode/tui_actions/overagent.py +3 -1
- overcode/tui_actions/session.py +148 -33
- overcode/tui_actions/swarm.py +3 -3
- overcode/tui_actions/typing_guard.py +613 -0
- overcode/tui_actions/view.py +5 -5
- overcode/tui_actions/view_control.py +2 -0
- overcode/tui_engine.py +4 -3
- overcode/tui_helpers.py +2 -2
- overcode/tui_logic.py +45 -18
- overcode/tui_tooltip.py +72 -0
- overcode/tui_widgets/agent_visibility_modal.py +2 -2
- overcode/tui_widgets/command_palette.py +96 -10
- overcode/tui_widgets/daemon_status_bar.py +13 -29
- overcode/tui_widgets/session_summary.py +10 -2
- overcode/tui_widgets/summary_config_modal.py +22 -15
- overcode/tui_widgets/swarm_rows.py +11 -10
- overcode/typing_guard.py +192 -0
- overcode/upgrade_consent.py +2 -2
- overcode/usage_monitor.py +11 -13
- overcode/web_api.py +75 -12
- overcode/web_control_api.py +33 -6
- overcode/web_server.py +7 -1
- overcode/weft_claims.py +352 -0
- overcode/worker_guard.py +37 -8
- overcode/workflow_progress.py +564 -0
- overcode/wrapper.py +8 -2
- {overcode-0.6.2.dist-info → overcode-0.6.5.dist-info}/METADATA +1 -1
- overcode-0.6.5.dist-info/RECORD +376 -0
- overcode-0.6.2.dist-info/RECORD +0 -344
- /overcode/docs/{release-notes-0.3.0.md → releases/release-notes-0.3.0.md} +0 -0
- /overcode/docs/{release-notes-0.4.2.md → releases/release-notes-0.4.2.md} +0 -0
- /overcode/docs/{release-notes-0.5.2.md → releases/release-notes-0.5.2.md} +0 -0
- /overcode/docs/{release-notes-0.5.3.md → releases/release-notes-0.5.3.md} +0 -0
- /overcode/docs/{release-notes-0.5.4.md → releases/release-notes-0.5.4.md} +0 -0
- /overcode/docs/{release-notes-0.5.5.md → releases/release-notes-0.5.5.md} +0 -0
- /overcode/docs/{release-notes-0.5.6.md → releases/release-notes-0.5.6.md} +0 -0
- /overcode/docs/{release-notes-0.5.7.md → releases/release-notes-0.5.7.md} +0 -0
- /overcode/docs/{release-notes-0.5.8.md → releases/release-notes-0.5.8.md} +0 -0
- /overcode/docs/{release-notes-0.6.2.md → releases/release-notes-0.6.2.md} +0 -0
- {overcode-0.6.2.dist-info → overcode-0.6.5.dist-info}/WHEEL +0 -0
- {overcode-0.6.2.dist-info → overcode-0.6.5.dist-info}/entry_points.txt +0 -0
- {overcode-0.6.2.dist-info → overcode-0.6.5.dist-info}/licenses/LICENSE +0 -0
- {overcode-0.6.2.dist-info → overcode-0.6.5.dist-info}/top_level.txt +0 -0
overcode/agent_files.py
CHANGED
|
@@ -14,8 +14,9 @@ relaunched.
|
|
|
14
14
|
|
|
15
15
|
import os
|
|
16
16
|
import shutil
|
|
17
|
+
from typing import Optional
|
|
17
18
|
|
|
18
|
-
from .paths import agent_dir, agent_file
|
|
19
|
+
from .paths import agent_dir, agent_file, agent_path
|
|
19
20
|
|
|
20
21
|
# Where a relaunch moves the report the previous run filed, so the new run
|
|
21
22
|
# does not settle from it (kept for whoever wants to read it).
|
|
@@ -41,9 +42,23 @@ def prepare_agent_dir(tmux_session: str, session_id: str, *, reset: bool = False
|
|
|
41
42
|
agent_file(tmux_session, session_id, "hook_state").unlink(missing_ok=True)
|
|
42
43
|
except OSError:
|
|
43
44
|
pass
|
|
44
|
-
|
|
45
|
+
retire_report(tmux_session, session_id)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def retire_report(tmux_session: str, session_id: str, name: Optional[str] = None) -> None:
|
|
49
|
+
"""Move the agent's filed report aside so nothing settles from it again; never raises.
|
|
50
|
+
|
|
51
|
+
A relaunch does this, and so does the daemon when a done child goes
|
|
52
|
+
back to work (#556). The report stays readable as ``PREVIOUS_REPORT``
|
|
53
|
+
(``report_<name>.previous.json`` for an agent with no directory).
|
|
54
|
+
"""
|
|
55
|
+
report = agent_path(tmux_session, session_id, name, "report")
|
|
56
|
+
if report.parent.name == session_id:
|
|
57
|
+
previous = report.parent / PREVIOUS_REPORT
|
|
58
|
+
else:
|
|
59
|
+
previous = report.with_name(report.stem + ".previous.json")
|
|
45
60
|
try:
|
|
46
|
-
os.replace(report,
|
|
61
|
+
os.replace(report, previous)
|
|
47
62
|
except OSError:
|
|
48
63
|
pass # none filed
|
|
49
64
|
|
overcode/agent_identity.py
CHANGED
|
@@ -22,6 +22,22 @@ def env_agent_name(env: Optional[Mapping[str, str]] = None) -> Optional[str]:
|
|
|
22
22
|
return (os.environ if env is None else env).get("OVERCODE_SESSION_NAME") or None
|
|
23
23
|
|
|
24
24
|
|
|
25
|
+
# Set in a job an agent started (``overcode bash``): an agent the job
|
|
26
|
+
# launches is that agent's child. Not OVERCODE_SESSION_ID: the job is not
|
|
27
|
+
# the agent (its reports, hooks and state access are its own).
|
|
28
|
+
JOB_OWNER_VAR = "OVERCODE_JOB_OWNER_ID"
|
|
29
|
+
|
|
30
|
+
# The agent spend recorded from this process bills to (experiment billing,
|
|
31
|
+
# ``external_spend``): set by an agent's ``overcode bash`` job, or by hand.
|
|
32
|
+
# Cleared from launch lines: an agent bills its own evals.
|
|
33
|
+
BILL_TO_VAR = "OVERCODE_BILL_TO"
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def env_job_owner_id(env: Optional[Mapping[str, str]] = None) -> Optional[str]:
|
|
37
|
+
"""The id of the agent whose job this process runs in, or None."""
|
|
38
|
+
return (os.environ if env is None else env).get(JOB_OWNER_VAR) or None
|
|
39
|
+
|
|
40
|
+
|
|
25
41
|
def in_agent(env: Optional[Mapping[str, str]] = None) -> bool:
|
|
26
42
|
"""True inside an agent overcode launched (either variable set)."""
|
|
27
43
|
return bool(env_agent_id(env) or env_agent_name(env))
|
overcode/agent_io.py
CHANGED
|
@@ -11,6 +11,7 @@ import subprocess
|
|
|
11
11
|
import time
|
|
12
12
|
from typing import Optional
|
|
13
13
|
|
|
14
|
+
from . import budget_gate
|
|
14
15
|
from .backends import AgentBackend, get_backend
|
|
15
16
|
from .session_manager import Session
|
|
16
17
|
from .tmux_utils import (
|
|
@@ -238,13 +239,20 @@ class AgentIOMixin:
|
|
|
238
239
|
# Fallback: prompt not detected, use original delay
|
|
239
240
|
return send(startup_delay)
|
|
240
241
|
|
|
241
|
-
|
|
242
|
+
# Why the last send was refused (budget_gate), else None
|
|
243
|
+
send_refusal: Optional[str] = None
|
|
244
|
+
|
|
245
|
+
def send_to_session(self, name: str, text: str, enter: bool = True,
|
|
246
|
+
over_budget: bool = False) -> bool:
|
|
242
247
|
"""Send text/keys to a session by name.
|
|
243
248
|
|
|
244
249
|
Args:
|
|
245
250
|
name: Name of the session
|
|
246
251
|
text: Text to send (or special key like "Enter", "Escape")
|
|
247
252
|
enter: Whether to press Enter after the text (default: True)
|
|
253
|
+
over_budget: Send a prompt to an agent over its cost budget
|
|
254
|
+
anyway (budget_gate); without it the send is refused and
|
|
255
|
+
``send_refusal`` says why
|
|
248
256
|
|
|
249
257
|
Returns:
|
|
250
258
|
True if successful, False otherwise
|
|
@@ -254,9 +262,10 @@ class AgentIOMixin:
|
|
|
254
262
|
print(f"Session '{name}' not found")
|
|
255
263
|
return False
|
|
256
264
|
|
|
257
|
-
return self._send_to_resolved_session(session, text, enter)
|
|
265
|
+
return self._send_to_resolved_session(session, text, enter, over_budget=over_budget)
|
|
258
266
|
|
|
259
|
-
def send_to_session_by_id(self, session_id: str, text: str, enter: bool = True
|
|
267
|
+
def send_to_session_by_id(self, session_id: str, text: str, enter: bool = True,
|
|
268
|
+
over_budget: bool = False, keypress: bool = False) -> bool:
|
|
260
269
|
"""Send text/keys to a session by ID.
|
|
261
270
|
|
|
262
271
|
Preferred over send_to_session() when the session ID is known,
|
|
@@ -266,6 +275,9 @@ class AgentIOMixin:
|
|
|
266
275
|
session_id: Unique session ID
|
|
267
276
|
text: Text to send (or special key like "Enter", "Escape")
|
|
268
277
|
enter: Whether to press Enter after the text (default: True)
|
|
278
|
+
over_budget: As for send_to_session
|
|
279
|
+
keypress: ``text`` is a key the person pressed (a menu number),
|
|
280
|
+
not a prompt: never refused for the budget
|
|
269
281
|
|
|
270
282
|
Returns:
|
|
271
283
|
True if successful, False otherwise
|
|
@@ -274,18 +286,60 @@ class AgentIOMixin:
|
|
|
274
286
|
if session is None:
|
|
275
287
|
return False
|
|
276
288
|
|
|
277
|
-
return self._send_to_resolved_session(session, text, enter
|
|
289
|
+
return self._send_to_resolved_session(session, text, enter,
|
|
290
|
+
over_budget=over_budget, keypress=keypress)
|
|
291
|
+
|
|
292
|
+
# Named keys and gestures: never refused (budget_gate)
|
|
293
|
+
SEND_KEYS = ("enter", "escape", "esc", "tab", "up", "down", "left", "right",
|
|
294
|
+
"approve", "reject")
|
|
278
295
|
|
|
279
|
-
def
|
|
296
|
+
def _budget_gate(self, session: Session, text: str, enter: bool,
|
|
297
|
+
over_budget: bool, keypress: bool) -> bool:
|
|
298
|
+
"""Refuse a prompt to an agent over its cost budget (#530, budget_gate).
|
|
299
|
+
|
|
300
|
+
True to send. A refusal is kept in ``send_refusal`` and stamped on
|
|
301
|
+
the agent (the daemon shows it "rejected"). With ``over_budget`` it
|
|
302
|
+
is sent, and the agent's own budget check (Claude's hook) is given
|
|
303
|
+
a permit for it.
|
|
304
|
+
"""
|
|
305
|
+
self.send_refusal = None
|
|
306
|
+
if keypress or not budget_gate.is_prompt(text, enter, self.SEND_KEYS):
|
|
307
|
+
return True
|
|
308
|
+
reason = budget_gate.refusal(session, self.sessions)
|
|
309
|
+
if reason is None:
|
|
310
|
+
return True
|
|
311
|
+
if over_budget:
|
|
312
|
+
try:
|
|
313
|
+
budget_gate.write_permit(self.tmux.session_name, session.id)
|
|
314
|
+
except OSError:
|
|
315
|
+
pass # the overcode side is open; the hook may still refuse
|
|
316
|
+
return True
|
|
317
|
+
self.send_refusal = reason
|
|
318
|
+
try:
|
|
319
|
+
self.sessions.update_session(session.id, budget_rejected_at=budget_gate.now_iso())
|
|
320
|
+
except Exception:
|
|
321
|
+
pass # the refusal stands without its badge
|
|
322
|
+
return False
|
|
323
|
+
|
|
324
|
+
def _send_to_resolved_session(self, session: Session, text: str, enter: bool = True,
|
|
325
|
+
over_budget: bool = False, keypress: bool = False) -> bool:
|
|
280
326
|
"""Send text/keys to an already-resolved session.
|
|
281
327
|
|
|
282
328
|
Internal helper shared by send_to_session() and send_to_session_by_id().
|
|
283
329
|
Sent in the agent's own tmux session: agents are found fleet-wide,
|
|
284
330
|
and this launcher's may not be theirs (the CLI's --session default).
|
|
331
|
+
A prompt to an agent over its cost budget is refused unless
|
|
332
|
+
``over_budget`` (``_budget_gate``); keys and gestures always go.
|
|
285
333
|
"""
|
|
286
334
|
owner = self.for_agent(session)
|
|
287
335
|
if owner is not self:
|
|
288
|
-
|
|
336
|
+
sent = owner._send_to_resolved_session(session, text, enter,
|
|
337
|
+
over_budget=over_budget, keypress=keypress)
|
|
338
|
+
self.send_refusal = owner.send_refusal
|
|
339
|
+
return sent
|
|
340
|
+
|
|
341
|
+
if not self._budget_gate(session, text, enter, over_budget, keypress):
|
|
342
|
+
return False
|
|
289
343
|
|
|
290
344
|
# Handle special keys
|
|
291
345
|
special_keys = {
|
|
@@ -359,6 +413,9 @@ class AgentIOMixin:
|
|
|
359
413
|
session.id,
|
|
360
414
|
last_activity=time.strftime("%Y-%m-%dT%H:%M:%S")
|
|
361
415
|
)
|
|
416
|
+
if over_budget and budget_gate.refused_at(session):
|
|
417
|
+
# Sent on purpose: the agent is no longer refused
|
|
418
|
+
self.sessions.update_session(session.id, budget_rejected_at=None)
|
|
362
419
|
|
|
363
420
|
return success
|
|
364
421
|
|
overcode/backends/__init__.py
CHANGED
|
@@ -13,6 +13,8 @@ from .base import (
|
|
|
13
13
|
DialogRule,
|
|
14
14
|
KeyPress,
|
|
15
15
|
LaunchSpec,
|
|
16
|
+
check_effort,
|
|
17
|
+
effort_applies,
|
|
16
18
|
supports,
|
|
17
19
|
)
|
|
18
20
|
from .claude_code import ClaudeCodeBackend
|
|
@@ -170,6 +172,8 @@ __all__ = [
|
|
|
170
172
|
"KeyPress",
|
|
171
173
|
"LaunchSpec",
|
|
172
174
|
"UnknownBackendError",
|
|
175
|
+
"check_effort",
|
|
176
|
+
"effort_applies",
|
|
173
177
|
"capabilities_from_names",
|
|
174
178
|
"capability_names",
|
|
175
179
|
"get_backend",
|
overcode/backends/base.py
CHANGED
|
@@ -103,6 +103,10 @@ class LaunchSpec:
|
|
|
103
103
|
|
|
104
104
|
# Agent configuration
|
|
105
105
|
model: Optional[str] = None
|
|
106
|
+
# Reasoning effort (#537), in the backend's own vocabulary ("high",
|
|
107
|
+
# "xhigh", an opencode variant, ...). Each backend maps it onto its own
|
|
108
|
+
# flag; see ``AgentBackendBase.effort_levels``.
|
|
109
|
+
effort: Optional[str] = None
|
|
106
110
|
agent: Optional[str] = None
|
|
107
111
|
allowed_tools: Optional[str] = None
|
|
108
112
|
extra_args: List[str] = field(default_factory=list)
|
|
@@ -191,6 +195,13 @@ class AgentBackend(Protocol):
|
|
|
191
195
|
|
|
192
196
|
def make_polling_detector(self, tmux_session: str, tmux=None, patterns=None): ...
|
|
193
197
|
|
|
198
|
+
model_applies_on_resume: bool
|
|
199
|
+
|
|
200
|
+
def applies_launch_agent(self) -> bool: ...
|
|
201
|
+
|
|
202
|
+
def launch_warnings(self, *, model: Optional[str] = None, agent: Optional[str] = None,
|
|
203
|
+
effort: Optional[str] = None, resuming: bool = False) -> List[str]: ...
|
|
204
|
+
|
|
194
205
|
def normalize_hook_payload(self, data: dict) -> Optional[dict]: ...
|
|
195
206
|
|
|
196
207
|
def display_name_args(self, name: str) -> List[str]: ...
|
|
@@ -250,6 +261,52 @@ class AgentBackendBase:
|
|
|
250
261
|
# import cost); hook_dialects.for_backend must agree with it.
|
|
251
262
|
hook_dialect: hook_dialects.HookDialect = hook_dialects.CLAUDE
|
|
252
263
|
|
|
264
|
+
# Reasoning effort at launch (#537). The levels the CLI takes at launch;
|
|
265
|
+
# empty when it has no way to set effort per launch (a warning says so,
|
|
266
|
+
# see ``check_effort``). ``effort_levels_exhaustive`` False means the CLI
|
|
267
|
+
# also takes other values (opencode variants are per model, grok takes
|
|
268
|
+
# per-model menu ids): an unlisted value is passed with a warning rather
|
|
269
|
+
# than refused.
|
|
270
|
+
effort_levels: Tuple[str, ...] = ()
|
|
271
|
+
effort_levels_exhaustive: bool = True
|
|
272
|
+
# Why a backend with no ``effort_levels`` cannot set it, for the warning
|
|
273
|
+
effort_unsupported_reason: str = ""
|
|
274
|
+
|
|
275
|
+
def effort_warnings(self, effort: str, model: Optional[str]) -> List[str]:
|
|
276
|
+
"""Backend-specific reasons a valid ``effort`` may still not apply."""
|
|
277
|
+
return []
|
|
278
|
+
|
|
279
|
+
# Does a model (and effort) chosen at launch apply when the CLI resumes
|
|
280
|
+
# a conversation? False where the resumed conversation keeps its own
|
|
281
|
+
# (opencode2, #529): ``launch_warnings`` says so, and ``restart`` does
|
|
282
|
+
# not record a choice that will not be in force.
|
|
283
|
+
model_applies_on_resume: bool = True
|
|
284
|
+
|
|
285
|
+
def applies_launch_agent(self) -> bool:
|
|
286
|
+
"""Is a launch-time agent persona (``--agent``) put into effect?"""
|
|
287
|
+
return bool(self.capabilities & BackendCapability.AGENT_INJECTION)
|
|
288
|
+
|
|
289
|
+
def launch_warnings(self, *, model: Optional[str] = None, agent: Optional[str] = None,
|
|
290
|
+
effort: Optional[str] = None, resuming: bool = False) -> List[str]:
|
|
291
|
+
"""What a launch or restart with these choices will not apply (#529).
|
|
292
|
+
|
|
293
|
+
Printed as warnings, the way ``check_effort``'s are; effort itself
|
|
294
|
+
is ``check_effort``'s business, except on a resume the model
|
|
295
|
+
choice does not reach.
|
|
296
|
+
"""
|
|
297
|
+
warnings = []
|
|
298
|
+
if agent and not self.applies_launch_agent():
|
|
299
|
+
warnings.append(f"--agent {agent} is ignored on backend '{self.name}': "
|
|
300
|
+
f"it has no way to pick an agent persona at launch")
|
|
301
|
+
if resuming and not self.model_applies_on_resume:
|
|
302
|
+
for flag, value in (("--model", model), ("--effort", effort)):
|
|
303
|
+
if value:
|
|
304
|
+
warnings.append(
|
|
305
|
+
f"{flag} {value} is not applied: a resumed {self.name} session keeps "
|
|
306
|
+
f"the model and effort it started on (restart --fresh for a new "
|
|
307
|
+
f"session, or switch with /model in the agent's TUI)")
|
|
308
|
+
return warnings
|
|
309
|
+
|
|
253
310
|
def normalize_hook_payload(self, data: dict) -> Optional[dict]:
|
|
254
311
|
"""A hook payload in Claude Code's vocabulary, or None to drop it."""
|
|
255
312
|
return self.hook_dialect.normalize(data)
|
|
@@ -314,6 +371,51 @@ class AgentBackendBase:
|
|
|
314
371
|
return []
|
|
315
372
|
|
|
316
373
|
|
|
374
|
+
def effort_applies(backend, effort: Optional[str]) -> bool:
|
|
375
|
+
"""Should ``build_command`` pass ``effort`` to the CLI?
|
|
376
|
+
|
|
377
|
+
A value the backend lists, or any value for a backend whose list is not
|
|
378
|
+
exhaustive. Anything else (an effort read back from a transcript that
|
|
379
|
+
the launch flag does not take) is left out, so a restart never fails on it.
|
|
380
|
+
"""
|
|
381
|
+
levels = getattr(backend, "effort_levels", ())
|
|
382
|
+
if not effort or not levels:
|
|
383
|
+
return False
|
|
384
|
+
return effort in levels or not getattr(backend, "effort_levels_exhaustive", True)
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
def check_effort(backend, effort: Optional[str],
|
|
388
|
+
model: Optional[str] = None) -> Tuple[Optional[str], List[str]]:
|
|
389
|
+
"""Validate a launch-time ``effort`` for ``backend`` (#537).
|
|
390
|
+
|
|
391
|
+
Returns ``(effort, warnings)``: the value normalized (trimmed, lower
|
|
392
|
+
case), and what to tell the person (the backend cannot set effort, the
|
|
393
|
+
value is not one it is known to take, it needs a model). Raises
|
|
394
|
+
``ValueError`` with the accepted levels for a value the backend is known
|
|
395
|
+
to refuse.
|
|
396
|
+
"""
|
|
397
|
+
if effort is None:
|
|
398
|
+
return None, []
|
|
399
|
+
value = effort.strip().lower()
|
|
400
|
+
if not value:
|
|
401
|
+
return None, []
|
|
402
|
+
name = getattr(backend, "name", "?")
|
|
403
|
+
levels = getattr(backend, "effort_levels", ())
|
|
404
|
+
if not levels:
|
|
405
|
+
reason = getattr(backend, "effort_unsupported_reason", "") or \
|
|
406
|
+
"it has no way to set reasoning effort at launch"
|
|
407
|
+
return value, [f"--effort {value} is ignored on backend '{name}': {reason}"]
|
|
408
|
+
if value not in levels:
|
|
409
|
+
if getattr(backend, "effort_levels_exhaustive", True):
|
|
410
|
+
raise ValueError(f"unknown effort '{value}' for backend '{name}'. "
|
|
411
|
+
f"Use one of: {', '.join(levels)}")
|
|
412
|
+
warnings = [f"effort '{value}' is not one of the levels known for backend "
|
|
413
|
+
f"'{name}' ({', '.join(levels)}); passing it as given"]
|
|
414
|
+
else:
|
|
415
|
+
warnings = []
|
|
416
|
+
return value, warnings + list(backend.effort_warnings(value, model))
|
|
417
|
+
|
|
418
|
+
|
|
317
419
|
def supports(backend: AgentBackend, capability: BackendCapability) -> bool:
|
|
318
420
|
"""True when ``backend`` declares ``capability``."""
|
|
319
421
|
return bool(backend.capabilities & capability)
|
overcode/backends/claude_code.py
CHANGED
|
@@ -10,6 +10,7 @@ from typing import TYPE_CHECKING, Dict, List, Set, Tuple
|
|
|
10
10
|
from ..exceptions import AgentCliNotFoundError
|
|
11
11
|
from .base import (
|
|
12
12
|
AgentBackendBase,
|
|
13
|
+
effort_applies,
|
|
13
14
|
BackendCapability,
|
|
14
15
|
DialogRule,
|
|
15
16
|
KeyPress,
|
|
@@ -141,6 +142,10 @@ class ClaudeCodeBackend(AgentBackendBase):
|
|
|
141
142
|
# ...and a multi-line `overcode send` is typed, a backslash-Enter per line break
|
|
142
143
|
type_multiline_text = True
|
|
143
144
|
|
|
145
|
+
# `claude --effort <level>` (verified on 2.1.310, `claude --help`):
|
|
146
|
+
# "Effort level for the current session (low, medium, high, xhigh, max)"
|
|
147
|
+
effort_levels = ("low", "medium", "high", "xhigh", "max")
|
|
148
|
+
|
|
144
149
|
def build_command(self, spec: LaunchSpec) -> List[str]:
|
|
145
150
|
"""Construct the claude CLI argument list.
|
|
146
151
|
|
|
@@ -203,6 +208,8 @@ class ClaudeCodeBackend(AgentBackendBase):
|
|
|
203
208
|
cmd.extend(self.display_name_args(spec.name))
|
|
204
209
|
if spec.model:
|
|
205
210
|
cmd.extend(["--model", spec.model])
|
|
211
|
+
if effort_applies(self, spec.effort):
|
|
212
|
+
cmd.extend(["--effort", spec.effort])
|
|
206
213
|
if spec.agent:
|
|
207
214
|
cmd.extend(["--agent", spec.agent])
|
|
208
215
|
if spec.allowed_tools:
|
overcode/backends/codex.py
CHANGED
|
@@ -30,6 +30,7 @@ from ..exceptions import AgentCliNotFoundError
|
|
|
30
30
|
from ..status_patterns import NEVER, NEVER_SUBSTRING, StatusPatterns
|
|
31
31
|
from .base import (
|
|
32
32
|
AgentBackendBase,
|
|
33
|
+
effort_applies,
|
|
33
34
|
BackendCapability,
|
|
34
35
|
DialogRule,
|
|
35
36
|
KeyPress,
|
|
@@ -321,6 +322,11 @@ class CodexBackend(AgentBackendBase):
|
|
|
321
322
|
# options rather than appending it.
|
|
322
323
|
return [("fork" if fork else "resume"), session_id]
|
|
323
324
|
|
|
325
|
+
# `-c model_reasoning_effort=<level>` (#537). The levels are the ones the
|
|
326
|
+
# API names when it refuses another (codex-cli 0.164.0, `codex exec -c
|
|
327
|
+
# model_reasoning_effort=bogus`): a model takes a subset of them.
|
|
328
|
+
effort_levels = ("none", "minimal", "low", "medium", "high", "xhigh", "max")
|
|
329
|
+
|
|
324
330
|
def build_command(self, spec: LaunchSpec) -> List[str]:
|
|
325
331
|
"""Construct the codex CLI argument list.
|
|
326
332
|
|
|
@@ -329,6 +335,7 @@ class CodexBackend(AgentBackendBase):
|
|
|
329
335
|
resume -> ``codex resume <id> [opts]`` (subcommand first)
|
|
330
336
|
fork -> ``codex fork <id> [opts]`` (subcommand first)
|
|
331
337
|
model -> ``-m <model>`` (bare id, e.g. ``gpt-5.6-sol``)
|
|
338
|
+
effort -> ``-c model_reasoning_effort="<level>"``
|
|
332
339
|
bypass -> ``--dangerously-bypass-approvals-and-sandbox``
|
|
333
340
|
permissive -> ``-a never --sandbox workspace-write``
|
|
334
341
|
normal -> no flags (default: on-request approval)
|
|
@@ -360,6 +367,9 @@ class CodexBackend(AgentBackendBase):
|
|
|
360
367
|
if spec.model:
|
|
361
368
|
cmd.extend(["-m", spec.model])
|
|
362
369
|
|
|
370
|
+
if effort_applies(self, spec.effort):
|
|
371
|
+
cmd.extend(["-c", f'model_reasoning_effort="{spec.effort}"'])
|
|
372
|
+
|
|
363
373
|
if spec.dangerously_skip_permissions or spec.permissiveness_mode == "bypass":
|
|
364
374
|
cmd.append("--dangerously-bypass-approvals-and-sandbox")
|
|
365
375
|
elif spec.skip_permissions or spec.permissiveness_mode == "permissive":
|
|
@@ -452,9 +462,21 @@ class CodexBackend(AgentBackendBase):
|
|
|
452
462
|
),
|
|
453
463
|
# codex 0.156.1 (seen live Oct 12 2026): "Trust this folder? ...
|
|
454
464
|
# › 1. Trust and continue / 2. Quit / enter continue · esc quit"
|
|
465
|
+
# There "1" confirmed at once; on 0.164 (seen live Nov 25 2026,
|
|
466
|
+
# "2. Back to Agent Command Center" / "enter continue · esc
|
|
467
|
+
# back") a digit only moves the highlight and Enter confirms, so
|
|
468
|
+
# a bare "1" left the dialog up until the launcher gave up and
|
|
469
|
+
# pasted the initial prompt into it. "1" puts the highlight on
|
|
470
|
+
# "Trust and continue" whatever the version, then Enter confirms
|
|
471
|
+
# it — sent only while the dialog still shows that option
|
|
472
|
+
# highlighted (where "1" already confirmed, it is gone and
|
|
473
|
+
# nothing more is sent).
|
|
455
474
|
DialogRule(
|
|
456
475
|
marker="Trust this folder?",
|
|
457
|
-
presses=[
|
|
476
|
+
presses=[
|
|
477
|
+
KeyPress("1", enter=False, delay_after=0.5),
|
|
478
|
+
KeyPress("", enter=True, wait_for="› 1. Trust and continue"),
|
|
479
|
+
],
|
|
458
480
|
settle_seconds=1.5,
|
|
459
481
|
),
|
|
460
482
|
]
|
overcode/backends/grok.py
CHANGED
|
@@ -33,6 +33,7 @@ from .. import hook_dialects
|
|
|
33
33
|
from ..status_patterns import NEVER, NEVER_SUBSTRING, StatusPatterns
|
|
34
34
|
from .base import (
|
|
35
35
|
AgentBackendBase,
|
|
36
|
+
effort_applies,
|
|
36
37
|
BackendCapability,
|
|
37
38
|
DialogRule,
|
|
38
39
|
KeyPress,
|
|
@@ -511,6 +512,12 @@ class GrokBackend(AgentBackendBase):
|
|
|
511
512
|
args.append("--fork-session")
|
|
512
513
|
return args
|
|
513
514
|
|
|
515
|
+
# `--reasoning-effort <level>` (alias --effort; grok 1.0.34 `grok --help`).
|
|
516
|
+
# Its docs name these canonical levels and say a model also takes its
|
|
517
|
+
# own menu ids (e.g. "deep"), so the list is not exhaustive.
|
|
518
|
+
effort_levels = ("none", "minimal", "low", "medium", "high", "xhigh", "max")
|
|
519
|
+
effort_levels_exhaustive = False
|
|
520
|
+
|
|
514
521
|
def build_command(self, spec: LaunchSpec) -> List[str]:
|
|
515
522
|
"""Construct the grok CLI argument list.
|
|
516
523
|
|
|
@@ -523,6 +530,7 @@ class GrokBackend(AgentBackendBase):
|
|
|
523
530
|
id is prescribed too (launcher.py mints one
|
|
524
531
|
for any SESSION_ID_PRESCRIPTION backend)
|
|
525
532
|
model -> ``-m <id>`` (bare id, e.g. ``grok-4.6``)
|
|
533
|
+
effort -> ``--reasoning-effort <level>``
|
|
526
534
|
persona -> ``--agent <name>``
|
|
527
535
|
bypass -> ``--permission-mode bypassPermissions``
|
|
528
536
|
permissive -> ``--permission-mode auto`` (Phase 0 correction
|
|
@@ -568,6 +576,9 @@ class GrokBackend(AgentBackendBase):
|
|
|
568
576
|
if spec.model:
|
|
569
577
|
cmd.extend(["-m", spec.model])
|
|
570
578
|
|
|
579
|
+
if effort_applies(self, spec.effort):
|
|
580
|
+
cmd.extend(["--reasoning-effort", spec.effort])
|
|
581
|
+
|
|
571
582
|
if spec.agent:
|
|
572
583
|
cmd.extend(["--agent", spec.agent])
|
|
573
584
|
|
overcode/backends/grok_stats.py
CHANGED
|
@@ -13,7 +13,7 @@ needs across a few files inside one per-session directory:
|
|
|
13
13
|
tagged with the owning session id
|
|
14
14
|
|
|
15
15
|
Two things §3.4 flagged as unconfirmed were determined empirically against a
|
|
16
|
-
real 413-message session (``01a015cb-...`` under
|
|
16
|
+
real 413-message session (``01a015cb-...`` under a real project dir) before
|
|
17
17
|
this reader was written, and are recorded here rather than left as a Phase 4
|
|
18
18
|
guess:
|
|
19
19
|
|
|
@@ -167,7 +167,7 @@ class _UpdatesFold:
|
|
|
167
167
|
return
|
|
168
168
|
|
|
169
169
|
# `_meta` sits inside `params`, not at the envelope's top level —
|
|
170
|
-
# confirmed against the real
|
|
170
|
+
# confirmed against the real session file (413-message,
|
|
171
171
|
# module docstring), which has zero top-level `_meta` keys.
|
|
172
172
|
params = entry.get("params")
|
|
173
173
|
meta = params.get("_meta") if isinstance(params, dict) else None
|
overcode/backends/hermes.py
CHANGED
|
@@ -31,6 +31,7 @@ from ..exceptions import AgentCliNotFoundError
|
|
|
31
31
|
from ..status_patterns import NEVER, NEVER_SUBSTRING, StatusPatterns
|
|
32
32
|
from .base import (
|
|
33
33
|
AgentBackendBase,
|
|
34
|
+
effort_applies,
|
|
34
35
|
BackendCapability,
|
|
35
36
|
DialogRule,
|
|
36
37
|
KeyPress,
|
|
@@ -540,6 +541,11 @@ class HermesBackend(AgentBackendBase):
|
|
|
540
541
|
# and a resume is the closest thing if it ever does.
|
|
541
542
|
return ["--resume", session_id]
|
|
542
543
|
|
|
544
|
+
# `--reasoning <level>` (Hermes v0.21.3 `hermes --help`: "none, minimal,
|
|
545
|
+
# low, medium, high, xhigh, max, or ultra"; overrides
|
|
546
|
+
# agent.reasoning_effort for this run, and reaches the --cli chat).
|
|
547
|
+
effort_levels = ("none", "minimal", "low", "medium", "high", "xhigh", "max", "ultra")
|
|
548
|
+
|
|
543
549
|
def build_command(self, spec: LaunchSpec) -> List[str]:
|
|
544
550
|
"""Construct the hermes CLI argument list.
|
|
545
551
|
|
|
@@ -549,6 +555,7 @@ class HermesBackend(AgentBackendBase):
|
|
|
549
555
|
model -> ``-m <model>`` (Hermes's own id form: a bare
|
|
550
556
|
``gpt-5-mini`` for openai-api, or
|
|
551
557
|
``provider/model`` for routed providers)
|
|
558
|
+
effort -> ``--reasoning <level>``
|
|
552
559
|
bypass -> ``--yolo`` (skips every dangerous-command
|
|
553
560
|
approval prompt)
|
|
554
561
|
permissive, normal -> no flag: Hermes has no per-launch approval
|
|
@@ -579,6 +586,9 @@ class HermesBackend(AgentBackendBase):
|
|
|
579
586
|
if spec.model:
|
|
580
587
|
cmd.extend(["-m", spec.model])
|
|
581
588
|
|
|
589
|
+
if effort_applies(self, spec.effort):
|
|
590
|
+
cmd.extend(["--reasoning", spec.effort])
|
|
591
|
+
|
|
582
592
|
if spec.dangerously_skip_permissions or spec.permissiveness_mode == "bypass":
|
|
583
593
|
cmd.append("--yolo")
|
|
584
594
|
|
overcode/backends/opencode.py
CHANGED
|
@@ -33,6 +33,7 @@ from ..exceptions import AgentCliNotFoundError
|
|
|
33
33
|
from ..status_patterns import NEVER, NEVER_SUBSTRING, StatusPatterns
|
|
34
34
|
from .base import (
|
|
35
35
|
AgentBackendBase,
|
|
36
|
+
effort_applies,
|
|
36
37
|
BackendCapability,
|
|
37
38
|
DialogRule,
|
|
38
39
|
KeyPress,
|
|
@@ -110,6 +111,34 @@ OPENCODE_ALLOW_EVERYTHING_PERMISSION: Dict[str, str] = {
|
|
|
110
111
|
}
|
|
111
112
|
|
|
112
113
|
|
|
114
|
+
# #531: overcode's own commands (`overcode report *`, `overcode show *`, ...:
|
|
115
|
+
# the list Claude agents get as `Bash(...)` allow rules, `cli/perms.py`) are
|
|
116
|
+
# allowed under this permission key, not under "bash". opencode merges
|
|
117
|
+
# OPENCODE_PERMISSION into the resolved config with a deep merge, so an
|
|
118
|
+
# object under "bash" *replaces* a project's string `"bash": "ask"` or
|
|
119
|
+
# `"bash": "deny"`, and every other command then falls through to opencode's
|
|
120
|
+
# built-in `"*": "allow"`. A key of its own merges alongside the project's
|
|
121
|
+
# rules instead: each key becomes rules in order, the last matching rule wins
|
|
122
|
+
# (`findLast`), and permission names are matched as wildcards, so "bash*"
|
|
123
|
+
# applies to the bash tool. Verified on 1.18.29 with `opencode debug config`
|
|
124
|
+
# and `opencode debug agent build`: project `"bash": "ask"` stays as
|
|
125
|
+
# `bash * ask`, followed by `bash* overcode report * allow`. Side effect: in
|
|
126
|
+
# a project that denies bash outright, the bash tool stays in the model's
|
|
127
|
+
# catalog (its last rule is no longer a `*` deny) and only overcode's
|
|
128
|
+
# commands run; everything else is still denied.
|
|
129
|
+
OPENCODE_OVERCODE_BASH_KEY = "bash*"
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
def overcode_bash_permission(include_punchy: bool = False) -> Dict[str, str]:
|
|
133
|
+
"""The ``OPENCODE_PERMISSION`` rules that pre-allow overcode's commands."""
|
|
134
|
+
from ..cli.perms import overcode_bash_patterns
|
|
135
|
+
|
|
136
|
+
return {
|
|
137
|
+
pattern: "allow"
|
|
138
|
+
for pattern in overcode_bash_patterns(include_punchy=include_punchy)
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
|
|
113
142
|
def parse_version(text: str) -> Optional[Tuple[int, int, int]]:
|
|
114
143
|
"""Extract a (major, minor, patch) tuple from `opencode --version` output.
|
|
115
144
|
|
|
@@ -431,6 +460,24 @@ class OpencodeBackend(AgentBackendBase):
|
|
|
431
460
|
| BackendCapability.SKILL_PROFILES
|
|
432
461
|
)
|
|
433
462
|
|
|
463
|
+
# Reasoning effort is a model variant (#497, #537). The TUI has no
|
|
464
|
+
# --variant flag (only `opencode run` does, 1.18.29), so the variant goes
|
|
465
|
+
# in as agent config: OPENCODE_CONFIG_CONTENT sets
|
|
466
|
+
# agent.<agent>.{model, variant}. opencode applies an agent's variant
|
|
467
|
+
# only while the agent's model is the one in use (read from the 1.18.29
|
|
468
|
+
# binary), hence the model alongside it, and no effort without --model.
|
|
469
|
+
# Variants are per model; these are the common ones, not a closed list.
|
|
470
|
+
effort_levels = ("none", "minimal", "low", "medium", "high", "xhigh", "max")
|
|
471
|
+
effort_levels_exhaustive = False
|
|
472
|
+
# The agent opencode starts on when none is named
|
|
473
|
+
default_agent = "build"
|
|
474
|
+
|
|
475
|
+
def effort_warnings(self, effort: str, model: Optional[str]) -> List[str]:
|
|
476
|
+
if not model:
|
|
477
|
+
return [f"opencode sets effort as a variant of a given model: --effort {effort} "
|
|
478
|
+
f"is ignored without --model provider/model"]
|
|
479
|
+
return []
|
|
480
|
+
|
|
434
481
|
def executable(self) -> str:
|
|
435
482
|
"""The binary to invoke, honouring the OPENCODE_COMMAND override.
|
|
436
483
|
|
|
@@ -450,6 +497,8 @@ class OpencodeBackend(AgentBackendBase):
|
|
|
450
497
|
|
|
451
498
|
Flag mapping (Appendix A of the design doc, re-verified at v1.18.19):
|
|
452
499
|
model -> ``--model <provider/model>``
|
|
500
|
+
effort -> the agent's model variant, in
|
|
501
|
+
``OPENCODE_CONFIG_CONTENT`` (``env_prefix``)
|
|
453
502
|
bypass/permissive -> ``--auto`` (deny rules still win; opencode
|
|
454
503
|
has no separate "ask nothing but obey deny"
|
|
455
504
|
mode, so both overcode modes collapse onto it)
|
|
@@ -517,6 +566,9 @@ class OpencodeBackend(AgentBackendBase):
|
|
|
517
566
|
``OVERCODE_SESSION_NAME`` and ``OVERCODE_TMUX_SESSION`` are already in
|
|
518
567
|
the launcher's shared prefix.
|
|
519
568
|
|
|
569
|
+
Every launch sets ``OPENCODE_PERMISSION`` with allow rules for
|
|
570
|
+
overcode's own commands (``OPENCODE_OVERCODE_BASH_KEY``, #531).
|
|
571
|
+
|
|
520
572
|
In **bypass** mode only (never permissive — see
|
|
521
573
|
``docs/backends.md``'s "Permission modes" section), also sets
|
|
522
574
|
``OPENCODE_PERMISSION`` to an allow-everything JSON blob. Both
|
|
@@ -547,6 +599,12 @@ class OpencodeBackend(AgentBackendBase):
|
|
|
547
599
|
permission: Dict[str, Any] = {}
|
|
548
600
|
if spec.dangerously_skip_permissions or spec.permissiveness_mode == "bypass":
|
|
549
601
|
permission = dict(OPENCODE_ALLOW_EVERYTHING_PERMISSION)
|
|
602
|
+
# Every launch, like Claude's `Bash(overcode report *)` rules, so a
|
|
603
|
+
# child never asks before it reports back (#531). A key of its own,
|
|
604
|
+
# so the bypass blob's "bash": "allow" is untouched.
|
|
605
|
+
permission[OPENCODE_OVERCODE_BASH_KEY] = overcode_bash_permission(
|
|
606
|
+
include_punchy=spec.include_punchy_perms,
|
|
607
|
+
)
|
|
550
608
|
|
|
551
609
|
# Skill profile (#499). OPENCODE_CONFIG_DIR adds the profile's skills
|
|
552
610
|
# on top of ~/.config/opencode (it is an extra config dir, not a
|
|
@@ -562,8 +620,13 @@ class OpencodeBackend(AgentBackendBase):
|
|
|
562
620
|
rules.update({name: "deny" for name in spec.hidden_skills})
|
|
563
621
|
permission["skill"] = rules
|
|
564
622
|
|
|
565
|
-
|
|
566
|
-
|
|
623
|
+
env["OPENCODE_PERMISSION"] = shlex.quote(json.dumps(permission))
|
|
624
|
+
|
|
625
|
+
# Reasoning effort as the agent's model variant (see effort_levels)
|
|
626
|
+
if spec.model and effort_applies(self, spec.effort):
|
|
627
|
+
agent = spec.agent or self.default_agent
|
|
628
|
+
content = {"agent": {agent: {"model": spec.model, "variant": spec.effort}}}
|
|
629
|
+
env["OPENCODE_CONFIG_CONTENT"] = shlex.quote(json.dumps(content))
|
|
567
630
|
|
|
568
631
|
return env
|
|
569
632
|
|