@aintela/chat 0.2.39 → 0.2.41

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 (28) hide show
  1. package/dist/components.js +6482 -6240
  2. package/dist/components.js.map +1 -1
  3. package/dist/hooks.js +1 -1
  4. package/dist/{httpArtifactService-BpRwcTJp.js → httpArtifactService-DBKIvfSD.js} +159 -154
  5. package/dist/httpArtifactService-DBKIvfSD.js.map +1 -0
  6. package/dist/{httpSessionService-M1IKQIQK.js → httpSessionService-CNzThf-T.js} +85 -80
  7. package/dist/httpSessionService-CNzThf-T.js.map +1 -0
  8. package/dist/index.js +190 -183
  9. package/dist/services.js +7 -6
  10. package/dist/src/components/AiChat/AiChatContext.d.ts +8 -0
  11. package/dist/src/components/AiChat/AiChatTypes.d.ts +29 -0
  12. package/dist/src/components/AiChat/ChatPane/AskUserSheet.d.ts +21 -9
  13. package/dist/src/components/AiChat/ChatPane/CurrentMessage.d.ts +2 -2
  14. package/dist/src/components/AiChat/aiChatEngine.d.ts +89 -0
  15. package/dist/src/components/AiChat/aiChatEngine.test.d.ts +1 -0
  16. package/dist/src/components/AiChat/useLiveSession.d.ts +52 -0
  17. package/dist/src/components/index.d.ts +6 -0
  18. package/dist/src/components/v2/RunProgressStripV2.d.ts +3 -1
  19. package/dist/src/services/accessTokenProvider.d.ts +9 -0
  20. package/dist/src/services/httpArtifactService.d.ts +2 -1
  21. package/dist/src/services/httpPromptAssistService.d.ts +2 -7
  22. package/dist/src/services/httpSessionService.d.ts +2 -1
  23. package/dist/src/services/index.d.ts +2 -0
  24. package/dist/{useChatSessions-C-XVE-h3.js → useChatSessions-mnF6pUGm.js} +2 -2
  25. package/dist/{useChatSessions-C-XVE-h3.js.map → useChatSessions-mnF6pUGm.js.map} +1 -1
  26. package/package.json +1 -1
  27. package/dist/httpArtifactService-BpRwcTJp.js.map +0 -1
  28. package/dist/httpSessionService-M1IKQIQK.js.map +0 -1
@@ -0,0 +1,89 @@
1
+ import { AgentContext, User } from '../../models/contexts';
2
+ import { SendMessageResponse } from '../../models/SendMessageResponse';
3
+ import { EventBusService } from '../../services/eventBusService';
4
+ import { AgentGatewayService, GatewaySendMessageOptions } from '../../services/servers/AgentGatewayService';
5
+ import { IStorageService } from '../../services/storageService';
6
+ import { ISessionService } from '../../services/servers/sessionService/ISessionService';
7
+ import { IArtifactService } from '../../services/interfaces/artifactService';
8
+ import { IWebSocketConnection } from '../../services/WebSocketConnection/webSocketConnection';
9
+ import { INotificationPort } from '../../interfaces/INotificationPort';
10
+ import { AiChatStore } from './stateConfiguration';
11
+ import { SessionStateManagerService } from './sessionStateManagerService';
12
+ import { SendMessageUi } from './AiChatTypes';
13
+ /**
14
+ * The connection/session slice of {@link AiChatProps} — everything needed to
15
+ * build a live agent engine (WS gateway + session store + state manager),
16
+ * independent of the presentation props (uiTools, renderers, show* flags, …)
17
+ * which stay with {@link AiChatProvider}.
18
+ */
19
+ export interface AiChatEngineConfig {
20
+ serverBaseUrl: string;
21
+ user: User;
22
+ /**
23
+ * Live source of the authenticated user. When provided, the engine reads
24
+ * the user (and its `access_token`) through this callback on EVERY dial,
25
+ * reconnect and HTTP call, instead of the `user` snapshot — so a token that
26
+ * changes while no React consumer is mounted (silent refresh, sign-in on
27
+ * another page) is still picked up. `setUser` becomes a fallback for hosts
28
+ * that don't supply it. Long-lived shared engines should always pass one:
29
+ * a stale snapshot dialing the WS resolves the WRONG tenant server-side
30
+ * (the JWT rides the handshake and is fixed for the socket's lifetime).
31
+ */
32
+ getUser?: () => User | undefined;
33
+ agentContext: AgentContext;
34
+ sessionService?: ISessionService;
35
+ artifactService?: IArtifactService;
36
+ storageService?: IStorageService;
37
+ eventBusService?: EventBusService;
38
+ notificationPort?: INotificationPort;
39
+ onGetWebSocketProvider?: (rootUrl: string) => IWebSocketConnection;
40
+ onSessionEstablished?: (sessionId: string) => void;
41
+ onRenderPrompt?: (prompt: string) => {
42
+ promptAsString?: string;
43
+ json?: string;
44
+ };
45
+ onGatewayReady?: (gateway: AgentGatewayService) => void;
46
+ }
47
+ /**
48
+ * A standalone, React-independent AiChat engine — the long-lived services that
49
+ * used to be built inside {@link AiChatProvider}'s `useMemo([])`. Extracted
50
+ * (issue #236) so a host can open + hold a live session WITHOUT mounting the
51
+ * whole `<AiChat>` UI over the app: the home page can pre-warm a session (open
52
+ * the socket, create a session) via {@link useLiveSession}, and the operations
53
+ * page mounts a scoped `<AiChat engine={…}>` that ADOPTS the same live engine —
54
+ * same WebSocket, same session, no reconnect on navigation.
55
+ *
56
+ * Creating an engine touches no network; the gateway/manager only dial once
57
+ * {@link openLiveSession} runs.
58
+ */
59
+ export interface AiChatEngine {
60
+ eventBusService: EventBusService;
61
+ storageService: IStorageService;
62
+ notificationPort: INotificationPort;
63
+ artifactService: IArtifactService;
64
+ sessionService: ISessionService;
65
+ sessionStore: AiChatStore;
66
+ agentGatewayService: AgentGatewayService;
67
+ sessionStateManagerService: SessionStateManagerService;
68
+ /** Send a turn (with the optional rich `{ ui }` representation). Mirrors AiChatProvider's `sendMessage`. */
69
+ sendMessage: (text: string, options?: GatewaySendMessageOptions & {
70
+ ui?: SendMessageUi;
71
+ }) => Promise<SendMessageResponse>;
72
+ /** Open the live socket + bind a session (existing id, or a fresh one). The one call a warm-up needs. */
73
+ openLiveSession: (agentContext: AgentContext, sessionId?: string) => Promise<void>;
74
+ /** Push a new agent context to the gateway + manager (live-update, no reconnect). */
75
+ setAgentContext: (context: AgentContext) => void;
76
+ /** Update the user whose token the socket authenticates with (read live on each (re)dial). */
77
+ setUser: (user: User) => void;
78
+ /** Live-swap the model the next turn ships. */
79
+ setModel: (modelId: string) => void;
80
+ /** The model the engine currently ships. */
81
+ getModel: () => string | undefined;
82
+ /** Tear the engine down (stop the manager + close the socket). Not called for shared engines. */
83
+ dispose: () => Promise<void>;
84
+ }
85
+ /**
86
+ * Build a standalone {@link AiChatEngine}. This is the exact service graph
87
+ * {@link AiChatProvider} used to construct inline; keep the two in sync.
88
+ */
89
+ export declare function createAiChatEngine(config: AiChatEngineConfig): AiChatEngine;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,52 @@
1
+ import { AgentContext } from '../../models/contexts';
2
+ import { HttpPromptAssistService } from '../../services/httpPromptAssistService';
3
+ import { AiChatStore } from './stateConfiguration';
4
+ import { AiChatEngine, AiChatEngineConfig } from './aiChatEngine';
5
+ /** Get (or lazily create) the shared engine for `key`. The factory runs at most once per key. */
6
+ export declare function getSharedAiChatEngine(key: string, factory: () => AiChatEngine): AiChatEngine;
7
+ /**
8
+ * Dispose + forget the shared engine for `key` (stops the manager, closes the
9
+ * socket). Hosts call this on a hard identity reset (e.g. full sign-out) if
10
+ * they want the next session to start from a clean socket. Normal navigation
11
+ * should NOT dispose — the whole point is that the engine persists.
12
+ */
13
+ export declare function disposeSharedAiChatEngine(key: string): Promise<void>;
14
+ export interface UseLiveSessionOptions {
15
+ /**
16
+ * Registry key for the shared engine. Callers that must share ONE live
17
+ * session (the home warm-up + the operations page adopting it) pass the
18
+ * SAME key. Defaults to `'default'`. Omit / reuse for a single app-wide
19
+ * conversation; vary it to run independent conversations side by side.
20
+ */
21
+ key?: string;
22
+ }
23
+ /**
24
+ * What {@link useLiveSession} hands back: the shared engine plus the couple of
25
+ * per-consumer services a host reads directly (the prompt-assist client — live
26
+ * over `config.getUser` when supplied, otherwise token-bound and rebuilt on
27
+ * token change — and the session store).
28
+ */
29
+ export interface LiveSession {
30
+ engine: AiChatEngine;
31
+ /** Open the socket + bind a session (fresh, or an existing id). The warm-up entry point. */
32
+ openLiveSession: (agentContext: AgentContext, sessionId?: string) => Promise<void>;
33
+ sessionStore: AiChatStore;
34
+ /** Prompt-assist REST client (auto-@ locations, date hints) — same base URL + bearer as the socket. */
35
+ promptAssistService: HttpPromptAssistService;
36
+ }
37
+ /**
38
+ * Open + hold a live agent session against a defined `agentContext`, WITHOUT
39
+ * mounting the `<AiChat>` UI (issue #236).
40
+ *
41
+ * The engine is shared by `options.key`, so a component can warm a session and
42
+ * a *different* component (mounted after the first unmounts) continues it — the
43
+ * home page pre-warms while the user types, then the operations page mounts a
44
+ * scoped `<AiChat engine={liveSession.engine}>` that adopts the same socket and
45
+ * session. Creating the engine touches no network; call {@link openLiveSession}
46
+ * (typically after the auth boot settles) to actually dial.
47
+ *
48
+ * Config changes (agent context, the user's token) are pushed into the shared
49
+ * engine on change via its live-update setters, so every consumer of the same
50
+ * key sees them without a reconnect.
51
+ */
52
+ export declare function useLiveSession(config: AiChatEngineConfig, options?: UseLiveSessionOptions): LiveSession;
@@ -1,5 +1,6 @@
1
1
  export { default as AiChat } from './AiChat/AiChat';
