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,7 +1,7 @@
|
|
|
1
1
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
2
2
|
import { parseSSEJson, readSSE } from "../streams.js";
|
|
3
3
|
import { parseAssistantStreamEvent, upsertConversationMessage } from "../assistant-events.js";
|
|
4
|
-
import {
|
|
4
|
+
import { conversationMessageText, getLatestAssistantMessage, } from "./assistant-output.js";
|
|
5
5
|
import { normalizeError } from "./utils.js";
|
|
6
6
|
function applyPodScope(client, podId) {
|
|
7
7
|
const resolvedPodId = podId ?? client.podId;
|
|
@@ -84,8 +84,8 @@ function parseStreamingToolToken(token) {
|
|
|
84
84
|
return null;
|
|
85
85
|
const rawToolCallId = [parsed.tool_call_id, parsed.toolCallId, parsed.call_id, parsed.id]
|
|
86
86
|
.find((value) => typeof value === "string" && value.trim().length > 0);
|
|
87
|
-
const rawArgs = parsed.tool_input ?? parsed.args ?? parsed.arguments ?? parsed.input;
|
|
88
|
-
const rawResult = parsed.tool_output ?? parsed.result ?? parsed.output;
|
|
87
|
+
const rawArgs = parsed.tool_args ?? parsed.tool_input ?? parsed.args ?? parsed.arguments ?? parsed.input;
|
|
88
|
+
const rawResult = parsed.tool_result ?? parsed.tool_output ?? parsed.result ?? parsed.output;
|
|
89
89
|
const hasResult = typeof rawResult !== "undefined";
|
|
90
90
|
return {
|
|
91
91
|
...(typeof rawToolCallId === "string" ? { toolCallId: rawToolCallId } : {}),
|
|
@@ -143,6 +143,9 @@ export function useAssistantSession(options) {
|
|
|
143
143
|
const onStatusRef = useRef(onStatus);
|
|
144
144
|
const onMessageRef = useRef(onMessage);
|
|
145
145
|
const onErrorRef = useRef(onError);
|
|
146
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
147
|
+
const consumeRef = useRef(null);
|
|
148
|
+
const streamReconnectCountRef = useRef(0);
|
|
146
149
|
const setConversationId = useCallback((nextConversationId) => {
|
|
147
150
|
abortRef.current?.abort();
|
|
148
151
|
abortRef.current = null;
|
|
@@ -274,6 +277,7 @@ export function useAssistantSession(options) {
|
|
|
274
277
|
instructions: typeof input.instructions === "undefined"
|
|
275
278
|
? defaultInstructions ?? undefined
|
|
276
279
|
: input.instructions,
|
|
280
|
+
metadata: input.metadata ?? undefined,
|
|
277
281
|
pod_id: input.podId ?? defaultPodId ?? scopedClient.podId ?? undefined,
|
|
278
282
|
agent_name: input.agentName
|
|
279
283
|
?? input.assistantName
|
|
@@ -288,6 +292,7 @@ export function useAssistantSession(options) {
|
|
|
288
292
|
agent_runtime: typeof input.agentRuntime === "undefined"
|
|
289
293
|
? undefined
|
|
290
294
|
: input.agentRuntime,
|
|
295
|
+
parent_id: input.parentId ?? undefined,
|
|
291
296
|
};
|
|
292
297
|
const created = await scopedClient.conversations.create(payload);
|
|
293
298
|
if (input.setActive !== false) {
|
|
@@ -391,6 +396,16 @@ export function useAssistantSession(options) {
|
|
|
391
396
|
const payload = parseSSEJson(event);
|
|
392
397
|
onEventRef.current?.(event, payload);
|
|
393
398
|
const parsed = parseAssistantStreamEvent(payload);
|
|
399
|
+
if (parsed.error) {
|
|
400
|
+
const streamError = new Error(parsed.error);
|
|
401
|
+
setError(streamError);
|
|
402
|
+
onErrorRef.current?.(streamError);
|
|
403
|
+
setConversationStatus(parsed.status ?? "FAILED");
|
|
404
|
+
sawTerminalStatus = true;
|
|
405
|
+
clearStreamingText();
|
|
406
|
+
clearStreamingTool();
|
|
407
|
+
continue;
|
|
408
|
+
}
|
|
394
409
|
if (parsed.token) {
|
|
395
410
|
if (parsed.tokenKind === "tool") {
|
|
396
411
|
streamingToolTokenRef.current += parsed.token;
|
|
@@ -435,6 +450,28 @@ export function useAssistantSession(options) {
|
|
|
435
450
|
}
|
|
436
451
|
if (!controller.signal.aborted) {
|
|
437
452
|
if (!sawTerminalStatus && isConversationRunningStatus(statusRef.current)) {
|
|
453
|
+
const reconId = streamConversationId ?? conversationId;
|
|
454
|
+
if (reconId && streamReconnectCountRef.current < 3) {
|
|
455
|
+
streamReconnectCountRef.current += 1;
|
|
456
|
+
const delay = Math.pow(2, streamReconnectCountRef.current - 1) * 1000;
|
|
457
|
+
await new Promise((r) => setTimeout(r, delay));
|
|
458
|
+
if (!controller.signal.aborted && isConversationRunningStatus(statusRef.current)) {
|
|
459
|
+
try {
|
|
460
|
+
const scope = normalizeScope(client, defaultScope);
|
|
461
|
+
const scopedClient = applyPodScope(client, scope.podId);
|
|
462
|
+
const newStream = await scopedClient.conversations.resumeStream(reconId, {
|
|
463
|
+
pod_id: scope.podId ?? undefined,
|
|
464
|
+
signal: controller.signal,
|
|
465
|
+
});
|
|
466
|
+
// Sync any messages delivered while the stream was dropped
|
|
467
|
+
await loadMessages({ conversationId: reconId, limit: 100 });
|
|
468
|
+
streamReconnectCountRef.current = 0;
|
|
469
|
+
return consumeRef.current({ stream: newStream, controller, streamConversationId: reconId, syncAfterStream });
|
|
470
|
+
}
|
|
471
|
+
catch { /* fall through to WAITING */ }
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
streamReconnectCountRef.current = 0;
|
|
438
475
|
setConversationStatus("WAITING");
|
|
439
476
|
}
|
|
440
477
|
clearStreamingText();
|
|
@@ -464,12 +501,17 @@ export function useAssistantSession(options) {
|
|
|
464
501
|
appendStreamingToken,
|
|
465
502
|
clearStreamingTool,
|
|
466
503
|
clearStreamingText,
|
|
504
|
+
client,
|
|
467
505
|
conversationId,
|
|
506
|
+
defaultScope,
|
|
468
507
|
loadMessages,
|
|
469
508
|
refreshConversation,
|
|
470
509
|
setConversationStatus,
|
|
471
510
|
syncOnTurnEnd,
|
|
472
511
|
]);
|
|
512
|
+
useEffect(() => {
|
|
513
|
+
consumeRef.current = consume;
|
|
514
|
+
}, [consume]);
|
|
473
515
|
const ensureConversation = useCallback(async (overrideConversationId) => {
|
|
474
516
|
const existingId = overrideConversationId ?? conversationId;
|
|
475
517
|
if (existingId) {
|
|
@@ -658,10 +700,8 @@ export function useAssistantSession(options) {
|
|
|
658
700
|
};
|
|
659
701
|
}, [autoLoad, autoResume, conversationId, loadMessages, refreshConversation, resumeIfRunning]);
|
|
660
702
|
const latestAssistantMessage = useMemo(() => getLatestAssistantMessage(messages), [messages]);
|
|
661
|
-
const output = latestAssistantMessage
|
|
662
|
-
const latestAssistantText = latestAssistantMessage
|
|
663
|
-
? extractConversationMessageText(latestAssistantMessage.content)
|
|
664
|
-
: "";
|
|
703
|
+
const output = latestAssistantMessage ?? null;
|
|
704
|
+
const latestAssistantText = conversationMessageText(latestAssistantMessage);
|
|
665
705
|
const outputText = streamingText.trim() || latestAssistantText;
|
|
666
706
|
const finalOutput = !isStreaming && !isConversationRunningStatus(status) ? output : null;
|
|
667
707
|
const finalOutputText = !isStreaming && !isConversationRunningStatus(status) ? latestAssistantText : "";
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import type { LemmaClient } from "../client.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { DatastoreCountResponse } from "../types.js";
|
|
3
3
|
export interface UseBulkRecordsOptions {
|
|
4
4
|
client: LemmaClient;
|
|
5
5
|
podId?: string;
|
|
6
6
|
tableName: string;
|
|
7
7
|
enabled?: boolean;
|
|
8
|
-
onSuccess?: (response:
|
|
8
|
+
onSuccess?: (response: DatastoreCountResponse) => void;
|
|
9
9
|
onError?: (error: unknown) => void;
|
|
10
10
|
}
|
|
11
11
|
export interface UseBulkRecordsResult {
|
|
12
12
|
isSubmitting: boolean;
|
|
13
13
|
error: Error | null;
|
|
14
14
|
lastMessage: string | null;
|
|
15
|
-
createMany: (records: Record<string, unknown>[]) => Promise<
|
|
16
|
-
updateMany: (records: Record<string, unknown>[]) => Promise<
|
|
17
|
-
deleteMany: (recordIds: Array<string | number>) => Promise<
|
|
15
|
+
createMany: (records: Record<string, unknown>[]) => Promise<DatastoreCountResponse | null>;
|
|
16
|
+
updateMany: (records: Record<string, unknown>[]) => Promise<DatastoreCountResponse | null>;
|
|
17
|
+
deleteMany: (recordIds: Array<string | number>) => Promise<DatastoreCountResponse | null>;
|
|
18
18
|
reset: () => void;
|
|
19
19
|
}
|
|
20
20
|
export declare function useBulkRecords({ client, podId, tableName, enabled, onSuccess, onError, }: UseBulkRecordsOptions): UseBulkRecordsResult;
|
|
@@ -10,7 +10,7 @@ export function useBulkRecords({ client, podId, tableName, enabled = true, onSuc
|
|
|
10
10
|
useEffect(() => { onErrorRef.current = onError; }, [onError]);
|
|
11
11
|
const trimmedTableName = tableName.trim();
|
|
12
12
|
const isEnabled = enabled && trimmedTableName.length > 0;
|
|
13
|
-
const runBulkOperation = useCallback(async (action, fallbackError) => {
|
|
13
|
+
const runBulkOperation = useCallback(async (action, fallbackError, describe) => {
|
|
14
14
|
if (!isEnabled) {
|
|
15
15
|
return null;
|
|
16
16
|
}
|
|
@@ -19,7 +19,7 @@ export function useBulkRecords({ client, podId, tableName, enabled = true, onSuc
|
|
|
19
19
|
try {
|
|
20
20
|
const scopedClient = resolvePodClient(client, podId);
|
|
21
21
|
const response = await action(scopedClient);
|
|
22
|
-
setLastMessage(response.
|
|
22
|
+
setLastMessage(describe(response.count));
|
|
23
23
|
onSuccessRef.current?.(response);
|
|
24
24
|
return response;
|
|
25
25
|
}
|
|
@@ -36,17 +36,17 @@ export function useBulkRecords({ client, podId, tableName, enabled = true, onSuc
|
|
|
36
36
|
const createMany = useCallback(async (records) => {
|
|
37
37
|
if (records.length === 0)
|
|
38
38
|
return null;
|
|
39
|
-
return runBulkOperation((scopedClient) => scopedClient.records.bulk.create(trimmedTableName, records), "Failed to bulk create records.");
|
|
39
|
+
return runBulkOperation((scopedClient) => scopedClient.records.bulk.create(trimmedTableName, records), "Failed to bulk create records.", (count) => `${count} record${count === 1 ? "" : "s"} created.`);
|
|
40
40
|
}, [runBulkOperation, trimmedTableName]);
|
|
41
41
|
const updateMany = useCallback(async (records) => {
|
|
42
42
|
if (records.length === 0)
|
|
43
43
|
return null;
|
|
44
|
-
return runBulkOperation((scopedClient) => scopedClient.records.bulk.update(trimmedTableName, records), "Failed to bulk update records.");
|
|
44
|
+
return runBulkOperation((scopedClient) => scopedClient.records.bulk.update(trimmedTableName, records), "Failed to bulk update records.", (count) => `${count} record${count === 1 ? "" : "s"} updated.`);
|
|
45
45
|
}, [runBulkOperation, trimmedTableName]);
|
|
46
46
|
const deleteMany = useCallback(async (recordIds) => {
|
|
47
47
|
if (recordIds.length === 0)
|
|
48
48
|
return null;
|
|
49
|
-
return runBulkOperation((scopedClient) => scopedClient.records.bulk.delete(trimmedTableName, recordIds), "Failed to bulk delete records.");
|
|
49
|
+
return runBulkOperation((scopedClient) => scopedClient.records.bulk.delete(trimmedTableName, recordIds), "Failed to bulk delete records.", (count) => `${count} record${count === 1 ? "" : "s"} deleted.`);
|
|
50
50
|
}, [runBulkOperation, trimmedTableName]);
|
|
51
51
|
const reset = useCallback(() => {
|
|
52
52
|
setError(null);
|
|
@@ -40,9 +40,9 @@ export interface UseConversationMessagesResult {
|
|
|
40
40
|
nextPageToken: string | null;
|
|
41
41
|
streamingText: string;
|
|
42
42
|
latestAssistantMessage: ConversationMessage | null;
|
|
43
|
-
output: ConversationMessage
|
|
43
|
+
output: ConversationMessage | null;
|
|
44
44
|
outputText: string;
|
|
45
|
-
finalOutput: ConversationMessage
|
|
45
|
+
finalOutput: ConversationMessage | null;
|
|
46
46
|
finalOutputText: string;
|
|
47
47
|
error: Error | null;
|
|
48
48
|
refresh: (options?: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { conversationMessageText, getLatestAssistantMessage, isConversationRunningStatus, normalizeConversationStatus, sortConversationMessagesByCreatedAt, } from "./assistant-output.js";
|
|
3
3
|
import { useAssistantSession, } from "./useAssistantSession.js";
|
|
4
4
|
function resolveConversationId(preferred, fallback) {
|
|
5
5
|
return preferred ?? fallback ?? null;
|
|
@@ -117,10 +117,8 @@ export function useConversationMessages({ client, podId, agentName, assistantNam
|
|
|
117
117
|
}, [autoLoad, autoResume, cancel, clearSessionMessages, conversationId, enabled, limit, refresh, resumeIfRunning]);
|
|
118
118
|
const messages = useMemo(() => sortConversationMessagesByCreatedAt(sessionMessages), [sessionMessages]);
|
|
119
119
|
const latestAssistantMessage = useMemo(() => getLatestAssistantMessage(messages), [messages]);
|
|
120
|
-
const output = latestAssistantMessage
|
|
121
|
-
const latestAssistantText = latestAssistantMessage
|
|
122
|
-
? extractConversationMessageText(latestAssistantMessage.content)
|
|
123
|
-
: "";
|
|
120
|
+
const output = latestAssistantMessage ?? null;
|
|
121
|
+
const latestAssistantText = conversationMessageText(latestAssistantMessage);
|
|
124
122
|
const outputText = streamingText.trim() || latestAssistantText;
|
|
125
123
|
const finalOutput = isSettledStatus(status, isStreaming) ? output : null;
|
|
126
124
|
const finalOutputText = isSettledStatus(status, isStreaming) ? latestAssistantText : "";
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import type { LemmaClient } from "../client.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { 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;
|
|
8
7
|
}
|
|
9
8
|
export interface UseCreateFolderOptions {
|
|
10
9
|
client: LemmaClient;
|
|
11
10
|
podId?: string;
|
|
12
|
-
namespace?: DatastoreFileNamespace | null;
|
|
13
11
|
enabled?: boolean;
|
|
14
12
|
onSuccess?: (folder: FileResponse) => void;
|
|
15
13
|
onError?: (error: unknown) => void;
|
|
@@ -21,4 +19,4 @@ export interface UseCreateFolderResult<TFile extends FileResponse = FileResponse
|
|
|
21
19
|
createFolder: (name: string, options?: CreateFolderInput) => Promise<TFile | null>;
|
|
22
20
|
reset: () => void;
|
|
23
21
|
}
|
|
24
|
-
export declare function useCreateFolder<TFile extends FileResponse = FileResponse>({ client, podId,
|
|
22
|
+
export declare function useCreateFolder<TFile extends FileResponse = FileResponse>({ client, podId, 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,
|
|
3
|
+
export function useCreateFolder({ client, podId, 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);
|
|
@@ -19,7 +19,6 @@ export function useCreateFolder({ client, podId, namespace, enabled = true, onSu
|
|
|
19
19
|
const scopedClient = resolvePodClient(client, podId);
|
|
20
20
|
const nextFolder = await scopedClient.files.folder.create(trimmedName, {
|
|
21
21
|
...options,
|
|
22
|
-
namespace: options.namespace ?? namespace,
|
|
23
22
|
});
|
|
24
23
|
setCreatedFolder(nextFolder);
|
|
25
24
|
onSuccessRef.current?.(nextFolder);
|
|
@@ -34,7 +33,7 @@ export function useCreateFolder({ client, podId, namespace, enabled = true, onSu
|
|
|
34
33
|
finally {
|
|
35
34
|
setIsSubmitting(false);
|
|
36
35
|
}
|
|
37
|
-
}, [client, enabled,
|
|
36
|
+
}, [client, enabled, podId]);
|
|
38
37
|
const reset = useCallback(() => {
|
|
39
38
|
setCreatedFolder(null);
|
|
40
39
|
setError(null);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { LemmaClient } from "../client.js";
|
|
2
|
-
import type { FunctionRun
|
|
2
|
+
import type { FunctionRun } from "../types.js";
|
|
3
3
|
/**
|
|
4
4
|
* React hook for creating a single record. Manages loading/error state and
|
|
5
5
|
* exposes a `create` function you can call from event handlers.
|
|
@@ -35,7 +35,7 @@ export interface UseCreateRecordOptions {
|
|
|
35
35
|
createVia?: "direct" | "function";
|
|
36
36
|
/** Function name to run when `createVia` is `"function"`. Falls back to `tableName` if omitted. */
|
|
37
37
|
createFunctionName?: string;
|
|
38
|
-
onSuccess?: (record: Record<string, unknown>, response:
|
|
38
|
+
onSuccess?: (record: Record<string, unknown>, response: Record<string, unknown> | FunctionRun) => void;
|
|
39
39
|
onError?: (error: unknown) => void;
|
|
40
40
|
}
|
|
41
41
|
export interface UseCreateRecordResult<TRecord extends Record<string, unknown> = Record<string, unknown>> {
|
|
@@ -29,7 +29,7 @@ export function useCreateRecord({ client, podId, tableName, enabled = true, crea
|
|
|
29
29
|
return nextRecord;
|
|
30
30
|
}
|
|
31
31
|
const response = await scopedClient.records.create(trimmedTableName, data);
|
|
32
|
-
const nextRecord = (response
|
|
32
|
+
const nextRecord = (response ?? null);
|
|
33
33
|
setCreatedRecord(nextRecord);
|
|
34
34
|
if (nextRecord) {
|
|
35
35
|
onSuccessRef.current?.(nextRecord, response);
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import type { LemmaClient } from "../client.js";
|
|
2
|
-
import type { DatastoreFileNamespace } from "../types.js";
|
|
3
2
|
export interface UseDeleteFileOptions {
|
|
4
3
|
client: LemmaClient;
|
|
5
4
|
podId?: string;
|
|
6
5
|
path?: string | null;
|
|
7
|
-
namespace?: DatastoreFileNamespace | null;
|
|
8
6
|
enabled?: boolean;
|
|
9
7
|
onSuccess?: (path: string) => void;
|
|
10
8
|
onError?: (error: unknown) => void;
|
|
@@ -15,8 +13,7 @@ export interface UseDeleteFileResult {
|
|
|
15
13
|
error: Error | null;
|
|
16
14
|
remove: (overrides?: {
|
|
17
15
|
path?: string | null;
|
|
18
|
-
namespace?: DatastoreFileNamespace | null;
|
|
19
16
|
}) => Promise<boolean>;
|
|
20
17
|
reset: () => void;
|
|
21
18
|
}
|
|
22
|
-
export declare function useDeleteFile({ client, podId, path,
|
|
19
|
+
export declare function useDeleteFile({ client, podId, path, enabled, onSuccess, onError, }: UseDeleteFileOptions): UseDeleteFileResult;
|
|
@@ -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 useDeleteFile({ client, podId, path = null,
|
|
3
|
+
export function useDeleteFile({ client, podId, path = null, enabled = true, onSuccess, onError, }) {
|
|
4
4
|
const [deletedPath, setDeletedPath] = useState(null);
|
|
5
5
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
6
6
|
const [error, setError] = useState(null);
|
|
@@ -21,7 +21,7 @@ export function useDeleteFile({ client, podId, path = null, namespace, enabled =
|
|
|
21
21
|
setError(null);
|
|
22
22
|
try {
|
|
23
23
|
const scopedClient = resolvePodClient(client, podId);
|
|
24
|
-
await scopedClient.files.delete(nextPath
|
|
24
|
+
await scopedClient.files.delete(nextPath);
|
|
25
25
|
setDeletedPath(nextPath);
|
|
26
26
|
onSuccessRef.current?.(nextPath);
|
|
27
27
|
return true;
|
|
@@ -35,7 +35,7 @@ export function useDeleteFile({ client, podId, path = null, namespace, enabled =
|
|
|
35
35
|
finally {
|
|
36
36
|
setIsSubmitting(false);
|
|
37
37
|
}
|
|
38
|
-
}, [client, isEnabled,
|
|
38
|
+
}, [client, isEnabled, podId, trimmedPath]);
|
|
39
39
|
const reset = useCallback(() => {
|
|
40
40
|
setDeletedPath(null);
|
|
41
41
|
setError(null);
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import type { LemmaClient } from "../client.js";
|
|
2
|
-
import type { DatastoreMessageResponse } from "../types.js";
|
|
3
2
|
export interface UseDeleteRecordOptions {
|
|
4
3
|
client: LemmaClient;
|
|
5
4
|
podId?: string;
|
|
6
5
|
tableName: string;
|
|
7
6
|
recordId?: string | null;
|
|
8
7
|
enabled?: boolean;
|
|
9
|
-
onSuccess?: (
|
|
8
|
+
onSuccess?: () => void;
|
|
10
9
|
onError?: (error: unknown) => void;
|
|
11
10
|
}
|
|
12
11
|
export interface UseDeleteRecordResult {
|
|
@@ -22,9 +22,9 @@ export function useDeleteRecord({ client, podId, tableName, recordId = null, ena
|
|
|
22
22
|
setError(null);
|
|
23
23
|
try {
|
|
24
24
|
const scopedClient = resolvePodClient(client, podId);
|
|
25
|
-
|
|
26
|
-
setLastMessage(
|
|
27
|
-
onSuccessRef.current?.(
|
|
25
|
+
await scopedClient.records.delete(trimmedTableName, nextRecordId);
|
|
26
|
+
setLastMessage("Record deleted.");
|
|
27
|
+
onSuccessRef.current?.();
|
|
28
28
|
return true;
|
|
29
29
|
}
|
|
30
30
|
catch (mutationError) {
|
package/dist/react/useFile.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import type { LemmaClient } from "../client.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { FileResponse } from "../types.js";
|
|
3
3
|
export interface UseFileOptions {
|
|
4
4
|
client: LemmaClient;
|
|
5
5
|
podId?: string;
|
|
6
6
|
path?: string | null;
|
|
7
|
-
namespace?: DatastoreFileNamespace | null;
|
|
8
7
|
enabled?: boolean;
|
|
9
8
|
autoLoad?: boolean;
|
|
10
9
|
}
|
|
@@ -14,7 +13,6 @@ export interface UseFileResult {
|
|
|
14
13
|
error: Error | null;
|
|
15
14
|
refresh: (overrides?: {
|
|
16
15
|
path?: string | null;
|
|
17
|
-
namespace?: DatastoreFileNamespace | null;
|
|
18
16
|
}) => Promise<FileResponse | null>;
|
|
19
17
|
}
|
|
20
|
-
export declare function useFile({ client, podId, path,
|
|
18
|
+
export declare function useFile({ client, podId, path, enabled, autoLoad, }: UseFileOptions): UseFileResult;
|
package/dist/react/useFile.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
2
2
|
import { normalizeError, resolvePodClient } from "./utils.js";
|
|
3
|
-
export function useFile({ client, podId, path = null,
|
|
3
|
+
export function useFile({ client, podId, path = null, enabled = true, autoLoad = true, }) {
|
|
4
4
|
const [file, setFile] = useState(null);
|
|
5
5
|
const [isLoading, setIsLoading] = useState(false);
|
|
6
6
|
const [error, setError] = useState(null);
|
|
@@ -18,7 +18,7 @@ export function useFile({ client, podId, path = null, namespace, enabled = true,
|
|
|
18
18
|
setError(null);
|
|
19
19
|
try {
|
|
20
20
|
const scopedClient = resolvePodClient(client, podId);
|
|
21
|
-
const nextFile = await scopedClient.files.get(nextPath
|
|
21
|
+
const nextFile = await scopedClient.files.get(nextPath);
|
|
22
22
|
if (signal?.aborted)
|
|
23
23
|
return null;
|
|
24
24
|
setFile(nextFile);
|
|
@@ -35,7 +35,7 @@ export function useFile({ client, podId, path = null, namespace, enabled = true,
|
|
|
35
35
|
if (!signal?.aborted)
|
|
36
36
|
setIsLoading(false);
|
|
37
37
|
}
|
|
38
|
-
}, [client, enabled,
|
|
38
|
+
}, [client, enabled, podId, trimmedPath]);
|
|
39
39
|
useEffect(() => {
|
|
40
40
|
if (!isEnabled) {
|
|
41
41
|
setFile(null);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { LemmaClient } from "../client.js";
|
|
2
|
-
import type { DatastoreFileNamespace } from "../types.js";
|
|
3
2
|
export type FilePreviewMode = "rendered" | "artifact";
|
|
4
3
|
export interface UseFilePreviewOptions {
|
|
5
4
|
client: LemmaClient;
|
|
@@ -9,7 +8,6 @@ export interface UseFilePreviewOptions {
|
|
|
9
8
|
autoLoad?: boolean;
|
|
10
9
|
mode?: FilePreviewMode;
|
|
11
10
|
artifact?: string;
|
|
12
|
-
namespace?: DatastoreFileNamespace | null;
|
|
13
11
|
}
|
|
14
12
|
export interface UseFilePreviewResult {
|
|
15
13
|
content: string | null;
|
|
@@ -20,7 +18,6 @@ export interface UseFilePreviewResult {
|
|
|
20
18
|
path?: string | null;
|
|
21
19
|
mode?: FilePreviewMode;
|
|
22
20
|
artifact?: string;
|
|
23
|
-
namespace?: DatastoreFileNamespace | null;
|
|
24
21
|
}) => Promise<string | null>;
|
|
25
22
|
}
|
|
26
|
-
export declare function useFilePreview({ client, podId, path, enabled, autoLoad, mode, artifact,
|
|
23
|
+
export declare function useFilePreview({ client, podId, path, enabled, autoLoad, mode, artifact, }: UseFilePreviewOptions): UseFilePreviewResult;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
2
2
|
import { normalizeError, resolvePodClient } from "./utils.js";
|
|
3
|
-
export function useFilePreview({ client, podId, path = null, enabled = true, autoLoad = true, mode = "rendered", artifact = "document.md",
|
|
3
|
+
export function useFilePreview({ client, podId, path = null, enabled = true, autoLoad = true, mode = "rendered", artifact = "document.md", }) {
|
|
4
4
|
const [content, setContent] = useState(null);
|
|
5
5
|
const [blob, setBlob] = useState(null);
|
|
6
6
|
const [isLoading, setIsLoading] = useState(false);
|
|
@@ -22,9 +22,8 @@ export function useFilePreview({ client, podId, path = null, enabled = true, aut
|
|
|
22
22
|
setError(null);
|
|
23
23
|
try {
|
|
24
24
|
const scopedClient = resolvePodClient(client, podId);
|
|
25
|
-
const nextNamespace = overrides.namespace ?? namespace;
|
|
26
25
|
if (nextMode === "artifact") {
|
|
27
|
-
const nextBlob = await scopedClient.files.converted.download(nextPath, nextArtifact
|
|
26
|
+
const nextBlob = await scopedClient.files.converted.download(nextPath, nextArtifact);
|
|
28
27
|
const text = await nextBlob.text();
|
|
29
28
|
if (signal?.aborted)
|
|
30
29
|
return null;
|
|
@@ -32,7 +31,7 @@ export function useFilePreview({ client, podId, path = null, enabled = true, aut
|
|
|
32
31
|
setContent(text);
|
|
33
32
|
return text;
|
|
34
33
|
}
|
|
35
|
-
const rendered = await scopedClient.files.converted.render(nextPath
|
|
34
|
+
const rendered = await scopedClient.files.converted.render(nextPath);
|
|
36
35
|
const text = typeof rendered === "string" ? rendered : String(rendered ?? "");
|
|
37
36
|
if (signal?.aborted)
|
|
38
37
|
return null;
|
|
@@ -52,7 +51,7 @@ export function useFilePreview({ client, podId, path = null, enabled = true, aut
|
|
|
52
51
|
if (!signal?.aborted)
|
|
53
52
|
setIsLoading(false);
|
|
54
53
|
}
|
|
55
|
-
}, [artifact, client, enabled, mode,
|
|
54
|
+
}, [artifact, client, enabled, mode, podId, trimmedPath]);
|
|
56
55
|
useEffect(() => {
|
|
57
56
|
if (!isEnabled) {
|
|
58
57
|
setContent(null);
|
|
@@ -9,6 +9,8 @@ export interface UseFileSearchOptions {
|
|
|
9
9
|
minQueryLength?: number;
|
|
10
10
|
limit?: number;
|
|
11
11
|
searchMethod?: SearchMethod;
|
|
12
|
+
scopePath?: string;
|
|
13
|
+
scopeMode?: "DIRECT" | "SUBTREE";
|
|
12
14
|
}
|
|
13
15
|
export interface UseFileSearchResult {
|
|
14
16
|
response: FileSearchResponse | null;
|
|
@@ -20,7 +22,9 @@ export interface UseFileSearchResult {
|
|
|
20
22
|
query?: string;
|
|
21
23
|
limit?: number;
|
|
22
24
|
searchMethod?: SearchMethod;
|
|
25
|
+
scopePath?: string;
|
|
26
|
+
scopeMode?: "DIRECT" | "SUBTREE";
|
|
23
27
|
}) => Promise<FileSearchResponse | null>;
|
|
24
28
|
reset: () => void;
|
|
25
29
|
}
|
|
26
|
-
export declare function useFileSearch({ client, podId, query, enabled, autoLoad, minQueryLength, limit, searchMethod, }: UseFileSearchOptions): UseFileSearchResult;
|
|
30
|
+
export declare function useFileSearch({ client, podId, query, enabled, autoLoad, minQueryLength, limit, searchMethod, scopePath, scopeMode, }: UseFileSearchOptions): UseFileSearchResult;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
2
2
|
import { normalizeError, resolvePodClient } from "./utils.js";
|
|
3
|
-
export function useFileSearch({ client, podId, query = "", enabled = true, autoLoad = true, minQueryLength = 1, limit = 10, searchMethod, }) {
|
|
3
|
+
export function useFileSearch({ client, podId, query = "", enabled = true, autoLoad = true, minQueryLength = 1, limit = 10, searchMethod, scopePath, scopeMode, }) {
|
|
4
4
|
const [response, setResponse] = useState(null);
|
|
5
5
|
const [isLoading, setIsLoading] = useState(false);
|
|
6
6
|
const [error, setError] = useState(null);
|
|
@@ -23,6 +23,8 @@ export function useFileSearch({ client, podId, query = "", enabled = true, autoL
|
|
|
23
23
|
const nextResponse = await scopedClient.files.search(nextQuery, {
|
|
24
24
|
limit: overrides.limit ?? limit,
|
|
25
25
|
searchMethod: overrides.searchMethod ?? searchMethod,
|
|
26
|
+
scopePath: overrides.scopePath ?? scopePath,
|
|
27
|
+
scopeMode: overrides.scopeMode ?? scopeMode,
|
|
26
28
|
});
|
|
27
29
|
if (signal?.aborted)
|
|
28
30
|
return null;
|
|
@@ -40,7 +42,7 @@ export function useFileSearch({ client, podId, query = "", enabled = true, autoL
|
|
|
40
42
|
if (!signal?.aborted)
|
|
41
43
|
setIsLoading(false);
|
|
42
44
|
}
|
|
43
|
-
}, [client, enabled, limit, minQueryLength, podId, reset, searchMethod, trimmedQuery]);
|
|
45
|
+
}, [client, enabled, limit, minQueryLength, podId, reset, scopeMode, scopePath, searchMethod, trimmedQuery]);
|
|
44
46
|
useEffect(() => {
|
|
45
47
|
if (!enabled || !autoLoad)
|
|
46
48
|
return;
|
|
@@ -54,8 +56,8 @@ export function useFileSearch({ client, podId, query = "", enabled = true, autoL
|
|
|
54
56
|
}, [autoLoad, enabled, minQueryLength, reset, search, trimmedQuery]);
|
|
55
57
|
return useMemo(() => ({
|
|
56
58
|
response,
|
|
57
|
-
results: response?.
|
|
58
|
-
totalResults: response?.
|
|
59
|
+
results: response?.items ?? [],
|
|
60
|
+
totalResults: response?.total ?? 0,
|
|
59
61
|
isLoading,
|
|
60
62
|
error,
|
|
61
63
|
search,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { LemmaClient } from "../client.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { DirectoryTreeNode, DirectoryTreeResponse } from "../types.js";
|
|
3
3
|
export interface UseFileTreeOptions {
|
|
4
4
|
client: LemmaClient;
|
|
5
5
|
podId?: string;
|
|
@@ -7,7 +7,6 @@ export interface UseFileTreeOptions {
|
|
|
7
7
|
autoLoad?: boolean;
|
|
8
8
|
rootPath?: string;
|
|
9
9
|
filesPerDirectory?: number;
|
|
10
|
-
namespace?: DatastoreFileNamespace | null;
|
|
11
10
|
}
|
|
12
11
|
export interface UseFileTreeResult {
|
|
13
12
|
tree: DirectoryTreeNode | null;
|
|
@@ -17,7 +16,6 @@ export interface UseFileTreeResult {
|
|
|
17
16
|
refresh: (overrides?: {
|
|
18
17
|
rootPath?: string;
|
|
19
18
|
filesPerDirectory?: number;
|
|
20
|
-
namespace?: DatastoreFileNamespace | null;
|
|
21
19
|
}) => Promise<DirectoryTreeResponse | null>;
|
|
22
20
|
}
|
|
23
|
-
export declare function useFileTree({ client, podId, enabled, autoLoad, rootPath, filesPerDirectory,
|
|
21
|
+
export declare function useFileTree({ client, podId, enabled, autoLoad, rootPath, filesPerDirectory, }: UseFileTreeOptions): UseFileTreeResult;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
2
2
|
import { normalizeError, resolvePodClient } from "./utils.js";
|
|
3
|
-
export function useFileTree({ client, podId, enabled = true, autoLoad = true, rootPath = "/", filesPerDirectory = 3,
|
|
3
|
+
export function useFileTree({ client, podId, enabled = true, autoLoad = true, rootPath = "/", filesPerDirectory = 3, }) {
|
|
4
4
|
const [response, setResponse] = useState(null);
|
|
5
5
|
const [isLoading, setIsLoading] = useState(false);
|
|
6
6
|
const [error, setError] = useState(null);
|
|
@@ -18,7 +18,6 @@ export function useFileTree({ client, podId, enabled = true, autoLoad = true, ro
|
|
|
18
18
|
const nextResponse = await scopedClient.files.tree({
|
|
19
19
|
rootPath: overrides.rootPath ?? rootPath,
|
|
20
20
|
filesPerDirectory: overrides.filesPerDirectory ?? filesPerDirectory,
|
|
21
|
-
namespace: overrides.namespace ?? namespace,
|
|
22
21
|
});
|
|
23
22
|
if (signal?.aborted)
|
|
24
23
|
return null;
|
|
@@ -36,7 +35,7 @@ export function useFileTree({ client, podId, enabled = true, autoLoad = true, ro
|
|
|
36
35
|
if (!signal?.aborted)
|
|
37
36
|
setIsLoading(false);
|
|
38
37
|
}
|
|
39
|
-
}, [client, enabled, filesPerDirectory,
|
|
38
|
+
}, [client, enabled, filesPerDirectory, podId, rootPath]);
|
|
40
39
|
useEffect(() => {
|
|
41
40
|
if (!enabled) {
|
|
42
41
|
setResponse(null);
|
package/dist/react/useFiles.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { LemmaClient } from "../client.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { FileResponse } from "../types.js";
|
|
3
3
|
export interface UseFilesOptions {
|
|
4
4
|
client: LemmaClient;
|
|
5
5
|
podId?: string;
|
|
@@ -9,7 +9,6 @@ export interface UseFilesOptions {
|
|
|
9
9
|
pageToken?: string;
|
|
10
10
|
directoryPath?: string;
|
|
11
11
|
parentId?: string;
|
|
12
|
-
namespace?: DatastoreFileNamespace | null;
|
|
13
12
|
}
|
|
14
13
|
export interface UseFilesResult {
|
|
15
14
|
files: FileResponse[];
|
|
@@ -22,10 +21,9 @@ export interface UseFilesResult {
|
|
|
22
21
|
pageToken?: string;
|
|
23
22
|
directoryPath?: string;
|
|
24
23
|
parentId?: string;
|
|
25
|
-
namespace?: DatastoreFileNamespace | null;
|
|
26
24
|
}) => Promise<FileResponse[]>;
|
|
27
25
|
loadMore: (overrides?: {
|
|
28
26
|
limit?: number;
|
|
29
27
|
}) => Promise<FileResponse[]>;
|
|
30
28
|
}
|
|
31
|
-
export declare function useFiles({ client, podId, enabled, autoLoad, limit, pageToken, directoryPath, parentId,
|
|
29
|
+
export declare function useFiles({ client, podId, enabled, autoLoad, limit, pageToken, directoryPath, parentId, }: UseFilesOptions): UseFilesResult;
|