lemma-sdk 0.2.40 → 0.2.42
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 +10 -3
- package/dist/browser/lemma-client.js +95 -68
- package/dist/index.d.ts +1 -1
- package/dist/namespaces/conversations.d.ts +6 -0
- package/dist/namespaces/conversations.js +2 -0
- package/dist/namespaces/files.js +12 -21
- package/dist/namespaces/resources.d.ts +21 -5
- package/dist/openapi_client/index.d.ts +21 -15
- package/dist/openapi_client/index.js +5 -5
- package/dist/openapi_client/models/AgentResponse.d.ts +3 -2
- package/dist/openapi_client/models/BillingHistoryResponse.d.ts +8 -0
- package/dist/openapi_client/models/BillingInvoiceResponse.d.ts +29 -0
- package/dist/openapi_client/models/BillingInvoiceStatus.d.ts +10 -0
- package/dist/openapi_client/models/BillingInvoiceStatus.js +15 -0
- package/dist/openapi_client/models/BillingScope.d.ts +7 -0
- package/dist/openapi_client/models/BillingScope.js +12 -0
- package/dist/openapi_client/models/ConversationResponse.d.ts +6 -0
- package/dist/openapi_client/models/ConversationStatus.d.ts +11 -0
- package/dist/openapi_client/models/ConversationStatus.js +16 -0
- package/dist/openapi_client/models/ConversationType.d.ts +7 -0
- package/dist/openapi_client/models/ConversationType.js +12 -0
- package/dist/openapi_client/models/CreateAgentRequest.d.ts +3 -2
- package/dist/openapi_client/models/CreateConversationRequest.d.ts +4 -0
- package/dist/openapi_client/models/CreateDeskRequest.d.ts +1 -0
- package/dist/openapi_client/models/CreateFolderRequest.d.ts +1 -2
- package/dist/openapi_client/models/CreateFunctionRequest.d.ts +9 -4
- package/dist/openapi_client/models/CreateInvoicePaymentUrlRequest.d.ts +7 -0
- package/dist/openapi_client/models/CreateInvoicePaymentUrlResponse.d.ts +8 -0
- package/dist/openapi_client/models/CreateScheduleRequest.d.ts +1 -0
- package/dist/openapi_client/models/CreateTableRequest.d.ts +1 -0
- package/dist/openapi_client/models/DatastoreFileUploadRequest.d.ts +1 -2
- package/dist/openapi_client/models/DeskResponse.d.ts +2 -0
- package/dist/openapi_client/models/FileResponse.d.ts +2 -2
- package/dist/openapi_client/models/FlowResponse.d.ts +2 -0
- package/dist/openapi_client/models/FunctionResponse.d.ts +13 -2
- package/dist/openapi_client/models/{app__modules__function__api__schemas__function_schemas__TableAccessEntry.d.ts → FunctionTableAccessEntry.d.ts} +1 -1
- package/dist/openapi_client/models/PodMemberAddRequest.d.ts +1 -0
- package/dist/openapi_client/models/PodMemberDetailResponse.d.ts +1 -0
- package/dist/openapi_client/models/PodMemberResponse.d.ts +1 -0
- package/dist/openapi_client/models/PodMemberUpdateRoleRequest.d.ts +2 -1
- package/dist/openapi_client/models/PodRoleCreateRequest.d.ts +6 -0
- package/dist/openapi_client/models/PodRoleListResponse.d.ts +7 -0
- package/dist/openapi_client/models/PodRoleResponse.d.ts +11 -0
- package/dist/openapi_client/models/ScheduleResponse.d.ts +2 -0
- package/dist/openapi_client/models/SendMessageRequest.d.ts +1 -0
- package/dist/openapi_client/models/StartSubscriptionResponse.d.ts +3 -1
- package/dist/openapi_client/models/StartTeamBillingRequest.d.ts +6 -0
- package/dist/openapi_client/models/SubscriptionResponse.d.ts +22 -0
- package/dist/openapi_client/models/SubscriptionWithPlanResponse.d.ts +4 -1
- package/dist/openapi_client/models/{app__modules__agent__domain__value_objects__TableAccessEntry.d.ts → TableAccessEntry.d.ts} +1 -1
- package/dist/openapi_client/models/TableAccessEntry.js +1 -0
- package/dist/openapi_client/models/TableResponse.d.ts +2 -0
- package/dist/openapi_client/models/UpdateAgentRequest.d.ts +3 -2
- package/dist/openapi_client/models/UpdateConversationRequest.d.ts +2 -0
- package/dist/openapi_client/models/UpdateDeskRequest.d.ts +2 -0
- package/dist/openapi_client/models/UpdateFunctionRequest.d.ts +6 -2
- package/dist/openapi_client/models/UpdateScheduleRequest.d.ts +1 -0
- package/dist/openapi_client/models/UpdateTableRequest.d.ts +2 -1
- package/dist/openapi_client/models/UsageLimitScopeResponse.d.ts +10 -0
- package/dist/openapi_client/models/UsageLimitScopeResponse.js +1 -0
- package/dist/openapi_client/models/UsageLimitsResponse.d.ts +11 -0
- package/dist/openapi_client/models/UsageLimitsResponse.js +1 -0
- package/dist/openapi_client/models/UsageListResponse.d.ts +10 -0
- package/dist/openapi_client/models/UsageListResponse.js +1 -0
- package/dist/openapi_client/models/UsageRecordResponse.d.ts +12 -4
- package/dist/openapi_client/models/UsageStatsBucketResponse.d.ts +12 -0
- package/dist/openapi_client/models/UsageStatsBucketResponse.js +1 -0
- package/dist/openapi_client/models/UsageStatsResponse.d.ts +12 -0
- package/dist/openapi_client/models/UsageStatsResponse.js +1 -0
- package/dist/openapi_client/models/UsageSummaryResponse.d.ts +3 -0
- package/dist/openapi_client/models/WorkflowCreateRequest.d.ts +1 -0
- package/dist/openapi_client/models/WorkflowUpdateRequest.d.ts +1 -0
- package/dist/openapi_client/models/update.d.ts +1 -2
- package/dist/openapi_client/services/AgentConversationsService.d.ts +5 -1
- package/dist/openapi_client/services/AgentConversationsService.js +5 -1
- package/dist/openapi_client/services/BillingSubscriptionsService.d.ts +80 -20
- package/dist/openapi_client/services/BillingSubscriptionsService.js +164 -27
- package/dist/openapi_client/services/BillingUsageService.d.ts +89 -5
- package/dist/openapi_client/services/BillingUsageService.js +186 -6
- package/dist/openapi_client/services/DesksService.d.ts +21 -4
- package/dist/openapi_client/services/DesksService.js +44 -2
- package/dist/openapi_client/services/FilesService.d.ts +11 -20
- package/dist/openapi_client/services/FilesService.js +11 -28
- package/dist/openapi_client/services/FunctionsService.d.ts +2 -2
- package/dist/openapi_client/services/FunctionsService.js +2 -2
- package/dist/openapi_client/services/PodMembersService.d.ts +10 -0
- package/dist/openapi_client/services/PodMembersService.js +24 -0
- package/dist/openapi_client/services/PodRolesService.d.ts +29 -0
- package/dist/openapi_client/services/PodRolesService.js +63 -0
- package/dist/react/AuthGuard.d.ts +0 -15
- package/dist/react/AuthGuard.js +128 -167
- package/dist/react/index.d.ts +1 -1
- package/dist/react/useAssistantController.d.ts +8 -4
- package/dist/react/useAssistantController.js +9 -6
- package/dist/react/useAssistantSession.d.ts +9 -0
- package/dist/react/useAssistantSession.js +10 -2
- package/dist/react/useConversationMessages.d.ts +2 -1
- package/dist/react/useConversationMessages.js +2 -1
- package/dist/react/useConversations.d.ts +7 -1
- package/dist/react/useConversations.js +10 -4
- package/dist/types.d.ts +2 -2
- package/package.json +1 -1
- package/dist/openapi_client/models/Body_upload_file_files__resource_type___resource_id__upload_post.d.ts +0 -3
- package/dist/openapi_client/models/FileInfo.d.ts +0 -14
- package/dist/openapi_client/models/FileInfo.js +0 -8
- package/dist/openapi_client/models/FileNamespace.d.ts +0 -4
- package/dist/openapi_client/models/FileNamespace.js +0 -9
- package/dist/openapi_client/models/FileUploadResponse.d.ts +0 -6
- package/dist/openapi_client/models/GrantPermissionRequest.d.ts +0 -6
- package/dist/openapi_client/models/PodPermissionsResponse.d.ts +0 -4
- package/dist/openapi_client/models/ResourceFileListResponse.d.ts +0 -6
- package/dist/openapi_client/models/ResourcePermissionListResponse.d.ts +0 -4
- package/dist/openapi_client/models/ResourcePermissionResponse.d.ts +0 -12
- package/dist/openapi_client/models/ResourceType.d.ts +0 -4
- package/dist/openapi_client/models/ResourceType.js +0 -9
- package/dist/openapi_client/models/SetVisibilityRequest.d.ts +0 -3
- package/dist/openapi_client/services/AgentFilesService.d.ts +0 -46
- package/dist/openapi_client/services/AgentFilesService.js +0 -103
- package/dist/openapi_client/services/AuthorizationService.d.ts +0 -58
- package/dist/openapi_client/services/AuthorizationService.js +0 -122
- /package/dist/openapi_client/models/{Body_upload_file_files__resource_type___resource_id__upload_post.js → BillingHistoryResponse.js} +0 -0
- /package/dist/openapi_client/models/{FileUploadResponse.js → BillingInvoiceResponse.js} +0 -0
- /package/dist/openapi_client/models/{GrantPermissionRequest.js → CreateInvoicePaymentUrlRequest.js} +0 -0
- /package/dist/openapi_client/models/{PodPermissionsResponse.js → CreateInvoicePaymentUrlResponse.js} +0 -0
- /package/dist/openapi_client/models/{ResourceFileListResponse.js → FunctionTableAccessEntry.js} +0 -0
- /package/dist/openapi_client/models/{ResourcePermissionListResponse.js → PodRoleCreateRequest.js} +0 -0
- /package/dist/openapi_client/models/{ResourcePermissionResponse.js → PodRoleListResponse.js} +0 -0
- /package/dist/openapi_client/models/{SetVisibilityRequest.js → PodRoleResponse.js} +0 -0
- /package/dist/openapi_client/models/{app__modules__agent__domain__value_objects__TableAccessEntry.js → StartTeamBillingRequest.js} +0 -0
- /package/dist/openapi_client/models/{app__modules__function__api__schemas__function_schemas__TableAccessEntry.js → SubscriptionResponse.js} +0 -0
package/dist/react/AuthGuard.js
CHANGED
|
@@ -1,172 +1,131 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { useCallback
|
|
3
|
-
import { ApiError } from "../http.js";
|
|
2
|
+
import { useCallback } from "react";
|
|
4
3
|
import { useAuth } from "./useAuth.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
import { usePodAccess } from "./usePodAccess.js";
|
|
5
|
+
const pageStyle = {
|
|
6
|
+
display: "flex",
|
|
7
|
+
alignItems: "center",
|
|
8
|
+
justifyContent: "center",
|
|
9
|
+
minHeight: "100vh",
|
|
10
|
+
padding: "24px",
|
|
11
|
+
fontFamily: "Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", sans-serif",
|
|
12
|
+
background: "linear-gradient(135deg, #f8fafc 0%, #eef2f7 46%, #f9fafb 100%)",
|
|
13
|
+
color: "#172033",
|
|
14
|
+
};
|
|
15
|
+
const panelStyle = {
|
|
16
|
+
width: "100%",
|
|
17
|
+
maxWidth: "440px",
|
|
18
|
+
border: "1px solid rgba(23, 32, 51, 0.1)",
|
|
19
|
+
borderRadius: "14px",
|
|
20
|
+
backgroundColor: "rgba(255, 255, 255, 0.94)",
|
|
21
|
+
boxShadow: "0 18px 60px rgba(23, 32, 51, 0.12)",
|
|
22
|
+
padding: "28px",
|
|
23
|
+
};
|
|
24
|
+
const eyebrowStyle = {
|
|
25
|
+
margin: "0 0 10px",
|
|
26
|
+
fontSize: "12px",
|
|
27
|
+
fontWeight: 700,
|
|
28
|
+
letterSpacing: "0.08em",
|
|
29
|
+
textTransform: "uppercase",
|
|
30
|
+
color: "#5f6f8a",
|
|
31
|
+
};
|
|
32
|
+
const titleStyle = {
|
|
33
|
+
margin: "0",
|
|
34
|
+
color: "#111827",
|
|
35
|
+
fontSize: "24px",
|
|
36
|
+
fontWeight: 700,
|
|
37
|
+
lineHeight: 1.18,
|
|
38
|
+
};
|
|
39
|
+
const bodyStyle = {
|
|
40
|
+
margin: "12px 0 0",
|
|
41
|
+
color: "#526173",
|
|
42
|
+
fontSize: "14px",
|
|
43
|
+
lineHeight: 1.55,
|
|
44
|
+
};
|
|
45
|
+
const buttonRowStyle = {
|
|
46
|
+
display: "flex",
|
|
47
|
+
gap: "10px",
|
|
48
|
+
marginTop: "24px",
|
|
49
|
+
flexWrap: "wrap",
|
|
50
|
+
};
|
|
51
|
+
function buttonStyle(variant, disabled = false) {
|
|
52
|
+
return {
|
|
53
|
+
flex: "1 1 160px",
|
|
54
|
+
minHeight: "42px",
|
|
55
|
+
border: variant === "primary" ? "1px solid #182235" : "1px solid rgba(23, 32, 51, 0.14)",
|
|
56
|
+
borderRadius: "10px",
|
|
57
|
+
backgroundColor: disabled
|
|
58
|
+
? "#d5dbe5"
|
|
59
|
+
: variant === "primary"
|
|
60
|
+
? "#182235"
|
|
61
|
+
: "#ffffff",
|
|
62
|
+
color: disabled
|
|
63
|
+
? "#6b7280"
|
|
64
|
+
: variant === "primary"
|
|
65
|
+
? "#ffffff"
|
|
66
|
+
: "#172033",
|
|
67
|
+
fontSize: "14px",
|
|
68
|
+
fontWeight: 650,
|
|
69
|
+
cursor: disabled ? "not-allowed" : "pointer",
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
function StatusPill({ status }) {
|
|
73
|
+
const label = status === "pending"
|
|
74
|
+
? "Request pending"
|
|
75
|
+
: status === "error"
|
|
76
|
+
? "Needs attention"
|
|
77
|
+
: "Access required";
|
|
78
|
+
return (_jsx("span", { style: {
|
|
79
|
+
display: "inline-flex",
|
|
9
80
|
alignItems: "center",
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
width: "100%",
|
|
23
|
-
}, children: [_jsx("div", { style: {
|
|
24
|
-
width: "40px",
|
|
25
|
-
height: "40px",
|
|
26
|
-
borderRadius: "8px",
|
|
27
|
-
backgroundColor: "#111827",
|
|
28
|
-
margin: "0 auto 20px",
|
|
29
|
-
} }), _jsx("h1", { style: { margin: "0 0 8px", fontSize: "20px", fontWeight: 600, color: "#111827" }, children: "Sign in to continue" }), _jsx("p", { style: { margin: "0 0 24px", fontSize: "14px", color: "#6b7280" }, children: "You need to be signed in to access this app." }), _jsx("button", { onClick: onSignIn, style: {
|
|
30
|
-
width: "100%",
|
|
31
|
-
padding: "10px 16px",
|
|
32
|
-
backgroundColor: "#111827",
|
|
33
|
-
color: "#fff",
|
|
34
|
-
border: "none",
|
|
35
|
-
borderRadius: "8px",
|
|
36
|
-
fontSize: "14px",
|
|
37
|
-
fontWeight: 500,
|
|
38
|
-
cursor: "pointer",
|
|
39
|
-
}, children: "Sign In" })] }) }));
|
|
81
|
+
borderRadius: "999px",
|
|
82
|
+
border: "1px solid rgba(95, 111, 138, 0.24)",
|
|
83
|
+
backgroundColor: "#f5f7fb",
|
|
84
|
+
color: "#526173",
|
|
85
|
+
padding: "5px 9px",
|
|
86
|
+
fontSize: "12px",
|
|
87
|
+
fontWeight: 650,
|
|
88
|
+
marginBottom: "16px",
|
|
89
|
+
}, children: label }));
|
|
90
|
+
}
|
|
91
|
+
function DefaultSignInPage({ onSignIn }) {
|
|
92
|
+
return (_jsx("div", { style: pageStyle, children: _jsxs("div", { style: panelStyle, children: [_jsx("p", { style: eyebrowStyle, children: "Lemma app" }), _jsx("h1", { style: titleStyle, children: "Sign in to continue" }), _jsx("p", { style: bodyStyle, children: "Use your Lemma account to open this workspace and keep your session synced." }), _jsx("div", { style: buttonRowStyle, children: _jsx("button", { onClick: onSignIn, style: buttonStyle("primary"), children: "Sign in" }) })] }) }));
|
|
40
93
|
}
|
|
41
|
-
function DefaultRequestAccessPage({
|
|
94
|
+
function DefaultRequestAccessPage({ status, isSubmitting, signedInAs, error, onRequestAccess, onRetry, }) {
|
|
95
|
+
const isPending = status === "pending";
|
|
96
|
+
const isError = status === "error";
|
|
97
|
+
const title = isPending
|
|
98
|
+
? "Your request is waiting for approval"
|
|
99
|
+
: isError
|
|
100
|
+
? "We could not verify access"
|
|
101
|
+
: "Request access to this pod";
|
|
42
102
|
const message = isPending
|
|
43
|
-
? "
|
|
44
|
-
: "You are signed in, but
|
|
45
|
-
return (_jsx("div", { style: {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
gap: "16px",
|
|
54
|
-
}, children: _jsxs("div", { style: {
|
|
55
|
-
backgroundColor: "#fff",
|
|
56
|
-
borderRadius: "12px",
|
|
57
|
-
boxShadow: "0 1px 4px rgba(0,0,0,0.1)",
|
|
58
|
-
padding: "40px 48px",
|
|
59
|
-
textAlign: "center",
|
|
60
|
-
maxWidth: "420px",
|
|
61
|
-
width: "100%",
|
|
62
|
-
}, children: [_jsx("h1", { style: { margin: "0 0 8px", fontSize: "20px", fontWeight: 600, color: "#111827" }, children: "Request pod access" }), _jsx("p", { style: { margin: "0 0 24px", fontSize: "14px", color: "#6b7280" }, children: message }), _jsx("button", { onClick: onRequestAccess, disabled: isSubmitting || isPending, style: {
|
|
63
|
-
width: "100%",
|
|
64
|
-
padding: "10px 16px",
|
|
65
|
-
backgroundColor: isSubmitting || isPending ? "#9ca3af" : "#111827",
|
|
66
|
-
color: "#fff",
|
|
67
|
-
border: "none",
|
|
68
|
-
borderRadius: "8px",
|
|
69
|
-
fontSize: "14px",
|
|
70
|
-
fontWeight: 500,
|
|
71
|
-
cursor: isSubmitting || isPending ? "not-allowed" : "pointer",
|
|
72
|
-
}, children: isSubmitting ? "Submitting..." : isPending ? "Request Sent" : "Request Access" }), error ? (_jsx("p", { style: { margin: "12px 0 0", fontSize: "13px", color: "#b91c1c" }, children: error })) : null] }) }));
|
|
103
|
+
? "An admin can approve your request from pod settings. You can refresh this screen after they add you."
|
|
104
|
+
: "You are signed in, but this pod is gated to members. Send an access request and an admin can let you in.";
|
|
105
|
+
return (_jsx("div", { style: pageStyle, children: _jsxs("div", { style: panelStyle, children: [_jsx(StatusPill, { status: status }), _jsx("h1", { style: titleStyle, children: title }), _jsx("p", { style: bodyStyle, children: message }), signedInAs ? (_jsxs("p", { style: {
|
|
106
|
+
margin: "18px 0 0",
|
|
107
|
+
borderRadius: "10px",
|
|
108
|
+
backgroundColor: "#f5f7fb",
|
|
109
|
+
padding: "10px 12px",
|
|
110
|
+
color: "#526173",
|
|
111
|
+
fontSize: "13px",
|
|
112
|
+
}, children: ["Signed in as ", _jsx("strong", { style: { color: "#172033" }, children: signedInAs })] })) : null, error ? (_jsx("p", { style: { margin: "14px 0 0", color: "#b42318", fontSize: "13px", lineHeight: 1.45 }, children: error.message })) : null, _jsxs("div", { style: buttonRowStyle, children: [_jsx("button", { onClick: onRequestAccess, disabled: isSubmitting || isPending, style: buttonStyle("primary", isSubmitting || isPending), children: isSubmitting ? "Sending..." : isPending ? "Request sent" : "Request access" }), _jsx("button", { onClick: onRetry, style: buttonStyle("secondary"), children: isError ? "Try again" : "Refresh" })] })] }) }));
|
|
73
113
|
}
|
|
74
|
-
/**
|
|
75
|
-
* AuthGuard wraps your application and handles auth state:
|
|
76
|
-
* - Loading: shows loadingFallback (blank by default)
|
|
77
|
-
* - Unauthenticated: shows sign-in page (or custom unauthenticatedFallback)
|
|
78
|
-
* - Authenticated and member: renders children
|
|
79
|
-
* - Authenticated but not pod member: shows request-access page
|
|
80
|
-
*
|
|
81
|
-
* Usage:
|
|
82
|
-
* <AuthGuard client={getClient()}>
|
|
83
|
-
* <App />
|
|
84
|
-
* </AuthGuard>
|
|
85
|
-
*/
|
|
86
114
|
export function AuthGuard({ client, children, loadingFallback = null, unauthenticatedFallback, accessRequestFallback, }) {
|
|
87
115
|
const { isLoading, isAuthenticated, redirectToAuth } = useAuth(client);
|
|
88
|
-
const
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
await client.podMembers.lookupByUserId(client.podId, currentUser.id);
|
|
102
|
-
setMembershipState("member");
|
|
103
|
-
setJoinRequest(null);
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
catch (error) {
|
|
107
|
-
const apiError = error instanceof ApiError ? error : null;
|
|
108
|
-
const isMissingMembership = apiError?.statusCode === 404 || apiError?.statusCode === 403;
|
|
109
|
-
if (!isMissingMembership) {
|
|
110
|
-
throw error;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
try {
|
|
114
|
-
const existingRequest = await client.podJoinRequests.me(client.podId);
|
|
115
|
-
setJoinRequest(existingRequest);
|
|
116
|
-
}
|
|
117
|
-
catch {
|
|
118
|
-
// non-fatal: request could still be created by the user manually
|
|
119
|
-
}
|
|
120
|
-
setMembershipState("missing");
|
|
121
|
-
}, [client, isAuthenticated]);
|
|
122
|
-
useEffect(() => {
|
|
123
|
-
let cancelled = false;
|
|
124
|
-
const run = async () => {
|
|
125
|
-
if (!isAuthenticated) {
|
|
126
|
-
setMembershipState("idle");
|
|
127
|
-
setJoinRequest(null);
|
|
128
|
-
setMembershipError(null);
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
try {
|
|
132
|
-
await checkMembership();
|
|
133
|
-
}
|
|
134
|
-
catch (error) {
|
|
135
|
-
if (cancelled)
|
|
136
|
-
return;
|
|
137
|
-
const message = error instanceof Error
|
|
138
|
-
? error.message
|
|
139
|
-
: "Failed to verify pod membership. Please try again.";
|
|
140
|
-
setMembershipError(message);
|
|
141
|
-
setMembershipState("missing");
|
|
142
|
-
}
|
|
143
|
-
};
|
|
144
|
-
void run();
|
|
145
|
-
return () => {
|
|
146
|
-
cancelled = true;
|
|
147
|
-
};
|
|
148
|
-
}, [checkMembership, isAuthenticated]);
|
|
149
|
-
const handleRequestAccess = useCallback(async () => {
|
|
150
|
-
if (!client.podId || isSubmittingJoinRequest || joinRequest?.status === "PENDING") {
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
setIsSubmittingJoinRequest(true);
|
|
154
|
-
setMembershipError(null);
|
|
155
|
-
try {
|
|
156
|
-
const request = await client.podJoinRequests.create(client.podId);
|
|
157
|
-
setJoinRequest(request);
|
|
158
|
-
}
|
|
159
|
-
catch (error) {
|
|
160
|
-
const message = error instanceof Error
|
|
161
|
-
? error.message
|
|
162
|
-
: "Failed to create access request. Please try again.";
|
|
163
|
-
setMembershipError(message);
|
|
164
|
-
}
|
|
165
|
-
finally {
|
|
166
|
-
setIsSubmittingJoinRequest(false);
|
|
167
|
-
}
|
|
168
|
-
}, [client, isSubmittingJoinRequest, joinRequest]);
|
|
169
|
-
if (isLoading || (isAuthenticated && membershipState === "checking")) {
|
|
116
|
+
const hasPodScope = Boolean(client.podId);
|
|
117
|
+
const podAccess = usePodAccess({
|
|
118
|
+
client,
|
|
119
|
+
enabled: isAuthenticated && hasPodScope,
|
|
120
|
+
autoLoad: isAuthenticated && hasPodScope,
|
|
121
|
+
});
|
|
122
|
+
const handleRequestAccess = useCallback(() => {
|
|
123
|
+
void podAccess.requestAccess();
|
|
124
|
+
}, [podAccess]);
|
|
125
|
+
const handleRetry = useCallback(() => {
|
|
126
|
+
void podAccess.refresh();
|
|
127
|
+
}, [podAccess]);
|
|
128
|
+
if (isLoading || (isAuthenticated && hasPodScope && podAccess.status === "checking")) {
|
|
170
129
|
return _jsx(_Fragment, { children: loadingFallback });
|
|
171
130
|
}
|
|
172
131
|
if (!isAuthenticated) {
|
|
@@ -175,11 +134,13 @@ export function AuthGuard({ client, children, loadingFallback = null, unauthenti
|
|
|
175
134
|
}
|
|
176
135
|
return _jsx(DefaultSignInPage, { onSignIn: redirectToAuth });
|
|
177
136
|
}
|
|
178
|
-
if (
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
return
|
|
137
|
+
if (!hasPodScope || podAccess.hasAccess) {
|
|
138
|
+
return _jsx(_Fragment, { children: children });
|
|
139
|
+
}
|
|
140
|
+
if (accessRequestFallback !== undefined) {
|
|
141
|
+
return _jsx(_Fragment, { children: accessRequestFallback });
|
|
183
142
|
}
|
|
184
|
-
|
|
143
|
+
const fullName = [podAccess.user?.first_name, podAccess.user?.last_name].filter(Boolean).join(" ");
|
|
144
|
+
const signedInAs = podAccess.user?.email ?? (fullName.length > 0 ? fullName : podAccess.user?.id ?? null);
|
|
145
|
+
return (_jsx(DefaultRequestAccessPage, { status: podAccess.status, isSubmitting: podAccess.isRequestingAccess, signedInAs: signedInAs, error: podAccess.error, onRequestAccess: handleRequestAccess, onRetry: handleRetry }));
|
|
185
146
|
}
|
package/dist/react/index.d.ts
CHANGED
|
@@ -85,7 +85,7 @@ export type { UseRecordFormOptions, UseRecordFormResult } from "./useRecordForm.
|
|
|
85
85
|
export { useSchemaForm } from "./useSchemaForm.js";
|
|
86
86
|
export type { UseSchemaFormOptions, UseSchemaFormResult } from "./useSchemaForm.js";
|
|
87
87
|
export { useAssistantController } from "./useAssistantController.js";
|
|
88
|
-
export type { AssistantAction, AssistantConversationScope, AssistantMessagePart, AssistantRenderableMessage, AssistantToolInvocation, UseAssistantControllerOptions, UseAssistantControllerResult, } from "./useAssistantController.js";
|
|
88
|
+
export type { AssistantAction, AssistantConversationScope, AssistantMessagePart, AssistantRenderableMessage, AssistantToolInvocation, SendAssistantControllerMessageOptions, UseAssistantControllerOptions, UseAssistantControllerResult, } from "./useAssistantController.js";
|
|
89
89
|
export { useFunctionSession } from "./useFunctionSession.js";
|
|
90
90
|
export type { UseFunctionSessionOptions, UseFunctionSessionResult, } from "./useFunctionSession.js";
|
|
91
91
|
export { useFunctionRun } from "./useFunctionRun.js";
|
|
@@ -57,6 +57,12 @@ export interface AssistantAction {
|
|
|
57
57
|
export interface UseAssistantControllerOptions extends AssistantConversationScope {
|
|
58
58
|
client: LemmaClient;
|
|
59
59
|
enabled?: boolean;
|
|
60
|
+
instructions?: string | null;
|
|
61
|
+
}
|
|
62
|
+
export interface SendAssistantControllerMessageOptions {
|
|
63
|
+
forceNewConversation?: boolean;
|
|
64
|
+
metadata?: Record<string, unknown> | null;
|
|
65
|
+
instructions?: string | null;
|
|
60
66
|
}
|
|
61
67
|
export interface UseAssistantControllerResult {
|
|
62
68
|
messages: AssistantRenderableMessage[];
|
|
@@ -77,9 +83,7 @@ export interface UseAssistantControllerResult {
|
|
|
77
83
|
completedActions: AssistantAction[];
|
|
78
84
|
selectConversation: (conversationId: string | null) => void;
|
|
79
85
|
setConversationModel: (model: ConversationModel | null) => Promise<void>;
|
|
80
|
-
sendMessage: (content: string, options?:
|
|
81
|
-
forceNewConversation?: boolean;
|
|
82
|
-
}) => Promise<void>;
|
|
86
|
+
sendMessage: (content: string, options?: SendAssistantControllerMessageOptions) => Promise<void>;
|
|
83
87
|
uploadFiles: (files: File[], options?: {
|
|
84
88
|
deferUntilSend?: boolean;
|
|
85
89
|
}) => Promise<void>;
|
|
@@ -89,4 +93,4 @@ export interface UseAssistantControllerResult {
|
|
|
89
93
|
clearMessages: () => void;
|
|
90
94
|
stop: () => void;
|
|
91
95
|
}
|
|
92
|
-
export declare function useAssistantController({ client, podId, agentName, assistantName, assistantId, organizationId, enabled, }: UseAssistantControllerOptions): UseAssistantControllerResult;
|
|
96
|
+
export declare function useAssistantController({ client, podId, agentName, assistantName, assistantId, organizationId, enabled, instructions, }: UseAssistantControllerOptions): UseAssistantControllerResult;
|
|
@@ -570,7 +570,7 @@ function appendPersonalFileReferences(content, files) {
|
|
|
570
570
|
const references = formatPersonalFileReferences(files);
|
|
571
571
|
return `${content}\n\nPersonal files available to this run:\n${references}`;
|
|
572
572
|
}
|
|
573
|
-
export function useAssistantController({ client, podId, agentName, assistantName, assistantId, organizationId, enabled = true, }) {
|
|
573
|
+
export function useAssistantController({ client, podId, agentName, assistantName, assistantId, organizationId, enabled = true, instructions, }) {
|
|
574
574
|
const [localError, setLocalError] = useState(null);
|
|
575
575
|
const [conversations, setConversations] = useState([]);
|
|
576
576
|
const [activeConversationId, setActiveConversationId] = useState(null);
|
|
@@ -617,6 +617,7 @@ export function useAssistantController({ client, podId, agentName, assistantName
|
|
|
617
617
|
assistantName: scope.assistantName ?? undefined,
|
|
618
618
|
assistantId: scope.assistantId ?? undefined,
|
|
619
619
|
organizationId: scope.organizationId ?? undefined,
|
|
620
|
+
instructions,
|
|
620
621
|
conversationId: activeConversationId ?? undefined,
|
|
621
622
|
autoLoad: false,
|
|
622
623
|
onError: handleAssistantSessionError,
|
|
@@ -977,13 +978,14 @@ export function useAssistantController({ client, podId, agentName, assistantName
|
|
|
977
978
|
const clearMessages = useCallback(() => {
|
|
978
979
|
resetConversationState(false);
|
|
979
980
|
}, [resetConversationState]);
|
|
980
|
-
const ensureConversation = useCallback(async (titleSeed) => {
|
|
981
|
+
const ensureConversation = useCallback(async (titleSeed, options = {}) => {
|
|
981
982
|
const existingConversationId = activeConversationIdRef.current;
|
|
982
983
|
if (existingConversationId) {
|
|
983
984
|
return existingConversationId;
|
|
984
985
|
}
|
|
985
986
|
const createdConversation = await sessionCreateConversation({
|
|
986
987
|
title: titleSeed.slice(0, 120),
|
|
988
|
+
instructions: typeof options.instructions === "undefined" ? instructions : options.instructions,
|
|
987
989
|
model: conversationModel,
|
|
988
990
|
...scope,
|
|
989
991
|
});
|
|
@@ -1001,7 +1003,7 @@ export function useAssistantController({ client, podId, agentName, assistantName
|
|
|
1001
1003
|
clearRuntimeMessages();
|
|
1002
1004
|
setOlderMessagesCursor(null);
|
|
1003
1005
|
return createdConversation.id;
|
|
1004
|
-
}, [clearRuntimeMessages, conversationModel, scope, sessionCreateConversation]);
|
|
1006
|
+
}, [clearRuntimeMessages, conversationModel, instructions, scope, sessionCreateConversation]);
|
|
1005
1007
|
const queuePendingFiles = useCallback((files) => {
|
|
1006
1008
|
if (files.length === 0)
|
|
1007
1009
|
return;
|
|
@@ -1018,11 +1020,11 @@ export function useAssistantController({ client, podId, agentName, assistantName
|
|
|
1018
1020
|
const clearPendingFiles = useCallback(() => {
|
|
1019
1021
|
setPendingFiles([]);
|
|
1020
1022
|
}, []);
|
|
1021
|
-
const sendMessage = useCallback(async (content, options) => {
|
|
1023
|
+
const sendMessage = useCallback(async (content, options = {}) => {
|
|
1022
1024
|
const trimmed = content.trim();
|
|
1023
1025
|
if (!enabled || !trimmed || isStreaming || sessionIsStreaming)
|
|
1024
1026
|
return;
|
|
1025
|
-
const forceNewConversation = options
|
|
1027
|
+
const forceNewConversation = options.forceNewConversation === true;
|
|
1026
1028
|
setLocalError(null);
|
|
1027
1029
|
if (forceNewConversation) {
|
|
1028
1030
|
resetConversationState(true);
|
|
@@ -1030,7 +1032,7 @@ export function useAssistantController({ client, podId, agentName, assistantName
|
|
|
1030
1032
|
let conversationId = forceNewConversation ? null : activeConversationId;
|
|
1031
1033
|
try {
|
|
1032
1034
|
if (!conversationId) {
|
|
1033
|
-
conversationId = await ensureConversation(trimmed);
|
|
1035
|
+
conversationId = await ensureConversation(trimmed, { instructions: options.instructions });
|
|
1034
1036
|
}
|
|
1035
1037
|
if (!conversationId) {
|
|
1036
1038
|
throw new Error("Conversation could not be initialized");
|
|
@@ -1057,6 +1059,7 @@ export function useAssistantController({ client, podId, agentName, assistantName
|
|
|
1057
1059
|
touchConversation(finalConversationId, { status: "running" });
|
|
1058
1060
|
await sessionSendMessage(messageContent, {
|
|
1059
1061
|
conversationId: finalConversationId,
|
|
1062
|
+
metadata: options.metadata ?? undefined,
|
|
1060
1063
|
});
|
|
1061
1064
|
touchConversation(finalConversationId, { updated_at: new Date().toISOString() });
|
|
1062
1065
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { LemmaClient } from "../client.js";
|
|
2
2
|
import { type SseRawEvent } from "../streams.js";
|
|
3
3
|
import type { Conversation, ConversationMessage, ConversationModel, CursorPage } from "../types.js";
|
|
4
|
+
import type { ConversationStatus } from "../openapi_client/models/ConversationStatus.js";
|
|
5
|
+
import type { ConversationType } from "../openapi_client/models/ConversationType.js";
|
|
4
6
|
interface ConversationScope {
|
|
5
7
|
podId?: string | null;
|
|
6
8
|
agentName?: string | null;
|
|
@@ -27,6 +29,7 @@ export interface UseAssistantSessionOptions {
|
|
|
27
29
|
*/
|
|
28
30
|
assistantId?: string;
|
|
29
31
|
organizationId?: string;
|
|
32
|
+
instructions?: string | null;
|
|
30
33
|
conversationId?: string | null;
|
|
31
34
|
autoLoad?: boolean;
|
|
32
35
|
autoResume?: boolean;
|
|
@@ -38,6 +41,9 @@ export interface UseAssistantSessionOptions {
|
|
|
38
41
|
}
|
|
39
42
|
export interface CreateConversationInput {
|
|
40
43
|
title?: string | null;
|
|
44
|
+
instructions?: string | null;
|
|
45
|
+
metadata?: Record<string, unknown> | null;
|
|
46
|
+
type?: ConversationType | `${ConversationType}` | null;
|
|
41
47
|
model?: ConversationModel | null;
|
|
42
48
|
podId?: string | null;
|
|
43
49
|
agentName?: string | null;
|
|
@@ -54,6 +60,7 @@ export interface CreateConversationInput {
|
|
|
54
60
|
}
|
|
55
61
|
export interface SendAssistantMessageOptions {
|
|
56
62
|
conversationId?: string | null;
|
|
63
|
+
metadata?: Record<string, unknown> | null;
|
|
57
64
|
syncOnTurnEnd?: boolean;
|
|
58
65
|
}
|
|
59
66
|
export interface ResumeAssistantOptions {
|
|
@@ -81,6 +88,8 @@ export interface UseAssistantSessionResult {
|
|
|
81
88
|
listConversations: (options?: {
|
|
82
89
|
limit?: number;
|
|
83
90
|
pageToken?: string;
|
|
91
|
+
status?: ConversationStatus | `${ConversationStatus}` | null;
|
|
92
|
+
type?: ConversationType | `${ConversationType}` | null;
|
|
84
93
|
scope?: ConversationScope;
|
|
85
94
|
}) => Promise<CursorPage<Conversation>>;
|
|
86
95
|
createConversation: (input?: CreateConversationInput) => Promise<Conversation>;
|
|
@@ -51,7 +51,7 @@ function resolveResumeInput(input) {
|
|
|
51
51
|
return input ?? {};
|
|
52
52
|
}
|
|
53
53
|
export function useAssistantSession(options) {
|
|
54
|
-
const { client, podId: defaultPodId, agentName: defaultAgentName, assistantName: defaultAssistantName, assistantId: defaultAssistantId, organizationId: defaultOrganizationId, conversationId: externalConversationId = null, autoLoad = true, autoResume = false, syncOnTurnEnd = false, onEvent, onStatus, onMessage, onError, } = options;
|
|
54
|
+
const { client, podId: defaultPodId, agentName: defaultAgentName, assistantName: defaultAssistantName, assistantId: defaultAssistantId, organizationId: defaultOrganizationId, instructions: defaultInstructions, conversationId: externalConversationId = null, autoLoad = true, autoResume = false, syncOnTurnEnd = false, onEvent, onStatus, onMessage, onError, } = options;
|
|
55
55
|
const [conversationId, setConversationIdState] = useState(externalConversationId);
|
|
56
56
|
const [conversation, setConversation] = useState(null);
|
|
57
57
|
const [status, setStatus] = useState(undefined);
|
|
@@ -166,6 +166,8 @@ export function useAssistantSession(options) {
|
|
|
166
166
|
const response = await scopedClient.conversations.list({
|
|
167
167
|
pod_id: scope.podId ?? undefined,
|
|
168
168
|
agent_name: scope.agentName ?? undefined,
|
|
169
|
+
status: input.status ?? undefined,
|
|
170
|
+
type: input.type,
|
|
169
171
|
limit: input.limit,
|
|
170
172
|
page_token: input.pageToken,
|
|
171
173
|
});
|
|
@@ -193,6 +195,11 @@ export function useAssistantSession(options) {
|
|
|
193
195
|
const scopedClient = applyPodScope(client, input.podId ?? defaultPodId ?? null);
|
|
194
196
|
const payload = {
|
|
195
197
|
title: input.title ?? undefined,
|
|
198
|
+
instructions: typeof input.instructions === "undefined"
|
|
199
|
+
? defaultInstructions ?? undefined
|
|
200
|
+
: input.instructions,
|
|
201
|
+
metadata: input.metadata ?? undefined,
|
|
202
|
+
type: input.type,
|
|
196
203
|
pod_id: input.podId ?? defaultPodId ?? scopedClient.podId ?? undefined,
|
|
197
204
|
agent_name: input.agentName
|
|
198
205
|
?? input.assistantName
|
|
@@ -228,6 +235,7 @@ export function useAssistantSession(options) {
|
|
|
228
235
|
defaultAgentName,
|
|
229
236
|
defaultAssistantId,
|
|
230
237
|
defaultAssistantName,
|
|
238
|
+
defaultInstructions,
|
|
231
239
|
defaultPodId,
|
|
232
240
|
setConversationStatus,
|
|
233
241
|
]);
|
|
@@ -386,7 +394,7 @@ export function useAssistantSession(options) {
|
|
|
386
394
|
abortRef.current = controller;
|
|
387
395
|
const scope = normalizeScope(client, defaultScope);
|
|
388
396
|
const scopedClient = applyPodScope(client, scope.podId);
|
|
389
|
-
const stream = await scopedClient.conversations.sendMessageStream(resolvedConversationId, { content }, {
|
|
397
|
+
const stream = await scopedClient.conversations.sendMessageStream(resolvedConversationId, { content, metadata: input.metadata ?? undefined }, {
|
|
390
398
|
pod_id: scope.podId ?? undefined,
|
|
391
399
|
signal: controller.signal,
|
|
392
400
|
});
|
|
@@ -15,6 +15,7 @@ export interface UseConversationMessagesOptions {
|
|
|
15
15
|
*/
|
|
16
16
|
assistantId?: string;
|
|
17
17
|
organizationId?: string;
|
|
18
|
+
instructions?: string | null;
|
|
18
19
|
conversationId?: string | null;
|
|
19
20
|
enabled?: boolean;
|
|
20
21
|
autoLoad?: boolean;
|
|
@@ -60,4 +61,4 @@ export interface UseConversationMessagesResult {
|
|
|
60
61
|
clearMessages: () => void;
|
|
61
62
|
createConversation: (input?: CreateConversationInput) => Promise<Conversation>;
|
|
62
63
|
}
|
|
63
|
-
export declare function useConversationMessages({ client, podId, agentName, assistantName, assistantId, organizationId, conversationId, enabled, autoLoad, autoResume, limit, syncOnTurnEnd, onEvent, onStatus, onMessage, onError, }: UseConversationMessagesOptions): UseConversationMessagesResult;
|
|
64
|
+
export declare function useConversationMessages({ client, podId, agentName, assistantName, assistantId, organizationId, instructions, conversationId, enabled, autoLoad, autoResume, limit, syncOnTurnEnd, onEvent, onStatus, onMessage, onError, }: UseConversationMessagesOptions): UseConversationMessagesResult;
|
|
@@ -12,7 +12,7 @@ function isSettledStatus(status, isStreaming) {
|
|
|
12
12
|
return true;
|
|
13
13
|
return !isConversationRunningStatus(normalized);
|
|
14
14
|
}
|
|
15
|
-
export function useConversationMessages({ client, podId, agentName, assistantName, assistantId, organizationId, conversationId = null, enabled = true, autoLoad = true, autoResume = false, limit = 100, syncOnTurnEnd = false, onEvent, onStatus, onMessage, onError, }) {
|
|
15
|
+
export function useConversationMessages({ client, podId, agentName, assistantName, assistantId, organizationId, instructions, conversationId = null, enabled = true, autoLoad = true, autoResume = false, limit = 100, syncOnTurnEnd = false, onEvent, onStatus, onMessage, onError, }) {
|
|
16
16
|
const [nextPageToken, setNextPageToken] = useState(null);
|
|
17
17
|
const [isLoading, setIsLoading] = useState(false);
|
|
18
18
|
const [isLoadingOlder, setIsLoadingOlder] = useState(false);
|
|
@@ -25,6 +25,7 @@ export function useConversationMessages({ client, podId, agentName, assistantNam
|
|
|
25
25
|
assistantName,
|
|
26
26
|
assistantId,
|
|
27
27
|
organizationId,
|
|
28
|
+
instructions,
|
|
28
29
|
conversationId: conversationId ?? undefined,
|
|
29
30
|
autoLoad: false,
|
|
30
31
|
autoResume: false,
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { LemmaClient } from "../client.js";
|
|
2
|
+
import type { ConversationStatus } from "../openapi_client/models/ConversationStatus.js";
|
|
3
|
+
import type { ConversationType } from "../openapi_client/models/ConversationType.js";
|
|
2
4
|
import type { Conversation } from "../types.js";
|
|
3
5
|
import { type CreateConversationInput } from "./useAssistantSession.js";
|
|
4
6
|
export interface UseConversationsOptions {
|
|
@@ -19,6 +21,8 @@ export interface UseConversationsOptions {
|
|
|
19
21
|
autoSelectFirst?: boolean;
|
|
20
22
|
limit?: number;
|
|
21
23
|
pageToken?: string;
|
|
24
|
+
status?: ConversationStatus | `${ConversationStatus}` | null;
|
|
25
|
+
type?: ConversationType | `${ConversationType}` | null;
|
|
22
26
|
initialConversationId?: string | null;
|
|
23
27
|
}
|
|
24
28
|
export interface UseConversationsResult {
|
|
@@ -45,6 +49,8 @@ export interface UseConversationsResult {
|
|
|
45
49
|
refresh: (overrides?: {
|
|
46
50
|
limit?: number;
|
|
47
51
|
pageToken?: string;
|
|
52
|
+
status?: ConversationStatus | `${ConversationStatus}` | null;
|
|
53
|
+
type?: ConversationType | `${ConversationType}` | null;
|
|
48
54
|
}) => Promise<Conversation[]>;
|
|
49
55
|
loadMore: (overrides?: {
|
|
50
56
|
limit?: number;
|
|
@@ -53,4 +59,4 @@ export interface UseConversationsResult {
|
|
|
53
59
|
createAndSelectConversation: (input?: Omit<CreateConversationInput, "setActive">) => Promise<Conversation>;
|
|
54
60
|
ensureConversation: (input?: Omit<CreateConversationInput, "setActive">) => Promise<Conversation>;
|
|
55
61
|
}
|
|
56
|
-
export declare function useConversations({ client, podId, agentName, assistantName, assistantId, organizationId, enabled, autoLoad, autoSelectFirst, limit, pageToken, initialConversationId, }: UseConversationsOptions): UseConversationsResult;
|
|
62
|
+
export declare function useConversations({ client, podId, agentName, assistantName, assistantId, organizationId, enabled, autoLoad, autoSelectFirst, limit, pageToken, status, type, initialConversationId, }: UseConversationsOptions): UseConversationsResult;
|
|
@@ -8,7 +8,7 @@ function sortConversationsByUpdatedAt(conversations) {
|
|
|
8
8
|
return bTime - aTime;
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
|
-
export function useConversations({ client, podId, agentName, assistantName, assistantId, organizationId, enabled = true, autoLoad = true, autoSelectFirst = true, limit = 20, pageToken, initialConversationId = null, }) {
|
|
11
|
+
export function useConversations({ client, podId, agentName, assistantName, assistantId, organizationId, enabled = true, autoLoad = true, autoSelectFirst = true, limit = 20, pageToken, status, type, initialConversationId = null, }) {
|
|
12
12
|
const [conversations, setConversations] = useState([]);
|
|
13
13
|
const [total, setTotal] = useState(0);
|
|
14
14
|
const [nextPageToken, setNextPageToken] = useState(null);
|
|
@@ -21,7 +21,9 @@ export function useConversations({ client, podId, agentName, assistantName, assi
|
|
|
21
21
|
assistantName: assistantName ?? null,
|
|
22
22
|
assistantId: assistantId ?? null,
|
|
23
23
|
organizationId: organizationId ?? null,
|
|
24
|
-
|
|
24
|
+
status: status ?? null,
|
|
25
|
+
type: type ?? null,
|
|
26
|
+
}), [agentName, assistantId, assistantName, organizationId, podId, status, type]);
|
|
25
27
|
const { error, listConversations, createConversation: sessionCreateConversation, } = useAssistantSession({
|
|
26
28
|
client,
|
|
27
29
|
podId,
|
|
@@ -44,6 +46,8 @@ export function useConversations({ client, podId, agentName, assistantName, assi
|
|
|
44
46
|
const response = await listConversations({
|
|
45
47
|
limit: overrides.limit ?? limit,
|
|
46
48
|
pageToken: overrides.pageToken ?? pageToken,
|
|
49
|
+
status: overrides.status ?? status,
|
|
50
|
+
type: overrides.type ?? type,
|
|
47
51
|
});
|
|
48
52
|
const nextConversations = sortConversationsByUpdatedAt(response.items ?? []);
|
|
49
53
|
setConversations(nextConversations);
|
|
@@ -63,7 +67,7 @@ export function useConversations({ client, podId, agentName, assistantName, assi
|
|
|
63
67
|
finally {
|
|
64
68
|
setIsLoading(false);
|
|
65
69
|
}
|
|
66
|
-
}, [autoSelectFirst, enabled, initialConversationId, limit, listConversations, pageToken]);
|
|
70
|
+
}, [autoSelectFirst, enabled, initialConversationId, limit, listConversations, pageToken, status, type]);
|
|
67
71
|
const loadMore = useCallback(async (overrides = {}) => {
|
|
68
72
|
if (!enabled || !nextPageToken || isLoading || isLoadingMore) {
|
|
69
73
|
return [];
|
|
@@ -73,6 +77,8 @@ export function useConversations({ client, podId, agentName, assistantName, assi
|
|
|
73
77
|
const response = await listConversations({
|
|
74
78
|
limit: overrides.limit ?? limit,
|
|
75
79
|
pageToken: nextPageToken,
|
|
80
|
+
status,
|
|
81
|
+
type,
|
|
76
82
|
});
|
|
77
83
|
const moreConversations = sortConversationsByUpdatedAt(response.items ?? []);
|
|
78
84
|
setConversations((previous) => [...previous, ...moreConversations]);
|
|
@@ -87,7 +93,7 @@ export function useConversations({ client, podId, agentName, assistantName, assi
|
|
|
87
93
|
finally {
|
|
88
94
|
setIsLoadingMore(false);
|
|
89
95
|
}
|
|
90
|
-
}, [conversations.length, enabled, isLoading, isLoadingMore, limit, listConversations, nextPageToken]);
|
|
96
|
+
}, [conversations.length, enabled, isLoading, isLoadingMore, limit, listConversations, nextPageToken, status, type]);
|
|
91
97
|
const createConversation = useCallback(async (input = {}) => {
|
|
92
98
|
const createdConversation = await sessionCreateConversation({
|
|
93
99
|
...input,
|