@lota-sdk/ui 0.1.15 → 0.1.17
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lota-sdk/ui",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.17",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
17
|
"scripts": {
|
|
18
|
-
"lint": "
|
|
18
|
+
"lint": "bunx oxlint --fix -c ../oxlint.config.ts src",
|
|
19
19
|
"format": "bunx oxfmt src",
|
|
20
20
|
"typecheck": "bunx tsgo --noEmit",
|
|
21
21
|
"test:unit": "bun test ../tests/unit/ui"
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"registry": "https://registry.npmjs.org/"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@lota-sdk/shared": "0.1.
|
|
29
|
-
"ai": "^6.0.
|
|
28
|
+
"@lota-sdk/shared": "0.1.17",
|
|
29
|
+
"ai": "^6.0.137"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"@ai-sdk/react": "^3.0.118",
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"react": "^19.2.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@ai-sdk/react": "^3.0.
|
|
38
|
-
"@tanstack/react-query": "^5.
|
|
37
|
+
"@ai-sdk/react": "^3.0.139",
|
|
38
|
+
"@tanstack/react-query": "^5.95.2",
|
|
39
39
|
"@types/react": "^19.2.14",
|
|
40
40
|
"react": "^19.2.4"
|
|
41
41
|
}
|
package/src/chat/attachments.ts
CHANGED
|
@@ -63,7 +63,7 @@ export async function uploadComposerFiles(params: {
|
|
|
63
63
|
throw new Error('Total attachment size exceeds allowed limit.')
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
return
|
|
66
|
+
return Promise.all(
|
|
67
67
|
uploads.map(async (file) => {
|
|
68
68
|
const response = await params.uploadFile(file)
|
|
69
69
|
return {
|
|
@@ -74,7 +74,7 @@ export function useSessionMessages<TMessage extends { id: string; metadata?: { c
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
const response = pageParam ? await fetchOlderPage(sessionId, pageParam) : await fetchLatestPage(sessionId)
|
|
77
|
-
return
|
|
77
|
+
return normalizePage({ response, validateMessages })
|
|
78
78
|
},
|
|
79
79
|
getNextPageParam: (lastPage) => (lastPage.hasMore ? lastPage.prevCursor : undefined),
|
|
80
80
|
initialPageParam: undefined as string | undefined,
|
|
@@ -83,6 +83,8 @@ export function useThreadChat<UI_MESSAGE extends UIMessage>({
|
|
|
83
83
|
messages: initialMessages,
|
|
84
84
|
messageMetadataSchema,
|
|
85
85
|
dataPartSchemas,
|
|
86
|
+
// TODO: Replace with stable `throttle` once AI SDK promotes it from experimental.
|
|
87
|
+
// Tracked at: https://github.com/vercel/ai/issues — currently still `experimental_throttle` in @ai-sdk/react v3.x.
|
|
86
88
|
experimental_throttle: experimentalThrottle,
|
|
87
89
|
sendAutomaticallyWhen,
|
|
88
90
|
onFinish: () => {
|
|
@@ -103,10 +105,10 @@ export function useThreadChat<UI_MESSAGE extends UIMessage>({
|
|
|
103
105
|
// has no StrictMode guard, causing two concurrent GET streams.
|
|
104
106
|
const resumedForChatRef = useRef<string | null>(null)
|
|
105
107
|
useEffect(() => {
|
|
106
|
-
if (!resume || resumedForChatRef.current === chatId) return
|
|
108
|
+
if (!resume || status !== 'ready' || resumedForChatRef.current === chatId) return
|
|
107
109
|
resumedForChatRef.current = chatId
|
|
108
110
|
void resumeStream()
|
|
109
|
-
}, [resume, chatId, resumeStream])
|
|
111
|
+
}, [resume, status, chatId, resumeStream])
|
|
110
112
|
|
|
111
113
|
const stop = useCallback(async () => {
|
|
112
114
|
const stopRequest = threadId && stopRemoteRun ? stopRemoteRun(threadId) : Promise.resolve(null)
|
|
@@ -1,23 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SerializablePlanNode } from '@lota-sdk/shared'
|
|
2
|
+
import { getLatestExecutionPlanResult } from '@lota-sdk/shared'
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
return value !== null && value !== undefined && typeof value === 'object' && 'hasPlan' in value
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export function getLatestExecutionPlanResult(output: unknown): ExecutionPlanToolResultData | null {
|
|
8
|
-
if (isExecutionPlanResult(output)) {
|
|
9
|
-
return output
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
if (Array.isArray(output)) {
|
|
13
|
-
for (let index = output.length - 1; index >= 0; index -= 1) {
|
|
14
|
-
const candidate = getLatestExecutionPlanResult(output[index])
|
|
15
|
-
if (candidate) return candidate
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
return null
|
|
20
|
-
}
|
|
4
|
+
export { getLatestExecutionPlanResult }
|
|
21
5
|
|
|
22
6
|
export function getExecutionPlanActionLabel(action: string, isRunning: boolean): string {
|
|
23
7
|
if (isRunning) return 'Updating execution run'
|