Context: PR #26569 narrowly fixed a crash where the generated SDK sent
GET /session/{sessionID}/message?limit=80&directory=... because public.ts
manually injected InstanceQueryParameters (directory/workspace) into OpenAPI,
but the runtime MessagesQuery schema omitted directory, causing empty 400.
This change eliminates the drift by:
1. Creating a shared schema helper in query.ts that adds directory/workspace
fields to all instance route query schemas.
2. Updating all instance route query schemas to use the helper:
- session.ts: MessagesQuery, ListQuery
- file.ts: FileQuery, FindTextQuery, FindFileQuery, FindSymbolQuery
- experimental.ts: ToolListQuery, SessionListQuery
- control.ts: LogQuery (already correct, now uses helper)
- instance.ts, v2/session.ts, v2/message.ts
3. Adding reproducer tests in httpapi-query-schema-drift.test.ts that verify
the runtime accepts directory/workspace params on affected routes.
The OpenAPI spec generation in public.ts still manually injects params for
backward compatibility with the legacy SDK format, but now the runtime
schemas match, eliminating the validation errors.
Verification:
- bun typecheck passes
- 4 drift reproducer tests pass
- 24 httpapi tests pass across session, file, experimental, workspace-routing
The normalizeProviderModelCosts function was only setting { input: 0, output: 0 }
which doesn't match the full OpenCode provider cost shape that includes cache fields.
This fix:
- Preserves existing cost fields (input, output, cache.read, cache.write) if valid
- Adds missing cache: { read: 0, write: 0 } structure when not present
- Validates provider and model objects before modification to avoid poisoning
invalid provider metadata
- Updates ProviderModel type to include optional cache field
Fixes provider cost normalization to maintain cache field compatibility.