Skip to content

Catalog: add xAI (Grok) + Cohere, bump Moonshot default to kimi-k2 - #163

Merged
FMXExpress merged 2 commits into
mainfrom
claude/catalog-add-xai-cohere
Jun 6, 2026
Merged

FMXExpress merged 2 commits into
mainfrom
claude/catalog-add-xai-cohere

Conversation

@FMXExpress

Copy link
Copy Markdown
Owner

Summary

Cross-referenced MakerAi's provider list against our 19-entry catalog. (Note: did not read MakerAi's code — only confirmed which providers it ships, then implemented PasClaw's own catalog entries for the ones we were missing.)

The user-listed model families fall into three buckets:

User-listed family Bucket Action
Claude (claude-opus-4-7, claude-sonnet-4-6, claude-haiku-4-5) Already covered as MODEL names None — operator picks the model per-config
Gemini (gemini-3.1-pro, gemini-3-flash, gemini-3.1-flash-lite, gemini-3.1-flash-image) Already covered as MODEL names None
Mistral (magistral-medium/small, devstral, voxtral) Already covered as MODEL names Updated notes column to list them
Groq (llama-4-scout/maverick, kimi-k2, qwen3, compound-beta) Already covered as MODEL names Updated notes column to list them
Kimi (kimi-k2, kimi-k2.5, kimi-k2-thinking) Already covered (Moonshot entry) Bumped stale moonshot-v1-32k default → kimi-k2
Cohere (command-a-03-2025, command-a-reasoning, command-a-vision) Missing as a provider Added (pfPlaceholder)
Grok (grok-4-fast, grok-3, grok-code-fast-1) Missing as a provider Added (pfOpenAI, fully functional)

Adds

xAI / Grok — https://api.x.ai/v1/chat/completions, Bearer auth, strict OpenAI-compatible request/response. The existing pfOpenAI provider talks to it unchanged — just a new catalog row. Default model grok-4-fast; operator can override to grok-3 / grok-code-fast-1 / grok-2 via config or onboarding.

Cohere v2 — https://api.cohere.com/v2/chat, Bearer auth. Path differs from OpenAI's /v1/chat/completions, and PasClaw.Providers.OpenAI hard-codes the OpenAI path. Landed as pfPlaceholder so:

  • The kind validates in config.json
  • It appears in pasclaw onboard like every other provider
  • Selecting it surfaces the existing pfPlaceholder error ("Cohere is in the catalog but its protocol implementation is not yet bundled in this build") instead of a confusing 404 at request time

Follow-up PR can add a dedicated TCohereProvider that mirrors the v2 wire shape (messages array, tool_calls similar to OpenAI but with citations / search_queries surfaced on assistant turns).

Stale default bumped

Moonshot's default was moonshot-v1-32k — the Kimi V1 generation, deprecated. Bumped to kimi-k2 (current generation; matches the user's primary listed Kimi model).

Test plan

  • Catalog size 19 → 21.
  • LookupProvider('xai') resolves: Kind=xai, Family=pfOpenAI, DefaultBase=https://api.x.ai, DefaultModel=grok-4-fast.
  • LookupProvider('cohere') resolves: Kind=cohere, Family=pfPlaceholder, DefaultBase=https://api.cohere.com, DefaultModel=command-a-03-2025.
  • NewProviderFromConfig('xai') constructs a working TOpenAIProvider (verified GetName=xai, GetDefaultModel=grok-4-fast).
  • NewProviderFromConfig('cohere') returns False with ErrMsg = "provider \"Cohere\" is in the catalog but its protocol implementation is not yet bundled in this build".
  • All unrelated test suites green: hashline, anthropic-server-tools, openai-server-tools, println-helper, utf8-codepage-tag, gemini-schema-strip, markdown-render, json-utf8-roundtrip.
  • Live pasclaw agent against an xAI API key to confirm the wire trip is clean end-to-end (no key in CI).

test-toolview is the pre-existing ellipsis-glyph mojibake — fixed in PR #162, not yet merged. Unrelated to this change.

Not in this PR (separate concern)

The user also raised: "maybe we need to upgrade pasclaw onboarding so that after you pick a provider and enter an api key then it uses the /models api endpoint of that provider to get a list of models for you to choose from?"

That's a worthwhile feature but a substantial standalone change — needs per-provider /models endpoint discovery (OpenAI's GET /v1/models, Anthropic's GET /v1/models, Gemini's GET /v1beta/models, xAI's GET /v1/models, each with their own response shape), an interactive picker UI, and tests. Happy to do it next PR if you want.


Generated by Claude Code

Cross-referenced MakerAi's provider list against our 19-entry
catalog. The user-listed model families fall into three buckets:

  Already covered as MODEL names within an existing entry —
    Claude (anthropic), Gemini (gemini), Mistral (mistral),
    Groq (groq), Kimi (moonshot), DeepSeek (deepseek). Operator
    sets the specific model on the per-config line; no catalog
    change needed for these.

  Missing AS PROVIDERS (this commit) — xAI/Grok, Cohere.

  Already in the catalog with a stale default — Moonshot's default
    was moonshot-v1-32k (Kimi V1 generation, deprecated). Bumped
    to kimi-k2 which is what current MakerAi configs use and what
    the user listed first under Kimi.

xAI ships a strict OpenAI-compatible chat-completions endpoint at
https://api.x.ai/v1/chat/completions with Bearer auth. The existing
pfOpenAI provider talks to it unchanged — just a new catalog row.
Default model grok-4-fast; operator can override to grok-3 /
grok-code-fast-1 / grok-2 etc. via config or onboarding.

Cohere v2 ships its chat API at https://api.cohere.com/v2/chat —
same Bearer auth as OpenAI but a different URL path
(/v2/chat vs /v1/chat/completions). PasClaw.Providers.OpenAI
hard-codes the OpenAI path, so Cohere can't piggyback without
making the path configurable. Landed as pfPlaceholder so:

  - The kind validates in config.json,
  - It appears in `pasclaw onboard` like every other provider,
  - Selecting it surfaces the existing pfPlaceholder error
    ("Cohere is in the catalog but its protocol implementation is
    not yet bundled in this build") instead of a confusing 404 at
    request time.

Future PR can add a dedicated TCohereProvider that mirrors the v2
wire shape (messages array, tool_calls similar to OpenAI but with
the citations / search_queries surfaced on assistant turns).

Also tightened the catalog notes column on three rows where the
displayed model list was outdated next to the user's current
generation (Groq → Llama-4 / Kimi K2 / Qwen3 / compound-beta,
Mistral → Magistral / Devstral / Voxtral added, Gemini → Gemini 3
generation).

Verified:
  - Catalog size 21 (was 19).
  - LookupProvider('xai') / LookupProvider('cohere') resolve with
    the right Kind / Family / DefaultBase / DefaultModel.
  - NewProviderFromConfig('xai') constructs a working
    TOpenAIProvider with default model grok-4-fast.
  - NewProviderFromConfig('cohere') returns False with the clean
    pfPlaceholder ErrMsg.
  - All unrelated test suites still green (test-hashline,
    test-anthropic-server-tools, test-openai-server-tools,
    test-println-helper, test-utf8-codepage-tag,
    test-gemini-schema-strip, test-markdown-render,
    test-json-utf8-roundtrip). test-toolview is the pre-existing
    ellipsis-glyph mojibake (fixed in PR #162, not yet merged).

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 308c3ec375

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Result[8] := MkSpec('moonshot', 'Moonshot (Kimi)',
pfOpenAI, 'https://api.moonshot.cn',
'moonshot-v1-32k',
'kimi-k2',

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Use a live Moonshot model as the default

When a Moonshot provider entry leaves model blank, the factory and onboarding flow fall back to this catalog DefaultModel, so new/onboarded Moonshot users will now send model: "kimi-k2" by default. Moonshot/Kimi's current model list shows active models such as kimi-k2.6/kimi-k2.5 and marks the kimi-k2 series discontinued on May 25, 2026 (https://platform.kimi.ai/docs/models), so this default is likely to fail with model-not-found instead of providing the intended working Kimi default.

Useful? React with 👍 / 👎.

Three concerns landed on PR #163; this commit addresses all three.

Codex P2: kimi-k2 was discontinued.
  Moonshot retired the whole k2 series on 2026-05-25 (per
  https://platform.kimi.ai/docs/models), so the catalog's freshly-
  bumped kimi-k2 default would have 404'd new onboardings out of
  the gate. Bumped to kimi-k2.6 which Moonshot lists as the current
  flagship; added a comment noting the row is time-sensitive and
  needs refreshing when Moonshot rolls the next generation.

User: drop Cohere.
  pfPlaceholder gave operators a row they can pick from `pasclaw
  onboard` only to hit "implementation not yet bundled" — more
  noise than signal. Left a short comment in the same spot
  explaining why Cohere isn't there (the v2 chat path `/v2/chat`
  vs pfOpenAI's hard-coded `/v1/chat/completions`) so the next
  pass adding a real TCohereProvider has the context.

User: add LM Studio alongside Ollama.
  LM Studio runs an OpenAI-compatible server on port 1234 by
  default — same pfOpenAI + asNone profile as Ollama and vLLM.
  DefaultModel left empty because the loaded model id depends on
  whatever the operator downloaded in the LM Studio UI; LM Studio
  routes a missing model id to the currently-loaded one.

Catalog size 21 (was 19 on main: -1 cohere placeholder, +1 lmstudio,
+1 xai). Verified:

  - LookupProvider('cohere')   = False
  - LookupProvider('lmstudio') = True, base=http://localhost:1234,
                                 auth=asNone
  - LookupProvider('moonshot') = True, DefaultModel=kimi-k2.6
  - LookupProvider('xai')      = True, DefaultModel=grok-4-fast
  - NewProviderFromConfig('lmstudio') constructs a working
    TOpenAIProvider, same path as the existing ollama row.

All unrelated test suites green: hashline, anthropic-server-tools,
openai-server-tools, println-helper, utf8-codepage-tag,
gemini-schema-strip, markdown-render, json-utf8-roundtrip.
@FMXExpress
FMXExpress merged commit b3bb7d9 into main Jun 6, 2026
khongten001 pushed a commit to khongten001/PasClaw that referenced this pull request Jul 13, 2026
Lifts the "use the provider's /models endpoint" idea from
UltraCode-Shim's Auto Router (and the carry-over from PR FMXExpress#163's
followup question) into a complete loop: discover, cache, surface
in onboarding.

New unit: src/pkg/providers/PasClaw.Providers.Models.pas

  Three family parsers driven off TProviderSpec.Family:

    pfOpenAI     GET <base>/v1/models, Bearer auth (or asNone for
                 Ollama / vLLM / LM Studio). Parses `data[].id` +
                 `data[].created`. Used by 14 catalog rows that share
                 the OpenAI-compatible /v1/models shape — openrouter,
                 groq, deepseek, mistral, xai, qwen, zhipu, cerebras,
                 moonshot, ollama, vllm, lmstudio, litellm, openai.

    pfAnthropic  GET <base>/v1/models, x-api-key + anthropic-version
                 headers. Parses `data[].id` + `display_name` + ISO
                 `created_at`.

    pfGemini     GET <base>/v1beta/models, x-goog-api-key header.
                 Strips the "models/" namespace prefix from each
                 `name`, filters out rows that don't list
                 "generateContent" in supportedGenerationMethods
                 (embedders and counters live there too and would
                 404 the chat path).

  Cache at $PASCLAW_HOME/cache/models/<provider>.json with a
  fetched_at unix timestamp. JoinPath built up segment-by-segment
  so PathDelim insertion stays consistent on Windows (PR FMXExpress#169 trap).

  Discovery never raises; failure modes return Ok=False with a
  human-readable ErrMsg the caller surfaces verbatim. Empty result
  is Ok=True with Length=0 (the operator's call whether to retry).

New subcommands: src/cmd/PasClaw.Cmd.Model.pas

    pasclaw model refresh <provider>     hit /v1/models, save cache
    pasclaw model refresh --all          refresh every configured row
    pasclaw model list <provider>        show cached roster + age

  `pasclaw model show` now adds a cache-freshness annotation for the
  default provider — "models cached: 47 (refreshed 3 days ago)" or
  the gentle nudge "(none — run `pasclaw model refresh anthropic`
  to populate)" when no cache exists yet.

Onboarding picker: src/cmd/PasClaw.Cmd.Onboard.pas

  Flipped the order: now prompts for the API key BEFORE the model,
  so the key is available for the /v1/models fetch. Live fetch is
  bounded at 8s — onboarding is interactive, a slow provider status
  page shouldn't make the user wait 30s. On success: numbered
  picker over the top 12 newest models (sorted by created_at desc),
  with the option to type a free-form id or hit Enter for the
  catalog default. On failure: falls back to the existing text
  prompt verbatim so a broken /v1/models never blocks first-time
  setup.

  Both the full result AND a sort-truncated view get cached, so
  `pasclaw model list <provider>` later shows the whole roster
  even though the onboarding picker only displayed the top 12.

New test: src/tests/model_discovery_tests.pas

  Covers the cache schema contract (Save → Load round-trip preserves
  every field), missing-cache fallback (LoadCachedModels returns
  False, NOT True-with-empty-array), HumanAge bucket boundaries
  (minutes / hours / days / over-a-year cap), and case-insensitive
  ModelCachePath canonicalisation. Wired into `make test` as
  test-model-discovery.

Updated:
  - src/pasclaw/PasClaw.dproj: registers PasClaw.Providers.Models
    so the Delphi build resolves it too (PR FMXExpress#156 / FMXExpress#167 pattern).
  - README.md: maintenance section adds `model refresh` / `model list`
    examples + explains the onboarding picker behaviour.
  - Makefile: adds test-model-discovery target and rolls it into the
    composite `test:` target.

Verified end-to-end on Linux/FPC:

  $ pasclaw model show
    default provider: anthropic
    default model:    claude-opus-4-7
    models cached:    (none — run `pasclaw model refresh anthropic` to populate)

  $ pasclaw model refresh anthropic        # without a real key
      · fetching /models from Anthropic ...
      ✗ anthropic: API key required for Anthropic /models endpoint

  $ # synthesised cache file → list works:
  $ pasclaw model list openai
    openai (3 cached, refreshed over a year ago)
      · gpt-4o   (GPT-4o)
      · gpt-4o-mini   (GPT-4o Mini)
      · gpt-5   (GPT-5)

  $ make test
    ... all 11 test suites green including model_discovery_tests: OK

Live-HTTP verification against real Anthropic / OpenAI / Gemini /
xAI keys hasn't run in this environment (no real keys), but the
parser tests cover the JSON shapes documented in each provider's
current API reference.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants