@lota-sdk/ui 0.2.3 → 0.3.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lota-sdk/ui",
3
- "version": "0.2.3",
3
+ "version": "0.3.0",
4
4
  "type": "module",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -25,7 +25,7 @@
25
25
  "registry": "https://registry.npmjs.org/"
26
26
  },
27
27
  "dependencies": {
28
- "@lota-sdk/shared": "0.2.3",
28
+ "@lota-sdk/shared": "0.3.0",
29
29
  "ai": "^6.0.145"
30
30
  },
31
31
  "peerDependencies": {
@@ -6,8 +6,7 @@ export interface ThreadManagementItem<TAgentId extends string = string> {
6
6
  threadId: string
7
7
  title: string
8
8
  status: 'regular' | 'archived'
9
- mode: 'direct' | 'group'
10
- core: boolean
9
+ type: string
11
10
  isMutable: boolean
12
11
  agentId?: TAgentId | null
13
12
  }
@@ -63,11 +62,7 @@ export function findReusableRegularGroupThreadId<TThread extends ThreadManagemen
63
62
  defaultThreadTitle: string,
64
63
  ): string | null {
65
64
  const draft = threads.find(
66
- (thread) =>
67
- thread.mode === 'group' &&
68
- !thread.core &&
69
- thread.status === 'regular' &&
70
- thread.title.trim() === defaultThreadTitle,
65
+ (thread) => thread.type === 'group' && thread.status === 'regular' && thread.title.trim() === defaultThreadTitle,
71
66
  )
72
67
 
73
68
  return draft?.threadId ?? null
@@ -151,7 +146,7 @@ export function useThreadManagement<TThread extends ThreadManagementItem<TAgentI
151
146
  ? (() => {
152
147
  const agentId = threadId.slice(placeholderThreadPrefix.length) as TAgentId
153
148
  const directThread = allThreadsRef.current.find(
154
- (thread) => thread.mode === 'direct' && thread.agentId === agentId,
149
+ (thread) => thread.type === 'default' && thread.agentId === agentId,
155
150
  )
156
151
  return directThread?.threadId
157
152
  })()
@@ -160,7 +155,7 @@ export function useThreadManagement<TThread extends ThreadManagementItem<TAgentI
160
155
  if (!resolvedThreadId) return
161
156
 
162
157
  const target = allThreadsRef.current.find((thread) => thread.threadId === resolvedThreadId)
163
- const nextAgentId = target?.mode === 'direct' && target.agentId ? target.agentId : null
158
+ const nextAgentId = target?.type === 'default' && target.agentId ? target.agentId : null
164
159
  setCurrentThreadId(resolvedThreadId)
165
160
  setSelectedAgentId(nextAgentId)
166
161
  },
@@ -243,10 +238,10 @@ export function useThreadManagement<TThread extends ThreadManagementItem<TAgentI
243
238
  const preferredThread =
244
239
  primaryDirectAgentId === undefined
245
240
  ? threads[0]
246
- : (threads.find((thread) => thread.mode === 'direct' && thread.agentId === primaryDirectAgentId) ??
241
+ : (threads.find((thread) => thread.type === 'default' && thread.agentId === primaryDirectAgentId) ??
247
242
  threads[0])
248
243
  setCurrentThreadId(preferredThread.threadId)
249
- setSelectedAgentId(preferredThread.mode === 'direct' && preferredThread.agentId ? preferredThread.agentId : null)
244
+ setSelectedAgentId(preferredThread.type === 'default' && preferredThread.agentId ? preferredThread.agentId : null)
250
245
  return
251
246
  }
252
247
 
@@ -276,7 +271,7 @@ export function useThreadManagement<TThread extends ThreadManagementItem<TAgentI
276
271
  if (!currentThreadId?.startsWith(placeholderThreadPrefix)) return
277
272
 
278
273
  const agentId = currentThreadId.slice(placeholderThreadPrefix.length) as TAgentId
279
- const directThread = allThreads.find((thread) => thread.mode === 'direct' && thread.agentId === agentId)
274
+ const directThread = allThreads.find((thread) => thread.type === 'default' && thread.agentId === agentId)
280
275
  if (!directThread) return
281
276
 
282
277
  setCurrentThreadId(directThread.threadId)
@@ -286,7 +281,7 @@ export function useThreadManagement<TThread extends ThreadManagementItem<TAgentI
286
281
  useEffect(() => {
287
282
  if (currentThreadId !== null || selectedAgentId === null) return
288
283
 
289
- const directThread = allThreads.find((thread) => thread.mode === 'direct' && thread.agentId === selectedAgentId)
284
+ const directThread = allThreads.find((thread) => thread.type === 'default' && thread.agentId === selectedAgentId)
290
285
  if (!directThread) return
291
286
 
292
287
  setCurrentThreadId(directThread.threadId)
@@ -303,7 +298,7 @@ export function useThreadManagement<TThread extends ThreadManagementItem<TAgentI
303
298
  const activeThread = allThreads.find((thread) => thread.threadId === currentThreadId)
304
299
  if (!activeThread) return
305
300
 
306
- const expectedAgentId = activeThread.mode === 'direct' && activeThread.agentId ? activeThread.agentId : null
301
+ const expectedAgentId = activeThread.type === 'default' && activeThread.agentId ? activeThread.agentId : null
307
302
  if (selectedAgentId !== expectedAgentId) {
308
303
  setSelectedAgentId(expectedAgentId)
309
304
  }
@@ -1,4 +1,4 @@
1
- import type { SerializablePlanNode } from '@lota-sdk/shared'
1
+ import type { ExecutionPlanNodeSummary } from '@lota-sdk/shared'
2
2
  import { getLatestExecutionPlanResult } from '@lota-sdk/shared'
3
3
 
4
4
  export { getLatestExecutionPlanResult }
@@ -33,14 +33,13 @@ export function getExecutionPlanStatusLabel(status: string | null | undefined):
33
33
  }
34
34
 
35
35
  export function getExecutionPlanOwnerLabel(
36
- node: SerializablePlanNode,
36
+ node: ExecutionPlanNodeSummary,
37
37
  displayNameByOwnerRef: Record<string, string> = {},
38
38
  ): string {
39
- if (node.owner.executorType === 'agent' && node.owner.ref in displayNameByOwnerRef) {
40
- return displayNameByOwnerRef[node.owner.ref]
39
+ if (node.ownerRef in displayNameByOwnerRef) {
40
+ return displayNameByOwnerRef[node.ownerRef]
41
41
  }
42
- if (node.owner.executorType === 'user') return 'User'
43
- return node.owner.ref
42
+ return node.ownerRef
44
43
  }
45
44
 
46
45
  export function buildExecutionPlanToolViewModel(params: { input: unknown; isRunning: boolean; output: unknown }) {
@@ -54,12 +53,11 @@ export function buildExecutionPlanToolViewModel(params: { input: unknown; isRunn
54
53
  ? params.input.title.trim()
55
54
  : ''
56
55
  const title = plan && plan.title.trim() ? plan.title.trim() : inputTitle || 'Execution run'
57
- const completedCount = plan ? plan.progress.completed + plan.progress.partial : 0
56
+ const completedCount = plan ? plan.progress.completed : 0
58
57
 
59
58
  return {
60
59
  actionLabel: getExecutionPlanActionLabel(result?.action ?? 'none', params.isRunning),
61
60
  hasPlan: plan !== null,
62
- latestEvent: plan ? plan.recentEvents.at(-1)?.message.trim() : undefined,
63
61
  plan,
64
62
  progressSummary: plan ? `${completedCount}/${plan.progress.total} complete` : 'No active execution run',
65
63
  result,