Repository navigation
Support Cloudflare AI Gateway as a saved provider - #4
rknightion wants to merge 8 commits into
Conversation
Cloudflare serves Jev as a Workers AI model at
<gateway>/workers-ai/run/typesafe/jev with Unified Billing. Auth saves the
account's gateway URL (gateway.ai.cloudflare.com/v1/ACCOUNT/GATEWAY or a
custom domain) alongside the token. The evaluator adapts that one request:
path from the saved URL, token as cf-aig-authorization, model taken from the
path, {state, result} envelope unwrapped, redirects refused.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016dpmZNjz5QApmRBSwvz2Ne
… the spec
Adds cloudflare to the reference transport and provider replay, the installed
saved-provider journey, conflicting-environment and invalid-record cases, and
the interactive auth prompt, all through a canonical fixture gateway routed by
the test-only preload. Only a {state: "Completed", result} envelope yields an
answer. specs/done/cloudflare-provider records the route evidence, choices and
verification.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016dpmZNjz5QApmRBSwvz2Ne
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016dpmZNjz5QApmRBSwvz2Ne
|
thanks! did you use the repo's spec and implement skills by any chance? looks like claude followed the internal conventions pretty well and did you test it? |
Resolves to upstream's tree; the Cloudflare provider is re-ported onto the custom-endpoint seams in the next commit.
Cloudflare becomes a credential provider beside custom: its record is
{provider, baseURL, apiKey}, auth takes the gateway URL through the shared
--base-url flag and validateBaseURL, and endpointFor resolves it. The
evaluator still adapts the one request to the Workers AI route
(cf-aig-authorization, no model field, Completed envelope, no redirects).
A gateway URL that already carries a /workers-ai or /compat route is
rejected instead of doubled.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UsM3MRh2GKBUmaPwA5E322
…skills refactor-clean: drop the Cloudflare-only cache namespace (provider and gateway URL already isolate it), simplify the envelope unwrap, and give the saved-provider order one owner, credentialProviders, used by the menu, argument validation and errors. code-review: no unused-binding suppression or type cast. write-docs: link the provider record from the CLI README. audit-choices: rewrite the choices ledger per the skill. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UsM3MRh2GKBUmaPwA5E322
|
No, to be honest. I had Claude build it, but it matched the conventions by reading the existing specs in Since then I've merged main in (merge commit, no force push) and re-ported it onto the custom endpoint work from #28. Cloudflare still can't just be a custom endpoint - CF only serves Jev on the Workers AI route ( I did run the repo's skills over it this time: review (refactor-clean, code-review, write-docs) then audit-choices on the whole change. That dropped a Cloudflare-specific cache namespace it didn't need (provider + baseURL already keep it separate), simplified the envelope unwrap, gave the provider order one owner ( Two things in choices.md are your call:
Testing, yes. |
Adds Cloudflare AI Gateway as a saved provider, alongside the presets and the custom endpoint from #28.
Cloudflare serves Jev (
typesafe/jev) with Unified Billing, but only on the gateway's Workers AI route,<gateway>/workers-ai/run/typesafe/jev. That route takes the model from the path and the token ascf-aig-authorization, and wraps the answer as{state: "Completed", result}. The TypeSafe paths (/typesafe/v1/systemoneand friends) return2008 Invalid provider, so it can't be set up as a custom endpoint.Setup
Or pick "Cloudflare AI Gateway" in
jg auth. The gateway URL can also be the gateway's custom domain. The token needs the account's AI Gateway Run permission.How it works
{provider: "cloudflare", baseURL, apiKey}. It sharesbaseURL,--base-urlandvalidateBaseURLwith the custom provider and has nomodel;--modelis rejected.endpointForstrips a trailing slash and rejects a URL that already has a/workers-aior/compatroute on it.modelin the body, andredirect: "error"so the custom header can't follow a cross-origin redirect. Only a Completed envelope yields an answer. Anything else fails validation and is never scored.credentialProvidersinproviders.tsowns the provider order (presets, Cloudflare, custom last) for the auth menu, argument checks and error text.The spec record, research and choices ledger are in
specs/done/cloudflare-provider/.Testing
bun run test(Docker): 125 bun, 18 provider protocol, 39 parser, 4 release and 30 harness tests passbun run test:installed: 42/42, including the cloudflare auth, doctor, search, cache and replacement journey and invalid Cloudflare recordsoxfmt --check .only flags upstream files this PR doesn't touchFor you to decide
validateBaseURL's empty-value message is now neutral, since two providers use itretry-afterand ended incomplete