ca198f739e
Simplify pass after the typed ToolRuntime initial drop. Findings from a parallel review (code reuse + quality + perf): src/tool.ts - Tool now carries memoized decode/encode codecs and a precomputed ToolDefinition, derived once at tool() construction time. The runtime no longer rebuilds Schema closures or JSON Schema docs per call/per run. - Constrains parameters/success to Schema.Codec<T, any, never, never> so the codecs have no service requirements. Drops the 'as unknown as' casts the runtime needed previously. - Fixes a latent bug: schemas with $ref now correctly emit $defs on ToolDefinition.inputSchema (toJsonSchemaDocument's definitions were silently dropped before). src/tool-runtime.ts - Uses LLMRequest constructor instead of 'as LLMRequest' casts. - Default tool dispatch concurrency is 10 (was 'unbounded'); exposed via RunOptions.concurrency. Unbounded is still available for handlers that do not share a saturable resource. - Drops dead 'usage' state, the single-use Dispatched interface, and the DEFAULT_MAX_STEPS constant per the inline-when-used style rule. - accumulate() now factors text-delta and reasoning-delta into one helper. test/lib/openai-chunks.ts (new) - Shared deltaChunk / usageChunk / toolCallChunk / finishChunk helpers. test/lib/http.ts - scriptedResponses moved here from tool-runtime.test.ts so future multi-step adapter tests can reuse it. Also picks up parallel work that swapped HandlerInput to a 'respond' callback for cleaner Response construction. test/tool-runtime.test.ts - Uses LLMEvent.guards for typed event filtering instead of cast-and-check. - Concurrent test now uses sseEvents + deltaChunk instead of a hand-rolled body string. Includes parallel callsite updates in test/adapter.test.ts and test/provider/openai-compatible-chat.test.ts that adopt the 'respond' API in lib/http.ts.