Commit Graph

16 Commits

  • feat(ai): switch xiaomi default to api billing, add per-region token plan providers (#4112)
    Built-in `xiaomi` provider now targets the API billing endpoint (https://api.xiaomimimo.com/anthropic) — a single stable URL for keys issued at platform.xiaomimimo.com. The Token Plan endpoints are exposed as three sibling providers, each with its own env var:
    
    - xiaomi-token-plan-cn: XIAOMI_TOKEN_PLAN_CN_API_KEY
    - xiaomi-token-plan-ams: XIAOMI_TOKEN_PLAN_AMS_API_KEY
    - xiaomi-token-plan-sgp: XIAOMI_TOKEN_PLAN_SGP_API_KEY
    
    BREAKING CHANGE: users who previously set XIAOMI_API_KEY against the Token Plan AMS endpoint must move to xiaomi-token-plan-ams and set XIAOMI_TOKEN_PLAN_AMS_API_KEY. This also resolves the 401 reported by on #4005, where a platform.xiaomimimo.com key fails against the Token Plan endpoint.
    
    closes #4082
  • feat(ai): add Xiaomi MiMo provider (#4005)
    * fix(ai): include minimax-cn in cross-provider-handoff matrix
    
    * feat(ai): add Xiaomi MiMo provider
    
    Adds Xiaomi MiMo as an openai-completions-compatible provider.
    
    - packages/ai: register provider in types/KnownProvider, env-api-keys (XIAOMI_API_KEY), generate-models, models.generated.ts, overflow util, README, CHANGELOG
    - packages/ai/test: extend stream, tokens, abort, empty, context-overflow, overflow, image-tool-result, tool-call-without-result, total-tokens, unicode-surrogate, cross-provider-handoff matrices with Xiaomi
    - packages/coding-agent: default model (mimo-v2.5-pro), display name (Xiaomi MiMo), CLI env var docs, README, docs/providers.md
    
    closes #3912
    
    ---------
    
    Co-authored-by: Mario Zechner <badlogicgames@gmail.com>
  • feat(ai): add Cloudflare Workers AI as a provider (#3851)
    * feat(ai): add Cloudflare Workers AI as a provider
    
    Cloudflare Workers AI hosts open-weight LLMs (Kimi K2.6, GPT-OSS,
    GLM-4.7, Llama 4, Gemma 4, Nemotron 3) on Cloudflare's GPU network with
    an OpenAI-compatible endpoint. Reuses the openai-completions API
    protocol; the per-account URL contains a {CLOUDFLARE_ACCOUNT_ID}
    placeholder resolved at request time by a small helper.
    
    Pi automatically sets x-session-affinity for prefix caching:
    https://developers.cloudflare.com/workers-ai/features/prompt-caching/
    
    Auth: CLOUDFLARE_API_KEY (matches pi's *_API_KEY convention) +
    CLOUDFLARE_ACCOUNT_ID. The User-Agent identifies traffic as
    'pi-coding-agent' in Cloudflare analytics.
    
    Verified end-to-end against a real Cloudflare account: 17 e2e tests
    pass across stream/empty/tokens/unicode/tool-call-without-result/
    total-tokens against @cf/moonshotai/kimi-k2.6.
    
    Cloudflare AI Gateway is a separate, larger change (it requires routing
    through provider-specific subpaths with the matching API protocol per
    upstream) and will land in a follow-up PR.
    
    * refactor(ai): move Cloudflare User-Agent and session-affinity flag to per-model metadata
    
    Instead of conditionally setting them in openai-completions.ts based on
    provider detection, declare them as model-level fields in the catalog
    (headers + compat). This is consistent with how the github-copilot and
    kimi-coding entries already declare their static headers.
    
      packages/ai/scripts/generate-models.ts: emit headers and compat fields
      on each cloudflare-workers-ai entry (CLOUDFLARE_STATIC_HEADERS).
      packages/ai/src/providers/openai-completions.ts: drop the
      isCloudflareProvider conditional that injected User-Agent and the
      isCloudflareWorkersAI override of sendSessionAffinityHeaders.
      packages/ai/src/models.generated.ts: re-spliced 8 cloudflare-workers-ai
      entries with headers + compat.
    
    Behavior is unchanged - verified via fetch interceptor that User-Agent
    and x-session-affinity / session_id / x-client-request-id are still sent
    on outbound requests. 5/5 e2e tests pass.
  • fix(typebox): migrate to v1 with extension compat (#3474)
    * fix(typebox): migrate to v1 with extension compat
    
    Replace AJV-based validation with TypeBox-native validation, keep legacy extension imports working (including @sinclair/typebox/compiler), and restore coercion for serialized/plain JSON schemas.
    
    This change closes #3112.
    
    * fix(typebox): use canonical imports and harden coercion
    
    Switch first-party code to canonical typebox imports while retaining legacy extension aliases in the loader.
    
    Remove obsolete runtime codegen guards, expand serialized JSON-schema coercion coverage, and update related tests and fixtures.
    
    Fixes #3112.
    
    ---------
    
    Co-authored-by: Mario Zechner <badlogicgames@gmail.com>
  • feat(ai): add Kimi For Coding provider support
    - Add kimi-coding provider using Anthropic Messages API
    - API endpoint: https://api.kimi.com/coding/v1
    - Environment variable: KIMI_API_KEY
    - Models: kimi-k2-thinking (text), k2p5 (text + image)
    - Add context overflow detection pattern for Kimi errors
    - Add tests for all standard test suites
  • feat(ai): add Hugging Face provider support
    - Add huggingface to KnownProvider type
    - Add HF_TOKEN env var mapping
    - Process huggingface models from models.dev (14 models)
    - Use openai-completions API with compat settings
    - Add tests for all provider test suites
    - Update documentation
    
    fixes #994
  • fix(ai): skip cross-provider-handoff tests when no API keys available
    Tests were throwing errors instead of skipping on CI where no API keys
    are configured. Now uses describe.skipIf() and it.skipIf() patterns
    consistent with other tests in the package.