capt-hook 12.77.1__tar.gz → 12.78.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {capt_hook-12.77.1 → capt_hook-12.78.0}/PKG-INFO +1 -1
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/.claude-plugin/plugin.json +1 -1
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/cli.py +9 -1
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/context.py +50 -15
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/guard_literal.py +109 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/primitives/llm.py +5 -1
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/snapshots/client.py +54 -22
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/snapshots/worker.py +30 -1
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/testing/helpers.py +7 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/testing/types.py +14 -6
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/transcripts.py +8 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/hatch_build.py +92 -1
- {capt_hook-12.77.1 → capt_hook-12.78.0}/internal/wireproto/guard.json +1 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/pyproject.toml +1 -1
- {capt_hook-12.77.1 → capt_hook-12.78.0}/.gitignore +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/LICENSE +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/README.md +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/capt_hook_client/__init__.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/capt_hook_client/__main__.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/capt_hook_client/client.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/.mcp.json +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/__init__.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/__init__.pyi +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/__main__.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/annotations.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/app.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/ast_grep.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/bindings.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/__init__.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/fixes/__init__.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/fixes/hooks/__init__.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/fixes/hooks/_lib.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/fixes/hooks/scratch_writes.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/fixes/hooks/teammate_permissions.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/general/__init__.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/general/hooks/__init__.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/general/hooks/_lib.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/general/hooks/_sessions.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/general/hooks/commands.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/general/hooks/comments.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/general/hooks/deletions.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/general/hooks/detours.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/general/hooks/docs.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/general/hooks/hook_files.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/general/hooks/models.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/general/hooks/plain_english.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/general/hooks/plans.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/general/hooks/prompts/fragments/deliverable_rubric.md +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/general/hooks/prompts/fragments/workflow_script_header.md +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/general/hooks/prompts/models/browser_delegation_nudge.md +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/general/hooks/prompts/models/implementation_spawn_nudge.md +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/general/hooks/prompts/models/inline_edit_nudge.md +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/general/hooks/prompts/models/prose_spawn_gate.md +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/general/hooks/prompts/models/prose_workflow_nudge.md +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/general/hooks/prompts/models/review_routing_spawn_nudge.md +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/general/hooks/prompts/models/review_routing_workflow_nudge.md +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/general/hooks/prompts/models/writing_docs_spawn_nudge.md +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/general/hooks/prompts/models/writing_docs_workflow_nudge.md +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/general/hooks/prompts/plain_english_rules.md +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/general/hooks/prompts/tools/preload_nudge.md +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/general/hooks/prompts.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/general/hooks/questions.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/general/hooks/review.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/general/hooks/sessions.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/general/hooks/tasks.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/general/hooks/tombstones.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/general/hooks/tooling.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/general/hooks/tools.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/general/pack.toml +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/go/__init__.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/go/hooks/__init__.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/go/hooks/testing.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/go/hooks/toolchain.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/graphite/__init__.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/graphite/gitdir/.graphite_repo_config +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/graphite/hooks/__init__.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/graphite/hooks/_lib.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/graphite/hooks/queue.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/graphite/hooks/vcs.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/performance/__init__.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/performance/hooks/__init__.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/performance/hooks/filesystem.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/performance/hooks/pipelining.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/python/__init__.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/python/hooks/__init__.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/python/hooks/style.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/python/hooks/testing.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/python/hooks/toolchain.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/steering/__init__.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/steering/hooks/__init__.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/steering/hooks/steering.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/steering/hooks/teammates.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/steering/hooks/workarounds.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/builtin_packs/steering/pack.toml +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/classifiers/__init__.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/classifiers/conductor.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/classifiers/droid.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/classifiers/lane.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/classifiers/native.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/cmd.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/command_schema.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/command_schemas.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/conditions.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/confirm.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/contexts.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/daemon/__init__.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/daemon/context.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/daemon/decision_writer.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/daemon/logsink.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/daemon/registry.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/daemon/tree.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/decisions.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/desktop/__init__.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/desktop/cli.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/desktop/client.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/dispatch.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/doc_conventions.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/durable.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/events.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/faults.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/fields.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/file.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/guard_literal.sh +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/heartbeat.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/hook_lint.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/hooks/hooks.json +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/loader.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/log.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/mcp_server.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/packs/__init__.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/packs/manager.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/packs/plugins.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/primitives/__init__.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/primitives/commands.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/primitives/lint.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/primitives/nudge.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/primitives/permissions.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/primitives/provision.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/primitives/rewrite.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/primitives/workflow.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/prompt.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/py.typed +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/review/__init__.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/review/announce.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/review/cli.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/review/dashboard.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/review/fix.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/review/formats.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/review/judge.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/review/notify.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/review/pipeline.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/review/prompts.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/review/repo.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/review/routing.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/review/scan.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/review/settings.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/review/snapshot.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/review/status.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/review/store.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/review/sync.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/review/triage.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/scripts/install-binary.sh +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/scripts/install-mcp.sh +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/session.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/settings.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/signals/__init__.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/signals/nlp.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/skills/authoring-hooks/SKILL.md +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/skills/authoring-hooks/references/capt-hook-api.md +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/skills/authoring-hooks/references/pattern-catalog.md +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/skills/authoring-hooks/references/pitfalls.md +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/skills/authoring-hooks/references/testing-hooks.md +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/skills/bootstrapping-hooks/SKILL.md +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/skills/scanning-sessions/SKILL.md +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/skills/scanning-sessions/references/pr-workflow.md +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/skills/scanning-sessions/references/review-cli.md +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/skills/translating-styleguides/SKILL.md +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/skills/translating-styleguides/references/llm-rule-patterns.md +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/skills/translating-styleguides/references/matcher-reference.md +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/skills/translating-styleguides/references/tier-rubric.md +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/snapshots/__init__.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/snapshots/contracts.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/snapshots/review.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/snapshots/schema.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/snapshots/schemas/config.schema.json +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/snapshots/schemas/context.schema.json +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/snapshots/schemas/host-request.schema.json +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/snapshots/schemas/host-response.schema.json +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/snapshots/schemas/request.schema.json +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/snapshots/schemas/response.schema.json +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/snapshots/schemas/tool_registry.schema.json +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/snapshots/validation.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/state.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/style/__init__.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/style/ast_grep.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/style/matchers.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/style/scope.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/style/types.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/tasks.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/templates/example_hook.py.tmpl +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/testing/__init__.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/testing/fixtures.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/testing/session_cache.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/testing/snapshots.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/turn.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/types.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/update/__init__.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/update/cli.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/update/settings.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/update/updater.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/util/__init__.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/util/automode.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/util/caching.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/util/fs.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/util/globbing.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/util/http.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/util/model_cache.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/util/paths.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/util/payload.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/util/proc.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/util/reqenv.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/util/scratch.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/util/shell.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/util/text.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/util/userpath.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/util/vcs.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/worker/__init__.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/worker/__main__.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/worker/fail_open.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/worker/protocol.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/worker/runtime.py +0 -0
- {capt_hook-12.77.1 → capt_hook-12.78.0}/captain_hook/worker/service.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "captain-hook",
|
|
3
|
-
"version": "12.77.
|
|
3
|
+
"version": "12.77.1",
|
|
4
4
|
"displayName": "Captain Hook",
|
|
5
5
|
"description": "Skills for the capt-hook declarative hook framework: bootstrap gates and nudges from a repo's conventions, and translate style guides into enforced StyleRules.",
|
|
6
6
|
"author": {
|
|
@@ -278,7 +278,13 @@ def dispatch_event(
|
|
|
278
278
|
"""
|
|
279
279
|
from captain_hook.context import HookContext
|
|
280
280
|
from captain_hook.heartbeat import record_heartbeat
|
|
281
|
-
from captain_hook.transcripts import
|
|
281
|
+
from captain_hook.transcripts import (
|
|
282
|
+
ROOT_TAIL_EVENTS,
|
|
283
|
+
lane_transcript_path,
|
|
284
|
+
lazy_transcript,
|
|
285
|
+
registered_sources,
|
|
286
|
+
root_transcript,
|
|
287
|
+
)
|
|
282
288
|
from captain_hook.util import reqenv
|
|
283
289
|
|
|
284
290
|
record_heartbeat(event, raw)
|
|
@@ -293,11 +299,13 @@ def dispatch_event(
|
|
|
293
299
|
attach=lambda: registered_sources(session_dir),
|
|
294
300
|
)
|
|
295
301
|
background_transcript = transcript.fork()
|
|
302
|
+
parent = raw.get("transcript_path")
|
|
296
303
|
ctx = HookContext(
|
|
297
304
|
session=SessionStore(session_dir),
|
|
298
305
|
transcript=transcript,
|
|
299
306
|
settings=_state.settings,
|
|
300
307
|
project_root=root,
|
|
308
|
+
root_transcript=root_transcript(parent, ROOT_TAIL_EVENTS) if parent and resolved_path != parent else None,
|
|
301
309
|
)
|
|
302
310
|
evt = event.event_class(_raw=raw, ctx=ctx)
|
|
303
311
|
within_margin = reqenv.deadline_within(SYNC_DEADLINE_MARGIN_SECONDS)
|
|
@@ -94,6 +94,21 @@ def transcript_window(transcript: bool | int | Literal["recent", "full"]) -> int
|
|
|
94
94
|
return events
|
|
95
95
|
|
|
96
96
|
|
|
97
|
+
def render_window(
|
|
98
|
+
transcript: Session | RemoteSession, *, window: int | None, tool_results: bool, budget: Budget | None
|
|
99
|
+
) -> str:
|
|
100
|
+
from cc_transcript.render import Budget, render_turn
|
|
101
|
+
|
|
102
|
+
src = transcript if window is None else transcript.recent_messages(window)
|
|
103
|
+
if isinstance(src, RemoteSession):
|
|
104
|
+
return src.render(budget=budget or Budget(), tool_results=tool_results)
|
|
105
|
+
return "\n\n".join(
|
|
106
|
+
rendered
|
|
107
|
+
for turn in src.turns
|
|
108
|
+
if (rendered := render_turn(turn, budget=budget or Budget(), tool_results=tool_results))
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
|
|
97
112
|
@dataclass(frozen=True)
|
|
98
113
|
class HookEvidence:
|
|
99
114
|
source_ref: str | None
|
|
@@ -109,13 +124,16 @@ class HookEvidence:
|
|
|
109
124
|
class HookContext:
|
|
110
125
|
"""Runtime context injected into every hook event.
|
|
111
126
|
|
|
112
|
-
Holds session state, the transcript ``Session``, settings, and LLM/CLI helpers.
|
|
127
|
+
Holds session state, the transcript ``Session``, settings, and LLM/CLI helpers. Inside a
|
|
128
|
+
subagent or teammate lane, ``transcript`` is the lane's own and ``root_transcript`` tails the
|
|
129
|
+
session that spawned it, where the user's own words live; it is ``None`` everywhere else.
|
|
113
130
|
"""
|
|
114
131
|
|
|
115
132
|
session: SessionStore
|
|
116
133
|
transcript: Session | RemoteSession | LazyTranscript
|
|
117
134
|
settings: HooksSettings | None
|
|
118
135
|
project_root: Path | None = None
|
|
136
|
+
root_transcript: Session | RemoteSession | LazyTranscript | None = None
|
|
119
137
|
signal_evidence: dict[tuple[int | Literal["turn"], str, bool], tuple[str, ...]] = field(
|
|
120
138
|
default_factory=dict, init=False
|
|
121
139
|
)
|
|
@@ -238,16 +256,7 @@ class HookContext:
|
|
|
238
256
|
tool_results: Render each tool result after its call, as ``result:`` or ``failed:``.
|
|
239
257
|
budget: Character budgets for prose, tool calls and answer previews; ``None`` is cc-transcript's default.
|
|
240
258
|
"""
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
src = self.t if window is None else self.t.recent_messages(window)
|
|
244
|
-
if isinstance(src, RemoteSession):
|
|
245
|
-
return src.render(budget=budget or Budget(), tool_results=tool_results)
|
|
246
|
-
return "\n\n".join(
|
|
247
|
-
rendered
|
|
248
|
-
for turn in src.turns
|
|
249
|
-
if (rendered := render_turn(turn, budget=budget or Budget(), tool_results=tool_results))
|
|
250
|
-
)
|
|
259
|
+
return render_window(self.t, window=window, tool_results=tool_results, budget=budget)
|
|
251
260
|
|
|
252
261
|
def transcript_block(
|
|
253
262
|
self, *, window: int | None = RECENT_WINDOW, tool_results: bool = False, budget: Budget | None = None
|
|
@@ -257,6 +266,19 @@ class HookContext:
|
|
|
257
266
|
return f'<transcript evidence="{self.t.evidence_ref}">\n{rendered}\n</transcript>'
|
|
258
267
|
return f"<transcript>\n{rendered}\n</transcript>"
|
|
259
268
|
|
|
269
|
+
def root_transcript_block(
|
|
270
|
+
self, *, window: int | None = RECENT_WINDOW, tool_results: bool = False, budget: Budget | None = None
|
|
271
|
+
) -> str:
|
|
272
|
+
"""The lane's root session rendered like ``transcript_block`` as ``<root_transcript>``; empty outside a lane."""
|
|
273
|
+
from captain_hook.transcripts import LazyTranscript
|
|
274
|
+
|
|
275
|
+
if self.root_transcript is None:
|
|
276
|
+
return ""
|
|
277
|
+
root = self.root_transcript
|
|
278
|
+
src = root.resolve() if isinstance(root, LazyTranscript) else root
|
|
279
|
+
rendered = render_window(src, window=window, tool_results=tool_results, budget=budget)
|
|
280
|
+
return f"<root_transcript>\n{rendered}\n</root_transcript>"
|
|
281
|
+
|
|
260
282
|
def call_cli(
|
|
261
283
|
self,
|
|
262
284
|
args: list[str],
|
|
@@ -453,16 +475,29 @@ class HookContext:
|
|
|
453
475
|
tool_results: bool,
|
|
454
476
|
budget: Budget | None = None,
|
|
455
477
|
diff_text: str | None,
|
|
478
|
+
root_transcript: bool | int | Literal["recent", "full"] = False,
|
|
456
479
|
) -> str:
|
|
457
|
-
|
|
458
|
-
|
|
480
|
+
block = "\n\n".join(
|
|
481
|
+
rendered
|
|
482
|
+
for rendered in (
|
|
483
|
+
self.root_transcript_block(
|
|
484
|
+
window=transcript_window(root_transcript), tool_results=tool_results, budget=budget
|
|
485
|
+
)
|
|
486
|
+
if root_transcript
|
|
487
|
+
else "",
|
|
488
|
+
self.transcript_block(window=transcript_window(transcript), tool_results=tool_results, budget=budget)
|
|
489
|
+
if transcript
|
|
490
|
+
else "",
|
|
491
|
+
)
|
|
492
|
+
if rendered
|
|
493
|
+
)
|
|
459
494
|
match template:
|
|
460
495
|
case Prompt():
|
|
461
496
|
prompt = str(template.context("diff", diff_text))
|
|
462
|
-
if not
|
|
497
|
+
if not block:
|
|
463
498
|
return prompt
|
|
464
499
|
return f"{block}\n\n<task>\n{prompt}\n</task>"
|
|
465
500
|
case str():
|
|
466
|
-
wrapped = f"{{transcript}}\n\n<task>\n{template}\n</task>" if
|
|
501
|
+
wrapped = f"{{transcript}}\n\n<task>\n{template}\n</task>" if block else template
|
|
467
502
|
body = wrapped.format(*args, **kwargs, transcript=block)
|
|
468
503
|
return f"<diff>\n{diff_text}\n</diff>\n\n{body}" if diff_text is not None else body
|
|
@@ -15,6 +15,20 @@ GUARDED: str = (
|
|
|
15
15
|
"|halt|poweroff|renice|tmux|softwareupdate|pmset|caffeinate|setsid|builtin|noglob|stdbuf|unbuffer|scr"
|
|
16
16
|
"ipt|watch|parallel|chrt|ionice|taskset|arch|su|chroot|find)\\b"
|
|
17
17
|
)
|
|
18
|
+
EXEMPT_HEADS: tuple[str, ...] = (
|
|
19
|
+
"cc-slack",
|
|
20
|
+
"ccn",
|
|
21
|
+
"cc-notes",
|
|
22
|
+
"cc-present",
|
|
23
|
+
"cc-transcript",
|
|
24
|
+
"cat",
|
|
25
|
+
"echo",
|
|
26
|
+
"grep",
|
|
27
|
+
"head",
|
|
28
|
+
"jq",
|
|
29
|
+
"tail",
|
|
30
|
+
"wc",
|
|
31
|
+
)
|
|
18
32
|
FOLDS: dict[str, str] = {"\u0130": "i", "\u0131": "i", "\u017f": "s", "\u212a": "k"}
|
|
19
33
|
KINDS: tuple[str, ...] = (
|
|
20
34
|
"host-unavailable",
|
|
@@ -36,6 +50,11 @@ PASS_EXIT: int = 3
|
|
|
36
50
|
GUARDED_WORD: re.Pattern[str] = re.compile(GUARDED, re.IGNORECASE | re.ASCII)
|
|
37
51
|
QUOTING_CHARS: re.Pattern[str] = re.compile(QUOTING)
|
|
38
52
|
FOLD_TABLE: dict[int, str] = str.maketrans(FOLDS)
|
|
53
|
+
ASSIGNMENT: re.Pattern[str] = re.compile("^[A-Za-z_][A-Za-z0-9_]*=")
|
|
54
|
+
LITERAL_HEAD: re.Pattern[str] = re.compile("[A-Za-z0-9_./~+-]+")
|
|
55
|
+
OPAQUE_SHELL: tuple[str, ...] = ("$(", "`", "<(", ">(")
|
|
56
|
+
SEGMENT_BREAKS: frozenset[str] = frozenset(";\n|()")
|
|
57
|
+
QUOTED_ESCAPES: frozenset[str] = frozenset('$`"\\\n')
|
|
39
58
|
|
|
40
59
|
|
|
41
60
|
def names_guarded(text: str) -> bool:
|
|
@@ -57,6 +76,94 @@ def names_guarded_value(value: object) -> bool:
|
|
|
57
76
|
return False
|
|
58
77
|
|
|
59
78
|
|
|
79
|
+
def first_party_command(tool_input: object) -> bool:
|
|
80
|
+
if not isinstance(tool_input, dict):
|
|
81
|
+
return False
|
|
82
|
+
command = cast(dict[object, object], tool_input).get("command")
|
|
83
|
+
if not isinstance(command, str):
|
|
84
|
+
return False
|
|
85
|
+
joined = command.replace("\\\n", "")
|
|
86
|
+
if any(opaque in joined for opaque in OPAQUE_SHELL):
|
|
87
|
+
return False
|
|
88
|
+
segments = shell_segments(command)
|
|
89
|
+
return segments is not None and all(exempt_segment(words) for words in segments)
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def exempt_segment(words: list[tuple[str, str, bool]]) -> bool:
|
|
93
|
+
for raw, cooked, redirect in words:
|
|
94
|
+
if redirect:
|
|
95
|
+
return False
|
|
96
|
+
if ASSIGNMENT.match(raw) is None:
|
|
97
|
+
return LITERAL_HEAD.fullmatch(cooked) is not None and cooked.rpartition("/")[2] in EXEMPT_HEADS
|
|
98
|
+
return True
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def shell_segments(command: str) -> list[list[tuple[str, str, bool]]] | None:
|
|
102
|
+
segments: list[list[tuple[str, str, bool]]] = [[]]
|
|
103
|
+
raw: list[str] = []
|
|
104
|
+
cooked: list[str] = []
|
|
105
|
+
started = redirect = after_redirect = False
|
|
106
|
+
|
|
107
|
+
def end_word() -> None:
|
|
108
|
+
nonlocal started, redirect
|
|
109
|
+
if started:
|
|
110
|
+
segments[-1].append(("".join(raw), "".join(cooked), redirect))
|
|
111
|
+
raw.clear()
|
|
112
|
+
cooked.clear()
|
|
113
|
+
started = redirect = False
|
|
114
|
+
|
|
115
|
+
index = 0
|
|
116
|
+
while index < len(command):
|
|
117
|
+
char = command[index]
|
|
118
|
+
redirecting = False
|
|
119
|
+
if char == "\\" and index + 1 == len(command):
|
|
120
|
+
raw.append(char)
|
|
121
|
+
cooked.append(char)
|
|
122
|
+
started = True
|
|
123
|
+
elif char == "\\":
|
|
124
|
+
index += 1
|
|
125
|
+
if command[index] != "\n":
|
|
126
|
+
raw.append(command[index - 1 : index + 1])
|
|
127
|
+
cooked.append(command[index])
|
|
128
|
+
started = True
|
|
129
|
+
elif char == "'":
|
|
130
|
+
end = command.find("'", index + 1)
|
|
131
|
+
if end < 0:
|
|
132
|
+
return None
|
|
133
|
+
raw.append(command[index : end + 1])
|
|
134
|
+
cooked.append(command[index + 1 : end])
|
|
135
|
+
started = True
|
|
136
|
+
index = end
|
|
137
|
+
elif char == '"':
|
|
138
|
+
end = index + 1
|
|
139
|
+
while end < len(command) and command[end] != '"':
|
|
140
|
+
escaped = command[end] == "\\" and end + 1 < len(command) and command[end + 1] in QUOTED_ESCAPES
|
|
141
|
+
end += escaped
|
|
142
|
+
if not (escaped and command[end] == "\n"):
|
|
143
|
+
cooked.append(command[end])
|
|
144
|
+
end += 1
|
|
145
|
+
if end == len(command):
|
|
146
|
+
return None
|
|
147
|
+
raw.append(command[index : end + 1])
|
|
148
|
+
started = True
|
|
149
|
+
index = end
|
|
150
|
+
elif char in " \t":
|
|
151
|
+
end_word()
|
|
152
|
+
elif char in SEGMENT_BREAKS or (char == "&" and not after_redirect and command[index + 1 : index + 2] != ">"):
|
|
153
|
+
end_word()
|
|
154
|
+
segments.append([])
|
|
155
|
+
else:
|
|
156
|
+
raw.append(char)
|
|
157
|
+
cooked.append(char)
|
|
158
|
+
started = True
|
|
159
|
+
redirecting = char in "<>"
|
|
160
|
+
redirect = redirect or redirecting
|
|
161
|
+
after_redirect = redirecting
|
|
162
|
+
index += 1
|
|
163
|
+
end_word()
|
|
164
|
+
return segments
|
|
165
|
+
|
|
166
|
+
|
|
60
167
|
def mandatory(event: str, payload: bytes) -> bool:
|
|
61
168
|
if event not in EVENTS:
|
|
62
169
|
return False
|
|
@@ -67,6 +174,8 @@ def mandatory(event: str, payload: bytes) -> bool:
|
|
|
67
174
|
if not isinstance(fields, dict):
|
|
68
175
|
return False
|
|
69
176
|
payload_fields = cast(dict[object, object], fields)
|
|
177
|
+
if payload_fields.get("tool_name") == "Bash" and first_party_command(payload_fields.get("tool_input")):
|
|
178
|
+
return False
|
|
70
179
|
return names_guarded_value(payload_fields.get("tool_name")) or names_guarded_value(payload_fields.get("tool_input"))
|
|
71
180
|
|
|
72
181
|
|
|
@@ -87,6 +87,7 @@ def llm_evaluate[M: BaseModel](
|
|
|
87
87
|
model: TModel = "small",
|
|
88
88
|
agent: bool = False,
|
|
89
89
|
transcript: bool | int | Literal["recent", "full"] = False,
|
|
90
|
+
root_transcript: bool | int | Literal["recent", "full"] = False,
|
|
90
91
|
tool_results: bool = False,
|
|
91
92
|
budget: Budget | None = None,
|
|
92
93
|
diff: bool | str = False,
|
|
@@ -100,7 +101,9 @@ def llm_evaluate[M: BaseModel](
|
|
|
100
101
|
attaches the transcript window and optional diff, then calls the backend — retrying up
|
|
101
102
|
to ``retries`` times, feeding a schema validation failure back to the model on re-ask. Returns
|
|
102
103
|
``None`` on a skip; raises when the call still fails after the final retry, and at once when the
|
|
103
|
-
backend rejects the model itself.
|
|
104
|
+
backend rejects the model itself. ``root_transcript`` takes a window like ``transcript`` and, when
|
|
105
|
+
the event fires inside a subagent or teammate lane, adds that window of the root session that
|
|
106
|
+
spawned the lane as ``<root_transcript>``, so a judge can read the user's words a lane never saw.
|
|
104
107
|
"""
|
|
105
108
|
from cc_transcript.render import clip
|
|
106
109
|
|
|
@@ -144,6 +147,7 @@ def llm_evaluate[M: BaseModel](
|
|
|
144
147
|
tool_results=tool_results,
|
|
145
148
|
budget=budget,
|
|
146
149
|
diff_text=None,
|
|
150
|
+
root_transcript=root_transcript,
|
|
147
151
|
)
|
|
148
152
|
asked = dispatched
|
|
149
153
|
for attempt in count():
|
|
@@ -57,6 +57,24 @@ def foreground_seconds(event: str) -> float:
|
|
|
57
57
|
return GATE_WORK_SECONDS if event in GATE_EVENTS else GRAPH_WORK_SECONDS
|
|
58
58
|
|
|
59
59
|
|
|
60
|
+
SCALAR_QUERY_KINDS = frozenset(
|
|
61
|
+
{
|
|
62
|
+
"user_text",
|
|
63
|
+
"first_prompt",
|
|
64
|
+
"event_count",
|
|
65
|
+
"turn_count",
|
|
66
|
+
"tool_count",
|
|
67
|
+
"message_count",
|
|
68
|
+
"unresolved_tools",
|
|
69
|
+
"failures",
|
|
70
|
+
"workflow_text",
|
|
71
|
+
"pending_named_task",
|
|
72
|
+
}
|
|
73
|
+
)
|
|
74
|
+
SCALAR_MISS = object()
|
|
75
|
+
type ScalarKey = tuple[str, tuple[tuple[str, str], ...], SnapshotClient, PreparedGraphEvidence | None, str, str]
|
|
76
|
+
|
|
77
|
+
|
|
60
78
|
def graph_limits() -> dict[str, int]:
|
|
61
79
|
limits = DEFAULT_LIMITS.copy()
|
|
62
80
|
limits["max_discovery_entries"] = min(limits["max_discovery_entries"], GRAPH_DISCOVERY_ENTRIES)
|
|
@@ -482,6 +500,7 @@ class Lease:
|
|
|
482
500
|
self.guard = threading.Lock()
|
|
483
501
|
self.subagent_guard = threading.Lock()
|
|
484
502
|
self.subagent_views: dict[str, RemoteSubagentIndex] = {}
|
|
503
|
+
self.scalar_results: dict[ScalarKey, Any] = {}
|
|
485
504
|
|
|
486
505
|
def renewable_by(self, client: SnapshotClient) -> bool:
|
|
487
506
|
return (deadline := client.foreground_deadline_unix_ms) is None or self.expires_unix_ms < deadline
|
|
@@ -500,12 +519,15 @@ class Lease:
|
|
|
500
519
|
|
|
501
520
|
def release(self) -> None:
|
|
502
521
|
with self.subagent_guard:
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
for
|
|
507
|
-
|
|
508
|
-
|
|
522
|
+
try:
|
|
523
|
+
with ExitStack() as cleanup:
|
|
524
|
+
cleanup.callback(self._release)
|
|
525
|
+
for index in self.subagent_views.values():
|
|
526
|
+
for item in index:
|
|
527
|
+
cleanup.callback(item.session.release)
|
|
528
|
+
finally:
|
|
529
|
+
self.subagent_views.clear()
|
|
530
|
+
self.scalar_results.clear()
|
|
509
531
|
|
|
510
532
|
def _release(self) -> None:
|
|
511
533
|
with self.guard:
|
|
@@ -923,13 +945,38 @@ class RemoteSession:
|
|
|
923
945
|
return f"transcript:{handle['owner_epoch']}:{handle['snapshot_id']}:{handle['generation']}"
|
|
924
946
|
|
|
925
947
|
def query(self, query: Mapping[str, object]) -> Any:
|
|
926
|
-
values: list[Any] = []
|
|
927
948
|
deep = query.get("subagents") is True or query["kind"] in {
|
|
928
949
|
"deep_predicate_inputs",
|
|
929
950
|
"sidechain_membership",
|
|
930
951
|
}
|
|
931
952
|
if deep and query["kind"] == "sidechain_membership":
|
|
932
953
|
raise EvidenceIncomplete("invalid_request", "sidechain membership has no prepared graph projection")
|
|
954
|
+
scalar = query["kind"] in SCALAR_QUERY_KINDS or str(query["kind"]).startswith("has_")
|
|
955
|
+
if not scalar:
|
|
956
|
+
return self._query(query, deep=deep)
|
|
957
|
+
key: ScalarKey = (
|
|
958
|
+
self.evidence_ref,
|
|
959
|
+
tuple(sorted(self.classifier.items())),
|
|
960
|
+
self.client,
|
|
961
|
+
self.graph if deep else None,
|
|
962
|
+
json.dumps(self.selectors, sort_keys=True, separators=(",", ":")),
|
|
963
|
+
json.dumps(query, sort_keys=True, separators=(",", ":")),
|
|
964
|
+
)
|
|
965
|
+
self.lease.require()
|
|
966
|
+
if (cached := self.lease.scalar_results.get(key, SCALAR_MISS)) is not SCALAR_MISS:
|
|
967
|
+
if deep:
|
|
968
|
+
self.graph.require(self)
|
|
969
|
+
return cached
|
|
970
|
+
values = self._query(query, deep=deep)
|
|
971
|
+
if len(values) != 1:
|
|
972
|
+
raise SnapshotProtocolError("scalar query returned a non-scalar result")
|
|
973
|
+
with self.lease.guard:
|
|
974
|
+
if not self.lease.closed:
|
|
975
|
+
self.lease.scalar_results[key] = values[0]
|
|
976
|
+
return values[0]
|
|
977
|
+
|
|
978
|
+
def _query(self, query: Mapping[str, object], *, deep: bool) -> list[Any]:
|
|
979
|
+
values: list[Any] = []
|
|
933
980
|
pages = (
|
|
934
981
|
self.graph.query_pages(self, query)
|
|
935
982
|
if deep
|
|
@@ -954,21 +1001,6 @@ class RemoteSession:
|
|
|
954
1001
|
raise EvidenceIncomplete(exc.status, exc.reason) from exc
|
|
955
1002
|
case _:
|
|
956
1003
|
raise SnapshotProtocolError("query returned an unexpected projection")
|
|
957
|
-
if query["kind"] in {
|
|
958
|
-
"user_text",
|
|
959
|
-
"first_prompt",
|
|
960
|
-
"event_count",
|
|
961
|
-
"turn_count",
|
|
962
|
-
"tool_count",
|
|
963
|
-
"message_count",
|
|
964
|
-
"unresolved_tools",
|
|
965
|
-
"failures",
|
|
966
|
-
"workflow_text",
|
|
967
|
-
"pending_named_task",
|
|
968
|
-
} or str(query["kind"]).startswith("has_"):
|
|
969
|
-
if len(values) != 1:
|
|
970
|
-
raise SnapshotProtocolError("scalar query returned a non-scalar result")
|
|
971
|
-
return values[0]
|
|
972
1004
|
return values
|
|
973
1005
|
|
|
974
1006
|
def __len__(self) -> int:
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
import asyncio
|
|
4
|
+
import hashlib
|
|
4
5
|
import importlib.metadata
|
|
5
6
|
import json
|
|
6
7
|
import os
|
|
@@ -23,6 +24,7 @@ from captain_hook.snapshots.client import (
|
|
|
23
24
|
read_exact,
|
|
24
25
|
)
|
|
25
26
|
from captain_hook.snapshots.validation import checked, parse_exact, validator
|
|
27
|
+
from captain_hook.util.caching import LRUDict
|
|
26
28
|
|
|
27
29
|
if TYPE_CHECKING:
|
|
28
30
|
from cc_transcript.snapshots import CallContext
|
|
@@ -42,6 +44,9 @@ OWNER_ADMISSION = {
|
|
|
42
44
|
"release": (4, 32),
|
|
43
45
|
"warm": (1, 4),
|
|
44
46
|
}
|
|
47
|
+
MAX_REGISTRY_GENERATIONS = 64
|
|
48
|
+
|
|
49
|
+
RegistryKey = tuple[str, str, bytes]
|
|
45
50
|
|
|
46
51
|
|
|
47
52
|
def read_frame(stream: BinaryIO, record_bytes: Callable[[int], None] | None = None) -> dict[str, Any] | None:
|
|
@@ -60,6 +65,18 @@ def read_frame(stream: BinaryIO, record_bytes: Callable[[int], None] | None = No
|
|
|
60
65
|
return result
|
|
61
66
|
|
|
62
67
|
|
|
68
|
+
def canonical(value: object) -> bytes:
|
|
69
|
+
return json.dumps(value, separators=(",", ":"), sort_keys=True).encode()
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def registry_key(tool_registry: list[dict[str, Any]], context: CallContext) -> RegistryKey:
|
|
73
|
+
return (
|
|
74
|
+
hashlib.sha256(canonical(sorted(tool_registry, key=canonical))).hexdigest(),
|
|
75
|
+
context["admission"],
|
|
76
|
+
canonical(context["authority"]),
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
|
|
63
80
|
def empty_usage() -> dict[str, int]:
|
|
64
81
|
return dict.fromkeys(validator("response").schema["$defs"]["Usage"]["properties"], 0)
|
|
65
82
|
|
|
@@ -99,6 +116,8 @@ class Owner:
|
|
|
99
116
|
self.incomplete_type = SnapshotIncomplete
|
|
100
117
|
self.policy = ReviewPolicy()
|
|
101
118
|
self.runner: asyncio.Runner | None = None
|
|
119
|
+
self.registry_generations: LRUDict[RegistryKey, str] = LRUDict(MAX_REGISTRY_GENERATIONS)
|
|
120
|
+
self.registry_guard = threading.Lock()
|
|
102
121
|
|
|
103
122
|
def _run_policy(self, snapshot: Any, request: dict[str, Any]) -> dict[str, Any]:
|
|
104
123
|
if self.runner is None:
|
|
@@ -165,12 +184,22 @@ class Owner:
|
|
|
165
184
|
return {"id": "captain-conductor", "version": "1"}
|
|
166
185
|
return {"id": "native", "version": "1"}
|
|
167
186
|
|
|
187
|
+
def registry_generation(self, tool_registry: list[dict[str, Any]], context: CallContext) -> str:
|
|
188
|
+
key = registry_key(tool_registry, context)
|
|
189
|
+
with self.registry_guard:
|
|
190
|
+
if key in self.registry_generations:
|
|
191
|
+
return self.registry_generations[key]
|
|
192
|
+
generation = self.store.register_tool_registry(tool_registry, context=context)
|
|
193
|
+
with self.registry_guard:
|
|
194
|
+
self.registry_generations[key] = generation
|
|
195
|
+
return generation
|
|
196
|
+
|
|
168
197
|
def call(
|
|
169
198
|
self, request: dict[str, Any], context: CallContext, token: Any, tool_registry: list[dict[str, Any]]
|
|
170
199
|
) -> dict[str, Any]:
|
|
171
200
|
usage: dict[str, int] | None = None
|
|
172
201
|
try:
|
|
173
|
-
context["registry_generation"] = self.
|
|
202
|
+
context["registry_generation"] = self.registry_generation(tool_registry, context)
|
|
174
203
|
if request["schema"] == CORE_SCHEMA:
|
|
175
204
|
if request["operation"] == "resume":
|
|
176
205
|
page = self.store.resume_projection(request["cursor"], context=context, cancellation=token)
|
|
@@ -94,6 +94,7 @@ class StubbedContext(HookContext):
|
|
|
94
94
|
transcript=ctx.transcript,
|
|
95
95
|
settings=ctx.settings,
|
|
96
96
|
project_root=ctx.project_root,
|
|
97
|
+
root_transcript=ctx.root_transcript,
|
|
97
98
|
llm=llm or {},
|
|
98
99
|
)
|
|
99
100
|
|
|
@@ -574,6 +575,12 @@ def input_to_event(
|
|
|
574
575
|
|
|
575
576
|
evt.__dict__["disallowed_tools"] = frozenset(inp.disallowed_tools or ())
|
|
576
577
|
|
|
578
|
+
match inp.root_transcript:
|
|
579
|
+
case TranscriptFixture() as tf:
|
|
580
|
+
evt.ctx.root_transcript = fixture_session(tf.messages)
|
|
581
|
+
case Path() as p:
|
|
582
|
+
evt.ctx.root_transcript = fixture_transcript(p)
|
|
583
|
+
|
|
577
584
|
evt.ctx = StubbedContext.wrapping(evt.ctx, inp.llm)
|
|
578
585
|
|
|
579
586
|
return evt
|
|
@@ -180,6 +180,8 @@ class Input:
|
|
|
180
180
|
transcript: Session history for transcript conditions — a path, a
|
|
181
181
|
``TranscriptFixture``, or a raw list of transcript-line dicts. A path
|
|
182
182
|
also lands in the payload as ``evt.transcript_path``, on every event.
|
|
183
|
+
root_transcript: The root session a lane's event reads as ``evt.ctx.root_transcript``,
|
|
184
|
+
in any form ``transcript`` takes; pair it with ``agent_id``.
|
|
183
185
|
tasks: The native task list read via ``evt.tasks``.
|
|
184
186
|
background_tasks: Background-task mappings for the ``Stop``/``SubagentStop``
|
|
185
187
|
payload, surfaced as ``evt.background_tasks`` — the shape that makes a
|
|
@@ -227,6 +229,7 @@ class Input:
|
|
|
227
229
|
offset: int | None = None
|
|
228
230
|
limit: int | None = None
|
|
229
231
|
transcript: Path | TranscriptFixture | list[dict[str, Any]] | None = None
|
|
232
|
+
root_transcript: Path | TranscriptFixture | list[dict[str, Any]] | None = None
|
|
230
233
|
tasks: list[dict[str, Any]] | None = None
|
|
231
234
|
background_tasks: list[dict[str, Any]] | None = None
|
|
232
235
|
llm: dict[str, Any] | None = None
|
|
@@ -236,12 +239,17 @@ class Input:
|
|
|
236
239
|
env: dict[str, str] | None = None
|
|
237
240
|
|
|
238
241
|
def __post_init__(self) -> None:
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
242
|
+
for name in ("transcript", "root_transcript"):
|
|
243
|
+
match getattr(self, name):
|
|
244
|
+
case list() as messages:
|
|
245
|
+
object.__setattr__(self, name, TranscriptFixture(messages))
|
|
246
|
+
case str() as path:
|
|
247
|
+
object.__setattr__(self, name, Path(path))
|
|
248
|
+
checks = FIELD_TYPES | {
|
|
249
|
+
"file": (str, FileFixture),
|
|
250
|
+
"transcript": (Path, TranscriptFixture),
|
|
251
|
+
"root_transcript": (Path, TranscriptFixture),
|
|
252
|
+
}
|
|
245
253
|
for name, types in checks.items():
|
|
246
254
|
if (value := getattr(self, name)) is not None and not isinstance(value, types):
|
|
247
255
|
raise TypeError(
|
|
@@ -28,6 +28,7 @@ if TYPE_CHECKING:
|
|
|
28
28
|
# A session id becomes a filesystem path component via ``ensure_session``; external callers (CLI, MCP)
|
|
29
29
|
# must not smuggle path separators or traversal past that trust boundary.
|
|
30
30
|
INVALID_SESSION_ID = re.compile(r"[/\\]|\x00|^\.\.?$")
|
|
31
|
+
ROOT_TAIL_EVENTS = 256
|
|
31
32
|
|
|
32
33
|
|
|
33
34
|
def user_classifier(events: Sequence[TranscriptEvent], *, path: Path | None = None) -> UserClassifier:
|
|
@@ -316,6 +317,13 @@ def lazy_transcript(
|
|
|
316
317
|
return LazyTranscript(TranscriptPins(load, partial(tail, path) if path else None), seed=True)
|
|
317
318
|
|
|
318
319
|
|
|
320
|
+
def root_transcript(path: str | Path, events: int) -> LazyTranscript:
|
|
321
|
+
"""The newest ``events`` events of a lane's root session transcript, tailed on first touch."""
|
|
322
|
+
return LazyTranscript(
|
|
323
|
+
TranscriptPins(partial(guarded_load, path, lambda source: tail_transcript(source, events))), seed=True
|
|
324
|
+
)
|
|
325
|
+
|
|
326
|
+
|
|
319
327
|
def guarded_load[S: Session | RemoteSession](path: str | Path | None, read: Callable[[str | Path | None], S]) -> S:
|
|
320
328
|
from captain_hook.snapshots.client import EvidenceIncomplete
|
|
321
329
|
|