@tanstack/ai-remix 0.2.1 → 0.4.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/package.json +6 -5
- package/src/byok.ts +25 -0
- package/src/create-chat.ts +23 -3
- package/src/index.ts +35 -0
- package/src/types.ts +10 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/ai-remix",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.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",
|
|
@@ -39,18 +39,19 @@
|
|
|
39
39
|
"types": "./src/index.ts",
|
|
40
40
|
"exports": {
|
|
41
41
|
".": "./src/index.ts",
|
|
42
|
-
"./ui": "./src/ui.ts"
|
|
42
|
+
"./ui": "./src/ui.ts",
|
|
43
|
+
"./byok": "./src/byok.ts"
|
|
43
44
|
},
|
|
44
45
|
"files": [
|
|
45
46
|
"src",
|
|
46
47
|
"README.md"
|
|
47
48
|
],
|
|
48
49
|
"dependencies": {
|
|
49
|
-
"@tanstack/ai-client": "^0.
|
|
50
|
+
"@tanstack/ai-client": "^0.32.1"
|
|
50
51
|
},
|
|
51
52
|
"peerDependencies": {
|
|
52
53
|
"remix": "^3.0.0-rc.1",
|
|
53
|
-
"@tanstack/ai": "^0.
|
|
54
|
+
"@tanstack/ai": "^0.55.0"
|
|
54
55
|
},
|
|
55
56
|
"devDependencies": {
|
|
56
57
|
"@types/node": "^24.10.1",
|
|
@@ -59,7 +60,7 @@
|
|
|
59
60
|
"remix": "^3.0.0-rc.1",
|
|
60
61
|
"vite": "^8.2.1",
|
|
61
62
|
"vitest": "^4.1.10",
|
|
62
|
-
"@tanstack/ai": "0.
|
|
63
|
+
"@tanstack/ai": "0.55.0"
|
|
63
64
|
},
|
|
64
65
|
"scripts": {
|
|
65
66
|
"lint:fix": "oxlint src --type-aware --fix",
|
package/src/byok.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export {
|
|
2
|
+
ByokClient,
|
|
3
|
+
EMPTY_BYOK_SNAPSHOT,
|
|
4
|
+
decryptKeyring,
|
|
5
|
+
defaultByokStorage,
|
|
6
|
+
defineByok,
|
|
7
|
+
defineByokProvider,
|
|
8
|
+
deriveAesKey,
|
|
9
|
+
encryptKeyring,
|
|
10
|
+
isPasskeyStorageSupported,
|
|
11
|
+
memoryStorage,
|
|
12
|
+
passkeyStorage,
|
|
13
|
+
} from '@tanstack/ai-client/byok'
|
|
14
|
+
export type {
|
|
15
|
+
ByokPrompt,
|
|
16
|
+
ByokProvider,
|
|
17
|
+
ByokProviderInit,
|
|
18
|
+
ByokSnapshot,
|
|
19
|
+
DefineByokOptions,
|
|
20
|
+
KeyPreview,
|
|
21
|
+
KeyStatus,
|
|
22
|
+
Keyring,
|
|
23
|
+
KeyringStorage,
|
|
24
|
+
PasskeyStorageOptions,
|
|
25
|
+
} from '@tanstack/ai-client/byok'
|
package/src/create-chat.ts
CHANGED
|
@@ -83,6 +83,7 @@ export function createChat<
|
|
|
83
83
|
) {
|
|
84
84
|
let messages = options.initialMessages || []
|
|
85
85
|
let isLoading = false
|
|
86
|
+
let hasOlderMessages = false
|
|
86
87
|
let error: Error | undefined
|
|
87
88
|
let status: ChatClientState = 'ready'
|
|
88
89
|
let isSubscribed = false
|
|
@@ -117,12 +118,20 @@ export function createChat<
|
|
|
117
118
|
...(options.initialMessages !== undefined && {
|
|
118
119
|
initialMessages: options.initialMessages,
|
|
119
120
|
}),
|
|
120
|
-
...(options.persistence
|
|
121
|
+
...(options.persistence === true
|
|
121
122
|
? {
|
|
122
|
-
persistence:
|
|
123
|
+
persistence: true,
|
|
123
124
|
threadId,
|
|
125
|
+
...(options.history !== undefined && {
|
|
126
|
+
history: options.history,
|
|
127
|
+
}),
|
|
124
128
|
}
|
|
125
|
-
:
|
|
129
|
+
: options.persistence
|
|
130
|
+
? {
|
|
131
|
+
persistence: options.persistence,
|
|
132
|
+
threadId,
|
|
133
|
+
}
|
|
134
|
+
: { threadId }),
|
|
126
135
|
...(options.initialResumeSnapshot !== undefined && {
|
|
127
136
|
initialResumeSnapshot: options.initialResumeSnapshot,
|
|
128
137
|
}),
|
|
@@ -160,6 +169,7 @@ export function createChat<
|
|
|
160
169
|
}),
|
|
161
170
|
onMessagesChange: (newMessages: Array<UIMessage<TTools>>) => {
|
|
162
171
|
messages = newMessages
|
|
172
|
+
hasOlderMessages = client.getHasOlderMessages()
|
|
163
173
|
commit()
|
|
164
174
|
},
|
|
165
175
|
onLoadingChange: (newIsLoading: boolean) => {
|
|
@@ -264,6 +274,12 @@ export function createChat<
|
|
|
264
274
|
}
|
|
265
275
|
}
|
|
266
276
|
|
|
277
|
+
const loadOlderMessages = async () => {
|
|
278
|
+
await client.loadOlderMessages()
|
|
279
|
+
hasOlderMessages = client.getHasOlderMessages()
|
|
280
|
+
commit()
|
|
281
|
+
}
|
|
282
|
+
|
|
267
283
|
const stop = () => {
|
|
268
284
|
client.stop()
|
|
269
285
|
}
|
|
@@ -359,6 +375,9 @@ export function createChat<
|
|
|
359
375
|
get isLoading() {
|
|
360
376
|
return isLoading
|
|
361
377
|
},
|
|
378
|
+
get hasOlderMessages() {
|
|
379
|
+
return hasOlderMessages
|
|
380
|
+
},
|
|
362
381
|
get error() {
|
|
363
382
|
return error
|
|
364
383
|
},
|
|
@@ -407,6 +426,7 @@ export function createChat<
|
|
|
407
426
|
cancelQueued,
|
|
408
427
|
append,
|
|
409
428
|
reload,
|
|
429
|
+
loadOlderMessages,
|
|
410
430
|
stop,
|
|
411
431
|
setMessages,
|
|
412
432
|
clear,
|
package/src/index.ts
CHANGED
|
@@ -64,6 +64,41 @@ export type { CreateAudioRecorderOptions } from './create-audio-recorder.ts'
|
|
|
64
64
|
// Re-export from ai-client for convenience (mirror octane index.ts).
|
|
65
65
|
// createMcpAppBridge / CreateMcpAppBridgeOptions come from ./create-mcp-app-bridge.
|
|
66
66
|
export {
|
|
67
|
+
AudioRecorder,
|
|
68
|
+
ChatClient,
|
|
69
|
+
InterruptManager,
|
|
70
|
+
RealtimeClient,
|
|
71
|
+
GenerationClient,
|
|
72
|
+
VideoGenerationClient,
|
|
73
|
+
GENERATION_EVENTS,
|
|
74
|
+
reconstructImageResult,
|
|
75
|
+
reconstructAudioResult,
|
|
76
|
+
reconstructSpeechResult,
|
|
77
|
+
reconstructTranscriptionResult,
|
|
78
|
+
reconstructSummarizeResult,
|
|
79
|
+
UnsupportedResponseStreamError,
|
|
80
|
+
createAIDevtoolsGenerationPreview,
|
|
81
|
+
StreamTruncatedError,
|
|
82
|
+
DurableStreamIncompleteError,
|
|
83
|
+
StreamReconnectLimitError,
|
|
84
|
+
uiMessageToModelMessages,
|
|
85
|
+
modelMessageToUIMessage,
|
|
86
|
+
modelMessagesToUIMessages,
|
|
87
|
+
convertMessagesToModelMessages,
|
|
88
|
+
normalizeToUIMessage,
|
|
89
|
+
generateMessageId,
|
|
90
|
+
StreamProcessor,
|
|
91
|
+
ImmediateStrategy,
|
|
92
|
+
PunctuationStrategy,
|
|
93
|
+
BatchStrategy,
|
|
94
|
+
WordBoundaryStrategy,
|
|
95
|
+
CompositeStrategy,
|
|
96
|
+
parsePartialJSON,
|
|
97
|
+
PartialJSONParser,
|
|
98
|
+
defaultJSONParser,
|
|
99
|
+
registerWebMCPTools,
|
|
100
|
+
clientTools,
|
|
101
|
+
webSocket,
|
|
67
102
|
fetchServerSentEvents,
|
|
68
103
|
fetchHttpStream,
|
|
69
104
|
xhrServerSentEvents,
|
package/src/types.ts
CHANGED
|
@@ -270,6 +270,16 @@ interface BaseCreateChatReturn<
|
|
|
270
270
|
*/
|
|
271
271
|
isLoading: boolean
|
|
272
272
|
|
|
273
|
+
/**
|
|
274
|
+
* True when the last hydrate or older-page response said more messages exist.
|
|
275
|
+
*/
|
|
276
|
+
hasOlderMessages: boolean
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Fetch the next older window and put it in front of the painted messages.
|
|
280
|
+
*/
|
|
281
|
+
loadOlderMessages: () => Promise<void>
|
|
282
|
+
|
|
273
283
|
/**
|
|
274
284
|
* Current error, if any
|
|
275
285
|
*/
|