2
2
  export { default as ChatPane } from './AiChat/ChatPane/ChatPane';
3
+ export { default as CurrentMessage } from './AiChat/ChatPane/CurrentMessage';
3
4
  export { AiChatProvider } from './AiChat/AiChatProvider';
4
5
  export { AiChatDrawer } from './AiChat/AiChatDrawer';
5
6
  export { AiChatFloating } from './AiChat/AiChatFloating';
@@ -10,9 +11,14 @@ export type { AiChatState, AiChatStore, SubAgentState } from './AiChat/stateConf
10
11
  export { createAiChatStore } from './AiChat/stateConfiguration';
11
12
  export { createAiChatSessionStore } from './AiChat/AiChatSessionStore';
12
13
  export { SessionStateManagerService, IDLE_TIMEOUT, WARNING_THRESHOLD, } from './AiChat/sessionStateManagerService';
14
+ export { createAiChatEngine } from './AiChat/aiChatEngine';
15
+ export type { AiChatEngine, AiChatEngineConfig } from './AiChat/aiChatEngine';
16
+ export { useLiveSession, getSharedAiChatEngine, disposeSharedAiChatEngine, } from './AiChat/useLiveSession';
17
+ export type { LiveSession, UseLiveSessionOptions } from './AiChat/useLiveSession';
13
18
  export { default as Message } from './AiChat/ChatPane/Message';
14
19
  export { default as SubAgentBox } from './AiChat/ChatPane/SubAgentBox';
15
20
  export type { SubAgentBoxProps } from './AiChat/ChatPane/SubAgentBox';
21
+ export { default as AskUserSheet } from './AiChat/ChatPane/AskUserSheet';
16
22
  export { configureFriendlyMapping, getFriendlyLabel } from './AiChat/ChatPane/friendlyToolConfig';
17
23
  export type { FriendlyState, FriendlyToolEntry } from './AiChat/ChatPane/friendlyToolConfig';
18
24
  export { classifyPart, DEFAULT_PART_RENDERERS, TextPart, ThoughtPart, FunctionPart, WaitingPart, SuspendedPart, BoxedPart, UiToolDispatcher, } from './AiChat/ChatPane/parts';
@@ -1,2 +1,4 @@
1
1
  import { default as React } from 'react';
2
- export declare const RunProgressStripV2: React.FC;
2
+ export declare const RunProgressStripV2: React.FC<{
3
+ showFlowing?: boolean;
4
+ }>;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * A bearer-token source for the library's HTTP clients: either a fixed token
3
+ * string (legacy behavior) or a callback resolved on EVERY request, so a
4
+ * long-lived service always sends the freshest JWT (sign-in, silent refresh,
5
+ * guest→real promotion) instead of the one captured at construction.
6
+ */
7
+ export type AccessTokenProvider = string | (() => string | undefined);
8
+ /** The current token for `provider` (empty string when a callback yields none). */
9
+ export declare function resolveAccessToken(provider: AccessTokenProvider): string;
@@ -1,5 +1,6 @@
1
1
  import { Artifact } from '../models/Artifact';
2
2
  import { IArtifactService } from './interfaces/artifactService';
3
+ import { AccessTokenProvider } from './accessTokenProvider';
3
4
  /**
4
5
  * Minimal IArtifactService for the replay demo. The replay path doesn't
5
6
  * generate artifacts — every persisted FunctionResultContent carries its
@@ -10,7 +11,7 @@ export declare class HttpArtifactService implements IArtifactService {
10
11
  private cache;
11
12
  private serverBaseUrl;
12
13
  private accessToken;
13
- constructor(serverBaseUrl: string, accessToken: string);
14
+ constructor(serverBaseUrl: string, accessToken: AccessTokenProvider);
14
15
  private get headers();
15
16
  init(): Promise<void>;
16
17
  getArtifacts(): Artifact[];
@@ -1,9 +1,4 @@
1
- /**
2
- * Client for the AgentsServer prompt-assist endpoints (POST /prompt/analyze and
3
- * /prompt/resolve-dates). Powers PromptV2's live behaviors: auto-inserting `@` when a location is
4
- * expected, showing date hints, and rendering resolved-date chips. Mirrors HttpArtifactService
5
- * (baseUrl + bearer). The heavy Qwen/NER models run server-side; this is a thin fetch client.
6
- */
1
+ import { AccessTokenProvider } from './accessTokenProvider';
7
2
  /** A personalized dropdown suggestion learned from the customer's history. */
