@elevasis/ui 2.72.0 → 2.74.0
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/dist/api/index.js +3 -3
- package/dist/app/index.d.ts +172 -20
- package/dist/app/index.js +9 -10
- package/dist/auth/index.js +5 -6
- package/dist/charts/index.js +5 -6
- package/dist/chunk-2GIJBHZT.js +60 -0
- package/dist/{chunk-2454MK7P.js → chunk-2MRRDF32.js} +115 -8
- package/dist/chunk-3LOKYZJC.js +231 -0
- package/dist/chunk-3QHX4ZKV.js +224 -0
- package/dist/chunk-43LC6XAX.js +69 -0
- package/dist/chunk-4M2BSHVT.js +116 -0
- package/dist/{chunk-SV4M2BUI.js → chunk-4MXNHJTA.js} +111 -46
- package/dist/{chunk-LEQGGX2U.js → chunk-5A6KCFS5.js} +36 -43
- package/dist/{chunk-KIDZXZM5.js → chunk-6JN2TLV2.js} +1480 -4200
- package/dist/{chunk-UZ5JO5TK.js → chunk-7ARBBELS.js} +1 -1
- package/dist/{chunk-DJWIIPKW.js → chunk-7RJ7P6S6.js} +6 -3
- package/dist/chunk-ARAFQBNI.js +515 -0
- package/dist/{chunk-DKVGO6RJ.js → chunk-BA3AZJUR.js} +1 -1
- package/dist/chunk-BRTGCFBH.js +305 -0
- package/dist/{chunk-7ESZKTQG.js → chunk-CQPULKKL.js} +5 -3
- package/dist/chunk-CRA7WQZH.js +49 -0
- package/dist/{chunk-XZIOCB5D.js → chunk-DCQKTDIG.js} +2 -52
- package/dist/{chunk-A3JHFZDP.js → chunk-E6YGA5WH.js} +1 -1
- package/dist/chunk-FA7LMNQO.js +439 -0
- package/dist/chunk-FZSG6M6W.js +45 -0
- package/dist/chunk-GDOR57D7.js +165 -0
- package/dist/{chunk-RRS2QR3W.js → chunk-GO4XJ5D4.js} +1 -1
- package/dist/chunk-GPQQGQGT.js +645 -0
- package/dist/chunk-HYQOGRWG.js +54 -0
- package/dist/{chunk-LCHL5SM2.js → chunk-LN4UW6S4.js} +1 -1
- package/dist/chunk-N6K2Q5BM.js +393 -0
- package/dist/{chunk-Z2W5VNN3.js → chunk-O32UQ26A.js} +3 -2
- package/dist/{chunk-M7WWRZ5Z.js → chunk-QFGNRKIE.js} +1 -78
- package/dist/{chunk-Q3O3WY7Q.js → chunk-R5UGIFYU.js} +74 -18
- package/dist/{chunk-753MKWFV.js → chunk-RFNJ2PTO.js} +1 -1
- package/dist/chunk-VM2OWOXL.js +24 -0
- package/dist/{chunk-ZBXCEWKF.js → chunk-W2QRBQQA.js} +5 -3
- package/dist/chunk-WDBNW44Z.js +49 -0
- package/dist/{chunk-IXBRUIYI.js → chunk-WZU3MCKI.js} +1 -1
- package/dist/chunk-YQQ5GRUR.js +21 -0
- package/dist/{chunk-IMZTRDY2.js → chunk-ZFA56VSR.js} +2 -2
- package/dist/{chunk-AFBFSXP3.js → chunk-ZWI62BQ6.js} +7 -4
- package/dist/chunk-ZYNVCWDZ.js +286 -0
- package/dist/components/index.d.ts +490 -22
- package/dist/components/index.js +335 -35
- package/dist/components/navigation/index.js +6 -7
- package/dist/features/auth/index.d.ts +154 -2
- package/dist/features/auth/index.js +18 -9
- package/dist/features/clients/index.js +7 -7
- package/dist/features/content/index.d.ts +718 -34
- package/dist/features/content/index.js +1345 -51
- package/dist/features/crm/index.d.ts +172 -20
- package/dist/features/crm/index.js +10 -8
- package/dist/features/dashboard/index.d.ts +19 -10
- package/dist/features/dashboard/index.js +9 -8
- package/dist/features/delivery/index.d.ts +134 -0
- package/dist/features/delivery/index.js +23 -7
- package/dist/features/knowledge/index.js +5 -6
- package/dist/features/lead-gen/index.d.ts +47 -35
- package/dist/features/lead-gen/index.js +12 -8
- package/dist/features/monitoring/index.js +11 -9
- package/dist/features/monitoring/requests/index.js +8 -7
- package/dist/features/operations/index.d.ts +38 -20
- package/dist/features/operations/index.js +15 -11
- package/dist/features/public-agent-chat/index.js +3 -1
- package/dist/features/settings/index.d.ts +134 -0
- package/dist/features/settings/index.js +9 -8
- package/dist/hooks/access/index.js +5 -6
- package/dist/hooks/delivery/index.d.ts +134 -0
- package/dist/hooks/delivery/index.js +3 -2
- package/dist/hooks/operations/command-view/utils/transformCommandViewData.d.ts +20 -11
- package/dist/hooks/published.d.ts +1421 -29
- package/dist/hooks/published.js +22 -6
- package/dist/initialization/index.d.ts +134 -0
- package/dist/knowledge/index.d.ts +38 -20
- package/dist/knowledge/index.js +167 -11
- package/dist/{knowledge-search-index-RZLIVWPJ.js → knowledge-search-index-6GQK55IQ.js} +1 -1
- package/dist/layout/index.js +8 -9
- package/dist/profile/index.d.ts +134 -0
- package/dist/provider/index.d.ts +191 -21
- package/dist/provider/index.js +5 -6
- package/dist/provider/published.d.ts +219 -21
- package/dist/provider/published.js +5 -6
- package/dist/test-utils/index.d.ts +16 -5
- package/dist/test-utils/index.js +17 -18
- package/dist/types/index.d.ts +184 -14
- package/dist/utils/index.d.ts +102 -13
- package/dist/utils/index.js +1 -1
- package/package.json +7 -6
- package/dist/chunk-6M6OLGQY.js +0 -36
- package/dist/chunk-MKH2KOAO.js +0 -39
- package/dist/hooks/index.css +0 -659
- package/dist/hooks/index.d.ts +0 -12853
- package/dist/hooks/index.js +0 -27
- package/dist/supabase/index.d.ts +0 -6969
- package/dist/supabase/index.js +0 -3
- package/dist/typeform/index.d.ts +0 -462
- package/dist/typeform/index.js +0 -2051
- package/dist/typeform/schemas.d.ts +0 -67
- package/dist/typeform/schemas.js +0 -2
|
@@ -0,0 +1,439 @@
|
|
|
1
|
+
import { createLiveTempMessageIdentity } from './chunk-QFGNRKIE.js';
|
|
2
|
+
import { sessionsKeys } from './chunk-6JN2TLV2.js';
|
|
3
|
+
import { SessionIdParamSchema, WebSocketSessionTurnSchema, ExecutionIdParamsSchema } from './chunk-2GIJBHZT.js';
|
|
4
|
+
import { useOrganization } from './chunk-DD3CCMCZ.js';
|
|
5
|
+
import { STALE_TIME_MONITORING, STALE_TIME_DEFAULT } from './chunk-R5UGIFYU.js';
|
|
6
|
+
import { WS_MAX_RETRIES_BEFORE_ERROR, WS_RECONNECT_BASE_DELAY, WS_RECONNECT_MAX_DELAY, REFETCH_INTERVAL_RUNNING } from './chunk-Y6I3IC45.js';
|
|
7
|
+
import { useElevasisServices } from './chunk-BI5VDO2K.js';
|
|
8
|
+
import { useAuthContext } from './chunk-BRJ3QZ4E.js';
|
|
9
|
+
import { useQuery, useQueryClient } from '@tanstack/react-query';
|
|
10
|
+
import { create } from 'zustand';
|
|
11
|
+
import { persist } from 'zustand/middleware';
|
|
12
|
+
import { useState, useRef, useCallback, useEffect } from 'react';
|
|
13
|
+
|
|
14
|
+
function useCommandViewStats(timeRange = "30d", options) {
|
|
15
|
+
const { apiRequest, workOSOrganizationId, isReady } = useElevasisServices();
|
|
16
|
+
return useQuery({
|
|
17
|
+
queryKey: ["command-view-stats", workOSOrganizationId, timeRange],
|
|
18
|
+
queryFn: async () => {
|
|
19
|
+
return apiRequest(`/command-view/stats?timeRange=${timeRange}`);
|
|
20
|
+
},
|
|
21
|
+
enabled: isReady && (options?.enabled ?? true),
|
|
22
|
+
staleTime: STALE_TIME_MONITORING
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
function useCheckpointTasks({ checkpointId, enabled = true }) {
|
|
26
|
+
const { apiRequest, workOSOrganizationId, isReady } = useElevasisServices();
|
|
27
|
+
return useQuery({
|
|
28
|
+
queryKey: ["checkpoint-tasks", workOSOrganizationId, checkpointId],
|
|
29
|
+
queryFn: async () => {
|
|
30
|
+
return apiRequest(
|
|
31
|
+
`/command-queue?humanCheckpoint=${checkpointId}&status=pending&limit=10`
|
|
32
|
+
);
|
|
33
|
+
},
|
|
34
|
+
// Only fetch when: org ready, checkpoint selected, and enabled
|
|
35
|
+
enabled: isReady && !!checkpointId && enabled,
|
|
36
|
+
staleTime: STALE_TIME_MONITORING
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
function useResourceExecutions({
|
|
40
|
+
resourceId,
|
|
41
|
+
timeRange,
|
|
42
|
+
page = 1,
|
|
43
|
+
limit = 10,
|
|
44
|
+
enabled = true
|
|
45
|
+
}) {
|
|
46
|
+
const { apiRequest, workOSOrganizationId, isReady } = useElevasisServices();
|
|
47
|
+
return useQuery({
|
|
48
|
+
queryKey: ["resource-executions", workOSOrganizationId, resourceId, timeRange, page, limit],
|
|
49
|
+
queryFn: async () => {
|
|
50
|
+
return apiRequest(
|
|
51
|
+
`/command-view/resource-executions?resourceId=${resourceId}&timeRange=${timeRange}&page=${page}&limit=${limit}`
|
|
52
|
+
);
|
|
53
|
+
},
|
|
54
|
+
// Only fetch when: org ready, resource selected, and enabled
|
|
55
|
+
enabled: isReady && !!resourceId && enabled,
|
|
56
|
+
staleTime: STALE_TIME_MONITORING
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
var NEW_SESSION_VISUALIZATION_MODE = "explore";
|
|
60
|
+
var LEGACY_VISUALIZATION_MODES = /* @__PURE__ */ new Set(["overview", "cluster", "swimlane", "focus", "network", "force"]);
|
|
61
|
+
function normalizePersistedVisualizationMode(value) {
|
|
62
|
+
if (value === "explore") return "explore";
|
|
63
|
+
if (LEGACY_VISUALIZATION_MODES.has(String(value))) return NEW_SESSION_VISUALIZATION_MODE;
|
|
64
|
+
return NEW_SESSION_VISUALIZATION_MODE;
|
|
65
|
+
}
|
|
66
|
+
var DEFAULT_DIAGNOSTIC_CATEGORIES = ["diagnostic", "testing"];
|
|
67
|
+
var useCommandViewStore = create()(
|
|
68
|
+
persist(
|
|
69
|
+
(set) => ({
|
|
70
|
+
statusFilter: "all",
|
|
71
|
+
setStatusFilter: (statusFilter) => set({ statusFilter }),
|
|
72
|
+
showIntegrations: true,
|
|
73
|
+
setShowIntegrations: (showIntegrations) => set({ showIntegrations }),
|
|
74
|
+
fitViewOnFilter: true,
|
|
75
|
+
setFitViewOnFilter: (fitViewOnFilter) => set({ fitViewOnFilter }),
|
|
76
|
+
// New sessions default to 'explore'; returning sessions get their stored mode via persist.
|
|
77
|
+
visualizationMode: NEW_SESSION_VISUALIZATION_MODE,
|
|
78
|
+
setVisualizationMode: (visualizationMode) => set({ visualizationMode, lastUsedVisualizationMode: visualizationMode }),
|
|
79
|
+
lastUsedVisualizationMode: null,
|
|
80
|
+
lastOpenBottomTab: null,
|
|
81
|
+
setLastOpenBottomTab: (lastOpenBottomTab) => set({ lastOpenBottomTab }),
|
|
82
|
+
selectedNodeId: null,
|
|
83
|
+
setSelectedNodeId: (selectedNodeId) => set({ selectedNodeId }),
|
|
84
|
+
resourcesHidden: true,
|
|
85
|
+
setResourcesHidden: (resourcesHidden) => set({ resourcesHidden, hasVisibilityInteraction: true }),
|
|
86
|
+
diagnosticsHidden: true,
|
|
87
|
+
setDiagnosticsHidden: (diagnosticsHidden) => set({ diagnosticsHidden, hasVisibilityInteraction: true }),
|
|
88
|
+
diagnosticCategories: DEFAULT_DIAGNOSTIC_CATEGORIES,
|
|
89
|
+
revealedIds: /* @__PURE__ */ new Set(),
|
|
90
|
+
setRevealedIds: (ids) => set({ revealedIds: new Set(ids) }),
|
|
91
|
+
clearRevealedIds: () => set({ revealedIds: /* @__PURE__ */ new Set() }),
|
|
92
|
+
hasVisibilityInteraction: false,
|
|
93
|
+
markVisibilityInteraction: () => set({ hasVisibilityInteraction: true }),
|
|
94
|
+
resetVisibilityInteraction: () => set({ hasVisibilityInteraction: false }),
|
|
95
|
+
expandedClusterDomains: [],
|
|
96
|
+
toggleClusterDomain: (domain) => set((s) => ({
|
|
97
|
+
expandedClusterDomains: s.expandedClusterDomains.includes(domain) ? s.expandedClusterDomains.filter((d) => d !== domain) : [...s.expandedClusterDomains, domain]
|
|
98
|
+
})),
|
|
99
|
+
setExpandedClusterDomains: (expandedClusterDomains) => set({ expandedClusterDomains }),
|
|
100
|
+
expandedNodeIdsArray: [],
|
|
101
|
+
expandedNodeIds: /* @__PURE__ */ new Set(),
|
|
102
|
+
toggleNodeExpansion: (nodeId) => set((s) => {
|
|
103
|
+
const currentSet = s.expandedNodeIds;
|
|
104
|
+
const isCurrentlyExpanded = currentSet.has(nodeId);
|
|
105
|
+
if (isCurrentlyExpanded) {
|
|
106
|
+
const next2 = new Set(currentSet);
|
|
107
|
+
next2.delete(nodeId);
|
|
108
|
+
const nextArray2 = [...next2];
|
|
109
|
+
return { expandedNodeIdsArray: nextArray2, expandedNodeIds: next2 };
|
|
110
|
+
}
|
|
111
|
+
const next = new Set(currentSet);
|
|
112
|
+
next.add(nodeId);
|
|
113
|
+
const nextArray = [...next];
|
|
114
|
+
return { expandedNodeIdsArray: nextArray, expandedNodeIds: next };
|
|
115
|
+
}),
|
|
116
|
+
clearExpandedNodes: () => set({ expandedNodeIdsArray: [], expandedNodeIds: /* @__PURE__ */ new Set() })
|
|
117
|
+
}),
|
|
118
|
+
{
|
|
119
|
+
name: "command-view-store",
|
|
120
|
+
partialize: (s) => ({
|
|
121
|
+
showIntegrations: s.showIntegrations,
|
|
122
|
+
fitViewOnFilter: s.fitViewOnFilter,
|
|
123
|
+
visualizationMode: s.visualizationMode,
|
|
124
|
+
lastUsedVisualizationMode: s.lastUsedVisualizationMode,
|
|
125
|
+
resourcesHidden: s.resourcesHidden,
|
|
126
|
+
diagnosticsHidden: s.diagnosticsHidden,
|
|
127
|
+
lastOpenBottomTab: s.lastOpenBottomTab,
|
|
128
|
+
expandedClusterDomains: s.expandedClusterDomains
|
|
129
|
+
}),
|
|
130
|
+
// Guard against stale localStorage with an invalid mode name (e.g. old 'overview' → 'explore' rename).
|
|
131
|
+
merge: (persisted, current) => {
|
|
132
|
+
const stored = persisted;
|
|
133
|
+
const storedMode = stored.visualizationMode;
|
|
134
|
+
const storedLastUsed = stored.lastUsedVisualizationMode;
|
|
135
|
+
const { expandedZonesArray: _dropped, ...restStored } = stored;
|
|
136
|
+
return {
|
|
137
|
+
...current,
|
|
138
|
+
...restStored,
|
|
139
|
+
visualizationMode: normalizePersistedVisualizationMode(storedMode),
|
|
140
|
+
lastUsedVisualizationMode: storedLastUsed === null || storedLastUsed === void 0 ? current.lastUsedVisualizationMode : normalizePersistedVisualizationMode(storedLastUsed)
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
)
|
|
145
|
+
);
|
|
146
|
+
function useSessionMessages(sessionId) {
|
|
147
|
+
const { apiRequest, isReady } = useElevasisServices();
|
|
148
|
+
const { currentSupabaseOrganizationId } = useOrganization();
|
|
149
|
+
return useQuery({
|
|
150
|
+
queryKey: sessionsKeys.messages(currentSupabaseOrganizationId, sessionId),
|
|
151
|
+
queryFn: async () => {
|
|
152
|
+
SessionIdParamSchema.parse({ sessionId });
|
|
153
|
+
const response = await apiRequest(`/sessions/${sessionId}/messages`, {
|
|
154
|
+
method: "GET"
|
|
155
|
+
});
|
|
156
|
+
const messages = response.messages.map((msg) => ({
|
|
157
|
+
...msg,
|
|
158
|
+
createdAt: new Date(msg.createdAt)
|
|
159
|
+
}));
|
|
160
|
+
return messages;
|
|
161
|
+
},
|
|
162
|
+
enabled: isReady && !!sessionId,
|
|
163
|
+
staleTime: 0
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
function formatMessageEvent(event) {
|
|
167
|
+
switch (event.type) {
|
|
168
|
+
case "user_message":
|
|
169
|
+
return event.text;
|
|
170
|
+
case "assistant_message":
|
|
171
|
+
return event.text;
|
|
172
|
+
case "agent:started":
|
|
173
|
+
return "\u{1F916} Agent started reasoning";
|
|
174
|
+
case "agent:reasoning":
|
|
175
|
+
return `\u{1F4AD} Reasoning (Iteration ${event.iteration})`;
|
|
176
|
+
case "agent:tool_call":
|
|
177
|
+
return `\u{1F527} Tool: ${event.toolName}`;
|
|
178
|
+
case "agent:tool_result":
|
|
179
|
+
return event.success ? "\u2705 Tool Result" : "\u26A0\uFE0F Tool Result (Failed)";
|
|
180
|
+
case "agent:completed":
|
|
181
|
+
return "\u2705 Agent completed";
|
|
182
|
+
case "agent:error":
|
|
183
|
+
return `\u274C Agent error: ${event.error}`;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
function getWsUrl(apiUrl) {
|
|
187
|
+
const url = new URL(apiUrl);
|
|
188
|
+
const protocol = url.protocol === "https:" ? "wss:" : "ws:";
|
|
189
|
+
return `${protocol}//${url.host}`;
|
|
190
|
+
}
|
|
191
|
+
function useSessionWebSocket(sessionId, apiUrl) {
|
|
192
|
+
const [messages, setMessages] = useState([]);
|
|
193
|
+
const [state, setState] = useState({
|
|
194
|
+
isConnected: false,
|
|
195
|
+
isProcessing: false,
|
|
196
|
+
error: null
|
|
197
|
+
});
|
|
198
|
+
const [lastTokenUsage, setLastTokenUsage] = useState(null);
|
|
199
|
+
const wsRef = useRef(null);
|
|
200
|
+
const retryCountRef = useRef(0);
|
|
201
|
+
const reconnectTimeoutRef = useRef(null);
|
|
202
|
+
const connectionEpochRef = useRef(0);
|
|
203
|
+
const { getAccessToken } = useAuthContext();
|
|
204
|
+
const { currentWorkOSOrganizationId, currentSupabaseOrganizationId } = useOrganization();
|
|
205
|
+
const queryClient = useQueryClient();
|
|
206
|
+
const getAccessTokenRef = useRef(getAccessToken);
|
|
207
|
+
getAccessTokenRef.current = getAccessToken;
|
|
208
|
+
const currentWorkOSOrgIdRef = useRef(currentWorkOSOrganizationId);
|
|
209
|
+
currentWorkOSOrgIdRef.current = currentWorkOSOrganizationId;
|
|
210
|
+
const queryClientRef = useRef(queryClient);
|
|
211
|
+
queryClientRef.current = queryClient;
|
|
212
|
+
const currentSupabaseOrgIdRef = useRef(currentSupabaseOrganizationId);
|
|
213
|
+
currentSupabaseOrgIdRef.current = currentSupabaseOrganizationId;
|
|
214
|
+
const connect = useCallback(async () => {
|
|
215
|
+
if (!sessionId) {
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
if (!currentWorkOSOrgIdRef.current) {
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
if (wsRef.current?.readyState === WebSocket.OPEN || wsRef.current?.readyState === WebSocket.CONNECTING) {
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
const epoch = connectionEpochRef.current;
|
|
225
|
+
const token = await getAccessTokenRef.current();
|
|
226
|
+
if (!token) {
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
if (epoch !== connectionEpochRef.current) {
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
const orgId = currentWorkOSOrgIdRef.current;
|
|
233
|
+
const wsUrl = `${getWsUrl(apiUrl)}/ws/sessions/${sessionId}?token=${token}&orgId=${orgId}`;
|
|
234
|
+
const ws = new WebSocket(wsUrl);
|
|
235
|
+
ws.onopen = () => {
|
|
236
|
+
setState((prev) => ({ ...prev, isConnected: true, error: null }));
|
|
237
|
+
retryCountRef.current = 0;
|
|
238
|
+
const supabaseOrgId = currentSupabaseOrgIdRef.current;
|
|
239
|
+
if (supabaseOrgId) {
|
|
240
|
+
queryClientRef.current.invalidateQueries({
|
|
241
|
+
queryKey: sessionsKeys.messages(supabaseOrgId, sessionId)
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
ws.onmessage = (event) => {
|
|
246
|
+
try {
|
|
247
|
+
const data = JSON.parse(event.data);
|
|
248
|
+
if (data.type && data.type !== "turn:complete" && data.type !== "error") {
|
|
249
|
+
const liveIdentity = createLiveTempMessageIdentity();
|
|
250
|
+
const tempMessage = {
|
|
251
|
+
id: liveIdentity.id,
|
|
252
|
+
role: data.type === "user_message" ? "user" : "assistant",
|
|
253
|
+
messageType: data.type,
|
|
254
|
+
text: formatMessageEvent(data),
|
|
255
|
+
// Format based on type
|
|
256
|
+
metadata: data.type.startsWith("agent:") ? data : void 0,
|
|
257
|
+
turnNumber: 999999,
|
|
258
|
+
// High placeholder so temp messages sort to bottom
|
|
259
|
+
messageIndex: liveIdentity.messageIndex,
|
|
260
|
+
createdAt: liveIdentity.createdAt
|
|
261
|
+
};
|
|
262
|
+
setMessages((prev) => [...prev, tempMessage]);
|
|
263
|
+
} else if (data.type === "turn:complete") {
|
|
264
|
+
if (data.tokenUsage) {
|
|
265
|
+
setLastTokenUsage(data.tokenUsage);
|
|
266
|
+
}
|
|
267
|
+
setState((prev) => ({ ...prev, isProcessing: false }));
|
|
268
|
+
const supabaseOrgId = currentSupabaseOrgIdRef.current;
|
|
269
|
+
if (supabaseOrgId) {
|
|
270
|
+
queryClientRef.current.invalidateQueries({
|
|
271
|
+
queryKey: sessionsKeys.messages(supabaseOrgId, sessionId)
|
|
272
|
+
});
|
|
273
|
+
queryClientRef.current.invalidateQueries({
|
|
274
|
+
queryKey: sessionsKeys.executions(supabaseOrgId, sessionId)
|
|
275
|
+
});
|
|
276
|
+
queryClientRef.current.invalidateQueries({
|
|
277
|
+
queryKey: sessionsKeys.session(supabaseOrgId, sessionId)
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
} else if (data.type === "error") {
|
|
281
|
+
setState((prev) => ({
|
|
282
|
+
...prev,
|
|
283
|
+
error: data.error,
|
|
284
|
+
isProcessing: false
|
|
285
|
+
}));
|
|
286
|
+
}
|
|
287
|
+
} catch (error) {
|
|
288
|
+
console.error("Failed to parse WebSocket message:", error);
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
ws.onerror = () => {
|
|
292
|
+
};
|
|
293
|
+
ws.onclose = (event) => {
|
|
294
|
+
setState((prev) => ({ ...prev, isConnected: false }));
|
|
295
|
+
if (!event.wasClean && retryCountRef.current >= WS_MAX_RETRIES_BEFORE_ERROR) {
|
|
296
|
+
setState((prev) => ({
|
|
297
|
+
...prev,
|
|
298
|
+
error: "Unable to connect to session. Retrying..."
|
|
299
|
+
}));
|
|
300
|
+
}
|
|
301
|
+
const terminalCodes = [1003, 1008];
|
|
302
|
+
if (terminalCodes.includes(event.code) || event.code >= 4e3) {
|
|
303
|
+
setState((prev) => ({
|
|
304
|
+
...prev,
|
|
305
|
+
error: `Connection rejected (code ${event.code})`
|
|
306
|
+
}));
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
const delay = Math.min(WS_RECONNECT_BASE_DELAY * Math.pow(2, retryCountRef.current), WS_RECONNECT_MAX_DELAY);
|
|
310
|
+
retryCountRef.current += 1;
|
|
311
|
+
reconnectTimeoutRef.current = setTimeout(() => {
|
|
312
|
+
connect();
|
|
313
|
+
}, delay);
|
|
314
|
+
};
|
|
315
|
+
wsRef.current = ws;
|
|
316
|
+
}, [sessionId, apiUrl]);
|
|
317
|
+
useEffect(() => {
|
|
318
|
+
retryCountRef.current = 0;
|
|
319
|
+
if (currentWorkOSOrgIdRef.current) {
|
|
320
|
+
connect();
|
|
321
|
+
}
|
|
322
|
+
return () => {
|
|
323
|
+
connectionEpochRef.current += 1;
|
|
324
|
+
if (reconnectTimeoutRef.current) {
|
|
325
|
+
clearTimeout(reconnectTimeoutRef.current);
|
|
326
|
+
reconnectTimeoutRef.current = null;
|
|
327
|
+
}
|
|
328
|
+
const ws = wsRef.current;
|
|
329
|
+
if (ws) {
|
|
330
|
+
ws.onopen = null;
|
|
331
|
+
ws.onmessage = null;
|
|
332
|
+
ws.onerror = null;
|
|
333
|
+
ws.onclose = null;
|
|
334
|
+
ws.close();
|
|
335
|
+
wsRef.current = null;
|
|
336
|
+
}
|
|
337
|
+
};
|
|
338
|
+
}, [sessionId, currentWorkOSOrganizationId, connect]);
|
|
339
|
+
const sendMessage = useCallback(
|
|
340
|
+
(text, pageContext) => {
|
|
341
|
+
const trimmed = text.trim();
|
|
342
|
+
if (!trimmed) {
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
if (!wsRef.current || state.isProcessing) {
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
if (wsRef.current.readyState !== WebSocket.OPEN) {
|
|
349
|
+
setState((prev) => ({
|
|
350
|
+
...prev,
|
|
351
|
+
error: "WebSocket not connected"
|
|
352
|
+
}));
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
const liveIdentity = createLiveTempMessageIdentity();
|
|
356
|
+
const userMessage = {
|
|
357
|
+
id: liveIdentity.id,
|
|
358
|
+
role: "user",
|
|
359
|
+
messageType: "user_message",
|
|
360
|
+
text: trimmed,
|
|
361
|
+
turnNumber: 999999,
|
|
362
|
+
// High placeholder so temp messages sort to bottom
|
|
363
|
+
messageIndex: liveIdentity.messageIndex,
|
|
364
|
+
createdAt: liveIdentity.createdAt
|
|
365
|
+
};
|
|
366
|
+
setMessages((prev) => [...prev, userMessage]);
|
|
367
|
+
const input = { message: trimmed };
|
|
368
|
+
if (pageContext) {
|
|
369
|
+
input.pageContext = pageContext;
|
|
370
|
+
}
|
|
371
|
+
const message = WebSocketSessionTurnSchema.parse({
|
|
372
|
+
type: "session:turn",
|
|
373
|
+
input
|
|
374
|
+
});
|
|
375
|
+
wsRef.current.send(JSON.stringify(message));
|
|
376
|
+
setState((prev) => ({ ...prev, isProcessing: true, error: null }));
|
|
377
|
+
},
|
|
378
|
+
[state.isProcessing, sessionId]
|
|
379
|
+
);
|
|
380
|
+
const clearError = useCallback(() => {
|
|
381
|
+
setState((prev) => ({ ...prev, error: null }));
|
|
382
|
+
}, []);
|
|
383
|
+
return {
|
|
384
|
+
messages,
|
|
385
|
+
state,
|
|
386
|
+
sendMessage,
|
|
387
|
+
clearError,
|
|
388
|
+
lastTokenUsage
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
function useSessionExecutions(sessionId) {
|
|
392
|
+
const { apiRequest, isReady } = useElevasisServices();
|
|
393
|
+
const { currentSupabaseOrganizationId } = useOrganization();
|
|
394
|
+
return useQuery({
|
|
395
|
+
queryKey: sessionsKeys.executions(currentSupabaseOrganizationId, sessionId),
|
|
396
|
+
queryFn: async () => {
|
|
397
|
+
SessionIdParamSchema.parse({ sessionId });
|
|
398
|
+
return apiRequest(`/sessions/${sessionId}/executions`, {
|
|
399
|
+
method: "GET"
|
|
400
|
+
});
|
|
401
|
+
},
|
|
402
|
+
enabled: isReady && !!sessionId,
|
|
403
|
+
staleTime: 0
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
function useSessionExecution(sessionId, executionId) {
|
|
407
|
+
const { apiRequest, isReady } = useElevasisServices();
|
|
408
|
+
const { currentSupabaseOrganizationId } = useOrganization();
|
|
409
|
+
return useQuery({
|
|
410
|
+
queryKey: sessionsKeys.execution(currentSupabaseOrganizationId, sessionId, executionId),
|
|
411
|
+
queryFn: async () => {
|
|
412
|
+
ExecutionIdParamsSchema.parse({ sessionId, executionId });
|
|
413
|
+
return apiRequest(`/sessions/${sessionId}/executions/${executionId}`, {
|
|
414
|
+
method: "GET"
|
|
415
|
+
});
|
|
416
|
+
},
|
|
417
|
+
enabled: isReady && !!sessionId && !!executionId,
|
|
418
|
+
refetchInterval: (query) => {
|
|
419
|
+
const data = query.state.data;
|
|
420
|
+
const shouldRefetch = data?.status === "running";
|
|
421
|
+
return shouldRefetch ? REFETCH_INTERVAL_RUNNING : false;
|
|
422
|
+
}
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
// src/hooks/operations/command-view/useCommandViewData.ts
|
|
427
|
+
function useCommandViewData() {
|
|
428
|
+
const { apiRequest, workOSOrganizationId, isReady } = useElevasisServices();
|
|
429
|
+
return useQuery({
|
|
430
|
+
queryKey: ["command-view", workOSOrganizationId],
|
|
431
|
+
queryFn: async () => {
|
|
432
|
+
return apiRequest("/command-view");
|
|
433
|
+
},
|
|
434
|
+
enabled: isReady,
|
|
435
|
+
staleTime: STALE_TIME_DEFAULT
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
export { useCheckpointTasks, useCommandViewData, useCommandViewStats, useCommandViewStore, useResourceExecutions, useSessionExecution, useSessionExecutions, useSessionMessages, useSessionWebSocket };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { dealKeys } from './chunk-6JN2TLV2.js';
|
|
2
|
+
import { showApiErrorNotification } from './chunk-HYQOGRWG.js';
|
|
3
|
+
import { APIClientError } from './chunk-R5UGIFYU.js';
|
|
4
|
+
import { useElevasisServices } from './chunk-BI5VDO2K.js';
|
|
5
|
+
import { useQuery, useQueryClient, useMutation } from '@tanstack/react-query';
|
|
6
|
+
|
|
7
|
+
function useDealDetail(acqDealId) {
|
|
8
|
+
const { apiRequest, isReady, workOSOrganizationId } = useElevasisServices();
|
|
9
|
+
return useQuery({
|
|
10
|
+
queryKey: ["deal-detail", workOSOrganizationId, acqDealId],
|
|
11
|
+
queryFn: async () => {
|
|
12
|
+
if (!acqDealId) return null;
|
|
13
|
+
try {
|
|
14
|
+
return await apiRequest(`/deals/${acqDealId}`);
|
|
15
|
+
} catch (err) {
|
|
16
|
+
if (err instanceof APIClientError && err.statusCode === 404) return null;
|
|
17
|
+
throw err;
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
enabled: isReady && !!acqDealId
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
function useExecuteAction({ dealId }) {
|
|
24
|
+
const { apiRequest, workOSOrganizationId } = useElevasisServices();
|
|
25
|
+
const queryClient = useQueryClient();
|
|
26
|
+
return useMutation({
|
|
27
|
+
mutationFn: async ({ key, payload }) => {
|
|
28
|
+
await apiRequest(`/deals/${dealId}/actions/${encodeURIComponent(key)}`, {
|
|
29
|
+
method: "POST",
|
|
30
|
+
body: JSON.stringify({ payload })
|
|
31
|
+
});
|
|
32
|
+
},
|
|
33
|
+
onSuccess: () => {
|
|
34
|
+
queryClient.invalidateQueries({ queryKey: dealKeys.lists() });
|
|
35
|
+
queryClient.invalidateQueries({ queryKey: dealKeys.summaries() });
|
|
36
|
+
queryClient.invalidateQueries({ queryKey: ["deal-detail", workOSOrganizationId, dealId] });
|
|
37
|
+
},
|
|
38
|
+
onError: (error) => {
|
|
39
|
+
queryClient.invalidateQueries({ queryKey: dealKeys.all });
|
|
40
|
+
showApiErrorNotification(error);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export { useDealDetail, useExecuteAction };
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { deriveActions } from './chunk-ZYNVCWDZ.js';
|
|
2
|
+
import { acquisitionListKeys } from './chunk-6JN2TLV2.js';
|
|
3
|
+
import { showApiErrorNotification, showSuccessNotification } from './chunk-HYQOGRWG.js';
|
|
4
|
+
import { useElevasisServices } from './chunk-BI5VDO2K.js';
|
|
5
|
+
import { useQuery, useQueryClient, useMutation } from '@tanstack/react-query';
|
|
6
|
+
import { useMemo } from 'react';
|
|
7
|
+
|
|
8
|
+
var leadGenArtifactKeys = {
|
|
9
|
+
all: ["lead-gen-artifacts"],
|
|
10
|
+
// ownerId is nullable/undefined here to match CreateArtifactRequest -- an
|
|
11
|
+
// 'organization'-owned artifact has no single owning entity row. See
|
|
12
|
+
// CreateArtifactRequestSchema (business/acquisition/api-schemas.ts).
|
|
13
|
+
list: (organizationId, ownerKind, ownerId) => [...leadGenArtifactKeys.all, organizationId, ownerKind, ownerId]
|
|
14
|
+
};
|
|
15
|
+
function useArtifacts({ ownerKind, ownerId }) {
|
|
16
|
+
const { apiRequest, isReady, workOSOrganizationId } = useElevasisServices();
|
|
17
|
+
return useQuery({
|
|
18
|
+
queryKey: leadGenArtifactKeys.list(workOSOrganizationId, ownerKind, ownerId),
|
|
19
|
+
queryFn: () => apiRequest(
|
|
20
|
+
`/acquisition/artifacts?ownerKind=${encodeURIComponent(ownerKind)}&ownerId=${encodeURIComponent(ownerId)}`
|
|
21
|
+
),
|
|
22
|
+
enabled: isReady && !!ownerId
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
function useCreateArtifact() {
|
|
26
|
+
const { apiRequest, workOSOrganizationId } = useElevasisServices();
|
|
27
|
+
const queryClient = useQueryClient();
|
|
28
|
+
return useMutation({
|
|
29
|
+
mutationFn: (body) => apiRequest("/acquisition/artifacts", {
|
|
30
|
+
method: "POST",
|
|
31
|
+
body: JSON.stringify(body)
|
|
32
|
+
}),
|
|
33
|
+
onSuccess: (_, variables) => {
|
|
34
|
+
queryClient.invalidateQueries({
|
|
35
|
+
queryKey: leadGenArtifactKeys.list(workOSOrganizationId, variables.ownerKind, variables.ownerId)
|
|
36
|
+
});
|
|
37
|
+
showSuccessNotification("Artifact created");
|
|
38
|
+
},
|
|
39
|
+
onError: (error) => {
|
|
40
|
+
showApiErrorNotification(error);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
var leadGenListMemberKeys = {
|
|
45
|
+
all: ["lead-gen-list-members"],
|
|
46
|
+
list: (organizationId, listId) => [...leadGenListMemberKeys.all, organizationId, "list", listId],
|
|
47
|
+
detail: (organizationId, memberId) => [...leadGenListMemberKeys.all, organizationId, "detail", memberId]
|
|
48
|
+
};
|
|
49
|
+
function useListMembers({ listId }) {
|
|
50
|
+
const { apiRequest, isReady, workOSOrganizationId } = useElevasisServices();
|
|
51
|
+
return useQuery({
|
|
52
|
+
queryKey: leadGenListMemberKeys.list(workOSOrganizationId, listId),
|
|
53
|
+
queryFn: () => apiRequest(`/acquisition/lists/${listId}/members`),
|
|
54
|
+
enabled: isReady && !!listId
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
function useListMember(memberId) {
|
|
58
|
+
const { apiRequest, isReady, workOSOrganizationId } = useElevasisServices();
|
|
59
|
+
return useQuery({
|
|
60
|
+
queryKey: leadGenListMemberKeys.detail(workOSOrganizationId, memberId),
|
|
61
|
+
queryFn: () => apiRequest(`/acquisition/list-members/${memberId}`),
|
|
62
|
+
enabled: isReady && !!memberId
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
function useTransitionListMember() {
|
|
66
|
+
const { apiRequest, workOSOrganizationId } = useElevasisServices();
|
|
67
|
+
const queryClient = useQueryClient();
|
|
68
|
+
return useMutation({
|
|
69
|
+
mutationFn: async (input) => {
|
|
70
|
+
const { memberId, pipelineKey, stageKey, stateKey, reason, expectedUpdatedAt } = input;
|
|
71
|
+
await apiRequest(`/acquisition/list-members/${memberId}/transition`, {
|
|
72
|
+
method: "PATCH",
|
|
73
|
+
body: JSON.stringify({
|
|
74
|
+
pipelineKey,
|
|
75
|
+
stageKey,
|
|
76
|
+
...stateKey !== void 0 ? { stateKey } : {},
|
|
77
|
+
...reason !== void 0 ? { reason } : {},
|
|
78
|
+
...expectedUpdatedAt !== void 0 ? { expectedUpdatedAt } : {}
|
|
79
|
+
})
|
|
80
|
+
});
|
|
81
|
+
},
|
|
82
|
+
onSuccess: (_, variables) => {
|
|
83
|
+
queryClient.invalidateQueries({
|
|
84
|
+
queryKey: leadGenListMemberKeys.detail(workOSOrganizationId, variables.memberId)
|
|
85
|
+
});
|
|
86
|
+
if (variables.listId) {
|
|
87
|
+
queryClient.invalidateQueries({ queryKey: leadGenListMemberKeys.list(workOSOrganizationId, variables.listId) });
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
onError: (error) => {
|
|
91
|
+
queryClient.invalidateQueries({ queryKey: leadGenListMemberKeys.all });
|
|
92
|
+
showApiErrorNotification(error);
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
function useDeriveActions(item) {
|
|
97
|
+
return useMemo(() => {
|
|
98
|
+
if (!item) return [];
|
|
99
|
+
if (item.pipeline_key !== "lead-gen") {
|
|
100
|
+
return deriveActions(item);
|
|
101
|
+
}
|
|
102
|
+
return [];
|
|
103
|
+
}, [item]);
|
|
104
|
+
}
|
|
105
|
+
function useUpdateListStatus() {
|
|
106
|
+
const { apiRequest, workOSOrganizationId } = useElevasisServices();
|
|
107
|
+
const queryClient = useQueryClient();
|
|
108
|
+
return useMutation({
|
|
109
|
+
mutationFn: async (input) => {
|
|
110
|
+
await apiRequest(`/acquisition/lists/${input.listId}/status`, {
|
|
111
|
+
method: "PATCH",
|
|
112
|
+
body: JSON.stringify({ status: input.status })
|
|
113
|
+
});
|
|
114
|
+
},
|
|
115
|
+
onSuccess: (_, variables) => {
|
|
116
|
+
queryClient.invalidateQueries({ queryKey: acquisitionListKeys.list(workOSOrganizationId) });
|
|
117
|
+
queryClient.invalidateQueries({ queryKey: acquisitionListKeys.detail(workOSOrganizationId, variables.listId) });
|
|
118
|
+
queryClient.invalidateQueries({ queryKey: acquisitionListKeys.telemetry(workOSOrganizationId) });
|
|
119
|
+
},
|
|
120
|
+
onError: (error) => {
|
|
121
|
+
queryClient.invalidateQueries({ queryKey: acquisitionListKeys.all });
|
|
122
|
+
showApiErrorNotification(error);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// src/hooks/lead-gen/useTransitionListCompany.ts
|
|
128
|
+
var leadGenListCompanyKeys = {
|
|
129
|
+
all: ["lead-gen-list-companies"],
|
|
130
|
+
detail: (organizationId, listCompanyId) => [...leadGenListCompanyKeys.all, organizationId, "detail", listCompanyId]
|
|
131
|
+
};
|
|
132
|
+
function useTransitionListCompany() {
|
|
133
|
+
const { apiRequest, workOSOrganizationId } = useElevasisServices();
|
|
134
|
+
const queryClient = useQueryClient();
|
|
135
|
+
return useMutation({
|
|
136
|
+
mutationFn: async (input) => {
|
|
137
|
+
const { listCompanyId, pipelineKey, stageKey, stateKey, reason, expectedUpdatedAt } = input;
|
|
138
|
+
await apiRequest(`/acquisition/list-companies/${listCompanyId}/transition`, {
|
|
139
|
+
method: "PATCH",
|
|
140
|
+
body: JSON.stringify({
|
|
141
|
+
pipelineKey,
|
|
142
|
+
stageKey,
|
|
143
|
+
...stateKey !== void 0 ? { stateKey } : {},
|
|
144
|
+
...reason !== void 0 ? { reason } : {},
|
|
145
|
+
...expectedUpdatedAt !== void 0 ? { expectedUpdatedAt } : {}
|
|
146
|
+
})
|
|
147
|
+
});
|
|
148
|
+
},
|
|
149
|
+
onSuccess: (_, variables) => {
|
|
150
|
+
queryClient.invalidateQueries({
|
|
151
|
+
queryKey: leadGenListCompanyKeys.detail(workOSOrganizationId, variables.listCompanyId)
|
|
152
|
+
});
|
|
153
|
+
if (variables.listId) {
|
|
154
|
+
queryClient.invalidateQueries({ queryKey: acquisitionListKeys.telemetry(workOSOrganizationId) });
|
|
155
|
+
queryClient.invalidateQueries({ queryKey: acquisitionListKeys.detail(workOSOrganizationId, variables.listId) });
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
onError: (error) => {
|
|
159
|
+
queryClient.invalidateQueries({ queryKey: leadGenListCompanyKeys.all });
|
|
160
|
+
showApiErrorNotification(error);
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export { leadGenArtifactKeys, leadGenListCompanyKeys, leadGenListMemberKeys, useArtifacts, useCreateArtifact, useDeriveActions, useListMember, useListMembers, useTransitionListCompany, useTransitionListMember, useUpdateListStatus };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NavigationButton, useAppearance, useElevasisSystems } from './chunk-
|
|
1
|
+
import { NavigationButton, useAppearance, useElevasisSystems } from './chunk-6JN2TLV2.js';
|
|
2
2
|
import { sidebarItemGap, sidebarSubLinkPaddingY, sidebarSubLinkPaddingX, sidebarSubLinkIndent, sidebarHoverDelay, sidebarTransitionDuration, sidebarCollapsedWidth, sidebarWidth, topbarHeight, sidebarToggleIconSize, sidebarSectionPadding, sidebarGroupChevronSize, sidebarIconInnerSize, SubshellNavItem } from './chunk-MISHPEJX.js';
|
|
3
3
|
import { useRouterContext } from './chunk-Q7DJKLEN.js';
|
|
4
4
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|