lemma-sdk 0.2.35 → 0.2.37
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/README.md +126 -43
- package/dist/browser/lemma-client.js +456 -169
- package/dist/client.d.ts +1 -2
- package/dist/client.js +1 -3
- package/dist/index.d.ts +1 -1
- package/dist/namespaces/agents.js +1 -1
- package/dist/namespaces/conversations.d.ts +73 -0
- package/dist/namespaces/conversations.js +174 -0
- package/dist/namespaces/files.d.ts +24 -6
- package/dist/namespaces/files.js +25 -12
- package/dist/namespaces/integrations.d.ts +10 -2
- package/dist/namespaces/integrations.js +17 -2
- package/dist/namespaces/pod-surfaces.d.ts +1 -1
- package/dist/namespaces/pod-surfaces.js +6 -6
- package/dist/namespaces/tasks.d.ts +1 -5
- package/dist/namespaces/tasks.js +54 -12
- package/dist/openapi_client/index.d.ts +27 -34
- package/dist/openapi_client/index.js +9 -12
- package/dist/openapi_client/models/AdminConsentInfoResponse.d.ts +2 -2
- package/dist/openapi_client/models/AgentListResponse.d.ts +2 -4
- package/dist/openapi_client/models/AgentMessageResponse.d.ts +0 -3
- package/dist/openapi_client/models/{AvailableModels.d.ts → AgentModelName.d.ts} +4 -1
- package/dist/openapi_client/models/AgentModelName.js +18 -0
- package/dist/openapi_client/models/AgentResponse.d.ts +18 -13
- package/dist/openapi_client/models/AgentSurfaceListResponse.d.ts +6 -0
- package/dist/openapi_client/models/{AssistantSurfaceResponse.d.ts → AgentSurfaceResponse.d.ts} +6 -5
- package/dist/openapi_client/models/{AssistantSurfaceStatus.d.ts → AgentSurfaceStatus.d.ts} +1 -1
- package/dist/openapi_client/models/AgentSurfaceStatus.js +10 -0
- package/dist/openapi_client/models/{ToolSet.d.ts → AgentToolset.d.ts} +3 -5
- package/dist/openapi_client/models/AgentToolset.js +17 -0
- package/dist/openapi_client/models/ApplicationAccessConfig.d.ts +3 -5
- package/dist/openapi_client/models/ApplicationMode.d.ts +3 -3
- package/dist/openapi_client/models/ApplicationMode.js +3 -3
- package/dist/openapi_client/models/ConversationResponse.d.ts +9 -20
- package/dist/openapi_client/models/CreateAgentRequest.d.ts +11 -7
- package/dist/openapi_client/models/CreateConversationRequest.d.ts +4 -8
- package/dist/openapi_client/models/CreateFolderRequest.d.ts +2 -5
- package/dist/openapi_client/models/CreateFunctionRequest.d.ts +2 -2
- package/dist/openapi_client/models/CreateSurfaceRequest.d.ts +1 -1
- package/dist/openapi_client/models/DatastoreFileUploadRequest.d.ts +2 -2
- package/dist/openapi_client/models/FeedbackCategory.d.ts +7 -0
- package/dist/openapi_client/models/FeedbackCategory.js +12 -0
- package/dist/openapi_client/models/FileNamespace.d.ts +4 -0
- package/dist/openapi_client/models/FileNamespace.js +9 -0
- package/dist/openapi_client/models/FileResponse.d.ts +2 -2
- package/dist/openapi_client/models/FlowRunEntity.d.ts +11 -1
- package/dist/openapi_client/models/FunctionResponse.d.ts +2 -2
- package/dist/openapi_client/models/HarnessKind.d.ts +7 -0
- package/dist/openapi_client/models/HarnessKind.js +12 -0
- package/dist/openapi_client/models/IntegrationHelperAgentRequest.d.ts +13 -0
- package/dist/openapi_client/models/IntegrationHelperAgentResponse.d.ts +25 -0
- package/dist/openapi_client/models/MessageListResponse.d.ts +6 -0
- package/dist/openapi_client/models/MessageResponse.d.ts +17 -0
- package/dist/openapi_client/models/OperationDetail.d.ts +3 -0
- package/dist/openapi_client/models/OperationDetailsBatchRequest.d.ts +9 -0
- package/dist/openapi_client/models/OperationDetailsBatchResponse.d.ts +18 -0
- package/dist/openapi_client/models/OperationDiscoverResponse.d.ts +26 -0
- package/dist/openapi_client/models/OperationSummary.d.ts +3 -0
- package/dist/openapi_client/models/OrganizationCreateRequest.d.ts +2 -0
- package/dist/openapi_client/models/OrganizationInvitationRequest.d.ts +1 -0
- package/dist/openapi_client/models/OrganizationInvitationResponse.d.ts +4 -0
- package/dist/openapi_client/models/OrganizationMessageResponse.d.ts +1 -0
- package/dist/openapi_client/models/OrganizationResponse.d.ts +2 -0
- package/dist/openapi_client/models/OrganizationSlugAvailabilityResponse.d.ts +7 -0
- package/dist/openapi_client/models/ReportFeedbackRequest.d.ts +30 -0
- package/dist/openapi_client/models/ReportFeedbackResponse.d.ts +25 -0
- package/dist/openapi_client/models/ResourceType.d.ts +0 -1
- package/dist/openapi_client/models/ResourceType.js +0 -1
- package/dist/openapi_client/models/SendMessageRequest.d.ts +5 -0
- package/dist/openapi_client/models/{ToolCallRequest.d.ts → ToolCallContent.d.ts} +1 -1
- package/dist/openapi_client/models/{ToolCallResponse.d.ts → ToolReturnContent.d.ts} +2 -1
- package/dist/openapi_client/models/UpdateAgentRequest.d.ts +11 -7
- package/dist/openapi_client/models/UpdateConversationRequest.d.ts +2 -5
- package/dist/openapi_client/models/UpdateFunctionRequest.d.ts +2 -2
- package/dist/openapi_client/models/WorkflowInstallListResponse.d.ts +4 -0
- package/dist/openapi_client/models/app__modules__agent__domain__value_objects__TableAccessEntry.d.ts +8 -0
- package/dist/openapi_client/models/{TableAccessEntry.d.ts → app__modules__function__api__schemas__function_schemas__TableAccessEntry.d.ts} +1 -1
- package/dist/openapi_client/models/update.d.ts +2 -2
- package/dist/openapi_client/services/AgentConversationsService.d.ts +97 -0
- package/dist/openapi_client/services/AgentConversationsService.js +217 -0
- package/dist/openapi_client/services/{AssistantSurfacesIngressService.d.ts → AgentSurfacesIngressService.d.ts} +2 -2
- package/dist/openapi_client/services/{AssistantSurfacesIngressService.js → AgentSurfacesIngressService.js} +2 -2
- package/dist/openapi_client/services/{AssistantSurfacesService.d.ts → AgentSurfacesService.d.ts} +11 -11
- package/dist/openapi_client/services/{AssistantSurfacesService.js → AgentSurfacesService.js} +10 -10
- package/dist/openapi_client/services/AgentToolsService.d.ts +24 -4
- package/dist/openapi_client/services/AgentToolsService.js +40 -4
- package/dist/openapi_client/services/AgentsService.d.ts +7 -7
- package/dist/openapi_client/services/AgentsService.js +8 -8
- package/dist/openapi_client/services/ApplicationsService.d.ts +10 -9
- package/dist/openapi_client/services/ApplicationsService.js +11 -10
- package/dist/openapi_client/services/FilesService.d.ts +17 -8
- package/dist/openapi_client/services/FilesService.js +25 -8
- package/dist/openapi_client/services/IntegrationsService.d.ts +3 -2
- package/dist/openapi_client/services/IntegrationsService.js +4 -2
- package/dist/openapi_client/services/OrganizationsService.d.ts +18 -0
- package/dist/openapi_client/services/OrganizationsService.js +40 -0
- package/dist/openapi_client/services/WorkflowsService.d.ts +10 -0
- package/dist/openapi_client/services/WorkflowsService.js +21 -0
- package/dist/react/useAgentRun.d.ts +28 -7
- package/dist/react/useAgentRun.js +120 -27
- package/dist/react/useAssistantController.d.ts +6 -2
- package/dist/react/useAssistantController.js +57 -14
- package/dist/react/useAssistantSession.d.ts +15 -3
- package/dist/react/useAssistantSession.js +19 -15
- package/dist/react/useConversationMessages.d.ts +6 -2
- package/dist/react/useConversationMessages.js +2 -1
- package/dist/react/useConversations.d.ts +6 -2
- package/dist/react/useConversations.js +7 -5
- package/dist/react/useCreateFolder.d.ts +4 -2
- package/dist/react/useCreateFolder.js +6 -3
- package/dist/react/useDeleteFile.d.ts +4 -1
- package/dist/react/useDeleteFile.js +3 -3
- package/dist/react/useFile.d.ts +4 -2
- package/dist/react/useFile.js +3 -3
- package/dist/react/useFilePreview.d.ts +4 -1
- package/dist/react/useFilePreview.js +5 -4
- package/dist/react/useFileTree.d.ts +4 -2
- package/dist/react/useFileTree.js +3 -2
- package/dist/react/useFiles.d.ts +4 -2
- package/dist/react/useFiles.js +5 -3
- package/dist/react/useUpdateFile.d.ts +4 -2
- package/dist/react/useUpdateFile.js +6 -3
- package/dist/react/useUploadFile.d.ts +4 -2
- package/dist/react/useUploadFile.js +6 -3
- package/dist/react/useWorkflowRun.js +1 -1
- package/dist/react/useWorkflowStart.js +1 -1
- package/dist/run-utils.d.ts +2 -1
- package/dist/types.d.ts +62 -6
- package/package.json +1 -1
- package/dist/namespaces/assistants.d.ts +0 -96
- package/dist/namespaces/assistants.js +0 -160
- package/dist/openapi_client/models/AddMessageRequest.d.ts +0 -6
- package/dist/openapi_client/models/AppDescriptorResponse.d.ts +0 -5
- package/dist/openapi_client/models/AssistantListResponse.d.ts +0 -6
- package/dist/openapi_client/models/AssistantResponse.d.ts +0 -23
- package/dist/openapi_client/models/AssistantSurfaceListResponse.d.ts +0 -6
- package/dist/openapi_client/models/AssistantSurfaceStatus.js +0 -10
- package/dist/openapi_client/models/AvailableModelInfo.d.ts +0 -8
- package/dist/openapi_client/models/AvailableModels.js +0 -15
- package/dist/openapi_client/models/AvailableModelsListResponse.d.ts +0 -7
- package/dist/openapi_client/models/ConversationMessageListResponse.d.ts +0 -6
- package/dist/openapi_client/models/ConversationMessageResponse.d.ts +0 -19
- package/dist/openapi_client/models/ConversationStatus.d.ts +0 -7
- package/dist/openapi_client/models/ConversationStatus.js +0 -12
- package/dist/openapi_client/models/ConversationType.d.ts +0 -8
- package/dist/openapi_client/models/ConversationType.js +0 -13
- package/dist/openapi_client/models/CreateAssistantRequest.d.ts +0 -18
- package/dist/openapi_client/models/CreateMessageRequest.d.ts +0 -6
- package/dist/openapi_client/models/CreateTaskRequest.d.ts +0 -10
- package/dist/openapi_client/models/FileVisibility.d.ts +0 -4
- package/dist/openapi_client/models/FileVisibility.js +0 -9
- package/dist/openapi_client/models/OperationListResponse.d.ts +0 -6
- package/dist/openapi_client/models/TaskListResponse.d.ts +0 -9
- package/dist/openapi_client/models/TaskMessageListResponse.d.ts +0 -9
- package/dist/openapi_client/models/TaskMessageResponse.d.ts +0 -15
- package/dist/openapi_client/models/TaskResponse.d.ts +0 -16
- package/dist/openapi_client/models/TaskResponse.js +0 -1
- package/dist/openapi_client/models/TaskStatus.d.ts +0 -12
- package/dist/openapi_client/models/TaskStatus.js +0 -17
- package/dist/openapi_client/models/ToolCallRequest.js +0 -1
- package/dist/openapi_client/models/ToolCallResponse.js +0 -1
- package/dist/openapi_client/models/ToolSet.js +0 -19
- package/dist/openapi_client/models/UpdateAssistantRequest.d.ts +0 -17
- package/dist/openapi_client/models/UpdateAssistantRequest.js +0 -1
- package/dist/openapi_client/services/AssistantsService.d.ts +0 -49
- package/dist/openapi_client/services/AssistantsService.js +0 -112
- package/dist/openapi_client/services/ConversationsService.d.ts +0 -88
- package/dist/openapi_client/services/ConversationsService.js +0 -202
- package/dist/openapi_client/services/TasksService.d.ts +0 -76
- package/dist/openapi_client/services/TasksService.js +0 -167
- /package/dist/openapi_client/models/{AddMessageRequest.js → AgentSurfaceListResponse.js} +0 -0
- /package/dist/openapi_client/models/{AppDescriptorResponse.js → AgentSurfaceResponse.js} +0 -0
- /package/dist/openapi_client/models/{AssistantListResponse.js → IntegrationHelperAgentRequest.js} +0 -0
- /package/dist/openapi_client/models/{AssistantResponse.js → IntegrationHelperAgentResponse.js} +0 -0
- /package/dist/openapi_client/models/{AssistantSurfaceListResponse.js → MessageListResponse.js} +0 -0
- /package/dist/openapi_client/models/{AssistantSurfaceResponse.js → MessageResponse.js} +0 -0
- /package/dist/openapi_client/models/{AvailableModelInfo.js → OperationDetailsBatchRequest.js} +0 -0
- /package/dist/openapi_client/models/{AvailableModelsListResponse.js → OperationDetailsBatchResponse.js} +0 -0
- /package/dist/openapi_client/models/{ConversationMessageListResponse.js → OperationDiscoverResponse.js} +0 -0
- /package/dist/openapi_client/models/{ConversationMessageResponse.js → OrganizationSlugAvailabilityResponse.js} +0 -0
- /package/dist/openapi_client/models/{CreateAssistantRequest.js → ReportFeedbackRequest.js} +0 -0
- /package/dist/openapi_client/models/{CreateMessageRequest.js → ReportFeedbackResponse.js} +0 -0
- /package/dist/openapi_client/models/{CreateTaskRequest.js → SendMessageRequest.js} +0 -0
- /package/dist/openapi_client/models/{OperationListResponse.js → ToolCallContent.js} +0 -0
- /package/dist/openapi_client/models/{TableAccessEntry.js → ToolReturnContent.js} +0 -0
- /package/dist/openapi_client/models/{TaskListResponse.js → WorkflowInstallListResponse.js} +0 -0
- /package/dist/openapi_client/models/{TaskMessageListResponse.js → app__modules__agent__domain__value_objects__TableAccessEntry.js} +0 -0
- /package/dist/openapi_client/models/{TaskMessageResponse.js → app__modules__function__api__schemas__function_schemas__TableAccessEntry.js} +0 -0
|
@@ -1,17 +1,38 @@
|
|
|
1
|
-
import type { Task } from "../types.js";
|
|
2
|
-
import { type
|
|
3
|
-
export interface UseAgentRunOptions extends Omit<
|
|
1
|
+
import type { Conversation, ConversationMessage, Task } from "../types.js";
|
|
2
|
+
import { type UseAssistantSessionOptions } from "./useAssistantSession.js";
|
|
3
|
+
export interface UseAgentRunOptions extends Omit<UseAssistantSessionOptions, "agentName" | "assistantName" | "assistantId" | "conversationId"> {
|
|
4
4
|
agentName?: string;
|
|
5
|
+
conversationId?: string | null;
|
|
5
6
|
taskId?: string | null;
|
|
7
|
+
autoConnect?: boolean;
|
|
8
|
+
autoConnectOnStart?: boolean;
|
|
6
9
|
}
|
|
7
|
-
export interface UseAgentRunResult
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
export interface UseAgentRunResult {
|
|
11
|
+
taskId: string | null;
|
|
12
|
+
conversationId: string | null;
|
|
13
|
+
task: Task | null;
|
|
14
|
+
conversation: Conversation | null;
|
|
15
|
+
status?: string;
|
|
16
|
+
messages: ConversationMessage[];
|
|
17
|
+
output: unknown;
|
|
18
|
+
finalOutput: unknown;
|
|
19
|
+
outputText: string;
|
|
20
|
+
finalOutputText: string;
|
|
21
|
+
isStreaming: boolean;
|
|
22
|
+
error: Error | null;
|
|
10
23
|
isWaitingForInput: boolean;
|
|
11
24
|
isFinished: boolean;
|
|
25
|
+
setTaskId: (taskId: string | null) => void;
|
|
26
|
+
setConversationId: (conversationId: string | null) => void;
|
|
12
27
|
start: (inputData?: Record<string, unknown> | null, options?: {
|
|
13
28
|
agentName?: string;
|
|
14
29
|
}) => Promise<Task>;
|
|
15
30
|
submitInput: (content: string) => Promise<Task | null>;
|
|
31
|
+
refreshTask: (taskId?: string | null) => Promise<Task | null>;
|
|
32
|
+
loadMessages: (taskId?: string | null) => Promise<ConversationMessage[]>;
|
|
33
|
+
connect: (taskId?: string | null) => Promise<void>;
|
|
34
|
+
disconnect: () => void;
|
|
35
|
+
stop: () => Promise<Task | null>;
|
|
36
|
+
clearMessages: () => void;
|
|
16
37
|
}
|
|
17
|
-
export declare function useAgentRun({ client, podId, agentName, taskId, autoConnect, autoConnectOnStart, onEvent, onStatus, onMessage, onError, }: UseAgentRunOptions): UseAgentRunResult;
|
|
38
|
+
export declare function useAgentRun({ client, podId, agentName, conversationId, taskId, autoConnect, autoConnectOnStart, autoLoad, autoResume, syncOnTurnEnd, onEvent, onStatus, onMessage, onError, }: UseAgentRunOptions): UseAgentRunResult;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { useCallback, useMemo } from "react";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { useTaskSession, } from "./useTaskSession.js";
|
|
2
|
+
import { extractConversationMessageText, getLatestAssistantMessage, isConversationRunningStatus, normalizeConversationStatus, } from "./assistant-output.js";
|
|
3
|
+
import { useAssistantSession, } from "./useAssistantSession.js";
|
|
5
4
|
function resolveAgentName(base, override) {
|
|
6
5
|
const resolved = override ?? base;
|
|
7
6
|
if (!resolved) {
|
|
@@ -9,48 +8,142 @@ function resolveAgentName(base, override) {
|
|
|
9
8
|
}
|
|
10
9
|
return resolved;
|
|
11
10
|
}
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
function stringifyAgentInput(inputData) {
|
|
12
|
+
if (!inputData || Object.keys(inputData).length === 0) {
|
|
13
|
+
return "";
|
|
14
|
+
}
|
|
15
|
+
const prompt = inputData.prompt ?? inputData.message ?? inputData.content;
|
|
16
|
+
if (typeof prompt === "string" && prompt.trim().length > 0 && Object.keys(inputData).length === 1) {
|
|
17
|
+
return prompt.trim();
|
|
18
|
+
}
|
|
19
|
+
return JSON.stringify(inputData, null, 2);
|
|
20
|
+
}
|
|
21
|
+
function taskFromConversation(conversation, status, inputData, output) {
|
|
22
|
+
if (!conversation)
|
|
23
|
+
return null;
|
|
24
|
+
return {
|
|
25
|
+
id: conversation.id,
|
|
26
|
+
agent_id: conversation.agent_id,
|
|
27
|
+
pod_id: conversation.pod_id,
|
|
28
|
+
user_id: conversation.user_id,
|
|
29
|
+
input_data: inputData ?? null,
|
|
30
|
+
output_data: output ?? null,
|
|
31
|
+
error: null,
|
|
32
|
+
status: normalizeConversationStatus(status ?? conversation.status) ?? "WAITING",
|
|
33
|
+
created_at: conversation.created_at,
|
|
34
|
+
updated_at: conversation.updated_at,
|
|
35
|
+
conversation,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export function useAgentRun({ client, podId, agentName, conversationId, taskId = null, autoConnect = true, autoConnectOnStart = true, autoLoad, autoResume, syncOnTurnEnd, onEvent, onStatus, onMessage, onError, }) {
|
|
39
|
+
const session = useAssistantSession({
|
|
14
40
|
client,
|
|
15
41
|
podId,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
42
|
+
agentName,
|
|
43
|
+
conversationId: conversationId ?? taskId,
|
|
44
|
+
autoLoad: autoLoad ?? autoConnect,
|
|
45
|
+
autoResume: autoResume ?? autoConnect,
|
|
46
|
+
syncOnTurnEnd,
|
|
19
47
|
onEvent,
|
|
20
48
|
onStatus,
|
|
21
49
|
onMessage,
|
|
22
50
|
onError,
|
|
23
51
|
});
|
|
24
52
|
const start = useCallback(async (inputData, options) => {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
53
|
+
const resolvedAgentName = resolveAgentName(agentName, options?.agentName);
|
|
54
|
+
const content = stringifyAgentInput(inputData);
|
|
55
|
+
const conversation = await session.createConversation({
|
|
56
|
+
agentName: resolvedAgentName,
|
|
57
|
+
title: content ? content.slice(0, 120) : resolvedAgentName,
|
|
58
|
+
setActive: true,
|
|
28
59
|
});
|
|
29
|
-
|
|
60
|
+
if (content) {
|
|
61
|
+
await session.sendMessage(content, {
|
|
62
|
+
conversationId: conversation.id,
|
|
63
|
+
createIfMissing: false,
|
|
64
|
+
syncOnTurnEnd,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
else if (autoConnectOnStart) {
|
|
68
|
+
await session.resume(conversation.id);
|
|
69
|
+
}
|
|
70
|
+
return taskFromConversation(conversation, session.status, inputData) ?? {
|
|
71
|
+
id: conversation.id,
|
|
72
|
+
agent_id: conversation.agent_id,
|
|
73
|
+
pod_id: conversation.pod_id,
|
|
74
|
+
user_id: conversation.user_id,
|
|
75
|
+
input_data: inputData ?? null,
|
|
76
|
+
output_data: null,
|
|
77
|
+
error: null,
|
|
78
|
+
status: "WAITING",
|
|
79
|
+
created_at: conversation.created_at,
|
|
80
|
+
updated_at: conversation.updated_at,
|
|
81
|
+
conversation,
|
|
82
|
+
};
|
|
83
|
+
}, [agentName, autoConnectOnStart, session, syncOnTurnEnd]);
|
|
30
84
|
const submitInput = useCallback(async (content) => {
|
|
31
|
-
const
|
|
32
|
-
if (!
|
|
33
|
-
throw new Error("
|
|
85
|
+
const resolvedConversationId = session.conversationId;
|
|
86
|
+
if (!resolvedConversationId) {
|
|
87
|
+
throw new Error("conversationId is required to submit additional agent input.");
|
|
34
88
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
89
|
+
await session.sendMessage(content, {
|
|
90
|
+
conversationId: resolvedConversationId,
|
|
91
|
+
createIfMissing: false,
|
|
92
|
+
syncOnTurnEnd,
|
|
93
|
+
});
|
|
94
|
+
return taskFromConversation(session.conversation, session.status);
|
|
95
|
+
}, [session, syncOnTurnEnd]);
|
|
96
|
+
const refreshTask = useCallback(async (explicitTaskId) => {
|
|
97
|
+
const conversation = await session.refreshConversation(explicitTaskId);
|
|
98
|
+
return taskFromConversation(conversation, session.status);
|
|
99
|
+
}, [session]);
|
|
100
|
+
const loadMessages = useCallback(async (explicitTaskId) => {
|
|
101
|
+
const response = await session.loadMessages({ conversationId: explicitTaskId });
|
|
102
|
+
return response.items;
|
|
103
|
+
}, [session]);
|
|
104
|
+
const connect = useCallback(async (explicitTaskId) => {
|
|
105
|
+
await session.resume(explicitTaskId);
|
|
106
|
+
}, [session]);
|
|
107
|
+
const stop = useCallback(async () => {
|
|
108
|
+
await session.stop();
|
|
109
|
+
return taskFromConversation(session.conversation, "WAITING");
|
|
110
|
+
}, [session]);
|
|
40
111
|
return useMemo(() => {
|
|
41
|
-
const
|
|
42
|
-
const
|
|
112
|
+
const latestAssistantMessage = getLatestAssistantMessage(session.messages);
|
|
113
|
+
const output = latestAssistantMessage?.content ?? session.output ?? null;
|
|
114
|
+
const outputText = latestAssistantMessage
|
|
115
|
+
? extractConversationMessageText(latestAssistantMessage.content)
|
|
116
|
+
: session.outputText;
|
|
117
|
+
const normalizedStatus = normalizeConversationStatus(session.status);
|
|
118
|
+
const running = isConversationRunningStatus(normalizedStatus) || session.isStreaming;
|
|
43
119
|
const isWaitingForInput = normalizedStatus === "WAITING";
|
|
44
|
-
const
|
|
45
|
-
const
|
|
120
|
+
const isFinished = !!latestAssistantMessage && !running;
|
|
121
|
+
const task = taskFromConversation(session.conversation, session.status, null, output);
|
|
46
122
|
return {
|
|
47
|
-
|
|
123
|
+
taskId: session.conversationId,
|
|
124
|
+
conversationId: session.conversationId,
|
|
125
|
+
task,
|
|
126
|
+
conversation: session.conversation,
|
|
127
|
+
status: normalizedStatus,
|
|
128
|
+
messages: session.messages,
|
|
48
129
|
output,
|
|
49
|
-
finalOutput,
|
|
130
|
+
finalOutput: isFinished ? output : null,
|
|
131
|
+
outputText,
|
|
132
|
+
finalOutputText: isFinished ? outputText : "",
|
|
133
|
+
isStreaming: session.isStreaming,
|
|
134
|
+
error: session.error,
|
|
50
135
|
isWaitingForInput,
|
|
51
136
|
isFinished,
|
|
137
|
+
setTaskId: session.setConversationId,
|
|
138
|
+
setConversationId: session.setConversationId,
|
|
52
139
|
start,
|
|
53
140
|
submitInput,
|
|
141
|
+
refreshTask,
|
|
142
|
+
loadMessages,
|
|
143
|
+
connect,
|
|
144
|
+
disconnect: session.cancel,
|
|
145
|
+
stop,
|
|
146
|
+
clearMessages: session.clearMessages,
|
|
54
147
|
};
|
|
55
|
-
}, [session, start, submitInput]);
|
|
148
|
+
}, [connect, loadMessages, refreshTask, session, start, stop, submitInput]);
|
|
56
149
|
}
|
|
@@ -2,9 +2,13 @@ import type { LemmaClient } from "../client.js";
|
|
|
2
2
|
import type { AvailableModelInfo, Conversation, ConversationModel } from "../types.js";
|
|
3
3
|
export interface AssistantConversationScope {
|
|
4
4
|
podId?: string | null;
|
|
5
|
+
agentName?: string | null;
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated Use agentName instead.
|
|
8
|
+
*/
|
|
5
9
|
assistantName?: string | null;
|
|
6
10
|
/**
|
|
7
|
-
* @deprecated Use
|
|
11
|
+
* @deprecated Use agentName instead.
|
|
8
12
|
*/
|
|
9
13
|
assistantId?: string | null;
|
|
10
14
|
organizationId?: string | null;
|
|
@@ -85,4 +89,4 @@ export interface UseAssistantControllerResult {
|
|
|
85
89
|
clearMessages: () => void;
|
|
86
90
|
stop: () => void;
|
|
87
91
|
}
|
|
88
|
-
export declare function useAssistantController({ client, podId, assistantName, assistantId, organizationId, enabled, }: UseAssistantControllerOptions): UseAssistantControllerResult;
|
|
92
|
+
export declare function useAssistantController({ client, podId, agentName, assistantName, assistantId, organizationId, enabled, }: UseAssistantControllerOptions): UseAssistantControllerResult;
|
|
@@ -539,7 +539,38 @@ function isConversationRunning(status) {
|
|
|
539
539
|
}
|
|
540
540
|
return true;
|
|
541
541
|
}
|
|
542
|
-
|
|
542
|
+
function resolveScopedClient(client, podId) {
|
|
543
|
+
if (podId && podId !== client.podId) {
|
|
544
|
+
return client.withPod(podId);
|
|
545
|
+
}
|
|
546
|
+
return client;
|
|
547
|
+
}
|
|
548
|
+
async function uploadPersonalFiles(client, files) {
|
|
549
|
+
const uploaded = [];
|
|
550
|
+
for (const file of files) {
|
|
551
|
+
uploaded.push(await client.files.upload(file, {
|
|
552
|
+
name: file.name,
|
|
553
|
+
namespace: "PRIVATE",
|
|
554
|
+
}));
|
|
555
|
+
}
|
|
556
|
+
return uploaded;
|
|
557
|
+
}
|
|
558
|
+
function formatPersonalFileReferences(files) {
|
|
559
|
+
return files
|
|
560
|
+
.map((file) => {
|
|
561
|
+
const pathParts = file.path.split("/").filter(Boolean);
|
|
562
|
+
const name = file.name || pathParts[pathParts.length - 1] || file.path;
|
|
563
|
+
return `- ${name}: ${file.path}`;
|
|
564
|
+
})
|
|
565
|
+
.join("\n");
|
|
566
|
+
}
|
|
567
|
+
function appendPersonalFileReferences(content, files) {
|
|
568
|
+
if (files.length === 0)
|
|
569
|
+
return content;
|
|
570
|
+
const references = formatPersonalFileReferences(files);
|
|
571
|
+
return `${content}\n\nPersonal files available to this run:\n${references}`;
|
|
572
|
+
}
|
|
573
|
+
export function useAssistantController({ client, podId, agentName, assistantName, assistantId, organizationId, enabled = true, }) {
|
|
543
574
|
const [localError, setLocalError] = useState(null);
|
|
544
575
|
const [conversations, setConversations] = useState([]);
|
|
545
576
|
const [activeConversationId, setActiveConversationId] = useState(null);
|
|
@@ -564,22 +595,25 @@ export function useAssistantController({ client, podId, assistantName, assistant
|
|
|
564
595
|
const resumeIfRunningRef = useRef(null);
|
|
565
596
|
const scope = useMemo(() => ({
|
|
566
597
|
podId: podId ?? null,
|
|
598
|
+
agentName: agentName ?? assistantName ?? assistantId ?? null,
|
|
567
599
|
assistantName: assistantName ?? assistantId ?? null,
|
|
568
600
|
assistantId: assistantId ?? null,
|
|
569
601
|
organizationId: organizationId ?? null,
|
|
570
|
-
}), [assistantId, assistantName, organizationId, podId]);
|
|
602
|
+
}), [agentName, assistantId, assistantName, organizationId, podId]);
|
|
571
603
|
const scopeKey = useMemo(() => JSON.stringify({
|
|
572
604
|
podId: scope.podId ?? null,
|
|
605
|
+
agentName: scope.agentName ?? null,
|
|
573
606
|
assistantName: scope.assistantName ?? null,
|
|
574
607
|
assistantId: scope.assistantId ?? null,
|
|
575
608
|
organizationId: scope.organizationId ?? null,
|
|
576
|
-
}), [scope.assistantId, scope.assistantName, scope.organizationId, scope.podId]);
|
|
609
|
+
}), [scope.agentName, scope.assistantId, scope.assistantName, scope.organizationId, scope.podId]);
|
|
577
610
|
const handleAssistantSessionError = useCallback((sessionError) => {
|
|
578
|
-
setLocalError((prev) => prev || (sessionError instanceof Error ? sessionError.message : "
|
|
611
|
+
setLocalError((prev) => prev || (sessionError instanceof Error ? sessionError.message : "Agent session failed"));
|
|
579
612
|
}, []);
|
|
580
613
|
const assistantSession = useAssistantSession({
|
|
581
614
|
client,
|
|
582
615
|
podId: scope.podId ?? undefined,
|
|
616
|
+
agentName: scope.agentName ?? undefined,
|
|
583
617
|
assistantName: scope.assistantName ?? undefined,
|
|
584
618
|
assistantId: scope.assistantId ?? undefined,
|
|
585
619
|
organizationId: scope.organizationId ?? undefined,
|
|
@@ -1002,12 +1036,13 @@ export function useAssistantController({ client, podId, assistantName, assistant
|
|
|
1002
1036
|
throw new Error("Conversation could not be initialized");
|
|
1003
1037
|
}
|
|
1004
1038
|
const finalConversationId = conversationId;
|
|
1039
|
+
let messageContent = trimmed;
|
|
1005
1040
|
if (pendingFiles.length > 0) {
|
|
1006
1041
|
setIsUploadingFiles(true);
|
|
1007
1042
|
try {
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1043
|
+
const fileClient = resolveScopedClient(client, scope.podId);
|
|
1044
|
+
const uploadedFiles = await uploadPersonalFiles(fileClient, pendingFiles);
|
|
1045
|
+
messageContent = appendPersonalFileReferences(trimmed, uploadedFiles);
|
|
1011
1046
|
setPendingFiles([]);
|
|
1012
1047
|
touchConversation(finalConversationId, { updated_at: new Date().toISOString() });
|
|
1013
1048
|
}
|
|
@@ -1015,12 +1050,12 @@ export function useAssistantController({ client, podId, assistantName, assistant
|
|
|
1015
1050
|
setIsUploadingFiles(false);
|
|
1016
1051
|
}
|
|
1017
1052
|
}
|
|
1018
|
-
appendOptimisticUserMessage(
|
|
1053
|
+
appendOptimisticUserMessage(messageContent, {
|
|
1019
1054
|
conversationId: finalConversationId,
|
|
1020
1055
|
});
|
|
1021
1056
|
setIsStreaming(true);
|
|
1022
1057
|
touchConversation(finalConversationId, { status: "running" });
|
|
1023
|
-
await sessionSendMessage(
|
|
1058
|
+
await sessionSendMessage(messageContent, {
|
|
1024
1059
|
conversationId: finalConversationId,
|
|
1025
1060
|
createIfMissing: false,
|
|
1026
1061
|
});
|
|
@@ -1038,12 +1073,12 @@ export function useAssistantController({ client, podId, assistantName, assistant
|
|
|
1038
1073
|
}, [
|
|
1039
1074
|
activeConversationId,
|
|
1040
1075
|
appendOptimisticUserMessage,
|
|
1041
|
-
client.resources,
|
|
1042
1076
|
enabled,
|
|
1043
1077
|
ensureConversation,
|
|
1044
1078
|
isStreaming,
|
|
1045
1079
|
pendingFiles,
|
|
1046
1080
|
resetConversationState,
|
|
1081
|
+
scope.podId,
|
|
1047
1082
|
sessionIsStreaming,
|
|
1048
1083
|
sessionSendMessage,
|
|
1049
1084
|
touchConversation,
|
|
@@ -1061,9 +1096,14 @@ export function useAssistantController({ client, podId, assistantName, assistant
|
|
|
1061
1096
|
}
|
|
1062
1097
|
setIsUploadingFiles(true);
|
|
1063
1098
|
try {
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
}
|
|
1099
|
+
const fileClient = resolveScopedClient(client, scope.podId);
|
|
1100
|
+
const uploadedFiles = await uploadPersonalFiles(fileClient, normalizedFiles);
|
|
1101
|
+
const fileMessage = `Personal files available to this run:\n${formatPersonalFileReferences(uploadedFiles)}`;
|
|
1102
|
+
setIsStreaming(true);
|
|
1103
|
+
await sessionSendMessage(fileMessage, {
|
|
1104
|
+
conversationId: activeId,
|
|
1105
|
+
createIfMissing: false,
|
|
1106
|
+
});
|
|
1067
1107
|
await loadConversationMessages(activeId);
|
|
1068
1108
|
touchConversation(activeId, { updated_at: new Date().toISOString() });
|
|
1069
1109
|
}
|
|
@@ -1072,15 +1112,18 @@ export function useAssistantController({ client, podId, assistantName, assistant
|
|
|
1072
1112
|
throw err;
|
|
1073
1113
|
}
|
|
1074
1114
|
finally {
|
|
1115
|
+
setIsStreaming(false);
|
|
1075
1116
|
setIsUploadingFiles(false);
|
|
1076
1117
|
}
|
|
1077
1118
|
}, [
|
|
1078
|
-
client
|
|
1119
|
+
client,
|
|
1079
1120
|
enabled,
|
|
1080
1121
|
isLoading,
|
|
1081
1122
|
isUploadingFiles,
|
|
1082
1123
|
loadConversationMessages,
|
|
1083
1124
|
queuePendingFiles,
|
|
1125
|
+
scope.podId,
|
|
1126
|
+
sessionSendMessage,
|
|
1084
1127
|
touchConversation,
|
|
1085
1128
|
]);
|
|
1086
1129
|
const { pendingActions, completedActions } = useMemo(() => {
|
|
@@ -3,9 +3,13 @@ import { type SseRawEvent } from "../streams.js";
|
|
|
3
3
|
import type { Conversation, ConversationMessage, ConversationModel, CursorPage } from "../types.js";
|
|
4
4
|
interface ConversationScope {
|
|
5
5
|
podId?: string | null;
|
|
6
|
+
agentName?: string | null;
|
|
7
|
+
/**
|
|
8
|
+
* @deprecated Use agentName instead.
|
|
9
|
+
*/
|
|
6
10
|
assistantName?: string | null;
|
|
7
11
|
/**
|
|
8
|
-
* @deprecated Use
|
|
12
|
+
* @deprecated Use agentName instead.
|
|
9
13
|
*/
|
|
10
14
|
assistantId?: string | null;
|
|
11
15
|
organizationId?: string | null;
|
|
@@ -13,9 +17,13 @@ interface ConversationScope {
|
|
|
13
17
|
export interface UseAssistantSessionOptions {
|
|
14
18
|
client: LemmaClient;
|
|
15
19
|
podId?: string;
|
|
20
|
+
agentName?: string;
|
|
21
|
+
/**
|
|
22
|
+
* @deprecated Use agentName instead.
|
|
23
|
+
*/
|
|
16
24
|
assistantName?: string;
|
|
17
25
|
/**
|
|
18
|
-
* @deprecated Use
|
|
26
|
+
* @deprecated Use agentName instead.
|
|
19
27
|
*/
|
|
20
28
|
assistantId?: string;
|
|
21
29
|
organizationId?: string;
|
|
@@ -32,9 +40,13 @@ export interface CreateConversationInput {
|
|
|
32
40
|
title?: string | null;
|
|
33
41
|
model?: ConversationModel | null;
|
|
34
42
|
podId?: string | null;
|
|
43
|
+
agentName?: string | null;
|
|
44
|
+
/**
|
|
45
|
+
* @deprecated Use agentName instead.
|
|
46
|
+
*/
|
|
35
47
|
assistantName?: string | null;
|
|
36
48
|
/**
|
|
37
|
-
* @deprecated Use
|
|
49
|
+
* @deprecated Use agentName instead.
|
|
38
50
|
*/
|
|
39
51
|
assistantId?: string | null;
|
|
40
52
|
organizationId?: string | null;
|
|
@@ -17,14 +17,17 @@ function requireConversationId(conversationId) {
|
|
|
17
17
|
return conversationId;
|
|
18
18
|
}
|
|
19
19
|
function normalizeScope(client, defaults, override) {
|
|
20
|
-
const
|
|
20
|
+
const resolvedAgentName = override?.agentName
|
|
21
|
+
?? override?.assistantName
|
|
21
22
|
?? override?.assistantId
|
|
23
|
+
?? defaults.agentName
|
|
22
24
|
?? defaults.assistantName
|
|
23
25
|
?? defaults.assistantId
|
|
24
26
|
?? null;
|
|
25
27
|
return {
|
|
26
28
|
podId: override?.podId ?? defaults.podId ?? client.podId ?? null,
|
|
27
|
-
|
|
29
|
+
agentName: resolvedAgentName,
|
|
30
|
+
assistantName: override?.assistantName ?? defaults.assistantName ?? null,
|
|
28
31
|
assistantId: override?.assistantId ?? defaults.assistantId ?? null,
|
|
29
32
|
organizationId: override?.organizationId ?? defaults.organizationId ?? null,
|
|
30
33
|
};
|
|
@@ -48,7 +51,7 @@ function resolveResumeInput(input) {
|
|
|
48
51
|
return input ?? {};
|
|
49
52
|
}
|
|
50
53
|
export function useAssistantSession(options) {
|
|
51
|
-
const { client, podId: defaultPodId, assistantName: defaultAssistantName, assistantId: defaultAssistantId, organizationId: defaultOrganizationId, conversationId: externalConversationId = null, autoLoad = true, autoResume = false, syncOnTurnEnd = false, onEvent, onStatus, onMessage, onError, } = options;
|
|
54
|
+
const { client, podId: defaultPodId, agentName: defaultAgentName, assistantName: defaultAssistantName, assistantId: defaultAssistantId, organizationId: defaultOrganizationId, conversationId: externalConversationId = null, autoLoad = true, autoResume = false, syncOnTurnEnd = false, onEvent, onStatus, onMessage, onError, } = options;
|
|
52
55
|
const [conversationId, setConversationIdState] = useState(externalConversationId);
|
|
53
56
|
const [conversation, setConversation] = useState(null);
|
|
54
57
|
const [status, setStatus] = useState(undefined);
|
|
@@ -150,10 +153,11 @@ export function useAssistantSession(options) {
|
|
|
150
153
|
}, []);
|
|
151
154
|
const defaultScope = useMemo(() => ({
|
|
152
155
|
podId: defaultPodId ?? null,
|
|
156
|
+
agentName: defaultAgentName ?? defaultAssistantName ?? defaultAssistantId ?? null,
|
|
153
157
|
assistantName: defaultAssistantName ?? defaultAssistantId ?? null,
|
|
154
158
|
assistantId: defaultAssistantId ?? null,
|
|
155
159
|
organizationId: defaultOrganizationId ?? null,
|
|
156
|
-
}), [defaultAssistantId, defaultAssistantName, defaultOrganizationId, defaultPodId]);
|
|
160
|
+
}), [defaultAgentName, defaultAssistantId, defaultAssistantName, defaultOrganizationId, defaultPodId]);
|
|
157
161
|
const listConversations = useCallback(async (input = {}) => {
|
|
158
162
|
setError(null);
|
|
159
163
|
try {
|
|
@@ -161,8 +165,7 @@ export function useAssistantSession(options) {
|
|
|
161
165
|
const scopedClient = applyPodScope(client, scope.podId);
|
|
162
166
|
const response = await scopedClient.conversations.list({
|
|
163
167
|
pod_id: scope.podId ?? undefined,
|
|
164
|
-
|
|
165
|
-
organization_id: scope.organizationId ?? undefined,
|
|
168
|
+
agent_name: scope.agentName ?? undefined,
|
|
166
169
|
limit: input.limit,
|
|
167
170
|
page_token: input.pageToken,
|
|
168
171
|
});
|
|
@@ -191,12 +194,13 @@ export function useAssistantSession(options) {
|
|
|
191
194
|
const payload = {
|
|
192
195
|
title: input.title ?? undefined,
|
|
193
196
|
pod_id: input.podId ?? defaultPodId ?? scopedClient.podId ?? undefined,
|
|
194
|
-
|
|
197
|
+
agent_name: input.agentName
|
|
198
|
+
?? input.assistantName
|
|
195
199
|
?? input.assistantId
|
|
200
|
+
?? defaultAgentName
|
|
196
201
|
?? defaultAssistantName
|
|
197
202
|
?? defaultAssistantId
|
|
198
203
|
?? undefined,
|
|
199
|
-
organization_id: input.organizationId ?? defaultOrganizationId ?? undefined,
|
|
200
204
|
model: typeof input.model === "undefined"
|
|
201
205
|
? undefined
|
|
202
206
|
: input.model,
|
|
@@ -205,7 +209,7 @@ export function useAssistantSession(options) {
|
|
|
205
209
|
if (input.setActive !== false) {
|
|
206
210
|
setConversationIdState(created.id);
|
|
207
211
|
setConversation(created);
|
|
208
|
-
setConversationStatus(created.status);
|
|
212
|
+
setConversationStatus(created.status ?? undefined);
|
|
209
213
|
setMessages([]);
|
|
210
214
|
clearStreamingText();
|
|
211
215
|
autoResumedKeyRef.current = null;
|
|
@@ -221,9 +225,9 @@ export function useAssistantSession(options) {
|
|
|
221
225
|
}, [
|
|
222
226
|
clearStreamingText,
|
|
223
227
|
client,
|
|
228
|
+
defaultAgentName,
|
|
224
229
|
defaultAssistantId,
|
|
225
230
|
defaultAssistantName,
|
|
226
|
-
defaultOrganizationId,
|
|
227
231
|
defaultPodId,
|
|
228
232
|
setConversationStatus,
|
|
229
233
|
]);
|
|
@@ -338,7 +342,7 @@ export function useAssistantSession(options) {
|
|
|
338
342
|
}
|
|
339
343
|
catch (streamError) {
|
|
340
344
|
if (!(streamError instanceof Error && streamError.name === "AbortError")) {
|
|
341
|
-
const normalized = normalizeError(streamError, "Failed to stream
|
|
345
|
+
const normalized = normalizeError(streamError, "Failed to stream agent run.");
|
|
342
346
|
setError(normalized);
|
|
343
347
|
onErrorRef.current?.(streamError);
|
|
344
348
|
}
|
|
@@ -402,7 +406,7 @@ export function useAssistantSession(options) {
|
|
|
402
406
|
return resolvedConversation;
|
|
403
407
|
}
|
|
404
408
|
catch (sendError) {
|
|
405
|
-
const normalized = normalizeError(sendError, "Failed to send
|
|
409
|
+
const normalized = normalizeError(sendError, "Failed to send agent message.");
|
|
406
410
|
setError(normalized);
|
|
407
411
|
onErrorRef.current?.(sendError);
|
|
408
412
|
throw normalized;
|
|
@@ -434,7 +438,7 @@ export function useAssistantSession(options) {
|
|
|
434
438
|
});
|
|
435
439
|
}
|
|
436
440
|
catch (resumeError) {
|
|
437
|
-
const normalized = normalizeError(resumeError, "Failed to resume
|
|
441
|
+
const normalized = normalizeError(resumeError, "Failed to resume agent run.");
|
|
438
442
|
setError(normalized);
|
|
439
443
|
onErrorRef.current?.(resumeError);
|
|
440
444
|
throw normalized;
|
|
@@ -487,7 +491,7 @@ export function useAssistantSession(options) {
|
|
|
487
491
|
clearStreamingText();
|
|
488
492
|
}
|
|
489
493
|
catch (stopError) {
|
|
490
|
-
const normalized = normalizeError(stopError, "Failed to stop
|
|
494
|
+
const normalized = normalizeError(stopError, "Failed to stop agent run.");
|
|
491
495
|
setError(normalized);
|
|
492
496
|
onErrorRef.current?.(stopError);
|
|
493
497
|
throw normalized;
|
|
@@ -536,7 +540,7 @@ export function useAssistantSession(options) {
|
|
|
536
540
|
.catch((bootstrapError) => {
|
|
537
541
|
if (cancelled)
|
|
538
542
|
return;
|
|
539
|
-
const normalized = normalizeError(bootstrapError, "Failed to load
|
|
543
|
+
const normalized = normalizeError(bootstrapError, "Failed to load agent conversation.");
|
|
540
544
|
setError(normalized);
|
|
541
545
|
onErrorRef.current?.(bootstrapError);
|
|
542
546
|
})
|
|
@@ -5,9 +5,13 @@ import { type CreateConversationInput, type ResumeAssistantOptions, type SendAss
|
|
|
5
5
|
export interface UseConversationMessagesOptions {
|
|
6
6
|
client: LemmaClient;
|
|
7
7
|
podId?: string;
|
|
8
|
+
agentName?: string;
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated Use agentName instead.
|
|
11
|
+
*/
|
|
8
12
|
assistantName?: string;
|
|
9
13
|
/**
|
|
10
|
-
* @deprecated Use
|
|
14
|
+
* @deprecated Use agentName instead.
|
|
11
15
|
*/
|
|
12
16
|
assistantId?: string;
|
|
13
17
|
organizationId?: string;
|
|
@@ -56,4 +60,4 @@ export interface UseConversationMessagesResult {
|
|
|
56
60
|
clearMessages: () => void;
|
|
57
61
|
createConversation: (input?: CreateConversationInput) => Promise<Conversation>;
|
|
58
62
|
}
|
|
59
|
-
export declare function useConversationMessages({ client, podId, assistantName, assistantId, organizationId, conversationId, enabled, autoLoad, autoResume, limit, syncOnTurnEnd, onEvent, onStatus, onMessage, onError, }: UseConversationMessagesOptions): UseConversationMessagesResult;
|
|
63
|
+
export declare function useConversationMessages({ client, podId, agentName, assistantName, assistantId, organizationId, conversationId, enabled, autoLoad, autoResume, limit, syncOnTurnEnd, onEvent, onStatus, onMessage, onError, }: UseConversationMessagesOptions): UseConversationMessagesResult;
|
|
@@ -12,7 +12,7 @@ function isSettledStatus(status, isStreaming) {
|
|
|
12
12
|
return true;
|
|
13
13
|
return !isConversationRunningStatus(normalized);
|
|
14
14
|
}
|
|
15
|
-
export function useConversationMessages({ client, podId, assistantName, assistantId, organizationId, conversationId = null, enabled = true, autoLoad = true, autoResume = false, limit = 100, syncOnTurnEnd = false, onEvent, onStatus, onMessage, onError, }) {
|
|
15
|
+
export function useConversationMessages({ client, podId, agentName, assistantName, assistantId, organizationId, conversationId = null, enabled = true, autoLoad = true, autoResume = false, limit = 100, syncOnTurnEnd = false, onEvent, onStatus, onMessage, onError, }) {
|
|
16
16
|
const [nextPageToken, setNextPageToken] = useState(null);
|
|
17
17
|
const [isLoading, setIsLoading] = useState(false);
|
|
18
18
|
const [isLoadingOlder, setIsLoadingOlder] = useState(false);
|
|
@@ -21,6 +21,7 @@ export function useConversationMessages({ client, podId, assistantName, assistan
|
|
|
21
21
|
const { conversation: sessionConversation, conversationId: sessionConversationId, messages: sessionMessages, status, streamingText, isStreaming, error, refreshConversation, loadMessages, sendMessage, resume, resumeIfRunning, stop, cancel, clearMessages: clearSessionMessages, createConversation, } = useAssistantSession({
|
|
22
22
|
client,
|
|
23
23
|
podId,
|
|
24
|
+
agentName: agentName ?? assistantName ?? assistantId,
|
|
24
25
|
assistantName,
|
|
25
26
|
assistantId,
|
|
26
27
|
organizationId,
|
|
@@ -4,9 +4,13 @@ import { type CreateConversationInput } from "./useAssistantSession.js";
|
|
|
4
4
|
export interface UseConversationsOptions {
|
|
5
5
|
client: LemmaClient;
|
|
6
6
|
podId?: string;
|
|
7
|
+
agentName?: string;
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated Use agentName instead.
|
|
10
|
+
*/
|
|
7
11
|
assistantName?: string;
|
|
8
12
|
/**
|
|
9
|
-
* @deprecated Use
|
|
13
|
+
* @deprecated Use agentName instead.
|
|
10
14
|
*/
|
|
11
15
|
assistantId?: string;
|
|
12
16
|
organizationId?: string;
|
|
@@ -49,4 +53,4 @@ export interface UseConversationsResult {
|
|
|
49
53
|
createAndSelectConversation: (input?: Omit<CreateConversationInput, "setActive">) => Promise<Conversation>;
|
|
50
54
|
ensureConversation: (input?: Omit<CreateConversationInput, "setActive">) => Promise<Conversation>;
|
|
51
55
|
}
|
|
52
|
-
export declare function useConversations({ client, podId, assistantName, assistantId, organizationId, enabled, autoLoad, autoSelectFirst, limit, pageToken, initialConversationId, }: UseConversationsOptions): UseConversationsResult;
|
|
56
|
+
export declare function useConversations({ client, podId, agentName, assistantName, assistantId, organizationId, enabled, autoLoad, autoSelectFirst, limit, pageToken, initialConversationId, }: UseConversationsOptions): UseConversationsResult;
|