Skip to main content

token-sentinel-adapter

Host-agnostic adapter kernel for TokenSentinel.

Coding-agent hosts (Claude Code, Codex, and similar) convert vendor-specific events into AdapterEvent, call EngineHandle, and map Decision back to the host.

Rules live only in token-sentinel. This package does not reimplement them.

Install

pip install token-sentinel-adapter

Requires token-sentinel>=1.0.3,<2.

For local development against a source checkout of the engine:

pip install -e /path/to/tokensentinel-sdk-python -e .

Quick start

from token_sentinel_adapter import AdapterEvent, EngineHandle

engine = EngineHandle(project="my-app", preset="observe")  # observe | alert | strict

result = engine.handle(
    AdapterEvent(
        host="claude-code",
        host_event="PostToolUse",
        host_session_id="sess-123",
        agent_id="main",  # use host-provided id for subagents
        tool_name="Read",
        tool_input={"path": "app.py"},
    )
)
print(result.decision.action, result.decision.reason)
print(result.decision.to_wire())

Behavior

Concern Behavior
Multi-agent Rule windows are per (host_session_id, agent_id) — sibling agents do not pool
Health RuntimeStatus: healthy, degraded, or down
Strict mode May deny tools only when status is healthy
Engine All detection via token-sentinel

Presets

Preset Sentinel mode Denies tools?
observe log No
alert alert No
strict block Yes (when healthy)

Default coding rules: tool_loop, retry_storm, retrieval_thrash, context_bloat, zombie.

Status

0.1.0 — library kernel for host plugins. Optional long-lived HTTP sidecar can be added by host packages as needed.

License

Apache-2.0

Download files

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

Source Distribution

token_sentinel_adapter-0.1.0.tar.gz (18.7 kB view details)

Uploaded Source

Built Distribution

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

token_sentinel_adapter-0.1.0-py3-none-any.whl (21.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: token_sentinel_adapter-0.1.0.tar.gz
  • Upload date:
  • Size: 18.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for token_sentinel_adapter-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0a2fc2b863489a0e73b125d92c7557ea0a888a22eb490d2111c9d894b1c9e4e0
MD5 1cac4f04e3ac984469fe7fcaec4073d0
BLAKE2b-256 dea3abf0161c8d24daac3ca8aea466d89f7e68b91a5b8eba1631a43a15923b5c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for token_sentinel_adapter-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7b43d85f70df43eaca2cd6d0898a25bdb9e5c23ea1dcc7cd99d11ac75679cc14
MD5 d6d38b1b970ccdea33b5d93384ed28a7
BLAKE2b-256 e280859ba0314da5c378873c81285f1eabed7fc4343748dbfb4f5c5f35b9fa7e

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page