Skip to content

feat(ai): add type-safe tool call events to chat() stream#452

Merged
AlemTuzlak merged 5 commits into
mainfrom
worktree-serialized-exploring-wall
Jul 21, 2026
Merged

feat(ai): add type-safe tool call events to chat() stream#452
AlemTuzlak merged 5 commits into
mainfrom
worktree-serialized-exploring-wall

Conversation

@AlemTuzlak

@AlemTuzlak AlemTuzlak commented Apr 15, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Made ToolCallStartEvent and ToolCallEndEvent generic with backward-compatible defaults (string / unknown)
  • Added TypedStreamChunk<TTools> exported type that replaces untyped tool call events with typed versions based on the tools array
  • Threaded TTools generic through TextActivityOptions, TextActivityResult, chat(), and createChatOptions() so the stream return type carries tool type information
  • Added IsAny guard in ToolInputsOf to prevent any leaking through InferSchemaType for tools without inputSchema
  • Added 29 type-level tests covering: typed names/inputs, server/client/definition tool variants, empty/default/readonly arrays, backward compatibility, and chat() inference without explicit type args
  • Updated streaming docs with "Type-Safe Tool Call Events" section, StreamChunk.md reference, and cross-links from tools docs
  • Added showcase snippet in ts-react-chat example

Test plan

  • All 660 unit tests pass (pnpm --filter @tanstack/ai test:lib)
  • Build succeeds (pnpm --filter @tanstack/ai build)
  • Example app builds (pnpm --filter ts-react-chat build)
  • 29 type-level tests verify: literal name narrowing, input type inference, fallback to string/unknown, empty arrays, as const, server/client tool variants, chat() inference, backward compat (assignability, StreamChunk unchanged)
  • toBeUnknown() assertions used instead of toEqualTypeOf<unknown>() to catch any leaks

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Type-safe tool-call events in chat streaming: when using typed tools, streaming chunks now include type information, with toolName narrowed to tool name literals and input typed to corresponding tool schemas.
  • Bug Fixes

    • Fixed callback propagation in the Svelte integration to ensure all callbacks stay synchronized with option updates.
  • Documentation

    • Added comprehensive guides on type-safe streaming with tools, including examples and type references.

@coderabbitai

coderabbitai Bot commented Apr 15, 2026

Copy link
Copy Markdown
Contributor

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The changes introduce type-safe streaming for tool calls in the chat function. When chat() receives tools with Zod schemas via toolDefinition(), the streaming output now provides typed TOOL_CALL_START and TOOL_CALL_END events where toolName is narrowed to tool name literals and input is narrowed to corresponding tool input types, forming discriminated unions.

Changes

Cohort / File(s) Summary
Documentation & Type Reference
docs/chat/streaming.md, docs/reference/type-aliases/StreamChunk.md, docs/tools/tools.md, docs/tools/server-tools.md
Added documentation and type reference explaining type-safe tool-call streaming, TypedStreamChunk helper type, discriminated union behavior with multiple tools, and how Zod-based type inference is preserved in streaming output.
Core Type System
packages/typescript/ai/src/types.ts
Made ToolCallStartEvent and ToolCallEndEvent generic with tool name and input type parameters. Added TypedStreamChunk<TTools> export that conditionally creates discriminated union types for tool-call events when concrete tool types are provided; falls back to StreamChunk when tools lack type information.
Chat API Integration
packages/typescript/ai/src/activities/chat/index.ts
Added TTools generic parameter (defaulting to ReadonlyArray<Tool<any, any, any>>) to TextActivityOptions, createChatOptions, and chat function. Updated streaming return type from AsyncIterable<StreamChunk> to AsyncIterable<TypedStreamChunk<TTools>> to propagate tool type information through the API.
Type Safety Tests
packages/typescript/ai/tests/type-check.test.ts
Expanded type-check tests with tool definition fixtures (Zod-backed, schema-less, plain JSON Schema variants) and extensive compile-time assertions validating TypedStreamChunk tool-call typing: toolName literal narrowing, input union typing discriminated by tool name, and backward compatibility with unparameterized event types.
Changeset Metadata
.changeset/svelte-callback-propagation.md
Added patch-level changeset documenting a Svelte callback propagation fix ensuring all five createChat callbacks are routed through consistent call-time indirection.

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 With whiskers twitching at the types so fine,
Tool calls now speak in literals divine,
Each input narrowed, each name so clear,
Type-safe streaming brings a cheer!
From Zod to streams, the magic's spun,
A rabbit's joy—the typing's done! 🌟

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: adding type-safe tool call events to the chat() stream, which is the primary objective of this PR.
Description check ✅ Passed The pull request description is comprehensive and well-structured, covering all major changes, test results, and implementation details that align with the repository's template expectations.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch worktree-serialized-exploring-wall

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Apr 15, 2026

Copy link
Copy Markdown
Contributor

🚀 Changeset Version Preview

3 package(s) bumped directly, 44 bumped as dependents.

🟥 Major bumps

Package Version Reason
@tanstack/ai-durable-stream 0.0.0 → 1.0.0 Changeset
@tanstack/ai-acp 0.2.3 → 1.0.0 Dependent
@tanstack/ai-angular 0.3.1 → 1.0.0 Dependent
@tanstack/ai-anthropic 0.16.3 → 1.0.0 Dependent
@tanstack/ai-bedrock 0.1.4 → 1.0.0 Dependent
@tanstack/ai-claude-code 0.2.3 → 1.0.0 Dependent
@tanstack/ai-code-mode 0.3.8 → 1.0.0 Dependent
@tanstack/ai-code-mode-skills 0.3.11 → 1.0.0 Dependent
@tanstack/ai-codex 0.2.3 → 1.0.0 Dependent
@tanstack/ai-elevenlabs 0.2.34 → 1.0.0 Dependent
@tanstack/ai-fal 0.9.12 → 1.0.0 Dependent
@tanstack/ai-gemini 0.20.1 → 1.0.0 Dependent
@tanstack/ai-grok 0.14.9 → 1.0.0 Dependent
@tanstack/ai-grok-build 0.2.3 → 1.0.0 Dependent
@tanstack/ai-groq 0.5.3 → 1.0.0 Dependent
@tanstack/ai-isolate-node 0.1.47 → 1.0.0 Dependent
@tanstack/ai-isolate-quickjs 0.1.47 → 1.0.0 Dependent
@tanstack/ai-mistral 0.2.3 → 1.0.0 Dependent
@tanstack/ai-ollama 0.8.16 → 1.0.0 Dependent
@tanstack/ai-openai 0.17.1 → 1.0.0 Dependent
@tanstack/ai-opencode 0.2.3 → 1.0.0 Dependent
@tanstack/ai-openrouter 0.15.10 → 1.0.0 Dependent
@tanstack/ai-preact 0.11.1 → 1.0.0 Dependent
@tanstack/ai-react 0.18.1 → 1.0.0 Dependent
@tanstack/ai-react-ui 0.8.15 → 1.0.0 Dependent
@tanstack/ai-sandbox 0.2.4 → 1.0.0 Dependent
@tanstack/ai-sandbox-cloudflare 0.2.4 → 1.0.0 Dependent
@tanstack/ai-sandbox-daytona 0.2.0 → 1.0.0 Dependent
@tanstack/ai-sandbox-docker 0.2.0 → 1.0.0 Dependent
@tanstack/ai-sandbox-local-process 0.2.0 → 1.0.0 Dependent
@tanstack/ai-sandbox-sprites 0.2.1 → 1.0.0 Dependent
@tanstack/ai-sandbox-vercel 0.2.0 → 1.0.0 Dependent
@tanstack/ai-solid 0.15.1 → 1.0.0 Dependent
@tanstack/ai-solid-ui 0.7.14 → 1.0.0 Dependent
@tanstack/ai-svelte 0.15.1 → 1.0.0 Dependent
@tanstack/ai-vue 0.15.1 → 1.0.0 Dependent
@tanstack/openai-base 0.9.9 → 1.0.0 Dependent

🟨 Minor bumps

Package Version Reason
@tanstack/ai 0.42.0 → 0.43.0 Changeset
@tanstack/ai-client 0.22.1 → 0.23.0 Changeset

🟩 Patch bumps

Package Version Reason
@tanstack/ai-devtools-core 0.4.24 → 0.4.25 Dependent
@tanstack/ai-isolate-cloudflare 0.2.38 → 0.2.39 Dependent
@tanstack/ai-mcp 0.2.5 → 0.2.6 Dependent
@tanstack/ai-vue-ui 0.2.34 → 0.2.35 Dependent
@tanstack/preact-ai-devtools 0.1.67 → 0.1.68 Dependent
@tanstack/react-ai-devtools 0.2.67 → 0.2.68 Dependent
@tanstack/solid-ai-devtools 0.2.67 → 0.2.68 Dependent
ag-ui 0.0.2 → 0.0.3 Dependent

