@lota-sdk/ui 0.1.14 → 0.1.16
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 +5 -5
- package/src/chat/attachments.ts +1 -1
- package/src/runtime/active-thread-helpers.ts +0 -18
- package/src/runtime/use-session-messages.ts +1 -1
- package/src/runtime/use-thread-chat.ts +2 -0
- package/src/runtime/use-thread-management.ts +4 -2
- package/src/tools/execution-plan.ts +3 -15
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lota-sdk/ui",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.16",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -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.16",
|
|
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 {
|
|
@@ -19,24 +19,6 @@ export function getLatestAssistantMessage<TMessage extends UIMessage>(messages:
|
|
|
19
19
|
return null
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
export function readLatestDataPart<TData = unknown, TMessage extends UIMessage = UIMessage>(
|
|
23
|
-
messages: TMessage[],
|
|
24
|
-
dataPartType: `data-${string}`,
|
|
25
|
-
): TData | null {
|
|
26
|
-
for (let messageIndex = messages.length - 1; messageIndex >= 0; messageIndex -= 1) {
|
|
27
|
-
const message = messages[messageIndex]
|
|
28
|
-
if (message.role !== 'assistant') continue
|
|
29
|
-
|
|
30
|
-
for (let partIndex = message.parts.length - 1; partIndex >= 0; partIndex -= 1) {
|
|
31
|
-
const part = message.parts[partIndex]
|
|
32
|
-
if (part.type !== dataPartType || !('data' in part)) continue
|
|
33
|
-
return part.data as TData
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return null
|
|
38
|
-
}
|
|
39
|
-
|
|
40
22
|
export function readLatestToolOutput<TOutput = unknown, TMessage extends UIMessage = UIMessage>(
|
|
41
23
|
messages: TMessage[],
|
|
42
24
|
toolName: string,
|
|
@@ -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: () => {
|
|
@@ -24,7 +24,7 @@ export interface UseThreadManagementOptions<TThread extends ThreadManagementItem
|
|
|
24
24
|
isRefetchingThreads: boolean
|
|
25
25
|
hasMoreThreads: boolean
|
|
26
26
|
isFetchingNextThreadsPage: boolean
|
|
27
|
-
fetchNextThreadsPageRaw: () => Promise<
|
|
27
|
+
fetchNextThreadsPageRaw: () => Promise<void>
|
|
28
28
|
createThread: () => Promise<{ id: string }>
|
|
29
29
|
renameThread: (params: { threadId: string; title: string }) => Promise<unknown>
|
|
30
30
|
archiveThread: (threadId: string) => Promise<unknown>
|
|
@@ -255,7 +255,9 @@ export function useThreadManagement<TThread extends ThreadManagementItem<TAgentI
|
|
|
255
255
|
isCreatingThreadRef.current = true
|
|
256
256
|
|
|
257
257
|
handleCreateNewThread()
|
|
258
|
-
.catch(() => {
|
|
258
|
+
.catch(() => {
|
|
259
|
+
// Error already forwarded to notifyBackgroundError in handleCreateNewThread
|
|
260
|
+
})
|
|
259
261
|
.finally(() => {
|
|
260
262
|
isCreatingThreadRef.current = false
|
|
261
263
|
})
|
|
@@ -1,19 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SerializablePlanNode } from '@lota-sdk/shared'
|
|
2
|
+
import { getLatestExecutionPlanResult } from '@lota-sdk/shared'
|
|
2
3
|
|
|
3
|
-
export
|
|
4
|
-
if (output && typeof output === 'object' && 'hasPlan' in output) {
|
|
5
|
-
return output as ExecutionPlanToolResultData
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
if (Array.isArray(output)) {
|
|
9
|
-
for (let index = output.length - 1; index >= 0; index -= 1) {
|
|
10
|
-
const candidate = getLatestExecutionPlanResult(output[index])
|
|
11
|
-
if (candidate) return candidate
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
return null
|
|
16
|
-
}
|
|
4
|
+
export { getLatestExecutionPlanResult }
|
|
17
5
|
|
|
18
6
|
export function getExecutionPlanActionLabel(action: string, isRunning: boolean): string {
|
|
19
7
|
if (isRunning) return 'Updating execution run'
|