feat(ack): add grok workers and allow --always-approve

Grok is a first-class worker CLI. Launcher argv includes --always-approve so
unattended tool calls are not blocked; sandbox stays required.
This commit is contained in:
2026-08-23 19:08:54 +08:00
parent c113f68bf4
commit 7dfdf80e9e
28 changed files with 679 additions and 78 deletions
+59 -2
View File
@@ -324,6 +324,9 @@ class EnvironmentAndExecutableTests(unittest.TestCase):
"OPENAI_API_KEY": "test-token",
"AZURE_OPENAI_API_KEY": "azure-token",
"CURSOR_API_KEY": "cursor-token",
"XAI_API_KEY": "xai-token",
"GROK_HOME": "/tmp/evil-grok",
"GROK_SANDBOX": "off",
"ANTHROPIC_API_KEY": "anthropic-token",
"DBUS_SESSION_BUS_ADDRESS": "unix:path=/tmp/dbus",
"DISPLAY": ":99",
@@ -336,17 +339,24 @@ class EnvironmentAndExecutableTests(unittest.TestCase):
control = launch_worker.control_environment()
codex = launch_worker.worker_environment("codex")
cursor = launch_worker.worker_environment("cursor-agent")
grok = launch_worker.worker_environment("grok")
for environment in (control, codex, cursor):
for environment in (control, codex, cursor, grok):
self.assertNotIn(hostile_path, environment["PATH"].split(os.pathsep))
self.assertEqual(environment["LANG"], "C.UTF-8")
self.assertNotIn("OPENAI_API_KEY", control)
self.assertNotIn("CURSOR_API_KEY", control)
self.assertNotIn("XAI_API_KEY", control)
self.assertEqual(codex["OPENAI_API_KEY"], "test-token")
self.assertEqual(codex["AZURE_OPENAI_API_KEY"], "azure-token")
self.assertNotIn("CURSOR_API_KEY", codex)
self.assertNotIn("XAI_API_KEY", codex)
self.assertEqual(cursor["CURSOR_API_KEY"], "cursor-token")
self.assertNotIn("OPENAI_API_KEY", cursor)
self.assertNotIn("XAI_API_KEY", cursor)
self.assertEqual(grok["XAI_API_KEY"], "xai-token")
self.assertNotIn("OPENAI_API_KEY", grok)
self.assertNotIn("CURSOR_API_KEY", grok)
for forbidden in (
"ANTHROPIC_API_KEY",
"DBUS_SESSION_BUS_ADDRESS",
@@ -356,11 +366,13 @@ class EnvironmentAndExecutableTests(unittest.TestCase):
"NODE_OPTIONS",
"PYTHONPATH",
"CODEX_HOME",
"GROK_HOME",
"GROK_SANDBOX",
"GIT_SSH_COMMAND",
"WAYLAND_DISPLAY",
"XDG_RUNTIME_DIR",
):
for environment in (control, codex, cursor):
for environment in (control, codex, cursor, grok):
self.assertNotIn(forbidden, environment)
def test_executable_resolution_ignores_hostile_path(self) -> None:
@@ -373,6 +385,51 @@ class EnvironmentAndExecutableTests(unittest.TestCase):
self.assertEqual(resolved, Path("/usr/bin/git"))
def test_grok_vendor_layout_is_trusted_and_outside_artifacts_are_not(self) -> None:
with tempfile.TemporaryDirectory() as temporary:
home = Path(temporary) / "home"
downloads = home / ".grok" / "downloads"
downloads.mkdir(parents=True)
artifact = downloads / "grok-linux-x86_64"
artifact.write_text("#!/bin/sh\n", encoding="utf-8")
artifact.chmod(0o775)
bindir = home / ".local" / "bin"
bindir.mkdir(parents=True)
(bindir / "grok").symlink_to(artifact)
hostile_dir = Path(temporary) / "tmp"
hostile_dir.mkdir()
hostile = hostile_dir / "grok-linux-x86_64"
hostile.write_text("#!/bin/sh\n", encoding="utf-8")
hostile.chmod(0o775)
hostile_bin = Path(temporary) / "hostile-bin"
hostile_bin.mkdir()
(hostile_bin / "grok").symlink_to(hostile)
with mock.patch.object(
launch_worker,
"account_identity",
return_value=(home.resolve(strict=True), "ace"),
), mock.patch.object(
launch_worker,
"trusted_path_entries",
return_value=[bindir.resolve(strict=True)],
):
resolved = launch_worker.resolve_executable("grok")
self.assertEqual(resolved, artifact.resolve(strict=True))
with mock.patch.object(
launch_worker,
"account_identity",
return_value=(home.resolve(strict=True), "ace"),
), mock.patch.object(
launch_worker,
"trusted_path_entries",
return_value=[hostile_bin.resolve(strict=True)],
):
with self.assertRaises(launch_worker.LaunchError):
launch_worker.resolve_executable("grok")
class PlanTests(unittest.TestCase):
def test_authoritative_board_is_derived_from_project_root_without_repo_path(self) -> None: