@assistant-ui/mcp-docs-server 0.1.16 → 0.1.18
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/with-ag-ui.md +149 -155
- package/.docs/organized/code-examples/with-ai-sdk-v5.md +98 -103
- package/.docs/organized/code-examples/with-assistant-transport.md +134 -222
- package/.docs/organized/code-examples/with-cloud.md +127 -134
- package/.docs/organized/code-examples/with-custom-thread-list.md +28 -48
- package/.docs/organized/code-examples/with-external-store.md +149 -154
- package/.docs/organized/code-examples/with-ffmpeg.md +132 -142
- package/.docs/organized/code-examples/with-langgraph.md +234 -228
- package/.docs/organized/code-examples/with-parent-id-grouping.md +149 -154
- package/.docs/organized/code-examples/with-react-hook-form.md +149 -155
- package/.docs/organized/code-examples/{store-example.md → with-store.md} +181 -157
- package/.docs/organized/code-examples/with-tanstack.md +31 -45
- package/.docs/raw/docs/runtimes/custom/custom-thread-list.mdx +36 -0
- package/.docs/raw/docs/runtimes/custom/local.mdx +31 -8
- package/.docs/raw/docs/ui/Scrollbar.mdx +0 -6
- package/dist/constants.d.ts +10 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +14 -0
- package/dist/constants.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +33 -1
- package/dist/index.js.map +1 -0
- package/dist/prepare-docs/code-examples.d.ts +2 -0
- package/dist/prepare-docs/code-examples.d.ts.map +1 -0
- package/dist/prepare-docs/code-examples.js +129 -0
- package/dist/prepare-docs/code-examples.js.map +1 -0
- package/dist/prepare-docs/copy-raw.d.ts +2 -0
- package/dist/prepare-docs/copy-raw.d.ts.map +1 -0
- package/dist/prepare-docs/copy-raw.js +50 -0
- package/dist/prepare-docs/copy-raw.js.map +1 -0
- package/dist/prepare-docs/prepare.d.ts +2 -0
- package/dist/prepare-docs/prepare.d.ts.map +1 -0
- package/dist/prepare-docs/prepare.js +18 -195
- package/dist/prepare-docs/prepare.js.map +1 -0
- package/dist/stdio.d.ts +3 -0
- package/dist/stdio.d.ts.map +1 -0
- package/dist/stdio.js +4 -5
- package/dist/stdio.js.map +1 -0
- package/dist/tools/docs.d.ts +23 -0
- package/dist/tools/docs.d.ts.map +1 -0
- package/dist/tools/docs.js +168 -0
- package/dist/tools/docs.js.map +1 -0
- package/dist/tools/examples.d.ts +23 -0
- package/dist/tools/examples.d.ts.map +1 -0
- package/dist/tools/examples.js +95 -0
- package/dist/tools/examples.js.map +1 -0
- package/dist/tools/tests/test-setup.d.ts +4 -0
- package/dist/tools/tests/test-setup.d.ts.map +1 -0
- package/dist/tools/tests/test-setup.js +36 -0
- package/dist/tools/tests/test-setup.js.map +1 -0
- package/dist/utils/logger.d.ts +7 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +20 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/mcp-format.d.ts +7 -0
- package/dist/utils/mcp-format.d.ts.map +1 -0
- package/dist/utils/mcp-format.js +11 -0
- package/dist/utils/mcp-format.js.map +1 -0
- package/dist/utils/mdx.d.ts +9 -0
- package/dist/utils/mdx.d.ts.map +1 -0
- package/dist/utils/mdx.js +27 -0
- package/dist/utils/mdx.js.map +1 -0
- package/dist/utils/paths.d.ts +8 -0
- package/dist/utils/paths.d.ts.map +1 -0
- package/dist/utils/paths.js +84 -0
- package/dist/utils/paths.js.map +1 -0
- package/dist/utils/security.d.ts +2 -0
- package/dist/utils/security.d.ts.map +1 -0
- package/dist/utils/security.js +43 -0
- package/dist/utils/security.js.map +1 -0
- package/package.json +37 -19
- package/src/constants.ts +22 -0
- package/src/index.ts +51 -0
- package/src/prepare-docs/code-examples.ts +158 -0
- package/src/prepare-docs/copy-raw.ts +55 -0
- package/src/prepare-docs/prepare.ts +24 -0
- package/src/stdio.ts +7 -0
- package/src/tools/docs.ts +207 -0
- package/src/tools/examples.ts +107 -0
- package/src/tools/tests/docs.test.ts +122 -0
- package/src/tools/tests/examples.test.ts +94 -0
- package/src/tools/tests/integration.test.ts +46 -0
- package/src/tools/tests/json-parsing.test.ts +23 -0
- package/src/tools/tests/mcp-protocol.test.ts +133 -0
- package/src/tools/tests/path-traversal.test.ts +81 -0
- package/src/tools/tests/test-setup.ts +40 -0
- package/src/utils/logger.ts +20 -0
- package/src/utils/mcp-format.ts +12 -0
- package/src/utils/mdx.ts +39 -0
- package/src/utils/paths.ts +114 -0
- package/src/utils/security.ts +52 -0
- package/src/utils/tests/security.test.ts +119 -0
- package/dist/chunk-M2RKUM66.js +0 -38
- package/dist/chunk-NVNFQ5ZO.js +0 -423
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Example: store
|
|
1
|
+
# Example: with-store
|
|
2
2
|
|
|
3
3
|
## app/globals.css
|
|
4
4
|
|
|
@@ -118,14 +118,16 @@ import { FooList, FooListResource } from "./store/foo-store";
|
|
|
118
118
|
*/
|
|
119
119
|
const Foo = () => {
|
|
120
120
|
const aui = useAssistantClient();
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
|
|
121
|
+
const fooId = useAssistantState(({ foo }) => foo.id);
|
|
122
|
+
const fooBar = useAssistantState(({ foo }) => foo.bar);
|
|
123
|
+
|
|
124
|
+
// Each foo logs its own events - only receives events from THIS foo instance
|
|
125
|
+
useAssistantEvent("foo.updated", (payload) => {
|
|
126
|
+
console.log(`[${fooId}] Updated to: ${payload.newValue}`);
|
|
124
127
|
});
|
|
125
128
|
|
|
126
129
|
const handleUpdate = () => {
|
|
127
130
|
aui.foo().updateBar(`Updated at ${new Date().toLocaleTimeString()}`);
|
|
128
|
-
console.log("Foo state", aui.foo().getState(), fooState);
|
|
129
131
|
};
|
|
130
132
|
|
|
131
133
|
return (
|
|
@@ -136,14 +138,14 @@ const Foo = () => {
|
|
|
136
138
|
ID:
|
|
137
139
|
</span>
|
|
138
140
|
<span className="font-mono text-gray-900 text-sm dark:text-white">
|
|
139
|
-
{
|
|
141
|
+
{fooId}
|
|
140
142
|
</span>
|
|
141
143
|
</div>
|
|
142
144
|
<div className="flex items-center gap-2">
|
|
143
145
|
<span className="font-semibold text-gray-500 text-sm dark:text-gray-400">
|
|
144
146
|
Value:
|
|
145
147
|
</span>
|
|
146
|
-
<span className="text-gray-900 dark:text-white">{
|
|
148
|
+
<span className="text-gray-900 dark:text-white">{fooBar}</span>
|
|
147
149
|
</div>
|
|
148
150
|
<div className="mt-2 flex gap-2">
|
|
149
151
|
<button
|
|
@@ -252,12 +254,12 @@ const EventLog = () => {
|
|
|
252
254
|
* but we're explicitly passing it here for clarity in the example.
|
|
253
255
|
*/
|
|
254
256
|
export const ExampleApp = () => {
|
|
255
|
-
const
|
|
256
|
-
fooList: FooListResource(),
|
|
257
|
+
const aui = useAssistantClient({
|
|
258
|
+
fooList: FooListResource({ initialValues: true }),
|
|
257
259
|
});
|
|
258
260
|
|
|
259
261
|
return (
|
|
260
|
-
<AssistantProvider client={
|
|
262
|
+
<AssistantProvider client={aui}>
|
|
261
263
|
<div className="space-y-6">
|
|
262
264
|
<div className="rounded-lg border border-gray-200 bg-white p-4 shadow-sm dark:border-gray-700 dark:bg-gray-800">
|
|
263
265
|
<div className="flex items-center justify-between">
|
|
@@ -284,47 +286,48 @@ export const ExampleApp = () => {
|
|
|
284
286
|
## lib/store/foo-scope.ts
|
|
285
287
|
|
|
286
288
|
```typescript
|
|
287
|
-
|
|
289
|
+
type FooState = { id: string; bar: string };
|
|
290
|
+
type FooMethods = {
|
|
291
|
+
getState: () => FooState;
|
|
292
|
+
updateBar: (newBar: string) => void;
|
|
293
|
+
remove: () => void;
|
|
294
|
+
};
|
|
295
|
+
type FooMeta = {
|
|
296
|
+
source: "fooList";
|
|
297
|
+
query: { index: number } | { key: string };
|
|
298
|
+
};
|
|
299
|
+
type FooEvents = {
|
|
300
|
+
"foo.updated": { id: string; newValue: string };
|
|
301
|
+
"foo.removed": { id: string };
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
type FooListState = { foos: FooState[] };
|
|
305
|
+
type FooListMethods = {
|
|
306
|
+
getState: () => FooListState;
|
|
307
|
+
foo: (lookup: FooMeta["query"]) => FooMethods;
|
|
308
|
+
addFoo: () => void;
|
|
309
|
+
};
|
|
310
|
+
type FooListEvents = {
|
|
311
|
+
"fooList.added": { id: string };
|
|
312
|
+
};
|
|
288
313
|
|
|
289
314
|
declare module "@assistant-ui/store" {
|
|
290
|
-
interface
|
|
315
|
+
interface ClientRegistry {
|
|
291
316
|
foo: {
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
};
|
|
297
|
-
meta: { source: "fooList"; query: { index: number } | { id: string } };
|
|
298
|
-
events: {
|
|
299
|
-
"foo.updated": { id: string; newValue: string };
|
|
300
|
-
"foo.removed": { id: string };
|
|
301
|
-
};
|
|
317
|
+
state: FooState;
|
|
318
|
+
methods: FooMethods;
|
|
319
|
+
meta: FooMeta;
|
|
320
|
+
events: FooEvents;
|
|
302
321
|
};
|
|
303
322
|
fooList: {
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
lookup: { index: number } | { id: string },
|
|
308
|
-
) => AssistantScopeRegistry["foo"]["value"];
|
|
309
|
-
addFoo: (id?: string) => void;
|
|
310
|
-
};
|
|
311
|
-
meta: { source: "root"; query: Record<string, never> };
|
|
312
|
-
events: {
|
|
313
|
-
"fooList.added": { id: string };
|
|
314
|
-
};
|
|
323
|
+
state: FooListState;
|
|
324
|
+
methods: FooListMethods;
|
|
325
|
+
events: FooListEvents;
|
|
315
326
|
};
|
|
316
327
|
}
|
|
317
328
|
}
|
|
318
329
|
|
|
319
|
-
|
|
320
|
-
name: "fooList",
|
|
321
|
-
defaultInitialize: { error: "FooList is not configured" },
|
|
322
|
-
});
|
|
323
|
-
|
|
324
|
-
registerAssistantScope({
|
|
325
|
-
name: "foo",
|
|
326
|
-
defaultInitialize: { error: "Foo is not configured" },
|
|
327
|
-
});
|
|
330
|
+
export default {};
|
|
328
331
|
|
|
329
332
|
```
|
|
330
333
|
|
|
@@ -333,92 +336,88 @@ registerAssistantScope({
|
|
|
333
336
|
```tsx
|
|
334
337
|
"use client";
|
|
335
338
|
|
|
336
|
-
// Import scope types first to ensure module augmentation is available
|
|
337
339
|
import "./foo-scope";
|
|
338
340
|
|
|
339
341
|
import React from "react";
|
|
340
|
-
import { resource, tapState } from "@assistant-ui/tap";
|
|
342
|
+
import { resource, tapMemo, tapState } from "@assistant-ui/tap";
|
|
341
343
|
import {
|
|
342
344
|
useAssistantClient,
|
|
343
345
|
AssistantProvider,
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
DerivedScope,
|
|
346
|
+
tapClientList,
|
|
347
|
+
Derived,
|
|
347
348
|
useAssistantState,
|
|
348
|
-
|
|
349
|
+
tapAssistantEmit,
|
|
350
|
+
type ClientOutput,
|
|
349
351
|
} from "@assistant-ui/store";
|
|
350
352
|
|
|
353
|
+
type FooData = { id: string; bar: string };
|
|
354
|
+
|
|
351
355
|
export const FooItemResource = resource(
|
|
352
356
|
({
|
|
353
|
-
|
|
357
|
+
getInitialData,
|
|
354
358
|
remove,
|
|
355
|
-
}: {
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
const { events } = tapStoreContext();
|
|
360
|
-
|
|
361
|
-
const [state, setState] = tapState<{ id: string; bar: string }>({
|
|
362
|
-
id,
|
|
363
|
-
bar: initialBar,
|
|
364
|
-
});
|
|
359
|
+
}: tapClientList.ResourceProps<FooData>): ClientOutput<"foo"> => {
|
|
360
|
+
const emit = tapAssistantEmit();
|
|
361
|
+
|
|
362
|
+
const [state, setState] = tapState<FooData>(getInitialData);
|
|
365
363
|
|
|
366
364
|
const updateBar = (newBar: string) => {
|
|
367
365
|
setState({ ...state, bar: newBar });
|
|
368
|
-
|
|
366
|
+
emit("foo.updated", { id: state.id, newValue: newBar });
|
|
369
367
|
};
|
|
370
368
|
|
|
371
369
|
const handleRemove = () => {
|
|
372
|
-
|
|
370
|
+
emit("foo.removed", { id: state.id });
|
|
373
371
|
remove();
|
|
374
372
|
};
|
|
375
373
|
|
|
376
|
-
return
|
|
377
|
-
|
|
374
|
+
return {
|
|
375
|
+
state,
|
|
376
|
+
methods: {
|
|
378
377
|
getState: () => state,
|
|
379
378
|
updateBar,
|
|
380
379
|
remove: handleRemove,
|
|
381
380
|
},
|
|
382
|
-
|
|
383
|
-
);
|
|
381
|
+
};
|
|
384
382
|
},
|
|
385
383
|
);
|
|
386
384
|
|
|
387
|
-
/**
|
|
388
|
-
* FooList resource implementation
|
|
389
|
-
* Manages a list of foos using tapStoreList
|
|
390
|
-
*/
|
|
391
385
|
let counter = 3;
|
|
392
|
-
export const FooListResource = resource(
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
386
|
+
export const FooListResource = resource(
|
|
387
|
+
({ initialValues }: { initialValues: boolean }): ClientOutput<"fooList"> => {
|
|
388
|
+
const emit = tapAssistantEmit();
|
|
389
|
+
|
|
390
|
+
const foos = tapClientList({
|
|
391
|
+
initialValues: initialValues
|
|
392
|
+
? [
|
|
393
|
+
{ id: "foo-1", bar: "First Foo" },
|
|
394
|
+
{ id: "foo-2", bar: "Second Foo" },
|
|
395
|
+
{ id: "foo-3", bar: "Third Foo" },
|
|
396
|
+
]
|
|
397
|
+
: [],
|
|
398
|
+
getKey: (foo) => foo.id,
|
|
399
|
+
resource: FooItemResource,
|
|
400
|
+
});
|
|
405
401
|
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
402
|
+
const addFoo = () => {
|
|
403
|
+
const id = `foo-${++counter}`;
|
|
404
|
+
foos.add({ id: id, bar: `New Foo` });
|
|
405
|
+
emit("fooList.added", { id: id });
|
|
406
|
+
};
|
|
411
407
|
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
408
|
+
const state = tapMemo(() => ({ foos: foos.state }), [foos.state]);
|
|
409
|
+
|
|
410
|
+
return {
|
|
411
|
+
state,
|
|
412
|
+
methods: {
|
|
413
|
+
getState: () => state,
|
|
414
|
+
foo: foos.get,
|
|
415
|
+
addFoo,
|
|
416
|
+
},
|
|
417
|
+
};
|
|
418
|
+
},
|
|
419
|
+
);
|
|
418
420
|
|
|
419
|
-
/**
|
|
420
|
-
* FooProvider - Provides foo scope for a specific index
|
|
421
|
-
*/
|
|
422
421
|
export const FooProvider = ({
|
|
423
422
|
index,
|
|
424
423
|
children,
|
|
@@ -426,11 +425,10 @@ export const FooProvider = ({
|
|
|
426
425
|
index: number;
|
|
427
426
|
children: React.ReactNode;
|
|
428
427
|
}) => {
|
|
429
|
-
// Create a derived client with the foo scope at the specified index
|
|
430
428
|
const aui = useAssistantClient({
|
|
431
|
-
foo:
|
|
429
|
+
foo: Derived({
|
|
432
430
|
source: "fooList",
|
|
433
|
-
query: { index },
|
|
431
|
+
query: { index: index },
|
|
434
432
|
get: (aui) => aui.fooList().foo({ index }),
|
|
435
433
|
}),
|
|
436
434
|
});
|
|
@@ -438,10 +436,6 @@ export const FooProvider = ({
|
|
|
438
436
|
return <AssistantProvider client={aui}>{children}</AssistantProvider>;
|
|
439
437
|
};
|
|
440
438
|
|
|
441
|
-
/**
|
|
442
|
-
* FooList component - minimal mapping component
|
|
443
|
-
* Maps over the list and renders each item in a FooProvider
|
|
444
|
-
*/
|
|
445
439
|
export const FooList = ({
|
|
446
440
|
components,
|
|
447
441
|
}: {
|
|
@@ -479,9 +473,10 @@ export default nextConfig;
|
|
|
479
473
|
|
|
480
474
|
```json
|
|
481
475
|
{
|
|
482
|
-
"name": "store
|
|
483
|
-
"version": "0.
|
|
476
|
+
"name": "with-store",
|
|
477
|
+
"version": "0.0.0",
|
|
484
478
|
"private": true,
|
|
479
|
+
"type": "module",
|
|
485
480
|
"scripts": {
|
|
486
481
|
"dev": "next dev",
|
|
487
482
|
"build": "next build",
|
|
@@ -490,18 +485,20 @@ export default nextConfig;
|
|
|
490
485
|
"dependencies": {
|
|
491
486
|
"@assistant-ui/store": "workspace:*",
|
|
492
487
|
"@assistant-ui/tap": "workspace:*",
|
|
493
|
-
"next": "16.0
|
|
494
|
-
"react": "19.2.
|
|
495
|
-
"react-dom": "19.2.
|
|
488
|
+
"next": "16.1.0",
|
|
489
|
+
"react": "19.2.3",
|
|
490
|
+
"react-dom": "19.2.3"
|
|
496
491
|
},
|
|
497
492
|
"devDependencies": {
|
|
498
493
|
"@assistant-ui/x-buildutils": "workspace:*",
|
|
499
|
-
"@tailwindcss/postcss": "^4",
|
|
500
|
-
"@types/node": "^
|
|
501
|
-
"@types/react": "19.2.7",
|
|
502
|
-
"@types/react-dom": "19.2.3",
|
|
503
|
-
"
|
|
504
|
-
"
|
|
494
|
+
"@tailwindcss/postcss": "^4.1.18",
|
|
495
|
+
"@types/node": "^25.0.3",
|
|
496
|
+
"@types/react": "^19.2.7",
|
|
497
|
+
"@types/react-dom": "^19.2.3",
|
|
498
|
+
"postcss": "^8.5.6",
|
|
499
|
+
"tailwindcss": "^4.1.18",
|
|
500
|
+
"tw-animate-css": "^1.4.0",
|
|
501
|
+
"typescript": "^5.9.3"
|
|
505
502
|
}
|
|
506
503
|
}
|
|
507
504
|
|
|
@@ -516,9 +513,10 @@ This is a Next.js application demonstrating the `@assistant-ui/store` package.
|
|
|
516
513
|
|
|
517
514
|
## Features Demonstrated
|
|
518
515
|
|
|
519
|
-
- **
|
|
520
|
-
- **
|
|
521
|
-
- **
|
|
516
|
+
- **Client Registry**: Module augmentation for type-safe client definitions
|
|
517
|
+
- **tapClientList**: Managing lists with index and key lookup
|
|
518
|
+
- **tapAssistantEmit**: Emitting and subscribing to scoped events
|
|
519
|
+
- **Derived**: Creating derived client scopes from parent resources
|
|
522
520
|
- **Provider Pattern**: Scoped access to list items via FooProvider
|
|
523
521
|
- **Component Composition**: Render props pattern with components prop
|
|
524
522
|
|
|
@@ -537,33 +535,42 @@ Open [http://localhost:3000](http://localhost:3000) to see the example.
|
|
|
537
535
|
|
|
538
536
|
## Project Structure
|
|
539
537
|
|
|
540
|
-
- `lib/store/foo-
|
|
541
|
-
-
|
|
538
|
+
- `lib/store/foo-scope.ts` - Type definitions via module augmentation:
|
|
539
|
+
- Client registry definitions (foo, fooList)
|
|
540
|
+
- State, methods, meta, and events types
|
|
541
|
+
- `lib/store/foo-store.tsx` - Store implementation with:
|
|
542
542
|
- Resource implementations (FooItemResource, FooListResource)
|
|
543
543
|
- Provider component (FooProvider)
|
|
544
|
-
-
|
|
544
|
+
- FooList mapping component
|
|
545
545
|
- `lib/example-app.tsx` - Example app with styled components:
|
|
546
|
-
-
|
|
546
|
+
- Foo component with update/delete actions
|
|
547
|
+
- EventLog component demonstrating event subscriptions
|
|
547
548
|
- ExampleApp with layout and styling
|
|
548
549
|
- `app/page.tsx` - Main page that renders the ExampleApp
|
|
549
550
|
|
|
550
551
|
## Key Concepts
|
|
551
552
|
|
|
552
|
-
###
|
|
553
|
+
### Client Registry
|
|
553
554
|
|
|
554
555
|
```typescript
|
|
555
556
|
declare module "@assistant-ui/store" {
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
557
|
+
interface ClientRegistry {
|
|
558
|
+
foo: {
|
|
559
|
+
state: { id: string; bar: string };
|
|
560
|
+
methods: {
|
|
561
|
+
getState: () => FooState;
|
|
562
|
+
updateBar: (newBar: string) => void;
|
|
563
|
+
remove: () => void;
|
|
564
|
+
};
|
|
565
|
+
meta: {
|
|
563
566
|
source: "fooList";
|
|
564
|
-
query: { index: number } | {
|
|
567
|
+
query: { index: number } | { key: string };
|
|
568
|
+
};
|
|
569
|
+
events: {
|
|
570
|
+
"foo.updated": { id: string; newValue: string };
|
|
571
|
+
"foo.removed": { id: string };
|
|
565
572
|
};
|
|
566
|
-
}
|
|
573
|
+
};
|
|
567
574
|
}
|
|
568
575
|
}
|
|
569
576
|
```
|
|
@@ -571,33 +578,57 @@ declare module "@assistant-ui/store" {
|
|
|
571
578
|
### Resource Implementation
|
|
572
579
|
|
|
573
580
|
```typescript
|
|
574
|
-
const FooListResource = resource(
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
+
const FooListResource = resource(
|
|
582
|
+
({ initialValues }): ClientOutput<"fooList"> => {
|
|
583
|
+
const emit = tapAssistantEmit();
|
|
584
|
+
|
|
585
|
+
const foos = tapClientList({
|
|
586
|
+
initialValues: initialValues ? [/* ... */] : [],
|
|
587
|
+
getKey: (foo) => foo.id,
|
|
588
|
+
resource: FooItemResource,
|
|
589
|
+
});
|
|
581
590
|
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
591
|
+
return {
|
|
592
|
+
state: { foos: foos.state },
|
|
593
|
+
methods: {
|
|
594
|
+
getState: () => state,
|
|
595
|
+
foo: foos.get,
|
|
596
|
+
addFoo: () => { /* ... */ },
|
|
597
|
+
},
|
|
598
|
+
};
|
|
599
|
+
},
|
|
600
|
+
);
|
|
587
601
|
```
|
|
588
602
|
|
|
589
|
-
### Provider Pattern
|
|
603
|
+
### Provider Pattern with Derived
|
|
590
604
|
|
|
591
605
|
```typescript
|
|
592
606
|
const FooProvider = ({ index, children }) => {
|
|
593
|
-
const parentAui = useAssistantClient();
|
|
594
607
|
const aui = useAssistantClient({
|
|
595
|
-
foo:
|
|
608
|
+
foo: Derived({
|
|
609
|
+
source: "fooList",
|
|
610
|
+
query: { index },
|
|
611
|
+
get: (aui) => aui.fooList().foo({ index }),
|
|
612
|
+
}),
|
|
596
613
|
});
|
|
597
|
-
return <
|
|
614
|
+
return <AssistantProvider client={aui}>{children}</AssistantProvider>;
|
|
598
615
|
};
|
|
599
616
|
```
|
|
600
617
|
|
|
618
|
+
### Event Subscriptions
|
|
619
|
+
|
|
620
|
+
```typescript
|
|
621
|
+
// Subscribe to specific events within a scope
|
|
622
|
+
useAssistantEvent("foo.updated", (payload) => {
|
|
623
|
+
console.log(`Updated to: ${payload.newValue}`);
|
|
624
|
+
});
|
|
625
|
+
|
|
626
|
+
// Subscribe to all events using wildcard
|
|
627
|
+
useAssistantEvent("*", (data) => {
|
|
628
|
+
console.log(data.event, data.payload);
|
|
629
|
+
});
|
|
630
|
+
```
|
|
631
|
+
|
|
601
632
|
## Learn More
|
|
602
633
|
|
|
603
634
|
- [@assistant-ui/store Documentation](../store/README.md)
|
|
@@ -609,18 +640,11 @@ const FooProvider = ({ index, children }) => {
|
|
|
609
640
|
|
|
610
641
|
```json
|
|
611
642
|
{
|
|
612
|
-
"extends": "@assistant-ui/x-buildutils/ts/
|
|
643
|
+
"extends": "@assistant-ui/x-buildutils/ts/next",
|
|
613
644
|
"compilerOptions": {
|
|
614
|
-
"paths": {
|
|
615
|
-
"@/*": ["./*"],
|
|
616
|
-
"@assistant-ui/*": ["../../packages/*/src"],
|
|
617
|
-
"@assistant-ui/react/*": ["../../packages/react/src/*"],
|
|
618
|
-
"@assistant-ui/tap/*": ["../../packages/tap/src/*"],
|
|
619
|
-
"assistant-stream": ["../../packages/assistant-stream/src"],
|
|
620
|
-
"assistant-stream/*": ["../../packages/assistant-stream/src/*"]
|
|
621
|
-
}
|
|
645
|
+
"paths": { "@/*": ["./*"] }
|
|
622
646
|
},
|
|
623
|
-
"include": ["
|
|
647
|
+
"include": ["**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
|
|
624
648
|
"exclude": ["node_modules"]
|
|
625
649
|
}
|
|
626
650
|
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
|
|
23
23
|
```json
|
|
24
24
|
{
|
|
25
|
-
"name": "
|
|
25
|
+
"name": "with-tanstack",
|
|
26
|
+
"version": "0.0.0",
|
|
26
27
|
"private": true,
|
|
27
28
|
"type": "module",
|
|
28
29
|
"scripts": {
|
|
@@ -35,29 +36,29 @@
|
|
|
35
36
|
"@assistant-ui/react-markdown": "workspace:*",
|
|
36
37
|
"@radix-ui/react-slot": "^1.2.4",
|
|
37
38
|
"@radix-ui/react-tooltip": "^1.2.8",
|
|
38
|
-
"@tailwindcss/vite": "^4.1.
|
|
39
|
-
"@tanstack/react-router": "^1.
|
|
40
|
-
"@tanstack/react-start": "^1.
|
|
41
|
-
"@tanstack/router-plugin": "^1.139.14",
|
|
39
|
+
"@tailwindcss/vite": "^4.1.18",
|
|
40
|
+
"@tanstack/react-router": "^1.141.8",
|
|
41
|
+
"@tanstack/react-start": "^1.142.1",
|
|
42
42
|
"class-variance-authority": "^0.7.1",
|
|
43
43
|
"clsx": "^2.1.1",
|
|
44
|
-
"lucide-react": "^0.
|
|
45
|
-
"nitro": "
|
|
46
|
-
"openai": "^6.
|
|
47
|
-
"react": "
|
|
48
|
-
"react-dom": "
|
|
44
|
+
"lucide-react": "^0.562.0",
|
|
45
|
+
"nitro": "^3.0.1-alpha.1",
|
|
46
|
+
"openai": "^6.15.0",
|
|
47
|
+
"react": "19.2.3",
|
|
48
|
+
"react-dom": "19.2.3",
|
|
49
49
|
"remark-gfm": "^4.0.1",
|
|
50
50
|
"tailwind-merge": "^3.4.0",
|
|
51
|
-
"tailwindcss": "^4.1.
|
|
52
|
-
"vite-tsconfig-paths": "^
|
|
51
|
+
"tailwindcss": "^4.1.18",
|
|
52
|
+
"vite-tsconfig-paths": "^6.0.3"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@
|
|
55
|
+
"@assistant-ui/x-buildutils": "workspace:*",
|
|
56
|
+
"@types/node": "^25.0.3",
|
|
56
57
|
"@types/react": "^19.2.7",
|
|
57
58
|
"@types/react-dom": "^19.2.3",
|
|
58
|
-
"@vitejs/plugin-react": "^5.1.
|
|
59
|
+
"@vitejs/plugin-react": "^5.1.2",
|
|
59
60
|
"typescript": "^5.9.3",
|
|
60
|
-
"vite": "^7.
|
|
61
|
+
"vite": "^7.3.0"
|
|
61
62
|
}
|
|
62
63
|
}
|
|
63
64
|
|
|
@@ -368,7 +369,7 @@ const ThreadScrollToBottom: FC = () => {
|
|
|
368
369
|
<TooltipIconButton
|
|
369
370
|
tooltip="Scroll to bottom"
|
|
370
371
|
variant="outline"
|
|
371
|
-
className="aui-thread-scroll-to-bottom -top-12
|
|
372
|
+
className="aui-thread-scroll-to-bottom absolute -top-12 z-10 self-center rounded-full p-4 disabled:invisible dark:bg-background dark:hover:bg-accent"
|
|
372
373
|
>
|
|
373
374
|
<ArrowDownIcon />
|
|
374
375
|
</TooltipIconButton>
|
|
@@ -541,7 +542,7 @@ const AssistantActionBar: FC = () => {
|
|
|
541
542
|
hideWhenRunning
|
|
542
543
|
autohide="not-last"
|
|
543
544
|
autohideFloat="single-branch"
|
|
544
|
-
className="aui-assistant-action-bar-root
|
|
545
|
+
className="aui-assistant-action-bar-root col-start-3 row-start-2 -ml-1 flex gap-1 text-muted-foreground data-floating:absolute data-floating:rounded-md data-floating:border data-floating:bg-background data-floating:p-1 data-floating:shadow-sm"
|
|
545
546
|
>
|
|
546
547
|
<ActionBarPrimitive.Copy asChild>
|
|
547
548
|
<TooltipIconButton tooltip="Copy">
|
|
@@ -572,12 +573,12 @@ const UserMessage: FC = () => {
|
|
|
572
573
|
<div className="aui-user-message-content wrap-break-word rounded-3xl bg-muted px-5 py-2.5 text-foreground">
|
|
573
574
|
<MessagePrimitive.Parts />
|
|
574
575
|
</div>
|
|
575
|
-
<div className="aui-user-action-bar-wrapper -translate-x-full -translate-y-1/2
|
|
576
|
+
<div className="aui-user-action-bar-wrapper absolute top-1/2 left-0 -translate-x-full -translate-y-1/2 pr-2">
|
|
576
577
|
<UserActionBar />
|
|
577
578
|
</div>
|
|
578
579
|
</div>
|
|
579
580
|
|
|
580
|
-
<BranchPicker className="aui-user-branch-picker
|
|
581
|
+
<BranchPicker className="aui-user-branch-picker col-span-full col-start-1 row-start-3 -mr-1 justify-end" />
|
|
581
582
|
</MessagePrimitive.Root>
|
|
582
583
|
);
|
|
583
584
|
};
|
|
@@ -632,7 +633,7 @@ const BranchPicker: FC<BranchPickerPrimitive.Root.Props> = ({
|
|
|
632
633
|
<BranchPickerPrimitive.Root
|
|
633
634
|
hideWhenSingleBranch
|
|
634
635
|
className={cn(
|
|
635
|
-
"aui-branch-picker-root -
|
|
636
|
+
"aui-branch-picker-root mr-2 -ml-2 inline-flex items-center text-muted-foreground text-xs",
|
|
636
637
|
className,
|
|
637
638
|
)}
|
|
638
639
|
{...rest}
|
|
@@ -1516,32 +1517,13 @@ export const chatStream = createServerFn({ method: "POST" })
|
|
|
1516
1517
|
|
|
1517
1518
|
```json
|
|
1518
1519
|
{
|
|
1519
|
-
"
|
|
1520
|
+
"extends": "@assistant-ui/x-buildutils/ts/base",
|
|
1520
1521
|
"compilerOptions": {
|
|
1521
|
-
"target": "ES2022",
|
|
1522
|
-
"jsx": "react-jsx",
|
|
1523
|
-
"module": "ESNext",
|
|
1524
|
-
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
|
1525
1522
|
"types": ["vite/client"],
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
"verbatimModuleSyntax": false,
|
|
1531
|
-
"noEmit": true,
|
|
1532
|
-
|
|
1533
|
-
/* Linting */
|
|
1534
|
-
"skipLibCheck": true,
|
|
1535
|
-
"strict": true,
|
|
1536
|
-
"noUnusedLocals": true,
|
|
1537
|
-
"noUnusedParameters": true,
|
|
1538
|
-
"noFallthroughCasesInSwitch": true,
|
|
1539
|
-
"noUncheckedSideEffectImports": true,
|
|
1540
|
-
"baseUrl": ".",
|
|
1541
|
-
"paths": {
|
|
1542
|
-
"@/*": ["./src/*"]
|
|
1543
|
-
}
|
|
1544
|
-
}
|
|
1523
|
+
"paths": { "@/*": ["./src/*"] }
|
|
1524
|
+
},
|
|
1525
|
+
"include": ["**/*.ts", "**/*.tsx"],
|
|
1526
|
+
"exclude": ["node_modules"]
|
|
1545
1527
|
}
|
|
1546
1528
|
|
|
1547
1529
|
```
|
|
@@ -1558,7 +1540,11 @@ import { nitro } from "nitro/vite";
|
|
|
1558
1540
|
|
|
1559
1541
|
const config = defineConfig({
|
|
1560
1542
|
plugins: [
|
|
1561
|
-
nitro(
|
|
1543
|
+
nitro({
|
|
1544
|
+
output: {
|
|
1545
|
+
dir: "dist",
|
|
1546
|
+
},
|
|
1547
|
+
}),
|
|
1562
1548
|
viteTsConfigPaths({
|
|
1563
1549
|
projects: ["./tsconfig.json"],
|
|
1564
1550
|
}),
|