forgexa-cli 1.102.0__tar.gz → 1.103.0__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 (40) hide show
  1. {forgexa_cli-1.102.0 → forgexa_cli-1.103.0}/PKG-INFO +1 -1
  2. {forgexa_cli-1.102.0 → forgexa_cli-1.103.0}/forgexa_cli/__init__.py +1 -1
  3. {forgexa_cli-1.102.0 → forgexa_cli-1.103.0}/forgexa_cli/agent_core.py +213 -50
  4. {forgexa_cli-1.102.0 → forgexa_cli-1.103.0}/forgexa_cli/daemon.py +507 -112
  5. {forgexa_cli-1.102.0 → forgexa_cli-1.103.0}/forgexa_cli.egg-info/PKG-INFO +1 -1
  6. {forgexa_cli-1.102.0 → forgexa_cli-1.103.0}/pyproject.toml +1 -1
  7. {forgexa_cli-1.102.0 → forgexa_cli-1.103.0}/README.md +0 -0
  8. {forgexa_cli-1.102.0 → forgexa_cli-1.103.0}/forgexa_cli/_build_config.py +0 -0
  9. {forgexa_cli-1.102.0 → forgexa_cli-1.103.0}/forgexa_cli/_local_bind.py +0 -0
  10. {forgexa_cli-1.102.0 → forgexa_cli-1.103.0}/forgexa_cli/autoupgrade.py +0 -0
  11. {forgexa_cli-1.102.0 → forgexa_cli-1.103.0}/forgexa_cli/aws_evidence.py +0 -0
  12. {forgexa_cli-1.102.0 → forgexa_cli-1.103.0}/forgexa_cli/aws_logs_evidence.py +0 -0
  13. {forgexa_cli-1.102.0 → forgexa_cli-1.103.0}/forgexa_cli/code_review_rules.py +0 -0
  14. {forgexa_cli-1.102.0 → forgexa_cli-1.103.0}/forgexa_cli/component_runtime.py +0 -0
  15. {forgexa_cli-1.102.0 → forgexa_cli-1.103.0}/forgexa_cli/main.py +0 -0
  16. {forgexa_cli-1.102.0 → forgexa_cli-1.103.0}/forgexa_cli/observability_contract.py +0 -0
  17. {forgexa_cli-1.102.0 → forgexa_cli-1.103.0}/forgexa_cli/observability_evidence.py +0 -0
  18. {forgexa_cli-1.102.0 → forgexa_cli-1.103.0}/forgexa_cli/ocr_adapter.py +0 -0
  19. {forgexa_cli-1.102.0 → forgexa_cli-1.103.0}/forgexa_cli/py.typed +0 -0
  20. {forgexa_cli-1.102.0 → forgexa_cli-1.103.0}/forgexa_cli/runtime_evidence.py +0 -0
  21. {forgexa_cli-1.102.0 → forgexa_cli-1.103.0}/forgexa_cli/workspace_storage.py +0 -0
  22. {forgexa_cli-1.102.0 → forgexa_cli-1.103.0}/forgexa_cli/zcode_protocol.py +0 -0
  23. {forgexa_cli-1.102.0 → forgexa_cli-1.103.0}/forgexa_cli.egg-info/SOURCES.txt +0 -0
  24. {forgexa_cli-1.102.0 → forgexa_cli-1.103.0}/forgexa_cli.egg-info/dependency_links.txt +0 -0
  25. {forgexa_cli-1.102.0 → forgexa_cli-1.103.0}/forgexa_cli.egg-info/entry_points.txt +0 -0
  26. {forgexa_cli-1.102.0 → forgexa_cli-1.103.0}/forgexa_cli.egg-info/requires.txt +0 -0
  27. {forgexa_cli-1.102.0 → forgexa_cli-1.103.0}/forgexa_cli.egg-info/top_level.txt +0 -0
  28. {forgexa_cli-1.102.0 → forgexa_cli-1.103.0}/setup.cfg +0 -0
  29. {forgexa_cli-1.102.0 → forgexa_cli-1.103.0}/tests/test_auth_and_runtime_commands.py +0 -0
  30. {forgexa_cli-1.102.0 → forgexa_cli-1.103.0}/tests/test_autoupgrade.py +0 -0
  31. {forgexa_cli-1.102.0 → forgexa_cli-1.103.0}/tests/test_check_command.py +0 -0
  32. {forgexa_cli-1.102.0 → forgexa_cli-1.103.0}/tests/test_delivery_review_packaged.py +0 -0
  33. {forgexa_cli-1.102.0 → forgexa_cli-1.103.0}/tests/test_expiry_warnings_and_revoke.py +0 -0
  34. {forgexa_cli-1.102.0 → forgexa_cli-1.103.0}/tests/test_local_bind_commands.py +0 -0
  35. {forgexa_cli-1.102.0 → forgexa_cli-1.103.0}/tests/test_publish_script.py +0 -0
  36. {forgexa_cli-1.102.0 → forgexa_cli-1.103.0}/tests/test_runtime_credentials.py +0 -0
  37. {forgexa_cli-1.102.0 → forgexa_cli-1.103.0}/tests/test_session_credentials.py +0 -0
  38. {forgexa_cli-1.102.0 → forgexa_cli-1.103.0}/tests/test_silent_install.py +0 -0
  39. {forgexa_cli-1.102.0 → forgexa_cli-1.103.0}/tests/test_upgrade_observability.py +0 -0
  40. {forgexa_cli-1.102.0 → forgexa_cli-1.103.0}/tests/test_workspace_storage.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: forgexa-cli
