Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
# Changelog

## 0.10.0 (2026-11-16)

Follows API 1.20.11, as 0.9.1 did. The saved spec has 163 operations and the models are regenerated from it.
No client method, argument or return type changed. Every model a method takes or returns is kept.

### Removed

70 models are gone from `faxforagents.models`, which now has 174. No method of `Client` or `AsyncClient` takes or returns them, directly or in a field.
The public document of API 1.20.11 does not define them. They came from the server's own document in 0.2.2 and 0.2.3.
Under 0.x a minor release can break imports, and this one does. Code that imports one of them has to drop the import. Nothing replaces them.

- The admin console under `/v1/admin`, 43 models: `AbuseReview`, `AbuseReviewCreate`, `AbuseReviewPage`, `AbuseReviewPatch`, `Adjustment`, `AdjustmentApply`, `AdjustmentCreate`, `AdjustmentPage`, `AdminAction`, `AdminBrief`, `AdminDaily`, `AdminDailyPoint`, `AdminJob`, `AdminJobPage`, `AdminOrganization`, `AdminOrganizationDetail`, `AdminOrganizationPage`, `AdminRevenue`, `AdminStats`, `AdminWhoami`, `AnalyticsJourneys`, `AnalyticsOrganization`, `AnalyticsSource`, `AnalyticsSources`, `AnalyticsUsage`, `AnalyticsWebsite`, `AuditEvent`, `AuditEventPage`, `Client`, `ClientList`, `OutboxDiscarded`, `OutboxPage`, `OutboxRow`, `ProviderHealth`, `ProviderList`, `ReconcileResult`, `ReconciliationReport`, `ReleaseResult`, `ReviewAccessAction`, `ReviewAccessCreate`, `ReviewAccessIssued`, `RouteList`, `RouteState`.
- The dashboard sign-in under `/v1/auth`, 17 models: `Accepted`, `MagicLinkRequest`, `Passkey`, `PasskeyList`, `PasskeyLoginVerify`, `PasskeyRegisterVerify`, `Providers`, `Reauth`, `ReviewSignIn`, `Revoked`, `Sent`, `SessionInfo`, `SessionList`, `SessionOut`, `SwitchOrganization`, `UserOut`, `faxforagents__auth__schemas__Me`.
- The OAuth consent calls under `/v1/oauth/authorizations`, 5 models: `OAuthConsent`, `OAuthConsentClient`, `OAuthConsentDecision`, `OAuthConsentOrganization`, `OAuthRedirect`.
- The Stripe and Telnyx receivers under `/webhooks`, 2 models: `TelnyxAck`, `WebhookAck`.
- The server's module-qualified names for `InboxItem`, `InboxItemSummary` and `Me`, 3 models: `faxforagents__api__routes__inbox__InboxItem`, `faxforagents__api__schemas__InboxItem`, `faxforagents__api__schemas__Me`. The plain names stay.

`faxforagents.models.Client` described an OAuth client in the admin console. `faxforagents.Client`, the client of this package, is not affected.

`scripts/gen_models.py` now writes a model only for a schema that an operation reaches. The public document is curated by the same rule.
A refresh of the spec that brings one of these schemas back still leaves it out of `models.py`.
`tests/test_removed_models.py` fails when one of the 70 is back, or when the saved spec holds a schema that no operation reaches.

## 0.9.1 (2026-11-16)

Follows API 1.20.11. The saved spec has 163 operations and the models are regenerated from it.
Expand Down Expand Up @@ -181,7 +204,7 @@ The package metadata links to the pricing page and the dashboard. The README nam

## 0.3.2 (2026-11-10)

`identity.create_api_key` takes `connected_app` on both clients. A key made with `connected_app=True` is bound by the auto-send setting like an OAuth connection.
`identity.create_api_key` takes `connected_app` on both clients. An API key made with `connected_app=True` is bound by the auto-send setting like an OAuth connection.
The field is sent only when given, so existing calls send the same body. Needs API 1.12.0.

The saved spec follows the public document at API 1.13.2. No operation or schema changed.
Expand All @@ -205,7 +228,7 @@ Existing model names, fields and optionality are kept.

