forgexa-cli 1.104.0__tar.gz → 1.104.2__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.104.0 → forgexa_cli-1.104.2}/PKG-INFO +1 -1
  2. {forgexa_cli-1.104.0 → forgexa_cli-1.104.2}/forgexa_cli/__init__.py +1 -1
  3. {forgexa_cli-1.104.0 → forgexa_cli-1.104.2}/forgexa_cli/agent_core.py +18 -2
  4. {forgexa_cli-1.104.0 → forgexa_cli-1.104.2}/forgexa_cli/daemon.py +117 -7
  5. {forgexa_cli-1.104.0 → forgexa_cli-1.104.2}/forgexa_cli.egg-info/PKG-INFO +1 -1
  6. {forgexa_cli-1.104.0 → forgexa_cli-1.104.2}/pyproject.toml +1 -1
  7. {forgexa_cli-1.104.0 → forgexa_cli-1.104.2}/README.md +0 -0
  8. {forgexa_cli-1.104.0 → forgexa_cli-1.104.2}/forgexa_cli/_build_config.py +0 -0
  9. {forgexa_cli-1.104.0 → forgexa_cli-1.104.2}/forgexa_cli/_local_bind.py +0 -0
  10. {forgexa_cli-1.104.0 → forgexa_cli-1.104.2}/forgexa_cli/autoupgrade.py +0 -0
  11. {forgexa_cli-1.104.0 → forgexa_cli-1.104.2}/forgexa_cli/aws_evidence.py +0 -0
  12. {forgexa_cli-1.104.0 → forgexa_cli-1.104.2}/forgexa_cli/aws_logs_evidence.py +0 -0
  13. {forgexa_cli-1.104.0 → forgexa_cli-1.104.2}/forgexa_cli/code_review_rules.py +0 -0
  14. {forgexa_cli-1.104.0 → forgexa_cli-1.104.2}/forgexa_cli/component_runtime.py +0 -0
  15. {forgexa_cli-1.104.0 → forgexa_cli-1.104.2}/forgexa_cli/main.py +0 -0
  16. {forgexa_cli-1.104.0 → forgexa_cli-1.104.2}/forgexa_cli/observability_contract.py +0 -0
  17. {forgexa_cli-1.104.0 → forgexa_cli-1.104.2}/forgexa_cli/observability_evidence.py +0 -0
  18. {forgexa_cli-1.104.0 → forgexa_cli-1.104.2}/forgexa_cli/ocr_adapter.py +0 -0
  19. {forgexa_cli-1.104.0 → forgexa_cli-1.104.2}/forgexa_cli/py.typed +0 -0
  20. {forgexa_cli-1.104.0 → forgexa_cli-1.104.2}/forgexa_cli/runtime_evidence.py +0 -0
  21. {forgexa_cli-1.104.0 → forgexa_cli-1.104.2}/forgexa_cli/workspace_storage.py +0 -0
  22. {forgexa_cli-1.104.0 → forgexa_cli-1.104.2}/forgexa_cli/zcode_protocol.py +0 -0
  23. {forgexa_cli-1.104.0 → forgexa_cli-1.104.2}/forgexa_cli.egg-info/SOURCES.txt +0 -0
  24. {forgexa_cli-1.104.0 → forgexa_cli-1.104.2}/forgexa_cli.egg-info/dependency_links.txt +0 -0
  25. {forgexa_cli-1.104.0 → forgexa_cli-1.104.2}/forgexa_cli.egg-info/entry_points.txt +0 -0
  26. {forgexa_cli-1.104.0 → forgexa_cli-1.104.2}/forgexa_cli.egg-info/requires.txt +0 -0
  27. {forgexa_cli-1.104.0 → forgexa_cli-1.104.2}/forgexa_cli.egg-info/top_level.txt +0 -0
  28. {forgexa_cli-1.104.0 → forgexa_cli-1.104.2}/setup.cfg +0 -0
  29. {forgexa_cli-1.104.0 → forgexa_cli-1.104.2}/tests/test_auth_and_runtime_commands.py +0 -0
  30. {forgexa_cli-1.104.0 → forgexa_cli-1.104.2}/tests/test_autoupgrade.py +0 -0
  31. {forgexa_cli-1.104.0 → forgexa_cli-1.104.2}/tests/test_check_command.py +0 -0
  32. {forgexa_cli-1.104.0 → forgexa_cli-1.104.2}/tests/test_delivery_review_packaged.py +0 -0
  33. {forgexa_cli-1.104.0 → forgexa_cli-1.104.2}/tests/test_expiry_warnings_and_revoke.py +0 -0
  34. {forgexa_cli-1.104.0 → forgexa_cli-1.104.2}/tests/test_local_bind_commands.py +0 -0
  35. {forgexa_cli-1.104.0 → forgexa_cli-1.104.2}/tests/test_publish_script.py +0 -0
  36. {forgexa_cli-1.104.0 → forgexa_cli-1.104.2}/tests/test_runtime_credentials.py +0 -0
  37. {forgexa_cli-1.104.0 → forgexa_cli-1.104.2}/tests/test_session_credentials.py +0 -0
  38. {forgexa_cli-1.104.0 → forgexa_cli-1.104.2}/tests/test_silent_install.py +0 -0
  39. {forgexa_cli-1.104.0 → forgexa_cli-1.104.2}/tests/test_upgrade_observability.py +0 -0
  40. {forgexa_cli-1.104.0 → forgexa_cli-1.104.2}/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.104.0
