- Added declaration-only compiler options to multiple package publish tsconfig files.
- Standardized publish include/exclude settings to emit types from src into dist/types.
- Added manifest rewrite helpers to remap type paths from ./src to ./dist/types/*.d.ts.
- Updated publish flow to append dist/types/extra files and skip publish build/rewrite for native packages.
- Added MockResponse metadata fields and invoked onResponse pre-stream with lowercased headers, status fallback, and requestId.
- Wrapped request onResponse in agent-loop, captured response headers, and forwarded them with baseUrl to finish/fail span handling.
- Added detectGatewayFromHeaders export and pi.gen_ai.gateway.* span attributes via header-based gateway detection.
- Extended telemetry event/span payloads with responseHeaders and validated detection-priority and onResponse forwarding in tests.
- Unified line-ending normalization to `replace(/\r\n?/g, "\\n")` in editor, scraper, benchmark, and utils modules.
- Added terminal-aware line sanitization in code-cell rendering to collapse inline carriage returns and avoid overwrite corruption.
- Tightened editor and paste sanitizers to trim control characters consistently after CR normalization.
- Adopted draft-2020-12 tuple validation with `prefixItems`, rejecting array-valued `items`.
- Expanded strict-mode handling to recurse `prefixItems` entries and infer `array` when tuple prefixes exist.
- Normalized Anthropic schemas through `prefixItems`, keeping supported tuple constraints and dropping unsupported fields.
- Updated coding-agent schema metadata and tests to draft-2020-12 `$schema` targets, including MCP/theme fixtures.
- Added `trimTrailingWhitespace()` to strip trailing spaces/tabs and keep the original line when none exist.
- Changed `zodToWireSchema` to generate wire schemas with `target: "draft-2020-12"` instead of `draft-7` for better Anthropic input schema compatibility.
- Updated the nearby comment to describe that OpenAI strict, Google, and Anthropic CCA sanitizers accept the newer structural superset.
Fixes#1101
- Added homepage metadata entries to the Rust and Python package manifests.
- Replaced OpenRouter HTTP-Referer values with https://omp.sh/ in completion and image requests.
- Updated Codex WebSocket typing and construction to use Bun.WebSocket for handshake header capture.
Fixes#1102
- Added path-based key deletion helpers that remove keys from object and array arguments while preserving sibling structure sharing.
- Mapped Zod unrecognized_keys and JSON Schema additionalProperties violations to an unrecognized issue type and applied them in issue repair to tolerate strict input shapes.
- Updated tool argument coercion tests to confirm extra keys are stripped for strict and nested strict schemas and additionalProperties false payloads.
- Relocated compaction, branch-summarization, pruning, and utils from coding-agent to packages/agent/src/compaction.
- Moved OpenAI remote compaction helpers from packages/ai to the new compaction module.
- Added handoff.ts with extractHandoffDocument, createHandoffContext, and renderHandoffPrompt helpers.
- Exposed new entries.ts with standalone SessionEntry types so coding-agent no longer owns them.
Primitive $ref recursion now emits a validation issue when the depth cap is exceeded instead of returning true. This preserves termination without accepting invalid values at the end of a long ref chain.
- Keep duplicate suppression for chunks that carry both leaked markers and structured delta.tool_calls, but allow later independently healed calls to promote stopReason from stop to toolUse even if earlier chunks had structured calls.
- Treat streamFirstEventTimeoutMs: 0 as disabling the SDK request timeout instead of passing timeout: 0 or falling back to the env timeout floor.
- mergeUsage now recomputes totalTokens (and cost.total when cost components are supplied) when omitted by a Partial<Usage>, so mock-backed telemetry/run-summary tests don't under-count.
- Tool-call ID counter moved into MockState; reset() restores it, so two createMockModel() instances with identical scripted tool calls produce identical IDs regardless of test ordering.
- buildOpenAiNativeHistory now emits custom_tool_call / custom_tool_call_output for blocks with customWireName (apply_patch and other freeform tools), matching the normal Responses replay path; previously demoted to function_call which broke remote-compaction replay or mismatched the original call.
- requestOpenAiRemoteCompaction and requestRemoteCompaction accept an optional AbortSignal; the coding-agent compaction caller forwards the existing signal so cancellation now terminates the in-flight fetch instead of stranding the session in the compacting state until the server replies.
- JSON Schema validator now enforces propertyNames, patternProperties, dependentRequired, dependencies, if/then/else, contains, and prefixItems instead of silently accepting values that violate them; unevaluated* still permissive but warns once.
- Recursive $ref no longer short-circuits to true on revisit: cycle detection keys on (ref, value-identity) with a primitive depth cap, so nested sub-schema violations are caught.
- Meta-validator now structurally validates if/then/else/dependencies sub-schemas and accepts draft-07 dependencies as either schemas or string-array dependent keys.
- Wire-schema null normalization no longer strips null-valued unknown root fields before preserveUnknownRootFields snapshots them, so task.simple and similar callers still see disallowed null arguments.
- Promotion of healed stop→toolUse now gated on prior stopReason === "stop" so error/length/aborted finishes are preserved.
- When a chunk carries both leaked markers and a structured delta.tool_calls, the healer strips visible markers but discards its synthesized calls so structured payloads remain the single source of truth.
- Healer no longer finalizes tool calls outside an active <|tool_calls_section_begin|>…<|tool_calls_section_end|> section; bare tokens in assistant prose survive as text.
- OpenAI SDK client now honors per-request streamFirstEventTimeoutMs so slow-before-headers providers are not aborted at the env default before the wrapping watchdog arms.
- Replaced fromTypeBox conversion with a JSON-schema validator flow in ai tool handling and execution paths.
- Added recursive schema validation and expanded TypeBox checks for refs, enums, uniqueItems, and constraint keywords.
- Sanitized Azure/CCA tool schemas by dropping unsupported fields and rewriting oneOf tool branches as anyOf.
- Tightened argument and model-config validation, preserving unknown tool fields and adding apiKey plus compatibility flags.
- Added canonical `pi.zod` schema API exports and removed TypeBox package exports/imports.
- Migrated Tool schema typing from TypeBox to shared `TSchema`/Zod flow with legacy TypeBox compatibility.
- Updated AI provider adapters and MCP/agent builders to convert tool params through `toolWireSchema()`.
- Reworked schema validation from AJV to Zod-safe parsing with `fromTypeBox`, `toolWireSchema`, and meta schema checks.
- Added OpenAI completions progress detection to treat usage, finish reason, and real content deltas as progress while ignoring keepalive and role-only preamble chunks.
- Applied the new detector through the stream idle watchdog via `isProgressItem` so the timeout only advances on meaningful model output.
- Derived an SDK request timeout from the stream first-event watchdog window and passed it to the OpenAI client to avoid long pre-header stalls.
- Preserved description at the top level when wrapping optional properties with anyOf/null.
- Substituted schema-supplied defaults when a required field arrives as null or "null", cloning to prevent cross-call mutation.
- Added coercion tests for default substitution, isolation, optional null stripping, and nested JSON deserialization.
- Restored default stream idle timeout from 30s back to 120s (regression from 15.0.0).
- Fixed `iterateWithIdleTimeout` to only flip `awaitingFirstItem` on real progress items, not synthetic `start` events.
- Marked provider `start` events as non-progress keepalives in the lazy-stream wrapper.
- Added createMockModel() returning model, calls, stream, push, and reset helpers for mock streams.
- Added registerMockApi() and streamMock() to register MOCK_API, validate model ownership, and resolve handlers by responses, extras, then fallback.
- Implemented runMock() to normalize outputs, emit block stream events, and handle delays, aborts, errors, stop reasons, usage, and tool calls.
- Added mock-provider entrypoint export, changelog notes, and broader test coverage for cleanup, sequencing, async/sync scripts, and failures.
- Added OpenAI remote-compaction API support with provider-specific endpoint gating.
- Added buildOpenAiNativeHistory, token-budget estimation, and message trimming for remote-compaction.
- Added helpers to preserve and validate remote-compaction metadata in request/response handling.
- Refactored coding-agent compaction to consume pi-ai remote-compaction helpers with converted message history.
- Exported remote-compaction from ai index and documented the new APIs in CHANGELOG.
- Added a Kimi ToolCallHealer to strip leaked token markers while buffering partial stream chunks.
- Routed OpenAI completion deltas through healing and emitted cleaned text plus parsed toolCall blocks.
- Implemented healer finalization to normalize IDs, repair JSON arguments, and flush pending calls at stream end.
- Added regression SSE tests and CHANGELOG notes for marker leaks, split calls, multi-calls, and unknown tokens.
Priority (fast-mode) requests were being added to usage.premiumRequests in
all three OpenAI provider paths (completions, responses, codex-responses).
This caused the status-line and footer to render a spurious star whenever
fast mode was active.
The packages/stats parser already derives priority-tier premium counts from
service_tier_change session entries when premiumRequests is unset, so omp-stats
continues to account for fast-mode traffic correctly. The premiumRequests field
in usage payloads now exclusively carries GitHub Copilot premium multipliers.
Fixes#1095
- Updated root marker detection to read the directory once and match glob markers against top-level entries, preventing recursive scans when checking project roots.
- Adjusted root-marker glob error handling to warn on directory listing failures and treat the marker set as absent when unreadable.
- Reduced marksman's configured warmup timeout from 15,000 ms to 2,000 ms in LSP defaults.
Some HTTPS endpoints (e.g. corporate API gateways behind reverse proxies) advertise h2 via ALPN but then refuse or reset the connection at the HTTP/2 framing layer. Bun surfaces these failures as ConnectionRefused, ConnectionReset, or ConnectionClosed rather than HTTP2Unsupported.
Previously only HTTP2Unsupported triggered the transparent h1 retry, so any custom provider pointing at such a gateway would fail with a cryptic "Connection error." that was impossible to diagnose from user-land.
This commit widens the fallback set to include ConnectionRefused, ConnectionReset, and ConnectionClosed — all of which are transport-layer indicators that the h2 attempt itself failed, not the underlying application request.
- Introduced `FetchImpl` type with optional `preconnect` to accept non-Bun fetch implementations without type errors.
- Applied the new type across all providers and `StreamOptions.fetch`.
- Added tests verifying fetch override routing for openai-completions, openai-responses, and fetchWithRetry.
- Introduced a `fetch` option on `StreamOptions` and threaded it through providers to let callers supply a custom request transport.
- Updated provider clients and direct HTTP calls across Anthropic, OpenAI, Azure, Google, GitLab Duo, Gemini CLI, Ollama, and Codex flows to use the injected fetch implementation.
- Extended retry helper options to accept a fetch override and preserved preconnect support from the selected fetch function.
- Stop now marks the client as closed via `_mark_closed` with `RpcProcessExitError`, so `_wait_for_agent_end` wakes immediately instead of waiting for a timeout.
- Added a regression test using a hanging server subprocess to verify `stop()` unblocks `prompt_and_wait` promptly and raises `RpcProcessExitError`.
- Updated Kimi compatibility tests to distinguish Moonshot-hosted models from OpenCode-hosted ones for `reasoning_content` and assistant-content tool-call behavior.
OpenCode-Go and OpenCode-Zen handle reasoning content internally
and reject client-supplied reasoning_content in message history.
When retry fallback forwards conversation history to
opencode-go/kimi-k2.6, the compat layer was injecting synthetic
reasoning_content: '.' on assistant tool-call turns, causing
HTTP 400: 'Extra inputs are not permitted'.
Gate isKimiModel in requiresReasoningContentForToolCalls on
!isOpenCodeProvider so the injection path is skipped for
OpenCode providers while preserving existing behavior for
native Kimi API, DeepSeek, and OpenRouter.
- Added an internal accounting-state guard and used it to skip goal usage flushing when accounting was inactive.
- Updated goal abort handling to return early unless accounting or pause logic was required, then paused only a cloned active goal state before committing.
- Aligned related tests/types by tightening OpenAI helper typing and using Tool typings for the goal tool registry.
- Hardened context usage accounting to tolerate missing session fields by defaulting skills and tools to empty arrays.
- Guarded message and system-prompt token counting with presence checks to avoid access errors on partial session objects.
- Added getOpenAIReasoningModel to wrap the bundled gpt-5-mini model with a non-gpt-5 name in tests.
- Replaced all OpenAI responses test model constructions using gpt-5-mini with the new helper to bypass reasoning-model branching during payload assertions.
- Removed export leakage by demoting many helper and const symbols to module-local scope.
- Renamed underscore-prefixed internals and cache fields, then updated related references and `satisfies never` checks.
- Deleted obsolete logic branches and helpers, including harmony-stream interruption flow and unused benchmark runtime helpers.
- Updated Biome config and manifests by broadening lint coverage and removing an unused `@napi-rs/cli` dev dependency.
- Adjusted tests and utilities to use renamed test helpers and remove redundant private test-only helpers/locals.
- Removed local `abortableSleep` in favour of Node's built-in `scheduler.wait` from `node:timers/promises`.
- Consolidated per-provider retry/fetch loops into a shared `fetchWithRetry` utility in `packages/utils`.
- Moved `extractHttpStatusFromError`, `isRetryableError`, and related helpers out of `packages/ai` into `packages/utils`.
- Deleted `extractRetryDelay` in favour of `extractRetryHint` with unified header and body parsing.
- Raised the Bun minimum version to >=1.3.14 across package metadata, install scripts, and changelog notes.
- Removed the Photon native image pipeline and added SIXEL-based `sixel` support in pi-natives.
- Migrated coding-agent image handling and resizing to `Bun.Image`, including updated tests and a JPEG quality bump to 80.
- Added HTTP/2 fetch bootstrap with HTTPS-only fallback and updated Bun build flags for autoload suppression/`--keep-names`.
- Added `getPriorityPremiumRequests` and used it in OpenAI and OpenAI Codex providers to increment `usage.premiumRequests` when `serviceTier: "priority"` was sent.
- Combined Copilot and priority premium counts in OpenAI completions and responses usage parsing so emitted usage uses the merged premium total.
- Updated stats parsing/backfill to re-read `service_tier_change` entries and UPSERT only `premium_requests`, so historical sessions pick up priority traffic without mutating other metrics.
- Deferred initialize to flush queued credential_disabled events via queueMicrotask and event splicing.
- Added tests for pre-initialize credential_disabled emissions and onError propagation of handler failures.
- Replaced auth credential disable flow with CAS checks in #tryDisableAuthCredentialIfMatches and matching SQL statement.
- Retried OAuth getApiKey after disable failures; added peer-rotation race test for fresh token and active credential retention.
- Updated CHANGELOG for deferred microtask flushing plus eval import renames and diff URL/quoted-path parsing fixes.