@nx-cloud

nx-cloud Bot commented Apr 15, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit c0ada34

Command Status Duration Result
nx run-many --targets=build --exclude=examples/... ✅ Succeeded 1m 59s View ↗

☁️ Nx Cloud last updated this comment at 2026-07-20 21:59:35 UTC

@pkg-pr-new

pkg-pr-new Bot commented Apr 15, 2026

Copy link
Copy Markdown

Open in StackBlitz

@tanstack/ai

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai@452

@tanstack/ai-acp

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-acp@452

@tanstack/ai-angular

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-angular@452

@tanstack/ai-anthropic

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-anthropic@452

@tanstack/ai-bedrock

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-bedrock@452

@tanstack/ai-claude-code

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-claude-code@452

@tanstack/ai-client

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-client@452

@tanstack/ai-code-mode

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-code-mode@452

@tanstack/ai-code-mode-skills

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-code-mode-skills@452

@tanstack/ai-codex

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-codex@452

@tanstack/ai-devtools-core

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-devtools-core@452

@tanstack/ai-durable-stream

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-durable-stream@452

@tanstack/ai-elevenlabs

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-elevenlabs@452

@tanstack/ai-event-client

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-event-client@452

@tanstack/ai-fal

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-fal@452

@tanstack/ai-gemini

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-gemini@452

@tanstack/ai-grok

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-grok@452

@tanstack/ai-grok-build

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-grok-build@452

@tanstack/ai-groq

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-groq@452

@tanstack/ai-isolate-cloudflare

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-isolate-cloudflare@452

@tanstack/ai-isolate-node

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-isolate-node@452

@tanstack/ai-isolate-quickjs

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-isolate-quickjs@452

@tanstack/ai-mcp

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-mcp@452

@tanstack/ai-mistral

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-mistral@452

@tanstack/ai-ollama

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-ollama@452

@tanstack/ai-openai

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-openai@452

@tanstack/ai-opencode

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-opencode@452

@tanstack/ai-openrouter

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-openrouter@452

@tanstack/ai-preact

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-preact@452

@tanstack/ai-react

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-react@452

@tanstack/ai-react-ui

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-react-ui@452

@tanstack/ai-sandbox

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox@452

@tanstack/ai-sandbox-cloudflare

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-cloudflare@452

@tanstack/ai-sandbox-daytona

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-daytona@452

@tanstack/ai-sandbox-docker

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-docker@452

@tanstack/ai-sandbox-local-process

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-local-process@452

@tanstack/ai-sandbox-sprites

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-sprites@452

@tanstack/ai-sandbox-vercel

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-vercel@452

@tanstack/ai-solid

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-solid@452

@tanstack/ai-solid-ui

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-solid-ui@452

@tanstack/ai-svelte

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-svelte@452

@tanstack/ai-utils

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-utils@452

@tanstack/ai-vue

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-vue@452

@tanstack/ai-vue-ui

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-vue-ui@452

@tanstack/openai-base

npm i https://pkg.pr.new/TanStack/ai/@tanstack/openai-base@452

@tanstack/preact-ai-devtools

npm i https://pkg.pr.new/TanStack/ai/@tanstack/preact-ai-devtools@452

@tanstack/react-ai-devtools

npm i https://pkg.pr.new/TanStack/ai/@tanstack/react-ai-devtools@452

@tanstack/solid-ai-devtools

npm i https://pkg.pr.new/TanStack/ai/@tanstack/solid-ai-devtools@452

