@elevasis/ui 2.50.0 → 2.51.1

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.
Files changed (53) hide show
  1. package/dist/app/index.d.ts +82 -151
  2. package/dist/app/index.js +5 -4
  3. package/dist/auth/index.js +3 -3
  4. package/dist/charts/index.js +3 -3
  5. package/dist/{chunk-GUKY77FJ.js → chunk-E6NSKXYN.js} +12 -4
  6. package/dist/chunk-M7WWRZ5Z.js +159 -0
  7. package/dist/{chunk-SBNC3FRX.js → chunk-V3B26UZR.js} +10 -10
  8. package/dist/components/chat/index.d.ts +9 -1
  9. package/dist/components/chat/index.js +1 -1
  10. package/dist/components/index.d.ts +80 -150
  11. package/dist/components/index.js +3 -3
  12. package/dist/components/navigation/index.js +3 -3
  13. package/dist/features/auth/index.d.ts +80 -150
  14. package/dist/features/auth/index.js +4 -4
  15. package/dist/features/clients/index.js +3 -3
  16. package/dist/features/crm/index.d.ts +80 -150
  17. package/dist/features/crm/index.js +3 -3
  18. package/dist/features/dashboard/index.js +3 -3
  19. package/dist/features/delivery/index.d.ts +80 -150
  20. package/dist/features/delivery/index.js +3 -3
  21. package/dist/features/knowledge/index.js +3 -3
  22. package/dist/features/lead-gen/index.js +3 -3
  23. package/dist/features/monitoring/index.js +3 -3
  24. package/dist/features/monitoring/requests/index.js +4 -4
  25. package/dist/features/operations/index.js +3 -3
  26. package/dist/features/public-agent-chat/index.d.ts +17 -3
  27. package/dist/features/public-agent-chat/index.js +313 -113
  28. package/dist/features/settings/index.d.ts +80 -150
  29. package/dist/features/settings/index.js +3 -3
  30. package/dist/hooks/access/index.js +3 -3
  31. package/dist/hooks/delivery/index.d.ts +80 -150
  32. package/dist/hooks/delivery/index.js +3 -3
  33. package/dist/hooks/index.d.ts +97 -151
  34. package/dist/hooks/index.js +3 -3
  35. package/dist/hooks/published.d.ts +97 -151
  36. package/dist/hooks/published.js +3 -3
  37. package/dist/index.d.ts +97 -151
  38. package/dist/index.js +3 -3
  39. package/dist/initialization/index.d.ts +80 -150
  40. package/dist/knowledge/index.d.ts +48 -2
  41. package/dist/knowledge/index.js +324 -83
  42. package/dist/layout/index.js +3 -3
  43. package/dist/organization/index.js +3 -3
  44. package/dist/profile/index.d.ts +80 -150
  45. package/dist/provider/index.d.ts +80 -150
  46. package/dist/provider/index.js +3 -3
  47. package/dist/provider/published.d.ts +80 -150
  48. package/dist/provider/published.js +3 -3
  49. package/dist/supabase/index.d.ts +159 -292
  50. package/dist/types/index.d.ts +80 -150
  51. package/package.json +3 -3
  52. package/src/knowledge/README.md +4 -2
  53. package/dist/chunk-EJL4U7OZ.js +0 -79
@@ -13,9 +13,6 @@ type Json = string | number | boolean | null | {
13
13
  [key: string]: Json | undefined;
14
14
  } | Json[];
