@tanstack/ai-octane 0.3.1 → 0.5.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/index.ts +35 -0
- package/src/types.ts +10 -0
- package/src/use-chat.tsrx +26 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/ai-octane",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Octane bindings for TanStack AI streaming chat, structured outputs, and media generation.",
|
|
5
5
|
"author": "Dominic Gannaway",
|
|
6
6
|
"license": "MIT",
|
|
@@ -39,7 +39,8 @@
|
|
|
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",
|
|
@@ -47,11 +48,11 @@
|
|
|
47
48
|
],
|
|
48
49
|
"//lint": "The .tsrx.d.ts companions are generated declaration emits of the .tsrx implementations, so they are not hand-formatted and are excluded from lint rather than edited in place (a regeneration would undo any fix).",
|
|
49
50
|
"dependencies": {
|
|
50
|
-
"@tanstack/ai-client": "0.
|
|
51
|
+
"@tanstack/ai-client": "0.32.1"
|
|
51
52
|
},
|
|
52
53
|
"peerDependencies": {
|
|
53
54
|
"octane": "^0.1.17",
|
|
54
|
-
"@tanstack/ai": "^0.
|
|
55
|
+
"@tanstack/ai": "^0.55.0"
|
|
55
56
|
},
|
|
56
57
|
"devDependencies": {
|
|
57
58
|
"@octanejs/testing-library": "0.1.14",
|
|
@@ -62,7 +63,7 @@
|
|
|
62
63
|
"octane": "0.1.17",
|
|
63
64
|
"vite": "^8.2.1",
|
|
64
65
|
"zod": "^4.2.0",
|
|
65
|
-
"@tanstack/ai": "0.
|
|
66
|
+
"@tanstack/ai": "0.55.0"
|
|
66
67
|
},
|
|
67
68
|
"scripts": {
|
|
68
69
|
"lint:fix": "oxlint src --type-aware --ignore-pattern '**/*.tsrx.d.ts' --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/index.ts
CHANGED
|
@@ -66,6 +66,41 @@ export type {
|
|
|
66
66
|
|
|
67
67
|
// Re-export from ai-client for convenience (mirror upstream index.ts)
|
|
68
68
|
export {
|
|
69
|
+
AudioRecorder,
|
|
70
|
+
ChatClient,
|
|
71
|
+
InterruptManager,
|
|
72
|
+
RealtimeClient,
|
|
73
|
+
GenerationClient,
|
|
74
|
+
VideoGenerationClient,
|
|
75
|
+
GENERATION_EVENTS,
|
|
76
|
+
reconstructImageResult,
|
|
77
|
+
reconstructAudioResult,
|
|
78
|
+
reconstructSpeechResult,
|
|
79
|
+
reconstructTranscriptionResult,
|
|
80
|
+
reconstructSummarizeResult,
|
|
81
|
+
UnsupportedResponseStreamError,
|
|
82
|
+
createAIDevtoolsGenerationPreview,
|
|
83
|
+
StreamTruncatedError,
|
|
84
|
+
DurableStreamIncompleteError,
|
|
85
|
+
StreamReconnectLimitError,
|
|
86
|
+
uiMessageToModelMessages,
|
|
87
|
+
modelMessageToUIMessage,
|
|
88
|
+
modelMessagesToUIMessages,
|
|
89
|
+
convertMessagesToModelMessages,
|
|
90
|
+
normalizeToUIMessage,
|
|
91
|
+
generateMessageId,
|
|
92
|
+
StreamProcessor,
|
|
93
|
+
ImmediateStrategy,
|
|
94
|
+
PunctuationStrategy,
|
|
95
|
+
BatchStrategy,
|
|
96
|
+
WordBoundaryStrategy,
|
|
97
|
+
CompositeStrategy,
|
|
98
|
+
parsePartialJSON,
|
|
99
|
+
PartialJSONParser,
|
|
100
|
+
defaultJSONParser,
|
|
101
|
+
registerWebMCPTools,
|
|
102
|
+
clientTools,
|
|
103
|
+
webSocket,
|
|
69
104
|
fetchServerSentEvents,
|
|
70
105
|
fetchHttpStream,
|
|
71
106
|
xhrServerSentEvents,
|
package/src/types.ts
CHANGED
|
@@ -263,6 +263,16 @@ interface BaseUseChatReturn<
|
|
|
263
263
|
*/
|
|
264
264
|
isLoading: boolean
|
|
265
265
|
|
|
266
|
+
/**
|
|
267
|
+
* True when the last hydrate or older-page response said more messages exist.
|
|
268
|
+
*/
|
|
269
|
+
hasOlderMessages: boolean
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Fetch the next older window and put it in front of the painted messages.
|
|
273
|
+
*/
|
|
274
|
+
loadOlderMessages: () => Promise<void>
|
|
275
|
+
|
|
266
276
|
/**
|
|
267
277
|
* Current error, if any
|
|
268
278
|
*/
|
package/src/use-chat.tsrx
CHANGED
|
@@ -53,6 +53,7 @@ export function useChat<
|
|
|
53
53
|
options.initialMessages || [],
|
|
54
54
|
)
|
|
55
55
|
const [isLoading, setIsLoading] = useState(false)
|
|
56
|
+
const [hasOlderMessages, setHasOlderMessages] = useState(false)
|
|
56
57
|
const [error, setError] = useState<Error | undefined>(undefined)
|
|
57
58
|
const [status, setStatus] = useState<ChatClientState>('ready')
|
|
58
59
|
const [isSubscribed, setIsSubscribed] = useState(false)
|
|
@@ -141,16 +142,25 @@ export function useChat<
|
|
|
141
142
|
...transport,
|
|
142
143
|
initialMessages: messagesToUse,
|
|
143
144
|
...(typeof initialOptions.threadId === 'string' &&
|
|
144
|
-
initialOptions.persistence
|
|
145
|
+
initialOptions.persistence === true
|
|
145
146
|
? {
|
|
146
|
-
persistence:
|
|
147
|
+
persistence: true,
|
|
147
148
|
threadId: initialOptions.threadId,
|
|
149
|
+
...(initialOptions.history !== undefined && {
|
|
150
|
+
history: initialOptions.history,
|
|
151
|
+
}),
|
|
148
152
|
}
|
|
149
|
-
:
|
|
150
|
-
|
|
153
|
+
: typeof initialOptions.threadId === 'string' &&
|
|
154
|
+
initialOptions.persistence
|
|
155
|
+
? {
|
|
156
|
+
persistence: initialOptions.persistence,
|
|
151
157
|
threadId: initialOptions.threadId,
|
|
158
|
+
}
|
|
159
|
+
: {
|
|
160
|
+
...(initialOptions.threadId !== undefined && {
|
|
161
|
+
threadId: initialOptions.threadId,
|
|
162
|
+
}),
|
|
152
163
|
}),
|
|
153
|
-
}),
|
|
154
164
|
...(initialOptions.body !== undefined && { body: initialOptions.body }),
|
|
155
165
|
...(initialOptions.forwardedProps !== undefined && {
|
|
156
166
|
forwardedProps: initialOptions.forwardedProps,
|
|
@@ -206,6 +216,9 @@ export function useChat<
|
|
|
206
216
|
onMessagesChange: (newMessages: Array<UIMessage<TTools>>) => {
|
|
207
217
|
runOrQueueForActiveInstance(() => {
|
|
208
218
|
setMessages(newMessages)
|
|
219
|
+
const currentInstance = getActiveInstance()
|
|
220
|
+
if (!currentInstance) return
|
|
221
|
+
setHasOlderMessages(currentInstance.getHasOlderMessages())
|
|
209
222
|
})
|
|
210
223
|
},
|
|
211
224
|
onLoadingChange: (newIsLoading: boolean) => {
|
|
@@ -300,6 +313,7 @@ export function useChat<
|
|
|
300
313
|
if (clientMessages !== messagesRef.current) {
|
|
301
314
|
setMessages(clientMessages)
|
|
302
315
|
}
|
|
316
|
+
setHasOlderMessages(client.getHasOlderMessages())
|
|
303
317
|
}, [client])
|
|
304
318
|
|
|
305
319
|
// OCTANE DIVERGENCE: upstream captures the initial transport. ChatClient
|
|
@@ -424,6 +438,11 @@ export function useChat<
|
|
|
424
438
|
}
|
|
425
439
|
}, [client, syncResumeState])
|
|
426
440
|
|
|
441
|
+
const loadOlderMessages = useCallback(async () => {
|
|
442
|
+
await client.loadOlderMessages()
|
|
443
|
+
setHasOlderMessages(client.getHasOlderMessages())
|
|
444
|
+
}, [client])
|
|
445
|
+
|
|
427
446
|
const stop = useCallback(() => {
|
|
428
447
|
client.stop()
|
|
429
448
|
}, [client])
|
|
@@ -560,6 +579,8 @@ export function useChat<
|
|
|
560
579
|
reload,
|
|
561
580
|
stop,
|
|
562
581
|
isLoading,
|
|
582
|
+
hasOlderMessages,
|
|
583
|
+
loadOlderMessages,
|
|
563
584
|
error,
|
|
564
585
|
status,
|
|
565
586
|
isSubscribed,
|