commit: c0ada34

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/chat/streaming.md`:
- Around line 115-117: Remove the blank line between the two blockquotes so the
"**Note:**" and "**Tip:**" paragraphs are adjacent (or merge them into one
blockquote); specifically edit the section containing the "**Note:** When
multiple tools..." and the "**Tip:** The typed stream chunk type..." strings so
there is no empty line between those blockquote lines to satisfy markdownlint
MD028.

In `@docs/reference/type-aliases/StreamChunk.md`:
- Line 23: The "Defined in" source anchor for the TypedStreamChunk entry is
stale; update the anchor in docs/reference/type-aliases/StreamChunk.md to point
to the current declaration location packages/typescript/ai/src/types.ts at line
1048 (or to the exact URL/permalink generated by TypeDoc for TypedStreamChunk),
ensuring the link text and URL reflect the new file and line; update the
markdown so it uses the correct Markdown link format and matches the repo's
TypeDoc-generated anchor for TypedStreamChunk.

In `@packages/typescript/ai/tests/type-check.test.ts`:
- Around line 6-17: The named imports in this test file are not alphabetized
causing ESLint sort-imports errors; reorder the members inside each import's
braces alphabetically (e.g., change "describe, it, expectTypeOf" to "describe,
expectTypeOf, it" for the vitest import, and similarly alphabetize "chat,
createChatOptions, toolDefinition" and the type import list "JSONSchema,
StreamChunk, Tool, ToolCallArgsEvent, ToolCallEndEvent, ToolCallStartEvent,
TypedStreamChunk") so each import's named members are in ascending alphabetical
order.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 28ddc119-4e8d-45ba-8567-1aae00525797

📥 Commits

Reviewing files that changed from the base of the PR and between db5c3d3 and a2c2f9c.

📒 Files selected for processing (7)
  • docs/chat/streaming.md
  • docs/reference/type-aliases/StreamChunk.md
  • docs/tools/tools.md
  • examples/ts-react-chat/src/routes/api.tanchat.ts
  • packages/typescript/ai/src/activities/chat/index.ts
  • packages/typescript/ai/src/types.ts
  • packages/typescript/ai/tests/type-check.test.ts

Comment thread docs/chat/streaming.md Outdated
Comment thread docs/reference/type-aliases/StreamChunk.md Outdated
Comment thread packages/ai/tests/type-check.test.ts Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (2)
docs/reference/type-aliases/StreamChunk.md (1)

23-23: ⚠️ Potential issue | 🟡 Minor

Stale Defined in link for TypedStreamChunk.

The link points to types.ts:1033, but TypedStreamChunk is defined at line 1065 in the current code. This will create a broken anchor.

📝 Suggested fix
-Defined in: [types.ts:1033](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1033)
+Defined in: [types.ts:1065](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/types.ts#L1065)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/reference/type-aliases/StreamChunk.md` at line 23, The documentation
entry for TypedStreamChunk has a stale "Defined in" anchor; update the link
target in docs/reference/type-aliases/StreamChunk.md so it points to the actual
definition of TypedStreamChunk in types.ts (current location around line 1065)
or replace the fragile line-number anchor with a file-level link to types.ts and
a search-friendly fragment for TypedStreamChunk; ensure the reference text
"Defined in" continues to reference types.ts and that the anchor resolves to the
TypedStreamChunk definition.
packages/typescript/ai/tests/type-check.test.ts (1)

6-17: ⚠️ Potential issue | 🟡 Minor

Import members need alphabetical sorting.

ESLint's sort-imports rule requires alphabetically ordered named imports within each statement.

🔧 Suggested fix
-import { describe, it, expectTypeOf } from 'vitest'
+import { describe, expectTypeOf, it } from 'vitest'
 import { z } from 'zod'
 import { chat, createChatOptions, toolDefinition } from '../src'
 import type {
   JSONSchema,
   StreamChunk,
   Tool,
   ToolCallArgsEvent,
-  ToolCallStartEvent,
   ToolCallEndEvent,
+  ToolCallStartEvent,
   TypedStreamChunk,
 } from '../src'
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/typescript/ai/tests/type-check.test.ts` around lines 6 - 17, The
named imports in this file are not alphabetized; reorder the identifiers
alphabetically within each import statement—for example change "describe, it,
expectTypeOf" to "describe, expectTypeOf, it", "chat, createChatOptions,
toolDefinition" to "chat, createChatOptions, toolDefinition" (ensure correct
alphabetical order), and the type import list "JSONSchema, StreamChunk, Tool,
ToolCallArgsEvent, ToolCallStartEvent, ToolCallEndEvent, TypedStreamChunk"
should be reordered alphabetically (e.g., "JSONSchema, StreamChunk, Tool,
ToolCallArgsEvent, ToolCallEndEvent, ToolCallStartEvent, TypedStreamChunk") so
each import's named members follow ESLint's sort-imports rule.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@docs/reference/type-aliases/StreamChunk.md`:
- Line 23: The documentation entry for TypedStreamChunk has a stale "Defined in"
anchor; update the link target in docs/reference/type-aliases/StreamChunk.md so
it points to the actual definition of TypedStreamChunk in types.ts (current
location around line 1065) or replace the fragile line-number anchor with a
file-level link to types.ts and a search-friendly fragment for TypedStreamChunk;
ensure the reference text "Defined in" continues to reference types.ts and that
the anchor resolves to the TypedStreamChunk definition.

