diff --git a/.plans/implemented/implementation_step_5.md b/.plans/implemented/implementation_step_5.md new file mode 100644 index 0000000..d0bce3c --- /dev/null +++ b/.plans/implemented/implementation_step_5.md @@ -0,0 +1,73 @@ +# Step 5: Agent harness installation, CLI, SDK, and MCP + +## Goal and dependency + +Make the context service easy to install and use from agent harnesses, locally first and with the same tools against a cloud service. Depends on stable storage, ingestion, retrieval, and memory operations from Steps 1–4. + +## Installable product + +- Publish a Python package with a stable CLI and `docling-context mcp` stdio entry point. Provide a remote HTTP MCP endpoint for deployments. +- Provide `docling-context integrate {codex,claude,hermes,pi}` with `--scope user|project` and `--mode local|remote`, plus `doctor` and `remove` operations. These are planned project commands, to be implemented in this step. +- Generate or update only this project's config entry. Preserve unrelated configuration, detect name conflicts, and make repeated installation idempotent. For project scope, create a reviewable project configuration file where the harness supports one; do not place credentials in it. +- Installation verifies the executable, MCP handshake, tool discovery, backend access, and one cited retrieval. `doctor` reports actionable failures; removal deletes only entries created by this installer. Test upgrade and rollback of generated configuration. +- Ship short harness-specific usage guidance so agents know when to call `search`, `outline`, and `show`, and how to retain URI/XPath citations. Keep memory capture opt-in and expose write tools explicitly. + +## Public service contract + +- Define a Python service layer with typed request/response objects for `list`, `tree`, `outline`, `show`, `search`, `ingest`, `job_status`, `session_append`, `memory_list`, `memory_review`, and `memory_recall`. +- `show` accepts a document URI, optional immutable revision, and XPath, then returns bounded DocLang XML or a structured representation with exact citation metadata. `outline` returns the TOC sidecar and node links. `search` returns matches and optional assembled context without silently changing tiers. +- Standardize errors: invalid URI/XPath, unauthorized scope, missing revision, stale citation, package failure, conversion failure, unsupported provider, and budget exceeded. Include stable machine-readable codes. +- Version the public request/response schema before adding network transport. Keep backend choice in configuration; callers use the same operations locally and with a deployed service. + +## Surfaces + +1. **Python SDK:** synchronous core operations, with asynchronous wrappers only where jobs or remote calls benefit. Return typed records rather than raw database rows. Keep package readers available for callers needing DocLang node operations. +2. **CLI:** commands such as `add`, `ls`, `tree`, `outline`, `show`, `find`, `jobs`, `sessions`, and `memories`. Provide human output and structured JSON output; bound tree depth and result count. `show` can emit DocLang XML, with no Markdown storage/export implied. +3. **MCP server:** expose read/search tools first. Define tool input schemas with URI, scope, XPath, tier, and limits. Add writes only with explicit authenticated principal and operation-specific authorization. Return citations and truncation markers in every content-bearing response. + +## Harness targets + +| Harness | Initial installation route | +| --- | --- | +| Codex | Register the MCP server through its CLI or configuration; evaluate a packaged plugin after direct installation works. | +| Claude Code | Register through `claude mcp` at user or project scope. | +| Hermes Agent | Manage a named `mcp_servers` entry in its configuration. | +| Pi | Register through built-in `pi mcp`; create a Pi package only if native Pi behavior adds value. | + +Each adapter supports a local stdio server. Where the harness supports it, also support the remote HTTP endpoint with appropriate authentication. Harness adapters remain thin: every tool calls the same service contract. Maintain a compatibility matrix with tested harness versions, install scope, transport, verification, and removal behavior. + +## Operational behavior + +- Do not accept a caller-provided tenant or user ID as authorization by itself. Derive the principal from local configuration or authenticated transport, then check scope in the service layer. +- Enforce timeouts and budgets around conversion, model calls, retrieval, and XML output. Expose job IDs for slow ingestion rather than holding an interactive request indefinitely. +- Log operation ID, URI scope, latency, index generation, and result count; omit document content and credentials from default logs. +- Package optional agent framework adapters separately after the SDK is stable; harness installation is part of this step and calls the public service layer without adding independent storage semantics. + +## Work sequence + +1. Freeze the Python service schema and shared error types; package the local service, CLI, and stdio MCP entry point. +2. Implement MCP read tools with the same contract and bounds, then authorized write tools. +3. Implement harness configuration adapters, `doctor`, and removal. Test a fresh local install in each harness with a small DCLX fixture. +4. Add remote HTTP setup and authentication checks. +5. Publish installation guides and a compatibility matrix. Add framework adapters only where a concrete integration test exists. + +## Acceptance checks + +- For the same fixture and principal, SDK, CLI JSON, and MCP return equivalent URIs, revisions, XPaths, and content bounds. +- Bad scopes, oversized results, invalid XPath, and missing packages produce the defined errors on every surface. +- A local installation runs ingest, outline, search, and cited `show` without credentials, network, or a cloud account. +- A long conversion returns a job ID and can be polled after process restart. +- A new user can install the package, run one integration command, restart each supported harness, and retrieve a cited DocLang node. +- User and project installs coexist without overwriting unrelated settings. Reinstall, upgrade, and removal behave predictably for all four harnesses. +- All four harnesses expose equivalent read tools and citation fields. Local setup requires no cloud account; remote setup does not put secrets in project configuration. + +## Exit artifact + +An installable local product and verified integrations for Codex, Claude Code, Hermes, and Pi whose public operations can be served by the cloud backend without a contract change. + +## Harness documentation to recheck at implementation time + +- [Codex MCP setup](https://developers.openai.com/learn/docs-mcp) +- [Claude Code MCP setup](https://code.claude.com/docs/en/mcp) +- [Hermes Agent MCP setup](https://hermes-agent.nousresearch.com/docs/user-guide/features/mcp/) +- [Pi MCP setup](https://pi.dev/docs/latest/mcp) diff --git a/README.md b/README.md index 819e468..ac65fe7 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ A local context tree that stores documents as immutable DocLang `.dclx` packages See the [capability guide](docs/index.md), [retrieval guide](docs/retrieval.md), [session guide](docs/sessions.md), [memory guide](docs/memory.md), +[agent harness guide](docs/agents.md), [CLI reference](docs/cli.md), and [single PDF and folder examples](examples/adding_resources/README.md). @@ -49,6 +50,8 @@ uv run --extra vectors dc --store ./context-data search "invoice" --mode hybrid uv run dc --store ./context-data session start --id chat-1 uv run dc --store ./context-data session list uv run dc --store ./context-data memory list --status proposed +uv run docling-context integrate codex --scope project --store ./context-data +uv run docling-context doctor codex --scope project --store ./context-data ``` Use `uv run dc` or activate the project environment before running `dc` by diff --git a/docs/agents.md b/docs/agents.md new file mode 100644 index 0000000..1672875 --- /dev/null +++ b/docs/agents.md @@ -0,0 +1,127 @@ +# Agent harness installation + +Install `docling-context` into a Python environment visible to the harness. The +package exposes `dc` for document work and `docling-context` for MCP serving and +harness integration. Local serving uses the same SQLite store and DCLX packages +as `dc`; no cloud account is needed. + +```bash +uv sync --extra conversion +uv run dc add-resource ./paper.pdf --collection papers +uv run docling-context integrate codex --scope project +uv run docling-context doctor codex --scope project +``` + +`integrate` launches a temporary MCP server and checks handshake, tool discovery, +backend listing, and one immutable citation when indexed content exists. Then it +adds a named `docling-context` entry to the harness configuration. Restart the +harness to load it. `doctor` repeats the checks; `remove` deletes only an entry +still owned by this installer. Existing entries with the same name are reported +as conflicts. Repeating `integrate` is safe, and changing options upgrades only +the owned entry. The installer writes a small ownership marker next to the +config; keep it alongside the config for future upgrades and removal. + +## Harnesses + +| Harness | Local version observed | User config | Project config | Local stdio | Remote HTTP | Verification | +| --- | --- | --- | --- | --- | --- | --- | +| Codex | 0.160.0 | `~/.codex/config.toml` | `.codex/config.toml` | Yes | Yes | Config test, MCP handshake, CLI lists entry | +| Claude Code | 2.1.278 | `~/.claude.json` | `.mcp.json` | Yes | Yes | Config test, MCP handshake, CLI sees entry pending project approval | +| Hermes Agent | 0.21.1 | `~/.hermes/config.yaml` | Unsupported by Hermes | Yes | Yes | Config test, MCP handshake, CLI lists entry | +| Pi | Not installed locally | `~/.pi/agent/mcp.json` | `.pi/mcp.json` | Yes | Yes | Config test and MCP SDK handshake; native CLI unverified | + +The config tests check preservation, repeat installs, upgrades, and removal. The +MCP handshake is tested with the Python MCP client; harness binaries are not +required for the test suite. Project configuration is reviewable in Git. +Codex and Pi may require project trust before loading project MCP entries. +Configuration paths and transports follow the current +[Codex](https://developers.openai.com/codex/mcp), +[Claude Code](https://code.claude.com/docs/en/mcp), +[Hermes](https://hermes-agent.nousresearch.com/docs/reference/mcp-config-reference/), +and [Pi](https://pi.dev/docs/latest/mcp) MCP guides. + +```bash +uv run docling-context integrate claude --scope user +uv run docling-context integrate hermes --scope user +uv run docling-context integrate pi --scope project +uv run docling-context remove pi --scope project +``` + +The local entry uses the absolute Python executable of the current environment. +Keep that environment installed and accessible after restarting the harness. +Use `--store PATH`, `--tenant ID`, and `--user ID` on `integrate` and `doctor` +to select a local store and principal. Those IDs select local scope; they are +not remote authentication credentials. If the chosen store has no indexed +document, `doctor` reports that cited retrieval could not be exercised. + +## Using the tools + +Ask the agent to call `search` with a narrow URI scope, inspect relevant +documents with `outline`, and call `show` using the returned document URI, +immutable `revision_id`, and XPath. Keep those three values with quoted text +for a reproducible citation. `show` accepts `format="xml"` for bounded DocLang +XML. `search(include_context=True)` also assembles the bounded cited hits into +one context string. `@toc:` and `@summary:` search paths refer to package +sidecars; `show` accepts those paths, and `outline` exposes the TOC links. +With a configured image-capable vector model, `search` accepts an optional +base64 image query (up to 2.5 MB) alongside query text. A text-only model +silently skips the image contribution. + +Read tools are on by default. Local write tools require `--allow-writes` on +`integrate` or `docling-context mcp`; write tools include `ingest`, +`session_append`, and `memory_review`. Memory capture remains opt-in. Each +operation checks the principal's tenant and user scope. The current local +principal comes from the server command, not from tool arguments. + +MCP `ingest` accepts base64 source bytes up to 2.5 MB and returns a durable job +ID. Run `docling-context ingest-worker` alongside the agent, or +`docling-context ingest-worker --once` for one job. `job_status` reports queued, +running, completed, or failed state and the resulting revision. Jobs survive +server and worker restarts. Larger documents can be imported with `dc +add-resource`, which converts synchronously and indexes the result. Use +`dc jobs status JOB_ID` to inspect either job type; add `--json` for a record. +Queued Docling conversions use a five-minute document timeout. + +## Remote service + +Run the HTTP service behind a TLS terminator and provide a bearer token in an +environment variable. The server binds that token to the configured tenant and +user; callers cannot substitute a principal in requests. The server refuses to +start without the token. + +```bash +export DOCLING_CONTEXT_TOKEN='your-deployment-token' +uv run docling-context mcp --transport http --host 127.0.0.1 --port 8765 \ + --store ./context-data --tenant team --user agent +uv run docling-context integrate codex --mode remote \ + --url https://context.example.com/mcp +``` + +`integrate` and `doctor` need the token in their own environment to verify the +remote MCP endpoint. Generated config contains only the variable name or +`${VARIABLE}` reference, never the token value. Remote write tools are enabled +only on the server with `--allow-writes`. Restrict the deployment token and use +separate server instances or authentication mappings for distinct principals. + +The same version 1 operations are available to Python through +`RemoteContextService` at `/v1/{operation}` and locally through +`ContextService`. For example: + +```python +from docling_context import ContextService, LocalContextStore, Principal, SearchRequest + +with LocalContextStore("./context-data") as store: + service = ContextService(store, Principal("team", "agent")) + hits = service.search(SearchRequest("Koonap", uri="docling://resources/papers")) + for hit in hits.data["hits"]: + print(hit["uri"], hit["revision_id"], hit["xpath"]) +``` + +For a deployment, use the same `SearchRequest` with +`RemoteContextService("https://context.example.com/mcp", token)`. The token +stays in the client process and is sent only as a bearer header. + +The HTTP API requires `schema_version: 1`, returns an operation ID, and uses +stable error codes such as `invalid_uri`, `unauthorized_scope`, +`missing_revision`, `stale_citation`, `package_failure`, and +`budget_exceeded`. Content-bearing responses mark truncation. diff --git a/docs/cli.md b/docs/cli.md index 00eb4a6..2cb07cf 100644 --- a/docs/cli.md +++ b/docs/cli.md @@ -11,6 +11,7 @@ uses the name `dc` on some machines. uv run --extra conversion dc --store ./context-data add-resource ./paper.pdf \ --collection papers --no-ocr --tables --no-charts uv run dc --store ./context-data task status JOB_ID +uv run dc --store ./context-data jobs status JOB_ID --json uv run dc --store ./context-data worker --once uv run dc --store ./context-data status uv run dc --store ./context-data index status @@ -21,12 +22,17 @@ uv run --extra vectors dc --store ./context-data index vector rebuild uv run --extra vectors dc --store ./context-data search "invoice" --mode hybrid uv run dc --store ./context-data ls docling://resources/ uv run dc --store ./context-data tree docling://resources/papers -L 2 +uv run dc --store ./context-data outline docling://resources/papers/paper +uv run dc --store ./context-data show docling://resources/papers/paper \ + '/doclang[1]/text[1]' --format xml --json uv run dc --store ./context-data find "invoice" --uri docling://resources/papers uv run dc --store ./context-data grep "total" --uri docling://resources/papers uv run dc --store ./context-data search "invoice" --uri docling://resources/papers uv run dc --store ./context-data session start --id chat-1 uv run dc --store ./context-data session list --status open uv run dc --store ./context-data memory list --status proposed +uv run docling-context integrate codex --scope project --store ./context-data +uv run docling-context doctor codex --scope project --store ./context-data ``` `add-resource` accepts one document or a folder of documents. With the @@ -51,6 +57,15 @@ job; `add-resource` prints the revision and its `task_id`. `task status` reports that job. Run `worker --once` for one due job, or `worker` continuously. A collection summary may remain stale until its latest job completes. +`outline URI` reads the TOC sidecar and `show URI XPATH` reads one cited node. +Use `--revision ID` for an immutable revision, `--format xml` for DocLang XML, +and `--max-chars N` to bound output. Both commands support `--json`; JSON +includes the URI, document ID, revision ID, XPath, and truncation marker. + +`docling-context` exposes the existing `dc` commands and adds `mcp`, +`integrate`, `doctor`, `remove`, and `ingest-worker`. See the +[agent harness guide](agents.md) for scopes, remote tokens, and verification. + Every `status` command prints a table by default. Pass `--json` for structured output, for example `dc status --json`, `dc task status JOB_ID --json`, or `dc index vector status --json`. diff --git a/docs/index.md b/docs/index.md index fc00c4e..bc55350 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,7 +1,7 @@ # Capabilities `docling-context` stores document revisions as DocLang DCLX packages and exposes -them through local Python and `dc` command-line APIs. +them through Python, `dc`, MCP, and authenticated HTTP APIs. | Capability | Current behavior | | --- | --- | @@ -16,6 +16,8 @@ them through local Python and `dc` command-line APIs. | Search | `dc search` provides scoped lexical, vector, and hybrid retrieval, including picture assets with an image-capable model | | Sessions | `dc session` records, lists, replays, closes, and purges revisioned event packages | | Durable memory | `dc memory` lists and reviews DCLX claims, runs compilation jobs, and supports scoped recall | +| Agent harnesses | One-command MCP integration for Codex, Claude Code, Hermes, and Pi | +| Public service | Versioned Python and authenticated HTTP operations for inspection, search, ingestion, jobs, sessions, and memory | `find` and `grep` retain their bounded substring scans. Indexed retrieval verifies citations against the current DCLX revision before returning text. @@ -27,4 +29,5 @@ verifies citations against the current DCLX revision before returning text. - [Storage and jobs](storage.md) - [Agent sessions](sessions.md) - [Durable memory](memory.md) +- [Agent harness installation and MCP](agents.md) - [Single PDF and folder examples](../examples/adding_resources/README.md) diff --git a/pyproject.toml b/pyproject.toml index caeeee5..c070aa6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,7 +19,15 @@ classifiers = [ "Topic :: Database", "Topic :: Text Processing :: Markup :: XML", ] -dependencies = ["doclang", "tabulate>=0.10,<1", "tqdm>=4.66,<5"] +dependencies = [ + "doclang", + "httpx>=0.27,<1", + "mcp>=1.20,<2", + "ruamel.yaml>=0.18,<1", + "tabulate>=0.10,<1", + "tomlkit>=0.13,<1", + "tqdm>=4.66,<5", +] [project.optional-dependencies] conversion = ["docling[rapidocr]>=2.134.0,<3"] @@ -33,6 +41,7 @@ vectors = [ [project.scripts] dc = "docling_context.cli:main" +docling-context = "docling_context.app:main" [project.urls] Repository = "https://github.com/docling-project/docling-context" diff --git a/src/docling_context/__init__.py b/src/docling_context/__init__.py index 1145c1b..d713e67 100644 --- a/src/docling_context/__init__.py +++ b/src/docling_context/__init__.py @@ -21,6 +21,7 @@ local_embedding_provider, stored_embedding_provider, ) +from .ingest_queue import IngestJob, IngestQueue from .ingestion import Ingestor, SummaryProvider from .jobs import CollectionStatus, CollectionWorker, Job from .local import LocalContextStore, RecordMissing, RevisionConflict @@ -36,7 +37,25 @@ TreeEntry, ) from .package import FilePackageStore, PackageError, PackageMissing +from .remote import RemoteContextService from .retrieval import ContextResult, RetrievalHit, Retriever, SearchScope +from .service import ( + SCHEMA_VERSION, + ContextService, + IngestRequest, + JobStatusRequest, + ListRequest, + MemoryListRequest, + MemoryRecallRequest, + MemoryReviewRequest, + OutlineRequest, + SearchRequest, + ServiceError, + ServiceResult, + SessionAppendRequest, + ShowRequest, + TreeRequest, +) from .sessions import SessionEvent, SessionInfo, SessionStore from .uri import AccessDenied, ContextURI, InvalidURI, authorize_uri, parse_uri from .vectors import EmbeddingProvider, TurbovecIndex, VectorIndex @@ -44,11 +63,13 @@ __all__ = [ "CLIP_MODEL", "DEFAULT_MODEL", + "SCHEMA_VERSION", "AccessDenied", "ChangeEvent", "CollectionStatus", "CollectionWorker", "ContextResult", + "ContextService", "ContextStore", "ContextURI", "ConversionResult", @@ -58,36 +79,52 @@ "EmbeddingProvider", "FastEmbedProvider", "FilePackageStore", + "IngestJob", + "IngestQueue", + "IngestRequest", "Ingestor", "InvalidURI", "Job", + "JobStatusRequest", + "ListRequest", "LocalContextStore", "LocalDoclingConverter", "MemoryCompiler", "MemoryContextStore", "MemoryJob", + "MemoryListRequest", + "MemoryRecallRequest", "MemoryRecord", + "MemoryReviewRequest", "MemoryService", "MlxEmbeddingProvider", "NodeAddress", "NodeContent", + "OutlineRequest", "PackageError", "PackageMissing", "PackageRef", "PdfConversionConfig", "Principal", "RecordMissing", + "RemoteContextService", "RetrievalHit", "Retriever", "RevisionConflict", + "SearchRequest", "SearchScope", + "ServiceError", + "ServiceResult", + "SessionAppendRequest", "SessionEvent", "SessionInfo", "SessionStore", + "ShowRequest", "SourceCitation", "SummaryProvider", "TenantScope", "TreeEntry", + "TreeRequest", "TurbovecIndex", "VectorIndex", "authorize_uri", diff --git a/src/docling_context/app.py b/src/docling_context/app.py new file mode 100644 index 0000000..af10f2f --- /dev/null +++ b/src/docling_context/app.py @@ -0,0 +1,325 @@ +"""Installable command for MCP serving and harness integration.""" + +from __future__ import annotations + +import argparse +import asyncio +import json +import os +import sys +from pathlib import Path + +from .ingest_queue import IngestQueue +from .integration import IntegrationSpec, config_path, inspect, integrate +from .local import LocalContextStore +from .mcp_server import authenticated_http_app, create_mcp +from .models import Principal +from .service import ContextService + + +def _spec(args: argparse.Namespace) -> IntegrationSpec: + return IntegrationSpec( + args.harness, + args.scope, + args.mode, + Path(args.project_root).resolve(), + Path(args.home).expanduser().resolve(), + Path(args.store).expanduser(), + args.tenant, + args.user, + args.url, + args.token_env, + args.allow_writes, + ) + + +async def _probe(spec: IntegrationSpec) -> dict[str, object]: + from mcp import ClientSession, StdioServerParameters + from mcp.client.stdio import stdio_client + from mcp.client.streamable_http import streamablehttp_client + + if spec.mode == "local": + command_args = [ + "-m", + "docling_context.app", + "mcp", + "--store", + str(spec.store.expanduser().resolve()), + "--tenant", + spec.tenant, + "--user", + spec.user, + ] + if spec.allow_writes: + command_args.append("--allow-writes") + transport = stdio_client( + StdioServerParameters(command=sys.executable, args=command_args) + ) + else: + token = os.environ.get(spec.token_env) + if not token: + raise ValueError(f"set {spec.token_env} before remote doctor") + assert spec.url is not None + transport = streamablehttp_client( + spec.url, + headers={"Authorization": f"Bearer {token}"}, + timeout=10, + ) + async with transport as streams, ClientSession(streams[0], streams[1]) as session: + handshake = await session.initialize() + available = await session.list_tools() + names = {tool.name for tool in available.tools} + needed = {"list_resources", "tree", "outline", "show", "search"} + if not needed <= names: + raise RuntimeError(f"missing MCP tools: {sorted(needed - names)}") + if spec.allow_writes and "ingest" not in names: + raise RuntimeError("MCP write tools were requested but not exposed") + listing = await session.call_tool( + "list_resources", {"uri": "docling://resources"} + ) + if listing.isError: + raise RuntimeError("backend listing failed") + result: dict[str, object] = { + "status": "ok", + "protocol": handshake.protocolVersion, + "tools": sorted(names), + "backend": "reachable", + } + if spec.mode == "local": + with LocalContextStore(spec.store.expanduser()) as store: + row = store.db.execute( + """SELECT r.uri,r.xpath,r.revision_id,r.text FROM retrieval_units r + JOIN documents d ON d.tenant_id=r.tenant_id AND d.uri=r.uri + WHERE r.tenant_id=? AND r.uri LIKE 'docling://resources/%' + AND d.available=1 AND d.revision_id=r.revision_id + AND r.xpath NOT LIKE '@%' AND length(r.text)>3 LIMIT 1""", + (spec.tenant,), + ).fetchone() + if row is not None: + cite = await session.call_tool( + "show", + { + "uri": row["uri"], + "xpath": row["xpath"], + "revision_id": row["revision_id"], + "max_chars": 256, + }, + ) + content = cite.structuredContent or {} + if ( + cite.isError + or "error" in content + or content.get("data", {}).get("revision_id") != row["revision_id"] + or content.get("data", {}).get("xpath") != row["xpath"] + ): + raise RuntimeError("cited retrieval failed") + result["citation"] = { + "uri": row["uri"], + "revision_id": row["revision_id"], + "xpath": row["xpath"], + } + else: + result["citation"] = "no indexed document available" + return result + + +def _parser() -> argparse.ArgumentParser: + parser = argparse.ArgumentParser(prog="docling-context") + commands = parser.add_subparsers(dest="command", required=True) + mcp = commands.add_parser("mcp", help="Run the local or remote MCP server") + mcp.add_argument( + "--transport", + choices=("stdio", "http"), + default="stdio", + help="MCP transport (default: stdio)", + ) + mcp.add_argument( + "--store", + default=os.environ.get( + "DOCLING_CONTEXT_STORE", "~/.local/share/docling-context" + ), + help="Local context store (default: ~/.local/share/docling-context)", + ) + mcp.add_argument( + "--tenant", + default=os.environ.get("DOCLING_CONTEXT_TENANT", "default"), + help="Principal tenant (default: default)", + ) + mcp.add_argument( + "--user", + default=os.environ.get("DOCLING_CONTEXT_USER", "local"), + help="Principal user (default: local)", + ) + mcp.add_argument( + "--host", default="127.0.0.1", help="HTTP bind address (default: loopback)" + ) + mcp.add_argument("--port", type=int, default=8765, help="HTTP port (default: 8765)") + mcp.add_argument( + "--token-env", + default="DOCLING_CONTEXT_TOKEN", + help="Bearer token environment variable for HTTP", + ) + mcp.add_argument( + "--allow-writes", + action="store_true", + help="Expose ingestion, session, and memory write tools", + ) + ingestion_worker = commands.add_parser( + "ingest-worker", help="Process durable document ingestion jobs" + ) + ingestion_worker.add_argument( + "--store", + default=os.environ.get( + "DOCLING_CONTEXT_STORE", "~/.local/share/docling-context" + ), + help="Local context store (default: ~/.local/share/docling-context)", + ) + ingestion_worker.add_argument( + "--once", action="store_true", help="Process one queued job then exit" + ) + for action in ("integrate", "doctor", "remove"): + sub = commands.add_parser( + action, help=f"{action.capitalize()} one harness MCP entry" + ) + sub.add_argument("harness", choices=("codex", "claude", "hermes", "pi")) + sub.add_argument( + "--scope", + choices=("user", "project"), + default="user", + help="Harness config scope (default: user)", + ) + sub.add_argument( + "--mode", + choices=("local", "remote"), + default="local", + help="MCP transport mode (default: local stdio)", + ) + sub.add_argument( + "--project-root", + default=".", + help="Project configuration root (default: current directory)", + ) + sub.add_argument("--home", default=str(Path.home()), help=argparse.SUPPRESS) + sub.add_argument( + "--store", + default=os.environ.get( + "DOCLING_CONTEXT_STORE", "~/.local/share/docling-context" + ), + help="Local context store (default: ~/.local/share/docling-context)", + ) + sub.add_argument( + "--tenant", + default=os.environ.get("DOCLING_CONTEXT_TENANT", "default"), + help="Local principal tenant (default: default)", + ) + sub.add_argument( + "--user", + default=os.environ.get("DOCLING_CONTEXT_USER", "local"), + help="Local principal user (default: local)", + ) + sub.add_argument("--url", help="Remote HTTPS MCP endpoint including /mcp") + sub.add_argument( + "--token-env", + default="DOCLING_CONTEXT_TOKEN", + help="Remote bearer token environment variable", + ) + sub.add_argument( + "--allow-writes", action="store_true", help="Enable local MCP write tools" + ) + return parser + + +def main(argv: list[str] | None = None) -> int: + argv = list(sys.argv[1:] if argv is None else argv) + if argv and argv[0] not in { + "mcp", + "ingest-worker", + "integrate", + "doctor", + "remove", + "-h", + "--help", + }: + from .cli import main as dc_main + + return dc_main(argv) + args = _parser().parse_args(argv) + try: + if args.command == "mcp": + store = LocalContextStore(Path(args.store).expanduser()) + service = ContextService(store, Principal(args.tenant, args.user)) + server = create_mcp( + service, + allow_writes=args.allow_writes, + host=args.host, + port=args.port, + ) + if args.transport == "stdio": + server.run(transport="stdio") + else: + token = os.environ.get(args.token_env) + if not token: + raise ValueError(f"set {args.token_env} before serving HTTP") + import uvicorn + + uvicorn.run( + authenticated_http_app( + server, token, service, allow_writes=args.allow_writes + ), + host=args.host, + port=args.port, + ) + store.close() + return 0 + if args.command == "ingest-worker": + with LocalContextStore(Path(args.store).expanduser()) as store: + queue = IngestQueue(store) + if args.once: + job = queue.run_once() + print(json.dumps(job.to_dict() if job else {"status": "idle"})) + else: + import time + + try: + while True: + if queue.run_once() is None: + time.sleep(1) + except KeyboardInterrupt: + pass + return 0 + spec = _spec(args) + result: dict[str, object] + if args.command == "integrate": + config_path(spec) + if spec.mode == "remote" and ( + spec.url is None or not spec.url.startswith("https://") + ): + raise ValueError("remote mode requires an HTTPS --url") + if spec.mode == "remote" and spec.allow_writes: + raise ValueError("configure write tools on the remote server") + probe = asyncio.run(_probe(spec)) + result = dict(integrate(spec)) + result["verification"] = probe + elif args.command == "remove": + result = dict(integrate(spec, remove=True)) + else: + result = dict(inspect(spec)) + if result["status"] == "configured": + result.update(asyncio.run(_probe(spec))) + print(json.dumps(result, sort_keys=True)) + return ( + 0 + if result["status"] + in {"ok", "installed", "updated", "current", "removed", "absent"} + else 1 + ) + except Exception as exc: # noqa: BLE001 - MCP clients raise exception groups + cause: BaseException = exc + while isinstance(cause, BaseExceptionGroup) and cause.exceptions: + cause = cause.exceptions[0] + print(f"docling-context: {cause}", file=sys.stderr) + return 1 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/src/docling_context/cli.py b/src/docling_context/cli.py index c3c10ce..8ec871a 100644 --- a/src/docling_context/cli.py +++ b/src/docling_context/cli.py @@ -573,6 +573,13 @@ def _parser() -> argparse.ArgumentParser: task_status.add_argument( "--json", action="store_true", help="Print JSON instead of a table." ) + jobs = commands.add_parser( + "jobs", help="Inspect durable ingestion or collection jobs" + ) + jobs_commands = jobs.add_subparsers(dest="jobs_command", required=True) + jobs_status = jobs_commands.add_parser("status", help="Show one job by ID") + jobs_status.add_argument("job_id") + jobs_status.add_argument("--json", action="store_true") worker = commands.add_parser("worker", help="Process queued collection summaries") worker.add_argument("--once", action="store_true") listing = commands.add_parser("ls", help="List direct children") @@ -580,6 +587,17 @@ def _parser() -> argparse.ArgumentParser: tree = commands.add_parser("tree", help="Walk a context subtree") tree.add_argument("uri") tree.add_argument("-L", "--depth", type=int, default=2) + outline = commands.add_parser("outline", help="Read a document TOC sidecar") + outline.add_argument("uri") + outline.add_argument("--revision", help="Immutable document revision") + outline.add_argument("--json", action="store_true") + show = commands.add_parser("show", help="Read one cited DocLang node") + show.add_argument("uri") + show.add_argument("xpath") + show.add_argument("--revision", help="Immutable document revision") + show.add_argument("--format", choices=("text", "xml"), default="text") + show.add_argument("--max-chars", type=int, default=8_192) + show.add_argument("--json", action="store_true") for name in ("find", "grep"): search = commands.add_parser(name, help="Bounded lexical lookup") search.add_argument("term") @@ -1147,11 +1165,46 @@ def main(argv: list[str] | None = None) -> int: elif args.command == "ls": for entry in store.list_children(principal, _prefix(args.uri)): _json(asdict(entry)) + elif args.command == "jobs": + from .service import ContextService, JobStatusRequest + + job_data = ( + ContextService(store, principal) + .job_status(JobStatusRequest(args.job_id)) + .data + ) + _status(job_data, json_output=args.json) elif args.command == "tree": for entry in store.walk( principal, _prefix(args.uri), depth=args.depth, limit=1_000 ): print(f"{' ' * (entry.depth - 1)}{entry.uri}") + elif args.command in {"outline", "show"}: + from .service import ContextService, OutlineRequest, ShowRequest + + service = ContextService(store, principal) + if args.command == "outline": + value = service.outline( + OutlineRequest(args.uri, args.revision) + ).data + if args.json: + _json(value) + else: + print(value["toc_xml"]) + else: + value = service.show( + ShowRequest( + args.uri, + args.xpath, + args.revision, + args.max_chars, + args.format, + ) + ).data + if args.json: + _json(value) + else: + print(value["content"]) elif args.command in {"find", "grep"}: hits = _scan(store, principal, args.term, _prefix(args.uri)) if args.command == "find": diff --git a/src/docling_context/ingest_queue.py b/src/docling_context/ingest_queue.py new file mode 100644 index 0000000..1a27e17 --- /dev/null +++ b/src/docling_context/ingest_queue.py @@ -0,0 +1,132 @@ +"""Durable, bounded ingestion requests processed outside interactive MCP calls.""" + +from __future__ import annotations + +import uuid +from dataclasses import asdict, dataclass +from datetime import UTC, datetime, timedelta + +from .conversion_config import PdfConversionConfig +from .converters import LocalDoclingConverter +from .ingestion import Ingestor +from .local import LocalContextStore +from .models import Principal +from .uri import authorize_uri, parse_uri + +MAX_QUEUED_BYTES = 2_500_000 + + +def _now() -> str: + return datetime.now(UTC).isoformat() + + +@dataclass(frozen=True, slots=True) +class IngestJob: + job_id: str + uri: str + status: str + revision_id: str | None + error: str | None + created_at: str + updated_at: str + + def to_dict(self) -> dict: + return asdict(self) + + +class IngestQueue: + def __init__(self, store: LocalContextStore): + self.store = store + + def submit( + self, + principal: Principal, + uri: str, + source: bytes, + filename: str, + *, + force: bool = False, + ) -> IngestJob: + address = parse_uri(uri) + authorize_uri(principal, address) + if not 0 < len(source) <= MAX_QUEUED_BYTES or not filename: + raise ValueError("queued source must be nonempty and at most 2.5 MB") + job_id, stamp = uuid.uuid4().hex, _now() + with self.store.transaction(): + self.store.db.execute( + """INSERT INTO ingest_jobs + (job_id,tenant_id,user_id,uri,filename,source,force,status, + created_at,updated_at) VALUES (?,?,?,?,?,?,?,'queued',?,?)""", + ( + job_id, + principal.tenant_id, + principal.user_id, + address.value, + filename, + source, + int(force), + stamp, + stamp, + ), + ) + return self.get(principal, job_id) + + def get(self, principal: Principal, job_id: str) -> IngestJob: + row = self.store.db.execute( + """SELECT * FROM ingest_jobs WHERE job_id=? AND tenant_id=? AND user_id=?""", + (job_id, principal.tenant_id, principal.user_id), + ).fetchone() + if row is None: + raise KeyError(job_id) + authorize_uri(principal, parse_uri(row["uri"])) + return IngestJob(*(row[field] for field in IngestJob.__dataclass_fields__)) + + def run_once(self) -> IngestJob | None: + stamp = _now() + lease = (datetime.now(UTC) + timedelta(minutes=30)).isoformat() + with self.store.transaction(): + row = self.store.db.execute( + """SELECT * FROM ingest_jobs WHERE status='queued' + OR (status='running' AND lease_until Path: + root = spec.project_root if spec.scope == "project" else spec.home + if spec.harness == "codex": + return root / ".codex" / "config.toml" + if spec.harness == "claude": + return root / (".mcp.json" if spec.scope == "project" else ".claude.json") + if spec.harness == "pi": + return ( + root / ".pi" / ("mcp.json" if spec.scope == "project" else "agent/mcp.json") + ) + if spec.harness == "hermes" and spec.scope == "user": + return root / ".hermes" / "config.yaml" + raise ValueError("unsupported harness or scope; Hermes supports user scope only") + + +def _entry(spec: IntegrationSpec) -> dict[str, Any]: + if spec.mode == "local": + args = [ + "-m", + "docling_context.app", + "mcp", + "--store", + str(spec.store.expanduser().resolve()), + "--tenant", + spec.tenant, + "--user", + spec.user, + ] + if spec.allow_writes: + args.append("--allow-writes") + return {"command": sys.executable, "args": args} + if spec.mode != "remote" or not spec.url or not spec.url.startswith("https://"): + raise ValueError("remote mode requires an HTTPS --url") + if spec.allow_writes: + raise ValueError( + "configure write tools on the remote server, not the client entry" + ) + if not spec.token_env.isidentifier(): + raise ValueError("token environment variable name is invalid") + if spec.harness == "codex": + return {"url": spec.url, "bearer_token_env_var": spec.token_env} + entry = { + "url": spec.url, + "headers": {"Authorization": f"Bearer ${{{spec.token_env}}}"}, + } + if spec.harness == "claude": + entry["type"] = "http" + return entry + + +def _digest(value: Any) -> str: + data = json.dumps(value, sort_keys=True, separators=(",", ":")).encode() + return hashlib.sha256(data).hexdigest() + + +def _atomic_write(path: Path, content: str) -> None: + path.parent.mkdir(parents=True, exist_ok=True) + descriptor, name = tempfile.mkstemp(prefix=f".{path.name}.", dir=path.parent) + try: + with os.fdopen(descriptor, "w", encoding="utf-8") as handle: + handle.write(content) + os.replace(name, path) + finally: + Path(name).unlink(missing_ok=True) + + +def _load(path: Path, harness: str) -> Any: + if not path.exists(): + return tomlkit.document() if harness == "codex" else {} + content = path.read_text(encoding="utf-8") + if harness == "codex": + return tomlkit.parse(content) + if harness == "hermes": + return YAML(typ="rt").load(content) or {} + return json.loads(content) + + +def _render(value: Any, harness: str) -> str: + if harness == "codex": + return tomlkit.dumps(value) + if harness == "hermes": + stream = io.StringIO() + YAML(typ="rt").dump(value, stream) + return stream.getvalue() + return json.dumps(value, indent=2, ensure_ascii=False) + "\n" + + +def _mapping(config: Any, harness: str) -> Any: + key = "mcp_servers" if harness in {"codex", "hermes"} else "mcpServers" + if key not in config: + config[key] = tomlkit.table() if harness == "codex" else {} + mapping = config[key] + if not hasattr(mapping, "get"): + raise ValueError(f"{key} must be a mapping") + return mapping + + +def _plain(value: Any) -> Any: + if isinstance(value, dict) or hasattr(value, "items"): + return {str(key): _plain(item) for key, item in value.items()} + if isinstance(value, (list, tuple)): + return [_plain(item) for item in value] + return value + + +def _marker(path: Path) -> Path: + return path.with_name(f".{path.name}.docling-context-managed.json") + + +def integrate(spec: IntegrationSpec, *, remove: bool = False) -> dict[str, str]: + path = config_path(spec) + marker = _marker(path) + config = _load(path, spec.harness) + mapping = _mapping(config, spec.harness) + current = _plain(mapping[NAME]) if NAME in mapping else None + owned = json.loads(marker.read_text()) if marker.exists() else None + if current is not None and ( + owned is None or _digest(current) != owned.get("digest") + ): + raise ValueError( + f"{path}: existing {NAME} entry is not managed by this installer" + ) + if remove: + if current is None: + return {"status": "absent", "path": str(path)} + del mapping[NAME] + _atomic_write(path, _render(config, spec.harness)) + marker.unlink(missing_ok=True) + return {"status": "removed", "path": str(path)} + entry = _entry(spec) + if current == entry: + return {"status": "current", "path": str(path)} + mapping[NAME] = entry + previous = path.read_text() if path.exists() else None + try: + _atomic_write(path, _render(config, spec.harness)) + _atomic_write(marker, json.dumps({"digest": _digest(entry)}, indent=2) + "\n") + except OSError: + if previous is not None: + _atomic_write(path, previous) + else: + path.unlink(missing_ok=True) + raise + return { + "status": "updated" if current is not None else "installed", + "path": str(path), + } + + +def inspect(spec: IntegrationSpec) -> dict[str, str]: + path = config_path(spec) + if not path.exists(): + return {"status": "missing", "path": str(path)} + config = _load(path, spec.harness) + mapping = _mapping(config, spec.harness) + if NAME not in mapping: + return {"status": "missing", "path": str(path)} + marker = _marker(path) + if not marker.exists() or _digest(_plain(mapping[NAME])) != json.loads( + marker.read_text() + ).get("digest"): + return {"status": "conflict", "path": str(path)} + return {"status": "configured", "path": str(path)} diff --git a/src/docling_context/local.py b/src/docling_context/local.py index d056ce6..e556730 100644 --- a/src/docling_context/local.py +++ b/src/docling_context/local.py @@ -53,7 +53,11 @@ def __init__(self, root: str | Path, *, reconcile_on_start: bool = True): self.root = Path(root) self.root.mkdir(parents=True, exist_ok=True) self.packages = FilePackageStore(self.root / "packages") - self.db = sqlite3.connect(self.root / "context.sqlite3", isolation_level=None) + self.db = sqlite3.connect( + self.root / "context.sqlite3", + isolation_level=None, + check_same_thread=False, + ) self.db.row_factory = sqlite3.Row self.db.execute("PRAGMA foreign_keys = ON") self.db.execute("PRAGMA journal_mode = WAL") @@ -72,7 +76,7 @@ def __exit__(self, *_: object) -> None: def _migrate(self) -> None: version = self.db.execute("PRAGMA user_version").fetchone()[0] - if version > 7: + if version > 8: raise RuntimeError("database schema is newer than this library") if version == 0: self.db.executescript( @@ -281,6 +285,21 @@ def _migrate(self) -> None: COMMIT; """ ) + if version < 8: + self.db.executescript( + """BEGIN IMMEDIATE; + CREATE TABLE IF NOT EXISTS ingest_jobs ( + job_id TEXT PRIMARY KEY, tenant_id TEXT NOT NULL, + user_id TEXT NOT NULL, uri TEXT NOT NULL, filename TEXT NOT NULL, + source BLOB NOT NULL, force INTEGER NOT NULL, + status TEXT NOT NULL, revision_id TEXT, error TEXT, + lease_until TEXT, created_at TEXT NOT NULL, updated_at TEXT NOT NULL + ); + CREATE INDEX IF NOT EXISTS ingest_jobs_due ON ingest_jobs (status, lease_until); + PRAGMA user_version = 8; + COMMIT; + """ + ) self._backfill_retrieval() def _backfill_retrieval(self) -> None: diff --git a/src/docling_context/mcp_server.py b/src/docling_context/mcp_server.py new file mode 100644 index 0000000..fd71d68 --- /dev/null +++ b/src/docling_context/mcp_server.py @@ -0,0 +1,291 @@ +"""MCP tools backed by the public context service.""" + +from __future__ import annotations + +import hmac +from collections.abc import Callable +from typing import Any + +from mcp.server.fastmcp import FastMCP +from starlette.middleware.base import BaseHTTPMiddleware +from starlette.requests import Request +from starlette.responses import JSONResponse +from starlette.routing import Route + +from .service import SCHEMA_VERSION, ContextService, call_service + + +def create_mcp( + service: ContextService, + *, + allow_writes: bool = False, + host: str = "127.0.0.1", + port: int = 8765, +) -> FastMCP: + server = FastMCP( + "docling-context", + host=host, + port=port, + stateless_http=True, + json_response=True, + log_level="ERROR", + instructions=( + "Use search to locate relevant DocLang nodes, outline to inspect a document, " + "and show with the returned URI, immutable revision_id, and XPath for exact " + "citations. Treat @toc and @summary paths as sidecar references. " + "Memory capture is opt-in." + ), + ) + + @server.tool() + def list_resources( + uri: str = "docling://resources", limit: int = 100 + ) -> dict[str, Any]: + """List direct children of an authorized context URI.""" + return call_service(service, "list", {"uri": uri, "limit": limit}) + + @server.tool() + def tree( + uri: str = "docling://resources", depth: int = 3, limit: int = 100 + ) -> dict[str, Any]: + """Walk a bounded context subtree.""" + return call_service( + service, "tree", {"uri": uri, "depth": depth, "limit": limit} + ) + + @server.tool() + def outline(uri: str, revision_id: str | None = None) -> dict[str, Any]: + """Read a document's TOC sidecar and node links.""" + return call_service( + service, "outline", {"uri": uri, "revision_id": revision_id} + ) + + @server.tool() + def show( + uri: str, + xpath: str, + revision_id: str | None = None, + max_chars: int = 8192, + format: str = "text", + ) -> dict[str, Any]: + """Read one cited DocLang node as bounded text or XML.""" + return call_service( + service, + "show", + { + "uri": uri, + "xpath": xpath, + "revision_id": revision_id, + "max_chars": max_chars, + "format": format, + }, + ) + + @server.tool() + def search( + query: str = "", + uri: str = "docling://resources", + limit: int = 10, + mode: str = "lexical", + xpath: str | None = None, + document_uri: str | None = None, + tiers: list[int] | None = None, + max_tokens: int = 2000, + per_result_tokens: int = 500, + include_context: bool = False, + image_base64: str | None = None, + ) -> dict[str, Any]: + """Search indexed DocLang nodes with exact URI, revision, and XPath citations.""" + return call_service( + service, + "search", + { + "query": query, + "uri": uri, + "limit": limit, + "mode": mode, + "xpath": xpath, + "document_uri": document_uri, + "tiers": tuple(tiers) if tiers is not None else (0, 1, 2), + "max_tokens": max_tokens, + "per_result_tokens": per_result_tokens, + "include_context": include_context, + "image_base64": image_base64, + }, + ) + + @server.tool() + def job_status(job_id: str) -> dict[str, Any]: + """Inspect a background collection job.""" + return call_service(service, "job_status", {"job_id": job_id}) + + if allow_writes: + + @server.tool() + def ingest( + uri: str, filename: str, data_base64: str, force: bool = False + ) -> dict[str, Any]: + """Import bounded base64 document bytes into an authorized resource URI.""" + return call_service( + service, + "ingest", + { + "uri": uri, + "filename": filename, + "data_base64": data_base64, + "force": force, + }, + ) + + @server.tool() + def session_append( + session_id: str, + key: str, + kind: str, + text: str, + turn_id: str = "", + ) -> dict[str, Any]: + """Append one idempotent event to the current user's session.""" + return call_service( + service, + "session_append", + { + "session_id": session_id, + "key": key, + "kind": kind, + "text": text, + "turn_id": turn_id, + }, + ) + + @server.tool() + def memory_review( + uri: str, + action: str, + reason: str = "", + claim: str | None = None, + ) -> dict[str, Any]: + """Accept, reject, delete, or correct a current user's memory.""" + return call_service( + service, + "memory_review", + { + "uri": uri, + "action": action, + "reason": reason, + "claim": claim, + }, + ) + + @server.tool() + def memory_list( + status: str | None = None, + kind: str | None = None, + limit: int = 100, + offset: int = 0, + ) -> dict[str, Any]: + """List memories, reconciling stale source citations.""" + return call_service( + service, + "memory_list", + { + "status": status, + "kind": kind, + "limit": limit, + "offset": offset, + }, + ) + + @server.tool() + def memory_recall( + session_id: str, query: str = "", limit: int = 10 + ) -> dict[str, Any]: + """Recall accepted memories once for the current user's session.""" + return call_service( + service, + "memory_recall", + { + "session_id": session_id, + "query": query, + "limit": limit, + }, + ) + + return server + + +def authenticated_http_app( + server: FastMCP, token: str, service: ContextService, *, allow_writes: bool = False +): + """Require one deployment token before any MCP HTTP request reaches the app.""" + if not token: + raise ValueError("remote MCP requires a nonempty bearer token") + app = server.streamable_http_app() + + async def operation(request: Request) -> JSONResponse: + try: + if not allow_writes and request.path_params["name"] in { + "ingest", + "session_append", + "memory_list", + "memory_review", + "memory_recall", + }: + return JSONResponse( + { + "schema_version": SCHEMA_VERSION, + "error": { + "code": "unauthorized_scope", + "message": "write operation is disabled", + }, + }, + status_code=403, + ) + payload = await request.json() + if payload.get("schema_version") != SCHEMA_VERSION: + return JSONResponse( + { + "schema_version": SCHEMA_VERSION, + "error": { + "code": "unsupported_schema", + "message": "schema version mismatch", + }, + }, + status_code=400, + ) + result = call_service( + service, request.path_params["name"], payload.get("data", {}) + ) + return JSONResponse(result, status_code=400 if "error" in result else 200) + except (TypeError, ValueError): + return JSONResponse( + { + "error": { + "code": "invalid_request", + "message": "invalid JSON request", + } + }, + status_code=400, + ) + + app.routes.append(Route("/v1/{name}", operation, methods=["POST"])) + + class BearerMiddleware(BaseHTTPMiddleware): + async def dispatch(self, request: Request, call_next: Callable): + supplied = request.headers.get("authorization", "") + if not hmac.compare_digest(supplied, f"Bearer {token}"): + return JSONResponse({"error": "unauthorized"}, status_code=401) + if request.method == "POST": + size = request.headers.get("content-length") + if size is not None and not size.isdecimal(): + return JSONResponse( + {"error": "invalid content length"}, status_code=400 + ) + if size is not None and int(size) > 4_194_304: + return JSONResponse({"error": "request too large"}, status_code=413) + if len(await request.body()) > 4_194_304: + return JSONResponse({"error": "request too large"}, status_code=413) + return await call_next(request) + + app.add_middleware(BearerMiddleware) + return app diff --git a/src/docling_context/remote.py b/src/docling_context/remote.py new file mode 100644 index 0000000..9156c37 --- /dev/null +++ b/src/docling_context/remote.py @@ -0,0 +1,112 @@ +"""Typed HTTP client for a deployed context service.""" + +from __future__ import annotations + +from dataclasses import asdict +from typing import Any, Self +from urllib.parse import urlparse + +import httpx + +from .service import ( + SCHEMA_VERSION, + IngestRequest, + JobStatusRequest, + ListRequest, + MemoryListRequest, + MemoryRecallRequest, + MemoryReviewRequest, + OutlineRequest, + SearchRequest, + ServiceError, + ServiceResult, + SessionAppendRequest, + ShowRequest, + TreeRequest, +) + + +class RemoteContextService: + """Call the same versioned operations through authenticated HTTP.""" + + def __init__( + self, + base_url: str, + token: str, + *, + timeout: float = 30, + client: httpx.Client | None = None, + ): + parsed = urlparse(base_url) + if parsed.scheme != "https" and not ( + parsed.scheme == "http" and parsed.hostname in {"127.0.0.1", "localhost"} + ): + raise ValueError("remote service URL must use HTTPS or loopback HTTP") + if not token: + raise ValueError("remote service needs a bearer token") + self.base_url = base_url.rstrip("/").removesuffix("/mcp") + self.token = token + self.timeout = timeout + self.client = client or httpx.Client() + self._owns_client = client is None + + def close(self) -> None: + if self._owns_client: + self.client.close() + + def __enter__(self) -> Self: + return self + + def __exit__(self, *_: object) -> None: + self.close() + + def _call(self, operation: str, request: Any) -> ServiceResult[Any]: + response = self.client.post( + f"{self.base_url}/v1/{operation}", + json={"schema_version": SCHEMA_VERSION, "data": asdict(request)}, + headers={"Authorization": f"Bearer {self.token}"}, + timeout=self.timeout, + ) + payload = response.json() + if "error" in payload: + error = payload["error"] + raise ServiceError(error["code"], error["message"]) + response.raise_for_status() + if payload.get("schema_version") != SCHEMA_VERSION: + raise ServiceError("unsupported_schema", "server schema version mismatch") + return ServiceResult( + payload["schema_version"], payload["operation_id"], payload["data"] + ) + + def list(self, request: ListRequest) -> ServiceResult[Any]: + return self._call("list", request) + + def tree(self, request: TreeRequest) -> ServiceResult[Any]: + return self._call("tree", request) + + def outline(self, request: OutlineRequest) -> ServiceResult[Any]: + return self._call("outline", request) + + def show(self, request: ShowRequest) -> ServiceResult[Any]: + return self._call("show", request) + + def search(self, request: SearchRequest) -> ServiceResult[Any]: + return self._call("search", request) + + def ingest(self, request: IngestRequest) -> ServiceResult[Any]: + return self._call("ingest", request) + + def job_status(self, request: JobStatusRequest) -> ServiceResult[Any]: + return self._call("job_status", request) + + def session_append(self, request: SessionAppendRequest) -> ServiceResult[Any]: + return self._call("session_append", request) + + def memory_list(self, request: MemoryListRequest) -> ServiceResult[Any]: + return self._call("memory_list", request) + + def memory_review(self, request: MemoryReviewRequest) -> ServiceResult[Any]: + return self._call("memory_review", request) + + def memory_recall(self, request: MemoryRecallRequest) -> ServiceResult[Any]: + return self._call("memory_recall", request) diff --git a/src/docling_context/service.py b/src/docling_context/service.py new file mode 100644 index 0000000..53c2400 --- /dev/null +++ b/src/docling_context/service.py @@ -0,0 +1,537 @@ +"""Versioned, principal-bound operations shared by the SDK and MCP surfaces.""" + +from __future__ import annotations + +import base64 +import binascii +import builtins +import logging +import re +import time +import uuid +import xml.etree.ElementTree as ET +from dataclasses import asdict, dataclass +from threading import RLock +from typing import Any + +from .durable_memory import MemoryService +from .ingest_queue import IngestQueue +from .jobs import CollectionWorker +from .local import LocalContextStore, RecordMissing +from .models import NodeAddress, Principal +from .package import MAX_NODE_TEXT_CHARS, PackageError, PackageMissing +from .retrieval import Retriever, SearchScope +from .sessions import SessionStore +from .uri import AccessDenied, InvalidURI, authorize_uri, parse_uri + +SCHEMA_VERSION = 1 +_LOG = logging.getLogger(__name__) +_XPATH_PART = re.compile(r"([A-Za-z][A-Za-z0-9_.-]*)\[([1-9][0-9]*)\]") + + +@dataclass(frozen=True, slots=True) +class ServiceResult[T]: + schema_version: int + operation_id: str + data: T + + def to_dict(self) -> dict[str, Any]: + return asdict(self) + + +class ServiceError(Exception): + def __init__(self, code: str, message: str): + super().__init__(message) + self.code = code + + def to_dict(self) -> dict[str, str]: + return {"code": self.code, "message": str(self)} + + +@dataclass(frozen=True, slots=True) +class ListRequest: + uri: str = "docling://resources" + limit: int = 100 + + +@dataclass(frozen=True, slots=True) +class TreeRequest: + uri: str = "docling://resources" + depth: int = 3 + limit: int = 100 + + +@dataclass(frozen=True, slots=True) +class OutlineRequest: + uri: str + revision_id: str | None = None + limit: int = 256 + + +@dataclass(frozen=True, slots=True) +class ShowRequest: + uri: str + xpath: str + revision_id: str | None = None + max_chars: int = 8_192 + format: str = "text" + + +@dataclass(frozen=True, slots=True) +class SearchRequest: + query: str = "" + uri: str = "docling://resources" + xpath: str | None = None + document_uri: str | None = None + tiers: tuple[int, ...] = (0, 1, 2) + limit: int = 10 + mode: str = "lexical" + max_tokens: int = 2_000 + per_result_tokens: int = 500 + include_context: bool = False + image_base64: str | None = None + + +@dataclass(frozen=True, slots=True) +class IngestRequest: + uri: str + filename: str + data_base64: str + force: bool = False + + +@dataclass(frozen=True, slots=True) +class JobStatusRequest: + job_id: str + + +@dataclass(frozen=True, slots=True) +class SessionAppendRequest: + session_id: str + key: str + kind: str + text: str + turn_id: str = "" + + +@dataclass(frozen=True, slots=True) +class MemoryListRequest: + status: str | None = None + kind: str | None = None + limit: int = 100 + offset: int = 0 + + +@dataclass(frozen=True, slots=True) +class MemoryReviewRequest: + uri: str + action: str + reason: str = "" + claim: str | None = None + + +@dataclass(frozen=True, slots=True) +class MemoryRecallRequest: + session_id: str + query: str = "" + limit: int = 10 + + +def _xml_node(xml: str, xpath: str) -> str: + parts = xpath.strip("/").split("/") + if not parts or parts[0] != "doclang[1]" or len(parts) > 256: + raise ServiceError("invalid_xpath", "XPath must begin with /doclang[1]") + root = ET.fromstring(xml) + current = root + for part in parts[1:]: + match = _XPATH_PART.fullmatch(part) + if match is None: + raise ServiceError("invalid_xpath", "XPath has an invalid segment") + name, ordinal = match.groups() + children = [child for child in current if child.tag.rsplit("}", 1)[-1] == name] + index = int(ordinal) - 1 + if index >= len(children): + raise ServiceError("stale_citation", "XPath is absent from this revision") + current = children[index] + return ET.tostring(current, encoding="unicode") + + +def _validate_xpath(xpath: str) -> None: + parts = xpath.strip("/").split("/") + if ( + not xpath.startswith("/doclang[1]") + or len(xpath) > 2_048 + or len(parts) > 256 + or parts[0] != "doclang[1]" + or any(_XPATH_PART.fullmatch(part) is None for part in parts[1:]) + ): + raise ServiceError("invalid_xpath", "invalid or oversized XPath") + + +class ContextService: + """Bind an authenticated principal before accepting operation requests.""" + + def __init__(self, store: LocalContextStore, principal: Principal): + self.store = store + self.principal = principal + self._lock = RLock() + + @staticmethod + def _result[T](data: T) -> ServiceResult[T]: + return ServiceResult(SCHEMA_VERSION, uuid.uuid4().hex, data) + + def _record(self, uri: str, revision_id: str | None = None): + address = parse_uri(uri) + authorize_uri(self.principal, address) + current = self.store.get_record(self.principal, address.value) + if revision_id is None or revision_id == current.revision_id: + return current + return self.store.get_revision( + self.principal, + NodeAddress(current.document_id, revision_id, "/doclang[1]"), + ) + + def list( + self, request: ListRequest + ) -> ServiceResult[builtins.list[dict[str, Any]]]: + if not 1 <= request.limit <= 1_000: + raise ServiceError("budget_exceeded", "list limit must be 1 to 1000") + return self._result( + [ + asdict(item) + for item in self.store.list_children( + self.principal, request.uri, request.limit + ) + ] + ) + + def tree( + self, request: TreeRequest + ) -> ServiceResult[builtins.list[dict[str, Any]]]: + if not 0 <= request.depth <= 10 or not 1 <= request.limit <= 1_000: + raise ServiceError("budget_exceeded", "tree depth or limit is too large") + return self._result( + [ + asdict(item) + for item in self.store.walk( + self.principal, request.uri, request.depth, request.limit + ) + ] + ) + + def outline(self, request: OutlineRequest) -> ServiceResult[dict[str, Any]]: + if not 1 <= request.limit <= 256: + raise ServiceError("budget_exceeded", "outline limit must be 1 to 256") + record = self._record(request.uri, request.revision_id) + from .package import load_package + + document = load_package(self.store.packages.get(record.package.sha256)) + toc = document.toc() + links = [] + if toc is not None: + for entry in ET.fromstring(toc.xml()).iter("entry"): + target = entry.get("xpath") + if target: + links.append(target) + xml = toc.xml() if toc is not None else "" + return self._result( + { + "uri": record.uri, + "document_id": record.document_id, + "revision_id": record.revision_id, + "toc_xml": xml[:65_536], + "links": links[: request.limit], + "truncated": len(xml) > 65_536 or len(links) > request.limit, + } + ) + + def show(self, request: ShowRequest) -> ServiceResult[dict[str, Any]]: + if not 1 <= request.max_chars <= MAX_NODE_TEXT_CHARS: + raise ServiceError("budget_exceeded", "show max_chars is out of bounds") + if request.format not in {"text", "xml"}: + raise ServiceError("invalid_request", "format must be text or xml") + sidecar = None + xpath = request.xpath + for name in ("summary", "toc"): + if xpath.startswith(f"@{name}:"): + sidecar = name + xpath = xpath[len(name) + 2 :] + break + _validate_xpath(xpath) + record = self._record(request.uri, request.revision_id) + address = NodeAddress(record.document_id, record.revision_id, xpath) + if sidecar is not None: + from .package import load_package + + document = load_package(self.store.packages.get(record.package.sha256)) + part = document.summary() if sidecar == "summary" else document.toc() + if part is None: + raise ServiceError("stale_citation", "sidecar is unavailable") + selected_xml = _xml_node(part.xml(), xpath) + value = ( + selected_xml + if request.format == "xml" + else "".join(ET.fromstring(selected_xml).itertext()) + ) + truncated = len(value) > request.max_chars + value = value[: request.max_chars] + page, bbox = None, None + elif request.format == "text": + node = self.store.read_node(self.principal, address, request.max_chars) + value, truncated = node.text, node.truncated + page, bbox = node.page, node.bbox + else: + from .package import load_package + + document = load_package(self.store.packages.get(record.package.sha256)) + value = _xml_node(document.xml(), xpath) + truncated = len(value) > request.max_chars + value = value[: request.max_chars] + page, bbox = None, None + return self._result( + { + "uri": record.uri, + "document_id": record.document_id, + "revision_id": record.revision_id, + "xpath": request.xpath, + "format": request.format, + "content": value, + "truncated": truncated, + "page": page, + "bbox": bbox, + } + ) + + def search(self, request: SearchRequest) -> ServiceResult[dict[str, Any]]: + if ( + not 1 <= request.limit <= 100 + or not 1 <= request.per_result_tokens <= request.max_tokens <= 20_000 + ): + raise ServiceError("budget_exceeded", "search limits are out of bounds") + image = None + if request.image_base64 is not None: + try: + image = base64.b64decode(request.image_base64, validate=True) + except (ValueError, binascii.Error) as exc: + raise ServiceError( + "invalid_request", "image_base64 is invalid" + ) from exc + if not image or len(image) > 2_500_000: + raise ServiceError("budget_exceeded", "image query exceeds 2.5 MB") + retriever = Retriever(self.store) + if request.mode in {"vector", "hybrid"}: + from .embeddings import stored_embedding_provider + + state = self.store.db.execute( + "SELECT model_id FROM vector_state WHERE singleton=1" + ).fetchone() + if state is None: + raise ServiceError( + "unsupported_provider", + "vector search needs a configured embedding provider", + ) + self.store.require_exclusive_vector_scope(self.principal) + retriever = Retriever( + self.store, embedder=stored_embedding_provider(state["model_id"]) + ) + started = time.monotonic() + scope = SearchScope( + request.uri, request.xpath, request.document_uri, request.tiers + ) + result = retriever.search( + self.principal, + request.query, + image=image, + scope=scope, + k=request.limit, + mode=request.mode, + max_tokens=request.max_tokens, + per_result_tokens=request.per_result_tokens, + ) + context = None + if request.include_context: + context = "\n\n".join( + f"[{hit.uri} @ {hit.revision_id} {hit.xpath}]\n{hit.text}" + for hit in result.hits + ) + return self._result( + { + "hits": [asdict(hit) for hit in result.hits], + "context": context, + "total_hits": result.total_hits, + "tokens_used": result.tokens_used, + "truncated": result.truncated, + "elapsed_ms": round((time.monotonic() - started) * 1_000), + } + ) + + def ingest(self, request: IngestRequest) -> ServiceResult[dict[str, Any]]: + try: + data = base64.b64decode(request.data_base64, validate=True) + except (ValueError, binascii.Error) as exc: + raise ServiceError("invalid_request", "data_base64 is invalid") from exc + job = IngestQueue(self.store).submit( + self.principal, + request.uri, + data, + request.filename, + force=request.force, + ) + return self._result(asdict(job)) + + def job_status(self, request: JobStatusRequest) -> ServiceResult[dict[str, Any]]: + try: + job = IngestQueue(self.store).get(self.principal, request.job_id) + data = asdict(job) + if job.status == "failed": + data["error_code"] = "conversion_failure" + return self._result(data) + except KeyError: + return self._result( + asdict( + CollectionWorker(self.store).get_job(self.principal, request.job_id) + ) + ) + + def session_append( + self, request: SessionAppendRequest + ) -> ServiceResult[dict[str, Any]]: + return self._result( + asdict( + SessionStore(self.store).append( + self.principal, + request.session_id, + key=request.key, + kind=request.kind, + text=request.text, + turn_id=request.turn_id, + ) + ) + ) + + def memory_list( + self, request: MemoryListRequest + ) -> ServiceResult[builtins.list[dict[str, Any]]]: + return self._result( + [ + asdict(item) + for item in MemoryService(self.store).list( + self.principal, + status=request.status, + kind=request.kind, + limit=request.limit, + offset=request.offset, + ) + ] + ) + + def memory_review( + self, request: MemoryReviewRequest + ) -> ServiceResult[dict[str, Any]]: + memory = MemoryService(self.store) + if request.action == "correct" and request.claim is not None: + record = memory.correct(self.principal, request.uri, request.claim) + elif request.action in {"accept", "reject", "delete"}: + record = memory.transition( + self.principal, + request.uri, + {"accept": "accepted", "reject": "rejected", "delete": "deleted"}[ + request.action + ], + reason=request.reason, + ) + else: + raise ServiceError("invalid_request", "unsupported memory review action") + return self._result(asdict(record)) + + def memory_recall( + self, request: MemoryRecallRequest + ) -> ServiceResult[builtins.list[dict[str, Any]]]: + return self._result( + [ + asdict(item) + for item in MemoryService(self.store).recall( + self.principal, + request.session_id, + request.query, + limit=request.limit, + ) + ] + ) + + +def call_service( + service: ContextService, operation: str, data: dict[str, Any] +) -> dict[str, Any]: + started = time.monotonic() + with service._lock: + result = _dispatch(service, operation, data) + payload = result.get("data") + if isinstance(payload, builtins.list): + count = len(payload) + elif isinstance(payload, dict): + count = len(payload.get("hits", ())) if "hits" in payload else 1 + else: + count = 0 + generation = service.store.db.execute( + "SELECT generation FROM vector_state WHERE singleton=1" + ).fetchone() + _LOG.info( + "operation_id=%s operation=%s uri_scope=%s latency_ms=%d index_generation=%s result_count=%d", + result["operation_id"], + operation, + data.get("uri", ""), + round((time.monotonic() - started) * 1_000), + generation["generation"] if generation else "none", + count, + ) + return result + + +def _dispatch( + service: ContextService, operation: str, data: dict[str, Any] +) -> dict[str, Any]: + """Dispatch one versioned request and return a stable error envelope.""" + requests = { + "list": ListRequest, + "tree": TreeRequest, + "outline": OutlineRequest, + "show": ShowRequest, + "search": SearchRequest, + "ingest": IngestRequest, + "job_status": JobStatusRequest, + "session_append": SessionAppendRequest, + "memory_list": MemoryListRequest, + "memory_review": MemoryReviewRequest, + "memory_recall": MemoryRecallRequest, + } + if operation not in requests: + return { + "schema_version": SCHEMA_VERSION, + "operation_id": uuid.uuid4().hex, + "error": {"code": "invalid_request", "message": "unknown operation"}, + } + try: + request = requests[operation](**data) + return getattr(service, operation)(request).to_dict() + except ServiceError as exc: + error = exc.to_dict() + except InvalidURI as exc: + error = {"code": "invalid_uri", "message": str(exc)} + except AccessDenied as exc: + error = {"code": "unauthorized_scope", "message": str(exc)} + except RecordMissing as exc: + error = {"code": "missing_revision", "message": str(exc)} + except PackageError as exc: + error = {"code": "package_failure", "message": str(exc)} + except PackageMissing as exc: + error = {"code": "package_failure", "message": str(exc)} + except (KeyError, FileNotFoundError) as exc: + error = {"code": "stale_citation", "message": str(exc)} + except (TypeError, ValueError) as exc: + error = {"code": "invalid_request", "message": str(exc)} + return { + "schema_version": SCHEMA_VERSION, + "operation_id": uuid.uuid4().hex, + "error": error, + } diff --git a/tests/test_ingestion_jobs.py b/tests/test_ingestion_jobs.py index 0471179..abd3950 100644 --- a/tests/test_ingestion_jobs.py +++ b/tests/test_ingestion_jobs.py @@ -292,5 +292,5 @@ def test_existing_database_upgrades_without_losing_documents(tmp_path): ) with LocalContextStore(tmp_path) as store: assert store.get_record(PRINCIPAL, URI).revision_id == original.revision_id - assert store.db.execute("PRAGMA user_version").fetchone()[0] == 7 + assert store.db.execute("PRAGMA user_version").fetchone()[0] == 8 assert len(CollectionWorker(store).jobs(PRINCIPAL, COLLECTION)) == 1 diff --git a/tests/test_integration.py b/tests/test_integration.py new file mode 100644 index 0000000..b090516 --- /dev/null +++ b/tests/test_integration.py @@ -0,0 +1,115 @@ +"""Harness installer preserves unrelated settings and owns its entry.""" + +from __future__ import annotations + +import json +from dataclasses import replace + +import pytest +from doclang import DocLangXDocument + +import docling_context.integration as integration_module +from docling_context.app import main as app_main +from docling_context.ingestion import Ingestor +from docling_context.integration import IntegrationSpec, config_path, inspect, integrate +from docling_context.local import LocalContextStore +from docling_context.models import Principal + + +@pytest.mark.parametrize("harness", ["codex", "claude", "hermes", "pi"]) +def test_user_install_upgrade_and_removal(tmp_path, harness): + spec = IntegrationSpec(harness, home=tmp_path, store=tmp_path / "store") + path = config_path(spec) + path.parent.mkdir(parents=True, exist_ok=True) + if harness == "codex": + original = '[mcp_servers.other]\ncommand = "other"\n' + elif harness == "hermes": + original = "mcp_servers:\n other:\n command: other\n" + else: + original = json.dumps({"mcpServers": {"other": {"command": "other"}}}) + path.write_text(original) + assert integrate(spec)["status"] == "installed" + assert inspect(spec)["status"] == "configured" + assert integrate(spec)["status"] == "current" + upgraded = replace(spec, tenant="new-tenant") + assert integrate(upgraded)["status"] == "updated" + assert integrate(upgraded, remove=True)["status"] == "removed" + assert "other" in path.read_text() + assert "docling-context" not in path.read_text() + + +@pytest.mark.parametrize("harness", ["codex", "claude", "pi"]) +def test_project_remote_uses_environment_token(tmp_path, harness): + spec = IntegrationSpec( + harness, + scope="project", + mode="remote", + project_root=tmp_path, + url="https://example.test/mcp", + token_env="PRIVATE_TOKEN", + ) + assert integrate(spec)["status"] == "installed" + text = config_path(spec).read_text() + assert "PRIVATE_TOKEN" in text + assert "Bearer secret" not in text + + +def test_unmanaged_entry_and_unsupported_scope(tmp_path): + spec = IntegrationSpec("pi", home=tmp_path) + path = config_path(spec) + path.parent.mkdir(parents=True) + path.write_text('{"mcpServers":{"docling-context":{"command":"other"}}}') + with pytest.raises(ValueError, match="not managed"): + integrate(spec) + assert "other" in path.read_text() + with pytest.raises(ValueError, match="Hermes supports user scope"): + integrate(IntegrationSpec("hermes", scope="project", project_root=tmp_path)) + + +def test_failed_upgrade_restores_previous_config(tmp_path, monkeypatch): + spec = IntegrationSpec("codex", home=tmp_path) + integrate(spec) + path = config_path(spec) + before = path.read_text() + original_write = integration_module._atomic_write + + def fail_marker(target, content): + if target.name.endswith(".docling-context-managed.json"): + raise OSError("simulated marker write failure") + original_write(target, content) + + monkeypatch.setattr(integration_module, "_atomic_write", fail_marker) + with pytest.raises(OSError, match="marker write failure"): + integrate(replace(spec, tenant="changed")) + assert path.read_text() == before + assert inspect(spec)["status"] == "configured" + + +@pytest.mark.parametrize("harness", ["codex", "claude", "hermes", "pi"]) +def test_cli_install_checks_cited_retrieval(tmp_path, harness, capsys): + document = DocLangXDocument() + assert document.read_xml("Karoo citation") + store_path = tmp_path / "store" + with LocalContextStore(store_path) as store: + Ingestor(store).add_resource( + Principal("default", "local"), + "docling://resources/articles/karoo", + document.write_bytes(), + filename="karoo.dclx", + ) + assert ( + app_main( + [ + "integrate", + harness, + "--home", + str(tmp_path / "home"), + "--store", + str(store_path), + ] + ) + == 0 + ) + result = json.loads(capsys.readouterr().out) + assert result["status"] == "installed" + assert result["verification"]["citation"]["xpath"] == "/doclang[1]/text[1]" diff --git a/tests/test_retrieval.py b/tests/test_retrieval.py index 64cfef2..9e379c9 100644 --- a/tests/test_retrieval.py +++ b/tests/test_retrieval.py @@ -496,7 +496,7 @@ def test_existing_retrieval_index_adds_picture_column_on_upgrade(tmp_path): "ALTER TABLE retrieval_units DROP COLUMN asset_path; PRAGMA user_version=4;" ) with LocalContextStore(tmp_path) as store: - assert store.db.execute("PRAGMA user_version").fetchone()[0] == 7 + assert store.db.execute("PRAGMA user_version").fetchone()[0] == 8 assert "asset_path" in { row["name"] for row in store.db.execute("PRAGMA table_info(retrieval_units)") diff --git a/tests/test_service_mcp.py b/tests/test_service_mcp.py new file mode 100644 index 0000000..74ae0e7 --- /dev/null +++ b/tests/test_service_mcp.py @@ -0,0 +1,243 @@ +"""Public service, MCP, and durable import behavior.""" + +from __future__ import annotations + +import asyncio +import base64 +import json + +from doclang import DocLangXDocument +from starlette.testclient import TestClient + +from docling_context.cli import main as dc_main +from docling_context.ingest_queue import IngestQueue +from docling_context.ingestion import Ingestor +from docling_context.local import LocalContextStore +from docling_context.mcp_server import authenticated_http_app, create_mcp +from docling_context.models import Principal +from docling_context.remote import RemoteContextService +from docling_context.service import ( + ContextService, + IngestRequest, + JobStatusRequest, + ListRequest, + OutlineRequest, + SearchRequest, + ShowRequest, + call_service, +) + +URI = "docling://resources/articles/karoo" +PRINCIPAL = Principal("tenant-a", "alice") + + +def _package() -> bytes: + document = DocLangXDocument() + assert document.read_xml( + "KarooKoonap Formation" + ) + return document.write_bytes() + + +def test_service_citations_survive_worker_restart(tmp_path, capsys): + with LocalContextStore(tmp_path) as store: + service = ContextService(store, PRINCIPAL) + queued = service.ingest( + IngestRequest(URI, "karoo.dclx", base64.b64encode(_package()).decode()) + ).data + assert queued["status"] == "queued" + assert store.db.execute("SELECT COUNT(*) FROM documents").fetchone()[0] == 0 + with LocalContextStore(tmp_path) as store: + finished = IngestQueue(store).run_once() + assert finished is not None and finished.status == "completed" + service = ContextService(store, PRINCIPAL) + job = service.job_status(JobStatusRequest(queued["job_id"])).data + assert job["revision_id"] == finished.revision_id + assert ( + dc_main( + [ + "--store", + str(tmp_path), + "--tenant", + PRINCIPAL.tenant_id, + "--user", + PRINCIPAL.user_id, + "jobs", + "status", + queued["job_id"], + "--json", + ] + ) + == 0 + ) + assert ( + json.loads(capsys.readouterr().out)["revision_id"] == finished.revision_id + ) + outline = service.outline(OutlineRequest(URI)).data + assert outline["links"] == ["/doclang[1]/heading[1]"] + search = service.search( + SearchRequest("Koonap", uri=URI, include_context=True) + ).data + assert search["hits"][0]["revision_id"] == finished.revision_id + assert "Koonap Formation" in search["context"] + assert ( + service.show( + ShowRequest(URI, "@toc:/doclang[1]/toc[1]/entry[1]/description[1]") + ).data["content"] + == "Karoo" + ) + assert ( + "Karoo" + in service.show(ShowRequest(URI, "@summary:/doclang[1]/text[1]")).data[ + "content" + ] + ) + citation = service.show( + ShowRequest(URI, "/doclang[1]/text[1]", finished.revision_id) + ).data + assert citation["content"] == "Koonap Formation" + assert ( + dc_main( + [ + "--store", + str(tmp_path), + "--tenant", + PRINCIPAL.tenant_id, + "--user", + PRINCIPAL.user_id, + "show", + URI, + "/doclang[1]/text[1]", + "--revision", + finished.revision_id, + "--json", + ] + ) + == 0 + ) + cli_citation = json.loads(capsys.readouterr().out) + assert { + key: cli_citation[key] + for key in ("uri", "revision_id", "xpath", "content", "truncated") + } == { + key: citation[key] + for key in ("uri", "revision_id", "xpath", "content", "truncated") + } + assert ( + "Koonap Formation" + in service.show(ShowRequest(URI, "/doclang[1]/text[1]", format="xml")).data[ + "content" + ] + ) + assert ( + call_service( + service, "show", {"uri": URI, "xpath": "/doclang[1]/text[99]"} + )["error"]["code"] + == "stale_citation" + ) + assert ( + call_service(service, "show", {"uri": URI, "xpath": "//text"})["error"][ + "code" + ] + == "invalid_xpath" + ) + assert ( + call_service( + service, + "show", + {"uri": URI, "xpath": "/doclang[1]/text[1]", "max_chars": 100_000}, + )["error"]["code"] + == "budget_exceeded" + ) + assert ( + call_service( + service, "list", {"uri": "docling://users/tenant-a/bob/memories"} + )["error"]["code"] + == "unauthorized_scope" + ) + assert ( + call_service(service, "search", {"query": "Karoo", "image_base64": "bad!"})[ + "error" + ]["code"] + == "invalid_request" + ) + + +def test_mcp_tools_and_http_token(tmp_path): + with LocalContextStore(tmp_path) as store: + record = Ingestor(store).add_resource( + PRINCIPAL, URI, _package(), filename="karoo.dclx" + ) + service = ContextService(store, PRINCIPAL) + server = create_mcp(service) + names = {tool.name for tool in asyncio.run(server.list_tools())} + assert {"search", "outline", "show", "tree", "list_resources"} <= names + assert "ingest" not in names + writable = create_mcp(service, allow_writes=True) + assert "ingest" in {tool.name for tool in asyncio.run(writable.list_tools())} + result = asyncio.run( + server.call_tool( + "show", + { + "uri": URI, + "xpath": "/doclang[1]/text[1]", + "revision_id": record.revision_id, + }, + ) + ) + assert isinstance(result, tuple) + assert result[1]["data"]["content"] == "Koonap Formation" + app = authenticated_http_app(server, "secret", service) + with TestClient(app, base_url="http://127.0.0.1:8765") as client: + assert client.post("/mcp", json={}).status_code == 401 + assert ( + client.post( + "/mcp", headers={"Authorization": "Bearer wrong"}, json={} + ).status_code + == 401 + ) + assert client.post("/v1/list", json={}).status_code == 401 + denied = client.post( + "/v1/ingest", + headers={"Authorization": "Bearer secret"}, + json={"schema_version": 1, "data": {}}, + ) + assert denied.status_code == 403 + mcp_headers = { + "Authorization": "Bearer secret", + "Accept": "application/json, text/event-stream", + "Content-Type": "application/json", + } + initialized = client.post( + "/mcp", + headers=mcp_headers, + json={ + "jsonrpc": "2.0", + "id": 1, + "method": "initialize", + "params": { + "protocolVersion": "2025-11-25", + "capabilities": {}, + "clientInfo": {"name": "test", "version": "1"}, + }, + }, + ) + assert initialized.status_code == 200 + assert ( + initialized.json()["result"]["serverInfo"]["name"] == "docling-context" + ) + remote = RemoteContextService( + "https://example.test", "secret", client=client + ) + assert remote.list(ListRequest()).data == service.list(ListRequest()).data + + +def test_failed_ingest_reports_stable_conversion_code(tmp_path): + with LocalContextStore(tmp_path) as store: + service = ContextService(store, PRINCIPAL) + queued = service.ingest( + IngestRequest(URI, "broken.dclx", base64.b64encode(b"broken").decode()) + ).data + assert IngestQueue(store).run_once().status == "failed" + status = service.job_status(JobStatusRequest(queued["job_id"])).data + assert status["error_code"] == "conversion_failure" diff --git a/uv.lock b/uv.lock index 3ba31f1..69c8b9e 100644 --- a/uv.lock +++ b/uv.lock @@ -135,6 +135,91 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/0b/a7/71ac2cff56fec219ed242bb11b8efb69fcc4bec75db06fb7bfe35de520e6/certifi-2026.7.22-py3-none-any.whl", hash = "sha256:62f22742b58a1a33014a2b6b706588a8d7e2a88ae7bd1a6ebe8c992928483775", size = 136983, upload-time = "2026-07-22T03:35:11.276Z" }, ] +[[package]] +name = "cffi" +version = "2.1.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "pycparser", marker = "implementation_name != 'PyPy'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/9e/ef/008a1939e372c06329a3fce4279c02f328488f3526744906eeec3da7ad5f/cffi-2.1.1.tar.gz", hash = "sha256:dd31f52ea1086513bb9df30f8fcee9b8918323ae067a3d5b78bc826a000712be", size = 530807, upload-time = "2026-08-03T21:21:18.939Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/10/69/43965eccfdead3b9220015fd1320e117be8c6ed01a62ffab76eeb752f5d5/cffi-2.1.1-cp312-cp312-macosx_10_15_x86_64.whl", hash = "sha256:c8c69575568085ba0b1b10c0249d779a214aea6f6522e949a0fc9fb0fcb449d0", size = 184821, upload-time = "2026-08-03T21:19:44.887Z" }, + { url = "https://files.pythonhosted.org/packages/54/7d/16e5a096677b5e313ca80cd5e5170efa3ea44624a82bb111925522da64b1/cffi-2.1.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:f81b3b8f3d4e343550fa4baa0e479bba9f2d29ce9c2e9b51d1ce1718d7442fcf", size = 184719, upload-time = "2026-08-03T21:19:46.129Z" }, + { url = "https://files.pythonhosted.org/packages/56/e6/8941622732edec876dd17d0453dce07317ae96db34f2ec1436c9d3785986/cffi-2.1.1-cp312-cp312-manylinux1_i686.manylinux2014_i686.manylinux_2_17_i686.manylinux_2_5_i686.whl", hash = "sha256:811bd1e21d32de12efca32393a0ab3f5133b54fce9bd44b8bd77ab07da14bf6a", size = 214799, upload-time = "2026-08-03T21:19:47.218Z" }, + { url = "https://files.pythonhosted.org/packages/44/de/f98430906df1545ffde0d543dd124a7a439bc2cd32b36b9c53f805df7333/cffi-2.1.1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:68e62fe11f30d5ca8289242866f0a5291402d8529ca2178ab8afc5c9694ae890", size = 222389, upload-time = "2026-08-03T21:19:48.331Z" }, + { url = "https://files.pythonhosted.org/packages/6a/5b/717f1526b9957b34456313c31645c5b82b8fb5c3fe9e4752999be7128bfc/cffi-2.1.1-cp312-cp312-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:4a7c934f7360e8cd64fe9efadcbd10c7c6364f531e432b9a4bf5ccbc9e0e8b50", size = 210249, upload-time = "2026-08-03T21:19:49.543Z" }, + { url = "https://files.pythonhosted.org/packages/64/b3/f8aa4f3e34986c7e4ec45072d1b1b9dd295b6b18007b45518d79726dd725/cffi-2.1.1-cp312-cp312-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:3143d81e29e1e20a9ce10901ec369012947876596f75a222235965f2b7ae832e", size = 208775, upload-time = "2026-08-03T21:19:50.918Z" }, + { url = "https://files.pythonhosted.org/packages/b1/db/dceb9dd5b231e1da801793f8acc9f3c52a7e1afe40bb1aae37e02b0faad5/cffi-2.1.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:c1453022f490d2459a11819d83ad1d586e9ff65a12ac3e705ffebd46d3685dcf", size = 221822, upload-time = "2026-08-03T21:19:52.054Z" }, + { url = "https://files.pythonhosted.org/packages/a0/d2/6cd24ae3be000a634109c247d1475d62e5616d0dc78c82770942ec384248/cffi-2.1.1-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:208f941bb9d18e768138677f0a6d2ce01f590df56043dda1df1535ac57c88517", size = 225232, upload-time = "2026-08-03T21:19:53.109Z" }, + { url = "https://files.pythonhosted.org/packages/cb/52/3fa190537004dd7f0ab860a6dc7c0175b8667f68d1e618a46f5498d30250/cffi-2.1.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:210019b6c7cf07f081b4c54635c8cf744377001350e29cc0f81c4377b4797735", size = 223597, upload-time = "2026-08-03T21:19:54.515Z" }, + { url = "https://files.pythonhosted.org/packages/80/fb/0bb75b7039588c074b37ae99f40d9bfddf990ecb2fbc346ebccd2e56b9be/cffi-2.1.1-cp312-cp312-win32.whl", hash = "sha256:046bfc24911b37851ee1b51aab8bffe713d89c68c6a057b09484ce9fd5f69b4e", size = 175292, upload-time = "2026-08-03T21:19:55.566Z" }, + { url = "https://files.pythonhosted.org/packages/d9/79/615cc094e2fb508cade7de88d3b4f6c4ec2bab695c97bce9153dc65aadf5/cffi-2.1.1-cp312-cp312-win_amd64.whl", hash = "sha256:f53e442b08449d42821fa4a4fba000095af9f62742a500f978a9f557ec44339a", size = 185919, upload-time = "2026-08-03T21:19:56.89Z" }, + { url = "https://files.pythonhosted.org/packages/70/c6/d0ea84713fe46b243a436a18fcd47d639732747e21635c8a27191b06dc30/cffi-2.1.1-cp312-cp312-win_arm64.whl", hash = "sha256:7bde5e4cc5c10140859842b9d383af292b22639a4dffb725314baf45968cef80", size = 180093, upload-time = "2026-08-03T21:19:58.155Z" }, + { url = "https://files.pythonhosted.org/packages/9d/f4/035513d4117049066b4779dc3b7c0c0fdad175fa13731c9f4003f1cd1478/cffi-2.1.1-cp313-cp313-ios_13_0_arm64_iphoneos.whl", hash = "sha256:b5bdfd1c873d4e093aabc0ca84c4ca6dbc4f752afb5c86f146d9742580c9da2e", size = 194248, upload-time = "2026-08-03T21:19:59.399Z" }, + { url = "https://files.pythonhosted.org/packages/76/af/2aeb4dbb5fc41a04161ae9ff1518de7cec08e164f44a8ce6a4cf7fd2cd1d/cffi-2.1.1-cp313-cp313-ios_13_0_arm64_iphonesimulator.whl", hash = "sha256:31348097ff5bbe827ccc41795d4dd099d9f0625e7def00ee653c137a490c2a6c", size = 196908, upload-time = "2026-08-03T21:20:00.746Z" }, + { url = "https://files.pythonhosted.org/packages/a7/46/2e5fdde8555706dd98139a910ca11be02809f3f605ce956f655d0214e100/cffi-2.1.1-cp313-cp313-macosx_10_15_x86_64.whl", hash = "sha256:9d2055050ea716bd38b7f7f1579c275386646b4894c155a3e2f3cd62ed41b7c6", size = 184805, upload-time = "2026-08-03T21:20:02.02Z" }, + { url = "https://files.pythonhosted.org/packages/55/41/4c7042f317b9217502988f0873af87e16ad606dc20f84e546e3e6ce9764c/cffi-2.1.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:19ee6127ee34de7d83ce3d371ebc5ed91addbdcc39f9ab15ce4eb35a4e534971", size = 184764, upload-time = "2026-08-03T21:20:03.141Z" }, + { url = "https://files.pythonhosted.org/packages/43/1f/1c3d90d91811c8f86ced9ed637956c54bfe5b79ca98fe976d7f8c8979f6b/cffi-2.1.1-cp313-cp313-manylinux1_i686.manylinux2014_i686.manylinux_2_17_i686.manylinux_2_5_i686.whl", hash = "sha256:6a8dddef476fab96d066d578fc88526767b836ab5ab21754e1d5bf3879c31c7c", size = 214722, upload-time = "2026-08-03T21:20:04.377Z" }, + { url = "https://files.pythonhosted.org/packages/37/6f/3b5ce4c3b2192d250f04908f2bfd91ef34552ec8f7716a5d4abdb8d67bb2/cffi-2.1.1-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:f16c709686a78c727bbbf059f92b0bf41c6fc60deec706d2dc19f529175a6125", size = 222369, upload-time = "2026-08-03T21:20:05.544Z" }, + { url = "https://files.pythonhosted.org/packages/02/10/4b3c75dde3d9663c9e02ba05c2668b954f671d4bbe346413ca8c696b295a/cffi-2.1.1-cp313-cp313-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:fcd22650c908d7b7da162bbfaab594a1227a15d1643a98c68b122ac642fa2264", size = 210175, upload-time = "2026-08-03T21:20:06.75Z" }, + { url = "https://files.pythonhosted.org/packages/df/62/14f74b9543e605d17701dc797b815958b8bb70b7624ce1b832ddad48ed6c/cffi-2.1.1-cp313-cp313-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:aa9511c62d14da7aacc9b4bf51f3f697a621e83b2d6919008243c3aad168eea3", size = 208670, upload-time = "2026-08-03T21:20:08.04Z" }, + { url = "https://files.pythonhosted.org/packages/95/95/86342356ff5953b3fb06f7ef7c5bee212d45e770abc7218d451b9148313c/cffi-2.1.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:a931079504ecc49efed7744c476a5c343a92fabf66dec2db95edb1b2fdc770e2", size = 221824, upload-time = "2026-08-03T21:20:09.274Z" }, + { url = "https://files.pythonhosted.org/packages/eb/ff/7b3429ff53aafe931ed8a5fc69f481bbef7ba6de87ddcbb63d08f483f613/cffi-2.1.1-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:a2d7755bef5a12ed488f4ef1f1b69ee9191d7396083b755a5d2295f6edb4768b", size = 225148, upload-time = "2026-08-03T21:20:10.7Z" }, + { url = "https://files.pythonhosted.org/packages/34/34/a95870b9221e09cf4f2ce3178b1a210abdfe63a1bd357da940418d7b8d15/cffi-2.1.1-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:e0bcb7e0f677f543555d2adff3bf19c05f66cdb4796e5ff602442ab2fe3c4ef7", size = 223564, upload-time = "2026-08-03T21:20:12.165Z" }, + { url = "https://files.pythonhosted.org/packages/70/ea/839b50531021a647fb5e929f72cf97bc1ff702b5472166164b5b6e76b851/cffi-2.1.1-cp313-cp313-win32.whl", hash = "sha256:334644fbac4eff73d985a17a91226df55d0f394160c4cfb880e084c8f7161cac", size = 175263, upload-time = "2026-08-03T21:20:13.559Z" }, + { url = "https://files.pythonhosted.org/packages/60/a6/8b149b2c3f2e11aaa1618ef64500b45f50f22c57a977a4dff1aff1f91042/cffi-2.1.1-cp313-cp313-win_amd64.whl", hash = "sha256:1aa5645c30469b09530c4ebca77ebf8f17618293c58f8549cb1a543a50236e7d", size = 185688, upload-time = "2026-08-03T21:20:14.69Z" }, + { url = "https://files.pythonhosted.org/packages/01/9a/11f687cb39d6a3504060d5242f04f48c735afb4d3d533958a20594890cb2/cffi-2.1.1-cp313-cp313-win_arm64.whl", hash = "sha256:63bbfd5ded17c4840ac07cd8f1c21ba9d9708141f840b324f422f41b207e3973", size = 180078, upload-time = "2026-08-03T21:20:15.917Z" }, + { url = "https://files.pythonhosted.org/packages/d3/7b/d6bbf82b8b96e7391438898c42f5bd96dd02030fd5b64937d248220003e2/cffi-2.1.1-cp314-cp314-ios_13_0_arm64_iphoneos.whl", hash = "sha256:7dbb61fe3a7699468030f71bbe5f8a0e326a151daa91beb11a6fc1f980c55e1c", size = 194064, upload-time = "2026-08-03T21:20:17.148Z" }, + { url = "https://files.pythonhosted.org/packages/94/e6/bcc91b283be94735e268487a054004f0aa19947b6348fa367db53230abc8/cffi-2.1.1-cp314-cp314-ios_13_0_arm64_iphonesimulator.whl", hash = "sha256:f24fb43132a4c6b4cb4eb029492919b2db645be6808d738f244fd146c03c32cb", size = 196720, upload-time = "2026-08-03T21:20:18.268Z" }, + { url = "https://files.pythonhosted.org/packages/d9/99/c4b0c17cacdc9c3b8f280026286a9826d6a208c0f047591a3c3ce99b91fd/cffi-2.1.1-cp314-cp314-macosx_10_15_x86_64.whl", hash = "sha256:d28630f5854ab07ab1fd4aba756de52326c82e6be15d414b12793f1975048b54", size = 184964, upload-time = "2026-08-03T21:20:19.708Z" }, + { url = "https://files.pythonhosted.org/packages/b3/a9/9db617d05d7367c1ad0ab00b3aa6e6f9281edd689b4ee9ea0e5a84e89c97/cffi-2.1.1-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:661c298b4821edebead0c91edd2b00374d67ad7c5a1f7a91d4442633b79d6a72", size = 184962, upload-time = "2026-08-03T21:20:20.833Z" }, + { url = "https://files.pythonhosted.org/packages/67/b8/b42132ca113dc567d37684437b46ca1dafc885902b02a110a02d5b511857/cffi-2.1.1-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:58acb8ab8e295e6c5ea12f888cbb13cf21511ef2a3303a23f4325c29d17fe5c1", size = 222328, upload-time = "2026-08-03T21:20:22.118Z" }, + { url = "https://files.pythonhosted.org/packages/80/10/c5c0cbf0a657aecf59ef511409734230bf556f05a0d6c9eed7aa5c0a0166/cffi-2.1.1-cp314-cp314-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:456a61fa52d579ebf9df2e9552ead5129855dbaff6c1e5a9b1bc408809bdc062", size = 209985, upload-time = "2026-08-03T21:20:23.401Z" }, + { url = "https://files.pythonhosted.org/packages/d5/6c/bfa0b87b03b9238148beca990292843c9396ba069b54496596594173de7b/cffi-2.1.1-cp314-cp314-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:a4f00aa42f75d6e4595e8866e748cc1705adc0cddfeb2ca86d0d03993d63ba03", size = 208530, upload-time = "2026-08-03T21:20:24.628Z" }, + { url = "https://files.pythonhosted.org/packages/e9/02/4e7d553a7ac4b4238b38b3c1b80d486e9d4436f8d2acbf87a0997fe3f402/cffi-2.1.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:b0431303acaea1089ad4b3e9ce4e6518193def1118d4073ca848635ee4ea2e96", size = 221525, upload-time = "2026-08-03T21:20:25.758Z" }, + { url = "https://files.pythonhosted.org/packages/82/1d/a4aaf9babd75acb4d5f223bff71533bee748dd770a382619a798960ee9ba/cffi-2.1.1-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:64faea20f4e2613363a1a9b9c7dd73058f3ecd00133a511e72ad7c511658f527", size = 225053, upload-time = "2026-08-03T21:20:26.985Z" }, + { url = "https://files.pythonhosted.org/packages/81/10/5dc0e7bdd18e22107054288283380fc97a06ae3f1656a106908d666a3c88/cffi-2.1.1-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:5c58fe613dc5e5336357eff555824a314d8e43282600435c8d1cb6a7a2fedd13", size = 223213, upload-time = "2026-08-03T21:20:28.277Z" }, + { url = "https://files.pythonhosted.org/packages/0b/e9/d0061c364cde06ee43168a0d076ac1da512cbc380d44767b844ba34fe2b6/cffi-2.1.1-cp314-cp314-win32.whl", hash = "sha256:1a18a57b58cfb21fc28d72e876acf10eaed67a1ed96226f92af4df681d571c4c", size = 177682, upload-time = "2026-08-03T21:20:44.288Z" }, + { url = "https://files.pythonhosted.org/packages/a7/06/1c3e01e3ba14c39f6d10bfbac52753b7e22259e38088e5cfe1d704918690/cffi-2.1.1-cp314-cp314-win_amd64.whl", hash = "sha256:3222ba5d678f80a030e6afbcc33dc1ae5cb45facabb61cee2c7016b8432fde48", size = 187949, upload-time = "2026-08-03T21:20:45.623Z" }, + { url = "https://files.pythonhosted.org/packages/87/5b/da4e39efe18eeb89cf580ea9cfc66b6a7c3eadb808fc0cc1d3a295cb5a5d/cffi-2.1.1-cp314-cp314-win_arm64.whl", hash = "sha256:ab36d55f9ed2d067327667c2fea18dda018eb628dd6347aa01dda6cf1f5d3836", size = 182947, upload-time = "2026-08-03T21:20:46.955Z" }, + { url = "https://files.pythonhosted.org/packages/23/59/40338bf421c5accea1d45158170c87006ef1cd371b05c077e76476949728/cffi-2.1.1-cp314-cp314t-macosx_10_15_x86_64.whl", hash = "sha256:7750c6449dff7864bb9bb27ddfb0267756189201a3afc911d82b3caacd70dfc3", size = 188504, upload-time = "2026-08-03T21:20:29.495Z" }, + { url = "https://files.pythonhosted.org/packages/7d/47/5ecf1023850036e674c77ec4de86182d309ae344e39e7cba984b7df5d647/cffi-2.1.1-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:0beceaabe56af686895136a2de78db54ecd8e4046b236b8fd6d6cb61389e9bf2", size = 188259, upload-time = "2026-08-03T21:20:31.291Z" }, + { url = "https://files.pythonhosted.org/packages/2a/9c/92934c3bea9f785b23eba304538c0b4d37a2a96d2431eb3a1bc87a11aa19/cffi-2.1.1-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:49cbc70e6542d4ccccb936558d1064a8012541e78f821f955cff24e357776c94", size = 223864, upload-time = "2026-08-03T21:20:32.571Z" }, + { url = "https://files.pythonhosted.org/packages/4d/45/ba4c93527bc38616a8bd36488acb69a2212d60486794f0c1f318949bbb76/cffi-2.1.1-cp314-cp314t-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:e2d65b31f36619cda3999b78b2aa9632e76b78448e7a56fc4240824200e7c4fc", size = 211538, upload-time = "2026-08-03T21:20:33.808Z" }, + { url = "https://files.pythonhosted.org/packages/80/e9/b6ef565e452acb932fb0cb5443f44a78efbd1233e566f02b5a83855e9115/cffi-2.1.1-cp314-cp314t-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:28907ab9bfb6aa13184cfc17c6b8e1023c5ab6fd7076d8c20a35e59fe04f8f29", size = 210688, upload-time = "2026-08-03T21:20:34.974Z" }, + { url = "https://files.pythonhosted.org/packages/9a/95/eff5f0cee78d2eabc7eebffec40d3fc1876b5f3c95582e018bb4b99601f2/cffi-2.1.1-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:51b31d1c98274844cfd7838ce00bfc27c7423a4dc00fc0772fc3331c2cc90676", size = 223803, upload-time = "2026-08-03T21:20:36.564Z" }, + { url = "https://files.pythonhosted.org/packages/fa/01/579d39fb8bef00a335a23d83757b44feb24cd6345a2c451b64cb67b9c362/cffi-2.1.1-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:5e7cecbaadb83884793e05828cee59b210b24583b9c7425d0ba6a754fe22eb4e", size = 226763, upload-time = "2026-08-03T21:20:37.816Z" }, + { url = "https://files.pythonhosted.org/packages/8d/b0/0b44f47c60b01b57b6e2bbd92343f13a85a1d93bc46ccf6e47e244acd99c/cffi-2.1.1-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:25792eac27877609e7bb06d42ff88278a6624fff2ba9bbb523c09616b117e80f", size = 225688, upload-time = "2026-08-03T21:20:38.959Z" }, + { url = "https://files.pythonhosted.org/packages/eb/d2/3b7176cb570a1d3e27faf67b72f591af508036e0d8b2be2ef9af9e8c84bb/cffi-2.1.1-cp314-cp314t-win32.whl", hash = "sha256:8ef53b2de9bcb9197d31854256575d59dbac0cba72ac627bb291ef5eceb74be4", size = 182868, upload-time = "2026-08-03T21:20:40.388Z" }, + { url = "https://files.pythonhosted.org/packages/56/78/31f00c1bcd97c9bbf55f1bfdf5bc809a5de8887473e90bb9960dca825e80/cffi-2.1.1-cp314-cp314t-win_amd64.whl", hash = "sha256:616f097f2fe415bc92a247f02e11f634e1f9e9a83d327e3c915c15089c87869e", size = 194104, upload-time = "2026-08-03T21:20:41.725Z" }, + { url = "https://files.pythonhosted.org/packages/7b/1b/58496f2ed0a35de575250c02a43ab3cc2c04d494a88fed31c1cabc0fd176/cffi-2.1.1-cp314-cp314t-win_arm64.whl", hash = "sha256:ad2c86c495b899d862ea0f4b42891b8713a3bd45dd4105c7fd51c2a72f39f3a5", size = 186402, upload-time = "2026-08-03T21:20:43.042Z" }, + { url = "https://files.pythonhosted.org/packages/c1/8f/9ebe220eab48a093d1a5a5e339ab0dc7316eef3bb04d63c42f0251b61f50/cffi-2.1.1-cp315-cp315-ios_13_0_arm64_iphoneos.whl", hash = "sha256:dddad92b554513a31f272570678ba307fb9f618f05e3d4a5eacafff9eae03e1d", size = 194043, upload-time = "2026-08-03T21:20:48.179Z" }, + { url = "https://files.pythonhosted.org/packages/ff/69/844bad3ece306c4782c2ecb93597035b6690d48704b803914c199da1e8b3/cffi-2.1.1-cp315-cp315-ios_13_0_arm64_iphonesimulator.whl", hash = "sha256:da0e573f9f97159390c89d9f1a9e41908b66d408cc5b58d08cf3847d844c531b", size = 196737, upload-time = "2026-08-03T21:20:49.457Z" }, + { url = "https://files.pythonhosted.org/packages/1b/8a/af668013284634733f02d683458a0728739c7d6ddb5e14cb0c20832266fe/cffi-2.1.1-cp315-cp315-macosx_10_15_x86_64.whl", hash = "sha256:fb92203a88b3d3053034db775110081c49d28be6551923805e039924093761e4", size = 184933, upload-time = "2026-08-03T21:20:50.639Z" }, + { url = "https://files.pythonhosted.org/packages/0c/75/2f5207ff6d1a613133b23a5203cc0c2a628313b5eb3974d7956ae3c57950/cffi-2.1.1-cp315-cp315-macosx_11_0_arm64.whl", hash = "sha256:2ae64be792b8966f2c69538199728b290e34726562896df1e5dc8ffd8d8188e8", size = 185002, upload-time = "2026-08-03T21:20:52.173Z" }, + { url = "https://files.pythonhosted.org/packages/e2/31/9e1313b0a6e30e91b3b3d3fff51ae99c857c07738e3afcce1f7334e1b7ab/cffi-2.1.1-cp315-cp315-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:507a24c282e0f42f8ed737cf048572cbf580468da5555764a8331735e9c736b6", size = 222271, upload-time = "2026-08-03T21:20:53.462Z" }, + { url = "https://files.pythonhosted.org/packages/50/e3/f6234a833e6e08c7007003074723c406559eecf9b48dfc97471e5a8eb7a0/cffi-2.1.1-cp315-cp315-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:246fa40ce8645a614ff682e0b70f37134e460eaf93a775e0cbe3cca585a67a80", size = 209919, upload-time = "2026-08-03T21:20:54.783Z" }, + { url = "https://files.pythonhosted.org/packages/0d/fc/5f74e293fced6edb51af3a46c4ccf6c23c9943774ecb375ddbd522c76add/cffi-2.1.1-cp315-cp315-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:471cee653ae88de62096552e6d24ccb4a5adb8c8c9f10b5054d0122c15bf2779", size = 208529, upload-time = "2026-08-03T21:20:56.066Z" }, + { url = "https://files.pythonhosted.org/packages/44/16/29e6d01b388bef055ecd6ca8244b3f4d336bd09e92d5d892187b9601084e/cffi-2.1.1-cp315-cp315-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:aeae0e330c9f6acd681f647d46cefd30c29f93e3392882e792e82080c9691399", size = 221630, upload-time = "2026-08-03T21:20:57.336Z" }, + { url = "https://files.pythonhosted.org/packages/a4/18/fa7f1f6857d5eb88a4ca99ffcbfb7c387a287ccc154c64a73e86314745d7/cffi-2.1.1-cp315-cp315-musllinux_1_2_aarch64.whl", hash = "sha256:42a494cee34437f05546455144f2b5d9ac09b1face62bcfce597d2e521066688", size = 225134, upload-time = "2026-08-03T21:20:58.675Z" }, + { url = "https://files.pythonhosted.org/packages/e0/9f/e8e3dfa04a1b4c241f8c91faacad872b4d4efd051d49764ad4e2fd4b9fea/cffi-2.1.1-cp315-cp315-musllinux_1_2_x86_64.whl", hash = "sha256:cc572dace3f60ef98d7b12ff411d20f5362feb31a0439eab0085bbfd349982d7", size = 223197, upload-time = "2026-08-03T21:20:59.968Z" }, + { url = "https://files.pythonhosted.org/packages/f8/7e/8debeb04f1ab9fe2a6963964cd6f1aaf7192627b83926586a6a4e089c9fa/cffi-2.1.1-cp315-cp315-win32.whl", hash = "sha256:4f42141fc14250de6dde5ee7ea4432be017252d91f19c5ad043c084cea629cac", size = 177683, upload-time = "2026-08-03T21:21:14.901Z" }, + { url = "https://files.pythonhosted.org/packages/e0/31/5158704cc474ab65c1647932e88be78dc0873f47130e253be38bcaf13d01/cffi-2.1.1-cp315-cp315-win_amd64.whl", hash = "sha256:e6e8cff14d6fb0be70a09c0bdc58096f501952d04624ebf867e0e56da2df8960", size = 187897, upload-time = "2026-08-03T21:21:16.108Z" }, + { url = "https://files.pythonhosted.org/packages/cc/4b/b3a2da8570c704ffc0f9762cdc3ec0f02c8573798e0b5cf7f11c82bbb70f/cffi-2.1.1-cp315-cp315-win_arm64.whl", hash = "sha256:27350daa11d4f10c540e6e89dada4c54feb7256ad03e9a4dc075ebad7ba360d1", size = 182935, upload-time = "2026-08-03T21:21:17.271Z" }, + { url = "https://files.pythonhosted.org/packages/d0/ef/5443574510a1207e6f6bc38ba6e1f1de36cb48fef07b2728bb896a21f430/cffi-2.1.1-cp315-cp315t-macosx_10_15_x86_64.whl", hash = "sha256:c26608d2222fb1e94487e4a387d85f13eb55d5ed725cb25a0c589ac4ee60e7bc", size = 188464, upload-time = "2026-08-03T21:21:01.163Z" }, + { url = "https://files.pythonhosted.org/packages/7e/ae/a56fa8c4686ad50e148fcbc8d3ae0d03915ff5c30d795058988c24118cef/cffi-2.1.1-cp315-cp315t-macosx_11_0_arm64.whl", hash = "sha256:4be96343e422f2dfcd12ab5c9f5aebe03f82f737c6bffeca6830b3875cb44aab", size = 188262, upload-time = "2026-08-03T21:21:02.382Z" }, + { url = "https://files.pythonhosted.org/packages/53/b2/6187f46f2912276a3ae284076109cc5c8680482f11f766ccf26db4a86427/cffi-2.1.1-cp315-cp315t-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:937c0052c05a31ca1daf18de3158eed4dbfcb9cc107adbea227728d647be701e", size = 223779, upload-time = "2026-08-03T21:21:03.553Z" }, + { url = "https://files.pythonhosted.org/packages/8a/f6/c3ad28bd19f77047a03084424fbd4cbe997303267c14423737324be0385d/cffi-2.1.1-cp315-cp315t-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:df423d40ee8654634421812bc3b196da3f9bd7d32929da813f8394c4348a5358", size = 211520, upload-time = "2026-08-03T21:21:04.863Z" }, + { url = "https://files.pythonhosted.org/packages/a0/cd/ccac9013a5bd9fd764de118674ab9c805b5ca10c19270d90ee273f8b2240/cffi-2.1.1-cp315-cp315t-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:a730a083190634c65cca36ba5f489531576ebd79bcd5c8e172130f6453127231", size = 210673, upload-time = "2026-08-03T21:21:06.223Z" }, + { url = "https://files.pythonhosted.org/packages/52/86/2976131c639aead931c5bee5aba67e4b09fbeb8018b6f282f70803f923a7/cffi-2.1.1-cp315-cp315t-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:363e05fa78e15116c3c32c210ee36884fd6b9afa6d440e47112c3bd511d64cb6", size = 223835, upload-time = "2026-08-03T21:21:07.539Z" }, + { url = "https://files.pythonhosted.org/packages/ac/0c/33a7aeab2f9c76918c52e084beb39c570db3588133412929e8ec06fab90b/cffi-2.1.1-cp315-cp315t-musllinux_1_2_aarch64.whl", hash = "sha256:770de9db11e84213beec501cfcaa013b019820ca881e03344dea5844f7876d94", size = 226705, upload-time = "2026-08-03T21:21:08.774Z" }, + { url = "https://files.pythonhosted.org/packages/e3/26/2cde30fdde421130bfc18f70395731a6e6b2053c6a1978a5258ff04e72fa/cffi-2.1.1-cp315-cp315t-musllinux_1_2_x86_64.whl", hash = "sha256:7da0c5eff80f0197f3b3d1232ec5a682a9325f4ae9016a78f5f5ca35f9ced1f5", size = 225539, upload-time = "2026-08-03T21:21:09.911Z" }, + { url = "https://files.pythonhosted.org/packages/6d/cd/a361394c94b2129d604bb846f624a8e88255a3ee33129c434a00d715e64f/cffi-2.1.1-cp315-cp315t-win32.whl", hash = "sha256:06c72bb76605a4b0cd0aad6930b69d4baf7dd5d806cfc409b824191099700e66", size = 182707, upload-time = "2026-08-03T21:21:11.226Z" }, + { url = "https://files.pythonhosted.org/packages/9b/b5/ba2b299993c26577d529b6ae29841f9e15b9fcf004d65f423f4fcf94ade9/cffi-2.1.1-cp315-cp315t-win_amd64.whl", hash = "sha256:d9c275eaacd24aa73f94ffd6de08fc3f932424d8b6c376f4bed7cde376fe7bc3", size = 193772, upload-time = "2026-08-03T21:21:12.39Z" }, + { url = "https://files.pythonhosted.org/packages/aa/29/35e016098c814cd93de9cd320c66b5bfba14dc6ecedd3cb518fa7c408c69/cffi-2.1.1-cp315-cp315t-win_arm64.whl", hash = "sha256:d18e5ac0f2f03f4f518d3e23db0f0cad7faa1da8620e9c09461d443bbf6e6692", size = 186360, upload-time = "2026-08-03T21:21:13.636Z" }, +] + [[package]] name = "charset-normalizer" version = "3.5.2" @@ -395,6 +480,69 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/3f/0c/7a64e1ac90541a8edf50daef0914848011fb057a5bf55284a4811e21939a/coverage-7.16.2-py3-none-any.whl", hash = "sha256:11d28e9123a9156cb405d8d27b44256c9a58fb5decc2073a8f17862057e3aa0f", size = 215754, upload-time = "2026-09-27T12:28:59.075Z" }, ] +[[package]] +name = "cryptography" +version = "50.0.2" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "cffi", marker = "platform_python_implementation != 'PyPy'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/9d/af/182eb91b0df3fe75c4d9f26fe70684569566745f6ba7e5c9c73a862c5252/cryptography-50.0.2.tar.gz", hash = "sha256:7b46165bb56eb4704e2eaaf86f3c940d19154535d9b0ca7d6d590b04060e00d5", size = 880623, upload-time = "2026-09-30T15:30:04.884Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/e5/56/d194340cc4a57535e82e1bee9e89667ac4b7c13b5d3f59686deae3094dd5/cryptography-50.0.2-cp311-abi3-macosx_11_0_arm64.whl", hash = "sha256:fa8f5efb344d6908a1ce62f4a24e2e5780f825d6f53f5f50ec5ffacac72936cb", size = 3914904, upload-time = "2026-09-30T14:43:44.339Z" }, + { url = "https://files.pythonhosted.org/packages/d9/69/c9bd862c3bf43d6399c433caf002df16e2dffd4be49bdf515cda38038711/cryptography-50.0.2-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:79def8d059362e7831389ed3be0ecdf58a89386e1271e35dd9f5af84e81bffd0", size = 4731146, upload-time = "2026-09-30T14:43:47.113Z" }, + { url = "https://files.pythonhosted.org/packages/21/69/64cef1f702bf6657e0cc186ed1a2891d50d29fb41586b254e1c07adea261/cryptography-50.0.2-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:630ebfea3bf689d075f82316324ff7433dc447fe6bc1bfc76524b74b4a9567d2", size = 4719841, upload-time = "2026-09-30T14:43:49.01Z" }, + { url = "https://files.pythonhosted.org/packages/38/6b/61a3f8d8c5e1e49a6cddccafc4015cc1c0021360ab0acb4080e7a423644a/cryptography-50.0.2-cp311-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:f9f6143a8c75945eb960d9eb98905a441394abfa24afaae239d514ffb2586480", size = 4738340, upload-time = "2026-09-30T14:43:50.932Z" }, + { url = "https://files.pythonhosted.org/packages/7b/2e/7212ca32fd43dc91f2f41db20160b268098874b4c9a0e7be94d6835f5b2e/cryptography-50.0.2-cp311-abi3-manylinux_2_28_ppc64le.whl", hash = "sha256:a582ab2ae1d34f67112cadc86702774c9ea4374df6bca6afe672817203c99134", size = 5367029, upload-time = "2026-09-30T14:43:52.911Z" }, + { url = "https://files.pythonhosted.org/packages/1a/f1/b474e930c4d910328780e3940da76f5aa5cbc48ce1fc14e44d239d9ea9db/cryptography-50.0.2-cp311-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:4061c0079120205fb760c58acab6443e217307dcf05e3702cf970e0689972856", size = 4753050, upload-time = "2026-09-30T14:43:55.272Z" }, + { url = "https://files.pythonhosted.org/packages/7c/52/9af10e80ac16b0fcc2123f9cbd5e7afbd0fd5075bb7a607c592258a39cda/cryptography-50.0.2-cp311-abi3-manylinux_2_31_armv7l.whl", hash = "sha256:ac9ed99d81760c62fe89d5f0815cdfa1ba9a35141cf30f1c2d044f04b4803d2e", size = 4376724, upload-time = "2026-09-30T14:43:57.24Z" }, + { url = "https://files.pythonhosted.org/packages/71/37/6202e488cc1eb625ea110c292c6bda92823176e023f427d8d5660ce8d632/cryptography-50.0.2-cp311-abi3-manylinux_2_34_aarch64.whl", hash = "sha256:87e9ce85beb6b328ba370cc6e6aea483c92617b4c95b1d33a49297eb662bfb04", size = 4737859, upload-time = "2026-09-30T14:43:59.541Z" }, + { url = "https://files.pythonhosted.org/packages/8f/30/e86d7d518489b0ae2497091a35287abcb1a2ce4037837a34afbe9b1d6964/cryptography-50.0.2-cp311-abi3-manylinux_2_34_ppc64le.whl", hash = "sha256:f265528741e048bce55c3463ed721fb0aa45a5888d8add8cfeccb3035451bbdc", size = 5324103, upload-time = "2026-09-30T14:44:01.901Z" }, + { url = "https://files.pythonhosted.org/packages/d3/69/2c833a049475e0a3444e94c7d0aca0aa51d166374a449b09e92ac98138de/cryptography-50.0.2-cp311-abi3-manylinux_2_34_x86_64.whl", hash = "sha256:9dab55f57c74c3cad24c323bacbbd04be4705ba6eb0d92e920b1fc4837ed5079", size = 4752576, upload-time = "2026-09-30T14:44:04.545Z" }, + { url = "https://files.pythonhosted.org/packages/6c/5d/906970b83bbfc1f5bbfb677a143c181f2801f23b6a7204a3b47c42c97e65/cryptography-50.0.2-cp311-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:25784ce8b9621c90c643efb9e1e2162ab3b0224cae446ad5e70e7fcb1ce18b51", size = 4870819, upload-time = "2026-09-30T14:44:06.884Z" }, + { url = "https://files.pythonhosted.org/packages/68/e3/f2298d3bb55e0c4a91841ec4d01b3f020ba8c5fbf15ccdcc6dcf03f97025/cryptography-50.0.2-cp311-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:85d0d9a31b9098e98534226d5686b47264b95e62ce459dc2e62fdfc809f9fe93", size = 5030152, upload-time = "2026-09-30T14:44:09.443Z" }, + { url = "https://files.pythonhosted.org/packages/9a/4f/adfc442765721292fff86d314ce385d3249d22db42295c0dd057727b60f3/cryptography-50.0.2-cp311-abi3-win_amd64.whl", hash = "sha256:7afa5a6602a9f29af1f3a2965f831bae7c9d5d597b7cbb716d41ab3b7d89879c", size = 3824692, upload-time = "2026-09-30T14:44:11.671Z" }, + { url = "https://files.pythonhosted.org/packages/ce/cb/52eb3770c0d0be2702a98c6e96065ddc0a2877cf0845aa9c23397c142cd4/cryptography-50.0.2-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:f785f6161f202ab04d8ca194158968798e480ca058943907972da5f12e2881e8", size = 3892731, upload-time = "2026-09-30T14:44:13.485Z" }, + { url = "https://files.pythonhosted.org/packages/19/8e/aa1fc533d4546b127b45de8aa024eb5933d23eff9debfe25931e56861095/cryptography-50.0.2-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:0ecbc5652bdb6fc9eaf89a7d196e20941adfe812f43bc4ca05d9150496821047", size = 4710431, upload-time = "2026-09-30T14:44:15.427Z" }, + { url = "https://files.pythonhosted.org/packages/6a/64/72bc3f75176e7e406b748a3e3830432b8c51297b38368713df04dc04898a/cryptography-50.0.2-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:ab50ee449bf968271e820086f10a33d101dd060370abc10bcd22279be2656539", size = 4694824, upload-time = "2026-09-30T14:44:17.69Z" }, + { url = "https://files.pythonhosted.org/packages/4e/c6/62c77550edfa5ca3f14bf44a1e6739b9fa09d6e998a11d97ed8213bccc98/cryptography-50.0.2-cp314-cp314t-manylinux_2_28_aarch64.whl", hash = "sha256:a9f7355e6fab51f6c369b86fb7571cffa05edee2c2121e0380a37fb9ac1cd5c1", size = 4716967, upload-time = "2026-09-30T14:44:19.661Z" }, + { url = "https://files.pythonhosted.org/packages/f4/37/cce70f150c432914460157a6ecc161752e053aa5ec0ef3b3f7dc6e31039a/cryptography-50.0.2-cp314-cp314t-manylinux_2_28_ppc64le.whl", hash = "sha256:94e5e9f108ee10471288214d3d233fbfbb492840a8457eb85178d643ddeb32c7", size = 5328676, upload-time = "2026-09-30T14:44:21.744Z" }, + { url = "https://files.pythonhosted.org/packages/aa/9a/6f2f0304d634ceafdeaf23e84537336664ac419b5d07611675c2ad3f6b7a/cryptography-50.0.2-cp314-cp314t-manylinux_2_28_x86_64.whl", hash = "sha256:241449bf940a5d27309bd317e6f9a2af6932113818bb2b8f5c59ddc7ef16da18", size = 4727698, upload-time = "2026-09-30T14:44:24.178Z" }, + { url = "https://files.pythonhosted.org/packages/1d/de/66bcf9244d118663b2e1aaded8990f4640e3d7b7411870a5765f252074d2/cryptography-50.0.2-cp314-cp314t-manylinux_2_31_armv7l.whl", hash = "sha256:d8947001be83df1394050758ce0e745dd74fb134eef0a4b5124208dfc3a68c37", size = 4354821, upload-time = "2026-09-30T14:44:26.263Z" }, + { url = "https://files.pythonhosted.org/packages/bd/e6/db28a28c7b6c676addce89136de3d8db49ea825a8c863472e36e42ead4ad/cryptography-50.0.2-cp314-cp314t-manylinux_2_34_aarch64.whl", hash = "sha256:4a20ce1e5cb4284a86692fdcba7cb8754185c6b2e5c56fcef3751cf451d3cdc2", size = 4716748, upload-time = "2026-09-30T14:44:28.447Z" }, + { url = "https://files.pythonhosted.org/packages/30/96/01546c7f69ea0e2ab790a2e4f0934a4052fb9b388147fbf83c2fd72f1e57/cryptography-50.0.2-cp314-cp314t-manylinux_2_34_ppc64le.whl", hash = "sha256:84f964e537f916e2cc85199e5a88742e964939b575ac8598b3f9d6cc416cdaf1", size = 5285085, upload-time = "2026-09-30T14:44:30.704Z" }, + { url = "https://files.pythonhosted.org/packages/6c/01/03263395f74d50b071e9e66daace3f8bef80493e5d410726f2ba8554736b/cryptography-50.0.2-cp314-cp314t-manylinux_2_34_x86_64.whl", hash = "sha256:828d49b0ff5a0e3975865571c5d91dbbdd0d38d8289b249a163e9425413a5e05", size = 4727268, upload-time = "2026-09-30T14:44:32.92Z" }, + { url = "https://files.pythonhosted.org/packages/eb/94/2bfe8f29ec0cc9c0d99359c4161adf32858e4934b72c6d100d2ac0bbe962/cryptography-50.0.2-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:deb9fde5c60e437ee4821bc9bc39ff31b42135c27e1dc61ef0a629389c1de62e", size = 4849503, upload-time = "2026-09-30T14:44:34.969Z" }, + { url = "https://files.pythonhosted.org/packages/54/44/e80651ecbf0e42b62e2bb5f5768916e07eea72e1297338956a61df361f88/cryptography-50.0.2-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:8c71ba2cd31fc93748c38e1b613200ff1c2665cbfd5341fe3a61cfde35a1430e", size = 5004057, upload-time = "2026-09-30T14:44:37.064Z" }, + { url = "https://files.pythonhosted.org/packages/f8/cc/1d33befb3cd7ea7e77d2d73f43f2066471da1b21f24a6156efcaabf6d2e8/cryptography-50.0.2-cp314-cp314t-win_amd64.whl", hash = "sha256:78198641e5be9521beea5aa782bb551a58068d10e6eb04c9c680c1b69f2e7d45", size = 3795868, upload-time = "2026-09-30T14:44:39.71Z" }, + { url = "https://files.pythonhosted.org/packages/2d/49/93f6a6e7a87c9aa68d44d3e1cdb5fe8f60c90d5d2f46acae9a56892816b8/cryptography-50.0.2-cp315-abi3.abi3t-macosx_11_0_arm64.whl", hash = "sha256:edc3342adf8f697fc5f59c887a304356f147b397809440ed64e2fa6af2f50f37", size = 4133708, upload-time = "2026-09-30T14:44:41.807Z" }, + { url = "https://files.pythonhosted.org/packages/8c/75/32ac2a56243d778805c16ca6a32b8f74fb757df7e28d7ecb560afafb59cf/cryptography-50.0.2-cp315-abi3.abi3t-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:d370b8d1dfcdf7130178137f6fbee6140774a1acc6cacefc4b42643ec11d0a3a", size = 4956267, upload-time = "2026-09-30T14:44:43.693Z" }, + { url = "https://files.pythonhosted.org/packages/aa/a4/2c8d734e43d97f0842ee9f1b7b4bfb3d0cf5e19edebf43c2afe6675c2320/cryptography-50.0.2-cp315-abi3.abi3t-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:f2f9bd7f90c64fe89253f0a2c05e3c4856072660429ce8831b4235bf29403a67", size = 4966465, upload-time = "2026-09-30T14:44:45.769Z" }, + { url = "https://files.pythonhosted.org/packages/c2/58/ee288c829a6f41f6235ae9dd33d82fd19b45442b65b4c8a3da36963d9f7a/cryptography-50.0.2-cp315-abi3.abi3t-manylinux_2_28_aarch64.whl", hash = "sha256:e275096ea1e60cc595cda2836fd4a6c725d1125108b868be17f53684d164e2cc", size = 4959356, upload-time = "2026-09-30T14:44:48.211Z" }, + { url = "https://files.pythonhosted.org/packages/92/20/9ded6d51ddd9897f6b6e81fb9ebea7951d7cc5d6c890b0ed8abf77a51a80/cryptography-50.0.2-cp315-abi3.abi3t-manylinux_2_28_ppc64le.whl", hash = "sha256:b13478603dcd0a2479ff8e87e2c19a7d525734686fe3c49542472293a204212d", size = 5548822, upload-time = "2026-09-30T14:44:50.86Z" }, + { url = "https://files.pythonhosted.org/packages/02/a8/8df951850d6b31d2a00218f19e2b3f999523437ed7a819df7fa427942fca/cryptography-50.0.2-cp315-abi3.abi3t-manylinux_2_28_x86_64.whl", hash = "sha256:58a0c478eeca76fe5e07993c5a0703def34a6dc6a0cda4f5564639b33112ffe7", size = 5001199, upload-time = "2026-09-30T14:44:53.379Z" }, + { url = "https://files.pythonhosted.org/packages/8b/f9/36b3022218ce75b7cdf068fb95f809f9bd0d820e4955ef43b90c255cc7ac/cryptography-50.0.2-cp315-abi3.abi3t-manylinux_2_31_armv7l.whl", hash = "sha256:d38cdff612d06fa6a32840d5e1b1f7a27cee4a349aa9085d94a67789d6bfd408", size = 4629333, upload-time = "2026-09-30T14:44:55.635Z" }, + { url = "https://files.pythonhosted.org/packages/8c/72/20f99a219f6af47cdd1cbd978c243b92d71496e168a746138af44ded4f29/cryptography-50.0.2-cp315-abi3.abi3t-manylinux_2_34_aarch64.whl", hash = "sha256:fdd28f912fccfec1846a94e2e1e8f9b0012f557f0c46fe4f3eb0d7a87afcf90b", size = 4958822, upload-time = "2026-09-30T14:44:59.639Z" }, + { url = "https://files.pythonhosted.org/packages/f2/20/196f112617fb08eb4d608a2a6c422373d46f9cc2857f38fc0667033c0899/cryptography-50.0.2-cp315-abi3.abi3t-manylinux_2_34_ppc64le.whl", hash = "sha256:cbc8738fd8526d80f35cb3a40d41f41a2e7030bb3b18b09a6778ef63d291c2fd", size = 5506351, upload-time = "2026-09-30T14:45:02.267Z" }, + { url = "https://files.pythonhosted.org/packages/24/95/83378121ef3eaaaf71d4b781577ff794acb39b9e1b87a3f156898c8497ed/cryptography-50.0.2-cp315-abi3.abi3t-manylinux_2_34_x86_64.whl", hash = "sha256:e105ab60406787da31fccc883fc0f733af1efd78f0136a4599692c4083a73d0c", size = 5000859, upload-time = "2026-09-30T14:45:05.009Z" }, + { url = "https://files.pythonhosted.org/packages/22/f7/70fd7ae4d1dbfa7ba29b02e1b9068771519a86027756510b700ce81086a8/cryptography-50.0.2-cp315-abi3.abi3t-musllinux_1_2_aarch64.whl", hash = "sha256:6f8700550aa1474a91e5dc07049c46f98b423b5b1ddd0483e0b51362eeeaf5be", size = 5092151, upload-time = "2026-09-30T15:29:15.932Z" }, + { url = "https://files.pythonhosted.org/packages/d4/be/688367b74de86984bd58d8efacfc7c9e68b89a6a22ced0fb4f38db50254a/cryptography-50.0.2-cp315-abi3.abi3t-musllinux_1_2_x86_64.whl", hash = "sha256:c71be1cbfa5cd9a41ee452acf1eccd82b2c05950358b106ec8ceb83411d1a020", size = 5286120, upload-time = "2026-09-30T15:29:18.309Z" }, + { url = "https://files.pythonhosted.org/packages/39/d1/55f8a3f2ef5d1529e16835ef10cf0fe3d559ce237b46dddc440c0bba3649/cryptography-50.0.2-cp315-abi3.abi3t-win_amd64.whl", hash = "sha256:c423ab384a46c4dff7217b2ea5ba2e11cffdeab6441acd04cf65a369caf0366c", size = 4111557, upload-time = "2026-09-30T15:29:20.155Z" }, + { url = "https://files.pythonhosted.org/packages/23/ad/ac987755d00e1e64273760228d2635ae38dae2be83e3c6e0d3289d91dec3/cryptography-50.0.2-cp39-abi3-macosx_11_0_arm64.whl", hash = "sha256:0ec5f09541743261e66e291b4a0cbf0fb2997aeaab6d9e9c740b9dba1b58d1c2", size = 3943588, upload-time = "2026-09-30T15:29:22.265Z" }, + { url = "https://files.pythonhosted.org/packages/d5/8d/6d585339bedf85d45044c85d8412dac53f2bb6f918e8b7777efba1787844/cryptography-50.0.2-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:c5e67125c7dca78d199ec4e116aa93dbb83494808ecbb8211a2cb09b1bf41dbd", size = 4756166, upload-time = "2026-09-30T15:29:24.58Z" }, + { url = "https://files.pythonhosted.org/packages/bf/f1/1c1f6874e8550cfddd4b688ceb38cefb6ed15ceed224d56f133f3d88c214/cryptography-50.0.2-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:ee247f5c245c9a2fe7c8e2214e295918838e44e00a45a6718451e4004219e767", size = 4749145, upload-time = "2026-09-30T15:29:26.807Z" }, + { url = "https://files.pythonhosted.org/packages/c1/63/61b15dc1a8de03fe0adbe3fd7608b3ad5c73bf50993bbcb1faaa930afe33/cryptography-50.0.2-cp39-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:dfe9763530994147d9af1def057a5b9658b00e8f8fe8743d144d1e0911c2e454", size = 4763638, upload-time = "2026-09-30T15:29:28.588Z" }, + { url = "https://files.pythonhosted.org/packages/fc/35/b345bdfa40c9126df1a9d33236aa98418367931b8725f84fc3ae2b98dc59/cryptography-50.0.2-cp39-abi3-manylinux_2_28_ppc64le.whl", hash = "sha256:58ddb5a8e3179d12f19e4ea34d2d32e9d63a4baa142c875c1eb59f41b7243acd", size = 5382217, upload-time = "2026-09-30T15:29:30.589Z" }, + { url = "https://files.pythonhosted.org/packages/4f/87/ef344a9e616871f2519c22d6afcda79ddd5d35e9592d95eb6e677608d055/cryptography-50.0.2-cp39-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:f21e8a22c8605750c7af886bab299a363721264061b4ac0a30efb73cfd58efc5", size = 4781387, upload-time = "2026-09-30T15:29:32.605Z" }, + { url = "https://files.pythonhosted.org/packages/90/5b/f2fdb13cd0b96f6f932c8627bb292a45f11c64d21620a8e120aee9a3b848/cryptography-50.0.2-cp39-abi3-manylinux_2_31_armv7l.whl", hash = "sha256:9c8402a82ea0dc4ceeab793db05f0fafa8ca139ca34fcde5df0f596103c74107", size = 4403790, upload-time = "2026-09-30T15:29:34.374Z" }, + { url = "https://files.pythonhosted.org/packages/bc/ce/7e4f662b1e3c393513569e402cfc85ac7da0bd3d5435e122a3140219eb2d/cryptography-50.0.2-cp39-abi3-manylinux_2_34_aarch64.whl", hash = "sha256:0ddc924c04591c2811ca024d62ecad4f7f6f08af8939c211438f48a16bd23602", size = 4764319, upload-time = "2026-09-30T15:29:36.149Z" }, + { url = "https://files.pythonhosted.org/packages/3c/3f/86ff33ce34cc0de6847fb96e035a1a760d81652e38643f617c02ad32ef7a/cryptography-50.0.2-cp39-abi3-manylinux_2_34_ppc64le.whl", hash = "sha256:a6557e5f38e065ca9fbdaf7cfc7435ecb1d113aa81a022d1b51921ee7432e227", size = 5338560, upload-time = "2026-09-30T15:29:39.053Z" }, + { url = "https://files.pythonhosted.org/packages/40/cf/6b5c8e2fd9202d98988ab7cb5cc5c991704c4ad55f492ff408e4969f83f1/cryptography-50.0.2-cp39-abi3-manylinux_2_34_x86_64.whl", hash = "sha256:1981f1db4630889b9ef7803fadef12b056f428cb6b85c27ba57b774793b6093c", size = 4780973, upload-time = "2026-09-30T15:29:41.251Z" }, + { url = "https://files.pythonhosted.org/packages/10/bf/8d6ebc7dded797bd0f0160d52188021211f011a2b164ef0ae1dac4587465/cryptography-50.0.2-cp39-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:7a8701d6b584d76e909e3d305b7d126b41439876a5aaf76cddc67fc230eafa2e", size = 4897738, upload-time = "2026-09-30T15:29:43.106Z" }, + { url = "https://files.pythonhosted.org/packages/d4/aa/f3f6e0de7e6253b8baa8b2d8fb9d50924fa75cee3d4624bd4bc1208ee923/cryptography-50.0.2-cp39-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:ce47f66801c20ec6c6632453bb5960fe38939e9306970b48b3a5a26de7745d94", size = 5058280, upload-time = "2026-09-30T15:29:44.827Z" }, + { url = "https://files.pythonhosted.org/packages/f6/b6/a1faf3a27ae9405fb34b1713cc73b2d8a26b04d5c561578fa2e6ef3e5bb9/cryptography-50.0.2-cp39-abi3-win_amd64.whl", hash = "sha256:4e81d95e5bafc2d6e34e4bed780e53e4d5b9a2f928573428aa4d35fbec1eb0de", size = 3854095, upload-time = "2026-09-30T15:29:46.782Z" }, +] + [[package]] name = "cuda-bindings" version = "13.4.3" @@ -520,7 +668,11 @@ version = "0.1.0" source = { editable = "." } dependencies = [ { name = "doclang" }, + { name = "httpx" }, + { name = "mcp" }, + { name = "ruamel-yaml" }, { name = "tabulate" }, + { name = "tomlkit" }, { name = "tqdm" }, ] @@ -555,9 +707,13 @@ requires-dist = [ { name = "doclang", git = "https://github.com/doclang-project/doclang?rev=92d299026f2f985328b52424483c711e19b2f306" }, { name = "docling", extras = ["rapidocr"], marker = "extra == 'conversion'", specifier = ">=2.134.0,<3" }, { name = "fastembed", marker = "extra == 'vectors'", specifier = ">=0.8.1,<1" }, + { name = "httpx", specifier = ">=0.27,<1" }, + { name = "mcp", specifier = ">=1.20,<2" }, { name = "mlx-embedding-models", marker = "platform_machine == 'arm64' and sys_platform == 'darwin' and extra == 'vectors'", specifier = "==0.0.11" }, { name = "numpy", marker = "extra == 'vectors'", specifier = ">=1.26" }, + { name = "ruamel-yaml", specifier = ">=0.18,<1" }, { name = "tabulate", specifier = ">=0.10,<1" }, + { name = "tomlkit", specifier = ">=0.13,<1" }, { name = "tqdm", specifier = ">=4.66,<5" }, { name = "transformers", marker = "platform_machine == 'arm64' and sys_platform == 'darwin' and extra == 'vectors'", specifier = ">=4.47,<5" }, { name = "turbovec", marker = "extra == 'vectors'", specifier = ">=1,<2" }, @@ -861,6 +1017,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/2a/39/e50c7c3a983047577ee07d2a9e53faf5a69493943ec3f6a384bdc792deb2/httpx-0.28.1-py3-none-any.whl", hash = "sha256:d909fcccc110f8c7faf814ca82a9a4d816bc5a6dbfea25d6591d6985b8ba59ad", size = 73517, upload-time = "2024-12-06T15:37:21.509Z" }, ] +[[package]] +name = "httpx-sse" +version = "0.4.3" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/0f/4c/751061ffa58615a32c31b2d82e8482be8dd4a89154f003147acee90f2be9/httpx_sse-0.4.3.tar.gz", hash = "sha256:9b1ed0127459a66014aec3c56bebd93da3c1bc8bb6618c8082039a44889a755d", size = 15943, upload-time = "2025-10-10T21:48:22.271Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/d2/fd/6668e5aec43ab844de6fc74927e155a3b37bf40d7c3790e49fc0406b6578/httpx_sse-0.4.3-py3-none-any.whl", hash = "sha256:0ac1c9fe3c0afad2e0ebb25a934a59f4c7823b60792691f779fad2c5568830fc", size = 8960, upload-time = "2025-10-10T21:48:21.158Z" }, +] + [[package]] name = "huggingface-hub" version = "0.36.2" @@ -1367,6 +1532,31 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/92/f9/ecbde7149e95b8a0f18e16d5d747f7dc06049d5da2e4f77f6f5e4a1f46a8/markupsafe-3.0.4-cp315-cp315t-win_arm64.whl", hash = "sha256:39dbacefc411633db5b4378b066a9aca70a3d7e2922c9e578d825f844026eeba", size = 14417, upload-time = "2026-10-02T23:06:56.246Z" }, ] +[[package]] +name = "mcp" +version = "1.30.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "anyio" }, + { name = "httpx" }, + { name = "httpx-sse" }, + { name = "jsonschema" }, + { name = "pydantic" }, + { name = "pydantic-settings" }, + { name = "pyjwt", extra = ["crypto"] }, + { name = "python-multipart" }, + { name = "pywin32", marker = "sys_platform == 'win32'" }, + { name = "sse-starlette" }, + { name = "starlette" }, + { name = "typing-extensions" }, + { name = "typing-inspection" }, + { name = "uvicorn", marker = "sys_platform != 'emscripten'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/ba/93/0142dc84a666daf8ad51a34268f34c12fd6fda4f3810c4be2504eecc8212/mcp-1.30.0.tar.gz", hash = "sha256:445414625fce5c295faa505bb11bacece661ab6f4028d57c935db57820b7a3e4", size = 680511, upload-time = "2026-09-07T14:34:15.845Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/f5/f4/e58bc33317c92a0203664daaf00bf6f41166cc0149e5d6870a03f7cd004a/mcp-1.30.0-py3-none-any.whl", hash = "sha256:666edb5009503e1047c9d60346a756f94b261f05cc2625f23d41c728ffc484d0", size = 234581, upload-time = "2026-09-07T14:34:14.266Z" }, +] + [[package]] name = "mdurl" version = "0.1.2" @@ -2260,6 +2450,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/8f/dc/53df8b6931d47080b4fe4ee8450d42e660ee1c5c1556c7ab73359182b769/pyclipper-1.4.0-cp314-cp314t-win_amd64.whl", hash = "sha256:29dae3e0296dff8502eeb7639fcfee794b0eec8590ba3563aee28db269da6b04", size = 117608, upload-time = "2025-12-01T13:15:32.69Z" }, ] +[[package]] +name = "pycparser" +version = "3.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/1b/7d/92392ff7815c21062bea51aa7b87d45576f649f16458d78b7cf94b9ab2e6/pycparser-3.0.tar.gz", hash = "sha256:600f49d217304a5902ac3c37e1281c9fe94e4d0489de643a9504c5cdfdfc6b29", size = 103492, upload-time = "2026-01-21T14:26:51.89Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/0c/c3/44f3fbbfa403ea2a7c779186dc20772604442dde72947e7d01069cbe98e3/pycparser-3.0-py3-none-any.whl", hash = "sha256:b727414169a36b7d524c1c3e31839a521725078d7b2ff038656844266160a992", size = 48172, upload-time = "2026-01-21T14:26:50.693Z" }, +] + [[package]] name = "pydantic" version = "2.13.5" @@ -2373,6 +2572,20 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/71/46/17f022dd3e953bf20a04a028a21ec746d942f8d2af30fa0f124fa0e6a684/pygments-2.21.0-py3-none-any.whl", hash = "sha256:2363c69b61c4a97c838da3b130dcd6468f4848992b21a82f2a63ec34377137d9", size = 1250147, upload-time = "2026-08-17T08:02:44.912Z" }, ] +[[package]] +name = "pyjwt" +version = "2.15.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/43/ea/5194e52748b0da83d71e082d75496eaec6e58f419f5e184786ded517e6a9/pyjwt-2.15.1.tar.gz", hash = "sha256:4f259e80cdfb6b3fc18a7de51fd1ef9ec79652f25019bae68975ca2468a34df8", size = 121252, upload-time = "2026-09-28T18:40:42.598Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/50/ca/44de4e75f8aadc457f0634be3b542815078ded46dca30efb960edeecad6e/pyjwt-2.15.1-py3-none-any.whl", hash = "sha256:42d59d631f7768a1028a64c7ff581a9bf7519804daf91fc5b6c56e30eec5e193", size = 33860, upload-time = "2026-09-28T18:40:41.429Z" }, +] + +[package.optional-dependencies] +crypto = [ + { name = "cryptography" }, +] + [[package]] name = "pylatexenc" version = "2.11" @@ -2476,6 +2689,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/60/d1/38f3a3405989a89ac18390803e70c6ad7c7760da4f9b83cbeca0c44a0c72/python_dotenv-1.2.4-py3-none-any.whl", hash = "sha256:42269a8a5b3fd54ffa6f3d84b18abed50064717576b4ecf03dc4a55d8aa04fdc", size = 23266, upload-time = "2026-10-01T05:36:08.633Z" }, ] +[[package]] +name = "python-multipart" +version = "0.0.32" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/5b/42/55c32bb9b12693c092ad250a0e82edb5b31ddeda6eb772de5f308b3804ad/python_multipart-0.0.32.tar.gz", hash = "sha256:be54b7f3fa167bb83e4fcd936b887b708f4e57fe75911c02aebf53efaf8d938e", size = 46881, upload-time = "2026-06-04T16:18:58.647Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/e1/04/e8135ebd1ad02c56ec633277529b2602ff99ff634be76cdba5744cf554fd/python_multipart-0.0.32-py3-none-any.whl", hash = "sha256:ff6d3f776f16878c894e52e107296ffc890e913c611b1a4ec6c44e2821fe2e23", size = 30042, upload-time = "2026-06-04T16:18:57.319Z" }, +] + [[package]] name = "python-oxmsg" version = "0.0.2" @@ -2861,6 +3083,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/3f/50/0a9e7e7afe7339bd5e36911f0ceb15fed51945836ed803ae5afd661057fd/rtree-1.4.1-py3-none-win_arm64.whl", hash = "sha256:3d46f55729b28138e897ffef32f7ce93ac335cb67f9120125ad3742a220800f0", size = 355253, upload-time = "2025-08-13T19:32:00.296Z" }, ] +[[package]] +name = "ruamel-yaml" +version = "0.19.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/c7/3b/ebda527b56beb90cb7652cb1c7e4f91f48649fbcd8d2eb2fb6e77cd3329b/ruamel_yaml-0.19.1.tar.gz", hash = "sha256:53eb66cd27849eff968ebf8f0bf61f46cdac2da1d1f3576dd4ccee9b25c31993", size = 142709, upload-time = "2026-01-02T16:50:31.84Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/b8/0c/51f6841f1d84f404f92463fc2b1ba0da357ca1e3db6b7fbda26956c3b82a/ruamel_yaml-0.19.1-py3-none-any.whl", hash = "sha256:27592957fedf6e0b62f281e96effd28043345e0e66001f97683aa9a40c667c93", size = 118102, upload-time = "2026-01-02T16:50:29.201Z" }, +] + [[package]] name = "ruff" version = "0.16.10" @@ -3087,6 +3318,32 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/66/87/5ed59e1d0290564e2027ed066c52b059892c4637741337fc0967183c8d4d/soupsieve-2.10-py3-none-any.whl", hash = "sha256:8596eb8967d744174820280fa62b4542a2e955bfaccca73ed8a13c6eb8e9b502", size = 38019, upload-time = "2026-09-24T02:36:33.709Z" }, ] +[[package]] +name = "sse-starlette" +version = "3.5.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "anyio" }, + { name = "starlette" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/e4/be/0123026f719d1a7936f214a88b553bb5701e04ff2511147c1dab0c5035eb/sse_starlette-3.5.0.tar.gz", hash = "sha256:75de713aa8a9441513cc283220826da079d982770965b951e9437720e8bafdb2", size = 36794, upload-time = "2026-09-28T17:48:14.7Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/be/e4/cdda14023c316d71493bc54fdffc3dd006631b88866145c9d3cc33e0f1df/sse_starlette-3.5.0-py3-none-any.whl", hash = "sha256:3e6e1070df3f0f5d9cea81496de92dbb72f6721871d99748ece67441dd8b7997", size = 17407, upload-time = "2026-09-28T17:48:13.228Z" }, +] + +[[package]] +name = "starlette" +version = "1.7.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "anyio" }, + { name = "typing-extensions", marker = "python_full_version < '3.13'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/7b/2b/3850dc6bf7ef71b088962eba31dafc6cffd2f96e577ebb0bb316df96da3e/starlette-1.7.0.tar.gz", hash = "sha256:c79f74ea63cff761804fbbfb182f1e0b440c2d07b164d24700c5a1bab5d6ff5d", size = 2736246, upload-time = "2026-09-23T07:30:26.35Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/4e/d6/1ec1b290f9e0fb067899b61e1d37a30c923068bad260b216dbe37a7d2967/starlette-1.7.0-py3-none-any.whl", hash = "sha256:67f8e99895493dd2911a03f11314af6ceebeae4e704bb9f43dfc6a9db151c93e", size = 78980, upload-time = "2026-09-23T07:30:24.567Z" }, +] + [[package]] name = "sympy" version = "1.14.0" @@ -3161,6 +3418,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/d7/b0/dee84cb44175be1b4c35bd2f770727494e78f0bb38e571a623ade94dbebb/tokenizers-0.23.2-cp310-abi3-win_arm64.whl", hash = "sha256:e49c394456dd9985787fec76132438ba3fb8911f857b1bf3d40119f9292d41aa", size = 2729352, upload-time = "2026-09-03T08:55:44.345Z" }, ] +[[package]] +name = "tomlkit" +version = "0.15.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/94/96/e07752635b98536177fa1f37671c8f3cdde2e724c6bcf6034b2cfb571565/tomlkit-0.15.1.tar.gz", hash = "sha256:e25bbf38843005246210a12982776f27f99cb9be67160e14434d0c0d21ee1e97", size = 180129, upload-time = "2026-07-17T01:48:04.562Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/13/bc/8c13eb66537dce1d2bd3a57132902f38d0e7f5bb46fa9f4daed9fe9d76ee/tomlkit-0.15.1-py3-none-any.whl", hash = "sha256:177a05aece5a8ca5266fd3c448abb47b8d352f09d477d3ca8332db4d89b24304", size = 49449, upload-time = "2026-07-17T01:48:05.728Z" }, +] + [[package]] name = "torch" version = "2.14.1" @@ -3476,6 +3742,19 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/92/9d/c4e665119135114480843e7ab388fa94d8480650450e6f8e26b70d323a4c/urllib3-2.8.0-py3-none-any.whl", hash = "sha256:0cf3cae568d36aa9576b28dfb35f11328f1cb974ca7647d9475ebb86c75ac6e3", size = 135717, upload-time = "2026-09-15T19:29:34.577Z" }, ] +[[package]] +name = "uvicorn" +version = "0.54.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "click", marker = "sys_platform != 'emscripten'" }, + { name = "h11", marker = "sys_platform != 'emscripten'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/da/34/30e9280707135d2cfc589dfff3cb796bd07a3aeb1a3e415ba09dd89d7bb4/uvicorn-0.54.0.tar.gz", hash = "sha256:a2e33cbfaa0306f8e6b0c13e0cb89d7d7a2da3e62b90c66e18c33d9807b28620", size = 112283, upload-time = "2026-09-25T06:52:37.601Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/38/0c/b54a4fdd7f90a3af8b02ebc9ce6712c2c208b7926a2f7bad95c33ebbe943/uvicorn-0.54.0-py3-none-any.whl", hash = "sha256:505bdb0f318731d45f1f712071fc781a8981f6847a31c902c9f5e652d4f67faf", size = 87427, upload-time = "2026-09-25T06:52:35.829Z" }, +] + [[package]] name = "websockets" version = "16.1.1"