+
+```
+
+## Example: Tool Approval
+
+```vue
+
+
+
+
+
+
+
Approve: {{ part.name }}
+
+
+
+
+
+
+
+```
+
+## Example: Client Tools with Type Safety
+
+```vue
+
+
+
+
+
+
+
Tool executed: {{ part.name }}
+
+
+
+
+
+```
+
+## `createChatClientOptions(options)`
+
+Helper to create typed chat options (re-exported from `@tanstack/ai-client`).
+
+```typescript
+import {
+ clientTools,
+ createChatClientOptions,
+ type InferChatMessages
+} from "@tanstack/ai-client";
+
+// Create typed tools array (no 'as const' needed!)
+const tools = clientTools(tool1, tool2);
+
+const chatOptions = createChatClientOptions({
+ connection: fetchServerSentEvents("/api/chat"),
+ tools,
+});
+
+type Messages = InferChatMessages
;
+```
+
+## Types
+
+Re-exported from `@tanstack/ai-client`:
+
+- `UIMessage` - Message type with tool type parameter
+- `MessagePart` - Message part with tool type parameter
+- `TextPart` - Text content part
+- `ThinkingPart` - Thinking content part
+- `ToolCallPart` - Tool call part (discriminated union)
+- `ToolResultPart` - Tool result part
+- `ChatClientOptions` - Chat client options
+- `ConnectionAdapter` - Connection adapter interface
+- `InferChatMessages` - Extract message type from options
+
+Re-exported from `@tanstack/ai`:
+
+- `toolDefinition()` - Create isomorphic tool definition
+- `ToolDefinitionInstance` - Tool definition type
+- `ClientTool` - Client tool type
+- `ServerTool` - Server tool type
+
+## Next Steps
+
+- [Getting Started](../getting-started/quick-start) - Learn the basics
+- [Tools Guide](../guides/tools) - Learn about the isomorphic tool system
+- [Client Tools](../guides/client-tools) - Learn about client-side tools
diff --git a/docs/config.json b/docs/config.json
index 7cf47840..4b2259f2 100644
--- a/docs/config.json
+++ b/docs/config.json
@@ -19,7 +19,7 @@
},
{
"label": "Devtools",
- "to": "getting-started/devtools"
+ "to": "getting-started/devtools"
}
]
},
@@ -86,6 +86,10 @@
{
"label": "@tanstack/ai-solid",
"to": "api/ai-solid"
+ },
+ {
+ "label": "@tanstack/ai-vue",
+ "to": "api/ai-vue"
}
]
},
@@ -542,4 +546,4 @@
]
}
]
-}
+}
\ No newline at end of file
From dcdacf560f26e403cee425429cc3a8095e4773fd Mon Sep 17 00:00:00 2001
From: wankong <1549072621@qq.com>
Date: Tue, 9 Dec 2025 20:49:42 +0800
Subject: [PATCH 2/2] docs(ai-vue): correct type define and perfect example
---
docs/api/ai-vue.md | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/docs/api/ai-vue.md b/docs/api/ai-vue.md
index 458f92e0..1408d3ba 100644
--- a/docs/api/ai-vue.md
+++ b/docs/api/ai-vue.md
@@ -24,6 +24,7 @@ import {
createChatClientOptions,
type InferChatMessages
} from "@tanstack/ai-client";
+// see more in https://tanstack.com/ai/latest/docs/guides/client-tools#defining-client-tools
import { updateUIDef } from "@/tools/definitions";
const notification = ref(null);
@@ -74,7 +75,7 @@ Extends `ChatClientOptions` from `@tanstack/ai-client`:
```typescript
interface UseChatReturn {
- messages: UIMessage[];
+ messages: DeepReadonly>>;
sendMessage: (content: string) => Promise;
append: (message: ModelMessage | UIMessage) => Promise;
addToolResult: (result: {
@@ -90,8 +91,8 @@ interface UseChatReturn {
}) => Promise;
reload: () => Promise;
stop: () => void;
- isLoading: boolean;
- error: Error | undefined;
+ isLoading: DeepReadonly>;
+ error: DeepReadonly>;
setMessages: (messages: UIMessage[]) => void;
clear: () => void;
}
@@ -127,6 +128,7 @@ const handleSubmit = (e: Event) => {
const val = input.value.trim()
if (((val ?? '') !== '') && !isLoading) {
sendMessage(input.value);
+ input.value = '';
}
};
@@ -136,9 +138,8 @@ const handleSubmit = (e: Event) => {
{{ message.role }}
{{ part.content }}
-
-
💠Thinking: {{ part.content }}
-
+
💠Thinking: {{ part.content }}
+