In `@packages/typescript/ai/tests/type-check.test.ts`:
- Around line 6-17: The named imports in this file are not alphabetized; reorder
the identifiers alphabetically within each import statement—for example change
"describe, it, expectTypeOf" to "describe, expectTypeOf, it", "chat,
createChatOptions, toolDefinition" to "chat, createChatOptions, toolDefinition"
(ensure correct alphabetical order), and the type import list "JSONSchema,
StreamChunk, Tool, ToolCallArgsEvent, ToolCallStartEvent, ToolCallEndEvent,
TypedStreamChunk" should be reordered alphabetically (e.g., "JSONSchema,
StreamChunk, Tool, ToolCallArgsEvent, ToolCallEndEvent, ToolCallStartEvent,
TypedStreamChunk") so each import's named members follow ESLint's sort-imports
rule.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 230ab7f9-f926-49b5-a973-0080ff8b4502

📥 Commits

Reviewing files that changed from the base of the PR and between a2c2f9c and 5e3ebd7.

📒 Files selected for processing (5)
  • docs/chat/streaming.md
  • docs/reference/type-aliases/StreamChunk.md
  • examples/ts-react-chat/src/routes/api.tanchat.ts
  • packages/typescript/ai/src/types.ts
  • packages/typescript/ai/tests/type-check.test.ts
✅ Files skipped from review due to trivial changes (1)
  • docs/chat/streaming.md

@AlemTuzlak
AlemTuzlak force-pushed the worktree-serialized-exploring-wall branch from c798ae0 to f2aaac0 Compare April 24, 2026 10:43
Comment thread packages/ai/src/utilities/chat-params.ts Outdated
Comment thread packages/ai/src/utilities/chat-params.ts
Comment thread packages/ai/src/strip-to-spec-middleware.ts Outdated
Comment thread packages/ai/src/types.ts Outdated

@tombeckenham tombeckenham left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The event types diverge from @ag-ui/core . If we can't keep those types, then this isn't worth it

@tombeckenham tombeckenham self-assigned this Jun 5, 2026
tombeckenham added a commit that referenced this pull request Jul 20, 2026
Address PR #452 review: drop the Pick/AssertSatisfiesAGUI rewrite and
restore extends AGUI*Event. Keep tool-aware TypedStreamChunk, thread TTools
through chat(), fix mergeAgentTools with honest overloads, strip-to-spec
without unknown casts, and populate input/output on ToolResult for typed
engine END emissions (continuation path). Add toolCallName/output type tests.
@tombeckenham
tombeckenham self-requested a review July 20, 2026 07:38
tombeckenham added a commit that referenced this pull request Jul 20, 2026
Drop bulk gpt-4o→gpt-5.2 renames, unrelated Svelte callback fix, and other
incidental file churn so #452 is scoped to TypedStreamChunk / chat() tool
event typing and its docs/tests.
Rebased onto current main as a single clean commit (old history targeted
packages/typescript/ai and could not replay).

- TypedStreamChunk<TTools> with per-tool TOOL_CALL_START/END discrimination
- Thread TTools through chat() / TextActivityResult / createChatOptions
- Honest mergeAgentTools overloads; populate input/output on ToolResult
- Docs + type-level tests
@tombeckenham
tombeckenham force-pushed the worktree-serialized-exploring-wall branch from 28f2157 to 083835d Compare July 20, 2026 10:08
tombeckenham and others added 4 commits July 20, 2026 20:18
- Pick-based ToolCallStart/End/CustomEvent (no Zod index signature leak)
- Remap StreamChunk via type-literal discriminant, not Exclude<{type}>
- Docs: self-contained snippets; use `'type' in chunk` for control-flow narrow
- Sandbox test narrows CUSTOM before reading value
expect-type v1.2+ deprecates toMatchTypeOf in favor of toExtend for
assignability checks.
- Rename RemapStreamChunkForTools type param C → TChunk
- Drop unnecessary as StreamChunk/CustomEvent/ToolCallEndEvent casts
- Bedrock test: extract CUSTOM by string literal after Pick-based CustomEvent

@tombeckenham tombeckenham left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made a few changes. It looks clean now. Ready to merge

@AlemTuzlak
AlemTuzlak merged commit fe53f15 into main Jul 21, 2026
10 checks passed
@AlemTuzlak
AlemTuzlak deleted the worktree-serialized-exploring-wall branch July 21, 2026 09:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants