feat: consume server model reasoning capabilities

This commit is contained in:
2026-09-01 14:16:18 +08:00
parent 850947c092
commit ae79361742
20 changed files with 711 additions and 20 deletions

View File

@@ -0,0 +1,84 @@
# Task: Consume server model reasoning capabilities
## Identity
- Task ID: 20260901-server-model-capabilities-9e31b6c4
- Mode: Feature
- Branch: codex/20260901-server-model-capabilities-9e31b6c4-server-model-capabilities
- Worktree: D:\w\makelore-model-capabilities-9e31b6c4
- Base commit: 850947c092892cb647c4191b6d8bbf37a763e1ad
- Owner: codex
- Status: Ready for integration
## Scope
- Consume per-model reasoning capabilities from Works Square model config and persist
them on the imported Main-owned Provider account.
- Make server metadata override the local Pi reasoning map for server-provisioned
models while retaining the local verified profile as an old-server/direct-provider
fallback.
- Add native `max` to the product-neutral thinking-level contract and composer menu so
DeepSeek exposes off/low/high/max without relabeling provider values.
- Keep one-api and Pi `0.84.2` unchanged.
## Intent And Constraints
- Electron Main remains the sole Works/model-config, Provider, credential, and Pi-wire
owner. Renderer receives only safe product-neutral levels.
- Strictly normalize the trusted response shape; a missing capability field means an
older server and falls back to the local profile.
- Preserve persisted user choices and all non-Works Provider behavior.
- Do not restore OpenCode, add a second runtime, or expose Provider credentials or raw
response data.
- Feature mode may update only product code, focused tests, and this task record.
## Plan
1. Add failing tests for Works capability import, Provider metadata persistence,
server-over-local Pi mapping, and native `max` menu/contract acceptance.
2. Implement the typed response parser, Provider metadata projection, capability-map
precedence, local DeepSeek fallback, and minimal `max` propagation through existing
product validators/UI.
3. Run focused unit tests, typecheck, scoped lint, Vite/Main build, and the project-docs
completion gate.
## Outcome
- Parsed and normalized Works Square `model_capabilities`, stored the safe result on
the managed Provider account, removed stale overrides when the optional server field
disappears, and included the metadata in Provider runtime-shape invalidation.
- Server-provided efforts now override the local Pi reasoning/thinking-level map while
preserving verified local modalities, token limits, and wire-format compatibility.
A capability for a future model without a local profile enables standard
`reasoning_effort` serialization automatically.
- Updated the verified DeepSeek fallback to expose only off/low/high/max. Pi sends
`thinking.type=disabled` with no `reasoning_effort` for off, and sends the exact
low/high/max effort for enabled requests.
- Added native `max` to the product contract, snapshot validation, project persistence,
Host route, Pi runtime, and composer UI where it is labelled `最高`.
- Kept Pi at 0.84.2 and made no one-api, dependency, README, or second-runtime change.
## Verification
- Focused final Vitest combination: 8 files and 102/102 tests passed, including actual
Pi `streamSimple` payload checks for off and each of low/high/max.
- `pnpm run typecheck`: passed.
- `pnpm run lint:check`: passed with the repository's existing five warnings and no
errors; a separate scoped ESLint run over every changed TypeScript/TSX file passed.
- `pnpm run build:vite`: passed; only existing Browserslist, dynamic-import, and chunk
size warnings were emitted.
- `git diff --check`: passed.
## Follow-ups
- Integrate with the paired Works Square API change. Deployment order is tolerant:
a client talking to an older server uses the corrected local DeepSeek profile, and
older clients ignore the new server response member.
- Verify future server model entries against their provider's exact effort vocabulary
before publishing them; no one-api change is required while it remains transparent.
## Promotion Candidates
- Promote the Main-owned capability normalization/precedence rule and the safe
server-to-Provider metadata contract into canonical architecture documentation after
the paired server and client branches are integrated.