15
15
  type Database = {
16
- __InternalSupabase: {
17
- PostgrestVersion: "12.2.3 (519615d)";
18
- };
19
16
  public: {
20
17
  Tables: {
21
18
  acq_artifacts: {
@@ -1215,6 +1212,74 @@ type Database = {
1215
1212
  }
1216
1213
  ];
1217
1214
  };
1215
+ agent_access_grants: {
1216
+ Row: {
1217
+ allowed_origins: string[];
1218
+ branding: Json;
1219
+ capture_fields: Json;
1220
+ code_hash: string | null;
1221
+ code_salt: string | null;
1222
+ created_at: string;
1223
+ disabled_at: string | null;
1224
+ expires_at: string | null;
1225
+ id: string;
1226
+ max_sessions_per_visitor: number;
1227
+ max_turns_per_session: number;
1228
+ mode: string;
1229
+ organization_id: string;
1230
+ resource_id: string;
1231
+ slug: string;
1232
+ tool_policy: Json;
1233
+ updated_at: string;
1234
+ };
1235
+ Insert: {
1236
+ allowed_origins?: string[];
1237
+ branding?: Json;
1238
+ capture_fields?: Json;
1239
+ code_hash?: string | null;
1240
+ code_salt?: string | null;
1241
+ created_at?: string;
1242
+ disabled_at?: string | null;
1243
+ expires_at?: string | null;
1244
+ id?: string;
1245
+ max_sessions_per_visitor?: number;
1246
+ max_turns_per_session?: number;
1247
+ mode?: string;
1248
+ organization_id: string;
1249
+ resource_id: string;
1250
+ slug: string;
1251
+ tool_policy?: Json;
1252
+ updated_at?: string;
1253
+ };
1254
+ Update: {
1255
+ allowed_origins?: string[];
1256
+ branding?: Json;
1257
+ capture_fields?: Json;
1258
+ code_hash?: string | null;
1259
+ code_salt?: string | null;
1260
+ created_at?: string;
1261
+ disabled_at?: string | null;
1262
+ expires_at?: string | null;
1263
+ id?: string;
1264
+ max_sessions_per_visitor?: number;
1265
+ max_turns_per_session?: number;
1266
+ mode?: string;
1267
+ organization_id?: string;
1268
+ resource_id?: string;
1269
+ slug?: string;
1270
+ tool_policy?: Json;
1271
+ updated_at?: string;
1272
+ };
1273
+ Relationships: [
1274
+ {
1275
+ foreignKeyName: "agent_access_grants_organization_id_fkey";
1276
+ columns: ["organization_id"];
1277
+ isOneToOne: false;
1278
+ referencedRelation: "organizations";
1279
+ referencedColumns: ["id"];
1280
+ }
1281
+ ];
1282
+ };
1218
1283
  api_keys: {
1219
1284
  Row: {
1220
1285
  created_at: string | null;
@@ -2122,138 +2187,6 @@ type Database = {
2122
2187
  };
2123
2188
  Relationships: [];
2124
2189
  };
2125
- agent_access_grants: {
2126
- Row: {
2127
- allowed_origins: string[];
2128
- branding: Json;
2129
- capture_fields: Json;
2130
- code_hash: string | null;
2131
- code_salt: string | null;
2132
- created_at: string;
2133
- disabled_at: string | null;
2134
- expires_at: string | null;
2135
- id: string;
2136
- max_sessions_per_visitor: number;
2137
- max_turns_per_session: number;
2138
- mode: string;
2139
- organization_id: string;
2140
- resource_id: string;
2141
- slug: string;
2142
- tool_policy: Json;
2143
- updated_at: string;
2144
- };
2145
- Insert: {
2146
- allowed_origins?: string[];
2147
- branding?: Json;
2148
- capture_fields?: Json;
2149
- code_hash?: string | null;
2150
- code_salt?: string | null;
2151
- created_at?: string;
2152
- disabled_at?: string | null;
2153
- expires_at?: string | null;
2154
- id?: string;
2155
- max_sessions_per_visitor?: number;
2156
- max_turns_per_session?: number;
2157
- mode?: string;
2158
- organization_id: string;
2159
- resource_id: string;
2160
- slug: string;
2161
- tool_policy?: Json;
2162
- updated_at?: string;
2163
- };
2164
- Update: {
2165
- allowed_origins?: string[];
2166
- branding?: Json;
2167
- capture_fields?: Json;
2168
- code_hash?: string | null;
2169
- code_salt?: string | null;
2170
- created_at?: string;
2171
- disabled_at?: string | null;
2172
- expires_at?: string | null;
2173
- id?: string;
2174
- max_sessions_per_visitor?: number;
2175
- max_turns_per_session?: number;
2176
- mode?: string;
2177
- organization_id?: string;
2178
- resource_id?: string;
2179
- slug?: string;
2180
- tool_policy?: Json;
2181
- updated_at?: string;
2182
- };
2183
- Relationships: [
2184
- {
2185
- foreignKeyName: "agent_access_grants_organization_id_fkey";
2186
- columns: ["organization_id"];
2187
- isOneToOne: false;
2188
- referencedRelation: "organizations";
2189
- referencedColumns: ["id"];
2190
- }
2191
- ];
2192
- };
2193
- agent_chat_capabilities: {
2194
- Row: {
2195
- created_at: string;
2196
- expires_at: string;
2197
- grant_id: string;
2198
- id: string;
2199
- organization_id: string;
2200
- origin: string | null;
2201
- resource_id: string;
2202
- revoked_at: string | null;
2203
- session_id: string | null;
2204
- token_hash: string;
2205
- visitor_id: string | null;
2206
- };
2207
- Insert: {
2208
- created_at?: string;
2209
- expires_at: string;
2210
- grant_id: string;
2211
- id?: string;
2212
- organization_id: string;
2213
- origin?: string | null;
2214
- resource_id: string;
2215
- revoked_at?: string | null;
2216
- session_id?: string | null;
2217
- token_hash: string;
2218
- visitor_id?: string | null;
2219
- };
2220
- Update: {
2221
- created_at?: string;
2222
- expires_at?: string;
2223
- grant_id?: string;
2224
- id?: string;
2225
- organization_id?: string;
2226
- origin?: string | null;
2227
- resource_id?: string;
2228
- revoked_at?: string | null;
2229
- session_id?: string | null;
2230
- token_hash?: string;
2231
- visitor_id?: string | null;
2232
- };
2233
- Relationships: [
2234
- {
2235
- foreignKeyName: "agent_chat_capabilities_grant_id_fkey";
2236
- columns: ["grant_id"];
2237
- isOneToOne: false;
2238
- referencedRelation: "agent_access_grants";
2239
- referencedColumns: ["id"];
2240
- },
2241
- {
2242
- foreignKeyName: "agent_chat_capabilities_organization_id_fkey";
2243
- columns: ["organization_id"];
2244
- isOneToOne: false;
2245
- referencedRelation: "organizations";
2246
- referencedColumns: ["id"];
2247
- },
2248
- {
2249
- foreignKeyName: "agent_chat_capabilities_session_id_fkey";
2250
- columns: ["session_id"];
2251
- isOneToOne: false;
2252
- referencedRelation: "sessions";
2253
- referencedColumns: ["session_id"];
2254
- }
2255
- ];
2256
- };
2257
2190
  organizations: {
2258
2191
  Row: {
2259
2192
  config: Json;
@@ -3152,11 +3085,11 @@ type Database = {
3152
3085
  Returns: undefined;
3153
3086
  };
3154
3087
  auth_jwt_claims: {
3155
- Args: never;
3088
+ Args: Record<PropertyKey, never>;
3156
3089
  Returns: Json;
3157
3090
  };
3158
3091
  auth_uid_safe: {
3159
- Args: never;
3092
+ Args: Record<PropertyKey, never>;
3160
3093
  Returns: string;
3161
3094
  };
3162
3095
  can_assign_role_in_org: {
@@ -3167,7 +3100,7 @@ type Database = {
3167
3100
  Returns: boolean;
3168
3101
  };
3169
3102
  current_user_is_platform_admin: {
3170
- Args: never;
3103
+ Args: Record<PropertyKey, never>;
3171
3104
  Returns: boolean;
3172
3105
  };
3173
3106
  current_user_shares_org_with: {
@@ -3177,11 +3110,11 @@ type Database = {
3177
3110
  Returns: boolean;
3178
3111
  };
3179
3112
  current_user_supabase_id: {
3180
- Args: never;
3113
+ Args: Record<PropertyKey, never>;
3181
3114
  Returns: string;
3182
3115
  };
3183
3116
  detect_stalled_executions: {
3184
- Args: never;
3117
+ Args: Record<PropertyKey, never>;
3185
3118
  Returns: undefined;
3186
3119
  };
3187
3120
  execute_session_turn: {
@@ -3202,7 +3135,7 @@ type Database = {
3202
3135
  }[];
3203
3136
  };
3204
3137
  get_platform_credential_kek: {
3205
- Args: never;
3138
+ Args: Record<PropertyKey, never>;
3206
3139
  Returns: string;
3207
3140
  };
3208
3141
  get_storage_org_id: {
@@ -3212,7 +3145,7 @@ type Database = {
3212
3145
  Returns: string;
3213
3146
  };
3214
3147
  get_workos_user_id: {
3215
- Args: never;
3148
+ Args: Record<PropertyKey, never>;
3216
3149
  Returns: string;
3217
3150
  };
3218
3151
  has_org_access: {
@@ -3220,10 +3153,7 @@ type Database = {
3220
3153
  action?: string;
3221
3154
  org_id: string;
3222
3155
  system_path: string;
3223
- };
3224
- Returns: boolean;
3225
- } | {
3226
- Args: {
3156
+ } | {
3227
3157
  action?: string;
3228
3158
  system_path: string;
3229
3159
  };
@@ -3259,15 +3189,15 @@ type Database = {
3259
3189
  Returns: Json;
3260
3190
  };
3261
3191
  process_due_schedules: {
3262
- Args: never;
3192
+ Args: Record<PropertyKey, never>;
3263
3193
  Returns: Json;
3264
3194
  };
3265
3195
  recompute_all_memberships: {
3266
- Args: never;
3196
+ Args: Record<PropertyKey, never>;
3267
3197
  Returns: undefined;
3268
3198
  };
3269
3199
  repair_membership_role_assignments: {
3270
- Args: never;
3200
+ Args: Record<PropertyKey, never>;
3271
3201
  Returns: {
3272
3202
  membership_id: string;
3273
3203
  organization_id: string;
@@ -3297,7 +3227,7 @@ type Database = {
3297
3227
  Returns: string;
3298
3228
  };
3299
3229
  upsert_user_profile: {
3300
- Args: never;
3230
+ Args: Record<PropertyKey, never>;
3301
3231
  Returns: {
3302
3232
  profile_display_name: string;
3303
3233
  profile_email: string;
@@ -5170,6 +5100,7 @@ interface ElevasisAuthenticatedShellProps {
5170
5100
  topbar?: ReactNode | ((context: ElevasisAuthenticatedShellRenderContext) => ReactNode);
5171
5101
  children?: ReactNode;
5172
5102
  fullScreenPaths?: readonly string[];
5103
+ fullScreenPathPrefixes?: readonly string[];
5173
5104
  readyMode?: 'user' | 'organization';
5174
5105
  accountPath?: string;
5175
5106
  signOutReturnTo?: string;
@@ -5185,7 +5116,7 @@ interface ElevasisAuthenticatedShellProps {
5185
5116
  onError?: AppErrorBoundaryProps['onError'];
5186
5117
  sidebarLinks?: (links: ShellSidebarLinkGroup[]) => ShellSidebarLinkGroup[];
5187
5118
  }
5188
- declare function ElevasisAuthenticatedShell({ systems, organizationModel, logos, topbar, children, fullScreenPaths, readyMode, accountPath, signOutReturnTo, appVersion, timeRange, operationsApiUrl, operationsSSEManager, deliveryApiUrl, deliverySSEManager, disabledSubsectionPaths, isDev, errorFallback, onError, sidebarLinks }: ElevasisAuthenticatedShellProps): react_jsx_runtime.JSX.Element;
5119
+ declare function ElevasisAuthenticatedShell({ systems, organizationModel, logos, topbar, children, fullScreenPaths, fullScreenPathPrefixes, readyMode, accountPath, signOutReturnTo, appVersion, timeRange, operationsApiUrl, operationsSSEManager, deliveryApiUrl, deliverySSEManager, disabledSubsectionPaths, isDev, errorFallback, onError, sidebarLinks }: ElevasisAuthenticatedShellProps): react_jsx_runtime.JSX.Element;
5189
5120
 
5190
5121
  export { ElevasisAuthenticatedShell, createElevasisApp };
5191
5122
  export type { ElevasisAppConfig, ElevasisAppStoreConfig, ElevasisAuthenticatedShellLogoConfig, ElevasisAuthenticatedShellProps, ElevasisAuthenticatedShellRenderContext };
package/dist/app/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { useSessionCheck, AppErrorBoundary, SidebarProvider, ElevasisSystemsProvider, useElevasisSystems, AppShellContainer, Sidebar, AppShellRightSideContainer, AppShellRightSideOuterContainer, SystemShell, ElevasisUIProvider } from '../chunk-SBNC3FRX.js';
1
+ import { useSessionCheck, AppErrorBoundary, SidebarProvider, ElevasisSystemsProvider, useElevasisSystems, AppShellContainer, Sidebar, AppShellRightSideContainer, AppShellRightSideOuterContainer, SystemShell, ElevasisUIProvider } from '../chunk-V3B26UZR.js';
2
2
  import '../chunk-NZ2F5RQ4.js';
3
3
  import '../chunk-OJJK27GC.js';
4
4
  import '../chunk-ZTWA5H77.js';
@@ -11,8 +11,8 @@ import '../chunk-GMXGDO3I.js';
11
11
  import '../chunk-S3XR4II4.js';
12
12
  import { useInitialization } from '../chunk-6DO4PE3O.js';
13
13
  import '../chunk-DD3CCMCZ.js';
14
- import '../chunk-EJL4U7OZ.js';
15
- import '../chunk-GUKY77FJ.js';
14
+ import '../chunk-M7WWRZ5Z.js';
15
+ import '../chunk-E6NSKXYN.js';
16
16
  import { TanStackRouterBridge, ScrollToTop } from '../chunk-2IFYDILW.js';
17
17
  import '../chunk-Q7DJKLEN.js';
18
18
  import '../chunk-HENXLGVD.js';
@@ -126,6 +126,7 @@ function ElevasisAuthenticatedShell({
126
126
  topbar,
127
127
  children,
128
128
  fullScreenPaths = ["/login", "/auth-redirect"],
129
+ fullScreenPathPrefixes = ["/public/", "/chat/"],
129
130
  readyMode = "organization",
130
131
  accountPath = "/settings/account",
131
132
  signOutReturnTo,
@@ -151,7 +152,7 @@ function ElevasisAuthenticatedShell({
151
152
  if (isDev) return [...disabledSubsectionPaths ?? []];
152
153
  return [.../* @__PURE__ */ new Set([...devOnlySubsectionPaths(organizationModel), ...disabledSubsectionPaths ?? []])];
153
154
  }, [disabledSubsectionPaths, isDev, organizationModel]);
154
- const isFullScreenPage = fullScreenPaths.includes(location.pathname);
155
+ const isFullScreenPage = fullScreenPaths.includes(location.pathname) || fullScreenPathPrefixes.some((prefix) => location.pathname.startsWith(prefix));
155
156
  const isReady = readyMode === "user" ? initialization.userReady : initialization.allReady;
156
157
  const shouldShowSidebar = Boolean(user && !isLoading && !isFullScreenPage && isReady);
157
158
  if (!shouldShowSidebar) {
@@ -1,4 +1,4 @@
1
- export { AccessGuard, AccessKeys, ProtectedRoute, useSessionCheck as useRefocusSessionCheck, useSessionCheck, useStableAccessToken } from '../chunk-SBNC3FRX.js';
1
+ export { AccessGuard, AccessKeys, ProtectedRoute, useSessionCheck as useRefocusSessionCheck, useSessionCheck, useStableAccessToken } from '../chunk-V3B26UZR.js';
2
2
  import '../chunk-NZ2F5RQ4.js';
3
3
  import '../chunk-OJJK27GC.js';
4
4
  import '../chunk-ZTWA5H77.js';
@@ -11,8 +11,8 @@ import '../chunk-GMXGDO3I.js';
11
11
  import '../chunk-S3XR4II4.js';
12
12
  import '../chunk-6DO4PE3O.js';
13
13
  import '../chunk-DD3CCMCZ.js';
14
- import '../chunk-EJL4U7OZ.js';
15
- import '../chunk-GUKY77FJ.js';
14
+ import '../chunk-M7WWRZ5Z.js';
15
+ import '../chunk-E6NSKXYN.js';
16
16
  import '../chunk-2IFYDILW.js';
17
17
  import '../chunk-Q7DJKLEN.js';
18
18
  import '../chunk-HENXLGVD.js';
@@ -1,4 +1,4 @@
1
- export { ActivityTrendChart, ChartFrame, CombinedTrendChart, CostTrendChart, CyberAreaChart, CyberDonut, CyberDonutTooltip, CyberLegendItem, HeroStatsRow, getSeriesColor, useCyberColors } from '../chunk-SBNC3FRX.js';
1
+ export { ActivityTrendChart, ChartFrame, CombinedTrendChart, CostTrendChart, CyberAreaChart, CyberDonut, CyberDonutTooltip, CyberLegendItem, HeroStatsRow, getSeriesColor, useCyberColors } from '../chunk-V3B26UZR.js';
2
2
  import '../chunk-NZ2F5RQ4.js';
3
3
  import '../chunk-OJJK27GC.js';
4
4
  import '../chunk-ZTWA5H77.js';
@@ -11,8 +11,8 @@ import '../chunk-GMXGDO3I.js';
11
11
  import '../chunk-S3XR4II4.js';
12
12
  import '../chunk-6DO4PE3O.js';
13
13
  import '../chunk-DD3CCMCZ.js';
14
- import '../chunk-EJL4U7OZ.js';
15
- import '../chunk-GUKY77FJ.js';
14
+ import '../chunk-M7WWRZ5Z.js';
15
+ import '../chunk-E6NSKXYN.js';
16
16
  import '../chunk-2IFYDILW.js';
17
17
  import '../chunk-Q7DJKLEN.js';
18
18
  import '../chunk-HENXLGVD.js';
@@ -604,6 +604,7 @@ function ProcessingIndicator() {
604
604
  }
605
605
  );
606
606
  }
607
+ var TEXT_MESSAGE_TYPES = /* @__PURE__ */ new Set(["user_message", "assistant_message"]);
607
608
  function MessageAreaContent({
608
609
  isConnected,
609
610
  isProcessing,
@@ -636,6 +637,8 @@ function ChatInterface({
636
637
  input,
637
638
  onInputChange,
638
639
  onSendMessage,
640
+ className,
641
+ style,
639
642
  isProcessing = false,
640
643
  isConnected = true,
641
644
  error,
@@ -643,23 +646,28 @@ function ChatInterface({
643
646
  emptyStateText = "No messages yet",
644
647
  emptyStateSubtext = "Send a message to start the conversation",
645
648
  placeholder = "Message the agent...",
646
- messageAreaVariant = "grid"
649
+ messageAreaVariant = "grid",
650
+ showAgentActivity = true
647
651
  }) {
648
652
  const scrollRef = useRef(null);
649
653
  const scrollContainerRef = useRef(null);
654
+ const visibleMessages = useMemo(
655
+ () => showAgentActivity ? messages : messages.filter((message) => TEXT_MESSAGE_TYPES.has(message.messageType)),
656
+ [messages, showAgentActivity]
657
+ );
650
658
  useEffect(() => {
651
659
  if (scrollContainerRef.current) {
652
660
  scrollContainerRef.current.scrollTop = scrollContainerRef.current.scrollHeight;
653
661
  }
654
- }, [messages.length, isConnected, isProcessing]);
655
- return /* @__PURE__ */ jsxs(Stack, { gap: 0, style: { height: "100%", overflow: "hidden" }, children: [
662
+ }, [visibleMessages.length, isConnected, isProcessing]);
663
+ return /* @__PURE__ */ jsxs(Stack, { className, gap: 0, style: { height: "100%", overflow: "hidden", ...style }, children: [
656
664
  /* @__PURE__ */ jsx(ScrollableContainer, { containerRef: scrollContainerRef, variant: messageAreaVariant, children: /* @__PURE__ */ jsx(
657
665
  MessageAreaContent,
658
666
  {
659
667
  isConnected,
660
668
  isProcessing,
661
669
  error,
662
- messages,
670
+ messages: visibleMessages,
663
671
  emptyStateText,
664
672
  emptyStateSubtext,
665
673
  scrollRef
@@ -0,0 +1,159 @@
1
+ import { UuidSchema } from './chunk-TVTSASST.js';
2
+ import { z } from 'zod';
3
+
4
+ // src/hooks/sessions/mergeSessionMessages.ts
5
+ function canonicalize(value) {
6
+ if (Array.isArray(value)) {
7
+ return value.map(canonicalize);
8
+ }
9
+ if (value && typeof value === "object") {
10
+ const source = value;
11
+ return Object.keys(source).sort().reduce((acc, key) => {
12
+ acc[key] = canonicalize(source[key]);
13
+ return acc;
14
+ }, {});
15
+ }
16
+ return value;
17
+ }
18
+ function stableStringify(value) {
19
+ return JSON.stringify(canonicalize(value));
20
+ }
21
+ function mergeSessionMessages(historyMessages, liveMessages) {
22
+ const messageMap = /* @__PURE__ */ new Map();
23
+ for (const message of historyMessages) {
24
+ messageMap.set(message.id, message);
25
+ }
26
+ for (const message of liveMessages) {
27
+ if (!message.id.startsWith("temp-")) {
28
+ messageMap.set(message.id, message);
29
+ continue;
30
+ }
31
+ const alreadyPersisted = Array.from(messageMap.values()).some((existing) => {
32
+ if (existing.role !== message.role) return false;
33
+ if (existing.messageType !== message.messageType) return false;
34
+ if (message.metadata && existing.metadata) {
35
+ return stableStringify(existing.metadata) === stableStringify(message.metadata);
36
+ }
37
+ return existing.text === message.text;
38
+ });
39
+ if (!alreadyPersisted) {
40
+ messageMap.set(message.id, message);
41
+ }
42
+ }
43
+ return Array.from(messageMap.values()).sort((a, b) => {
44
+ if (a.turnNumber !== b.turnNumber) return a.turnNumber - b.turnNumber;
45
+ return (a.messageIndex ?? 0) - (b.messageIndex ?? 0);
46
+ });
47
+ }
48
+ var SessionIdParamSchema = z.object({
49
+ sessionId: UuidSchema
50
+ }).strict();
51
+ var ExecutionIdParamsSchema = z.object({
52
+ sessionId: UuidSchema,
53
+ executionId: UuidSchema
54
+ }).strict();
55
+ var CreateSessionSchema = z.object({
56
+ resourceId: z.string().min(1).max(100),
57
+ userId: UuidSchema.optional(),
58
+ metadata: z.any().optional()
59
+ }).strict();
60
+ z.object({
61
+ input: z.unknown().refine(
62
+ (val) => {
63
+ let text;
64
+ if (typeof val === "string") {
65
+ text = val;
66
+ } else if (val && typeof val === "object" && "message" in val) {
67
+ text = String(val.message);
68
+ } else {
69
+ text = JSON.stringify(val);
70
+ }
71
+ return text.length > 0 && text.length <= 1e5;
72
+ },
73
+ { message: "Input must be between 1 and 100,000 characters" }
74
+ ),
75
+ metadata: z.any().optional()
76
+ }).strict();
77
+ z.object({
78
+ userId: UuidSchema.optional(),
79
+ resourceId: z.string().optional(),
80
+ limit: z.coerce.number().int().min(1).max(100).default(20)
81
+ }).strict();
82
+ z.object({
83
+ limit: z.coerce.number().int().min(1).max(100).default(100),
84
+ cursor: z.coerce.number().int().min(0).optional()
85
+ }).strict();
86
+ var WebSocketSessionTurnSchema = z.object({
87
+ type: z.literal("session:turn"),
88
+ input: z.unknown().refine(
89
+ (val) => {
90
+ let text;
91
+ if (typeof val === "string") {
92
+ text = val;
93
+ } else if (val && typeof val === "object" && "message" in val) {
94
+ text = String(val.message);
95
+ } else {
96
+ text = JSON.stringify(val) || "";
97
+ }
98
+ return text && text.length > 0 && text.length <= 1e5;
99
+ },
100
+ { message: "Input must be between 1 and 100,000 characters" }
101
+ )
102
+ }).strict();
103
+ var NotificationCategorySchema = z.enum(["info", "queue", "alert", "error", "system"]);
104
+ var GetNotificationsQuerySchema = z.object({
105
+ limit: z.coerce.number().int().min(1).max(100).default(50),
106
+ offset: z.coerce.number().int().min(0).default(0)
107
+ });
108
+ var MarkAsReadParamsSchema = z.object({
109
+ id: UuidSchema
110
+ });
111
+ z.object({
112
+ userId: UuidSchema,
113
+ organizationId: UuidSchema,
114
+ category: NotificationCategorySchema,
115
+ title: z.string().trim().min(1).max(200),
116
+ message: z.string().trim().min(1).max(1e3),
117
+ actionUrl: z.string().url().optional()
118
+ }).strict();
119
+ z.object({
120
+ ids: z.array(UuidSchema).min(1).max(500)
121
+ }).strict();
122
+
123
+ // src/hooks/sessions/sessionWebSocketUtils.ts
124
+ var liveTempMessageCounter = 0;
125
+ function createLiveTempMessageIdentity() {
126
+ liveTempMessageCounter += 1;
127
+ return {
128
+ id: `temp-${liveTempMessageCounter}`,
129
+ messageIndex: liveTempMessageCounter,
130
+ createdAt: /* @__PURE__ */ new Date()
131
+ };
132
+ }
133
+ function formatMessageEvent(event) {
134
+ switch (event.type) {
135
+ case "user_message":
136
+ return event.text;
137
+ case "assistant_message":
138
+ return event.text;
139
+ case "agent:started":
140
+ return "Agent started reasoning";
141
+ case "agent:reasoning":
142
+ return `Reasoning (Iteration ${event.iteration})`;
143
+ case "agent:tool_call":
144
+ return `Tool: ${event.toolName}`;
145
+ case "agent:tool_result":
146
+ return event.success ? "Tool Result" : "Tool Result (Failed)";
147
+ case "agent:completed":
148
+ return "Agent completed";
149
+ case "agent:error":
150
+ return `Agent error: ${event.error}`;
151
+ }
152
+ }
153
+ function getWebSocketBaseUrl(apiUrl) {
154
+ const url = new URL(apiUrl);
155
+ const protocol = url.protocol === "https:" ? "wss:" : "ws:";
156
+ return `${protocol}//${url.host}`;
157
+ }
158
+
159
+ export { CreateSessionSchema, ExecutionIdParamsSchema, GetNotificationsQuerySchema, MarkAsReadParamsSchema, SessionIdParamSchema, WebSocketSessionTurnSchema, createLiveTempMessageIdentity, formatMessageEvent, getWebSocketBaseUrl, mergeSessionMessages };
@@ -6,8 +6,8 @@ import { sidebarItemGap, sidebarSubLinkPaddingY, sidebarSubLinkPaddingX, sidebar
6
6
  import { CardHeader } from './chunk-S3XR4II4.js';
7
7
  import { useInitialization, InitializationContext, InitializationProvider } from './chunk-6DO4PE3O.js';
8
8
  import { OrganizationContext, useOrganization } from './chunk-DD3CCMCZ.js';
9
- import { SessionIdParamSchema, CreateSessionSchema, GetNotificationsQuerySchema, MarkAsReadParamsSchema, ExecutionIdParamsSchema, WebSocketSessionTurnSchema } from './chunk-EJL4U7OZ.js';
10
- import { StyledMarkdown, ChatHeader, ChatSidebar } from './chunk-GUKY77FJ.js';
9
+ import { SessionIdParamSchema, CreateSessionSchema, GetNotificationsQuerySchema, MarkAsReadParamsSchema, ExecutionIdParamsSchema, createLiveTempMessageIdentity, WebSocketSessionTurnSchema } from './chunk-M7WWRZ5Z.js';
10
+ import { StyledMarkdown, ChatHeader, ChatSidebar } from './chunk-E6NSKXYN.js';
11
11
  import { useRouterContext } from './chunk-Q7DJKLEN.js';
12
12
  import { Graph_module_css_default, useDirectedChainHighlighting, useNodeSelection, useFitViewTrigger, useGraphHighlighting, calculateGraphHeight, GRAPH_CONSTANTS } from './chunk-HENXLGVD.js';
13
13
  import { STATUS_COLORS, getStatusIcon, formatDuration, getStatusColors, AGENT_CONSTANTS, shouldAnimateEdge, TIMELINE_CONSTANTS, calculateBarPosition, CONTAINER_CONSTANTS, useExecutionPath, useUnifiedWorkflowLayout, WORKFLOW_CONSTANTS, useReactFlowAgent, getResourceStatusColor, useMergedExecution, useTimelineData, useAgentIterationData } from './chunk-7FPLLSHN.js';
@@ -10967,8 +10967,9 @@ function useSessionWebSocket(sessionId, apiUrl) {
10967
10967
  try {
10968
10968
  const data = JSON.parse(event.data);
10969
10969
  if (data.type && data.type !== "turn:complete" && data.type !== "error") {
10970
+ const liveIdentity = createLiveTempMessageIdentity();
10970
10971
  const tempMessage = {
10971
- id: `temp-${Date.now()}`,
10972
+ id: liveIdentity.id,
10972
10973
  role: data.type === "user_message" ? "user" : "assistant",
10973
10974
  messageType: data.type,
10974
10975
  text: formatMessageEvent(data),
@@ -10976,9 +10977,8 @@ function useSessionWebSocket(sessionId, apiUrl) {
10976
10977
  metadata: data.type.startsWith("agent:") ? data : void 0,
10977
10978
  turnNumber: 999999,
10978
10979
  // High placeholder so temp messages sort to bottom
10979
- messageIndex: Date.now(),
10980
- // Use timestamp for unique ordering
10981
- createdAt: /* @__PURE__ */ new Date()
10980
+ messageIndex: liveIdentity.messageIndex,
10981
+ createdAt: liveIdentity.createdAt
10982
10982
  };
10983
10983
  setMessages((prev) => [...prev, tempMessage]);
10984
10984
  } else if (data.type === "turn:complete") {
@@ -11066,16 +11066,16 @@ function useSessionWebSocket(sessionId, apiUrl) {
11066
11066
  }));
11067
11067
  return;
11068
11068
  }
11069
+ const liveIdentity = createLiveTempMessageIdentity();
11069
11070
  const userMessage = {
11070
- id: `temp-${Date.now()}`,
11071
+ id: liveIdentity.id,
11071
11072
  role: "user",
11072
11073
  messageType: "user_message",
11073
11074
  text: trimmed,
11074
11075
  turnNumber: 999999,
11075
11076
  // High placeholder so temp messages sort to bottom
11076
- messageIndex: Date.now(),
11077
- // Use timestamp for unique ordering
11078
- createdAt: /* @__PURE__ */ new Date()
11077
+ messageIndex: liveIdentity.messageIndex,
11078
+ createdAt: liveIdentity.createdAt
11079
11079
  };
11080
11080
  setMessages((prev) => [...prev, userMessage]);
11081
11081
  const input = { message: trimmed };