lemma-sdk 0.2.36 → 0.2.38
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 +45 -30
- package/dist/browser/lemma-client.js +224 -212
- package/dist/client.d.ts +1 -4
- package/dist/client.js +1 -6
- package/dist/index.d.ts +2 -5
- package/dist/index.js +1 -2
- package/dist/namespaces/agents.js +1 -1
- package/dist/namespaces/conversations.d.ts +68 -0
- package/dist/namespaces/conversations.js +159 -0
- package/dist/namespaces/files.d.ts +24 -6
- package/dist/namespaces/files.js +25 -12
- package/dist/namespaces/integrations.js +1 -1
- package/dist/namespaces/pod-surfaces.d.ts +1 -1
- package/dist/namespaces/pod-surfaces.js +6 -6
- package/dist/openapi_client/index.d.ts +17 -32
- package/dist/openapi_client/index.js +8 -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/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 +10 -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/MessageListResponse.d.ts +6 -0
- package/dist/openapi_client/models/{TaskMessageResponse.d.ts → MessageResponse.d.ts} +8 -7
- package/dist/openapi_client/models/OrganizationInvitationResponse.d.ts +1 -0
- package/dist/openapi_client/models/ReportFeedbackResponse.d.ts +0 -4
- 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/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 +87 -0
- package/dist/openapi_client/services/{ConversationsService.js → AgentConversationsService.js} +61 -72
- 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 +8 -8
- package/dist/openapi_client/services/AgentToolsService.js +8 -8
- package/dist/openapi_client/services/AgentsService.d.ts +7 -7
- package/dist/openapi_client/services/AgentsService.js +8 -8
- package/dist/openapi_client/services/FilesService.d.ts +17 -8
- package/dist/openapi_client/services/FilesService.js +25 -8
- package/dist/openapi_client/services/WorkflowsService.d.ts +1 -1
- package/dist/openapi_client/services/WorkflowsService.js +1 -1
- package/dist/react/index.d.ts +0 -8
- package/dist/react/index.js +0 -4
- package/dist/react/useAssistantController.d.ts +6 -2
- package/dist/react/useAssistantController.js +56 -15
- package/dist/react/useAssistantSession.d.ts +15 -5
- package/dist/react/useAssistantSession.js +24 -26
- 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 -5
- package/dist/run-utils.js +0 -10
- package/dist/types.d.ts +24 -10
- package/package.json +1 -1
- package/dist/namespaces/assistants.d.ts +0 -96
- package/dist/namespaces/assistants.js +0 -160
- package/dist/namespaces/tasks.d.ts +0 -29
- package/dist/namespaces/tasks.js +0 -49
- package/dist/openapi_client/models/AddMessageRequest.d.ts +0 -6
- 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/CreateAssistantRequest.js +0 -1
- package/dist/openapi_client/models/CreateMessageRequest.d.ts +0 -6
- package/dist/openapi_client/models/CreateMessageRequest.js +0 -1
- package/dist/openapi_client/models/CreateTaskRequest.d.ts +0 -10
- package/dist/openapi_client/models/CreateTaskRequest.js +0 -1
- package/dist/openapi_client/models/FileVisibility.d.ts +0 -4
- package/dist/openapi_client/models/FileVisibility.js +0 -9
- package/dist/openapi_client/models/TableAccessEntry.js +0 -1
- package/dist/openapi_client/models/TaskListResponse.d.ts +0 -9
- package/dist/openapi_client/models/TaskListResponse.js +0 -1
- package/dist/openapi_client/models/TaskMessageListResponse.d.ts +0 -9
- package/dist/openapi_client/models/TaskMessageListResponse.js +0 -1
- package/dist/openapi_client/models/TaskMessageResponse.js +0 -1
- 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/TasksService.d.ts +0 -76
- package/dist/openapi_client/services/TasksService.js +0 -167
- package/dist/react/useAgentRun.d.ts +0 -17
- package/dist/react/useAgentRun.js +0 -56
- package/dist/react/useAgentRuns.d.ts +0 -33
- package/dist/react/useAgentRuns.js +0 -149
- package/dist/react/useAssistantRun.d.ts +0 -27
- package/dist/react/useAssistantRun.js +0 -47
- package/dist/react/useTaskSession.d.ts +0 -35
- package/dist/react/useTaskSession.js +0 -269
- package/dist/task-events.d.ts +0 -8
- package/dist/task-events.js +0 -115
- /package/dist/openapi_client/models/{AddMessageRequest.js → AgentSurfaceListResponse.js} +0 -0
- /package/dist/openapi_client/models/{AssistantListResponse.js → AgentSurfaceResponse.js} +0 -0
- /package/dist/openapi_client/models/{AssistantResponse.js → MessageListResponse.js} +0 -0
- /package/dist/openapi_client/models/{AssistantSurfaceListResponse.js → MessageResponse.js} +0 -0
- /package/dist/openapi_client/models/{AssistantSurfaceResponse.js → SendMessageRequest.js} +0 -0
- /package/dist/openapi_client/models/{AvailableModelInfo.js → ToolCallContent.js} +0 -0
- /package/dist/openapi_client/models/{AvailableModelsListResponse.js → ToolReturnContent.js} +0 -0
- /package/dist/openapi_client/models/{ConversationMessageListResponse.js → app__modules__agent__domain__value_objects__TableAccessEntry.js} +0 -0
- /package/dist/openapi_client/models/{ConversationMessageResponse.js → app__modules__function__api__schemas__function_schemas__TableAccessEntry.js} +0 -0
|
@@ -257,7 +257,7 @@ export class WorkflowsService {
|
|
|
257
257
|
}
|
|
258
258
|
/**
|
|
259
259
|
* List Workflow Installs
|
|
260
|
-
* List the current user
|
|
260
|
+
* List workflow installations visible to the current user. `GLOBAL` workflows return the pod-level install; `USER` workflows return the current user's install.
|
|
261
261
|
* @param podId
|
|
262
262
|
* @param workflowName
|
|
263
263
|
* @returns WorkflowInstallListResponse Successful Response
|
package/dist/react/index.d.ts
CHANGED
|
@@ -2,18 +2,12 @@ export { AuthGuard } from "./AuthGuard.js";
|
|
|
2
2
|
export type { AuthGuardProps } from "./AuthGuard.js";
|
|
3
3
|
export { useAuth } from "./useAuth.js";
|
|
4
4
|
export type { UseAuthResult } from "./useAuth.js";
|
|
5
|
-
export { useAssistantRun } from "./useAssistantRun.js";
|
|
6
|
-
export type { UseAssistantRunOptions, UseAssistantRunResult } from "./useAssistantRun.js";
|
|
7
5
|
export { useConversations } from "./useConversations.js";
|
|
8
6
|
export type { UseConversationsOptions, UseConversationsResult } from "./useConversations.js";
|
|
9
7
|
export { useConversation } from "./useConversation.js";
|
|
10
8
|
export type { UseConversationOptions, UseConversationResult } from "./useConversation.js";
|
|
11
9
|
export { useConversationMessages } from "./useConversationMessages.js";
|
|
12
10
|
export type { UseConversationMessagesOptions, UseConversationMessagesResult, } from "./useConversationMessages.js";
|
|
13
|
-
export { useAgentRun } from "./useAgentRun.js";
|
|
14
|
-
export type { UseAgentRunOptions, UseAgentRunResult } from "./useAgentRun.js";
|
|
15
|
-
export { useAgentRuns } from "./useAgentRuns.js";
|
|
16
|
-
export type { UseAgentRunsOptions, UseAgentRunsResult } from "./useAgentRuns.js";
|
|
17
11
|
export { useAgentInputSchema } from "./useAgentInputSchema.js";
|
|
18
12
|
export type { UseAgentInputSchemaOptions, UseAgentInputSchemaResult, } from "./useAgentInputSchema.js";
|
|
19
13
|
export { useAssistantSession } from "./useAssistantSession.js";
|
|
@@ -92,8 +86,6 @@ export { useSchemaForm } from "./useSchemaForm.js";
|
|
|
92
86
|
export type { UseSchemaFormOptions, UseSchemaFormResult } from "./useSchemaForm.js";
|
|
93
87
|
export { useAssistantController } from "./useAssistantController.js";
|
|
94
88
|
export type { AssistantAction, AssistantConversationScope, AssistantMessagePart, AssistantRenderableMessage, AssistantToolInvocation, UseAssistantControllerOptions, UseAssistantControllerResult, } from "./useAssistantController.js";
|
|
95
|
-
export { useTaskSession } from "./useTaskSession.js";
|
|
96
|
-
export type { CreateTaskInput, UseTaskSessionOptions, UseTaskSessionResult, } from "./useTaskSession.js";
|
|
97
89
|
export { useFunctionSession } from "./useFunctionSession.js";
|
|
98
90
|
export type { UseFunctionSessionOptions, UseFunctionSessionResult, } from "./useFunctionSession.js";
|
|
99
91
|
export { useFunctionRun } from "./useFunctionRun.js";
|
package/dist/react/index.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
export { AuthGuard } from "./AuthGuard.js";
|
|
2
2
|
export { useAuth } from "./useAuth.js";
|
|
3
|
-
export { useAssistantRun } from "./useAssistantRun.js";
|
|
4
3
|
export { useConversations } from "./useConversations.js";
|
|
5
4
|
export { useConversation } from "./useConversation.js";
|
|
6
5
|
export { useConversationMessages } from "./useConversationMessages.js";
|
|
7
|
-
export { useAgentRun } from "./useAgentRun.js";
|
|
8
|
-
export { useAgentRuns } from "./useAgentRuns.js";
|
|
9
6
|
export { useAgentInputSchema } from "./useAgentInputSchema.js";
|
|
10
7
|
export { useAssistantSession } from "./useAssistantSession.js";
|
|
11
8
|
export { useAssistantRuntime } from "./useAssistantRuntime.js";
|
|
@@ -45,7 +42,6 @@ export { useRecordSchema } from "./useRecordSchema.js";
|
|
|
45
42
|
export { useRecordForm } from "./useRecordForm.js";
|
|
46
43
|
export { useSchemaForm } from "./useSchemaForm.js";
|
|
47
44
|
export { useAssistantController } from "./useAssistantController.js";
|
|
48
|
-
export { useTaskSession } from "./useTaskSession.js";
|
|
49
45
|
export { useFunctionSession } from "./useFunctionSession.js";
|
|
50
46
|
export { useFunctionRun } from "./useFunctionRun.js";
|
|
51
47
|
export { useFunctionRuns } from "./useFunctionRuns.js";
|
|
@@ -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,14 +1050,13 @@ 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
|
-
createIfMissing: false,
|
|
1026
1060
|
});
|
|
1027
1061
|
touchConversation(finalConversationId, { updated_at: new Date().toISOString() });
|
|
1028
1062
|
}
|
|
@@ -1038,12 +1072,12 @@ export function useAssistantController({ client, podId, assistantName, assistant
|
|
|
1038
1072
|
}, [
|
|
1039
1073
|
activeConversationId,
|
|
1040
1074
|
appendOptimisticUserMessage,
|
|
1041
|
-
client.resources,
|
|
1042
1075
|
enabled,
|
|
1043
1076
|
ensureConversation,
|
|
1044
1077
|
isStreaming,
|
|
1045
1078
|
pendingFiles,
|
|
1046
1079
|
resetConversationState,
|
|
1080
|
+
scope.podId,
|
|
1047
1081
|
sessionIsStreaming,
|
|
1048
1082
|
sessionSendMessage,
|
|
1049
1083
|
touchConversation,
|
|
@@ -1061,9 +1095,13 @@ export function useAssistantController({ client, podId, assistantName, assistant
|
|
|
1061
1095
|
}
|
|
1062
1096
|
setIsUploadingFiles(true);
|
|
1063
1097
|
try {
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
}
|
|
1098
|
+
const fileClient = resolveScopedClient(client, scope.podId);
|
|
1099
|
+
const uploadedFiles = await uploadPersonalFiles(fileClient, normalizedFiles);
|
|
1100
|
+
const fileMessage = `Personal files available to this run:\n${formatPersonalFileReferences(uploadedFiles)}`;
|
|
1101
|
+
setIsStreaming(true);
|
|
1102
|
+
await sessionSendMessage(fileMessage, {
|
|
1103
|
+
conversationId: activeId,
|
|
1104
|
+
});
|
|
1067
1105
|
await loadConversationMessages(activeId);
|
|
1068
1106
|
touchConversation(activeId, { updated_at: new Date().toISOString() });
|
|
1069
1107
|
}
|
|
@@ -1072,15 +1110,18 @@ export function useAssistantController({ client, podId, assistantName, assistant
|
|
|
1072
1110
|
throw err;
|
|
1073
1111
|
}
|
|
1074
1112
|
finally {
|
|
1113
|
+
setIsStreaming(false);
|
|
1075
1114
|
setIsUploadingFiles(false);
|
|
1076
1115
|
}
|
|
1077
1116
|
}, [
|
|
1078
|
-
client
|
|
1117
|
+
client,
|
|
1079
1118
|
enabled,
|
|
1080
1119
|
isLoading,
|
|
1081
1120
|
isUploadingFiles,
|
|
1082
1121
|
loadConversationMessages,
|
|
1083
1122
|
queuePendingFiles,
|
|
1123
|
+
scope.podId,
|
|
1124
|
+
sessionSendMessage,
|
|
1084
1125
|
touchConversation,
|
|
1085
1126
|
]);
|
|
1086
1127
|
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;
|
|
@@ -42,8 +54,6 @@ export interface CreateConversationInput {
|
|
|
42
54
|
}
|
|
43
55
|
export interface SendAssistantMessageOptions {
|
|
44
56
|
conversationId?: string | null;
|
|
45
|
-
createIfMissing?: boolean;
|
|
46
|
-
createConversation?: CreateConversationInput;
|
|
47
57
|
syncOnTurnEnd?: boolean;
|
|
48
58
|
}
|
|
49
59
|
export interface ResumeAssistantOptions {
|
|
@@ -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 conversation.");
|
|
342
346
|
setError(normalized);
|
|
343
347
|
onErrorRef.current?.(streamError);
|
|
344
348
|
}
|
|
@@ -358,7 +362,7 @@ export function useAssistantSession(options) {
|
|
|
358
362
|
setConversationStatus,
|
|
359
363
|
syncOnTurnEnd,
|
|
360
364
|
]);
|
|
361
|
-
const ensureConversation = useCallback(async (overrideConversationId
|
|
365
|
+
const ensureConversation = useCallback(async (overrideConversationId) => {
|
|
362
366
|
const existingId = overrideConversationId ?? conversationId;
|
|
363
367
|
if (existingId) {
|
|
364
368
|
// Avoid a network roundtrip on every send when we already have this conversation in state.
|
|
@@ -370,23 +374,17 @@ export function useAssistantSession(options) {
|
|
|
370
374
|
return existing;
|
|
371
375
|
throw new Error("Failed to resolve existing conversation.");
|
|
372
376
|
}
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
}
|
|
376
|
-
return createConversation({
|
|
377
|
-
...(options.createConversation ?? {}),
|
|
378
|
-
setActive: true,
|
|
379
|
-
});
|
|
380
|
-
}, [conversation, conversationId, createConversation, refreshConversation]);
|
|
377
|
+
throw new Error("conversationId is required. Create a conversation before sending a message.");
|
|
378
|
+
}, [conversation, conversationId, refreshConversation]);
|
|
381
379
|
const sendMessage = useCallback(async (content, input = {}) => {
|
|
382
380
|
setError(null);
|
|
383
381
|
try {
|
|
384
|
-
const resolvedConversation = await ensureConversation(input.conversationId
|
|
382
|
+
const resolvedConversation = await ensureConversation(input.conversationId);
|
|
385
383
|
const resolvedConversationId = requireConversationId(resolvedConversation.id);
|
|
386
384
|
cancel();
|
|
387
385
|
const controller = new AbortController();
|
|
388
386
|
abortRef.current = controller;
|
|
389
|
-
const scope = normalizeScope(client, defaultScope
|
|
387
|
+
const scope = normalizeScope(client, defaultScope);
|
|
390
388
|
const scopedClient = applyPodScope(client, scope.podId);
|
|
391
389
|
const stream = await scopedClient.conversations.sendMessageStream(resolvedConversationId, { content }, {
|
|
392
390
|
pod_id: scope.podId ?? undefined,
|
|
@@ -402,7 +400,7 @@ export function useAssistantSession(options) {
|
|
|
402
400
|
return resolvedConversation;
|
|
403
401
|
}
|
|
404
402
|
catch (sendError) {
|
|
405
|
-
const normalized = normalizeError(sendError, "Failed to send
|
|
403
|
+
const normalized = normalizeError(sendError, "Failed to send agent message.");
|
|
406
404
|
setError(normalized);
|
|
407
405
|
onErrorRef.current?.(sendError);
|
|
408
406
|
throw normalized;
|
|
@@ -434,7 +432,7 @@ export function useAssistantSession(options) {
|
|
|
434
432
|
});
|
|
435
433
|
}
|
|
436
434
|
catch (resumeError) {
|
|
437
|
-
const normalized = normalizeError(resumeError, "Failed to resume
|
|
435
|
+
const normalized = normalizeError(resumeError, "Failed to resume conversation.");
|
|
438
436
|
setError(normalized);
|
|
439
437
|
onErrorRef.current?.(resumeError);
|
|
440
438
|
throw normalized;
|
|
@@ -487,7 +485,7 @@ export function useAssistantSession(options) {
|
|
|
487
485
|
clearStreamingText();
|
|
488
486
|
}
|
|
489
487
|
catch (stopError) {
|
|
490
|
-
const normalized = normalizeError(stopError, "Failed to stop
|
|
488
|
+
const normalized = normalizeError(stopError, "Failed to stop conversation.");
|
|
491
489
|
setError(normalized);
|
|
492
490
|
onErrorRef.current?.(stopError);
|
|
493
491
|
throw normalized;
|
|
@@ -536,7 +534,7 @@ export function useAssistantSession(options) {
|
|
|
536
534
|
.catch((bootstrapError) => {
|
|
537
535
|
if (cancelled)
|
|
538
536
|
return;
|
|
539
|
-
const normalized = normalizeError(bootstrapError, "Failed to load
|
|
537
|
+
const normalized = normalizeError(bootstrapError, "Failed to load agent conversation.");
|
|
540
538
|
setError(normalized);
|
|
541
539
|
onErrorRef.current?.(bootstrapError);
|
|
542
540
|
})
|
|
@@ -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;
|
|
@@ -8,7 +8,7 @@ function sortConversationsByUpdatedAt(conversations) {
|
|
|
8
8
|
return bTime - aTime;
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
|
-
export function useConversations({ client, podId, assistantName, assistantId, organizationId, enabled = true, autoLoad = true, autoSelectFirst = true, limit = 20, pageToken, initialConversationId = null, }) {
|
|
11
|
+
export function useConversations({ client, podId, agentName, assistantName, assistantId, organizationId, enabled = true, autoLoad = true, autoSelectFirst = true, limit = 20, pageToken, initialConversationId = null, }) {
|
|
12
12
|
const [conversations, setConversations] = useState([]);
|
|
13
13
|
const [total, setTotal] = useState(0);
|
|
14
14
|
const [nextPageToken, setNextPageToken] = useState(null);
|
|
@@ -17,13 +17,15 @@ export function useConversations({ client, podId, assistantName, assistantId, or
|
|
|
17
17
|
const [isLoadingMore, setIsLoadingMore] = useState(false);
|
|
18
18
|
const scopeKey = useMemo(() => JSON.stringify({
|
|
19
19
|
podId: podId ?? null,
|
|
20
|
-
|
|
20
|
+
agentName: agentName ?? assistantName ?? assistantId ?? null,
|
|
21
|
+
assistantName: assistantName ?? null,
|
|
21
22
|
assistantId: assistantId ?? null,
|
|
22
23
|
organizationId: organizationId ?? null,
|
|
23
|
-
}), [assistantId, assistantName, organizationId, podId]);
|
|
24
|
+
}), [agentName, assistantId, assistantName, organizationId, podId]);
|
|
24
25
|
const { error, listConversations, createConversation: sessionCreateConversation, } = useAssistantSession({
|
|
25
26
|
client,
|
|
26
27
|
podId,
|
|
28
|
+
agentName: agentName ?? assistantName ?? assistantId,
|
|
27
29
|
assistantName,
|
|
28
30
|
assistantId,
|
|
29
31
|
organizationId,
|
|
@@ -90,7 +92,7 @@ export function useConversations({ client, podId, assistantName, assistantId, or
|
|
|
90
92
|
const createdConversation = await sessionCreateConversation({
|
|
91
93
|
...input,
|
|
92
94
|
podId: input.podId ?? podId ?? undefined,
|
|
93
|
-
|
|
95
|
+
agentName: input.agentName ?? input.assistantName ?? agentName ?? assistantName ?? assistantId ?? undefined,
|
|
94
96
|
organizationId: input.organizationId ?? organizationId ?? undefined,
|
|
95
97
|
setActive: input.setActive ?? true,
|
|
96
98
|
});
|
|
@@ -106,7 +108,7 @@ export function useConversations({ client, podId, assistantName, assistantId, or
|
|
|
106
108
|
setSelectedConversationId(createdConversation.id);
|
|
107
109
|
}
|
|
108
110
|
return createdConversation;
|
|
109
|
-
}, [assistantId, assistantName, organizationId, podId, sessionCreateConversation]);
|
|
111
|
+
}, [agentName, assistantId, assistantName, organizationId, podId, sessionCreateConversation]);
|
|
110
112
|
const createAndSelectConversation = useCallback(async (input = {}) => {
|
|
111
113
|
return createConversation({
|
|
112
114
|
...input,
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import type { LemmaClient } from "../client.js";
|
|
2
|
-
import type { FileResponse } from "../types.js";
|
|
2
|
+
import type { DatastoreFileNamespace, FileResponse } from "../types.js";
|
|
3
3
|
export interface CreateFolderInput {
|
|
4
4
|
directoryPath?: string;
|
|
5
5
|
parentId?: string;
|
|
6
6
|
description?: string;
|
|
7
|
+
namespace?: DatastoreFileNamespace | null;
|
|
7
8
|
}
|
|
8
9
|
export interface UseCreateFolderOptions {
|
|
9
10
|
client: LemmaClient;
|
|
10
11
|
podId?: string;
|
|
12
|
+
namespace?: DatastoreFileNamespace | null;
|
|
11
13
|
enabled?: boolean;
|
|
12
14
|
onSuccess?: (folder: FileResponse) => void;
|
|
13
15
|
onError?: (error: unknown) => void;
|
|
@@ -19,4 +21,4 @@ export interface UseCreateFolderResult<TFile extends FileResponse = FileResponse
|
|
|
19
21
|
createFolder: (name: string, options?: CreateFolderInput) => Promise<TFile | null>;
|
|
20
22
|
reset: () => void;
|
|
21
23
|
}
|
|
22
|
-
export declare function useCreateFolder<TFile extends FileResponse = FileResponse>({ client, podId, enabled, onSuccess, onError, }: UseCreateFolderOptions): UseCreateFolderResult<TFile>;
|
|
24
|
+
export declare function useCreateFolder<TFile extends FileResponse = FileResponse>({ client, podId, namespace, enabled, onSuccess, onError, }: UseCreateFolderOptions): UseCreateFolderResult<TFile>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
2
2
|
import { normalizeError, resolvePodClient } from "./utils.js";
|
|
3
|
-
export function useCreateFolder({ client, podId, enabled = true, onSuccess, onError, }) {
|
|
3
|
+
export function useCreateFolder({ client, podId, namespace, enabled = true, onSuccess, onError, }) {
|
|
4
4
|
const [createdFolder, setCreatedFolder] = useState(null);
|
|
5
5
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
6
6
|
const [error, setError] = useState(null);
|
|
@@ -17,7 +17,10 @@ export function useCreateFolder({ client, podId, enabled = true, onSuccess, onEr
|
|
|
17
17
|
setError(null);
|
|
18
18
|
try {
|
|
19
19
|
const scopedClient = resolvePodClient(client, podId);
|
|
20
|
-
const nextFolder = await scopedClient.files.folder.create(trimmedName,
|
|
20
|
+
const nextFolder = await scopedClient.files.folder.create(trimmedName, {
|
|
21
|
+
...options,
|
|
22
|
+
namespace: options.namespace ?? namespace,
|
|
23
|
+
});
|
|
21
24
|
setCreatedFolder(nextFolder);
|
|
22
25
|
onSuccessRef.current?.(nextFolder);
|
|
23
26
|
return nextFolder;
|
|
@@ -31,7 +34,7 @@ export function useCreateFolder({ client, podId, enabled = true, onSuccess, onEr
|
|
|
31
34
|
finally {
|
|
32
35
|
setIsSubmitting(false);
|
|
33
36
|
}
|
|
34
|
-
}, [client, enabled, podId]);
|
|
37
|
+
}, [client, enabled, namespace, podId]);
|
|
35
38
|
const reset = useCallback(() => {
|
|
36
39
|
setCreatedFolder(null);
|
|
37
40
|
setError(null);
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { LemmaClient } from "../client.js";
|
|
2
|
+
import type { DatastoreFileNamespace } from "../types.js";
|
|
2
3
|
export interface UseDeleteFileOptions {
|
|
3
4
|
client: LemmaClient;
|
|
4
5
|
podId?: string;
|
|
5
6
|
path?: string | null;
|
|
7
|
+
namespace?: DatastoreFileNamespace | null;
|
|
6
8
|
enabled?: boolean;
|
|
7
9
|
onSuccess?: (path: string) => void;
|
|
8
10
|
onError?: (error: unknown) => void;
|
|
@@ -13,7 +15,8 @@ export interface UseDeleteFileResult {
|
|
|
13
15
|
error: Error | null;
|
|
14
16
|
remove: (overrides?: {
|
|
15
17
|
path?: string | null;
|
|
18
|
+
namespace?: DatastoreFileNamespace | null;
|
|
16
19
|
}) => Promise<boolean>;
|
|
17
20
|
reset: () => void;
|
|
18
21
|
}
|
|
19
|
-
export declare function useDeleteFile({ client, podId, path, enabled, onSuccess, onError, }: UseDeleteFileOptions): UseDeleteFileResult;
|
|
22
|
+
export declare function useDeleteFile({ client, podId, path, namespace, enabled, onSuccess, onError, }: UseDeleteFileOptions): UseDeleteFileResult;
|