* fix(typecheck): expand cachedMicrocompact stub exports
The cachedMicrocompact module is a feature-gated stub that only exported
3 functions, but microCompact.ts expected 10+ exports including types and
state management functions.
Changes:
- Add missing type exports: CachedMCState, CacheEditsBlock, PinnedCacheEdits, CachedMCConfig
- Add missing function stubs: createCachedMCState, markToolsSentToAPI, resetCachedMCState, registerToolResult, registerToolMessage, getToolResultsToDelete, createCacheEditsBlock
- Add null guard in cachedMicrocompactPath for config
- Add comprehensive tests for stub behavior
Resolves 15 typecheck errors in microCompact.ts:
- TS2694: Namespace has no exported member (10 errors)
- TS2339: Property does not exist (5 errors)
- TS18047: possibly null (2 errors)
Testing:
- bun test src/services/compact/cachedMicrocompact.test.ts: 7/7 pass
- bun test src/services/compact/: 61/61 pass
- bun run smoke: pass
- Typecheck errors: 697 → 682 (-15)
* fix(typecheck): address CodeRabbit review feedback
- Add missing fields to CachedMCConfig type: enabled, supportedModels,
systemPromptSuggestSummaries (used by prompts.ts and claude.ts)
- Replace silent fallback with explicit error throw in cachedMicrocompactPath
to enforce the invariant that isCachedMicrocompactEnabled() === true implies
getCachedMCConfig() !== null, preventing potential recursion in future
non-stub implementations
* test: prevent CI state leaks
* fix: resolve 28 typecheck errors in openaiShim.ts
Add null guards for nullable `reader`, `response`, and `responsesResponse`
variables, and use type assertions to bridge Node vs Web ReadableStream
type mismatches in stream processing helpers.
* fix(typecheck): resolve 17 errors in agentSdkTypes.ts
- Add @ts-expect-error for settingsTypes.generated.js (generated at build time)
- Fix type imports: redirect 5 types from ./sdk/runtimeTypes.js to ./sdk/shared.js
- Remove 11 unused type imports that don't exist (AnyZodRawShape, InferShape, etc.)
* fix(typecheck): resolve 26 errors in openaiShim.ts — nullable guards, ReadableStream types
* fix(typecheck): resolve 23 errors in messages.ts + groupToolUses.ts
MessageWithoutProgress resolved to `never` because all message types are
`any` stubs, making `Exclude<any, any>` = `never`. Widen types and use
boolean wrappers to avoid type-predicate narrowing. Add missing return
in getToolUseID switch statement.
* fix(typecheck): resolve 14 errors in toolExecution.ts — fix never[] inference
* fix(typecheck): resolve type errors in claude.ts
- Cast nested block params to BetaContentBlockParam for SDK type union mismatch
- Add missing CACHE_EDITING_BETA_HEADER constant to betas.ts
- Type-assert getCachedMCConfig() return for supportedModels access
- Add missing imports: getContextWindowForModel, COMPACT_MAX_OUTPUT_TOKENS, getSdkBetas
- Fix model variable reference to use options.model in compact context
- Add optional signature property to ConnectorTextBlock type
* ci: re-trigger checks
* fix: address CodeRabbit review feedback
- Throw error instead of silent return when response body is not readable
- Clamp hybrid context budget to non-negative floor (Math.max(0, ...))
- Remove unused isResult wrapper in messages.ts
* chore(tests): fix flaky and environment-dependent unit tests
- Mock fs.existsSync in geminiAuth tests to prevent real ADC reads
- Isolate runtimeMetadata tests from local environment variables
- Add shared mutation lock to sessionStorage tests to prevent env race conditions
* test: address environment cleanup review
* test(autoCompact): guard temp-dir cleanup against setup-time failures
If beforeEach throws before tempDir is assigned (e.g. lock acquisition or
mkdtempSync fails), afterEach's unconditional rmSync(tempDir) threw a
TypeError and masked the original failure. Type tempDir as string | undefined
and skip removal when unset, mirroring the savedAutoCompactEnabled reset.
Addresses CodeRabbit review on PR #1582.
Co-Authored-By: OpenClaude <openclaude@gitlawb.com>
---------
Co-authored-by: Kevin Codex <kevin@gitlawb.com>
Co-authored-by: OpenClaude <openclaude@gitlawb.com>