Skip to main content

Hook event contract for OrchestKit — Pydantic models, JSON schemas, and a thin validation helper. Zero runtime deps beyond pydantic.

Project description

orchestkit-hook-contract

Pydantic v2 + JSON Schema contract for Claude Code hook events. Python sibling of the npm package @orchestkit/hook-contract. Both packages regenerate from the single source of truth at spec/hook-events.spec.yml in the repo root.

Status

  • M141-3 (this package): scaffold — Pydantic models, JSON schemas, structural validator, hand-rolled codegen from spec.
  • M141-6 (next): cross-language parity gate CI — diff this output against the npm side field-by-field.

Install

pip install orchestkit-hook-contract

Requires Python 3.11+ and pydantic>=2.5.

Usage

from orchestkit_hook_contract import (
    HookEvent,
    HOOK_EVENT_NAMES,
    PreToolUsePayload,
    validate_hook_event,
)

# Structural validation
result = validate_hook_event({"event": "PreToolUse"})
if result.valid:
    print("known event:", result.event)

# Typed payload access
p = PreToolUsePayload(tool_name="Bash", tool_input={"cmd": "ls"})
assert p.tool_name == "Bash"

# Pydantic envelope
e = HookEvent(event="PreToolUse", payload={"tool_name": "Bash", "tool_input": {}})

Coverage

13 of the 19 hook events have typed payload classes (PreToolUsePayload, NotificationPayload, etc.). The remaining 6 events stay envelope-only — their CC payloads aren't documented enough to lock down: SessionEnd, Setup, InstructionsLoaded, WorktreeCreate, WorktreeRemove, ConfigChange.

Develop

cd packages/hook-contract-py
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
pytest -v
python scripts/codegen-py.py --check   # drift gate
python scripts/codegen-py.py           # regenerate from spec
mypy src/
ruff check src/ tests/

Why this package exists

The hook event surface is the contract between OrchestKit's TypeScript hook fan-out and any Python receiver (yonatan-hq/platform, custom analytics consumers). When the contracts drift, fields go missing in transit and observability lies. This package + the npm sibling both regenerate from one spec, eliminating that drift class.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

orchestkit_hook_contract-0.1.0.tar.gz (12.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

orchestkit_hook_contract-0.1.0-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

Details for the file orchestkit_hook_contract-0.1.0.tar.gz.

File metadata

  • Download URL: orchestkit_hook_contract-0.1.0.tar.gz
  • Upload date:
  • Size: 12.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for orchestkit_hook_contract-0.1.0.tar.gz
Algorithm Hash digest
SHA256 60cba72bb590cff5cff9599c8f67f448f732f524001aba73dc067ab2f7093085
MD5 041b6b1ac195081e1048acf1eead113d
BLAKE2b-256 cce2860e0774618de26500004d3ba4c2ed2b4c321dccb1ce9a2a01f0081db8f8

See more details on using hashes here.

Provenance

The following attestation bundles were made for orchestkit_hook_contract-0.1.0.tar.gz:

Publisher: publish-hook-contract-py.yml on yonatangross/orchestkit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file orchestkit_hook_contract-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for orchestkit_hook_contract-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1cc64ae2891c47cb0c04643f00d72c1be0399f63515ddba345622f20d4094101
MD5 62916d6cca96f2d3af1dad30bcf51644
BLAKE2b-256 651aaad0444abda8b9322373f05fd4e26f6b90c2cd5c9332547db8ea80fed734

See more details on using hashes here.

Provenance

The following attestation bundles were made for orchestkit_hook_contract-0.1.0-py3-none-any.whl:

Publisher: publish-hook-contract-py.yml on yonatangross/orchestkit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page