## 0.2.4 (2026-11-09)

`quotes.create` takes `quality`: standard, fine (the default), superfine or ultra. `Quote` and `FaxJob` carry it. The CLI has `--quality`. Needs API 1.11.0; older servers refuse the field.
`quotes.create` takes `quality`: standard, fine (the default), superfine or ultra. `Quote` and `FaxJob` carry it. The CLI has `--quality`. Needs API 1.11.0. Older servers refuse the field.

## 0.2.3 (2026-11-02)

Expand Down
21 changes: 12 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ The same in async form, with `AsyncClient` and `await` on every call.
that follow `next_cursor`.
- `documents.create(text=...)`, `markdown=...` or `html=...` renders on the server. HTML prints with
scripts off and no network, inline CSS and `data:` images only, at most 2 MiB.
- `documents.upload(path)` runs the whole upload path for a PDF or an image (PNG, JPG, TIFF): the
upload session, the signed PUT with the content type read from the filename, the sha256 check, the
document. An image becomes gray letter pages.
- `documents.upload(path)` runs the whole upload path for a PDF or an image (PNG, JPG, TIFF). It covers
the upload session, the signed PUT with the content type read from the filename, the sha256 check and
the document. An image becomes gray letter pages.
- `documents.create_upload(filename=..., size_bytes=...)` needs no `content_type`. The API reads the
type from the filename and refuses a filename of another format at once with `unsupported_format`.
- `billing.statement()` reads the wallet one line per event, with the balance after each line.
Expand Down Expand Up @@ -186,9 +186,9 @@ if req.status == "approved":
An agent's own API key can never approve. `ffa.policies.evaluate(quote_id=...)` is a dry run that says
whether a policy would allow the send.

A key made for a connected app used over stdio, such as the Gemini CLI extension, is created with
An API key for a connected app used over stdio, such as the Gemini CLI extension, is created with
`connected_app=True`. The organization's auto-send setting (`ffa.policies.get_auto_send`) then binds it like
an OAuth connection. An agent's key cannot carry the flag.
an OAuth connection. An agent's API key cannot carry the flag.

```python
key = ffa.identity.create_api_key("gemini", scopes=["fax:send"], connected_app=True)
Expand Down Expand Up @@ -315,13 +315,16 @@ ruff check src tests && mypy src
sh scripts/truthcheck.sh
```

`spec/openapi.yaml` follows the public document at API version 1.20.11 and keeps the schemas of the earlier live documents.
The two validation error schemas are the exception. 0.5.0 removed them because the server never sent that shape.
`spec/openapi.yaml` follows the public document at API version 1.20.11. It has the same 163 operations and no schema that document lacks.
It also declares fields a route returns beyond the public schemas, in `InboxItemSummary` and `ExtractionPage`.
0.5.0 removed the two validation error schemas, because the server never sent that shape.
0.6.0 removed two cost fields of an extraction, because the server stopped sending them.
0.8.0 replaced five fields it had declared itself with the public ones, such as `Quote.policy_evaluation`.
0.9.0 leaves `Delivery.webhook_deleted` optional, where the public document requires it.
It also retains earlier public model names and route-documented response additions.
To refresh it, merge the live schemas while preserving existing declarations, then run `uv run python scripts/gen_models.py`.
0.10.0 removed the 70 schemas of earlier server documents that no operation reaches, such as those of the admin console.
`scripts/gen_models.py` writes a model only for a schema an operation reaches, through its paths, a shared response or a field.
If a refresh brings in a schema that no operation reaches, it gets no model and `tests/test_removed_models.py` fails.
To refresh it, merge the public document while preserving existing declarations, then run `uv run python scripts/gen_models.py`.
Keep new response fields optional so older payloads and existing callers remain valid.
The schema drift test compares every saved schema property with the generated declarations without network access.

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "faxforagents"
version = "0.9.1"
version = "0.10.0"
description = "Python client for Fax for Agents: a fax API, a hosted MCP server and SDKs built so AI agents can send and receive faxes."
readme = "README.md"
requires-python = ">=3.10"
Expand Down
55 changes: 48 additions & 7 deletions scripts/gen_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@
"""Generate ``src/faxforagents/models.py`` (pydantic v2) from ``spec/openapi.yaml``.

The spec is the public document of https://github.com/faxforagents/openapi, copied into ``spec/`` so
the build is hermetic. Every ``components.schemas`` entry becomes a ``BaseModel``. Response models
allow extra fields (the API adds fields without a major version). Request models forbid them, as the
server does (``additionalProperties: false``). A field named ``from``, or one that is an attribute of
pydantic's BaseModel such as ``schema``, is ``from_`` or ``schema_`` with the alias ``from`` or
``schema``. Nullable fields are ``X | None``. Enums are ``Literal``.
the build is hermetic. Every ``components.schemas`` entry that an operation reaches becomes a
``BaseModel``. An operation reaches a schema through its parameters, request body and responses, a
shared response in ``components.responses``, or a field of another schema it reaches. A schema that no
operation reaches gets no model, even when a refresh of the spec brings one in from the server's own
document. The public document holds the same set, because its curate.py keeps only what the public
operations reach. 0.10.0 removed 70 such models, among them those of the admin console.

Response models allow extra fields (the API adds fields without a major version). Request models forbid
them, as the server does (``additionalProperties: false``). A field named ``from``, or one that is an
attribute of pydantic's BaseModel such as ``schema``, is ``from_`` or ``schema_`` with the alias ``from``
or ``schema``. Nullable fields are ``X | None``. Enums are ``Literal``.

Usage::

Expand Down Expand Up @@ -140,6 +146,36 @@ def walk(node: Any) -> None:
return out


def reached_schemas(spec: dict[str, Any]) -> set[str]:
"""The names of the schemas an operation reaches. Only these become models.

