@assistant-ui/mcp-docs-server 0.1.14 → 0.1.15
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/.docs/organized/code-examples/store-example.md +554 -0
- package/.docs/organized/code-examples/with-ag-ui.md +582 -32
- package/.docs/organized/code-examples/with-ai-sdk-v5.md +549 -47
- package/.docs/organized/code-examples/with-assistant-transport.md +547 -46
- package/.docs/organized/code-examples/with-cloud.md +634 -39
- package/.docs/organized/code-examples/with-external-store.md +581 -31
- package/.docs/organized/code-examples/with-ffmpeg.md +581 -47
- package/.docs/organized/code-examples/with-langgraph.md +633 -50
- package/.docs/organized/code-examples/with-parent-id-grouping.md +581 -31
- package/.docs/organized/code-examples/with-react-hook-form.md +582 -70
- package/.docs/raw/blog/2024-07-29-hello/index.mdx +0 -1
- package/.docs/raw/docs/cli.mdx +396 -0
- package/.docs/raw/docs/getting-started.mdx +31 -37
- package/.docs/raw/docs/runtimes/assistant-transport.mdx +891 -0
- package/.docs/raw/docs/runtimes/langgraph/index.mdx +1 -1
- package/package.json +13 -5
|
@@ -0,0 +1,554 @@
|
|
|
1
|
+
# Example: store-example
|
|
2
|
+
|
|
3
|
+
## app/globals.css
|
|
4
|
+
|
|
5
|
+
```css
|
|
6
|
+
@import "tailwindcss";
|
|
7
|
+
|
|
8
|
+
:root {
|
|
9
|
+
--background: #ffffff;
|
|
10
|
+
--foreground: #171717;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
@theme inline {
|
|
14
|
+
--color-background: var(--background);
|
|
15
|
+
--color-foreground: var(--foreground);
|
|
16
|
+
--font-sans: var(--font-geist-sans);
|
|
17
|
+
--font-mono: var(--font-geist-mono);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
@media (prefers-color-scheme: dark) {
|
|
21
|
+
:root {
|
|
22
|
+
--background: #0a0a0a;
|
|
23
|
+
--foreground: #ededed;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
body {
|
|
28
|
+
background: var(--background);
|
|
29
|
+
color: var(--foreground);
|
|
30
|
+
font-family: Arial, Helvetica, sans-serif;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## app/layout.tsx
|
|
36
|
+
|
|
37
|
+
```tsx
|
|
38
|
+
import type { Metadata } from "next";
|
|
39
|
+
import { Geist, Geist_Mono } from "next/font/google";
|
|
40
|
+
import "./globals.css";
|
|
41
|
+
|
|
42
|
+
const geistSans = Geist({
|
|
43
|
+
variable: "--font-geist-sans",
|
|
44
|
+
subsets: ["latin"],
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const geistMono = Geist_Mono({
|
|
48
|
+
variable: "--font-geist-mono",
|
|
49
|
+
subsets: ["latin"],
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
export const metadata: Metadata = {
|
|
53
|
+
title: "Create Next App",
|
|
54
|
+
description: "Generated by create next app",
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export default function RootLayout({
|
|
58
|
+
children,
|
|
59
|
+
}: Readonly<{
|
|
60
|
+
children: React.ReactNode;
|
|
61
|
+
}>) {
|
|
62
|
+
return (
|
|
63
|
+
<html lang="en">
|
|
64
|
+
<body
|
|
65
|
+
className={`${geistSans.variable} ${geistMono.variable} antialiased`}
|
|
66
|
+
>
|
|
67
|
+
{children}
|
|
68
|
+
</body>
|
|
69
|
+
</html>
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## app/page.tsx
|
|
76
|
+
|
|
77
|
+
```tsx
|
|
78
|
+
import { ExampleApp } from "@/lib/example-app";
|
|
79
|
+
|
|
80
|
+
export default function Home() {
|
|
81
|
+
return (
|
|
82
|
+
<div className="min-h-screen bg-gradient-to-br from-gray-50 to-gray-100 p-8 dark:from-gray-900 dark:to-gray-800">
|
|
83
|
+
<div className="mx-auto max-w-4xl">
|
|
84
|
+
<div className="mb-8">
|
|
85
|
+
<h1 className="mb-2 text-4xl font-bold text-gray-900 dark:text-white">
|
|
86
|
+
@assistant-ui/store Example
|
|
87
|
+
</h1>
|
|
88
|
+
<p className="text-lg text-gray-600 dark:text-gray-400">
|
|
89
|
+
Demonstrating tap-based state management with scopes, lists, and
|
|
90
|
+
providers
|
|
91
|
+
</p>
|
|
92
|
+
</div>
|
|
93
|
+
|
|
94
|
+
<ExampleApp />
|
|
95
|
+
</div>
|
|
96
|
+
</div>
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## lib/example-app.tsx
|
|
103
|
+
|
|
104
|
+
```tsx
|
|
105
|
+
"use client";
|
|
106
|
+
|
|
107
|
+
import {
|
|
108
|
+
useAssistantClient,
|
|
109
|
+
AssistantProvider,
|
|
110
|
+
useAssistantState,
|
|
111
|
+
} from "@assistant-ui/store";
|
|
112
|
+
import { FooList, FooListResource } from "./store/foo-store";
|
|
113
|
+
|
|
114
|
+
import "./store/foo-scope"; // Register the fooList scope (demonstrates scope registry)
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Single Foo component - displays and allows editing a single foo
|
|
118
|
+
*/
|
|
119
|
+
const Foo = () => {
|
|
120
|
+
const aui = useAssistantClient();
|
|
121
|
+
const fooState = useAssistantState(({ foo }) => {
|
|
122
|
+
console.log("selector called with state", foo);
|
|
123
|
+
return foo;
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
const handleUpdate = () => {
|
|
127
|
+
aui.foo().updateBar(`Updated at ${new Date().toLocaleTimeString()}`);
|
|
128
|
+
console.log("Foo state", aui.foo().getState(), fooState);
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
return (
|
|
132
|
+
<div className="rounded-lg border border-gray-200 bg-white p-6 shadow-md transition-shadow hover:shadow-lg dark:border-gray-700 dark:bg-gray-800">
|
|
133
|
+
<div className="space-y-3">
|
|
134
|
+
<div className="flex items-center gap-2">
|
|
135
|
+
<span className="text-sm font-semibold text-gray-500 dark:text-gray-400">
|
|
136
|
+
ID:
|
|
137
|
+
</span>
|
|
138
|
+
<span className="font-mono text-sm text-gray-900 dark:text-white">
|
|
139
|
+
{fooState.id}
|
|
140
|
+
</span>
|
|
141
|
+
</div>
|
|
142
|
+
<div className="flex items-center gap-2">
|
|
143
|
+
<span className="text-sm font-semibold text-gray-500 dark:text-gray-400">
|
|
144
|
+
Value:
|
|
145
|
+
</span>
|
|
146
|
+
<span className="text-gray-900 dark:text-white">{fooState.bar}</span>
|
|
147
|
+
</div>
|
|
148
|
+
<div className="mt-2 flex gap-2">
|
|
149
|
+
<button
|
|
150
|
+
onClick={handleUpdate}
|
|
151
|
+
className="flex-1 rounded-md bg-blue-600 px-4 py-2 font-medium text-white transition-colors hover:bg-blue-700 focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 focus:outline-none dark:focus:ring-offset-gray-800"
|
|
152
|
+
>
|
|
153
|
+
Update
|
|
154
|
+
</button>
|
|
155
|
+
<button
|
|
156
|
+
onClick={() => aui.foo().remove()}
|
|
157
|
+
className="rounded-md bg-red-600 px-4 py-2 font-medium text-white transition-colors hover:bg-red-700 focus:ring-2 focus:ring-red-500 focus:ring-offset-2 focus:outline-none dark:focus:ring-offset-gray-800"
|
|
158
|
+
>
|
|
159
|
+
Delete
|
|
160
|
+
</button>
|
|
161
|
+
</div>
|
|
162
|
+
</div>
|
|
163
|
+
</div>
|
|
164
|
+
);
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
const FooListLength = () => {
|
|
168
|
+
const fooListLength = useAssistantState(({ fooList }) => fooList.foos.length);
|
|
169
|
+
return (
|
|
170
|
+
<span className="text-gray-500 dark:text-gray-400">
|
|
171
|
+
({fooListLength} items)
|
|
172
|
+
</span>
|
|
173
|
+
);
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
const AddFooButton = () => {
|
|
177
|
+
const aui = useAssistantClient();
|
|
178
|
+
return (
|
|
179
|
+
<button
|
|
180
|
+
onClick={() => aui.fooList().addFoo()}
|
|
181
|
+
className="rounded-md bg-green-600 px-4 py-2 font-medium text-white transition-colors hover:bg-green-700 focus:ring-2 focus:ring-green-500 focus:ring-offset-2 focus:outline-none dark:focus:ring-offset-gray-800"
|
|
182
|
+
>
|
|
183
|
+
Add New
|
|
184
|
+
</button>
|
|
185
|
+
);
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Example App - demonstrates the store with styled components
|
|
190
|
+
*
|
|
191
|
+
* Note: The fooList scope is also registered in foo-scope.ts as a default,
|
|
192
|
+
* but we're explicitly passing it here for clarity in the example.
|
|
193
|
+
*/
|
|
194
|
+
export const ExampleApp = () => {
|
|
195
|
+
const rootClient = useAssistantClient({
|
|
196
|
+
fooList: FooListResource(),
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
return (
|
|
200
|
+
<AssistantProvider client={rootClient}>
|
|
201
|
+
<div className="space-y-6">
|
|
202
|
+
<div className="rounded-lg border border-gray-200 bg-white p-4 shadow-sm dark:border-gray-700 dark:bg-gray-800">
|
|
203
|
+
<div className="flex items-center justify-between">
|
|
204
|
+
<h2 className="text-xl font-semibold text-gray-900 dark:text-white">
|
|
205
|
+
Foo List <FooListLength />
|
|
206
|
+
</h2>
|
|
207
|
+
<AddFooButton />
|
|
208
|
+
</div>
|
|
209
|
+
<p className="mt-1 text-sm text-gray-600 dark:text-gray-400">
|
|
210
|
+
Each item is rendered in its own FooProvider with scoped access
|
|
211
|
+
</p>
|
|
212
|
+
</div>
|
|
213
|
+
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-3">
|
|
214
|
+
<FooList components={{ Foo }} />
|
|
215
|
+
</div>
|
|
216
|
+
</div>
|
|
217
|
+
</AssistantProvider>
|
|
218
|
+
);
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
## lib/store/foo-scope.ts
|
|
224
|
+
|
|
225
|
+
```typescript
|
|
226
|
+
/**
|
|
227
|
+
* Scope registration for the foo example
|
|
228
|
+
* Import this file to register the default fooList scope
|
|
229
|
+
*/
|
|
230
|
+
import { registerAssistantScope } from "@assistant-ui/store";
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Define scopes via module augmentation
|
|
234
|
+
* Implement the scope definition raw without importing ScopeDefinition
|
|
235
|
+
*/
|
|
236
|
+
declare module "@assistant-ui/store" {
|
|
237
|
+
interface AssistantScopeRegistry {
|
|
238
|
+
foo: {
|
|
239
|
+
value: {
|
|
240
|
+
getState: () => { id: string; bar: string };
|
|
241
|
+
updateBar: (newBar: string) => void;
|
|
242
|
+
remove: () => void;
|
|
243
|
+
};
|
|
244
|
+
source: "fooList";
|
|
245
|
+
query: { index: number } | { id: string };
|
|
246
|
+
};
|
|
247
|
+
fooList: {
|
|
248
|
+
value: {
|
|
249
|
+
getState: () => { foos: Array<{ id: string; bar: string }> };
|
|
250
|
+
foo: (
|
|
251
|
+
lookup: { index: number } | { id: string },
|
|
252
|
+
) => AssistantScopeRegistry["foo"]["value"];
|
|
253
|
+
addFoo: (id?: string) => void;
|
|
254
|
+
};
|
|
255
|
+
source: "root";
|
|
256
|
+
query: Record<string, never>;
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// Register the fooList scope with a default implementation
|
|
262
|
+
registerAssistantScope({
|
|
263
|
+
name: "fooList",
|
|
264
|
+
defaultInitialize: { error: "FooList is not configured" },
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
## lib/store/foo-store.tsx
|
|
270
|
+
|
|
271
|
+
```tsx
|
|
272
|
+
"use client";
|
|
273
|
+
|
|
274
|
+
import React from "react";
|
|
275
|
+
import { resource, tapState } from "@assistant-ui/tap";
|
|
276
|
+
import {
|
|
277
|
+
useAssistantClient,
|
|
278
|
+
AssistantProvider,
|
|
279
|
+
tapApi,
|
|
280
|
+
tapStoreList,
|
|
281
|
+
DerivedScope,
|
|
282
|
+
useAssistantState,
|
|
283
|
+
} from "@assistant-ui/store";
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Single Foo item resource
|
|
287
|
+
* Manages the state and actions for a single foo item
|
|
288
|
+
*/
|
|
289
|
+
export const FooItemResource = resource(
|
|
290
|
+
({
|
|
291
|
+
initialValue: { id, initialBar },
|
|
292
|
+
remove,
|
|
293
|
+
}: {
|
|
294
|
+
initialValue: { id: string; initialBar: string };
|
|
295
|
+
remove: () => void;
|
|
296
|
+
}) => {
|
|
297
|
+
const [state, setState] = tapState<{ id: string; bar: string }>({
|
|
298
|
+
id,
|
|
299
|
+
bar: initialBar,
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
const updateBar = (newBar: string) => {
|
|
303
|
+
setState({ ...state, bar: newBar });
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
return tapApi(
|
|
307
|
+
{
|
|
308
|
+
getState: () => state,
|
|
309
|
+
updateBar,
|
|
310
|
+
remove,
|
|
311
|
+
},
|
|
312
|
+
{ key: id },
|
|
313
|
+
);
|
|
314
|
+
},
|
|
315
|
+
);
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* FooList resource implementation
|
|
319
|
+
* Manages a list of foos using tapStoreList
|
|
320
|
+
*/
|
|
321
|
+
let counter = 3;
|
|
322
|
+
export const FooListResource = resource(() => {
|
|
323
|
+
const idGenerator = () => `foo-${++counter}`;
|
|
324
|
+
|
|
325
|
+
const foos = tapStoreList({
|
|
326
|
+
initialValues: [
|
|
327
|
+
{ id: "foo-1", initialBar: "First Foo" },
|
|
328
|
+
{ id: "foo-2", initialBar: "Second Foo" },
|
|
329
|
+
{ id: "foo-3", initialBar: "Third Foo" },
|
|
330
|
+
],
|
|
331
|
+
resource: FooItemResource,
|
|
332
|
+
idGenerator,
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
return tapApi({
|
|
336
|
+
getState: () => ({ foos: foos.state }),
|
|
337
|
+
foo: foos.api,
|
|
338
|
+
addFoo: (id?: string) => foos.add(id),
|
|
339
|
+
});
|
|
340
|
+
});
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* FooProvider - Provides foo scope for a specific index
|
|
344
|
+
*/
|
|
345
|
+
export const FooProvider = ({
|
|
346
|
+
index,
|
|
347
|
+
children,
|
|
348
|
+
}: {
|
|
349
|
+
index: number;
|
|
350
|
+
children: React.ReactNode;
|
|
351
|
+
}) => {
|
|
352
|
+
// Create a derived client with the foo scope at the specified index
|
|
353
|
+
const aui = useAssistantClient({
|
|
354
|
+
foo: DerivedScope({
|
|
355
|
+
source: "fooList",
|
|
356
|
+
query: { index },
|
|
357
|
+
get: (aui) => aui.fooList().foo({ index }),
|
|
358
|
+
}),
|
|
359
|
+
});
|
|
360
|
+
|
|
361
|
+
return <AssistantProvider client={aui}>{children}</AssistantProvider>;
|
|
362
|
+
};
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
* FooList component - minimal mapping component
|
|
366
|
+
* Maps over the list and renders each item in a FooProvider
|
|
367
|
+
*/
|
|
368
|
+
export const FooList = ({
|
|
369
|
+
components,
|
|
370
|
+
}: {
|
|
371
|
+
components: { Foo: React.ComponentType };
|
|
372
|
+
}) => {
|
|
373
|
+
const fooListState = useAssistantState(({ fooList }) => fooList.foos.length);
|
|
374
|
+
|
|
375
|
+
return (
|
|
376
|
+
<>
|
|
377
|
+
{Array.from({ length: fooListState }, (_, index) => (
|
|
378
|
+
<FooProvider key={index} index={index}>
|
|
379
|
+
<components.Foo />
|
|
380
|
+
</FooProvider>
|
|
381
|
+
))}
|
|
382
|
+
</>
|
|
383
|
+
);
|
|
384
|
+
};
|
|
385
|
+
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
## next.config.ts
|
|
389
|
+
|
|
390
|
+
```typescript
|
|
391
|
+
import type { NextConfig } from "next";
|
|
392
|
+
|
|
393
|
+
const nextConfig: NextConfig = {
|
|
394
|
+
/* config options here */
|
|
395
|
+
};
|
|
396
|
+
|
|
397
|
+
export default nextConfig;
|
|
398
|
+
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
## package.json
|
|
402
|
+
|
|
403
|
+
```json
|
|
404
|
+
{
|
|
405
|
+
"name": "store-example",
|
|
406
|
+
"version": "0.1.0",
|
|
407
|
+
"private": true,
|
|
408
|
+
"scripts": {
|
|
409
|
+
"dev": "next dev",
|
|
410
|
+
"build": "next build",
|
|
411
|
+
"start": "next start",
|
|
412
|
+
"lint": "eslint"
|
|
413
|
+
},
|
|
414
|
+
"dependencies": {
|
|
415
|
+
"@assistant-ui/store": "workspace:*",
|
|
416
|
+
"@assistant-ui/tap": "workspace:*",
|
|
417
|
+
"next": "16.0.4",
|
|
418
|
+
"react": "19.2.0",
|
|
419
|
+
"react-dom": "19.2.0"
|
|
420
|
+
},
|
|
421
|
+
"devDependencies": {
|
|
422
|
+
"@assistant-ui/x-buildutils": "workspace:*",
|
|
423
|
+
"@tailwindcss/postcss": "^4",
|
|
424
|
+
"@types/node": "^24",
|
|
425
|
+
"@types/react": "19.2.7",
|
|
426
|
+
"@types/react-dom": "19.2.3",
|
|
427
|
+
"eslint": "^9",
|
|
428
|
+
"eslint-config-next": "16.0.4",
|
|
429
|
+
"tailwindcss": "^4",
|
|
430
|
+
"typescript": "^5"
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
## README.md
|
|
437
|
+
|
|
438
|
+
```markdown
|
|
439
|
+
# @assistant-ui/store Example App
|
|
440
|
+
|
|
441
|
+
This is a Next.js application demonstrating the `@assistant-ui/store` package.
|
|
442
|
+
|
|
443
|
+
## Features Demonstrated
|
|
444
|
+
|
|
445
|
+
- **Scope Definition**: Module augmentation for type-safe scopes
|
|
446
|
+
- **tapApi**: Wrapping API objects for stability and reactivity
|
|
447
|
+
- **tapLookupResources**: Managing lists with index and ID lookup
|
|
448
|
+
- **Provider Pattern**: Scoped access to list items via FooProvider
|
|
449
|
+
- **Component Composition**: Render props pattern with components prop
|
|
450
|
+
|
|
451
|
+
## Getting Started
|
|
452
|
+
|
|
453
|
+
```bash
|
|
454
|
+
# Install dependencies (from monorepo root)
|
|
455
|
+
pnpm install
|
|
456
|
+
|
|
457
|
+
# Run the development server
|
|
458
|
+
cd examples/store-example
|
|
459
|
+
pnpm dev
|
|
460
|
+
```
|
|
461
|
+
|
|
462
|
+
Open [http://localhost:3000](http://localhost:3000) to see the example.
|
|
463
|
+
|
|
464
|
+
## Project Structure
|
|
465
|
+
|
|
466
|
+
- `lib/store/foo-store.tsx` - Clean store implementation with:
|
|
467
|
+
- Scope definitions (foo, fooList) via module augmentation
|
|
468
|
+
- Resource implementations (FooItemResource, FooListResource)
|
|
469
|
+
- Provider component (FooProvider)
|
|
470
|
+
- Minimal FooList mapping component
|
|
471
|
+
- `lib/example-app.tsx` - Example app with styled components:
|
|
472
|
+
- Styled Foo component
|
|
473
|
+
- ExampleApp with layout and styling
|
|
474
|
+
- `app/page.tsx` - Main page that renders the ExampleApp
|
|
475
|
+
|
|
476
|
+
## Key Concepts
|
|
477
|
+
|
|
478
|
+
### Scope Definition
|
|
479
|
+
|
|
480
|
+
```typescript
|
|
481
|
+
declare module "@assistant-ui/store" {
|
|
482
|
+
namespace AssistantStore {
|
|
483
|
+
interface Scopes {
|
|
484
|
+
foo: {
|
|
485
|
+
value: {
|
|
486
|
+
getState: () => { id: string; bar: string };
|
|
487
|
+
updateBar: (newBar: string) => void;
|
|
488
|
+
};
|
|
489
|
+
source: "fooList";
|
|
490
|
+
query: { index: number } | { id: string };
|
|
491
|
+
};
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
```
|
|
496
|
+
|
|
497
|
+
### Resource Implementation
|
|
498
|
+
|
|
499
|
+
```typescript
|
|
500
|
+
const FooListResource = resource(() => {
|
|
501
|
+
const items = [
|
|
502
|
+
/* ... */
|
|
503
|
+
];
|
|
504
|
+
const foos = tapLookupResources(
|
|
505
|
+
items.map((item) => FooItemResource(item, { key: item.id })),
|
|
506
|
+
);
|
|
507
|
+
|
|
508
|
+
return tapApi({
|
|
509
|
+
getState: () => ({ foos: foos.state }),
|
|
510
|
+
foo: foos.api,
|
|
511
|
+
});
|
|
512
|
+
});
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
### Provider Pattern
|
|
516
|
+
|
|
517
|
+
```typescript
|
|
518
|
+
const FooProvider = ({ index, children }) => {
|
|
519
|
+
const parentAui = useAssistantClient();
|
|
520
|
+
const aui = useAssistantClient({
|
|
521
|
+
foo: resource(() => parentAui.fooList().foo({ index }))(),
|
|
522
|
+
});
|
|
523
|
+
return <AssistantClientProvider client={aui}>{children}</AssistantClientProvider>;
|
|
524
|
+
};
|
|
525
|
+
```
|
|
526
|
+
|
|
527
|
+
## Learn More
|
|
528
|
+
|
|
529
|
+
- [@assistant-ui/store Documentation](../store/README.md)
|
|
530
|
+
- [Next.js Documentation](https://nextjs.org/docs)
|
|
531
|
+
|
|
532
|
+
```
|
|
533
|
+
|
|
534
|
+
## tsconfig.json
|
|
535
|
+
|
|
536
|
+
```json
|
|
537
|
+
{
|
|
538
|
+
"extends": "@assistant-ui/x-buildutils/ts/base",
|
|
539
|
+
"compilerOptions": {
|
|
540
|
+
"paths": {
|
|
541
|
+
"@/*": ["./*"],
|
|
542
|
+
"@assistant-ui/*": ["../../packages/*/src"],
|
|
543
|
+
"@assistant-ui/react/*": ["../../packages/react/src/*"],
|
|
544
|
+
"@assistant-ui/tap/*": ["../../packages/tap/src/*"],
|
|
545
|
+
"assistant-stream": ["../../packages/assistant-stream/src"],
|
|
546
|
+
"assistant-stream/*": ["../../packages/assistant-stream/src/*"]
|
|
547
|
+
}
|
|
548
|
+
},
|
|
549
|
+
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
|
|
550
|
+
"exclude": ["node_modules"]
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
```
|
|
554
|
+
|