3
- Version: 1.102.0
3
+ Version: 1.103.0
4
4
  Summary: Forgexa CLI — command-line client and AI agent runtime for the Forgexa platform
5
5
  Author-email: Jason Sun <dev.winds@gmail.com>
6
6
  License-Expression: MIT
@@ -1,2 +1,2 @@
1
1
  """forgexa-cli — Forgexa command-line client."""
2
- __version__ = "1.102.0"
2
+ __version__ = "1.103.0"
@@ -3676,6 +3676,9 @@ def build_codex_command(
3676
3676
  model: str | None = None,
3677
3677
  skip_git_repo_check: bool = False,
3678
3678
  resume_session_id: str | None = None,
3679
+ ephemeral: bool = False,
3680
+ ignore_user_config: bool = False,
3681
+ ignore_rules: bool = False,
3679
3682
  ) -> list[str]:
3680
3683
  """Codex CLI exec-mode (non-interactive) invocation.
3681
3684
 
@@ -3696,14 +3699,21 @@ def build_codex_command(
3696
3699
  ``resume_session_id`` continues a previous exec session via
3697
3700
  ``codex exec resume <SESSION_ID> -`` (prompt still read from stdin).
3698
3701
  """
3699
- sandbox_flag = (
3700
- "--full-auto"
3701
- if str(sandbox).strip().lower() == "bwrap"
3702
- # Default: bypass sandbox entirely — no bwrap, no approval prompts.
3703
- # Equivalent to Kimi's --yolo and OpenCode's --dangerously-skip-permissions.
3704
- else "--dangerously-bypass-approvals-and-sandbox"
3705
- )
3706
- cmd = [binary, "exec", sandbox_flag, "--json"]
3702
+ normalized_sandbox = str(sandbox).strip().lower()
3703
+ cmd = [binary, "exec"]
3704
+ if normalized_sandbox == "bwrap":
3705
+ cmd.append("--full-auto")
3706
+ elif normalized_sandbox in {"read-only", "workspace-write"}:
3707
+ cmd += ["--sandbox", normalized_sandbox]
3708
+ else:
3709
+ cmd.append("--dangerously-bypass-approvals-and-sandbox")
3710
+ cmd.append("--json")
3711
+ if ephemeral:
3712
+ cmd.append("--ephemeral")
3713
+ if ignore_user_config:
3714
+ cmd.append("--ignore-user-config")
3715
+ if ignore_rules:
3716
+ cmd.append("--ignore-rules")
3707
3717
  if skip_git_repo_check:
3708
3718
  cmd.append("--skip-git-repo-check")
3709
3719
  if model:
@@ -3715,6 +3725,23 @@ def build_codex_command(
3715
3725
 
3716
3726
 
3717
3727
  OPENCODE_WORKER_AGENT = "forgexa-worker"
3728
+ OPENCODE_REVIEW_AGENT = "forgexa-reviewer"
3729
+ OPENCODE_FIX_AGENT = "forgexa-fixer"
3730
+ DELIVERY_REVIEW_AGENT_IDS = frozenset({
3731
+ "claude", "codebuddy", "codex", "copilot", "deepseek", "gemini", "kimi",
3732
+ "mimo", "minimax", "opencode", "qoder", "qwen", "trae", "zcode",
3733
+ })
3734
+ DELIVERY_REVIEW_SENSITIVE_PATTERNS = (
3735
+ r"/[.]env([.][^/]*)?$", r"[.](pem|key|p12|pfx)$", r"/(id_rsa|id_ed25519)([.][^/]*)?$",
3736
+ r"/[.]aws/credentials$", r"/[.](npmrc|netrc)$", r"/[.]git(/|$)",
3737
+ )
3738
+
3739
+
3740
+ def delivery_review_sandbox_exec() -> str | None:
3741
+ executable = "/usr/bin/sandbox-exec"
3742
+ return executable if sys.platform == "darwin" and os.path.isfile(executable) and os.access(executable, os.X_OK) else None
3743
+
3744
+
3718
3745
  _OPENCODE_WORKER_DENIED_TOOLS = (
3719
3746
  "task", "subagent", "delegate_task", "call_omo_agent",
3720
3747
  "background_output", "background_cancel",
@@ -3753,6 +3780,8 @@ def build_opencode_command(
3753
3780
  profile: OpenCodeProfile = "v1",
3754
3781
  auto_approve: bool = True,
3755
3782
  single_worker: bool = False,
3783
+ agent_name: str | None = None,
3784
+ pure: bool = False,
3756
3785
  ) -> list[str]:
3757
3786
  """OpenCode CLI non-interactive invocation.
3758
3787
 
@@ -3768,14 +3797,17 @@ def build_opencode_command(
3768
3797
  if profile not in ("v1", "v2"):
3769
3798
  raise ValueError("Unknown OpenCode CLI profile")
3770
3799
  cmd = [binary, "run", "--format", "json"]
3800
+ if pure:
3801
+ cmd.append("--pure")
3771
3802
  if profile == "v2":
3772
3803
  cmd.append("--standalone")
3773
3804
  if auto_approve:
3774
3805
  cmd.append("--auto" if profile == "v2" else "--dangerously-skip-permissions")
3775
3806
  if profile == "v1":
3776
3807
  cmd += ["--dir", str(cwd)]
3777
- if single_worker:
3778
- cmd += ["--agent", OPENCODE_WORKER_AGENT]
3808
+ selected_agent = OPENCODE_WORKER_AGENT if single_worker else agent_name
3809
+ if selected_agent:
3810
+ cmd += ["--agent", selected_agent]
3779
3811
  if session_id:
3780
3812
  cmd += ["--session", session_id]
3781
3813
  if model:
@@ -3790,6 +3822,10 @@ def build_opencode_command(
3790
3822
  return cmd
3791
3823
 
3792
3824
 
3825
+ MIMO_REVIEW_AGENT = "forgexa-reviewer"
3826
+ MIMO_FIX_AGENT = "forgexa-fixer"
3827
+
3828
+
3793
3829
  def build_mimo_command(
3794
3830
  binary: str,
3795
3831
  *,
@@ -3798,14 +3834,19 @@ def build_mimo_command(
3798
3834
  prompt_file: str | Path | None = None,
3799
3835
  session_id: str | None = None,
3800
3836
  prompt: str | None = None,
3837
+ delivery_agent: str | None = None,
3838
+ auto_approve: bool = True,
3839
+ pure: bool = False,
3801
3840
  ) -> list[str]:
3802
3841
  """MiMo Code CLI non-interactive invocation for the local AgentHost."""
3803
- cmd = [
3804
- binary, "run",
3805
- "--format", "json",
3806
- "--dangerously-skip-permissions",
3807
- "--dir", str(cwd),
3808
- ]
3842
+ cmd = [binary, "run", "--format", "json"]
3843
+ if auto_approve:
3844
+ cmd.append("--dangerously-skip-permissions")
3845
+ if pure:
3846
+ cmd.append("--pure")
3847
+ cmd += ["--dir", str(cwd)]
3848
+ if delivery_agent:
3849
+ cmd += ["--agent", delivery_agent]
3809
3850
  if session_id:
3810
3851
  cmd += ["--session", session_id]
3811
3852
  if model:
@@ -4091,9 +4132,13 @@ def minimax_base_env(root: Path, temporary_root: Path) -> dict[str, str]:
4091
4132
  return env
4092
4133
 
4093
4134
 
4094
- def _minimax_sandbox(command: list[str], admission: dict, cwd: Path, temporary_root: Path) -> list[str]:
4135
+ def _minimax_sandbox(
4136
+ command: list[str], admission: dict, cwd: Path, temporary_root: Path, read_only: bool = False,
4137
+ delivery_review: bool = False,
4138
+ ) -> list[str]:
4095
4139
  root = admission["root"]
4096
4140
  protected = [root / "bindings", *admission["config_paths"]]
4141
+ writable = (root / "data", temporary_root) if read_only else (cwd, root / "data", temporary_root)
4097
4142
  git = subprocess.run(["git", "rev-parse", "--absolute-git-dir", "--git-common-dir"],
4098
4143
  cwd=cwd, capture_output=True, text=True, timeout=10)
4099
4144
  if git.returncode == 0:
@@ -4106,18 +4151,25 @@ def _minimax_sandbox(command: list[str], admission: dict, cwd: Path, temporary_r
4106
4151
  f"(deny file-read* (subpath {quote(Path.home())}))"]
4107
4152
  for path in (cwd, root, Path(admission["build"]["package_root"]).parents[1],
4108
4153
  Path(admission["build"]["node"]).parent.parent):
4109
- profile.append(f"(allow file-read* (subpath {quote(path)}))")
4110
- for path in (cwd, root / "data", temporary_root):
4154
+ if path != Path.home() and path not in Path.home().parents:
4155
+ profile.append(f"(allow file-read* (subpath {quote(path)}))")
4156
+ for path in writable:
4111
4157
  profile.append(f"(allow file-write* (subpath {quote(path)}))")
4112
4158
  for path in protected:
4113
4159
  profile.append(f"(deny file-write* (subpath {quote(path)}))")
4114
- return ["sandbox-exec", "-p", "\n".join(profile), *command]
4160
+ if delivery_review:
4161
+ patterns = " ".join(f"(regex #{json.dumps(pattern)})" for pattern in DELIVERY_REVIEW_SENSITIVE_PATTERNS)
4162
+ profile.append(f"(deny file-read-data {patterns})")
4163
+ sandbox = delivery_review_sandbox_exec() if delivery_review else "sandbox-exec"
4164
+ if not sandbox:
4165
+ raise RuntimeError("MiniMax delivery review sandbox is unavailable")
4166
+ return [sandbox, "-p", "\n".join(profile), *command]
4115
4167
  wrapped = ["bwrap", "--die-with-parent", "--new-session", "--ro-bind", "/", "/",
4116
4168
  "--tmpfs", str(Path.home()), "--dev", "/dev", "--proc", "/proc"]
4117
4169
  for path in (Path(admission["build"]["package_root"]).parents[1],
4118
4170
  Path(admission["build"]["node"]).parent.parent, root):
4119
4171
  wrapped += ["--ro-bind", str(path), str(path)]
4120
- for path in (cwd, root / "data", temporary_root):
4172
+ for path in writable:
4121
4173
  wrapped += ["--bind", str(path), str(path)]
4122
4174
  for path in protected:
4123
4175
  wrapped += ["--ro-bind", str(path), str(path)]
@@ -4130,6 +4182,7 @@ async def run_minimax(
4130
4182
  on_event: Any = None, on_started: Any = None, on_chunk: Any = None,
4131
4183
  cancel_requested: Any = None,
4132
4184
  component_lease: Any = None,
4185
+ read_only: bool = False, delivery_review: bool = False,
4133
4186
  ) -> dict:
4134
4187
  lease = (
4135
4188
  component_lease if component_lease is not None else component_runtime.current_execution()
@@ -4171,7 +4224,7 @@ async def run_minimax(
4171
4224
  raise RuntimeError("MiniMax model override is not authorized by the accepted profile policy")
4172
4225
  binding_identity = hashlib.sha256(json.dumps({
4173
4226
  "admission": admission["fingerprint"], "workspace": str(cwd),
4174
- "model": model, "prompt_mode": "coding", "context_mode": "standard",
4227
+ "model": model, "prompt_mode": "coding", "context_mode": "standard", "read_only": read_only,
4175
4228
  }, sort_keys=True).encode()).hexdigest()
4176
4229
  if session_id:
4177
4230
  binding = root / "bindings" / (hashlib.sha256(session_id.encode()).hexdigest() + ".json")
@@ -4194,7 +4247,9 @@ async def run_minimax(
4194
4247
  component_runtime.harness_command, lease, "minimax", binary, command,
4195
4248
  minimax_base_env(root, temporary_root),
4196
4249
  )
4197
- command = _minimax_sandbox(command, admission, cwd, temporary_root)
4250
+ command = _minimax_sandbox(
4251
+ command, admission, cwd, temporary_root, read_only=read_only, delivery_review=delivery_review,
4252
+ )
4198
4253
  if cancel_requested is not None and cancel_requested():
4199
4254
  return state.finish(-1, cancelled=True)
4200
4255
  _minimax_write_record(active, {"fingerprint": binding_identity, "state": "spawning"})
@@ -4795,7 +4850,9 @@ def approve_deepseek_harness_build(binary: str) -> dict:
4795
4850
  return information
4796
4851
 
4797
4852
 
4798
- def deepseek_harness_base_env(env: dict[str, str], *, home: str | Path, temporary_root: str | Path) -> dict[str, str]:
4853
+ def deepseek_harness_base_env(
4854
+ env: dict[str, str], *, home: str | Path, temporary_root: str | Path, read_only: bool = False,
4855
+ ) -> dict[str, str]:
4799
4856
  allowed = {
4800
4857
  "PATH", "HOME", "USER", "LOGNAME", "USERPROFILE", "HOMEDRIVE", "HOMEPATH",
4801
4858
  "SYSTEMROOT", "WINDIR", "COMSPEC", "APPDATA", "LOCALAPPDATA", "LANG", "LC_ALL",
@@ -4804,7 +4861,7 @@ def deepseek_harness_base_env(env: dict[str, str], *, home: str | Path, temporar
4804
4861
  }
4805
4862
  controlled = {name: value for name, value in env.items() if name.upper() in allowed}
4806
4863
  controlled.update({
4807
- "DSH_HOME": str(home), "DSH_PERMISSION_MODE": "workspace-write",
4864
+ "DSH_HOME": str(home), "DSH_PERMISSION_MODE": "read-only" if read_only else "workspace-write",
4808
4865
  "DSH_TELEMETRY_DISABLED": "1", "DSH_TOOLS_MODE": "native",
4809
4866
  "TMPDIR": str(temporary_root), "TMP": str(temporary_root), "TEMP": str(temporary_root),
4810
4867
  "DEEPSEEK_BASE_URL": "https://api.deepseek.com/anthropic",
@@ -4853,18 +4910,21 @@ def deepseek_harness_profile_lock_path(workspace_path: str | Path) -> Path:
4853
4910
  return deepseek_harness_home(workspace_path) / "profile.lock"
4854
4911
 
4855
4912
 
4856
- def deepseek_harness_overlay(*, cwd: Path, credentials_path: Path, provider: str, model: str) -> list[dict]:
4913
+ def deepseek_harness_overlay(
4914
+ *, cwd: Path, credentials_path: Path, provider: str, model: str, read_only: bool = False,
4915
+ ) -> list[dict]:
4857
4916
  if not re.fullmatch(r"[A-Za-z0-9][A-Za-z0-9._:/-]{0,199}", model):
4858
4917
  raise ValueError("Invalid DeepSeek Harness model ID")
4918
+ sandbox_mode = "read-only" if read_only else "workspace-write"
4859
4919
  rows = [
4860
4920
  {"id": "agent-default-model", "config": {"provider": provider, "model": model, "reasoningEffort": "high"}},
4861
4921
  {"id": "credentials", "config": {"path": str(credentials_path), "watch": False}},
4862
4922
  {"id": "approval", "config": {"policy": "never"}},
4863
4923
  {"id": "permission", "config": {
4864
- "presets": {"forgexa-workspace": {"sandbox": "workspace-write", "approval": "never"}},
4924
+ "presets": {"forgexa-workspace": {"sandbox": sandbox_mode, "approval": "never"}},
4865
4925
  "defaultPreset": "forgexa-workspace",
4866
4926
  }},
4867
- {"id": "sandbox-policy", "config": {"mode": "workspace-write", "workspaceRoot": str(cwd)}},
4927
+ {"id": "sandbox-policy", "config": {"mode": sandbox_mode, "workspaceRoot": str(cwd)}},
4868
4928
  {"id": "fs-sandbox", "config": {"cwd": str(cwd)}},
4869
4929
  {"id": "tools", "config": {"mode": "native"}},
4870
4930
  {"id": "session-log-deepseek", "config": {"enabled": False}},
@@ -4911,24 +4971,46 @@ def _deepseek_harness_git_roots(cwd: Path) -> list[Path]:
4911
4971
  return roots
4912
4972
 
4913
4973
 
4914
- def deepseek_harness_sandbox_command(command: list[str], *, cwd: Path, home: Path, temporary_root: Path, credentials_path: Path | None = None) -> list[str]:
4974
+ def deepseek_harness_sandbox_command(
4975
+ command: list[str], *, cwd: Path, home: Path, temporary_root: Path,
4976
+ credentials_path: Path | None = None, read_only: bool = False,
4977
+ delivery_review: bool = False, read_paths: list[Path] | None = None,
4978
+ ) -> list[str]:
4915
4979
  git_roots = [*_deepseek_harness_git_roots(cwd), home / "forgexa-session-bindings"]
4916
4980
  if credentials_path is not None:
4917
4981
  git_roots.append(credentials_path)
4982
+ writable_roots = (home, temporary_root) if read_only else (cwd, home, temporary_root)
4918
4983
  if sys.platform == "darwin":
4919
- sandbox = shutil.which("sandbox-exec")
4984
+ sandbox = delivery_review_sandbox_exec() if delivery_review else shutil.which("sandbox-exec")
4920
4985
  if not sandbox:
4921
4986
  raise RuntimeError("DeepSeek Harness outer sandbox is unavailable")
4922
- writable = " ".join(f"(subpath {json.dumps(str(root.resolve()))})" for root in (cwd, home, temporary_root))
4987
+ writable = " ".join(f"(subpath {json.dumps(str(root.resolve()))})" for root in writable_roots)
4923
4988
  protected = " ".join(f"(subpath {json.dumps(str(root.resolve()))})" for root in git_roots)
4924
4989
  profile = f'(version 1) (allow default) (deny file-write*) (allow file-write* {writable} (literal "/dev/null")) (deny file-write* {protected})'
4990
+ if delivery_review:
4991
+ user_home = Path.home().resolve()
4992
+ roots = {path.resolve() for path in (cwd, home, temporary_root, *(read_paths or []))}
4993
+ roots = {path for path in roots if path != user_home and path not in user_home.parents}
4994
+ metadata = {parent for path in roots for parent in path.parents}
4995
+ if credentials_path is not None:
4996
+ metadata.update(credentials_path.resolve().parents)
4997
+ metadata_rules = " ".join(f"(literal {json.dumps(str(path))})" for path in sorted(metadata))
4998
+ read_rules = " ".join(f"(subpath {json.dumps(str(path))})" for path in sorted(roots))
4999
+ if credentials_path is not None:
5000
+ read_rules += f" (literal {json.dumps(str(credentials_path.resolve()))})"
5001
+ patterns = " ".join(f"(regex #{json.dumps(pattern)})" for pattern in DELIVERY_REVIEW_SENSITIVE_PATTERNS)
5002
+ profile += (
5003
+ f" (deny file-read* (subpath {json.dumps(str(user_home))}))"
5004
+ f" (allow file-read-metadata {metadata_rules}) (allow file-read-data {metadata_rules})"
5005
+ f" (allow file-read* {read_rules}) (deny file-read-data {patterns})"
5006
+ )
4925
5007
  return [sandbox, "-p", profile, *command]
4926
5008
  if sys.platform == "linux":
4927
5009
  sandbox = shutil.which("bwrap")
4928
5010
  if not sandbox:
4929
5011
  raise RuntimeError("DeepSeek Harness requires a working bubblewrap outer sandbox")
4930
5012
  wrapped = [sandbox, "--die-with-parent", "--unshare-pid", "--ro-bind", "/", "/", "--proc", "/proc", "--dev", "/dev"]
4931
- for root in (cwd, home, temporary_root):
5013
+ for root in writable_roots:
4932
5014
  wrapped += ["--bind", str(root), str(root)]
4933
5015
  for root in git_roots:
4934
5016
  if root.exists():
@@ -4938,7 +5020,10 @@ def deepseek_harness_sandbox_command(command: list[str], *, cwd: Path, home: Pat
4938
5020
 
4939
5021
 
4940
5022
  @contextmanager
4941
- def deepseek_harness_runtime(binary: str, workspace_path: str | Path, *, model: str | None = None, session_id: str | None = None):
5023
+ def deepseek_harness_runtime(
5024
+ binary: str, workspace_path: str | Path, *, model: str | None = None,
5025
+ session_id: str | None = None, read_only: bool = False, delivery_review: bool = False,
5026
+ ):
4942
5027
  binary = os.path.abspath(shutil.which(binary) or os.path.expanduser(binary))
4943
5028
  cwd = Path(workspace_path).expanduser().resolve()
4944
5029
  home = deepseek_harness_home(cwd)
@@ -4970,13 +5055,18 @@ def deepseek_harness_runtime(binary: str, workspace_path: str | Path, *, model:
4970
5055
  raise RuntimeError("The managed Harness profile contains an unsupported bundle")
4971
5056
  with tempfile.TemporaryDirectory(prefix="run-", dir=home) as run_dir:
4972
5057
  temporary_root = Path(run_dir).resolve()
4973
- env = deepseek_harness_base_env(os.environ.copy(), home=home, temporary_root=temporary_root)
5058
+ env = deepseek_harness_base_env(
5059
+ os.environ.copy(), home=home, temporary_root=temporary_root, read_only=read_only,
5060
+ )
4974
5061
  source_home = Path(os.environ.get("DSH_HOME", str(Path.home() / ".dsh"))).expanduser().resolve()
4975
5062
  credentials = Path(os.environ.get("FACTORY_DEEPSEEK_HARNESS_CREDENTIALS", str(source_home / ".credentials.yaml"))).expanduser().resolve()
4976
5063
  configuration = deepseek_harness_configuration(binary, credentials, env)
4977
5064
  selected_model = model or os.environ.get("FACTORY_DEEPSEEK_HARNESS_MODEL", "").strip() or "deepseek-flash"
4978
5065
  overlay = temporary_root / "run.patch.json"
4979
- composition = deepseek_harness_overlay(cwd=cwd, credentials_path=credentials, provider=configuration["provider"], model=selected_model)
5066
+ composition = deepseek_harness_overlay(
5067
+ cwd=cwd, credentials_path=credentials, provider=configuration["provider"],
5068
+ model=selected_model, read_only=read_only,
5069
+ )
4980
5070
  identity = hashlib.sha256(json.dumps({"build": deepseek_harness_build_info(binary)["fingerprint"], "overlay": composition}, sort_keys=True).encode()).hexdigest()
4981
5071
  env["FORGEXA_DEEPSEEK_HARNESS_COMPOSITION"] = identity
4982
5072
  if session_id:
@@ -4985,7 +5075,19 @@ def deepseek_harness_runtime(binary: str, workspace_path: str | Path, *, model:
4985
5075
  raise RuntimeError("Native Harness session configuration changed or is not owned by Forgexa; start a new session")
4986
5076
  overlay.write_text(json.dumps(composition), encoding="utf-8")
4987
5077
  command = build_deepseek_harness_command(binary, overlay_path=overlay, session_id=session_id)
4988
- yield deepseek_harness_sandbox_command(command, cwd=cwd, home=home, temporary_root=temporary_root, credentials_path=credentials), env
5078
+ read_paths = []
5079
+ if delivery_review:
5080
+ executable = Path(binary)
5081
+ read_paths = [executable.parent, executable.resolve().parent]
5082
+ read_paths.extend(root.parents[1] for root in _deepseek_harness_package_roots(binary))
5083
+ node = shutil.which("node")
5084
+ if node:
5085
+ read_paths.append(Path(node).resolve().parent.parent)
5086
+ yield deepseek_harness_sandbox_command(
5087
+ command, cwd=cwd, home=home, temporary_root=temporary_root,
5088
+ credentials_path=credentials, read_only=read_only,
5089
+ delivery_review=delivery_review, read_paths=read_paths,
5090
+ ), env
4989
5091
  finally:
4990
5092
  release_file_lock(lock)
4991
5093
 
@@ -5003,6 +5105,7 @@ async def run_deepseek_harness(
5003
5105
  on_chunk: Any = None,
5004
5106
  cancel_requested: Any = None,
5005
5107
  component_lease: Any = None,
5108
+ read_only: bool = False, delivery_review: bool = False,
5006
5109
  ) -> dict:
5007
5110
  """Execute and validate a supervised one-shot process with bounded output."""
5008
5111
  process = None
@@ -5014,7 +5117,10 @@ async def run_deepseek_harness(
5014
5117
  raw_lines = []
5015
5118
  raw_bytes = 0
5016
5119
  stderr_text = ""
5017
- runtime = deepseek_harness_runtime(binary, workspace_path, model=model, session_id=session_id)
5120
+ runtime = deepseek_harness_runtime(
5121
+ binary, workspace_path, model=model, session_id=session_id,
5122
+ read_only=read_only, delivery_review=delivery_review,
5123
+ )
5018
5124
  entered = False
5019
5125
  try:
5020
5126
  command, env = await asyncio.to_thread(runtime.__enter__)
@@ -5135,7 +5241,9 @@ async def run_deepseek_harness(
5135
5241
  "stderr": stderr_text, "raw_tail": "\n".join(raw_lines)}
5136
5242
 
5137
5243
 
5138
- def mimo_base_env(env: dict[str, str]) -> dict[str, str]:
5244
+ def mimo_base_env(
5245
+ env: dict[str, str], *, delivery_agent: str | None = None, allow_edits: bool = False,
5246
+ ) -> dict[str, str]:
5139
5247
  """Return the constrained MiMo Code environment used by AgentHost turns."""
5140
5248
  env = dict(env)
5141
5249
  config = json.loads(env.get("MIMOCODE_CONFIG_CONTENT") or "{}")
@@ -5181,6 +5289,18 @@ def mimo_base_env(env: dict[str, str]) -> dict[str, str]:
5181
5289
  "codesearch": "deny",
5182
5290
  }, separators=(",", ":")),
5183
5291
  })
5292
+ if delivery_agent is not None:
5293
+ if delivery_agent not in {MIMO_REVIEW_AGENT, MIMO_FIX_AGENT}:
5294
+ raise ValueError("Unknown MiMo delivery agent")
5295
+ allowed = ["read", "glob", "grep", "list"]
5296
+ if allow_edits:
5297
+ allowed.extend(["edit", "write"])
5298
+ permission = {"*": "deny", **dict.fromkeys(allowed, "allow")}
5299
+ config["agent"][delivery_agent] = {
5300
+ "mode": "primary", "hidden": True, "disable": False, "permission": permission,
5301
+ }
5302
+ env["MIMOCODE_CONFIG_CONTENT"] = json.dumps(config, separators=(",", ":"))
5303
+ env["MIMOCODE_PERMISSION"] = json.dumps(permission, separators=(",", ":"))
5184
5304
  return env
5185
5305
 
5186
5306
 
@@ -5189,6 +5309,8 @@ def opencode_base_env(
5189
5309
  require_windows_shell: bool = False, profile: OpenCodeProfile = "v1",
5190
5310
  cwd: str | Path | None = None,
5191
5311
  single_worker: bool = False,
5312
+ delivery_agent: str | None = None,
5313
+ allow_edits: bool = False,
5192
5314
  ) -> dict[str, str]:
5193
5315
  """Isolate each OpenCode run in its own XDG data directory.
5194
5316
 
@@ -5232,6 +5354,24 @@ def opencode_base_env(
5232
5354
  },
5233
5355
  )
5234
5356
  env["OPENCODE_CONFIG_CONTENT"] = json.dumps(config, ensure_ascii=False)
5357
+ if delivery_agent is not None:
5358
+ if delivery_agent not in {OPENCODE_REVIEW_AGENT, OPENCODE_FIX_AGENT}:
5359
+ raise OpenCodeConfigurationError("Unknown OpenCode delivery agent")
5360
+ config = _opencode_config_content(env)
5361
+ agents = config.setdefault("agent", {})
5362
+ if not isinstance(agents, dict):
5363
+ raise OpenCodeConfigurationError("OpenCode delivery configuration requires an agent object")
5364
+ agent = agents.setdefault(delivery_agent, {})
5365
+ if not isinstance(agent, dict):
5366
+ raise OpenCodeConfigurationError("OpenCode delivery agent configuration must be an object")
5367
+ allowed = ["read", "glob", "grep", "list"]
5368
+ if allow_edits:
5369
+ allowed.extend(["edit", "write"])
5370
+ agent.update(
5371
+ mode="primary", hidden=True, disable=False,
5372
+ permission={"*": "deny", **dict.fromkeys(allowed, "allow")},
5373
+ )
5374
+ env["OPENCODE_CONFIG_CONTENT"] = json.dumps(config, ensure_ascii=False)
5235
5375
  if profile == "v1" and data_home is not None:
5236
5376
  env["XDG_DATA_HOME"] = str(data_home)
5237
5377
  if cwd is not None:
@@ -5369,6 +5509,8 @@ def build_gemini_command(
5369
5509
  output_format: str | None = None,
5370
5510
  resume_session_id: str | None = None,
5371
5511
  skip_trust: bool = False,
5512
+ approval_mode: str = "yolo",
5513
+ extensions: list[str] | None = None,
5372
5514
  ) -> list[str]:
5373
5515
  """Gemini CLI headless/prompt-mode invocation (prompt via stdin).
5374
5516
 
@@ -5378,7 +5520,9 @@ def build_gemini_command(
5378
5520
  and ``skip_trust`` marks the workspace trusted so ``--approval-mode yolo``
5379
5521
  is not overridden back to "default" in untrusted folders.
5380
5522
  """
5381
- cmd = [binary, "--approval-mode", "yolo"]
5523
+ cmd = [binary, "--approval-mode", approval_mode]
5524
+ if extensions is not None:
5525
+ cmd += ["--extensions", ",".join(extensions)]
5382
5526
  if skip_trust:
5383
5527
  cmd.append("--skip-trust")
5384
5528
  if output_format:
@@ -5423,6 +5567,8 @@ def build_trae_code_command(
5423
5567
  resume_session_id: str | None = None,
5424
5568
  ephemeral: bool = False,
5425
5569
  shell_tool_timeout: str = "10m",
5570
+ sandbox: str = "workspace-write",
5571
+ permission_mode: str | None = "auto",
5426
5572
  ) -> list[str]:
5427
5573
  """Run TraeCode CLI headlessly with stdin prompt and local authentication.
5428
5574
 
@@ -5433,11 +5579,11 @@ def build_trae_code_command(
5433
5579
  if resume_session_id:
5434
5580
  cmd = [binary, "exec", "resume", resume_session_id]
5435
5581
  else:
5436
- cmd = [binary, "exec", "--sandbox", "workspace-write"]
5582
+ cmd = [binary, "exec", "--sandbox", sandbox]
5583
+ cmd += ["--json", "--color", "never"]
5584
+ if permission_mode is not None:
5585
+ cmd += ["--permission-mode", permission_mode]
5437
5586
  cmd += [
5438
- "--json",
5439
- "--color", "never",
5440
- "--permission-mode", "auto",
5441
5587
  "--ignore-user-config",
5442
5588
  "--ignore-rules",
5443
5589
  "--shell-tool-timeout", shell_tool_timeout,
@@ -5594,10 +5740,13 @@ ZCODE_DENIED_TOOLS = (
5594
5740
  )
5595
5741
 
5596
5742
 
5597
- def zcode_permission_response(params: dict[str, Any]) -> dict[str, Any]:
5743
+ def zcode_permission_response(
5744
+ params: dict[str, Any], *, allowed_tools: tuple[str, ...] | None = None,
5745
+ ) -> dict[str, Any]:
5598
5746
  """Return the bounded full-auto decision for one ZCode permission request."""
5599
5747
  tool_name = str(params.get("toolName") or "").strip()
5600
- if tool_name.lower() not in {tool.lower() for tool in ZCODE_ALLOWED_TOOLS}:
5748
+ tools = ZCODE_ALLOWED_TOOLS if allowed_tools is None else allowed_tools
5749
+ if tool_name.lower() not in {tool.lower() for tool in tools}:
5601
5750
  return {"decision": "deny", "reason": "Tool is not allowed by Forgexa policy"}
5602
5751
  return {"decision": "allow", "reason": "Allowed by Forgexa full_auto policy"}
5603
5752
 
@@ -5693,8 +5842,10 @@ def build_codebuddy_command(
5693
5842
  resume_session_id: str | None = None,
5694
5843
  max_turns: int = 60,
5695
5844
  no_session_persistence: bool = False,
5845
+ tools: list[str] | None = None,
5696
5846
  ) -> list[str]:
5697
5847
  """Run CodeBuddy through its isolated headless stream-json protocol."""
5848
+ selected_tools = _FORGEXA_CODING_AGENT_TOOLS if tools is None else tools
5698
5849
  cmd = [
5699
5850
  binary,
5700
5851
  "-p",
@@ -5702,8 +5853,8 @@ def build_codebuddy_command(
5702
5853
  "--input-format", "text",
5703
5854
  "--include-partial-messages",
5704
5855
  "--permission-mode", "dontAsk",
5705
- "--tools", ",".join(_FORGEXA_CODING_AGENT_TOOLS),
5706
- "--allowedTools", ",".join(_FORGEXA_CODING_AGENT_TOOLS),
5856
+ "--tools", ",".join(selected_tools),
5857
+ "--allowedTools", ",".join(selected_tools),
5707
5858
  "--disallowedTools", ",".join(_FORGEXA_CODING_AGENT_DENIED_TOOLS),
5708
5859
  "--strict-mcp-config",
5709
5860
  "--setting-sources", "",
@@ -5742,6 +5893,7 @@ def build_qoder_command(
5742
5893
  resume_session_id: str | None = None,
5743
5894
  max_turns: int = 60,
5744
5895
  no_session_persistence: bool = False,
5896
+ tools: list[str] | None = None,
5745
5897
  ) -> list[str]:
5746
5898
  """Run Qoder CLI through its isolated headless stream-json protocol.
5747
5899
 
@@ -5749,6 +5901,7 @@ def build_qoder_command(
5749
5901
  environment variable. Settings sources stay disabled to isolate hooks and
5750
5902
  plugins; installed skills remain available through the managed profile.
5751
5903
  """
5904
+ selected_tools = _FORGEXA_CODING_AGENT_TOOLS if tools is None else tools
5752
5905
  cmd = [
5753
5906
  binary,
5754
5907
  "-p",
@@ -5756,8 +5909,8 @@ def build_qoder_command(
5756
5909
  "--input-format", "text",
5757
5910
  "--cwd", str(cwd),
5758
5911
  "--permission-mode", "dont_ask",
5759
- "--tools", ",".join(_FORGEXA_CODING_AGENT_TOOLS),
5760
- "--allowed-tools", ",".join(_FORGEXA_CODING_AGENT_TOOLS),
5912
+ "--tools", ",".join(selected_tools),
5913
+ "--allowed-tools", ",".join(selected_tools),
5761
5914
  "--disallowed-tools", ",".join(_FORGEXA_CODING_AGENT_DENIED_TOOLS),
5762
5915
  "--strict-mcp-config",
5763
5916
  "--setting-sources", "",
@@ -6065,6 +6218,10 @@ def build_copilot_command(
6065
6218
  disable_builtin_mcps: bool = False,
6066
6219
  denied_tools: list[str] | None = None,
6067
6220
  prompt_via_stdin: bool = False,
6221
+ allow_all: bool = True,
6222
+ available_tools: list[str] | None = None,
6223
+ disable_custom_instructions: bool = False,
6224
+ disable_auto_update: bool = False,
6068
6225
  ) -> list[str]:
6069
6226
  """GitHub Copilot CLI non-interactive JSON-streaming invocation.
6070
6227
 
@@ -6088,12 +6245,18 @@ def build_copilot_command(
6088
6245
  cmd = [
6089
6246
  binary,
6090
6247
  "--output-format", "json",
6091
- "--allow-all",
6248
+ "--allow-all" if allow_all else "--allow-all-tools",
6092
6249
  ]
6250
+ for tool in available_tools or []:
6251
+ cmd.append(f"--available-tools={tool}")
6093
6252
  for tool in denied_tools or []:
6094
6253
  cmd.append(f"--deny-tool={tool}")
6095
6254
  if disable_builtin_mcps:
6096
6255
  cmd.append("--disable-builtin-mcps")
6256
+ if disable_custom_instructions:
6257
+ cmd.append("--no-custom-instructions")
6258
+ if disable_auto_update:
6259
+ cmd.append("--no-auto-update")
6097
6260
  if reasoning:
6098
6261
  cmd += ["--effort", reasoning]
6099
6262
  if resume_session_id: