lemma-sdk 0.2.44 → 0.2.46
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 +1 -1
- package/dist/assistant-events.d.ts +1 -0
- package/dist/assistant-events.js +37 -2
- package/dist/browser/lemma-client.js +312 -228
- package/dist/client.js +1 -1
- package/dist/config.d.ts +2 -2
- package/dist/config.js +2 -2
- package/dist/hey_client/client/client.gen.d.ts +2 -0
- package/dist/hey_client/client/client.gen.js +216 -0
- package/dist/hey_client/client/index.d.ts +10 -0
- package/dist/hey_client/client/index.js +6 -0
- package/dist/hey_client/client/types.gen.d.ts +120 -0
- package/dist/hey_client/client/types.gen.js +2 -0
- package/dist/hey_client/client/utils.gen.d.ts +37 -0
- package/dist/hey_client/client/utils.gen.js +228 -0
- package/dist/hey_client/client.gen.d.ts +12 -0
- package/dist/hey_client/client.gen.js +3 -0
- package/dist/hey_client/core/auth.gen.d.ts +25 -0
- package/dist/hey_client/core/auth.gen.js +14 -0
- package/dist/hey_client/core/bodySerializer.gen.d.ts +25 -0
- package/dist/hey_client/core/bodySerializer.gen.js +57 -0
- package/dist/hey_client/core/params.gen.d.ts +43 -0
- package/dist/hey_client/core/params.gen.js +100 -0
- package/dist/hey_client/core/pathSerializer.gen.d.ts +33 -0
- package/dist/hey_client/core/pathSerializer.gen.js +106 -0
- package/dist/hey_client/core/queryKeySerializer.gen.d.ts +18 -0
- package/dist/hey_client/core/queryKeySerializer.gen.js +92 -0
- package/dist/hey_client/core/serverSentEvents.gen.d.ts +71 -0
- package/dist/hey_client/core/serverSentEvents.gen.js +132 -0
- package/dist/hey_client/core/types.gen.d.ts +83 -0
- package/dist/hey_client/core/types.gen.js +2 -0
- package/dist/hey_client/core/utils.gen.d.ts +19 -0
- package/dist/hey_client/core/utils.gen.js +87 -0
- package/dist/hey_client/index.d.ts +2 -0
- package/dist/hey_client/index.js +2 -0
- package/dist/hey_client/sdk.gen.d.ts +1005 -0
- package/dist/hey_client/sdk.gen.js +1438 -0
- package/dist/hey_client/types.gen.d.ts +12992 -0
- package/dist/hey_client/types.gen.js +2 -0
- package/dist/namespaces/conversations.d.ts +2 -2
- package/dist/namespaces/files.d.ts +6 -24
- package/dist/namespaces/files.js +6 -16
- package/dist/namespaces/integrations.d.ts +2 -4
- package/dist/namespaces/integrations.js +6 -6
- package/dist/namespaces/pod-surfaces.d.ts +8 -3
- package/dist/namespaces/pod-surfaces.js +15 -6
- package/dist/namespaces/pods.d.ts +2 -3
- package/dist/namespaces/pods.js +1 -6
- package/dist/namespaces/records.d.ts +10 -16
- package/dist/namespaces/records.js +4 -33
- package/dist/namespaces/resource-access.d.ts +3 -3
- package/dist/namespaces/resource-access.js +6 -6
- package/dist/namespaces/schedules.d.ts +1 -0
- package/dist/namespaces/schedules.js +1 -1
- package/dist/namespaces/tables.d.ts +2 -2
- package/dist/namespaces/workflows.d.ts +12 -8
- package/dist/namespaces/workflows.js +9 -18
- package/dist/openapi_client/index.d.ts +23 -42
- package/dist/openapi_client/index.js +5 -11
- package/dist/openapi_client/models/AgentHarnessInfo.d.ts +2 -0
- package/dist/openapi_client/models/AgentNode.d.ts +1 -1
- package/dist/openapi_client/models/AgentNodeConfig.d.ts +1 -1
- package/dist/openapi_client/models/AgentResourcePermissionRequest.d.ts +1 -1
- package/dist/openapi_client/models/AgentResourcePermissionResponse.d.ts +1 -1
- package/dist/openapi_client/models/AgentRuntimeProfileResponse.d.ts +6 -0
- package/dist/openapi_client/models/AgentSurfaceResponse.d.ts +6 -17
- package/dist/openapi_client/models/AgentSurfaceStatus.d.ts +3 -1
- package/dist/openapi_client/models/AgentSurfaceStatus.js +2 -0
- package/dist/openapi_client/models/AgentToolset.d.ts +2 -1
- package/dist/openapi_client/models/AgentToolset.js +1 -0
- package/dist/openapi_client/models/AppTriggerResponseSchema.d.ts +2 -0
- package/dist/openapi_client/models/ApplicationSkillResponse.d.ts +6 -0
- package/dist/openapi_client/models/ApprovalDecisionResponse.d.ts +6 -0
- package/dist/openapi_client/models/AuthProvider.d.ts +4 -0
- package/dist/openapi_client/models/AuthProvider.js +9 -0
- package/dist/openapi_client/models/ConnectedAccountSummary.d.ts +7 -0
- package/dist/openapi_client/models/CreateFunctionRequest.d.ts +0 -1
- package/dist/openapi_client/models/CreateScheduleRequest.d.ts +4 -0
- package/dist/openapi_client/models/CreateSurfaceRequest.d.ts +3 -10
- package/dist/openapi_client/models/CreateUserDaemonRuntimeProfileRequest.d.ts +2 -0
- package/dist/openapi_client/models/DataStoreFlowStartInput.d.ts +1 -1
- package/dist/openapi_client/models/DataStoreFlowStartOutput.d.ts +1 -1
- package/dist/openapi_client/models/DatastoreCountResponse.d.ts +6 -0
- package/dist/openapi_client/models/DecisionNode.d.ts +2 -1
- package/dist/openapi_client/models/DecisionRule.d.ts +3 -0
- package/dist/openapi_client/models/EndNode.d.ts +1 -1
- package/dist/openapi_client/models/ExpressionInputBinding.d.ts +6 -2
- package/dist/openapi_client/models/FileListResponse.d.ts +1 -0
- package/dist/openapi_client/models/FileSearchResponse.d.ts +2 -2
- package/dist/openapi_client/models/FlowRunStatus.d.ts +5 -1
- package/dist/openapi_client/models/FlowRunStatus.js +5 -1
- package/dist/openapi_client/models/FormNode.d.ts +2 -1
- package/dist/openapi_client/models/FormNodeConfig.d.ts +1 -1
- package/dist/openapi_client/models/FunctionNode.d.ts +2 -1
- package/dist/openapi_client/models/FunctionResourcePermissionRequest.d.ts +1 -1
- package/dist/openapi_client/models/FunctionResourcePermissionResponse.d.ts +1 -1
- package/dist/openapi_client/models/InstalledAppSummary.d.ts +7 -0
- package/dist/openapi_client/models/IntegrationStatusResponse.d.ts +6 -0
- package/dist/openapi_client/models/LoopNode.d.ts +2 -1
- package/dist/openapi_client/models/LoopNodeConfig.d.ts +3 -3
- package/dist/openapi_client/models/MessageKind.d.ts +14 -0
- package/dist/openapi_client/models/MessageKind.js +19 -0
- package/dist/openapi_client/models/MessageResponse.d.ts +5 -6
- package/dist/openapi_client/models/PodMemberAddRequest.d.ts +1 -3
- package/dist/openapi_client/models/PodMemberDetailResponse.d.ts +0 -2
- package/dist/openapi_client/models/PodMemberResponse.d.ts +0 -2
- package/dist/openapi_client/models/PodMemberUpdateRoleRequest.d.ts +1 -3
- package/dist/openapi_client/models/PodRoleResourcePermissionRequest.d.ts +1 -1
- package/dist/openapi_client/models/PodRoleResourcePermissionResponse.d.ts +1 -1
- package/dist/openapi_client/models/ResourceAccessGrantResponse.d.ts +1 -1
- package/dist/openapi_client/models/ResourceAccessResponse.d.ts +1 -1
- package/dist/openapi_client/models/RuntimeProfileScope.d.ts +2 -1
- package/dist/openapi_client/models/RuntimeProfileScope.js +1 -0
- package/dist/openapi_client/models/ScheduleDetailResponse.d.ts +6 -0
- package/dist/openapi_client/models/ScheduleFireStatus.d.ts +8 -0
- package/dist/openapi_client/models/ScheduleFireStatus.js +13 -0
- package/dist/openapi_client/models/StepRecordResponse.d.ts +10 -0
- package/dist/openapi_client/models/StepStatus.d.ts +7 -0
- package/dist/openapi_client/models/StepStatus.js +12 -0
- package/dist/openapi_client/models/SurfaceBehaviorConfigInput.d.ts +4 -0
- package/dist/openapi_client/models/SurfaceChannelRouteInput.d.ts +6 -0
- package/dist/openapi_client/models/SurfaceChannelRouteResponse.d.ts +6 -0
- package/dist/openapi_client/models/SurfaceConfigResponse.d.ts +10 -0
- package/dist/openapi_client/models/SurfaceCredentialMode.d.ts +4 -0
- package/dist/openapi_client/models/SurfaceCredentialMode.js +9 -0
- package/dist/openapi_client/models/SurfaceIdentityConfigInput.d.ts +4 -0
- package/dist/openapi_client/models/SurfaceIdentityConfigResponse.d.ts +4 -0
- package/dist/openapi_client/models/SurfaceSetupStatusResponse.d.ts +10 -0
- package/dist/openapi_client/models/TableListResponse.d.ts +2 -0
- package/dist/openapi_client/models/ToggleSurfaceRequest.d.ts +1 -1
- package/dist/openapi_client/models/UpdateScheduleRequest.d.ts +1 -0
- package/dist/openapi_client/models/UpdateSurfaceChannelsRequest.d.ts +4 -0
- package/dist/openapi_client/models/UpdateSurfaceRequest.d.ts +4 -11
- package/dist/openapi_client/models/UpsertSurfaceRequest.d.ts +9 -0
- package/dist/openapi_client/models/UserProfileRequest.d.ts +1 -0
- package/dist/openapi_client/models/UserResponse.d.ts +1 -0
- package/dist/openapi_client/models/WaitUntilNode.d.ts +1 -1
- package/dist/openapi_client/models/WorkflowCreateRequest.d.ts +16 -0
- package/dist/openapi_client/models/WorkflowRunFormSubmitRequest.d.ts +13 -0
- package/dist/openapi_client/models/WorkflowRunResponse.d.ts +28 -0
- package/dist/openapi_client/models/WorkflowRunSummaryResponse.d.ts +2 -3
- package/dist/openapi_client/models/WorkflowRunWaitAssignment.d.ts +4 -4
- package/dist/openapi_client/models/{WorkflowRunWaitEntity.d.ts → WorkflowRunWaitResponse.d.ts} +4 -8
- package/dist/openapi_client/models/WorkflowRunWaitType.d.ts +1 -2
- package/dist/openapi_client/models/WorkflowRunWaitType.js +0 -1
- package/dist/openapi_client/models/WorkspaceAppAccessRequest.d.ts +0 -3
- package/dist/openapi_client/models/WorkspaceMeSandbox.d.ts +1 -4
- package/dist/openapi_client/services/AgentConversationsService.d.ts +5 -5
- package/dist/openapi_client/services/AgentConversationsService.js +3 -3
- package/dist/openapi_client/services/AgentSurfacesService.d.ts +39 -10
- package/dist/openapi_client/services/AgentSurfacesService.js +86 -20
- package/dist/openapi_client/services/ApplicationsService.d.ts +29 -19
- package/dist/openapi_client/services/ApplicationsService.js +63 -36
- package/dist/openapi_client/services/FilesService.d.ts +2 -3
- package/dist/openapi_client/services/FilesService.js +1 -1
- package/dist/openapi_client/services/FunctionsService.d.ts +1 -1
- package/dist/openapi_client/services/FunctionsService.js +1 -1
- package/dist/openapi_client/services/IntegrationsService.d.ts +12 -4
- package/dist/openapi_client/services/IntegrationsService.js +22 -4
- package/dist/openapi_client/services/PodResourceAccessService.d.ts +6 -6
- package/dist/openapi_client/services/PodResourceAccessService.js +12 -12
- package/dist/openapi_client/services/RecordsService.d.ts +22 -25
- package/dist/openapi_client/services/RecordsService.js +14 -18
- package/dist/openapi_client/services/SchedulesService.d.ts +2 -1
- package/dist/openapi_client/services/SchedulesService.js +3 -1
- package/dist/openapi_client/services/TablesService.d.ts +4 -5
- package/dist/openapi_client/services/TablesService.js +2 -2
- package/dist/openapi_client/services/WorkflowsService.d.ts +35 -26
- package/dist/openapi_client/services/WorkflowsService.js +57 -39
- package/dist/react/assistant-output.d.ts +6 -0
- package/dist/react/assistant-output.js +16 -0
- package/dist/react/useAddPodMember.js +1 -1
- package/dist/react/useAssistantController.d.ts +9 -1
- package/dist/react/useAssistantController.js +92 -251
- package/dist/react/useAssistantRuntime.js +6 -17
- package/dist/react/useAssistantSession.d.ts +5 -2
- package/dist/react/useAssistantSession.js +47 -7
- package/dist/react/useBulkRecords.d.ts +5 -5
- package/dist/react/useBulkRecords.js +5 -5
- package/dist/react/useConversationMessages.d.ts +2 -2
- package/dist/react/useConversationMessages.js +3 -5
- package/dist/react/useCreateFolder.d.ts +2 -4
- package/dist/react/useCreateFolder.js +2 -3
- package/dist/react/useCreateRecord.d.ts +2 -2
- package/dist/react/useCreateRecord.js +1 -1
- package/dist/react/useDeleteFile.d.ts +1 -4
- package/dist/react/useDeleteFile.js +3 -3
- package/dist/react/useDeleteRecord.d.ts +1 -2
- package/dist/react/useDeleteRecord.js +3 -3
- package/dist/react/useFile.d.ts +2 -4
- package/dist/react/useFile.js +3 -3
- package/dist/react/useFilePreview.d.ts +1 -4
- package/dist/react/useFilePreview.js +4 -5
- package/dist/react/useFileSearch.d.ts +5 -1
- package/dist/react/useFileSearch.js +6 -4
- package/dist/react/useFileTree.d.ts +2 -4
- package/dist/react/useFileTree.js +2 -3
- package/dist/react/useFiles.d.ts +2 -4
- package/dist/react/useFiles.js +3 -5
- package/dist/react/useFlowSession.d.ts +3 -1
- package/dist/react/useFlowSession.js +24 -17
- package/dist/react/useGlobalSearch.js +1 -1
- package/dist/react/useRecord.d.ts +2 -2
- package/dist/react/useRecord.js +1 -1
- package/dist/react/useRecordForm.d.ts +2 -2
- package/dist/react/useRecordForm.js +2 -2
- package/dist/react/useRecords.d.ts +1 -1
- package/dist/react/useRecords.js +2 -13
- package/dist/react/useReferencingRecords.d.ts +4 -6
- package/dist/react/useReferencingRecords.js +5 -5
- package/dist/react/useReverseRelatedRecords.d.ts +3 -4
- package/dist/react/useReverseRelatedRecords.js +6 -6
- package/dist/react/useUpdateFile.d.ts +2 -4
- package/dist/react/useUpdateFile.js +2 -3
- package/dist/react/useUpdateRecord.d.ts +2 -2
- package/dist/react/useUpdateRecord.js +1 -1
- package/dist/react/useUploadFile.d.ts +2 -4
- package/dist/react/useUploadFile.js +2 -3
- package/dist/react/useWorkflowResume.d.ts +1 -0
- package/dist/react/useWorkflowResume.js +10 -1
- package/dist/react/useWorkflowRun.js +1 -3
- package/dist/react/useWorkflowStart.js +11 -26
- package/dist/react/utils.js +2 -0
- package/dist/types.d.ts +15 -9
- package/package.json +7 -2
- package/dist/openapi_client/models/BillingHistoryResponse.d.ts +0 -8
- package/dist/openapi_client/models/BillingInterval.d.ts +0 -7
- package/dist/openapi_client/models/BillingInterval.js +0 -12
- package/dist/openapi_client/models/BillingInvoiceResponse.d.ts +0 -27
- package/dist/openapi_client/models/BillingInvoiceStatus.d.ts +0 -10
- package/dist/openapi_client/models/BillingInvoiceStatus.js +0 -15
- package/dist/openapi_client/models/CancelSubscriptionResponse.d.ts +0 -10
- package/dist/openapi_client/models/CreateInvoicePaymentUrlRequest.d.ts +0 -7
- package/dist/openapi_client/models/CreateInvoicePaymentUrlResponse.d.ts +0 -8
- package/dist/openapi_client/models/DatastoreMessageResponse.d.ts +0 -6
- package/dist/openapi_client/models/DeskServingConfigResponse.d.ts +0 -11
- package/dist/openapi_client/models/DeskServingConfigResponse.js +0 -8
- package/dist/openapi_client/models/FlowRunEntity.d.ts +0 -36
- package/dist/openapi_client/models/GmailSurfaceConfig.d.ts +0 -7
- package/dist/openapi_client/models/NotificationContent.d.ts +0 -4
- package/dist/openapi_client/models/OutlookSurfaceConfig.d.ts +0 -7
- package/dist/openapi_client/models/PlanListResponse.d.ts +0 -8
- package/dist/openapi_client/models/PlanResponse.d.ts +0 -18
- package/dist/openapi_client/models/PlanType.d.ts +0 -7
- package/dist/openapi_client/models/PlanType.js +0 -12
- package/dist/openapi_client/models/RecordResponse.d.ts +0 -9
- package/dist/openapi_client/models/SeatInfoResponse.d.ts +0 -10
- package/dist/openapi_client/models/SlackSurfaceConfig.d.ts +0 -7
- package/dist/openapi_client/models/StackFrame.d.ts +0 -11
- package/dist/openapi_client/models/StartSubscriptionRequest.d.ts +0 -14
- package/dist/openapi_client/models/StartSubscriptionResponse.d.ts +0 -9
- package/dist/openapi_client/models/StartTeamBillingRequest.d.ts +0 -6
- package/dist/openapi_client/models/StartTeamBillingRequest.js +0 -1
- package/dist/openapi_client/models/StepExecution.d.ts +0 -13
- package/dist/openapi_client/models/StepExecution.js +0 -1
- package/dist/openapi_client/models/SubscriptionResponse.d.ts +0 -22
- package/dist/openapi_client/models/SubscriptionResponse.js +0 -1
- package/dist/openapi_client/models/SubscriptionStatus.d.ts +0 -10
- package/dist/openapi_client/models/SubscriptionStatus.js +0 -15
- package/dist/openapi_client/models/SubscriptionStatusResponse.d.ts +0 -10
- package/dist/openapi_client/models/SubscriptionStatusResponse.js +0 -1
- package/dist/openapi_client/models/SubscriptionWithPlanResponse.d.ts +0 -22
- package/dist/openapi_client/models/SubscriptionWithPlanResponse.js +0 -1
- package/dist/openapi_client/models/SurfaceEventMode.d.ts +0 -6
- package/dist/openapi_client/models/SurfaceEventMode.js +0 -11
- package/dist/openapi_client/models/SurfaceMode.d.ts +0 -5
- package/dist/openapi_client/models/SurfaceMode.js +0 -10
- package/dist/openapi_client/models/SurfaceRoutingScope.d.ts +0 -4
- package/dist/openapi_client/models/SurfaceRoutingScope.js +0 -9
- package/dist/openapi_client/models/TeamsSurfaceConfig.d.ts +0 -7
- package/dist/openapi_client/models/TeamsSurfaceConfig.js +0 -1
- package/dist/openapi_client/models/TelegramSurfaceConfig.d.ts +0 -7
- package/dist/openapi_client/models/TelegramSurfaceConfig.js +0 -1
- package/dist/openapi_client/models/TextContent.d.ts +0 -4
- package/dist/openapi_client/models/TextContent.js +0 -1
- package/dist/openapi_client/models/ThinkingContent.d.ts +0 -4
- package/dist/openapi_client/models/ThinkingContent.js +0 -1
- package/dist/openapi_client/models/ToolCallContent.d.ts +0 -6
- package/dist/openapi_client/models/ToolCallContent.js +0 -1
- package/dist/openapi_client/models/ToolReturnContent.d.ts +0 -6
- package/dist/openapi_client/models/ToolReturnContent.js +0 -1
- package/dist/openapi_client/models/WhatsAppSurfaceConfig.d.ts +0 -7
- package/dist/openapi_client/models/WhatsAppSurfaceConfig.js +0 -1
- package/dist/openapi_client/models/WorkflowRunWaitEntity.js +0 -1
- package/dist/openapi_client/services/BillingSubscriptionsService.d.ts +0 -117
- package/dist/openapi_client/services/BillingSubscriptionsService.js +0 -230
- package/dist/openapi_client/services/BillingWebhooksService.d.ts +0 -12
- package/dist/openapi_client/services/BillingWebhooksService.js +0 -25
- package/dist/openapi_client/services/PublicDesksService.d.ts +0 -10
- package/dist/openapi_client/services/PublicDesksService.js +0 -15
- /package/dist/openapi_client/models/{BillingHistoryResponse.js → ApplicationSkillResponse.js} +0 -0
- /package/dist/openapi_client/models/{BillingInvoiceResponse.js → ApprovalDecisionResponse.js} +0 -0
- /package/dist/openapi_client/models/{CancelSubscriptionResponse.js → ConnectedAccountSummary.js} +0 -0
- /package/dist/openapi_client/models/{CreateInvoicePaymentUrlRequest.js → DatastoreCountResponse.js} +0 -0
- /package/dist/openapi_client/models/{CreateInvoicePaymentUrlResponse.js → InstalledAppSummary.js} +0 -0
- /package/dist/openapi_client/models/{DatastoreMessageResponse.js → IntegrationStatusResponse.js} +0 -0
- /package/dist/openapi_client/models/{FlowRunEntity.js → StepRecordResponse.js} +0 -0
- /package/dist/openapi_client/models/{GmailSurfaceConfig.js → SurfaceChannelRouteInput.js} +0 -0
- /package/dist/openapi_client/models/{NotificationContent.js → SurfaceChannelRouteResponse.js} +0 -0
- /package/dist/openapi_client/models/{OutlookSurfaceConfig.js → SurfaceConfigResponse.js} +0 -0
- /package/dist/openapi_client/models/{PlanListResponse.js → SurfaceIdentityConfigInput.js} +0 -0
- /package/dist/openapi_client/models/{PlanResponse.js → SurfaceIdentityConfigResponse.js} +0 -0
- /package/dist/openapi_client/models/{RecordResponse.js → SurfaceSetupStatusResponse.js} +0 -0
- /package/dist/openapi_client/models/{SeatInfoResponse.js → UpdateSurfaceChannelsRequest.js} +0 -0
- /package/dist/openapi_client/models/{SlackSurfaceConfig.js → UpsertSurfaceRequest.js} +0 -0
- /package/dist/openapi_client/models/{StackFrame.js → WorkflowRunFormSubmitRequest.js} +0 -0
- /package/dist/openapi_client/models/{StartSubscriptionRequest.js → WorkflowRunResponse.js} +0 -0
- /package/dist/openapi_client/models/{StartSubscriptionResponse.js → WorkflowRunWaitResponse.js} +0 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
2
2
|
import { useAssistantRuntime } from "./useAssistantRuntime.js";
|
|
3
3
|
import { useAssistantSession } from "./useAssistantSession.js";
|
|
4
|
+
const CONVERSATIONS_PAGE_SIZE = 30;
|
|
4
5
|
const EMPTY_SCOPE_KEY = JSON.stringify({
|
|
5
6
|
podId: null,
|
|
6
7
|
assistantName: null,
|
|
@@ -10,43 +11,6 @@ const EMPTY_SCOPE_KEY = JSON.stringify({
|
|
|
10
11
|
function isRecord(value) {
|
|
11
12
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
12
13
|
}
|
|
13
|
-
function stringifyContent(value) {
|
|
14
|
-
if (typeof value === "string")
|
|
15
|
-
return value;
|
|
16
|
-
if (Array.isArray(value)) {
|
|
17
|
-
const text = value
|
|
18
|
-
.map((entry) => extractTextFromStructuredContentEntry(entry))
|
|
19
|
-
.filter((entry) => entry.length > 0)
|
|
20
|
-
.join("\n\n")
|
|
21
|
-
.trim();
|
|
22
|
-
if (text.length > 0)
|
|
23
|
-
return text;
|
|
24
|
-
return "";
|
|
25
|
-
}
|
|
26
|
-
if (!isRecord(value))
|
|
27
|
-
return "";
|
|
28
|
-
const direct = value.content;
|
|
29
|
-
if (typeof direct === "string")
|
|
30
|
-
return direct;
|
|
31
|
-
if (Array.isArray(direct)) {
|
|
32
|
-
const text = direct
|
|
33
|
-
.map((entry) => extractTextFromStructuredContentEntry(entry))
|
|
34
|
-
.filter((entry) => entry.length > 0)
|
|
35
|
-
.join("\n\n")
|
|
36
|
-
.trim();
|
|
37
|
-
if (text.length > 0)
|
|
38
|
-
return text;
|
|
39
|
-
}
|
|
40
|
-
const text = value.text;
|
|
41
|
-
if (typeof text === "string")
|
|
42
|
-
return text;
|
|
43
|
-
try {
|
|
44
|
-
return JSON.stringify(value, null, 2);
|
|
45
|
-
}
|
|
46
|
-
catch {
|
|
47
|
-
return "";
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
14
|
function parseMaybeJsonObject(value) {
|
|
51
15
|
if (isRecord(value))
|
|
52
16
|
return value;
|
|
@@ -71,37 +35,6 @@ function parseMaybeJsonValue(value) {
|
|
|
71
35
|
return value;
|
|
72
36
|
}
|
|
73
37
|
}
|
|
74
|
-
function extractTextFromStructuredContentEntry(entry) {
|
|
75
|
-
if (typeof entry === "string")
|
|
76
|
-
return entry.trim();
|
|
77
|
-
if (!isRecord(entry))
|
|
78
|
-
return "";
|
|
79
|
-
if (typeof entry.text === "string")
|
|
80
|
-
return entry.text.trim();
|
|
81
|
-
if (typeof entry.content === "string")
|
|
82
|
-
return entry.content.trim();
|
|
83
|
-
if (typeof entry.value === "string")
|
|
84
|
-
return entry.value.trim();
|
|
85
|
-
if (Array.isArray(entry.content)) {
|
|
86
|
-
const nested = entry.content
|
|
87
|
-
.map((child) => extractTextFromStructuredContentEntry(child))
|
|
88
|
-
.filter((text) => text.length > 0)
|
|
89
|
-
.join("\n")
|
|
90
|
-
.trim();
|
|
91
|
-
if (nested.length > 0)
|
|
92
|
-
return nested;
|
|
93
|
-
}
|
|
94
|
-
if (Array.isArray(entry.summary)) {
|
|
95
|
-
const summary = entry.summary
|
|
96
|
-
.map((child) => extractTextFromStructuredContentEntry(child))
|
|
97
|
-
.filter((text) => text.length > 0)
|
|
98
|
-
.join("\n")
|
|
99
|
-
.trim();
|
|
100
|
-
if (summary.length > 0)
|
|
101
|
-
return summary;
|
|
102
|
-
}
|
|
103
|
-
return "";
|
|
104
|
-
}
|
|
105
38
|
function parseTimestampMs(value) {
|
|
106
39
|
if (typeof value === "number" && Number.isFinite(value)) {
|
|
107
40
|
return value;
|
|
@@ -137,27 +70,19 @@ function parseThinkingDurationFromRecord(record) {
|
|
|
137
70
|
?? parseDurationMs(record.thought_duration_ms)
|
|
138
71
|
?? parseDurationMs(record.thoughtDurationMs);
|
|
139
72
|
}
|
|
140
|
-
function
|
|
141
|
-
if (
|
|
142
|
-
return null;
|
|
143
|
-
const rawType = typeof content.type === "string" ? content.type.toLowerCase() : "";
|
|
144
|
-
if (rawType !== "thinking" && rawType !== "reasoning") {
|
|
73
|
+
function extractThinkingPart(msg) {
|
|
74
|
+
if (msg.kind !== "thinking")
|
|
145
75
|
return null;
|
|
146
|
-
|
|
147
|
-
const text = extractTextFromStructuredContentEntry(content.content ?? content.text ?? content.value ?? content.summary);
|
|
76
|
+
const text = typeof msg.text === "string" ? msg.text.trim() : "";
|
|
148
77
|
if (!text)
|
|
149
78
|
return null;
|
|
150
|
-
const
|
|
151
|
-
.find((value) => typeof value === "string");
|
|
152
|
-
const normalizedState = stateValue?.toLowerCase() || "";
|
|
153
|
-
const isStreaming = normalizedState.includes("stream")
|
|
154
|
-
|| normalizedState.includes("progress")
|
|
155
|
-
|| normalizedState.includes("running")
|
|
156
|
-
|| normalizedState.includes("thinking");
|
|
79
|
+
const metadata = getMessageMetadata(msg);
|
|
157
80
|
return {
|
|
158
81
|
text,
|
|
159
|
-
state:
|
|
160
|
-
durationMs:
|
|
82
|
+
state: "done",
|
|
83
|
+
durationMs: metadata
|
|
84
|
+
? parseThinkingDurationFromRecord(metadata)
|
|
85
|
+
: undefined,
|
|
161
86
|
};
|
|
162
87
|
}
|
|
163
88
|
function normalizeToolResult(value) {
|
|
@@ -172,143 +97,33 @@ function normalizeToolResult(value) {
|
|
|
172
97
|
function getMessageMetadata(msg) {
|
|
173
98
|
return (msg.message_metadata || msg.metadata || undefined);
|
|
174
99
|
}
|
|
175
|
-
function getNativeToolPayload(
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
const toolCallId = typeof content.tool_call_id === "string" ? content.tool_call_id : null;
|
|
179
|
-
if (!toolCallId)
|
|
180
|
-
return null;
|
|
181
|
-
const toolName = typeof content.tool_name === "string" ? content.tool_name : undefined;
|
|
182
|
-
if ("tool_output" in content) {
|
|
100
|
+
function getNativeToolPayload(msg) {
|
|
101
|
+
const toolName = typeof msg.tool_name === "string" ? msg.tool_name : undefined;
|
|
102
|
+
if (msg.kind === "tool_call") {
|
|
183
103
|
return {
|
|
184
|
-
kind: "
|
|
185
|
-
toolCallId
|
|
104
|
+
kind: "call",
|
|
105
|
+
toolCallId: (typeof msg.tool_call_id === "string" && msg.tool_call_id) || `${msg.id}-tool-call`,
|
|
186
106
|
toolName,
|
|
187
|
-
|
|
107
|
+
args: parseMaybeJsonObject(parseMaybeJsonValue(msg.tool_args)),
|
|
188
108
|
};
|
|
189
109
|
}
|
|
190
|
-
if (
|
|
110
|
+
if (msg.kind === "tool_return") {
|
|
191
111
|
return {
|
|
192
|
-
kind: "
|
|
193
|
-
toolCallId
|
|
112
|
+
kind: "result",
|
|
113
|
+
toolCallId: (typeof msg.tool_call_id === "string" && msg.tool_call_id) || `${msg.id}-tool-result`,
|
|
194
114
|
toolName,
|
|
195
|
-
|
|
115
|
+
result: normalizeToolResult(msg.tool_result),
|
|
196
116
|
};
|
|
197
117
|
}
|
|
198
118
|
return null;
|
|
199
119
|
}
|
|
200
|
-
function hasNativeToolPayloadContent(content) {
|
|
201
|
-
return getNativeToolPayload(content) !== null;
|
|
202
|
-
}
|
|
203
120
|
function toolInvocationKey(tool) {
|
|
204
121
|
return `${tool.toolCallId}:${tool.state}`;
|
|
205
122
|
}
|
|
206
|
-
function toolInvocationFromStructuredContentEntry(entry, fallbackId) {
|
|
207
|
-
const type = typeof entry.type === "string" ? entry.type.toLowerCase() : "";
|
|
208
|
-
const functionObj = isRecord(entry.function) ? entry.function : {};
|
|
209
|
-
const hasToolShape = type.includes("tool")
|
|
210
|
-
|| type.includes("function_call")
|
|
211
|
-
|| type.includes("function_result")
|
|
212
|
-
|| typeof entry.tool_call_id === "string"
|
|
213
|
-
|| typeof entry.call_id === "string"
|
|
214
|
-
|| typeof entry.tool_name === "string"
|
|
215
|
-
|| typeof functionObj.name === "string"
|
|
216
|
-
|| "tool_output" in entry
|
|
217
|
-
|| ("result" in entry && typeof entry.call_id === "string");
|
|
218
|
-
if (!hasToolShape)
|
|
219
|
-
return null;
|
|
220
|
-
const rawResult = entry.tool_output ?? entry.output ?? entry.result;
|
|
221
|
-
const isResultLike = type.includes("result")
|
|
222
|
-
|| type.includes("output")
|
|
223
|
-
|| type.includes("return")
|
|
224
|
-
|| typeof rawResult !== "undefined";
|
|
225
|
-
const toolCallId = ((typeof entry.tool_call_id === "string" && entry.tool_call_id)
|
|
226
|
-
|| (typeof entry.toolCallId === "string" && entry.toolCallId)
|
|
227
|
-
|| (typeof entry.call_id === "string" && entry.call_id)
|
|
228
|
-
|| (typeof entry.id === "string" && entry.id)
|
|
229
|
-
|| fallbackId);
|
|
230
|
-
const toolName = ((typeof entry.tool_name === "string" && entry.tool_name)
|
|
231
|
-
|| (typeof entry.toolName === "string" && entry.toolName)
|
|
232
|
-
|| (typeof functionObj.name === "string" && functionObj.name)
|
|
233
|
-
|| (typeof entry.name === "string" && entry.name)
|
|
234
|
-
|| "tool");
|
|
235
|
-
const argsRaw = functionObj.arguments
|
|
236
|
-
?? entry.tool_input
|
|
237
|
-
?? entry.input
|
|
238
|
-
?? entry.args
|
|
239
|
-
?? entry.arguments;
|
|
240
|
-
const state = isResultLike ? "result" : "call";
|
|
241
|
-
return {
|
|
242
|
-
toolCallId,
|
|
243
|
-
toolName,
|
|
244
|
-
args: parseMaybeJsonObject(parseMaybeJsonValue(argsRaw)),
|
|
245
|
-
state,
|
|
246
|
-
...(isResultLike ? { result: normalizeToolResult(rawResult) } : {}),
|
|
247
|
-
};
|
|
248
|
-
}
|
|
249
|
-
function parseStructuredAssistantParts(content) {
|
|
250
|
-
if (!Array.isArray(content))
|
|
251
|
-
return null;
|
|
252
|
-
const parts = [];
|
|
253
|
-
const textChunks = [];
|
|
254
|
-
const representedToolKeys = new Set();
|
|
255
|
-
content.forEach((rawPart, index) => {
|
|
256
|
-
if (!isRecord(rawPart))
|
|
257
|
-
return;
|
|
258
|
-
const partType = typeof rawPart.type === "string" ? rawPart.type.toLowerCase() : "";
|
|
259
|
-
const partId = (typeof rawPart.id === "string" && rawPart.id) || `content-part-${index}`;
|
|
260
|
-
const toolInvocation = toolInvocationFromStructuredContentEntry(rawPart, `${partId}-tool`);
|
|
261
|
-
if (toolInvocation) {
|
|
262
|
-
representedToolKeys.add(toolInvocationKey(toolInvocation));
|
|
263
|
-
parts.push({
|
|
264
|
-
id: `${partId}-tool`,
|
|
265
|
-
type: "tool",
|
|
266
|
-
toolInvocation,
|
|
267
|
-
});
|
|
268
|
-
return;
|
|
269
|
-
}
|
|
270
|
-
const text = extractTextFromStructuredContentEntry(rawPart);
|
|
271
|
-
if (!text)
|
|
272
|
-
return;
|
|
273
|
-
if (partType.includes("reasoning") || partType.includes("thinking")) {
|
|
274
|
-
const stateValue = [rawPart.state, rawPart.status, rawPart.phase]
|
|
275
|
-
.find((value) => typeof value === "string");
|
|
276
|
-
const normalizedState = stateValue?.toLowerCase() || partType;
|
|
277
|
-
const isStreaming = normalizedState.includes("stream")
|
|
278
|
-
|| normalizedState.includes("progress")
|
|
279
|
-
|| normalizedState.includes("running")
|
|
280
|
-
|| normalizedState.includes("thinking");
|
|
281
|
-
parts.push({
|
|
282
|
-
id: `${partId}-reasoning`,
|
|
283
|
-
type: "reasoning",
|
|
284
|
-
text,
|
|
285
|
-
state: isStreaming ? "streaming" : "done",
|
|
286
|
-
durationMs: parseThinkingDurationFromRecord(rawPart),
|
|
287
|
-
startedAtMs: parseTimestampMs(rawPart.started_at)
|
|
288
|
-
?? parseTimestampMs(rawPart.startedAt)
|
|
289
|
-
?? parseTimestampMs(rawPart.created_at)
|
|
290
|
-
?? parseTimestampMs(rawPart.createdAt)
|
|
291
|
-
?? undefined,
|
|
292
|
-
});
|
|
293
|
-
return;
|
|
294
|
-
}
|
|
295
|
-
textChunks.push(text);
|
|
296
|
-
parts.push({
|
|
297
|
-
id: `${partId}-text`,
|
|
298
|
-
type: "text",
|
|
299
|
-
text,
|
|
300
|
-
});
|
|
301
|
-
});
|
|
302
|
-
return {
|
|
303
|
-
parts,
|
|
304
|
-
textContent: textChunks.join("\n\n").trim(),
|
|
305
|
-
representedToolKeys,
|
|
306
|
-
};
|
|
307
|
-
}
|
|
308
123
|
function mapToolInvocations(msg) {
|
|
309
124
|
const invocations = [];
|
|
310
125
|
const metadata = getMessageMetadata(msg);
|
|
311
|
-
const nativeToolPayload = getNativeToolPayload(msg
|
|
126
|
+
const nativeToolPayload = getNativeToolPayload(msg);
|
|
312
127
|
if (metadata?.message_type === "tool_call") {
|
|
313
128
|
invocations.push({
|
|
314
129
|
toolCallId: metadata.tool_call_id || `${msg.id}-tool-call`,
|
|
@@ -362,20 +177,6 @@ function mapToolInvocations(msg) {
|
|
|
362
177
|
result: nativeToolPayload.result || {},
|
|
363
178
|
});
|
|
364
179
|
}
|
|
365
|
-
const contentObj = isRecord(msg.content) ? msg.content : null;
|
|
366
|
-
if (contentObj && nativeToolPayload === null && "tool_output" in contentObj) {
|
|
367
|
-
invocations.push({
|
|
368
|
-
toolCallId: (typeof contentObj.tool_call_id === "string" && contentObj.tool_call_id)
|
|
369
|
-
|| metadata?.tool_call_id
|
|
370
|
-
|| `${msg.id}-tool-output`,
|
|
371
|
-
toolName: (typeof contentObj.tool_name === "string" && contentObj.tool_name)
|
|
372
|
-
|| metadata?.tool_name
|
|
373
|
-
|| "tool",
|
|
374
|
-
args: metadata?.args || {},
|
|
375
|
-
state: "result",
|
|
376
|
-
result: normalizeToolResult(contentObj.tool_output),
|
|
377
|
-
});
|
|
378
|
-
}
|
|
379
180
|
const seen = new Set();
|
|
380
181
|
return invocations.filter((invocation) => {
|
|
381
182
|
const key = toolInvocationKey(invocation);
|
|
@@ -387,43 +188,34 @@ function mapToolInvocations(msg) {
|
|
|
387
188
|
}
|
|
388
189
|
function mapConversationMessage(msg, options) {
|
|
389
190
|
const toolInvocations = mapToolInvocations(msg);
|
|
390
|
-
const structured = parseStructuredAssistantParts(msg.content);
|
|
391
|
-
const explicitThinkingPart = extractThinkingPartFromContent(msg.content);
|
|
392
191
|
const createdAtMs = parseTimestampMs(msg.created_at) ?? undefined;
|
|
393
|
-
const parts =
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
: [];
|
|
401
|
-
const representedToolKeys = structured?.representedToolKeys || new Set();
|
|
402
|
-
let content = structured
|
|
403
|
-
? structured.textContent
|
|
404
|
-
: (hasNativeToolPayloadContent(msg.content) ? "" : stringifyContent(msg.content));
|
|
405
|
-
if (explicitThinkingPart) {
|
|
406
|
-
content = "";
|
|
192
|
+
const parts = [];
|
|
193
|
+
let content = "";
|
|
194
|
+
// Flat shape: a message is exactly one kind. Thinking renders as a reasoning
|
|
195
|
+
// part; text/notification render as a text part; tool_call/tool_return render
|
|
196
|
+
// via toolInvocations below.
|
|
197
|
+
const thinkingPart = extractThinkingPart(msg);
|
|
198
|
+
if (thinkingPart) {
|
|
407
199
|
parts.push({
|
|
408
200
|
id: `${msg.id}-reasoning`,
|
|
409
201
|
type: "reasoning",
|
|
410
|
-
text:
|
|
411
|
-
state:
|
|
412
|
-
durationMs:
|
|
202
|
+
text: thinkingPart.text,
|
|
203
|
+
state: thinkingPart.state,
|
|
204
|
+
durationMs: thinkingPart.durationMs ?? options?.thinkingDurationMs,
|
|
413
205
|
startedAtMs: createdAtMs,
|
|
414
206
|
});
|
|
415
207
|
}
|
|
416
|
-
else if (
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
208
|
+
else if (msg.kind === "text" || msg.kind === "notification") {
|
|
209
|
+
content = typeof msg.text === "string" ? msg.text.trim() : "";
|
|
210
|
+
if (content) {
|
|
211
|
+
parts.push({
|
|
212
|
+
id: `${msg.id}-text`,
|
|
213
|
+
type: "text",
|
|
214
|
+
text: content,
|
|
215
|
+
});
|
|
216
|
+
}
|
|
422
217
|
}
|
|
423
218
|
toolInvocations.forEach((toolInvocation, index) => {
|
|
424
|
-
const key = toolInvocationKey(toolInvocation);
|
|
425
|
-
if (representedToolKeys.has(key))
|
|
426
|
-
return;
|
|
427
219
|
parts.push({
|
|
428
220
|
id: `${msg.id}-tool-${index}`,
|
|
429
221
|
type: "tool",
|
|
@@ -442,8 +234,11 @@ function mapConversationMessage(msg, options) {
|
|
|
442
234
|
agent_run_id: msg.agent_run_id,
|
|
443
235
|
metadata: msg.metadata ?? null,
|
|
444
236
|
message_metadata: msg.message_metadata ?? null,
|
|
237
|
+
kind: msg.kind,
|
|
445
238
|
tool_call_id: msg.tool_call_id ?? null,
|
|
446
239
|
tool_name: msg.tool_name ?? null,
|
|
240
|
+
tool_args: msg.tool_args ?? null,
|
|
241
|
+
tool_result: msg.tool_result ?? null,
|
|
447
242
|
};
|
|
448
243
|
}
|
|
449
244
|
function mapConversationMessages(messages) {
|
|
@@ -451,7 +246,7 @@ function mapConversationMessages(messages) {
|
|
|
451
246
|
const pendingToolCalls = new Map();
|
|
452
247
|
const estimateThinkingDurationMs = (index) => {
|
|
453
248
|
const message = messages[index];
|
|
454
|
-
if (!message || !
|
|
249
|
+
if (!message || !extractThinkingPart(message))
|
|
455
250
|
return undefined;
|
|
456
251
|
const startedAtMs = parseTimestampMs(message.created_at);
|
|
457
252
|
if (!startedAtMs)
|
|
@@ -477,7 +272,7 @@ function mapConversationMessages(messages) {
|
|
|
477
272
|
pendingToolCalls.set(invocation.toolCallId, invocation);
|
|
478
273
|
}
|
|
479
274
|
});
|
|
480
|
-
const nativePayload = getNativeToolPayload(rawMessage
|
|
275
|
+
const nativePayload = getNativeToolPayload(rawMessage);
|
|
481
276
|
const isToolRole = rawMessage.role === "tool";
|
|
482
277
|
if (isToolRole && nativePayload?.kind === "result" && mappedMessage.toolInvocations && mappedMessage.toolInvocations.length > 0) {
|
|
483
278
|
let mergedIntoPriorCall = false;
|
|
@@ -625,6 +420,8 @@ export function useAssistantController({ client, podId, agentName, assistantName
|
|
|
625
420
|
const [conversationRuntime, setConversationRuntimeState] = useState(null);
|
|
626
421
|
const [isStreaming, setIsStreaming] = useState(false);
|
|
627
422
|
const [isLoadingConversations, setIsLoadingConversations] = useState(false);
|
|
423
|
+
const [isLoadingMoreConversations, setIsLoadingMoreConversations] = useState(false);
|
|
424
|
+
const [conversationsCursor, setConversationsCursor] = useState(null);
|
|
628
425
|
const [isLoadingMessages, setIsLoadingMessages] = useState(false);
|
|
629
426
|
const [isLoadingOlderMessages, setIsLoadingOlderMessages] = useState(false);
|
|
630
427
|
const [isUploadingFiles, setIsUploadingFiles] = useState(false);
|
|
@@ -739,9 +536,10 @@ export function useAssistantController({ client, podId, agentName, assistantName
|
|
|
739
536
|
const loadConversations = useCallback(async () => {
|
|
740
537
|
setIsLoadingConversations(true);
|
|
741
538
|
try {
|
|
742
|
-
const response = await sessionListConversations({ scope });
|
|
539
|
+
const response = await sessionListConversations({ scope, limit: CONVERSATIONS_PAGE_SIZE });
|
|
743
540
|
const nextConversations = sortConversationsByUpdatedAt(response.items || []);
|
|
744
541
|
setConversations(nextConversations);
|
|
542
|
+
setConversationsCursor(response.next_page_token ?? null);
|
|
745
543
|
setActiveConversationId((current) => {
|
|
746
544
|
if (current && nextConversations.some((conversation) => conversation.id === current)) {
|
|
747
545
|
return current;
|
|
@@ -759,6 +557,36 @@ export function useAssistantController({ client, podId, agentName, assistantName
|
|
|
759
557
|
setIsLoadingConversations(false);
|
|
760
558
|
}
|
|
761
559
|
}, [scope, sessionListConversations]);
|
|
560
|
+
const loadMoreConversations = useCallback(async () => {
|
|
561
|
+
if (!conversationsCursor || isLoadingConversations || isLoadingMoreConversations) {
|
|
562
|
+
return [];
|
|
563
|
+
}
|
|
564
|
+
setIsLoadingMoreConversations(true);
|
|
565
|
+
try {
|
|
566
|
+
const response = await sessionListConversations({
|
|
567
|
+
scope,
|
|
568
|
+
limit: CONVERSATIONS_PAGE_SIZE,
|
|
569
|
+
pageToken: conversationsCursor,
|
|
570
|
+
});
|
|
571
|
+
const moreConversations = response.items || [];
|
|
572
|
+
setConversations((prev) => {
|
|
573
|
+
const byId = new Map(prev.map((conversation) => [conversation.id, conversation]));
|
|
574
|
+
for (const conversation of moreConversations) {
|
|
575
|
+
byId.set(conversation.id, conversation);
|
|
576
|
+
}
|
|
577
|
+
return sortConversationsByUpdatedAt(Array.from(byId.values()));
|
|
578
|
+
});
|
|
579
|
+
setConversationsCursor(response.next_page_token ?? null);
|
|
580
|
+
return moreConversations;
|
|
581
|
+
}
|
|
582
|
+
catch (err) {
|
|
583
|
+
setLocalError((prev) => prev || (err instanceof Error ? err.message : "Failed to load more conversations"));
|
|
584
|
+
return [];
|
|
585
|
+
}
|
|
586
|
+
finally {
|
|
587
|
+
setIsLoadingMoreConversations(false);
|
|
588
|
+
}
|
|
589
|
+
}, [conversationsCursor, isLoadingConversations, isLoadingMoreConversations, scope, sessionListConversations]);
|
|
762
590
|
const loadAvailableModels = useCallback(async () => {
|
|
763
591
|
try {
|
|
764
592
|
const response = await client.conversations.listModels({
|
|
@@ -909,9 +737,11 @@ export function useAssistantController({ client, podId, agentName, assistantName
|
|
|
909
737
|
setConversationModelState(null);
|
|
910
738
|
setConversationRuntimeState(null);
|
|
911
739
|
setConversations([]);
|
|
740
|
+
setConversationsCursor(null);
|
|
912
741
|
setLocalError(null);
|
|
913
742
|
setOlderMessagesCursor(null);
|
|
914
743
|
setIsLoadingConversations(false);
|
|
744
|
+
setIsLoadingMoreConversations(false);
|
|
915
745
|
setIsLoadingMessages(false);
|
|
916
746
|
setIsLoadingOlderMessages(false);
|
|
917
747
|
return;
|
|
@@ -925,6 +755,7 @@ export function useAssistantController({ client, podId, agentName, assistantName
|
|
|
925
755
|
setConversationModelState(null);
|
|
926
756
|
setConversationRuntimeState(null);
|
|
927
757
|
setConversations([]);
|
|
758
|
+
setConversationsCursor(null);
|
|
928
759
|
setLocalError(null);
|
|
929
760
|
clearRuntimeMessages();
|
|
930
761
|
setOlderMessagesCursor(null);
|
|
@@ -1075,6 +906,7 @@ export function useAssistantController({ client, podId, agentName, assistantName
|
|
|
1075
906
|
const createdConversation = await sessionCreateConversation({
|
|
1076
907
|
title: titleSeed.slice(0, 120),
|
|
1077
908
|
instructions: typeof options.instructions === "undefined" ? instructions : options.instructions,
|
|
909
|
+
metadata: options.metadata ?? undefined,
|
|
1078
910
|
model: conversationModel,
|
|
1079
911
|
agentRuntime: conversationRuntime,
|
|
1080
912
|
...scope,
|
|
@@ -1136,7 +968,10 @@ export function useAssistantController({ client, podId, agentName, assistantName
|
|
|
1136
968
|
let conversationId = forceNewConversation ? null : activeConversationId;
|
|
1137
969
|
try {
|
|
1138
970
|
if (!conversationId) {
|
|
1139
|
-
conversationId = await ensureConversation(trimmed, {
|
|
971
|
+
conversationId = await ensureConversation(trimmed, {
|
|
972
|
+
instructions: options.instructions,
|
|
973
|
+
metadata: options.conversationMetadata,
|
|
974
|
+
});
|
|
1140
975
|
}
|
|
1141
976
|
if (!conversationId) {
|
|
1142
977
|
throw new Error("Conversation could not be initialized");
|
|
@@ -1282,6 +1117,8 @@ export function useAssistantController({ client, podId, agentName, assistantName
|
|
|
1282
1117
|
isActiveConversationRunning,
|
|
1283
1118
|
isLoading,
|
|
1284
1119
|
isLoadingConversations,
|
|
1120
|
+
isLoadingMoreConversations,
|
|
1121
|
+
hasMoreConversations: !!conversationsCursor,
|
|
1285
1122
|
isLoadingMessages,
|
|
1286
1123
|
isLoadingOlderMessages,
|
|
1287
1124
|
hasOlderMessages: !!olderMessagesCursor,
|
|
@@ -1299,6 +1136,7 @@ export function useAssistantController({ client, podId, agentName, assistantName
|
|
|
1299
1136
|
removePendingFile,
|
|
1300
1137
|
clearPendingFiles,
|
|
1301
1138
|
loadOlderMessages,
|
|
1139
|
+
loadMoreConversations,
|
|
1302
1140
|
resolveUserApproval,
|
|
1303
1141
|
clearMessages,
|
|
1304
1142
|
stop,
|
|
@@ -1312,12 +1150,15 @@ export function useAssistantController({ client, podId, agentName, assistantName
|
|
|
1312
1150
|
conversationModel,
|
|
1313
1151
|
conversations,
|
|
1314
1152
|
error,
|
|
1153
|
+
conversationsCursor,
|
|
1315
1154
|
isActiveConversationRunning,
|
|
1316
1155
|
isLoading,
|
|
1317
1156
|
isLoadingConversations,
|
|
1157
|
+
isLoadingMoreConversations,
|
|
1318
1158
|
isLoadingMessages,
|
|
1319
1159
|
isLoadingOlderMessages,
|
|
1320
1160
|
isUploadingFiles,
|
|
1161
|
+
loadMoreConversations,
|
|
1321
1162
|
loadOlderMessages,
|
|
1322
1163
|
messages,
|
|
1323
1164
|
olderMessagesCursor,
|
|
@@ -1,18 +1,6 @@
|
|
|
1
1
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
2
|
-
function
|
|
3
|
-
return
|
|
4
|
-
}
|
|
5
|
-
function messageText(content) {
|
|
6
|
-
if (typeof content === "string") {
|
|
7
|
-
return content.trim();
|
|
8
|
-
}
|
|
9
|
-
if (isRecord(content)) {
|
|
10
|
-
if (typeof content.content === "string")
|
|
11
|
-
return content.content.trim();
|
|
12
|
-
if (typeof content.text === "string")
|
|
13
|
-
return content.text.trim();
|
|
14
|
-
}
|
|
15
|
-
return "";
|
|
2
|
+
function messageText(message) {
|
|
3
|
+
return typeof message.text === "string" ? message.text.trim() : "";
|
|
16
4
|
}
|
|
17
5
|
function messageTime(message) {
|
|
18
6
|
const timestamp = new Date(message.created_at).getTime();
|
|
@@ -30,7 +18,7 @@ function upsertRuntimeMessage(previous, incoming) {
|
|
|
30
18
|
return next;
|
|
31
19
|
}
|
|
32
20
|
if (incoming.role === "user") {
|
|
33
|
-
const incomingText = messageText(incoming
|
|
21
|
+
const incomingText = messageText(incoming);
|
|
34
22
|
if (incomingText) {
|
|
35
23
|
const incomingTimestamp = messageTime(incoming);
|
|
36
24
|
let optimisticIndex = -1;
|
|
@@ -38,7 +26,7 @@ function upsertRuntimeMessage(previous, incoming) {
|
|
|
38
26
|
next.forEach((message, index) => {
|
|
39
27
|
if (message.role !== "user"
|
|
40
28
|
|| !isOptimisticId(message.id)
|
|
41
|
-
|| messageText(message
|
|
29
|
+
|| messageText(message) !== incomingText) {
|
|
42
30
|
return;
|
|
43
31
|
}
|
|
44
32
|
const distance = Math.abs(messageTime(message) - incomingTimestamp);
|
|
@@ -100,7 +88,8 @@ export function useAssistantRuntime({ conversationId = null, sessionConversation
|
|
|
100
88
|
const optimistic = {
|
|
101
89
|
id: buildOptimisticId(),
|
|
102
90
|
role: "user",
|
|
103
|
-
|
|
91
|
+
kind: "text",
|
|
92
|
+
text: trimmed,
|
|
104
93
|
created_at: new Date().toISOString(),
|
|
105
94
|
metadata: null,
|
|
106
95
|
...(optimisticConversationId ? { conversation_id: optimisticConversationId } : {}),
|
|
@@ -40,10 +40,13 @@ export interface UseAssistantSessionOptions {
|
|
|
40
40
|
export interface CreateConversationInput {
|
|
41
41
|
title?: string | null;
|
|
42
42
|
instructions?: string | null;
|
|
43
|
+
metadata?: Record<string, unknown> | null;
|
|
43
44
|
model?: ConversationModel | null;
|
|
44
45
|
agentRuntime?: AgentRuntimeConfig | null;
|
|
45
46
|
podId?: string | null;
|
|
46
47
|
agentName?: string | null;
|
|
48
|
+
/** Parent conversation id for sub-agent (child) conversations. */
|
|
49
|
+
parentId?: string | null;
|
|
47
50
|
/**
|
|
48
51
|
* @deprecated Use agentName instead.
|
|
49
52
|
*/
|
|
@@ -81,9 +84,9 @@ export interface UseAssistantSessionResult {
|
|
|
81
84
|
status?: string;
|
|
82
85
|
messages: ConversationMessage[];
|
|
83
86
|
latestAssistantMessage: ConversationMessage | null;
|
|
84
|
-
output: ConversationMessage
|
|
87
|
+
output: ConversationMessage | null;
|
|
85
88
|
outputText: string;
|
|
86
|
-
finalOutput: ConversationMessage
|
|
89
|
+
finalOutput: ConversationMessage | null;
|
|
87
90
|
finalOutputText: string;
|
|
88
91
|
streamingText: string;
|
|
89
92
|
streamingTool: AssistantStreamingTool | null;
|