The walk starts at ``paths`` (and ``webhooks``, if the document has any) and follows every
``$ref`` into ``components``: a shared response leads to its schema, a schema to the schemas of its
fields. A schema nothing points at is not reached, whatever it points at itself.
"""
components = spec.get("components") or {}
seen: set[tuple[str, str]] = set()

def walk(node: Any) -> None:
if isinstance(node, dict):
ref = node.get("$ref")
if isinstance(ref, str) and ref.startswith("#/components/"):
kind, _, name = ref[len("#/components/") :].partition("/")
if (kind, name) not in seen:
seen.add((kind, name))
walk((components.get(kind) or {}).get(name))
for v in node.values():
walk(v)
elif isinstance(node, list):
for v in node:
walk(v)

walk(spec.get("paths") or {})
walk(spec.get("webhooks") or {})
defined = set(components.get("schemas") or {})
return {name for kind, name in seen if kind == "schemas" and name in defined}


def order(schemas: dict[str, Any]) -> list[str]:
done: list[str] = []
seen: set[str] = set()
Expand Down Expand Up @@ -204,7 +240,8 @@ def render_model(name: str, schema: dict[str, Any]) -> str:


def render(spec: dict[str, Any]) -> str:
schemas = spec["components"]["schemas"]
reached = reached_schemas(spec)
schemas = {name: schema for name, schema in spec["components"]["schemas"].items() if name in reached}
names = order(schemas)
body = "\n\n".join(render_model(n, schemas[n]) for n in names)
all_names = ", ".join(f'"{n}"' for n in names)
Expand All @@ -223,14 +260,18 @@ def main() -> int:
args = ap.parse_args()
spec = yaml.safe_load(SPEC.read_text("utf-8"))
text = render(spec)
reached = reached_schemas(spec)
left_out = sorted(set(spec["components"]["schemas"]) - reached)
if left_out:
print(f"no model for the schemas no operation reaches: {', '.join(left_out)}")
if args.check:
if not OUT.exists() or OUT.read_text("utf-8") != text:
print("src/faxforagents/models.py is stale: run scripts/gen_models.py", file=sys.stderr)
return 1
print("models.py is current")
return 0
OUT.write_text(text, "utf-8")
print(f"wrote {OUT.relative_to(ROOT)}: {len(spec['components']['schemas'])} models")
print(f"wrote {OUT.relative_to(ROOT)}: {len(reached)} models")
return 0


Expand Down
Loading
Loading