diteko (Python)
Generate, export and run tests for Amazon Connect contact flows, from Python. It is the testing counterpart to cxblueprint: build or export a flow, then let Diteko derive its grammar, generate test calls that aim to cover its outcomes (with Grammatical Evolution), export them, and run them on Connect's native testing.
This package is a client: it needs a Diteko server. It does nothing on its own. Point it at your team's Diteko, or start one on this machine with
diteko server up(it needs Docker; see https://github.com/Lehlohonolo-Sehako/diteko-selfhost).
The SDK talks to a running Diteko deployment over its REST API. If that deployment requires API
keys, set DITEKO_API_KEY (or pass api_key=); otherwise point the SDK only at a deployment
inside your network or behind your VPN.
pip install diteko # SDK
pip install "diteko[mcp]" # + MCP server for Claude Desktop / Cursor / VS Code
pip install "diteko[cxblueprint]"
Getting started
-
Find your Diteko. Diteko is self-hosted: you need the address of a running deployment. If you run your own (diteko-selfhost), that is
http://localhost:8080, which is also the SDK's default. To start one on this machine (with Docker installed):diteko server up # sets it up in ~/.diteko/server and starts it with Docker
It needs only Docker (Docker Desktop on macOS and Windows): the self-hosting files travel in this package, and the first start downloads the server image. The first time, it creates a
WRITEkey and prints the two settings to export (PowerShell syntax on Windows), plus the bootstrap ADMIN key for the console at the same address.diteko server statusandditeko server downdo what they say; data is kept between runs, and upgrading this package upgrades the server's files on the nextupwithout touching your settings.--portpicks another port,--latestuses the newest diteko-selfhost release instead of the files in this package, and--bundle patha self-hosting folder you already have. -
Get a key, if it asks for one. When a deployment requires API keys, whoever runs it creates one for you under Settings › API keys.
WRITEis enough for everything here except live runs on Connect. Put it in the environment:export DITEKO_URL=https://diteko.example.internal export DITEKO_API_KEY=dk_... # only if the deployment requires keys
-
Check the connection:
from diteko import Diteko dk = Diteko() # DITEKO_URL and DITEKO_API_KEY from the environment print(dk.version()) # {'api': '1.1', 'server': '…', 'auth': 'keys'} print(dk.whoami()) # the key in use, or None when keys are off
-
Run the example.
examples/cxblueprint_to_excel.py, also as a notebook, builds a flow with cxblueprint, evolves a suite and writes the Excel test script, in about a minute. Both ship in the source distribution:pip download --no-binary :all: --no-deps diteko, then unpack it.
Watching a run, and typed results
run = project.evolve(preset="standard").wait(progress=True) # one line on stderr, kept up to date
run = project.evolve(preset="standard").wait(progress=print) # or any callable, given a RunProgress
run.info.best_fitness, run.info.generation, run.info.generations
project.refresh().info # ProjectInfo: grammar, latest run, suite, last execution, typed
execution = suite.publish_to_connect(dry_run=True)
execution.results # [Verdict(test_id, status, message), ...]
execution.passed, execution.failed, execution.inconclusive # inconclusive: Connect could not start it, etc.
The pipeline
from diteko import Diteko
dk = Diteko("http://localhost:8080")
project = dk.projects.from_json("claims.json") # Connect export or cxblueprint output
project.grammar.generate() # derive, store and validate the grammar
run = project.evolve(preset="standard", focus="balanced").wait()
suite = run.suite(top=30, selection="coverage") # or selection="fitness"
for test in suite:
print(test.test_id, test.keys, test.fitness)
suite.connect_tests # the ones publish_to_connect() publishes (API 1.5+)
suite.export_xlsx("claims-tests.xlsx") # manual test script (ISO/IEC/IEEE 29119-3)
suite.export_native("claims-native.json") # Amazon Connect native test cases
result = suite.publish_to_connect(dry_run=True) # dry run unless you say otherwise
print(result.passed, result.failed, result.verdicts)
Straight from cxblueprint
from cxblueprint import Flow
from diteko import Diteko
flow = Flow.build("Burger Order")
menu = flow.get_input("Press 1 for Classic or 2 for Veggie", timeout=10)
# ... build the flow as usual ...
project = Diteko().projects.from_cxblueprint(flow) # compiles locally, uploads the JSON
Other ways in
dk.projects.import_from_connect("08e145dc-d959-4094-9021-6f10d8590be2") # from the instance
dk.projects.list() # every project and its next step
dk.projects.get(21601).suite(top=10).export_xlsx()
Grammars as BNF or JSON
The two forms are exact reflections of each other. Both are validated by the same parser, and both keep comments.
g = project.grammar.latest()
spec = g.to_json() # {"format": "diteko-grammar/v1", "start": ..., "rules": [...]}
g.replace(spec, format="json").save() # edit as JSON, store as canonical BNF
dk.convert_grammar(bnf_text, "bnf", "json")
Presets
preset |
calls × generations |
|---|---|
quick |
40 × 15 |
standard |
100 × 50 |
thorough |
200 × 120 |
focus |
favours |
|---|---|
balanced |
blocks and branches, plus happy paths and recoveries |
coverage |
visiting as much of the flow as possible |
errors |
timeouts and wrong keys that still end properly |
transfers |
calls that reach an agent queue |
Pass population=, generations=, weights={"state_coverage": 1.0} or seed= to go beyond them.
API keys
dk = Diteko("https://diteko.internal", api_key="dk_...") # or set DITEKO_API_KEY
dk.whoami() # {"name": "nightly CI", "prefix": "dk_...", "scope": "WRITE", ...}; None if keys are off
A key carries one scope: READ (see and export), WRITE (also create, run and dry-run),
PUBLISH_LIVE (also run on Connect for real, which is billed) or ADMIN (also manage keys).
Keys are created in the console under Settings, API keys.
Review flow changes in CI
diteko gate reviews flows deployed to a test Connect instance against their suites. It is meant for
a pull request's pipeline, after terraform apply or cdk deploy:
DITEKO_URL=https://diteko.internal.example.com DITEKO_API_KEY=dk_... \
diteko gate --flow <connect-flow-id-or-arn> --live --max-executions 20
Each flow is imported and validated, then compared with the flow its suite was evolved from. Only
the tests whose route passes through a changed block are dry-run and, with --live, run on Connect.
It writes diteko-gate/diteko-gate.json, junit.xml and summary.md, and exits 0 when every flow
passed or none changed, 1 when one failed, 2 when a budget stopped it, and 3 on a configuration
problem. The GitHub Action is Lehlohonolo-Sehako/diteko-selfhost/gate; the guide "Review flow
changes in CI" on the docs site has it, a CodeBuild and a GitLab example.
When the gate fails, diteko triage says why each failed live test failed. It reads the gate's
report and needs only a READ key:
diteko triage # reads diteko-gate/diteko-gate.json
Each test gets a verdict: flow_change (it failed at a block the change touched), test_at_fault
(it relies on a value it made up), environment (Connect could not start it, or the block depends on
the test instance) or inconclusive. The evidence behind each verdict is in
diteko-gate/diteko-triage.json, and triage.md is a summary for the pull request. Rules decide;
no model is called. Triage never changes the gate's verdict. In Python, diteko.triage.triage().
MCP server
DITEKO_URL=http://localhost:8080 DITEKO_API_KEY=dk_... diteko-mcp # the key only if the server requires one
{ "mcpServers": { "diteko": { "command": "diteko-mcp", "env": { "DITEKO_URL": "http://localhost:8080", "DITEKO_API_KEY": "dk_..." } } } }
| Tool | Does |
|---|---|
whoami |
the key in use and its scope, or that the server needs none |
list_projects |
every flow under test and its next step |
list_connect_flows |
the flows in the configured Connect instance, and which are already projects |
import_flow |
register a flow from JSON text, a file path, or a Connect flow id; returns its diagnostics (stable codes) and, from Connect, the import warnings such as REPLACED_FLOW |
diff_flow |
what changed in a flow, block by block, against flow JSON or the deployed flow (API 1.6) |
validate_flow |
a project's flow health: errors, warnings and coded diagnostics |
generate_grammar |
derive, store and validate a flow's grammar; returns valid, errors and the generator's warnings |
save_grammar |
replace a project's grammar with edited BNF and validate it; an invalid grammar comes back as errors, not a failure |
test_grammar |
derive one call from a stored grammar without running anything |
convert_grammar |
BNF ⇄ JSON |
start_evolution |
start a run (size, focus, seed) |
get_run |
a run's progress; a failed run adds error, the reason the server recorded |
list_tests |
a run's tests in rank order; connect_only=true lists exactly what publish_suite publishes |
export_suite |
xlsx, json or native to a file |
publish_suite |
start a run on Connect and return at once; dry_run defaults to true, since a live run bills the AWS account |
get_execution |
a Connect run's status and verdicts; poll it until the status is no longer RUNNING |
get_test_outcome |
one test's outcome in a Connect run, with the failure point as fields and Connect's records (API 1.6) |
list_connect_runs |
every publish of a run's suite to Connect, with its verdict counts |
Each tool carries MCP annotations: read-only tools say so, and the tools that reach Connect (import_flow with a Connect flow id, list_connect_flows, publish_suite) are marked as reaching an external system. Validation results come back as data (valid, errors, diagnostics), so an agent can read them and fix what they name. Works with mcp 1.x and 2.x.
Support Diteko
Diteko is free to run for your own organisation. If it saves your team time, you can sponsor it on GitHub; the docs list other ways to help.
Versioning
The package follows Semantic Versioning. See the release notes for what each release changed.
The server reports an API version, MAJOR.MINOR, at GET /api/version. A minor bump only adds endpoints or fields. A major bump changes something an existing client relies on. Each SDK release speaks one API major version, currently 1. On its first call the SDK checks the server's version:
| Server | What happens |
|---|---|
| API 1.x | Works. |
| Another major | DitekoError, saying whether to upgrade the SDK or the server |
| Too old to report a version | A warning, then it carries on |
| Not a Diteko server | DitekoError: check DITEKO_URL |
| Nothing answering | DitekoError saying a server is needed and how to point at one; the next call checks again |
Diteko(url, check_version=False) skips the check, and dk.version() returns what the server reports.
Development
cd clients/python
python -m venv .venv && . .venv/bin/activate
pip install -e ".[dev,mcp]"
pytest # against an in-memory fake of the API
DITEKO_URL=http://localhost:8888 pytest # also runs the live and contract tests against a local stack
Metadata
Release files for diteko 0.12.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| diteko-0.12.0.tar.gz | 85.0 kB | With provenance | Details for diteko-0.12.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| diteko-0.12.0-py3-none-any.whl | Python 3 | none | any | Details for diteko-0.12.0-py3-none-any.whl |
Total release size: 136.5 kB
Release files / diteko-0.12.0.tar.gz
| Download URL | diteko-0.12.0.tar.gz |
|---|---|
| Size | 85.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6743302bf15a38229b2b62d1d338a23c5d36ff3bcb892fbf810b99cf328cb880
|
|
BLAKE2b-256 checksum How to use checksums |
64e43c82a4e876ee139366e42bf101d70e957434caaeb49979d4ecebefa8b6f7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.
Transparency logRelease files / diteko-0.12.0-py3-none-any.whl
| Download URL | diteko-0.12.0-py3-none-any.whl |
|---|---|
| Size | 51.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e2f5be3c1165c57eac5578d7adf9930aec16f8c2020ec94a795c789660729252
|
|
BLAKE2b-256 checksum How to use checksums |
ac3eaee74d9fc5dbbfb4f324718877eb064956b114f3b7f212072b499875fcfd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.
Transparency logSecurity for diteko 0.12.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for diteko-0.12.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.