brindle 0.6.0__tar.gz → 0.6.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.
- {brindle-0.6.0 → brindle-0.6.2}/PKG-INFO +1 -1
- {brindle-0.6.0 → brindle-0.6.2}/pyproject.toml +1 -1
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/agents.py +138 -44
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/antigravity.py +45 -19
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/ci_client.py +1 -1
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/cli.py +71 -4
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/codex_hook.py +66 -19
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/config.py +32 -14
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/cull.py +31 -1
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/daemon/api-schema.json +42 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/daemon/pty_view.py +31 -5
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/daemon/routes_actions.py +31 -3
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/daemon/routes_read.py +5 -1
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/daemon/session_review.py +4 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/db.py +59 -4
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/demo.py +14 -2
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/disk.py +4 -3
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/doctor.py +6 -1
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/git.py +334 -30
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/keys_cmds.py +7 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/keystore.py +46 -2
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/permission_grants.py +23 -3
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/permission_groups.py +19 -12
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/permission_routing.py +15 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/permissions.py +752 -98
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/prompt_answer.py +60 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/providers.py +137 -29
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/reap.py +2 -2
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/scratch.py +2 -1
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/service/dto.py +14 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/service/errors.py +1 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/service/inbox.py +3 -2
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/service/permissions.py +6 -1
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/session_sync.py +44 -11
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/spawn.py +50 -5
- {brindle-0.6.0 → brindle-0.6.2}/.gitignore +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/LICENSE +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/README.md +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/SCHEDULE-A +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/__init__.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/__main__.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/account.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/airgap.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/assembler.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/assets/braid_dark.png +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/assets/braid_light.png +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/autopilot.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/budget.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/build_caches.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/builtin_agents/__init__.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/builtin_agents/backend-auditor.md +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/builtin_agents/coordinator.md +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/builtin_agents/developer-codex.md +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/builtin_agents/developer-fable.md +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/builtin_agents/developer-gemini.md +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/builtin_agents/developer-heavy.md +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/builtin_agents/developer-light.md +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/builtin_agents/developer-local.md +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/builtin_agents/developer-opencode.md +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/builtin_agents/developer-sonnet.md +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/builtin_agents/developer.md +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/builtin_agents/qa.md +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/builtin_agents/reviewer-codex.md +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/builtin_agents/reviewer-gemini.md +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/builtin_agents/reviewer-local.md +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/builtin_agents/reviewer-opencode.md +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/builtin_agents/reviewer.md +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/builtin_agents/subagent.md +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/builtin_agents/supervisor.md +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/builtin_rules/__init__.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/builtin_rules/analysis/doc.md +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/builtin_rules/security/backend.md +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/builtin_rules/style/minimal-diff.md +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/builtin_rules/tests/only.md +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/bus.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/check_scope.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/ci_adapters.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/ci_federation.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/ci_hosts.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/clone.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/cloud_credential.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/cloud_login.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/codemap.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/codemap_docs.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/company_identity.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/company_login.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/conflicts.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/connections.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/coordinator.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/cost.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/cost_estimate.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/daemon/__init__.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/daemon/app.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/daemon/auth.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/daemon/events.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/daemon/health.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/daemon/holds.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/daemon/lifecycle.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/daemon/peer.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/daemon/process_probe.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/daemon/routes_org_permissions.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/daemon/schema.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/daemon/terminal.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/debuglog.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/detect.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/entry.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/escapes.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/events.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/gates.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/guardrails.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/history.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/identity_lock.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/inbox.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/kb.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/key_check.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/knowledge.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/launch_health.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/learned_rules.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/learning.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/legacy.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/local_setup.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/login_pause.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/mcp_server.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/mcp_stdio.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/model_access.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/model_availability.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/native/__init__.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/native/catalog.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/native/client.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/native/loop.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/native/lsp.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/native/permissions.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/native/runner.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/native/serve.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/native/tools.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/opencode.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/org_permissions.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/pane_auth.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/permission_asks.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/picker.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/pipeline.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/plugins.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/policy.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/pool.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/preflight.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/pricing.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/pro/__init__.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/pro/_files.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/pro/account.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/pro/analysis_brief.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/pro/analysis_docs.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/pro/analysis_imports.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/pro/analysis_policy.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/pro/audit_chain.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/pro/audit_export.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/pro/auth.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/pro/brief_learning.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/pro/cost_centers.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/pro/credentials.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/pro/features.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/pro/keys.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/pro/learning.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/pro/license.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/pro/loopback.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/pro/managed_models.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/pro/org_profiles.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/pro/orgkey.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/pro/rollout.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/pro/route_health.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/pro/settings_sync.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/pro/status.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/pro/team_events.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/pro/team_policy.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/procs.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/profiles.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/provider_homes.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/providers_install.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/quota.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/redact.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/repo_cmds.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/repos.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/rewind.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/rule_checks.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/savings.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/secrets.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/self_serve.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/service/__init__.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/service/routing.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/service/sessions.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/services.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/sessions.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/sidebar_follow.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/sidebar_logo.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/signin_pause.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/status_cache.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/tasks.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/tmux.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/updates.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/upgrade.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/usage.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/view.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/wake.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/watch.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/watch_costs.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/web/__init__.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/web/chat.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/web/dashboard.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/web/diff.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/web/server.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/web/static/app.js +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/web/static/index.html +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/worker_models.py +0 -0
- {brindle-0.6.0 → brindle-0.6.2}/src/brindle/workspaces.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: brindle
|
|
3
|
-
Version: 0.6.
|
|
3
|
+
Version: 0.6.2
|
|
4
4
|
Summary: Run coding agents in parallel, each on its own git branch, with a supervisor that delegates, reviews, and merges
|
|
5
5
|
Project-URL: Homepage, https://pawdelta.com/brindle/
|
|
6
6
|
Project-URL: Documentation, https://pawdelta.com/brindle/docs/recommended-use
|
|
@@ -29,7 +29,7 @@ from brindle import bus, cloud_credential, company_identity, company_login, git,
|
|
|
29
29
|
from brindle import spawn as processes # this module's own spawn() starts an agent
|
|
30
30
|
from brindle.assembler import DECISIONS, DOCUMENT_CHUNKS, OTHER_SESSIONS, TASK_AND_RULES, Block, assemble
|
|
31
31
|
from brindle.config import RepoConfig
|
|
32
|
-
from brindle.db import DB, Agent, Workspace
|
|
32
|
+
from brindle.db import DB, Agent, Workspace, request_subagent
|
|
33
33
|
from brindle.model_availability import ModelAvailabilityChecker, PROVISIONING_TIMEOUT, provisioning_context
|
|
34
34
|
from brindle.pro import route_health
|
|
35
35
|
from brindle.profiles import load_profile, local_fallback, missing_add_dirs
|
|
@@ -212,6 +212,9 @@ def managed(repo_root: str):
|
|
|
212
212
|
_UNREAD = object() # a ``managed`` argument not passed: read the org's settings now
|
|
213
213
|
|
|
214
214
|
|
|
215
|
+
_KEYCHAIN_HELPER_PLATFORM = sys.platform == "darwin" # where git's default credential helper can raise a dialog
|
|
216
|
+
|
|
217
|
+
|
|
215
218
|
def agent_env(ws: Workspace, agent_id: str, agent: Agent | None = None,
|
|
216
219
|
m=_UNREAD) -> dict[str, str]:
|
|
217
220
|
env = {**workspaces.workspace_env(ws), "BRINDLE_AGENT_ID": agent_id}
|
|
@@ -315,6 +318,14 @@ def agent_env(ws: Workspace, agent_id: str, agent: Agent | None = None,
|
|
|
315
318
|
# so a few of them don't each start one per core. Passed explicitly, since
|
|
316
319
|
# a pane can inherit an older tmux environment; a profile's value still wins.
|
|
317
320
|
env.setdefault("PYTEST_XDIST_AUTO_NUM_WORKERS", os.environ.get("PYTEST_XDIST_AUTO_NUM_WORKERS", "2"))
|
|
321
|
+
# An agent's own `git push` to GitHub signs in through gh, not git's keychain
|
|
322
|
+
# helper, whose dialog nobody in a pane can answer (see git.pane_git_config).
|
|
323
|
+
if _KEYCHAIN_HELPER_PLATFORM and (config := git.pane_git_config()):
|
|
324
|
+
env.setdefault("GIT_CONFIG_PARAMETERS", config)
|
|
325
|
+
if os.path.isdir(ws.path):
|
|
326
|
+
# An account with no git identity: fill only what is still missing once
|
|
327
|
+
# the whole environment (a profile's GIT_* lines included) is assembled.
|
|
328
|
+
env.update(git.identity_env(ws.path, env))
|
|
318
329
|
return env
|
|
319
330
|
|
|
320
331
|
|
|
@@ -1236,16 +1247,21 @@ def _launch_resolved(db: DB, agent: Agent, ws: Workspace, *, prompt: str | None,
|
|
|
1236
1247
|
mcp_recovery = bool(agent.mode == "review" and agent.review_sha and db.conn.execute(
|
|
1237
1248
|
"SELECT 1 FROM review_mcp_retries WHERE workspace_id=? AND sha=?",
|
|
1238
1249
|
(ws.id, agent.review_sha)).fetchone())
|
|
1250
|
+
# The pane's own config folder: a profile's env line may move it, except
|
|
1251
|
+
# under an enforced company identity (agent_env).
|
|
1252
|
+
chrome_chosen = (providers.claude_chrome_chosen(_window_environment(agent, ws, m)[0])
|
|
1253
|
+
if provider.name == "claude" else None)
|
|
1239
1254
|
try:
|
|
1240
1255
|
argv = provider.command(LaunchContext(agent.id, profile, prompt, resume=resume, cwd=ws.path,
|
|
1241
1256
|
mode=agent.mode, plan_first=bool(agent.plan_first),
|
|
1242
|
-
mcp_recovery=mcp_recovery))
|
|
1257
|
+
mcp_recovery=mcp_recovery, chrome_chosen=chrome_chosen))
|
|
1243
1258
|
except providers.CodexSandboxRefused as e:
|
|
1244
1259
|
raise AgentError(str(e)) from e
|
|
1245
1260
|
if provider.name == "codex":
|
|
1246
1261
|
from brindle import codex_hook
|
|
1247
1262
|
|
|
1248
1263
|
try:
|
|
1264
|
+
codex_hook.tell_skipped(db, agent, ws.path)
|
|
1249
1265
|
codex_hook.tell_untrusted(db, agent, ws.path) # launched without the hook it couldn't trust
|
|
1250
1266
|
except Exception: # noqa: BLE001 - never stop a launch over this
|
|
1251
1267
|
pass
|
|
@@ -2273,6 +2289,9 @@ def screen_status(db: DB, agent: Agent, samples: int = 2, gap: float = 0.7) -> s
|
|
|
2273
2289
|
screen = tmux.capture(agent.tmux_window, lines=40, server=server_of(agent))
|
|
2274
2290
|
except tmux.TmuxError:
|
|
2275
2291
|
return None
|
|
2292
|
+
if samples >= 2 and prompt_answer.decline_teach_auto_mode(db, agent, screen):
|
|
2293
|
+
db.set_status(agent.id, "waiting", only_if=agent.status)
|
|
2294
|
+
return "waiting"
|
|
2276
2295
|
state = "busy" if prompt_answer.pane_busy(screen) else provider.screen_state(screen)
|
|
2277
2296
|
if agent.status == "idle" and state == "busy" and not provider.busy_in_footer(screen):
|
|
2278
2297
|
state = None
|
|
@@ -4010,14 +4029,17 @@ def pre_tool_decision(db: DB, agent: Agent, payload: dict) -> dict | None:
|
|
|
4010
4029
|
"permissionDecisionReason": why,
|
|
4011
4030
|
}}
|
|
4012
4031
|
ruled = _pre_tool_policy(db, agent, ws, payload, load)
|
|
4013
|
-
|
|
4032
|
+
allowed = ruled is not None and ruled["hookSpecificOutput"]["permissionDecision"] == "allow"
|
|
4033
|
+
if ruled is not None and not allowed:
|
|
4014
4034
|
return ruled
|
|
4015
4035
|
if tool != "Bash":
|
|
4016
|
-
return
|
|
4036
|
+
return ruled
|
|
4017
4037
|
command = str((payload.get("tool_input") or {}).get("command", ""))
|
|
4018
4038
|
from brindle import codemap
|
|
4019
4039
|
|
|
4020
4040
|
codemap.record_query(db, agent, ws, command)
|
|
4041
|
+
if allowed:
|
|
4042
|
+
return ruled
|
|
4021
4043
|
try:
|
|
4022
4044
|
profile = load()
|
|
4023
4045
|
except Exception:
|
|
@@ -4039,18 +4061,51 @@ def pre_tool_decision(db: DB, agent: Agent, payload: dict) -> dict | None:
|
|
|
4039
4061
|
}}
|
|
4040
4062
|
|
|
4041
4063
|
|
|
4064
|
+
# Claude Code's modes that would prompt for what no rule of its own allows. In
|
|
4065
|
+
# these an allow at PreToolUse only saves the prompt; in any other mode (dontAsk
|
|
4066
|
+
# refuses, auto has its classifier, plan its own floor) it would change the outcome.
|
|
4067
|
+
PROMPTING_MODES = ("default", "acceptEdits")
|
|
4068
|
+
# What it answers there. Reads run unasked inside the worktree (nothing to save),
|
|
4069
|
+
# and the MCP and other tools stay with the PermissionRequest hook.
|
|
4070
|
+
PRE_TOOL_ALLOW_KINDS = ("bash", "write", "edit", "fetch")
|
|
4071
|
+
|
|
4072
|
+
|
|
4073
|
+
def _unasked(payload: object) -> bool:
|
|
4074
|
+
"""Whether Claude Code's mode runs this call if the PreToolUse hook gives
|
|
4075
|
+
no answer (providers.CLAUDE_UNASKED_MODES), so no answer can't mean "ask"."""
|
|
4076
|
+
return isinstance(payload, dict) and payload.get("permission_mode") in providers.CLAUDE_UNASKED_MODES
|
|
4077
|
+
|
|
4078
|
+
|
|
4079
|
+
def _pre_tool_unchecked(why: str) -> dict:
|
|
4080
|
+
"""PreToolUse's answer when brindle couldn't check a call in such a mode."""
|
|
4081
|
+
return {"hookSpecificOutput": {
|
|
4082
|
+
"hookEventName": "PreToolUse",
|
|
4083
|
+
"permissionDecision": "deny",
|
|
4084
|
+
"permissionDecisionReason": (
|
|
4085
|
+
f"brindle: couldn't check this call ({why}), and in this permission mode nothing after that check "
|
|
4086
|
+
"would stop it. Try again; if it keeps happening, tell your supervisor or the person"),
|
|
4087
|
+
}}
|
|
4088
|
+
|
|
4089
|
+
|
|
4042
4090
|
def _pre_tool_policy(db: DB, agent: Agent, ws: Workspace | None, payload: dict, load) -> dict | None:
|
|
4043
4091
|
"""With ``permission_policy`` on, the policy's word on a PreToolUse call
|
|
4044
4092
|
before any approval of brindle's own: a deny denies it, and an ask a rule
|
|
4045
4093
|
makes explicitly forces Claude Code's prompt (``permissionDecision``
|
|
4046
4094
|
"ask"), so the PermissionRequest hook then holds it for the person,
|
|
4047
4095
|
whatever the profile's allowed_tools or Claude Code's own mode would have
|
|
4048
|
-
run without asking.
|
|
4049
|
-
|
|
4050
|
-
|
|
4096
|
+
run without asking. An allow goes in here too where Claude Code would
|
|
4097
|
+
otherwise prompt, so the prompt the PermissionRequest hook would only close
|
|
4098
|
+
never shows; its deny rules, ask rules and safety checks still apply. Left
|
|
4099
|
+
to that hook: an allow a saved action settles, which spends a use there.
|
|
4100
|
+
None otherwise (the rest of the hook decides). In a mode that runs a call
|
|
4101
|
+
no answer stops (_unasked) that hook never comes, so a saved use is spent
|
|
4102
|
+
here, Autonomous's own asks (a person's "ask" for a group, which no rule
|
|
4103
|
+
makes) are forced too, and what can't be checked is denied. ``load`` loads
|
|
4104
|
+
the agent's profile. Never raises."""
|
|
4105
|
+
unasked = _unasked(payload)
|
|
4051
4106
|
try:
|
|
4052
4107
|
if ws is None:
|
|
4053
|
-
return None
|
|
4108
|
+
return _pre_tool_unchecked("its workspace is gone") if unasked else None
|
|
4054
4109
|
from brindle import permissions
|
|
4055
4110
|
from brindle.config import load_repo_config
|
|
4056
4111
|
|
|
@@ -4059,14 +4114,21 @@ def _pre_tool_policy(db: DB, agent: Agent, ws: Workspace | None, payload: dict,
|
|
|
4059
4114
|
return None
|
|
4060
4115
|
req = permissions.from_claude(payload, worktree=ws.path, repo_root=ws.repo_root, agent=agent.id)
|
|
4061
4116
|
if req is None:
|
|
4062
|
-
return None
|
|
4117
|
+
return _pre_tool_unchecked("the request names no tool") if unasked else None
|
|
4063
4118
|
try:
|
|
4064
4119
|
profile_rules = permissions.profile_rules(load())
|
|
4065
4120
|
except KeyError: # a deleted profile: no override (profiles.profile_rules_for)
|
|
4066
4121
|
profile_rules = []
|
|
4067
4122
|
rules = [*permissions.all_rules(ws.repo_root), *profile_rules]
|
|
4068
|
-
|
|
4069
|
-
|
|
4123
|
+
session = _session_of(db, agent)
|
|
4124
|
+
decision = permissions.decide(req, checks=cfg.checks, rules=rules, session=session)
|
|
4125
|
+
if unasked and decision.decision == "allow" and decision.saved is not None:
|
|
4126
|
+
decision = permissions.decide(req, checks=cfg.checks, rules=rules, session=session, spend=True)
|
|
4127
|
+
if decision.decision == "allow":
|
|
4128
|
+
_record_permission(db, agent, ws, req.summary(), f"allow: {decision.reason}")
|
|
4129
|
+
_note_decision(db, agent, ws, req.kind, req.summary(), decision)
|
|
4130
|
+
if (decision.decision == "deny" or (decision.decision == "ask" and (
|
|
4131
|
+
decision.rule is not None or (unasked and permissions.autonomous(cfg))))):
|
|
4070
4132
|
if decision.decision == "deny": # an ask is counted when the PermissionRequest hook holds it
|
|
4071
4133
|
_note_decision(db, agent, ws, req.kind, req.summary(), decision)
|
|
4072
4134
|
return {"hookSpecificOutput": {
|
|
@@ -4074,10 +4136,19 @@ def _pre_tool_policy(db: DB, agent: Agent, ws: Workspace | None, payload: dict,
|
|
|
4074
4136
|
"permissionDecision": decision.decision,
|
|
4075
4137
|
"permissionDecisionReason": f"brindle: {decision.reason}",
|
|
4076
4138
|
}}
|
|
4139
|
+
if (decision.decision == "allow" and decision.saved is None and req.kind in PRE_TOOL_ALLOW_KINDS
|
|
4140
|
+
and payload.get("permission_mode") in PROMPTING_MODES):
|
|
4141
|
+
_record_permission(db, agent, ws, req.summary(), f"allow: {decision.reason}")
|
|
4142
|
+
_note_decision(db, agent, ws, req.kind, req.summary(), decision)
|
|
4143
|
+
return {"hookSpecificOutput": {
|
|
4144
|
+
"hookEventName": "PreToolUse",
|
|
4145
|
+
"permissionDecision": "allow",
|
|
4146
|
+
"permissionDecisionReason": f"brindle: {decision.reason}",
|
|
4147
|
+
}}
|
|
4077
4148
|
return None
|
|
4078
|
-
except Exception: # noqa: BLE001 - a broken policy
|
|
4079
|
-
log.exception("brindle: permission policy failed in PreToolUse
|
|
4080
|
-
return None
|
|
4149
|
+
except Exception: # noqa: BLE001 - a broken policy falls through to Claude Code's own prompt, where it has one
|
|
4150
|
+
log.exception("brindle: permission policy failed in PreToolUse")
|
|
4151
|
+
return _pre_tool_unchecked("its permission check failed") if unasked else None
|
|
4081
4152
|
|
|
4082
4153
|
|
|
4083
4154
|
def codex_pre_tool_decision(db: DB, agent: Agent, payload: dict) -> dict | None:
|
|
@@ -4316,7 +4387,7 @@ def permission_request_decision(db: DB, agent: Agent, payload: dict,
|
|
|
4316
4387
|
suggestions = permissions.persistent_suggestions(suggestions)
|
|
4317
4388
|
# Recorded either way: its PostToolUse counts as the person's approval.
|
|
4318
4389
|
answer = _hold_for_app(db, agent, req, decision.reason, suggestions, keep=True,
|
|
4319
|
-
hold=cfg.permission_hold_seconds,
|
|
4390
|
+
hold=cfg.permission_hold_seconds, subagent=_subagent_of(payload),
|
|
4320
4391
|
**(_supervising(db, agent, cfg, decision, payload) if policy else {}))
|
|
4321
4392
|
if answer:
|
|
4322
4393
|
return permissions.claude_answer(answer, suggestions)
|
|
@@ -4338,6 +4409,18 @@ def _supervising(db: DB, agent: Agent, cfg, decision, payload: dict) -> dict:
|
|
|
4338
4409
|
"tool_input": payload.get("tool_input")}
|
|
4339
4410
|
|
|
4340
4411
|
|
|
4412
|
+
def _subagent_of(payload: dict) -> str | None:
|
|
4413
|
+
"""The Agent-tool subagent a Claude Code hook fired for (its payload's
|
|
4414
|
+
``agent_id``), or None on the main thread. A subagent's request has no prompt
|
|
4415
|
+
on screen while the hook holds it: Claude Code draws it only once the hook
|
|
4416
|
+
returns nothing (seen in 2.1.318), so nothing on the pane says what became of
|
|
4417
|
+
it. It ends with an answer, the person's "answer in the terminal", or the hold
|
|
4418
|
+
letting go: when the app isn't connected the daemon's wait route ends it, so the
|
|
4419
|
+
dialog comes (brindle.daemon.holds)."""
|
|
4420
|
+
subagent = payload.get("agent_id")
|
|
4421
|
+
return subagent if isinstance(subagent, str) and subagent else None
|
|
4422
|
+
|
|
4423
|
+
|
|
4341
4424
|
def _session_of(db: DB, agent: Agent) -> str | None:
|
|
4342
4425
|
"""The session (root agent) ``agent`` belongs to, for saved actions that last one."""
|
|
4343
4426
|
try:
|
|
@@ -4352,15 +4435,11 @@ def _session_of(db: DB, agent: Agent) -> str | None:
|
|
|
4352
4435
|
# agent was closed or its request answered at the CLI's own prompt.
|
|
4353
4436
|
HOLD_LOOK_SECONDS = 1.0
|
|
4354
4437
|
HOLD_MIN_LOOK = 0.1 # the shortest such wait (the daemon reads 0 as its longest)
|
|
4355
|
-
#
|
|
4356
|
-
#
|
|
4357
|
-
#
|
|
4358
|
-
#
|
|
4359
|
-
|
|
4360
|
-
# Looks in a row a pane must read past its CLI's own permission prompt, busy
|
|
4361
|
-
# or idle, before the hold ends: longer than one look, so a read while the
|
|
4362
|
-
# prompt is redrawn doesn't take it for answered. Any other read starts the
|
|
4363
|
-
# count over.
|
|
4438
|
+
# Looks in a row a pane that has shown its CLI's own permission prompt must then
|
|
4439
|
+
# read past it, busy or idle, before the hold ends: longer than one look, so a
|
|
4440
|
+
# read while the prompt is redrawn doesn't take it for answered. Any other read
|
|
4441
|
+
# starts the count over. A pane that hasn't shown it says nothing: no prompt may
|
|
4442
|
+
# be drawn yet, or at all while the hook holds the request (_subagent_of).
|
|
4364
4443
|
ANSWERED_LOOKS = 3
|
|
4365
4444
|
# Seconds a CLI's hook timeout is set above the hold (permission_hold_seconds),
|
|
4366
4445
|
# so the hook gives the request to the prompt itself before the CLI cancels it.
|
|
@@ -4370,7 +4449,7 @@ ANSWERS = ("allow_once", "allow_always", "deny")
|
|
|
4370
4449
|
|
|
4371
4450
|
def _hold_for_app(db: DB, agent: Agent, req, reason: str, suggestions: list | None, keep: bool,
|
|
4372
4451
|
hold: float, supervisor: Agent | None = None, supervise: float = 0,
|
|
4373
|
-
tool_input: object = None) -> str | None:
|
|
4452
|
+
tool_input: object = None, subagent: str | None = None) -> str | None:
|
|
4374
4453
|
"""Record a request the policy left to the person and, while the app's
|
|
4375
4454
|
daemon runs, hold it there for the person's answer for ``hold`` seconds
|
|
4376
4455
|
(_await_app_answer; the row's ``hold_until`` says till when, for the
|
|
@@ -4383,12 +4462,15 @@ def _hold_for_app(db: DB, agent: Agent, req, reason: str, suggestions: list | No
|
|
|
4383
4462
|
and keep it once the hold ends (for that pairing). ``supervisor``: the
|
|
4384
4463
|
worker's supervisor answers it first, for ``supervise`` seconds of the
|
|
4385
4464
|
hold (brindle.permission_routing), and the person after; it is shown the
|
|
4386
|
-
CLI's complete ``tool_input``, which also tells identical requests apart.
|
|
4465
|
+
CLI's complete ``tool_input``, which also tells identical requests apart.
|
|
4466
|
+
``subagent``: _subagent_of."""
|
|
4387
4467
|
from brindle import permission_asks, permission_routing, permissions
|
|
4388
4468
|
from brindle.daemon.holds import Holder
|
|
4389
4469
|
|
|
4390
4470
|
request_id = uuid.uuid4().hex[:16]
|
|
4391
|
-
recorded
|
|
4471
|
+
# The subagent goes in the recorded JSON (Request.from_dict ignores it): no released table gains a column.
|
|
4472
|
+
recorded = (json.dumps({**req.to_dict(), **({"subagent": subagent} if subagent else {})}),
|
|
4473
|
+
json.dumps(suggestions) if suggestions else None)
|
|
4392
4474
|
# Only an answer to exactly this request and these suggestions counts.
|
|
4393
4475
|
digest = permissions.request_digest(*recorded)
|
|
4394
4476
|
holder = Holder(agent.id, request_id, digest)
|
|
@@ -4419,7 +4501,8 @@ def _hold_for_app(db: DB, agent: Agent, req, reason: str, suggestions: list | No
|
|
|
4419
4501
|
if held:
|
|
4420
4502
|
try:
|
|
4421
4503
|
ended = _await_app_answer(db, agent, holder, req, hold_until,
|
|
4422
|
-
*([supervise_until] if supervise_until else [])
|
|
4504
|
+
*([supervise_until] if supervise_until else []),
|
|
4505
|
+
**({"pane_shows": False} if subagent else {}))
|
|
4423
4506
|
ended_at = time.time() # the wait's end, before the cleanup below
|
|
4424
4507
|
answer = ended if ended in ANSWERS or ended in permission_routing.AS_ANSWER else None
|
|
4425
4508
|
finally:
|
|
@@ -4443,7 +4526,7 @@ def _closed(agent: Agent | None) -> bool:
|
|
|
4443
4526
|
|
|
4444
4527
|
|
|
4445
4528
|
def _await_app_answer(db: DB, agent: Agent, holder, req, hold_until: float,
|
|
4446
|
-
supervise_until: float | None = None) -> str:
|
|
4529
|
+
supervise_until: float | None = None, pane_shows: bool = True) -> str:
|
|
4447
4530
|
"""The person's answer from the app's inbox (one of ANSWERS), or the
|
|
4448
4531
|
supervisor's (permission_routing.AS_ANSWER) while the request is its,
|
|
4449
4532
|
until ``supervise_until``, as the daemon hands it to ``holder``
|
|
@@ -4451,16 +4534,19 @@ def _await_app_answer(db: DB, agent: Agent, holder, req, hold_until: float,
|
|
|
4451
4534
|
hold ended: "timeout" at ``hold_until``, "terminal" when the person
|
|
4452
4535
|
asks to answer in the terminal, "agent_exit" once the agent is closed or
|
|
4453
4536
|
killed, "prompt" once its CLI's own prompt took the request (its
|
|
4454
|
-
PostToolUse removed the row, or its pane
|
|
4455
|
-
ANSWERED_LOOKS), "daemon_lost" if the daemon goes away
|
|
4456
|
-
|
|
4457
|
-
|
|
4537
|
+
PostToolUse removed the row, or its pane showed the prompt, then stayed
|
|
4538
|
+
past it for ANSWERED_LOOKS), "daemon_lost" if the daemon goes away (or, the
|
|
4539
|
+
request the person's, no app is left to show it in). Without an answer the
|
|
4540
|
+
request goes to the CLI's own prompt (or, where there is none, is refused).
|
|
4541
|
+
The agent shows waiting meanwhile, as at that prompt. ``pane_shows``: False
|
|
4542
|
+
when the CLI draws no prompt while the hook holds the request (_subagent_of),
|
|
4543
|
+
so the pane is never looked at."""
|
|
4458
4544
|
from brindle.permission_routing import AS_ANSWER
|
|
4459
4545
|
|
|
4460
4546
|
db.set_status(agent.id, "waiting")
|
|
4461
4547
|
if supervise_until is None:
|
|
4462
4548
|
bus.publish_agent(db, "permission.pending", agent.id, tool=req.tool, target=req.target())
|
|
4463
|
-
deadline, past, seen
|
|
4549
|
+
deadline, past, seen = time.monotonic() + hold_until - time.time(), 0, False
|
|
4464
4550
|
while True:
|
|
4465
4551
|
now = db.get_agent(agent.id)
|
|
4466
4552
|
recorded = db.conn.execute("SELECT channel FROM permission_requests WHERE agent_id=? AND tool_use_id=?",
|
|
@@ -4480,13 +4566,13 @@ def _await_app_answer(db: DB, agent: Agent, holder, req, hold_until: float,
|
|
|
4480
4566
|
supervise_until = None
|
|
4481
4567
|
db.update_permission_request(agent.id, holder.request_id, channel="hook")
|
|
4482
4568
|
bus.publish_agent(db, "permission.pending", agent.id, tool=req.tool, target=req.target())
|
|
4483
|
-
#
|
|
4484
|
-
#
|
|
4485
|
-
#
|
|
4486
|
-
if
|
|
4569
|
+
# On the main thread its CLI shows its own prompt for as long as this hook holds the
|
|
4570
|
+
# request: a pane that showed it and is now past it was answered there. An allow runs
|
|
4571
|
+
# the tool (its PostToolUse comes once it is done), a deny or a dismissal none.
|
|
4572
|
+
if pane_shows:
|
|
4487
4573
|
state = _pane_state(now)
|
|
4488
|
-
past = past + 1 if state in ("idle", "busy") else 0 # the prompt, or a read it can't tell
|
|
4489
4574
|
seen = seen or state == "prompt"
|
|
4575
|
+
past = past + 1 if seen and state in ("idle", "busy") else 0 # the prompt, or a read it can't tell
|
|
4490
4576
|
if past >= ANSWERED_LOOKS:
|
|
4491
4577
|
ended = "prompt"
|
|
4492
4578
|
break
|
|
@@ -4494,7 +4580,6 @@ def _await_app_answer(db: DB, agent: Agent, holder, req, hold_until: float,
|
|
|
4494
4580
|
if supervise_until is not None: # back in time to hand it to the person
|
|
4495
4581
|
look = max(min(look, supervise_until - time.time()), HOLD_MIN_LOOK)
|
|
4496
4582
|
held, answer = holder.wait(look)
|
|
4497
|
-
waits += 1
|
|
4498
4583
|
if answer is not None:
|
|
4499
4584
|
# Else the person sent it to the prompt.
|
|
4500
4585
|
ended = answer if answer in ANSWERS or answer in AS_ANSWER else "terminal"
|
|
@@ -4529,8 +4614,9 @@ def _pane_state(agent: Agent) -> str | None:
|
|
|
4529
4614
|
def note_permission_outcome(db: DB, agent: Agent, payload: dict) -> None:
|
|
4530
4615
|
"""PostToolUse: if the tool's request had been left to the person, they
|
|
4531
4616
|
approved it. Count that toward a suggestion (never a rule by itself).
|
|
4532
|
-
The request is the oldest recorded one for the same tool and input
|
|
4533
|
-
(PermissionRequest has no tool_use_id to pair them by)
|
|
4617
|
+
The request is the oldest recorded one for the same tool and input on the
|
|
4618
|
+
same thread (PermissionRequest has no tool_use_id to pair them by), and never
|
|
4619
|
+
a subagent's its hook still holds: that tool can't have run yet."""
|
|
4534
4620
|
try:
|
|
4535
4621
|
if not db.permission_requests_of(agent.id):
|
|
4536
4622
|
return # nothing was left to the person: skip the permissions import
|
|
@@ -4541,8 +4627,11 @@ def note_permission_outcome(db: DB, agent: Agent, payload: dict) -> None:
|
|
|
4541
4627
|
if ran is None:
|
|
4542
4628
|
return
|
|
4543
4629
|
same = (ran.tool, ran.kind, ran.command, ran.path, ran.url)
|
|
4630
|
+
thread = _subagent_of(payload)
|
|
4544
4631
|
|
|
4545
4632
|
def matches(row) -> bool:
|
|
4633
|
+
if request_subagent(row) != thread or (thread and row["channel"] in ("hook", "supervisor")):
|
|
4634
|
+
return False
|
|
4546
4635
|
r = json.loads(row["request"])
|
|
4547
4636
|
return (r.get("tool"), r.get("kind"), r.get("command"), r.get("path"), r.get("url")) == same
|
|
4548
4637
|
|
|
@@ -4698,7 +4787,7 @@ def handle_hook(db: DB, agent_id: str, event: str, payload: dict) -> dict | None
|
|
|
4698
4787
|
return _codex_pre_tool_hook(db, agent_id, payload)
|
|
4699
4788
|
agent = db.get_agent(agent_id)
|
|
4700
4789
|
if agent is None:
|
|
4701
|
-
return None
|
|
4790
|
+
return _pre_tool_unchecked("brindle doesn't know this agent") if event == "pre-tool" and _unasked(payload) else None
|
|
4702
4791
|
if agent.hooks_off:
|
|
4703
4792
|
db.update_agent(agent_id, hooks_off=None) # its hooks run after all: turned back on
|
|
4704
4793
|
# A hook runs only once the session is going, so its launch is past any
|
|
@@ -4809,7 +4898,8 @@ def handle_hook(db: DB, agent_id: str, event: str, payload: dict) -> dict | None
|
|
|
4809
4898
|
|
|
4810
4899
|
# A request left to the person with no PostToolUse by the end of the
|
|
4811
4900
|
# turn wasn't approved (or we can't tell): drop it, learn nothing.
|
|
4812
|
-
|
|
4901
|
+
# Terminal approval commands must remain usable after this reply.
|
|
4902
|
+
db.clear_permission_requests(agent_id, keep_terminal=True)
|
|
4813
4903
|
# A worker's turn is over: its branch may now share changed files
|
|
4814
4904
|
# with another running branch, which the supervisor hears about now
|
|
4815
4905
|
# rather than at merge time.
|
|
@@ -5305,6 +5395,10 @@ def hook_main(db: DB, agent_id: str, event: str, stdin_text: str, trusted: bool
|
|
|
5305
5395
|
payload = json.loads(stdin_text) if stdin_text.strip() else {}
|
|
5306
5396
|
except json.JSONDecodeError:
|
|
5307
5397
|
payload = {}
|
|
5398
|
+
if event == "pre-tool" and not (isinstance(payload, dict) and payload.get("tool_name")):
|
|
5399
|
+
# Nothing says what the call or the mode is. Fail the hook: a launch with no
|
|
5400
|
+
# prompt to fall back on blocks a failed hook (ClaudeCode._hook), any other prompts.
|
|
5401
|
+
raise ValueError("brindle: unreadable PreToolUse input")
|
|
5308
5402
|
if event in PERMISSION_EVENTS:
|
|
5309
5403
|
# Never let a failure turn into an allow: anything wrong means no
|
|
5310
5404
|
# output, so the CLI prompts the person as usual; except Codex's
|
|
@@ -30,10 +30,11 @@ agy's hooks, mapped onto brindle's:
|
|
|
30
30
|
- ``PreToolUse`` (only with ``permission_policy: "on"``): brindle's permission
|
|
31
31
|
policy (brindle.permissions) answers deny, or what agy would do anyway (allow
|
|
32
32
|
for a file inside the workspace, else ask), never nothing. Under
|
|
33
|
-
agy_approvals "brindle" (unset, for
|
|
34
|
-
strict_on), or a profile with permission_mode dontAsk (agy
|
|
35
|
-
refuses rather than prompts), agy runs with
|
|
36
|
-
and this hook allows or denies every call,
|
|
33
|
+
agy_approvals "brindle" (unset, for workers and for an interactive agent on
|
|
34
|
+
Autonomous; see strict_on), or a profile with permission_mode dontAsk (agy
|
|
35
|
+
has no mode that refuses rather than prompts), agy runs with
|
|
36
|
+
--dangerously-skip-permissions and this hook allows or denies every call,
|
|
37
|
+
whatever permission_policy says.
|
|
37
38
|
agy has no hook for "waiting for approval": that is read from the screen.
|
|
38
39
|
Hooks can't approve anything in agy (a hook's "allow" is ignored), so with the
|
|
39
40
|
policy on brindle mirrors the allow rules agy's syntax can express into the
|
|
@@ -466,10 +467,14 @@ def pre_tool_decision(db, agent_id: str | None, payload: object, strict: bool =
|
|
|
466
467
|
brain = os.path.realpath(Path.home() / ".gemini" / "antigravity-cli" / "brain")
|
|
467
468
|
if isinstance(artifacts, str) and os.path.realpath(artifacts).startswith(brain + os.sep):
|
|
468
469
|
spaces.append(os.path.realpath(artifacts))
|
|
469
|
-
|
|
470
|
+
# A person's own agent on Autonomous works where it's told, as it does
|
|
471
|
+
# on Claude Code: a command is judged from its Cwd, and a deny or ask still holds.
|
|
472
|
+
anywhere = agent.mode == "interactive" and _autonomous(cfg)
|
|
473
|
+
ambiguous = permissions.agy_strict_ambiguity(payload, ws.path, anywhere=anywhere) if req is not None else None
|
|
470
474
|
if ambiguous and decision.decision != "deny":
|
|
475
|
+
where = "" if anywhere else " inside your worktree"
|
|
471
476
|
out = {"decision": "deny", "reason": f"brindle: {ambiguous}, so it can't be checked; "
|
|
472
|
-
"use one absolute path
|
|
477
|
+
f"use one absolute path{where}"}
|
|
473
478
|
else:
|
|
474
479
|
# agy keeps what it tells the model about brindle's MCP server
|
|
475
480
|
# (its instructions and tools) and its built-in skills here:
|
|
@@ -490,9 +495,13 @@ def pre_tool_decision(db, agent_id: str | None, payload: object, strict: bool =
|
|
|
490
495
|
allowed = answer in ("allow_once", "allow_always")
|
|
491
496
|
out = {"decision": "allow" if allowed else "deny",
|
|
492
497
|
"reason": f"brindle: the person {'allowed' if allowed else 'denied'} this in the brindle app"}
|
|
493
|
-
if (escalate and not answer and req is not None and out["decision"] == "deny"
|
|
498
|
+
if ((escalate or not agent.parent_id) and not answer and req is not None and out["decision"] == "deny"
|
|
494
499
|
and decision.decision != "deny"):
|
|
495
|
-
_escalate(db, agent, ws, req, rules, cfg.checks
|
|
500
|
+
command = _escalate(db, agent, ws, req, rules, cfg.checks,
|
|
501
|
+
once=decision.rule is not None and decision.rule.decision == "ask")
|
|
502
|
+
if command and not agent.parent_id:
|
|
503
|
+
out["reason"] += (" Show the person this exact command to run in their own terminal, "
|
|
504
|
+
"then make the same call again:\n" + command)
|
|
496
505
|
else:
|
|
497
506
|
out = output(decision, req, spaces)
|
|
498
507
|
if req is not None and out["decision"] == "deny":
|
|
@@ -502,31 +511,38 @@ def pre_tool_decision(db, agent_id: str | None, payload: object, strict: bool =
|
|
|
502
511
|
return out
|
|
503
512
|
|
|
504
513
|
|
|
505
|
-
def _escalate(db, agent, ws, req, rules, checks) -> None:
|
|
514
|
+
def _escalate(db, agent, ws, req, rules, checks, *, once: bool = False) -> str | None:
|
|
506
515
|
"""A worker's call no rule allows, under brindle's hook: what a Claude
|
|
507
516
|
worker would wait on the person for. agy has already been told no, so it
|
|
508
517
|
becomes the worker's pending request (agents.pending_permission) and its
|
|
509
518
|
supervisor is told once per request in a turn, with the commands that
|
|
510
519
|
allow it (for a command, each part no rule covers yet: bash_grants),
|
|
511
520
|
after which the worker's retry passes the hook; with no grants, that no
|
|
512
|
-
rule can and what to do instead.
|
|
521
|
+
rule can and what to do instead. Explicit asks get a one-time approval
|
|
522
|
+
command instead of an ineffective allow rule. With no supervisor, record
|
|
523
|
+
the request and return that command for the agent to show the person.
|
|
524
|
+
Never raises."""
|
|
513
525
|
from brindle import agents, permissions
|
|
514
526
|
|
|
515
527
|
request = json.dumps(req.to_dict(), sort_keys=True)
|
|
516
528
|
key = "agy:" + hashlib.sha256(request.encode()).hexdigest() # the whole request, not its summary
|
|
529
|
+
command = f"brindle permissions allow --once {shlex.quote(key)}" if once or not agent.parent_id else None
|
|
517
530
|
try:
|
|
518
531
|
if db.conn.execute("SELECT 1 FROM permission_requests WHERE agent_id=? AND tool_use_id=?",
|
|
519
532
|
(agent.id, key)).fetchone():
|
|
520
|
-
return
|
|
521
|
-
db.add_permission_request(agent.id, key, request, "no rule allows it"
|
|
533
|
+
return command
|
|
534
|
+
db.add_permission_request(agent.id, key, request, "approval required" if command else "no rule allows it",
|
|
535
|
+
channel="terminal" if command else None)
|
|
536
|
+
if not agent.parent_id:
|
|
537
|
+
return command
|
|
522
538
|
grants = (permissions.bash_grants(req, rules, checks, cd_root=ws.path) if req.kind == "bash"
|
|
523
539
|
else [req.target()])
|
|
524
540
|
# The call's text is the worker's: it goes only inside fenced blocks,
|
|
525
541
|
# after brindle's own words, and after -- so it's never an option.
|
|
526
542
|
intro = (f"Worker {agent.id} ({agent.profile}) was refused a call no rule allows: it runs "
|
|
527
543
|
"without approval prompts. Only the user can allow it")
|
|
528
|
-
if grants and req.kind in permissions.KINDS:
|
|
529
|
-
allow = "\n".join(f"brindle permissions allow {req.kind} -- {shlex.quote(g)}" for g in grants)
|
|
544
|
+
if command or grants and req.kind in permissions.KINDS:
|
|
545
|
+
allow = command or "\n".join(f"brindle permissions allow {req.kind} -- {shlex.quote(g)}" for g in grants)
|
|
530
546
|
how = (": if the worker needs it, ask them to run the commands below, then tell the "
|
|
531
547
|
f"worker to retry.\n\nTo allow it:\n{_fenced(allow)}")
|
|
532
548
|
else:
|
|
@@ -582,7 +598,7 @@ def _prompting_agent(db, agent_id: str) -> bool:
|
|
|
582
598
|
|
|
583
599
|
agent = db.get_agent(agent_id)
|
|
584
600
|
ws = db.get_workspace(agent.workspace_id) if agent else None
|
|
585
|
-
if ws is None or strict_on(ws.repo_root, agent.mode):
|
|
601
|
+
if ws is None or strict_on(ws.repo_root, agent.mode, preset=False):
|
|
586
602
|
return False
|
|
587
603
|
try:
|
|
588
604
|
return load_profile(agent.profile, ws.repo_root).permission_mode != "dontAsk"
|
|
@@ -834,12 +850,22 @@ def policy_on(workspace: str) -> list[str] | None:
|
|
|
834
850
|
return list(cfg.checks or []) if cfg.permission_policy == "on" else None
|
|
835
851
|
|
|
836
852
|
|
|
837
|
-
def
|
|
853
|
+
def _autonomous(cfg) -> bool:
|
|
854
|
+
from brindle import permissions
|
|
855
|
+
|
|
856
|
+
return permissions.autonomous(cfg)
|
|
857
|
+
|
|
858
|
+
|
|
859
|
+
def strict_on(workspace: str, mode: str | None = None, preset: bool = True) -> bool:
|
|
838
860
|
"""Whether an agy agent of ``mode`` in ``workspace`` runs with
|
|
839
861
|
--dangerously-skip-permissions and brindle's hook decides every call:
|
|
840
862
|
under agy_approvals "brindle", and, with it unset, for every agent but an
|
|
841
|
-
interactive one (nobody watches a worker's prompts
|
|
842
|
-
interactive
|
|
863
|
+
interactive one (nobody watches a worker's prompts), and for an
|
|
864
|
+
interactive one on Autonomous: agy would prompt for all it runs, reading
|
|
865
|
+
no hook's allow. Other interactive agents are the person's to answer, and
|
|
866
|
+
"prompt" leaves agy asking. ``preset=False``: the repo's setting alone, for
|
|
867
|
+
an agent already running, whose launch flag says the rest (the person may
|
|
868
|
+
have changed preset since)."""
|
|
843
869
|
from brindle.config import load_repo_config
|
|
844
870
|
|
|
845
871
|
try:
|
|
@@ -848,7 +874,7 @@ def strict_on(workspace: str, mode: str | None = None) -> bool:
|
|
|
848
874
|
return False
|
|
849
875
|
if cfg.agy_approvals in ("brindle", "prompt"):
|
|
850
876
|
return cfg.agy_approvals == "brindle"
|
|
851
|
-
return mode != "interactive"
|
|
877
|
+
return mode != "interactive" or (preset and _autonomous(cfg))
|
|
852
878
|
|
|
853
879
|
|
|
854
880
|
def sync_for_launch(workspace: str, checks: list[str] | None) -> None:
|
|
@@ -1742,7 +1742,7 @@ def push_setup_branch(cwd: str, files: Mapping[str, str]) -> None:
|
|
|
1742
1742
|
path.parent.mkdir(parents=True, exist_ok=True)
|
|
1743
1743
|
path.write_text(text, encoding="utf-8")
|
|
1744
1744
|
git.run(["add", rel], cwd)
|
|
1745
|
-
git.run(["commit", "-q", "-m", "Add brindle CI workflows"], cwd)
|
|
1745
|
+
git.run([*git.identity_args(cwd), "commit", "-q", "-m", "Add brindle CI workflows"], cwd)
|
|
1746
1746
|
committed = True
|
|
1747
1747
|
git.run(["push", "-u", "origin", SETUP_BRANCH], cwd)
|
|
1748
1748
|
finally:
|