English · 简体中文 · 日本語 · Español · Português · 한국어
A middleware-style pipeline that authorizes, recognizes, redacts, and audits an owned visual QA fixture.
CapSolver is wrapped behind a mock-first boundary in this reference implementation. This repository applies the official Microsoft Agent Framework extension surface to ordered middleware stages with redaction before the result reaches an agent. The example is intentionally limited to a generated visual checkpoint from an owned QA environment.
- Separates authorization, recognition, redaction, and audit into ordered stages.
- Fails closed if a stage is invoked out of order.
- Hashes provider task IDs before returning a result.
- Emits a structured audit event without image data or credentials.
- Runs offline with an injected fixture recognizer.
A small context object moves through four middleware stages. Authorization records the approved scope, recognition calls the injected adapter, redaction minimizes the result, and audit records outcome and timestamp. Each stage asserts the state produced by its predecessor.
Only the recognition adapter knows the documented task payload; middleware carries a normalized result instead of the raw response. The field names and synchronous behavior are grounded in the official ImageToTextTask request and response contract and createTask operation.
agent tool request -> authorization middleware -> OCR adapter -> redaction -> audit event
Microsoft Agent Framework exposes middleware and workflow patterns, making ordered cross-cutting controls a natural integration boundary.
python -m venv .venv
source .venv/bin/activate
pip install -e '.[framework]'
PYTHONPATH=src python -m unittest discover -s tests -v
PYTHONPATH=src python examples/basic_usage.py
PYTHONPATH=src python -c 'import maf_qa_middleware; print(maf_qa_middleware.__version__)'The Microsoft Agent Framework quick start uses tests/fixtures/owned-qa.png; it does not load a browser session, API key, or external page.
Build the offline pipeline and pass an owned fixture plus its authorization reference:
result = run_middleware_pipeline(encoded_fixture, 'QA-MAF-12', FixtureRecognizer())The runnable Microsoft Agent Framework example in examples/basic_usage.py remains fully offline. A live client cannot be constructed until the operator supplies CAPSOLVER_API_KEY locally and deliberately sets CAPSOLVER_ALLOW_LIVE=1. Store the key outside the repository and agent context; the adapter still expects an approved authorization reference.
authorized=True
text=MAF-QA
audit.outcome=recognized
src/maf_qa_middleware/ core policy, client, tool, and workflow adapters
examples/ runnable mock-first demonstration
tests/unit/ rejection and configuration checks
tests/integration/ end-to-end flow with the bundled synthetic image
docs/ five localized README files
assets/cover.png shared English repository cover
Run the full offline suite with:
PYTHONPATH=src python -m unittest tests.unit.test_config tests.integration.test_mock_flow.GraphFlowTests -v
python -m compileall -q srcTests prove recognition cannot precede authorization and verify that the final audit event excludes encoded image data. No test instantiates an LLM, opens a browser, contacts the recognition endpoint, or reads a real credential.
- Preserve middleware order.
- Inspect the normalized context rather than the raw adapter response.
- Store audit events with a defined retention period.
Limit middleware input to approved fixtures, minimize audit fields, define retention and access controls, and never use the pipeline against restricted pages, private records, or third-party accounts. Stop immediately when authorization is withdrawn or the observed scope differs from the approved test plan.
Read CONTRIBUTING.md before changing the Microsoft Agent Framework adapter. Contributions must keep mock-first tests, explicit authorization, and bounded live execution.
Follow SECURITY.md when reporting an issue in the Microsoft Agent Framework integration. Treat image payloads, task identifiers, agent traces, and browser sessions as potentially sensitive even when the fixture is synthetic.
The pipeline turns authorization and redaction into explicit middleware stages instead of informal agent instructions, while the recognition contract stays aligned with CapSolver.
Developer sharing CapSolver integration examples.
MIT. See LICENSE.
