brindle 0.6.3__tar.gz → 0.6.4__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.3 → brindle-0.6.4}/PKG-INFO +1 -1
- {brindle-0.6.3 → brindle-0.6.4}/pyproject.toml +1 -1
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/agents.py +204 -32
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/autopilot.py +135 -28
- brindle-0.6.4/src/brindle/baseline.py +177 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/ci_client.py +6 -1
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/cli.py +7 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/codemap.py +32 -2
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/config.py +56 -28
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/cull.py +96 -27
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/daemon/api-schema.json +139 -5
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/daemon/app.py +2 -1
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/daemon/auth.py +23 -8
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/daemon/events.py +1 -1
- brindle-0.6.4/src/brindle/daemon/launch_env.py +69 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/daemon/lifecycle.py +102 -16
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/daemon/pty_view.py +1 -1
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/daemon/routes_actions.py +314 -37
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/daemon/routes_read.py +27 -8
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/daemon/session_review.py +436 -24
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/db.py +85 -13
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/disk.py +10 -5
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/entry.py +10 -1
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/gates.py +2 -1
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/git.py +293 -21
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/github_connect.py +5 -1
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/learned_rules.py +11 -4
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/login_pause.py +2 -1
- brindle-0.6.4/src/brindle/login_shell_env.py +296 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/mcp_server.py +61 -20
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/mcp_stdio.py +140 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/permission_grants.py +9 -4
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/permission_groups.py +2 -1
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/permissions.py +124 -46
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/pipeline.py +43 -19
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/plans.py +7 -2
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/pool.py +22 -4
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/pro/account.py +4 -3
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/pro/analysis_brief.py +7 -6
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/pro/auth.py +99 -11
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/procs.py +183 -3
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/provider_homes.py +98 -2
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/providers.py +202 -48
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/quota.py +73 -17
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/reap.py +2 -1
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/secrets.py +14 -1
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/service/dto.py +12 -3
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/service/inbox.py +89 -9
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/service/permissions.py +27 -16
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/service/sessions.py +159 -33
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/session_sync.py +357 -34
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/sessions.py +1 -1
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/sidebar_logo.py +5 -3
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/spawn.py +11 -0
- brindle-0.6.4/src/brindle/status_cache.py +794 -0
- brindle-0.6.4/src/brindle/subscription_usage.py +36 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/tasks.py +530 -68
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/tmux.py +86 -14
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/trash.py +25 -1
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/view.py +42 -21
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/visual_export.py +79 -25
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/visual_offers.py +46 -76
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/visuals.py +41 -25
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/watch.py +96 -12
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/workspaces.py +89 -26
- brindle-0.6.3/src/brindle/status_cache.py +0 -261
- {brindle-0.6.3 → brindle-0.6.4}/.gitignore +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/LICENSE +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/README.md +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/SCHEDULE-A +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/__init__.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/__main__.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/account.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/airgap.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/antigravity.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/assembler.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/assets/braid_dark.png +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/assets/braid_light.png +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/attachments.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/budget.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/build_caches.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/builtin_agents/__init__.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/builtin_agents/backend-auditor.md +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/builtin_agents/coordinator.md +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/builtin_agents/developer-codex.md +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/builtin_agents/developer-fable.md +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/builtin_agents/developer-gemini.md +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/builtin_agents/developer-heavy.md +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/builtin_agents/developer-light.md +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/builtin_agents/developer-local.md +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/builtin_agents/developer-opencode.md +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/builtin_agents/developer-sonnet.md +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/builtin_agents/developer.md +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/builtin_agents/qa.md +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/builtin_agents/reviewer-codex.md +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/builtin_agents/reviewer-gemini.md +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/builtin_agents/reviewer-local.md +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/builtin_agents/reviewer-opencode.md +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/builtin_agents/reviewer.md +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/builtin_agents/subagent.md +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/builtin_agents/supervisor.md +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/builtin_rules/__init__.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/builtin_rules/security/backend.md +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/builtin_rules/style/minimal-diff.md +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/builtin_rules/tests/only.md +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/bus.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/check_scope.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/ci_adapters.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/ci_federation.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/ci_hosts.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/clone.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/cloud_credential.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/cloud_login.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/codemap_docs.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/codex_hook.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/company_identity.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/company_login.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/conflicts.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/connections.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/coordinator.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/cost.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/cost_estimate.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/daemon/__init__.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/daemon/health.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/daemon/holds.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/daemon/peer.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/daemon/process_probe.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/daemon/routes_org_permissions.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/daemon/routes_visuals.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/daemon/schema.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/daemon/terminal.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/debuglog.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/demo.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/detect.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/doctor.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/escapes.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/events.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/fair_share.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/guardrails.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/history.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/identity_lock.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/inbox.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/kb.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/key_check.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/keys_cmds.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/keystore.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/knowledge.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/launch_health.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/learning.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/legacy.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/local_setup.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/mac_keychain.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/model_access.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/model_availability.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/native/__init__.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/native/catalog.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/native/client.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/native/loop.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/native/lsp.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/native/permissions.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/native/runner.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/native/serve.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/native/tools.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/new_tests.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/open_items.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/opencode.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/org_permissions.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/pane_auth.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/permission_asks.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/permission_routing.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/picker.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/plugins.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/policy.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/preflight.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/pricing.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/pro/__init__.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/pro/_files.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/pro/analysis_docs.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/pro/analysis_imports.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/pro/analysis_policy.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/pro/audit_chain.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/pro/audit_export.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/pro/brief_learning.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/pro/cost_centers.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/pro/credentials.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/pro/features.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/pro/keys.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/pro/learning.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/pro/license.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/pro/loopback.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/pro/managed_models.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/pro/org_profiles.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/pro/orgkey.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/pro/rollout.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/pro/route_health.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/pro/settings_sync.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/pro/status.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/pro/team_events.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/pro/team_policy.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/profiles.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/prompt_answer.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/providers_install.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/redact.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/repo_cmds.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/repos.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/rewind.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/rule_checks.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/savings.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/scratch.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/self_serve.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/service/__init__.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/service/errors.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/service/routing.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/services.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/sidebar_follow.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/signin_pause.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/updates.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/upgrade.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/usage.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/wake.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/watch_costs.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/web/__init__.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/web/chat.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/web/dashboard.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/web/diff.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/web/server.py +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/web/static/app.js +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/web/static/index.html +0 -0
- {brindle-0.6.3 → brindle-0.6.4}/src/brindle/worker_models.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.4
|
|
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
|
|
@@ -23,6 +23,7 @@ import uuid
|
|
|
23
23
|
from contextlib import ExitStack, contextmanager
|
|
24
24
|
from contextvars import ContextVar
|
|
25
25
|
from dataclasses import dataclass, field
|
|
26
|
+
from datetime import datetime
|
|
26
27
|
from types import SimpleNamespace
|
|
27
28
|
|
|
28
29
|
from brindle import bus, cloud_credential, company_identity, company_login, debuglog, git, keystore, knowledge, pane_auth, providers, secrets, tmux, upgrade, workspaces
|
|
@@ -225,7 +226,10 @@ _KEYCHAIN_HELPER_PLATFORM = sys.platform == "darwin" # where git's default c
|
|
|
225
226
|
|
|
226
227
|
|
|
227
228
|
def agent_env(ws: Workspace, agent_id: str, agent: Agent | None = None,
|
|
228
|
-
m=_UNREAD) -> dict[str, str]:
|
|
229
|
+
m=_UNREAD, *, identity: bool = True) -> dict[str, str]:
|
|
230
|
+
"""``identity``: fill a missing git identity (``git.identity_env``, a git
|
|
231
|
+
run); off for a reader that only looks at the login and route (the cull's
|
|
232
|
+
login_pause, once a minute per running agent), never for a launch."""
|
|
229
233
|
env = {**workspaces.workspace_env(ws), "BRINDLE_AGENT_ID": agent_id}
|
|
230
234
|
if agent is not None:
|
|
231
235
|
# The profile's ``env.NAME: value`` lines: how a Claude Code profile
|
|
@@ -332,7 +336,7 @@ def agent_env(ws: Workspace, agent_id: str, agent: Agent | None = None,
|
|
|
332
336
|
# whose dialog nobody in a pane can answer (see git.pane_git_config).
|
|
333
337
|
if config := git.pane_git_config(gh=_KEYCHAIN_HELPER_PLATFORM):
|
|
334
338
|
env.setdefault("GIT_CONFIG_PARAMETERS", config)
|
|
335
|
-
if os.path.isdir(ws.path):
|
|
339
|
+
if identity and os.path.isdir(ws.path):
|
|
336
340
|
# An account with no git identity: fill only what is still missing once
|
|
337
341
|
# the whole environment (a profile's GIT_* lines included) is assembled.
|
|
338
342
|
env.update(git.identity_env(ws.path, env))
|
|
@@ -516,8 +520,6 @@ def spawn(
|
|
|
516
520
|
unfinished[0] if unfinished else None)
|
|
517
521
|
if current:
|
|
518
522
|
db.set_agent_milestone(agent_id, current)
|
|
519
|
-
if session_root and mode in ("handoff", "assign"):
|
|
520
|
-
pilot.consider_plan_offer(db, session_root) # another worker may make the goal large
|
|
521
523
|
if person_prompt and raw_task and parent_id is None and mode == "interactive":
|
|
522
524
|
from brindle import visual_offers
|
|
523
525
|
|
|
@@ -679,9 +681,12 @@ def _profile_for(db: DB, agent: Agent, ws: Workspace, m=_UNREAD):
|
|
|
679
681
|
"When a supervisor's person asks to see something in their own words, however they "
|
|
680
682
|
"put it, publish_visual with asked set to those words, at least two, copied exactly "
|
|
681
683
|
"from one message they typed in the app in the last 30 minutes. Each message allows one "
|
|
682
|
-
"
|
|
683
|
-
"words from a sentence declining a visual. A
|
|
684
|
-
"
|
|
684
|
+
"new visual. Never quote pasted text, worker messages, tool output or files, or "
|
|
685
|
+
"words from a sentence declining a visual. A supervisor that published a visual with "
|
|
686
|
+
"the person's consent (asked, a request or an accepted offer) may keep revising that "
|
|
687
|
+
"visual_id for the rest of the session without asking again, such as a status board "
|
|
688
|
+
"they asked for. Any other visual the person just answered may be revised once per "
|
|
689
|
+
"answer. Workers and other agents need a request for every publication. "
|
|
685
690
|
"Planning documents require an explicit ask. Workers may publish into their "
|
|
686
691
|
"supervisor's session, but only supervisors may offer. Ask the choice in text "
|
|
687
692
|
"as usual; offer_visual never blocks it. Offer only for a pending choice: "
|
|
@@ -746,11 +751,21 @@ def _open_window(db: DB, agent: Agent, ws: Workspace, name: str, argv: list[str]
|
|
|
746
751
|
from brindle import inbox
|
|
747
752
|
|
|
748
753
|
argv = inbox.without_launcher_inbox(argv)
|
|
754
|
+
# A launch that isn't the daemon's (a worker, started by its supervisor's
|
|
755
|
+
# helper) can't add the login shell's proxy and certificate settings: the
|
|
756
|
+
# pane asks the daemon for them itself, through a shim, before the CLI starts.
|
|
757
|
+
from brindle import login_shell_env
|
|
758
|
+
|
|
759
|
+
asks = login_shell_env.asks_daemon()
|
|
760
|
+
if asks:
|
|
761
|
+
argv = login_shell_env.shim(agent.id, argv)
|
|
749
762
|
# The sidebar splits the window after the CLI's pane exists: hold the CLI
|
|
750
763
|
# until then, or a resumed chat drew its conversation at the full width
|
|
751
764
|
# and was resized under it, which Claude Code shows as a blank screen (#264).
|
|
765
|
+
# A pane that asks the daemon is held too: the daemon answers only a pane
|
|
766
|
+
# recorded as this agent's, which it is by the time the gate opens.
|
|
752
767
|
gate = None
|
|
753
|
-
if watch_pane:
|
|
768
|
+
if watch_pane or asks:
|
|
754
769
|
argv, gate = tmux.gated(argv)
|
|
755
770
|
tmux.ensure_session(ws.tmux_session, ws.path, workspaces.workspace_env(ws))
|
|
756
771
|
try:
|
|
@@ -862,7 +877,19 @@ def _window_environment(agent: Agent, ws: Workspace, m=_UNREAD):
|
|
|
862
877
|
# Claude Code's managed settings supply the credential: no stored Claude key.
|
|
863
878
|
no_stored = set(deny) | (set(providers._ENV_AUTH["claude"]) if org_managed else set())
|
|
864
879
|
env = {**keystore.pane_keys(credentials - no_stored, {**env, **org_env}), **env, **org_env}
|
|
865
|
-
|
|
880
|
+
# The proxy and certificate settings the daemon read from the person's login
|
|
881
|
+
# shell (it starts without them), only where the pane wouldn't have one anyway.
|
|
882
|
+
# Claude Code's client key is kept past the scrub; `deny` still takes it out.
|
|
883
|
+
from brindle import login_shell_env
|
|
884
|
+
|
|
885
|
+
if network := login_shell_env.for_launch(agent.provider, env):
|
|
886
|
+
inherited = tmux.inherited_env(ws.tmux_session)
|
|
887
|
+
env = {**{k: v for k, v in network.items() if not inherited.get(k)}, **env}
|
|
888
|
+
credentials = credentials | login_shell_env.kept(agent.provider)
|
|
889
|
+
# The pane keeps its provider's credentials and, for Claude Code, its TLS
|
|
890
|
+
# client settings, inherited from the tmux server as much as read from the
|
|
891
|
+
# login shell: only the credentials are stored keys (pane_keys above).
|
|
892
|
+
result = env, secrets.pane_keep(agent.provider, credentials), allow, deny, org_env
|
|
866
893
|
# Resolve stored/org keys once for this launch: catalog, health identity
|
|
867
894
|
# and pane must use the same key helper result, without repeated delays.
|
|
868
895
|
agent._pane_environment = m, result
|
|
@@ -881,6 +908,22 @@ def _effective_window_env(agent: Agent, ws: Workspace, m=_UNREAD) -> dict[str, s
|
|
|
881
908
|
return {k: v for k, v in {**inherited, **env}.items() if k not in unset}
|
|
882
909
|
|
|
883
910
|
|
|
911
|
+
def login_shell_additions(agent: Agent, ws: Workspace) -> dict[str, str]:
|
|
912
|
+
"""The login shell's proxy and certificate settings that a launch of
|
|
913
|
+
``agent`` by this process (the daemon, which read them) would leave in its
|
|
914
|
+
pane: the ones for its provider that its real launch environment ends up
|
|
915
|
+
with, so never one the pane has anyway (set by the launch, or handed down
|
|
916
|
+
by tmux) or one its environment rules take out. What the daemon gives a
|
|
917
|
+
pane it didn't launch itself (brindle.daemon.launch_env)."""
|
|
918
|
+
from brindle import login_shell_env
|
|
919
|
+
|
|
920
|
+
found = login_shell_env.for_launch(agent.provider)
|
|
921
|
+
if not found:
|
|
922
|
+
return {} # nothing read (the usual case): no need to work the pane's environment out
|
|
923
|
+
effective = _effective_window_env(agent, ws)
|
|
924
|
+
return {n: v for n, v in found.items() if effective.get(n) == v}
|
|
925
|
+
|
|
926
|
+
|
|
884
927
|
def model_problem(profile_name: str, ws: Workspace, *, agent: Agent | None = None,
|
|
885
928
|
profile=None, m=_UNREAD) -> str | None:
|
|
886
929
|
"""Read-only provisioning/routing gate, using the worker's actual identity."""
|
|
@@ -1638,6 +1681,17 @@ def pause(db: DB, root_id: str, *, stop_procs: bool = True,
|
|
|
1638
1681
|
owners = pane_owners(db) # first: a tmux server that doesn't answer stops the pause before anything changes
|
|
1639
1682
|
closing = _record_pause(db, root_id)
|
|
1640
1683
|
windows = closing.windows(db, owners)
|
|
1684
|
+
# Before the windows close: closing one ends the CLI in it, and what that
|
|
1685
|
+
# CLI started in a session of its own (a Bash tool's shell, a background
|
|
1686
|
+
# job) is left with launchd as its parent, out of reach of the agent's
|
|
1687
|
+
# process tree. Stopped while the tree is whole, all of it goes.
|
|
1688
|
+
# Skipped for this process and its ancestors: this can run in the chat's pane.
|
|
1689
|
+
if stop_procs:
|
|
1690
|
+
from brindle import procs
|
|
1691
|
+
|
|
1692
|
+
procs.stop([a.id for a in tree(db, root_id)], grace=2.0)
|
|
1693
|
+
else: # left to a cull: it ends what the close orphans from this note
|
|
1694
|
+
_hand_off_panes(windows)
|
|
1641
1695
|
# The sidebar follows the person around, so it may not be sitting in any
|
|
1642
1696
|
# of the windows about to close: find it wherever it is and stop it too,
|
|
1643
1697
|
# rather than leaving it running with nothing left to show it. Status was
|
|
@@ -1658,12 +1712,6 @@ def pause(db: DB, root_id: str, *, stop_procs: bool = True,
|
|
|
1658
1712
|
assert sidebar is not None
|
|
1659
1713
|
tmux.kill_pane(sidebar)
|
|
1660
1714
|
db.clear_sidebar_pane(root_id)
|
|
1661
|
-
# Closing the windows doesn't stop sessions Claude Code's daemon hosts.
|
|
1662
|
-
# Skipped for this process and its ancestors: this can run in the chat's pane.
|
|
1663
|
-
if stop_procs:
|
|
1664
|
-
from brindle import procs
|
|
1665
|
-
|
|
1666
|
-
procs.stop([a.id for a in tree(db, root_id)], grace=2.0)
|
|
1667
1715
|
others = _sessions_in_use(closing)
|
|
1668
1716
|
for session in closing.sessions - others:
|
|
1669
1717
|
if closing.closes(session, tmux.windows(session)):
|
|
@@ -1777,6 +1825,9 @@ def close_paused(db: DB, closings: list[Closing]) -> None:
|
|
|
1777
1825
|
# Ours, as _valid_sidebar tells (dead or alive), from the same look.
|
|
1778
1826
|
if pane in where and (panes.tags.get(pane) or {}).get(SIDEBAR_TAG) == c.root_id:
|
|
1779
1827
|
sidebars.append((c.root_id, pane))
|
|
1828
|
+
# Their processes are left to a cull (the detached one after this): it ends
|
|
1829
|
+
# what the closes orphan from this note.
|
|
1830
|
+
_hand_off_panes([w for c in closings for w in c.windows(db, owners)])
|
|
1780
1831
|
# What a session or window closing takes along isn't closed again (tmux would refuse it).
|
|
1781
1832
|
tmux.close(panes=[p for _, p in sidebars if where[p].window not in windows
|
|
1782
1833
|
and where[p].session not in sessions],
|
|
@@ -1887,6 +1938,21 @@ def _gate_check() -> None:
|
|
|
1887
1938
|
pass
|
|
1888
1939
|
|
|
1889
1940
|
|
|
1941
|
+
def _hand_off_panes(panes: list[str]) -> None:
|
|
1942
|
+
"""Note what runs under ``panes``, about to close with their processes
|
|
1943
|
+
left for a cull, so the cull can end what the close leaves without a
|
|
1944
|
+
parent (see procs.hand_off). Never stands in the way of the close."""
|
|
1945
|
+
if not panes:
|
|
1946
|
+
return
|
|
1947
|
+
from brindle import procs
|
|
1948
|
+
|
|
1949
|
+
try:
|
|
1950
|
+
pids = tmux.pane_pids()
|
|
1951
|
+
procs.hand_off([pids[p] for p in panes if p in pids])
|
|
1952
|
+
except (tmux.TmuxError, OSError, subprocess.SubprocessError, processes.Busy):
|
|
1953
|
+
log.warning("brindle: couldn't note what runs in panes %s before closing them", panes, exc_info=True)
|
|
1954
|
+
|
|
1955
|
+
|
|
1890
1956
|
def settle_panes(db: DB, agents: list[Agent], *, keep: bool = True) -> set[str]:
|
|
1891
1957
|
"""Make tmux's panes of ``agents`` what should be: for each, its one
|
|
1892
1958
|
launched pane if there is one (``keep``; not a failed agent's), and no
|
|
@@ -1905,6 +1971,7 @@ def settle_panes(db: DB, agents: list[Agent], *, keep: bool = True) -> set[str]:
|
|
|
1905
1971
|
kept[p.agent] = p.pane
|
|
1906
1972
|
else:
|
|
1907
1973
|
stale.append(p.pane)
|
|
1974
|
+
_hand_off_panes(stale)
|
|
1908
1975
|
for pane in stale:
|
|
1909
1976
|
tmux.kill_window(pane)
|
|
1910
1977
|
if stale and (left := {p.pane for p in tmux.agent_panes()} & set(stale)):
|
|
@@ -2093,15 +2160,18 @@ def _resume(db: DB, root_id: str, *, watch_pane: bool, only, recovery_env, settl
|
|
|
2093
2160
|
continue
|
|
2094
2161
|
db.set_status(a.id, "paused")
|
|
2095
2162
|
if a.status != "paused":
|
|
2163
|
+
from brindle import procs
|
|
2164
|
+
try:
|
|
2165
|
+
procs.stop([a.id], grace=2.0) # before its window closes (see pause)
|
|
2166
|
+
stopped = True
|
|
2167
|
+
except Exception:
|
|
2168
|
+
stopped = False
|
|
2096
2169
|
if a.tmux_window and same_server(a) and owns_pane(db, a):
|
|
2097
2170
|
try:
|
|
2098
2171
|
tmux.kill_window(a.tmux_window)
|
|
2099
2172
|
except Exception:
|
|
2100
2173
|
pass
|
|
2101
|
-
|
|
2102
|
-
try:
|
|
2103
|
-
procs.stop([a.id], grace=2.0)
|
|
2104
|
-
except Exception:
|
|
2174
|
+
if not stopped:
|
|
2105
2175
|
continue
|
|
2106
2176
|
ws = db.get_workspace(a.workspace_id)
|
|
2107
2177
|
if ws is None or not os.path.isdir(ws.path):
|
|
@@ -3450,6 +3520,7 @@ def _handle_report(db: DB, agent: Agent, ws: Workspace | None, result: str, firs
|
|
|
3450
3520
|
forwarded = f"{result}\n\n{usage_mod.summary_line(u, dollars, free)}"
|
|
3451
3521
|
else:
|
|
3452
3522
|
forwarded = result
|
|
3523
|
+
no_commits = False
|
|
3453
3524
|
if ws and agent.mode in ("handoff", "handoff_detached", "assign"):
|
|
3454
3525
|
if first:
|
|
3455
3526
|
pipeline.note_reported(db, ws, agent)
|
|
@@ -3457,12 +3528,23 @@ def _handle_report(db: DB, agent: Agent, ws: Workspace | None, result: str, firs
|
|
|
3457
3528
|
if forward and pipeline.on_report(db, agent, ws, forwarded, outbox_id=outbox_id):
|
|
3458
3529
|
return ("result recorded. brindle is having your branch reviewed; it will merge it, "
|
|
3459
3530
|
"or send you the review's findings to fix.")
|
|
3531
|
+
if forward:
|
|
3532
|
+
try:
|
|
3533
|
+
no_commits = not git.ahead_behind(ws.path, workspaces.require_base(ws))[1]
|
|
3534
|
+
except (git.GitError, workspaces.WorkspaceError):
|
|
3535
|
+
pass # an unknown branch state must not be described as empty
|
|
3460
3536
|
if forward and agent.mode in FORWARDING_MODES and agent.parent_id:
|
|
3461
3537
|
parent = db.get_agent(agent.parent_id)
|
|
3462
3538
|
if parent is None:
|
|
3463
3539
|
return "result recorded" # no supervisor to tell: the report stays accepted, undelivered
|
|
3464
3540
|
where = f" on branch `{ws.branch}` (workspace {ws.id})" if ws else ""
|
|
3465
|
-
|
|
3541
|
+
if no_commits:
|
|
3542
|
+
head = (f"{agent.id} reported{where}: the branch has no commits to review or merge. "
|
|
3543
|
+
f'Close the worker with remove_workspace(id="{ws.id}"), '
|
|
3544
|
+
f"or keep it for follow-up work. Report: {first_line(result)}")
|
|
3545
|
+
else:
|
|
3546
|
+
head = f"Assigned task finished{where}: {first_line(result)}"
|
|
3547
|
+
body = condense(head, forwarded)
|
|
3466
3548
|
if outbox_id is None:
|
|
3467
3549
|
send_message(db, agent.parent_id, body, sender_id=agent.id)
|
|
3468
3550
|
elif db.outbox_deliver(outbox_id, message=_report_message(db, parent, body, agent.id)):
|
|
@@ -3718,8 +3800,8 @@ def close_later(agent_id: str, delay: float = 5.0) -> None:
|
|
|
3718
3800
|
|
|
3719
3801
|
|
|
3720
3802
|
def _stop(db: DB, agent: Agent) -> None:
|
|
3721
|
-
"""Stop an agent:
|
|
3722
|
-
|
|
3803
|
+
"""Stop an agent: every process of its (Claude Code's daemon can host the
|
|
3804
|
+
real session; see brindle.procs), then its window.
|
|
3723
3805
|
A pane id a newer agent has since been given is left alone (see owns_pane)."""
|
|
3724
3806
|
from brindle import procs, spawn
|
|
3725
3807
|
|
|
@@ -3736,9 +3818,10 @@ def _stop(db: DB, agent: Agent) -> None:
|
|
|
3736
3818
|
# sidebar's would otherwise be stopped with the agent's.
|
|
3737
3819
|
rescue_sidebar_from_window(db, agent)
|
|
3738
3820
|
pane_pids = tmux.window_pids(window) if window else []
|
|
3821
|
+
# Before the window closes, while the agent's process tree is whole (see pause).
|
|
3822
|
+
procs.stop([agent.id], {agent.id: pane_pids})
|
|
3739
3823
|
if window:
|
|
3740
3824
|
tmux.kill_window(window)
|
|
3741
|
-
procs.stop([agent.id], {agent.id: pane_pids})
|
|
3742
3825
|
db.end_native_subagents(agent.id)
|
|
3743
3826
|
|
|
3744
3827
|
|
|
@@ -3846,6 +3929,23 @@ def launches_process(profile: str, repo_root: str) -> bool:
|
|
|
3846
3929
|
return provider is None or provider.launches_process
|
|
3847
3930
|
|
|
3848
3931
|
|
|
3932
|
+
def delegation_base(db: DB, caller: Agent | None, caller_ws: Workspace) -> str:
|
|
3933
|
+
"""The branch a new isolated worker branches from and merges into.
|
|
3934
|
+
|
|
3935
|
+
A supervisor's merge_into setting applies unless this is its attached
|
|
3936
|
+
session branch. A worker's sub-workers always use that worker's branch.
|
|
3937
|
+
Keep inspection and actual delegation on the same policy.
|
|
3938
|
+
"""
|
|
3939
|
+
from brindle import autopilot as pilot, repos
|
|
3940
|
+
from brindle.config import load_repo_config
|
|
3941
|
+
|
|
3942
|
+
merge_into = load_repo_config(caller_ws.repo_root).merge_into
|
|
3943
|
+
root = pilot.root_of(db, caller.id) if caller else None
|
|
3944
|
+
if root and caller_ws.branch and repos.session_branch(db, root, caller_ws.repo_root) == caller_ws.branch:
|
|
3945
|
+
merge_into = None
|
|
3946
|
+
return merge_into if merge_into and not (caller and caller.parent_id) else caller_ws.branch
|
|
3947
|
+
|
|
3948
|
+
|
|
3849
3949
|
def delegate(
|
|
3850
3950
|
db: DB,
|
|
3851
3951
|
caller: Agent | None,
|
|
@@ -3938,15 +4038,7 @@ def delegate(
|
|
|
3938
4038
|
with held: # until the worker's row says whose worktree this is
|
|
3939
4039
|
_check_branch_owner(db, caller, caller_ws.repo_root, branch)
|
|
3940
4040
|
caller_ws = workspaces.refresh_branch(db, caller_ws)
|
|
3941
|
-
|
|
3942
|
-
# sub-workers still branch from (and merge back into) its branch,
|
|
3943
|
-
# and a session's workers in a repo it attached use the session's
|
|
3944
|
-
# own branch there (repos.attach), whatever that repo's merge_into.
|
|
3945
|
-
merge_into = load_repo_config(caller_ws.repo_root).merge_into
|
|
3946
|
-
root = pilot.root_of(db, caller.id) if caller else None
|
|
3947
|
-
if root and caller_ws.branch and repos.session_branch(db, root, caller_ws.repo_root) == caller_ws.branch:
|
|
3948
|
-
merge_into = None
|
|
3949
|
-
base = merge_into if merge_into and not (caller and caller.parent_id) else caller_ws.branch
|
|
4041
|
+
base = delegation_base(db, caller, caller_ws)
|
|
3950
4042
|
start = start or (base if git.branch_exists(caller_ws.repo_root, base) else "HEAD")
|
|
3951
4043
|
created = workspaces.create(
|
|
3952
4044
|
db, caller_ws.path, branch, base, fetch=False, start=start,
|
|
@@ -5700,6 +5792,84 @@ def _codex_pre_tool_hook(db: DB, agent_id: str, payload: dict) -> dict:
|
|
|
5700
5792
|
return answer
|
|
5701
5793
|
|
|
5702
5794
|
|
|
5795
|
+
ABSORBED_MARK = "absorbed-prompts" # {"path": transcript, "offset": bytes of it already read}
|
|
5796
|
+
_ABSORBED_READ_MAX = 32 << 20 # more unread transcript than this at once is skipped, not read
|
|
5797
|
+
|
|
5798
|
+
|
|
5799
|
+
def _absorbed_prompts(db: DB, agent: Agent, path: str) -> list[tuple[str, float | None]]:
|
|
5800
|
+
"""What the person sent while a turn ran that Claude Code took into that turn
|
|
5801
|
+
("absorbed mid-turn"): no prompt hook runs for those, and its transcript records
|
|
5802
|
+
each as a ``queued_command`` attachment from a human. Each is returned once,
|
|
5803
|
+
to whichever hook claims the new lines first; lines written before brindle
|
|
5804
|
+
first saw this transcript aren't read at all."""
|
|
5805
|
+
try:
|
|
5806
|
+
size = os.path.getsize(path)
|
|
5807
|
+
except OSError:
|
|
5808
|
+
return []
|
|
5809
|
+
saved = db.mark(agent.id, ABSORBED_MARK)
|
|
5810
|
+
try:
|
|
5811
|
+
state = json.loads(saved) if saved else None
|
|
5812
|
+
offset = int(state["offset"]) if isinstance(state, dict) and state.get("path") == path else None
|
|
5813
|
+
except (ValueError, TypeError, KeyError):
|
|
5814
|
+
offset = None
|
|
5815
|
+
if offset is None or offset > size or size - offset > _ABSORBED_READ_MAX:
|
|
5816
|
+
fresh = json.dumps({"path": path, "offset": size})
|
|
5817
|
+
db.add_mark(agent.id, ABSORBED_MARK, fresh) if saved is None else db.replace_mark(agent.id, ABSORBED_MARK, saved, fresh)
|
|
5818
|
+
return []
|
|
5819
|
+
try:
|
|
5820
|
+
with open(path, "rb") as f:
|
|
5821
|
+
f.seek(offset)
|
|
5822
|
+
chunk = f.read(size - offset)
|
|
5823
|
+
except OSError:
|
|
5824
|
+
return []
|
|
5825
|
+
end = chunk.rfind(b"\n") + 1 # a line still being written waits for the next hook
|
|
5826
|
+
if not end or not db.replace_mark(agent.id, ABSORBED_MARK, saved,
|
|
5827
|
+
json.dumps({"path": path, "offset": offset + end})):
|
|
5828
|
+
return [] # nothing whole yet, or another hook took these lines
|
|
5829
|
+
prompts = []
|
|
5830
|
+
for line in chunk[:end].splitlines():
|
|
5831
|
+
if b'"queued_command"' not in line:
|
|
5832
|
+
continue
|
|
5833
|
+
try:
|
|
5834
|
+
entry = json.loads(line)
|
|
5835
|
+
except ValueError:
|
|
5836
|
+
continue
|
|
5837
|
+
attachment = entry.get("attachment") if isinstance(entry, dict) else None
|
|
5838
|
+
if (entry.get("type") == "attachment" and not entry.get("isSidechain") and isinstance(attachment, dict)
|
|
5839
|
+
and attachment.get("type") == "queued_command" and attachment.get("commandMode") == "prompt"
|
|
5840
|
+
and isinstance(attachment.get("origin"), dict) and attachment["origin"].get("kind") == "human"
|
|
5841
|
+
and isinstance(attachment.get("prompt"), str)):
|
|
5842
|
+
prompts.append((attachment["prompt"], _transcript_time(attachment.get("timestamp") or entry.get("timestamp"))))
|
|
5843
|
+
return prompts
|
|
5844
|
+
|
|
5845
|
+
|
|
5846
|
+
def _transcript_time(stamp) -> float | None:
|
|
5847
|
+
"""A transcript's ISO timestamp ("2026-11-10T18:21:36.251Z") as epoch seconds, or None."""
|
|
5848
|
+
try:
|
|
5849
|
+
return datetime.fromisoformat(stamp).timestamp() if isinstance(stamp, str) else None
|
|
5850
|
+
except ValueError:
|
|
5851
|
+
return None
|
|
5852
|
+
|
|
5853
|
+
|
|
5854
|
+
def _note_absorbed_prompts(db: DB, agent: Agent, path: str) -> None:
|
|
5855
|
+
"""The person spoke mid-turn: treat each absorbed message as its prompt hook
|
|
5856
|
+
would have been treated (see "prompt-submit" in handle_hook), so words the app
|
|
5857
|
+
staged for it become quotable in the same transaction that raises its grant."""
|
|
5858
|
+
try:
|
|
5859
|
+
prompts = _absorbed_prompts(db, agent, path)
|
|
5860
|
+
if not prompts:
|
|
5861
|
+
return
|
|
5862
|
+
from brindle import visual_offers
|
|
5863
|
+
|
|
5864
|
+
# In the order they were sent, each with its own time: a cancel read back
|
|
5865
|
+
# here ends only what the person typed before it, not a newer staged ask.
|
|
5866
|
+
for prompt, said_at in prompts:
|
|
5867
|
+
if "[brindle" not in prompt and not db.recently_delivered(agent.id, prompt):
|
|
5868
|
+
visual_offers.person_spoke(db, agent, prompt, cli_prompt=True, said_at=said_at)
|
|
5869
|
+
except Exception: # noqa: BLE001 - a hook must never fail over this
|
|
5870
|
+
log.exception("brindle: couldn't read the messages absorbed into %s's turn", agent.id)
|
|
5871
|
+
|
|
5872
|
+
|
|
5703
5873
|
def handle_hook(db: DB, agent_id: str, event: str, payload: dict) -> dict | None:
|
|
5704
5874
|
"""Called from ``brindle _hook <event>`` inside the agent's own process tree.
|
|
5705
5875
|
Returns JSON for Claude Code to read on stdout, or None."""
|
|
@@ -5739,6 +5909,8 @@ def handle_hook(db: DB, agent_id: str, event: str, payload: dict) -> dict | None
|
|
|
5739
5909
|
transcript = payload.get("transcript_path")
|
|
5740
5910
|
if transcript and agent.provider == "claude" and transcript != agent.transcript_path:
|
|
5741
5911
|
db.update_agent(agent_id, transcript_path=str(transcript))
|
|
5912
|
+
if agent.provider == "claude" and agent.mode == "interactive" and (transcript or agent.transcript_path):
|
|
5913
|
+
_note_absorbed_prompts(db, agent, str(transcript or agent.transcript_path))
|
|
5742
5914
|
|
|
5743
5915
|
if event in ("prompt-submit", "pre-tool", "tool-done") and agent.unreported_noted:
|
|
5744
5916
|
# It's working again, so a later stop without a result is a new one
|