8
3
  export interface AnalyzeSuggestion {
9
4
  kind: string;
@@ -68,7 +63,7 @@ export interface PromptResolution {
68
63
  export declare class HttpPromptAssistService {
69
64
  private baseUrl;
70
65
  private accessToken;
71
- constructor(serverBaseUrl: string, accessToken: string);
66
+ constructor(serverBaseUrl: string, accessToken: AccessTokenProvider);
72
67
  private get headers();
73
68
  /** Quick path (debounce ~300ms). `signal` lets the caller cancel a superseded keystroke. */
74
69
  analyze(text: string, caret: number, signal?: AbortSignal): Promise<PromptAnalysis>;
@@ -1,4 +1,5 @@
1
1
  import { ChatSession, Customer, ISessionService } from '..';
2
+ import { AccessTokenProvider } from './accessTokenProvider';
2
3
  /**
3
4
  * Minimal ISessionService over the WSServer's REST `/sessions` endpoints.
4
5
  *
@@ -12,7 +13,7 @@ import { ChatSession, Customer, ISessionService } from '..';
12
13
  export declare class HttpSessionService implements ISessionService {
13
14
  private serverBaseUrl;
14
15
  private accessToken;
15
- constructor(serverBaseUrl: string, accessToken: string);
16
+ constructor(serverBaseUrl: string, accessToken: AccessTokenProvider);
16
17
  private get headers();
17
18
  getAllSessions(): Promise<ChatSession[]>;
18
19
  retrieveSession(sessionId: string): Promise<ChatSession | null>;
@@ -14,3 +14,5 @@ export { InteractionService } from './interactionService';
14
14
  export { decodeSessionEvents } from './sessionEventDecoder';
15
15
  export { HttpSessionService } from './httpSessionService';
16
16
  export { HttpArtifactService } from './httpArtifactService';
17
+ export { resolveAccessToken } from './accessTokenProvider';
18
+ export type { AccessTokenProvider } from './accessTokenProvider';
@@ -1,7 +1,7 @@
1
1
  var L = Object.defineProperty;
2
2
  var d = (e, t) => L(e, "name", { value: t, configurable: !0 });
3
3
  import { useMemo as h, useState as v, useCallback as g, useEffect as C } from "react";
4
- import { H } from "./httpSessionService-M1IKQIQK.js";
4
+ import { H } from "./httpSessionService-CNzThf-T.js";
5
5
  const w = 6e4, y = 60 * w, l = 24 * y;
6
6
  function k(e) {
7
7
  if (!e) return;
@@ -104,4 +104,4 @@ d(Y, "useChatSessions");
104
104
  export {
105
105
  Y as u
106
106
  };
107
- //# sourceMappingURL=useChatSessions-C-XVE-h3.js.map
107
+ //# sourceMappingURL=useChatSessions-mnF6pUGm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useChatSessions-C-XVE-h3.js","sources":["../src/hooks/useChatSessions.ts"],"sourcesContent":["import { useCallback, useEffect, useMemo, useState } from 'react';\nimport type { ChatSession } from '@lib/models/ChatSession';\nimport type { ISessionService } from '@lib/services/servers/sessionService/ISessionService';\nimport { HttpSessionService } from '../services';\n\n/**\n * One row in a session-picker UI. `raw` is the original ChatSession the\n * server returned; everything else is a derived label the hook computed\n * (and the host's `decorate` callback may have overridden).\n */\nexport interface ChatSessionListItem {\n id: string;\n title: string;\n snippet?: string;\n /** Compact relative-time label (\"now\", \"5m\", \"2h\", \"Mar 14\"). */\n timeLabel?: string;\n /** Optional per-row tag — host-supplied via the `decorate` callback. */\n kind?: string;\n updatedAt?: Date;\n raw: ChatSession;\n}\n\n/**\n * Sessions bucketed by recency. The order of `label` reflects display\n * order top-down (\"Today\" first, \"Older\" last).\n */\nexport interface ChatSessionGroup {\n label: string;\n items: ChatSessionListItem[];\n}\n\nexport interface UseChatSessionsOptions {\n sessionService?: ISessionService;\n /**\n * If provided, the live (current) session is merged into the list —\n * replacing an existing entry by id, or prepended if not yet on the\n * server. Lets a \"New chat\" row appear instantly without waiting for\n * the server roundtrip.\n */\n liveSession?: ChatSession | null;\n\n accessToken: string,\n serverBaseUrl: string,\n /**\n * Per-row override hook. Whatever fields you return are merged on top\n * of the hook's computed item — typical use is adding a `kind` tag for\n * application-specific session types (`'chat' | 'composer' | ...`) the\n * library doesn't know about.\n */\n decorate?: (session: ChatSession) => Partial<ChatSessionListItem>;\n}\n\nexport interface UseChatSessionsResult {\n /** Flat list (live session merged in, server order preserved). */\n sessions: ChatSession[];\n /** Same data bucketed by recency. */\n groups: ChatSessionGroup[];\n isLoading: boolean;\n error: Error | null;\n refresh: () => Promise<void>;\n /** Optimistic rename — patches local state immediately, rolls back on failure. */\n rename: (id: string, title: string) => Promise<void>;\n /** Optimistic remove — drops from local state immediately, rolls back on failure. */\n remove: (id: string) => Promise<void>;\n}\n\nconst MINUTE_MS = 60_000;\nconst HOUR_MS = 60 * MINUTE_MS;\nconst DAY_MS = 24 * HOUR_MS;\n\nfunction toDate(value: Date | string | undefined | null): Date | undefined {\n if (!value) return undefined;\n if (value instanceof Date) return value;\n const d = new Date(value);\n return Number.isNaN(d.getTime()) ? undefined : d;\n}\n\nfunction formatTimeLabel(date: Date | undefined): string {\n if (!date) return '';\n const diff = Date.now() - date.getTime();\n if (diff < MINUTE_MS) return 'now';\n if (diff < HOUR_MS) return `${Math.floor(diff / MINUTE_MS)}m`;\n if (diff < DAY_MS) return `${Math.floor(diff / HOUR_MS)}h`;\n if (diff < 7 * DAY_MS) return `${Math.floor(diff / DAY_MS)}d`;\n return date.toLocaleDateString(undefined, { month: 'short', day: 'numeric' });\n}\n\nfunction startOfToday(): Date {\n const d = new Date();\n d.setHours(0, 0, 0, 0);\n return d;\n}\n\nfunction groupByTime(items: ChatSessionListItem[]): ChatSessionGroup[] {\n const today = startOfToday();\n const yesterday = new Date(today.getTime() - DAY_MS);\n const weekAgo = new Date(today.getTime() - 7 * DAY_MS);\n const monthAgo = new Date(today.getTime() - 30 * DAY_MS);\n\n // Insertion-ordered map preserves the bucket display order.\n const buckets: Array<[string, ChatSessionListItem[]]> = [\n ['Today', []],\n ['Yesterday', []],\n ['This Week', []],\n ['This Month', []],\n ['Older', []],\n ];\n\n for (const item of items) {\n const u = item.updatedAt;\n if (!u) { buckets[4][1].push(item); continue; }\n if (u >= today) buckets[0][1].push(item);\n else if (u >= yesterday) buckets[1][1].push(item);\n else if (u >= weekAgo) buckets[2][1].push(item);\n else if (u >= monthAgo) buckets[3][1].push(item);\n else buckets[4][1].push(item);\n }\n\n return buckets\n .filter(([, list]) => list.length > 0)\n .map(([label, list]) => ({ label, items: list }));\n}\n\nfunction buildItem(\n session: ChatSession,\n decorate?: (s: ChatSession) => Partial<ChatSessionListItem>,\n): ChatSessionListItem {\n const updatedAt = toDate(session.updatedAt) ?? toDate(session.created);\n const base: ChatSessionListItem = {\n id: session.id ?? session.browserScopeId ?? '',\n title: session.overview || session.userDescription || '(untitled chat)',\n snippet: session.lastQuestion ?? undefined,\n timeLabel: formatTimeLabel(updatedAt),\n kind: session.agentType as string | undefined,\n updatedAt,\n raw: session,\n };\n return { ...base, ...(decorate?.(session) ?? {}) };\n}\n\n/**\n * Fetch + organise the user's chat sessions for a picker UI. Backend-agnostic\n * — the host injects an `ISessionService` so the same hook drives an HTTP\n * client, an in-memory fake, or whatever else.\n *\n * Replaces the duplicated `useEffect(async () => sessionService.getAllSessions())`\n * + grouping logic that lived in DataExplorerViewV2 and MobileSessionsList,\n * and consolidates the optimistic rename/delete pattern.\n */\nexport function useChatSessions(opts: UseChatSessionsOptions): UseChatSessionsResult {\n\n const defaultSessionService = useMemo(() => {\n return new HttpSessionService(opts.serverBaseUrl, opts.accessToken);\n }, [opts.accessToken, opts.serverBaseUrl]);\n\n const { sessionService, liveSession, decorate } = {\n sessionService: defaultSessionService,\n liveSession: opts.liveSession,\n decorate: opts.decorate\n };\n const [sessions, setSessions] = useState<ChatSession[]>([]);\n const [isLoading, setIsLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n\n\n const refresh = useCallback(async () => {\n setIsLoading(true);\n setError(null);\n try {\n const list = await sessionService.getAllSessions();\n setSessions(list);\n } catch (err) {\n setError(err instanceof Error ? err : new Error(String(err)));\n } finally {\n setIsLoading(false);\n }\n }, [sessionService]);\n\n useEffect(() => { void refresh(); }, [refresh]);\n\n const merged = useMemo(() => {\n if (!liveSession?.id) return sessions;\n const idx = sessions.findIndex(s => s.id === liveSession.id);\n if (idx === -1) return [liveSession, ...sessions];\n const copy = sessions.slice();\n copy[idx] = liveSession;\n return copy;\n }, [sessions, liveSession]);\n\n const items = useMemo(\n () => merged.map(s => buildItem(s, decorate)),\n [merged, decorate],\n );\n\n const groups = useMemo(() => groupByTime(items), [items]);\n\n const rename = useCallback(async (id: string, title: string) => {\n setSessions(current =>\n current.map(s => (s.id === id ? { ...s, overview: title } : s)),\n );\n try {\n await sessionService.patchSession(id, { overview: title });\n } catch (err) {\n console.error('[useChatSessions] rename failed; refreshing to roll back:', err);\n void refresh();\n }\n }, [sessionService, refresh]);\n\n const remove = useCallback(async (id: string) => {\n setSessions(current => current.filter(s => s.id !== id));\n try {\n await sessionService.removeSession(id);\n } catch (err) {\n console.error('[useChatSessions] remove failed; refreshing to roll back:', err);\n void refresh();\n }\n }, [sessionService, refresh]);\n\n return { sessions: merged, groups, isLoading, error, refresh, rename, remove };\n}\n"],"names":["MINUTE_MS","HOUR_MS","DAY_MS","toDate","value","d","__name","formatTimeLabel","date","diff","startOfToday","groupByTime","items","today","yesterday","weekAgo","monthAgo","buckets","item","u","list","label","buildItem","session","decorate","updatedAt","useChatSessions","opts","defaultSessionService","useMemo","HttpSessionService","sessionService","liveSession","sessions","setSessions","useState","isLoading","setIsLoading","error","setError","refresh","useCallback","err","useEffect","merged","idx","s","copy","groups","rename","id","title","current","remove"],"mappings":";;;;AAkEA,MAAMA,IAAY,KACZC,IAAU,KAAKD,GACfE,IAAS,KAAKD;AAEpB,SAASE,EAAOC,GAA2D;AACvE,MAAI,CAACA,EAAO;AACZ,MAAIA,aAAiB,KAAM,QAAOA;AAClC,QAAMC,IAAI,IAAI,KAAKD,CAAK;AACxB,SAAO,OAAO,MAAMC,EAAE,QAAA,CAAS,IAAI,SAAYA;AACnD;AALSC,EAAAH,GAAA;AAOT,SAASI,EAAgBC,GAAgC;AACrD,MAAI,CAACA,EAAM,QAAO;AAClB,QAAMC,IAAO,KAAK,IAAA,IAAQD,EAAK,QAAA;AAC/B,SAAIC,IAAOT,IAAkB,QACz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S,CAAO,CAAC,GAEtBa,IAASZ,EAAY,OAAOS,MAAe;AAC7C,IAAAhB,EAAY,OAAWkB,EAAQ,OAAO,OAAKN,EAAE,OAAOI,CAAE,CAAC;AACvD,QAAI;AACA,YAAMnB,EAAe,cAAcmB,CAAE;AAAA,IACzC,SAASR,GAAK;AACV,cAAQ,MAAM,6DAA6DA,CAAG,GACzEF,EAAA;AAAA,IACT;AAAA,EACJ,GAAG,CAACT,GAAgBS,CAAO,CAAC;AAE5B,SAAO,EAAE,UAAUI,GAAQ,QAAAI,GAAQ,WAAAZ,GAAW,OAAAE,GAAO,SAAAE,GAAS,QAAAS,GAAQ,QAAAI,EAAA;AAC1E;AAtEgB/C,EAAAoB,GAAA;"}
1
+ {"version":3,"file":"useChatSessions-mnF6pUGm.js","sources":["../src/hooks/useChatSessions.ts"],"sourcesContent":["import { useCallback, useEffect, useMemo, useState } from 'react';\nimport type { ChatSession } from '@lib/models/ChatSession';\nimport type { ISessionService } from '@lib/services/servers/sessionService/ISessionService';\nimport { HttpSessionService } from '../services';\n\n/**\n * One row in a session-picker UI. `raw` is the original ChatSession the\n * server returned; everything else is a derived label the hook computed\n * (and the host's `decorate` callback may have overridden).\n */\nexport interface ChatSessionListItem {\n id: string;\n title: string;\n snippet?: string;\n /** Compact relative-time label (\"now\", \"5m\", \"2h\", \"Mar 14\"). */\n timeLabel?: string;\n /** Optional per-row tag — host-supplied via the `decorate` callback. */\n kind?: string;\n updatedAt?: Date;\n raw: ChatSession;\n}\n\n/**\n * Sessions bucketed by recency. The order of `label` reflects display\n * order top-down (\"Today\" first, \"Older\" last).\n */\nexport interface ChatSessionGroup {\n label: string;\n items: ChatSessionListItem[];\n}\n\nexport interface UseChatSessionsOptions {\n sessionService?: ISessionService;\n /**\n * If provided, the live (current) session is merged into the list —\n * replacing an existing entry by id, or prepended if not yet on the\n * server. Lets a \"New chat\" row appear instantly without waiting for\n * the server roundtrip.\n */\n liveSession?: ChatSession | null;\n\n accessToken: string,\n serverBaseUrl: string,\n /**\n * Per-row override hook. Whatever fields you return are merged on top\n * of the hook's computed item — typical use is adding a `kind` tag for\n * application-specific session types (`'chat' | 'composer' | ...`) the\n * library doesn't know about.\n */\n decorate?: (session: ChatSession) => Partial<ChatSessionListItem>;\n}\n\nexport interface UseChatSessionsResult {\n /** Flat list (live session merged in, server order preserved). */\n sessions: ChatSession[];\n /** Same data bucketed by recency. */\n groups: ChatSessionGroup[];\n isLoading: boolean;\n error: Error | null;\n refresh: () => Promise<void>;\n /** Optimistic rename — patches local state immediately, rolls back on failure. */\n rename: (id: string, title: string) => Promise<void>;\n /** Optimistic remove — drops from local state immediately, rolls back on failure. */\n remove: (id: string) => Promise<void>;\n}\n\nconst MINUTE_MS = 60_000;\nconst HOUR_MS = 60 * MINUTE_MS;\nconst DAY_MS = 24 * HOUR_MS;\n\nfunction toDate(value: Date | string | undefined | null): Date | undefined {\n if (!value) return undefined;\n if (value instanceof Date) return value;\n const d = new Date(value);\n return Number.isNaN(d.getTime()) ? undefined : d;\n}\n\nfunction formatTimeLabel(date: Date | undefined): string {\n if (!date) return '';\n const diff = Date.now() - date.getTime();\n if (diff < MINUTE_MS) return 'now';\n if (diff < HOUR_MS) return `${Math.floor(diff / MINUTE_MS)}m`;\n if (diff < DAY_MS) return `${Math.floor(diff / HOUR_MS)}h`;\n if (diff < 7 * DAY_MS) return `${Math.floor(diff / DAY_MS)}d`;\n return date.toLocaleDateString(undefined, { month: 'short', day: 'numeric' });\n}\n\nfunction startOfToday(): Date {\n const d = new Date();\n d.setHours(0, 0, 0, 0);\n return d;\n}\n\nfunction groupByTime(items: ChatSessionListItem[]): ChatSessionGroup[] {\n const today = startOfToday();\n const yesterday = new Date(today.getTime() - DAY_MS);\n const weekAgo = new Date(today.getTime() - 7 * DAY_MS);\n const monthAgo = new Date(today.getTime() - 30 * DAY_MS);\n\n // Insertion-ordered map preserves the bucket display order.\n const buckets: Array<[string, ChatSessionListItem[]]> = [\n ['Today', []],\n ['Yesterday', []],\n ['This Week', []],\n ['This Month', []],\n ['Older', []],\n ];\n\n for (const item of items) {\n const u = item.updatedAt;\n if (!u) { buckets[4][1].push(item); continue; }\n if (u >= today) buckets[0][1].push(item);\n else if (u >= yesterday) buckets[1][1].push(item);\n else if (u >= weekAgo) buckets[2][1].push(item);\n else if (u >= monthAgo) buckets[3][1].push(item);\n else buckets[4][1].push(item);\n }\n\n return buckets\n .filter(([, list]) => list.length > 0)\n .map(([label, list]) => ({ label, items: list }));\n}\n\nfunction buildItem(\n session: ChatSession,\n decorate?: (s: ChatSession) => Partial<ChatSessionListItem>,\n): ChatSessionListItem {\n const updatedAt = toDate(session.updatedAt) ?? toDate(session.created);\n const base: ChatSessionListItem = {\n id: session.id ?? session.browserScopeId ?? '',\n title: session.overview || session.userDescription || '(untitled chat)',\n snippet: session.lastQuestion ?? undefined,\n timeLabel: formatTimeLabel(updatedAt),\n kind: session.agentType as string | undefined,\n updatedAt,\n raw: session,\n };\n return { ...base, ...(decorate?.(session) ?? {}) };\n}\n\n/**\n * Fetch + organise the user's chat sessions for a picker UI. Backend-agnostic\n * — the host injects an `ISessionService` so the same hook drives an HTTP\n * client, an in-memory fake, or whatever else.\n *\n * Replaces the duplicated `useEffect(async () => sessionService.getAllSessions())`\n * + grouping logic that lived in DataExplorerViewV2 and MobileSessionsList,\n * and consolidates the optimistic rename/delete pattern.\n */\nexport function useChatSessions(opts: UseChatSessionsOptions): UseChatSessionsResult {\n\n const defaultSessionService = useMemo(() => {\n return new HttpSessionService(opts.serverBaseUrl, opts.accessToken);\n }, [opts.accessToken, opts.serverBaseUrl]);\n\n const { sessionService, liveSession, decorate } = {\n sessionService: defaultSessionService,\n liveSession: opts.liveSession,\n decorate: opts.decorate\n };\n const [sessions, setSessions] = useState<ChatSession[]>([]);\n const [isLoading, setIsLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n\n\n const refresh = useCallback(async () => {\n setIsLoading(true);\n setError(null);\n try {\n const list = await sessionService.getAllSessions();\n setSessions(list);\n } catch (err) {\n setError(err instanceof Error ? err : new Error(String(err)));\n } finally {\n setIsLoading(false);\n }\n }, [sessionService]);\n\n useEffect(() => { void refresh(); }, [refresh]);\n\n const merged = useMemo(() => {\n if (!liveSession?.id) return sessions;\n const idx = sessions.findIndex(s => s.id === liveSession.id);\n if (idx === -1) return [liveSession, ...sessions];\n const copy = sessions.slice();\n copy[idx] = liveSession;\n return copy;\n }, [sessions, liveSession]);\n\n const items = useMemo(\n () => merged.map(s => buildItem(s, decorate)),\n [merged, decorate],\n );\n\n const groups = useMemo(() => groupByTime(items), [items]);\n\n const rename = useCallback(async (id: string, title: string) => {\n setSessions(current =>\n current.map(s => (s.id === id ? { ...s, overview: title } : s)),\n );\n try {\n await sessionService.patchSession(id, { overview: title });\n } catch (err) {\n console.error('[useChatSessions] rename failed; refreshing to roll back:', err);\n void refresh();\n }\n }, [sessionService, refresh]);\n\n const remove = useCallback(async (id: string) => {\n setSessions(current => current.filter(s => s.id !== id));\n try {\n await sessionService.removeSession(id);\n } catch (err) {\n console.error('[useChatSessions] remove failed; refreshing to roll back:', err);\n void refresh();\n }\n }, [sessionService, refresh]);\n\n return { sessions: merged, groups, isLoading, error, refresh, rename, remove };\n}\n"],"names":["MINUTE_MS","HOUR_MS","DAY_MS","toDate","value","d","__name","formatTimeLabel","date","diff","startOfToday","groupByTime","items","today","yesterday","weekAgo","monthAgo","buckets","item","u","list","label","buildItem","session","decorate","updatedAt","useChatSessions","opts","defaultSessionService","useMemo","HttpSessionService","sessionService","liveSession","sessions","setSessions","useState","isLoading","setIsLoading","error","setError","refresh","useCallback","err","useEffect","merged","idx","s","copy","groups","rename","id","title","current","remove"],"mappings":";;;;AAkEA,MAAMA,IAAY,KACZC,IAAU,KAAKD,GACfE,IAAS,KAAKD;AAEpB,SAASE,EAAOC,GAA2D;AACvE,MAAI,CAACA,EAAO;AACZ,MAAIA,aAAiB,KAAM,QAAOA;AAClC,QAAMC,IAAI,IAAI,KAAKD,CAAK;AACxB,SAAO,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UK,EAAA,IAAUL,CAAE;AAAA,IAAA;AAElE,QAAI;AACA,YAAMf,EAAe,aAAamB,GAAI,EAAE,UAAUC,GAAO;AAAA,IAC7D,SAAST,GAAK;AACV,cAAQ,MAAM,6DAA6DA,CAAG,GACzEF,EAAA;AAAA,IACT;AAAA,EACJ,GAAG,CAACT,GAAgBS,CAAO,CAAC,GAEtBa,IAASZ,EAAY,OAAOS,MAAe;AAC7C,IAAAhB,EAAY,OAAWkB,EAAQ,OAAO,OAAKN,EAAE,OAAOI,CAAE,CAAC;AACvD,QAAI;AACA,YAAMnB,EAAe,cAAcmB,CAAE;AAAA,IACzC,SAASR,GAAK;AACV,cAAQ,MAAM,6DAA6DA,CAAG,GACzEF,EAAA;AAAA,IACT;AAAA,EACJ,GAAG,CAACT,GAAgBS,CAAO,CAAC;AAE5B,SAAO,EAAE,UAAUI,GAAQ,QAAAI,GAAQ,WAAAZ,GAAW,OAAAE,GAAO,SAAAE,GAAS,QAAAS,GAAQ,QAAAI,EAAA;AAC1E;AAtEgB/C,EAAAoB,GAAA;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aintela/chat",
3
- "version": "0.2.39",
3
+ "version": "0.2.41",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"