@tanstack/ai-remix 0.0.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -0
- package/package.json +4 -4
- package/src/create-web-mcp-tools.ts +59 -0
- package/src/index.ts +2 -0
package/README.md
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<picture>
|
|
3
|
+
<source
|
|
4
|
+
media="(prefers-color-scheme: dark)"
|
|
5
|
+
srcset="https://tanstack.com/api/readme/ai.png?theme=dark"
|
|
6
|
+
/>
|
|
7
|
+
<source
|
|
8
|
+
media="(prefers-color-scheme: light)"
|
|
9
|
+
srcset="https://tanstack.com/api/readme/ai.png"
|
|
10
|
+
/>
|
|
11
|
+
<img
|
|
12
|
+
src="https://tanstack.com/api/readme/ai.png"
|
|
13
|
+
alt="TanStack AI"
|
|
14
|
+
width="900"
|
|
15
|
+
/>
|
|
16
|
+
</picture>
|
|
17
|
+
</div>
|
|
18
|
+
|
|
19
|
+
<br />
|
|
20
|
+
|
|
1
21
|
# @tanstack/ai-remix
|
|
2
22
|
|
|
3
23
|
Remix 3 helpers for TanStack AI streaming chat.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/ai-remix",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Remix 3 bindings for TanStack AI streaming chat, structured outputs, and media generation.",
|
|
5
5
|
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -46,11 +46,11 @@
|
|
|
46
46
|
"README.md"
|
|
47
47
|
],
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@tanstack/ai-client": "^0.
|
|
49
|
+
"@tanstack/ai-client": "^0.31.0"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
52
|
"remix": "^3.0.0-rc.1",
|
|
53
|
-
"@tanstack/ai": "^0.
|
|
53
|
+
"@tanstack/ai": "^0.53.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@types/node": "^24.10.1",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"remix": "^3.0.0-rc.1",
|
|
60
60
|
"vite": "^8.2.1",
|
|
61
61
|
"vitest": "^4.1.10",
|
|
62
|
-
"@tanstack/ai": "0.
|
|
62
|
+
"@tanstack/ai": "0.53.0"
|
|
63
63
|
},
|
|
64
64
|
"scripts": {
|
|
65
65
|
"lint:fix": "oxlint src --type-aware --fix",
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { registerWebMCPTools } from '@tanstack/ai-client'
|
|
2
|
+
import type {
|
|
3
|
+
AnyClientTool,
|
|
4
|
+
InferredClientContext,
|
|
5
|
+
RegisterWebMCPToolsOptions,
|
|
6
|
+
} from '@tanstack/ai-client'
|
|
7
|
+
import type { Handle } from 'remix/ui'
|
|
8
|
+
|
|
9
|
+
/** Options for {@link createWebMCPTools}. */
|
|
10
|
+
export type CreateWebMCPToolsOptions<
|
|
11
|
+
TTools extends ReadonlyArray<AnyClientTool>,
|
|
12
|
+
TContext = InferredClientContext<TTools>,
|
|
13
|
+
> = Omit<RegisterWebMCPToolsOptions<TTools, TContext>, 'signal'> & {
|
|
14
|
+
/** Receives an asynchronous registration error. */
|
|
15
|
+
onError?: (error: unknown) => void
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
type CreateWebMCPToolsArguments<
|
|
19
|
+
TTools extends ReadonlyArray<AnyClientTool>,
|
|
20
|
+
TContext,
|
|
21
|
+
> =
|
|
22
|
+
{} extends CreateWebMCPToolsOptions<TTools, TContext>
|
|
23
|
+
? [options?: CreateWebMCPToolsOptions<TTools, TContext>]
|
|
24
|
+
: [options: CreateWebMCPToolsOptions<TTools, TContext>]
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Registers executable client tools with WebMCP for a Remix component.
|
|
28
|
+
*
|
|
29
|
+
* The component Handle signal removes every tool registered by this call.
|
|
30
|
+
*
|
|
31
|
+
* @param handle - The Remix component Handle from setup.
|
|
32
|
+
* @param tools - The executable client tools to expose through WebMCP.
|
|
33
|
+
* @param options - Runtime context, per-tool options, and error handling.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```tsx
|
|
37
|
+
* function Products(handle: Handle) {
|
|
38
|
+
* createWebMCPTools(handle, [searchProducts])
|
|
39
|
+
* return () => <ProductList />
|
|
40
|
+
* }
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export function createWebMCPTools<
|
|
44
|
+
const TTools extends ReadonlyArray<AnyClientTool>,
|
|
45
|
+
TContext = InferredClientContext<TTools>,
|
|
46
|
+
>(
|
|
47
|
+
handle: Pick<Handle, 'signal'>,
|
|
48
|
+
tools: TTools,
|
|
49
|
+
...[options]: CreateWebMCPToolsArguments<TTools, TContext>
|
|
50
|
+
) {
|
|
51
|
+
void registerWebMCPTools(tools, {
|
|
52
|
+
...options,
|
|
53
|
+
signal: handle.signal,
|
|
54
|
+
}).catch((error) => {
|
|
55
|
+
if (!handle.signal.aborted) {
|
|
56
|
+
options?.onError?.(error)
|
|
57
|
+
}
|
|
58
|
+
})
|
|
59
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -3,6 +3,8 @@ export { createByok } from './create-byok.ts'
|
|
|
3
3
|
export { createRealtimeChat } from './create-realtime-chat.ts'
|
|
4
4
|
export { createMcpAppBridge } from './create-mcp-app-bridge.ts'
|
|
5
5
|
export type { CreateMcpAppBridgeOptions } from './create-mcp-app-bridge.ts'
|
|
6
|
+
export { createWebMCPTools } from './create-web-mcp-tools.ts'
|
|
7
|
+
export type { CreateWebMCPToolsOptions } from './create-web-mcp-tools.ts'
|
|
6
8
|
export type {
|
|
7
9
|
DeepPartial,
|
|
8
10
|
CreateChatOptions,
|