3
+ Version: 1.104.2
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.104.0"
2
+ __version__ = "1.104.2"
@@ -3731,6 +3731,7 @@ DELIVERY_REVIEW_AGENT_IDS = frozenset({
3731
3731
  "claude", "codebuddy", "codex", "copilot", "deepseek", "gemini", "kimi",
3732
3732
  "mimo", "minimax", "opencode", "qoder", "qwen", "trae", "zcode",
3733
3733
  })
3734
+ LINUX_DELIVERY_REVIEW_AGENT_IDS = frozenset({"claude", "copilot", "opencode"})
3734
3735
  DELIVERY_REVIEW_SENSITIVE_PATTERNS = (
3735
3736
  r"/[.]env([.][^/]*)?$", r"[.](pem|key|p12|pfx)$", r"/(id_rsa|id_ed25519)([.][^/]*)?$",
3736
3737
  r"/[.]aws/credentials$", r"/[.](npmrc|netrc)$", r"/[.]git(/|$)",
@@ -3738,8 +3739,23 @@ DELIVERY_REVIEW_SENSITIVE_PATTERNS = (
3738
3739
 
3739
3740
 
3740
3741
  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
3742
+ if sys.platform not in {"darwin", "linux"}:
3743
+ return None
3744
+ executable = "/usr/bin/sandbox-exec" if sys.platform == "darwin" else "/usr/bin/bwrap"
3745
+ if not os.path.isfile(executable) or not os.access(executable, os.X_OK):
3746
+ return None
3747
+ if sys.platform == "linux":
3748
+ try:
3749
+ probe = subprocess.run(
3750
+ [executable, "--unshare-all", "--die-with-parent", "--new-session",
3751
+ "--ro-bind", "/", "/", "--proc", "/proc", "--dev", "/dev", "--", "/bin/true"],
3752
+ stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, timeout=3, check=False,
3753
+ )
3754
+ except (OSError, subprocess.SubprocessError):
3755
+ return None
3756
+ if probe.returncode != 0:
3757
+ return None
3758
+ return executable
3743
3759
 
3744
3760
 
3745
3761
  _OPENCODE_WORKER_DENIED_TOOLS = (
@@ -1428,7 +1428,7 @@ except (ImportError, ModuleNotFoundError):
1428
1428
  # DAEMON_VERSION is the protocol/logic version of the daemon code.
1429
1429
  # Kept in sync with pyproject.toml version via bump-version.sh.
1430
1430
  # CLIENT_TYPE identifies which packaging/distribution this daemon runs in.
1431
- DAEMON_VERSION = "1.104.0"
1431
+ DAEMON_VERSION = "1.104.2"
1432
1432
 
1433
1433
 
1434
1434
  def _detect_client_type() -> str:
@@ -6624,7 +6624,7 @@ def _delivery_review_capabilities() -> dict:
6624
6624
  return {"delivery_code_review": {
6625
6625
  "protocol_version": 2,
6626
6626
  "ocr_delegation_version": 1,
6627
- "agent_ids": sorted(agent_core.DELIVERY_REVIEW_AGENT_IDS),
6627
+ "agent_ids": sorted(agent_core.LINUX_DELIVERY_REVIEW_AGENT_IDS if sys.platform == "linux" else agent_core.DELIVERY_REVIEW_AGENT_IDS),
6628
6628
  }}
6629
6629
  return {}
6630
6630
 
@@ -6683,8 +6683,58 @@ def _delivery_review_sandbox_command(command: list[str], workspace: Path, home:
6683
6683
  virtualenv = executable_path.parent.parent
6684
6684
  if (virtualenv / "pyvenv.cfg").is_file():
6685
6685
  read_roots.add(str(virtualenv))
6686
+ if sys.platform == "linux":
6687
+ node_executable = shutil.which("node")
6688
+ if node_executable:
6689
+ read_roots.add(str(Path(node_executable).resolve().parent))
6690
+ for parent in executable_path.resolve().parents:
6691
+ if parent == user_home_path or parent in user_home_path.parents:
6692
+ break
6693
+ if (parent / "package.json").is_file():
6694
+ read_roots.add(str(parent))
6695
+ break
6686
6696
  if any(Path(root) == user_home_path or Path(root) in user_home_path.parents for root in read_roots):
6687
6697
  raise RuntimeError("delivery_review_sandbox_scope_invalid")
6698
+ if sys.platform == "linux":
6699
+ wrapped = [sandbox, "--unshare-all", "--die-with-parent", "--new-session", "--cap-drop", "ALL"]
6700
+ if network:
6701
+ wrapped.append("--share-net")
6702
+ system_paths = (
6703
+ "/usr", "/bin", "/sbin", "/lib", "/lib64", "/etc/ssl/certs", "/etc/ca-certificates",
6704
+ "/etc/pki", "/etc/resolv.conf", "/etc/hosts", "/etc/nsswitch.conf", "/etc/gai.conf",
6705
+ "/etc/localtime", "/etc/passwd", "/etc/group", "/etc/ld.so.cache", "/etc/alternatives",
6706
+ )
6707
+ for path in system_paths:
6708
+ if Path(path).exists():
6709
+ wrapped += ["--ro-bind", path, path]
6710
+ wrapped += ["--proc", "/proc", "--dev", "/dev", "--tmpfs", "/tmp", "--tmpfs", "/var/tmp"]
6711
+ for root in sorted(read_roots):
6712
+ path = Path(root)
6713
+ if not path.exists():
6714
+ continue
6715
+ if not path.is_dir() and not path.is_file():
6716
+ raise RuntimeError("delivery_review_sandbox_scope_invalid")
6717
+ wrapped += ["--ro-bind", root, root]
6718
+ wrapped += ["--bind" if writable else "--ro-bind", str(workspace_path), str(workspace_path)]
6719
+ wrapped += ["--bind", str(home_path), str(home_path)]
6720
+ protected = {path.absolute() for path in (deny_paths or [])}
6721
+ for root in (workspace_path, home_path, *(Path(path) for path in read_roots if not str(path).startswith(("/usr/", "/bin", "/sbin", "/lib")))):
6722
+ if any(re.search(pattern, str(root)) for pattern in agent_core.DELIVERY_REVIEW_SENSITIVE_PATTERNS):
6723
+ protected.add(root)
6724
+ continue
6725
+ for directory, directories, files in os.walk(root, followlinks=False):
6726
+ for name in [*directories, *files]:
6727
+ path = Path(directory) / name
6728
+ if any(re.search(pattern, str(path)) for pattern in agent_core.DELIVERY_REVIEW_SENSITIVE_PATTERNS):
6729
+ protected.add(path)
6730
+ if name in directories:
6731
+ directories.remove(name)
6732
+ for path in sorted(protected):
6733
+ if path.is_dir():
6734
+ wrapped += ["--tmpfs", str(path)]
6735
+ elif path.exists() or path.is_symlink():
6736
+ wrapped += ["--ro-bind", "/dev/null", str(path)]
6737
+ return [*wrapped, "--chdir", str(workspace_path), "--", *command]
6688
6738
  executable_rules = " ".join(f"(subpath {json.dumps(root)})" for root in sorted(read_roots))
6689
6739
  metadata_paths = {
6690
6740
  str(parent) for root in [*read_roots, str(workspace.resolve()), str(home.resolve())]
@@ -8091,7 +8141,7 @@ class ProcessManager:
8091
8141
  )
8092
8142
  # Copy auth.json so provider credentials are available.
8093
8143
  auth_src = Path.home() / ".local" / "share" / "opencode" / "auth.json"
8094
- if profile == "v1" and auth_src.exists():
8144
+ if (profile == "v1" or delivery_review) and auth_src.exists():
8095
8145
  shutil.copy2(auth_src, isolated_data_dir / "auth.json")
8096
8146
  try:
8097
8147
  env = agent_core.opencode_base_env(
@@ -8107,6 +8157,9 @@ class ProcessManager:
8107
8157
  env.update(TMPDIR=tmp_data_root, BUN_TMPDIR=tmp_data_root)
8108
8158
  if delivery_review:
8109
8159
  env.update(
8160
+ HOME=tmp_data_root,
8161
+ USERPROFILE=tmp_data_root,
8162
+ XDG_DATA_HOME=tmp_data_root,
8110
8163
  XDG_CONFIG_HOME=str(Path(tmp_data_root) / "config"),
8111
8164
  XDG_CACHE_HOME=str(Path(tmp_data_root) / "cache"),
8112
8165
  XDG_STATE_HOME=str(Path(tmp_data_root) / "state"),
@@ -15213,11 +15266,15 @@ class RuntimeDaemon:
15213
15266
 
15214
15267
  async def _execute_delivery_code_review(self, task, agent, workspace_path) -> TaskResult:
15215
15268
  engine_identity = None
15269
+ preparation_failure = None
15216
15270
 
15217
15271
  def failed(code: str, message: str) -> TaskResult:
15218
15272
  return TaskResult(status="failed", exit_code=-1, stdout="", stderr="", failure_code=code,
15219
15273
  error=message, execution_attempt_id=task.execution_attempt_id,
15220
- metrics={"delivery_review_engine_identity": engine_identity} if engine_identity else {})
15274
+ metrics={
15275
+ **({"delivery_review_engine_identity": engine_identity} if engine_identity else {}),
15276
+ **({"delivery_review_preparation": preparation_failure} if preparation_failure else {}),
15277
+ })
15221
15278
 
15222
15279
  def remember_identity(identity):
15223
15280
  nonlocal engine_identity
@@ -15258,9 +15315,12 @@ class RuntimeDaemon:
15258
15315
  if not task.workspace_branch or not default_branch or default_branch.startswith("-"):
15259
15316
  return failed("delivery_review_scope_incomplete", "The candidate or target branch is unavailable")
15260
15317
 
15318
+ preparation_stage = "workspace_branch"
15261
15319
  try:
15262
15320
  branch = (await self.workspace_manager._git("branch", "--show-current", cwd=workspace_path, timeout=10)).strip()
15321
+ preparation_stage = "candidate_head"
15263
15322
  head = (await self.workspace_manager._git("rev-parse", "--verify", "HEAD^{commit}", cwd=workspace_path, timeout=10)).strip()
15323
+ preparation_stage = "workspace_status"
15264
15324
  dirty = await self.workspace_manager._git(
15265
15325
  "--no-optional-locks", "status", "--porcelain=v1", "-z", "--untracked-files=no", cwd=workspace_path, timeout=10,
15266
15326
  )
@@ -15268,6 +15328,7 @@ class RuntimeDaemon:
15268
15328
  return failed("delivery_review_candidate_changed", "The candidate branch or workspace changed")
15269
15329
  target_ref = ""
15270
15330
  target = ""
15331
+ preparation_stage = "target_ref"
15271
15332
  for candidate in (f"refs/remotes/origin/{default_branch}", f"refs/heads/{default_branch}"):
15272
15333
  try:
15273
15334
  target = (await self.workspace_manager._git(
@@ -15283,7 +15344,37 @@ class RuntimeDaemon:
15283
15344
  expected_target = (task.input_data or {}).get("delivery_review_expected_target")
15284
15345
  if (expected_head is not None and expected_head != head) or (expected_target is not None and expected_target != target):
15285
15346
  return failed("delivery_review_candidate_changed", "The local workspace does not match the requested review version")
15286
- base = (await self.workspace_manager._git("merge-base", target, head, cwd=workspace_path, timeout=10)).strip()
15347
+ preparation_stage = "merge_base"
15348
+ try:
15349
+ base = (await self.workspace_manager._git("merge-base", target, head, cwd=workspace_path, timeout=10)).strip()
15350
+ except RuntimeError:
15351
+ if task.workspace_resolution != "cloud_worktree":
15352
+ raise
15353
+ shallow = (await self.workspace_manager._git(
15354
+ "rev-parse", "--is-shallow-repository", cwd=workspace_path, timeout=10,
15355
+ )).strip()
15356
+ if shallow != "true":
15357
+ raise
15358
+ await self.workspace_manager._git("check-ref-format", f"refs/heads/{default_branch}", cwd=workspace_path, timeout=10)
15359
+ for deepen in (128, 512):
15360
+ preparation_stage = "history_fetch"
15361
+ await self.workspace_manager._git(
15362
+ "fetch", "--no-tags", "--no-recurse-submodules", "--no-write-fetch-head", "--refmap=",
15363
+ f"--deepen={deepen}", "origin", f"refs/heads/{default_branch}", f"refs/heads/{branch}",
15364
+ cwd=workspace_path, timeout=60, project_key=(task.project or {}).get("project_key"),
15365
+ )
15366
+ preparation_stage = "merge_base"
15367
+ try:
15368
+ base = (await self.workspace_manager._git("merge-base", target, head, cwd=workspace_path, timeout=10)).strip()
15369
+ break
15370
+ except RuntimeError:
15371
+ if deepen == 512:
15372
+ raise
15373
+ current_head = (await self.workspace_manager._git("rev-parse", "--verify", "HEAD^{commit}", cwd=workspace_path, timeout=10)).strip()
15374
+ current_target = (await self.workspace_manager._git("rev-parse", "--verify", f"{target_ref}^{{commit}}", cwd=workspace_path, timeout=10)).strip()
15375
+ if current_head != head or current_target != target:
15376
+ return failed("delivery_review_candidate_changed", "The candidate or target changed while resolving review history")
15377
+ preparation_stage = "changed_files"
15287
15378
  changed = await self.workspace_manager._git(
15288
15379
  "diff", "--no-ext-diff", "--no-textconv", "--no-renames", "--name-only", "-z",
15289
15380
  base, head, "--", cwd=workspace_path, timeout=60,
@@ -15291,6 +15382,7 @@ class RuntimeDaemon:
15291
15382
  paths = [path for path in changed.split("\x00") if path]
15292
15383
  if len(paths) > 200 or any(_is_sensitive_local_path(path) for path in paths):
15293
15384
  return failed("delivery_review_scope_incomplete", "The changed-file scope exceeds review limits")
15385
+ preparation_stage = "candidate_diff"
15294
15386
  diff = await self.workspace_manager._git(
15295
15387
  "diff", "--no-ext-diff", "--no-textconv", "--no-renames", "--unified=3",
15296
15388
  base, head, "--", cwd=workspace_path, timeout=60,
@@ -15302,6 +15394,7 @@ class RuntimeDaemon:
15302
15394
  batches = []
15303
15395
  batch_paths, batch_diff = [], ""
15304
15396
  for path in paths:
15397
+ preparation_stage = "file_diff"
15305
15398
  file_diff = await self.workspace_manager._git(
15306
15399
  "--literal-pathspecs", "diff", "--no-ext-diff", "--no-textconv", "--no-renames", "--unified=3",
15307
15400
  base, head, "--", path, cwd=workspace_path, timeout=60,
@@ -15318,8 +15411,25 @@ class RuntimeDaemon:
15318
15411
  if len(batches) > 8:
15319
15412
  return failed("delivery_review_scope_incomplete", "The complete diff requires too many review batches")
15320
15413
  except (OSError, RuntimeError, ValueError, UnicodeError) as error:
15321
- logger.warning("Cannot prepare delivery review scope: %s", type(error).__name__)
15322
- return failed("delivery_review_scope_incomplete", "The complete candidate diff is unavailable")
15414
+ detail = str(error).lower()
15415
+ reason = "git_command_failed"
15416
+ for category, pattern in (
15417
+ ("git_timeout", r"timed out|timeout"),
15418
+ ("git_resource_exhausted", r"cannot allocate memory|unable to mmap|out of memory"),
15419
+ ("git_access_denied", r"permission denied|dubious ownership|authentication failed|could not read username"),
15420
+ ("git_object_unavailable", r"bad object|not a valid|unknown revision|invalid object|unable to read|missing blob|bad tree|corrupt"),
15421
+ ("git_history_unavailable", r"no merge base|no merge-base|unrelated histories"),
15422
+ ):
15423
+ if re.search(pattern, detail):
15424
+ reason = category
15425
+ break
15426
+ if isinstance(error, UnicodeError):
15427
+ reason = "git_output_encoding"
15428
+ elif preparation_stage == "merge_base" and reason == "git_command_failed":
15429
+ reason = "git_history_unavailable"
15430
+ preparation_failure = {"stage": preparation_stage, "reason": reason, "error_type": type(error).__name__}
15431
+ logger.warning("Cannot prepare delivery review scope (stage=%s, reason=%s, type=%s)", preparation_stage, reason, type(error).__name__)
15432
+ return failed("delivery_review_scope_incomplete", f"The complete candidate diff is unavailable (stage={preparation_stage}; reason={reason}). Resolve the original workspace's Git prerequisite before retrying; switching Agent cannot fix this preparation failure.")
15323
15433
 
15324
15434
  metadata = {"version": protocol, "base_sha": base, "target_sha": target, "head_sha": head,
15325
15435
  "changed_files": paths, "reviewed_batches": [batch_paths for batch_paths, _ in batches] if paths else []}
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: forgexa-cli
3
- Version: 1.104.0
3
+ Version: 1.104.2
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,6 +1,6 @@
1
1
  [project]
2
2
  name = "forgexa-cli"
3
- version = "1.104.0"
3
+ version = "1.104.2"
4
4
  description = "Forgexa CLI — command-line client and AI agent runtime for the Forgexa platform"
5
5
  requires-python = ">=3.9"
6
6
  license = "MIT"
File without changes
File without changes