Skip to content

feat: add a Moonshot Kimi chat preset (#240) - #335

Open
Zhangbo-cn wants to merge 1 commit into
ThinkFlowLab:mainfrom
Zhangbo-cn:feat/240-kimi-chat-preset
Open

Zhangbo-cn wants to merge 1 commit into
ThinkFlowLab:mainfrom
Zhangbo-cn:feat/240-kimi-chat-preset

Conversation

@Zhangbo-cn

Copy link
Copy Markdown
Contributor

What

Adds the 月之暗面 Kimi / Moonshot Kimi chat preset requested in #240 (mainland chat row).

  • src/canvas/providerPresets.ts: new kimi preset — kinds: ["agent"], url: https://api.moonshot.cn/v1, openai + api + bearer, logoOrganization: "moonshotai", English name Moonshot Kimi. Placed after bailian-beijing, before zhipu.
  • No new adapter or endpoint code is needed: Moonshot is OpenAI-compatible, so the existing agent transport drives it unchanged.
  • modelsByKind is deliberately omitted, so Fetch models stays a live /models call and the picker lists whatever the entered key can actually reach (same approach as deepseek). With a mainland key that is kimi-k3 and kimi-k3.1-pro.
  • The international endpoint (api.moonshot.ai) is a separate row of the [tracking] providers: API integrations #240 matrix and is intentionally not matched — it stays a custom OpenAI-compatible service. The docs paragraph says so.
  • Logo: nothing to add, moonshotai already resolves through modelBrands.json → kimi.svg.
  • docs/guides/user-guide.md + user-guide.zh-CN.md: one paragraph per locale (preset, live discovery, international endpoint → custom service).
  • tests/providerPresets.test.ts: 2 tests (preset shape + discovery-stays-on + localized labels + kind filtering; and providerPresetFor() re-selecting kimi for saved mainland connections while .ai, deeper paths and other kinds fall back to custom).
  • tests/browser/kimi_real.mjs + manifest.json: an opt-in real-endpoint browser check (helper, needs MOONSHOT_API_KEY, incurs charges, no lane runs it).

How tested

Gates on the rebased branch:

./node_modules/.bin/tsc --noEmit      # clean
node scripts/check-i18n.mjs           # 3011 keys, 0 problems
node scripts/check-browser-manifest.mjs  # 75 entries OK
npm test                              # 810 pass, 0 fail
scripts/generate_contracts.py --check # verified

Both new tests were mutation-checked: changing the preset URL to .ai fails 2 assertions, adding modelsByKind fails 1, restoring passes 20/20.

Real endpoint against a locally run app (isolated creation server + vite dev server), with a real mainland key:

MOONSHOT_API_KEY=… OPENDIRECTOR_URL=http://127.0.0.1:5190 \
OPENDIRECTOR_API=http://127.0.0.1:8040 node tests/browser/kimi_real.mjs

The script asserts, not just screenshots: /api/model-configs/discover returns kimi-k3, the streamed reply arrives in the UI, the agent-written asset comes back with provenance.source == "agent_written" and modelSnapshot.modelId == "kimi-k3", it appears in the asset list, adds a canvas node, and survives a reload. Browser requests to moonshot.(cn|ai) are asserted never to happen — the key stays server side.

Evidence

Preset (zh-CN) preset zh
Preset (en-US) preset en
Streamed reply reply
Asset list assets
Canvas node node
After reload reopen

Notes

  • Prompt used in the run: write a text asset named kimi-note.txt inside the project. The agent completed it through opendirector asset write-text, so the whole tool-calling loop works over Kimi.
  • kimi-k3 is slow-ish for a full tool round trip (~2 min for 4 calls in my run), which is why the browser check allows long waits; that is the model, not the integration.
  • Thanks @FayeSpica for the assignment. Happy to adjust the row's wording in [tracking] providers: API integrations #240, or add the international endpoint here if you'd rather keep both Kimi rows in one preset.

@github-actions github-actions Bot added area:provider Model providers and generation protocols type:feat New capability or behaviour labels Nov 15, 2026
Selecting MoonShot Kimi fills https://api.moonshot.cn/v1 and keeps live
model discovery, so the picker lists the models the entered key reaches.
The international endpoint stays a custom OpenAI-compatible service.
@Zhangbo-cn
Zhangbo-cn force-pushed the feat/240-kimi-chat-preset branch from 6c4557a to 347ad70 Compare November 15, 2026 07:08
@github-actions github-actions Bot added the area:docs Documentation / 文档 label Nov 15, 2026
@github-actions
github-actions Bot requested a review from wuzhf9 November 15, 2026 07:08

@FayeSpica FayeSpica left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Could you support both Moonshot Open Platform token billing and Kimi Coding Plan subscription quotas in this PR?

logoOrganization: "moonshotai",
name: "月之暗面 Kimi",
kinds: ["agent"],
url: "https://api.moonshot.cn/v1",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Could you add a separate Kimi Coding Plan preset alongside the pay-per-token Open Platform preset in this PR? Coding Plan uses https://api.kimi.com/coding/v1 with its own API key. Official configuration docs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:docs Documentation / 文档 area:provider Model providers and generation protocols type:feat New capability or behaviour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants