@aintela/chat 0.2.59 → 0.3.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.
Files changed (85) hide show
  1. package/README.md +63 -0
  2. package/dist/{ClientMessage-EKgfuTp8.js → ClientMessage-DUby3KyC.js} +16 -22
  3. package/dist/{ClientMessage-EKgfuTp8.js.map → ClientMessage-DUby3KyC.js.map} +1 -1
  4. package/dist/Memory-CjrYSkzB.js +47 -0
  5. package/dist/Memory-CjrYSkzB.js.map +1 -0
  6. package/dist/atMentions-CCNBOf5W.js +954 -0
  7. package/dist/atMentions-CCNBOf5W.js.map +1 -0
  8. package/dist/components.js +4239 -4165
  9. package/dist/components.js.map +1 -1
  10. package/dist/environmentUtils-VZNTCzEE.js +88 -0
  11. package/dist/environmentUtils-VZNTCzEE.js.map +1 -0
  12. package/dist/hooks.js +4 -5
  13. package/dist/{httpArtifactService-CpbRpTHb.js → httpArtifactService-kXjuQtGa.js} +518 -643
  14. package/dist/httpArtifactService-kXjuQtGa.js.map +1 -0
  15. package/dist/{httpSessionService-BEQMIKfv.js → httpSessionService-CMT6k-Nu.js} +2 -3
  16. package/dist/{httpSessionService-BEQMIKfv.js.map → httpSessionService-CMT6k-Nu.js.map} +1 -1
  17. package/dist/index.js +243 -258
  18. package/dist/models.js +48 -51
  19. package/dist/models.js.map +1 -1
  20. package/dist/serializer-D2W42bdT.js +1730 -0
  21. package/dist/serializer-D2W42bdT.js.map +1 -0
  22. package/dist/services.js +2 -2
  23. package/dist/src/components/AiChat/AiChatProvider.agent.test.d.ts +1 -0
  24. package/dist/src/components/AiChat/AiChatProvider.d.ts +2 -2
  25. package/dist/src/components/AiChat/AiChatTypes.d.ts +45 -16
  26. package/dist/src/components/AiChat/ChatPane/parts/ThoughtRun.d.ts +28 -0
  27. package/dist/src/components/AiChat/ChatPane/parts/ThoughtRunContext.d.ts +18 -0
  28. package/dist/src/components/AiChat/ChatPane/parts/index.d.ts +5 -1
  29. package/dist/src/components/AiChat/ChatPane/parts/thoughtRun.test.d.ts +1 -0
  30. package/dist/src/components/AiChat/aiChatEngine.d.ts +24 -5
  31. package/dist/src/components/AiChat/sessionStateManagerService.bind.test.d.ts +1 -0
  32. package/dist/src/components/AiChat/sessionStateManagerService.d.ts +22 -10
  33. package/dist/src/components/AiChat/useAgentEngine.d.ts +69 -0
  34. package/dist/src/components/AiChat/useAgentEngine.test.d.ts +1 -0
  35. package/dist/src/components/index.d.ts +4 -4
  36. package/dist/src/hooks/index.d.ts +1 -1
  37. package/dist/src/hooks/useContainerWidth.d.ts +0 -1
  38. package/dist/src/models/ArtifactData.d.ts +0 -7
  39. package/dist/src/models/ChatSession.d.ts +0 -32
  40. package/dist/src/models/ClientMessage.d.ts +0 -4
  41. package/dist/src/models/ServerEvent.d.ts +0 -36
  42. package/dist/src/models/enums.d.ts +0 -1
  43. package/dist/src/models/index.d.ts +1 -2
  44. package/dist/src/models/interactionPartUtils.test.d.ts +1 -0
  45. package/dist/src/models/semanticKernelModel/sanitizeJsonString.test.d.ts +0 -0
  46. package/dist/src/models/serverEventDecode.test.d.ts +0 -0
  47. package/dist/src/services/WebSocketConnection/webSocketConnectionV2.reconnect.test.d.ts +0 -0
  48. package/dist/src/services/interactionService.d.ts +11 -0
  49. package/dist/src/services/interactionServiceGrouping.test.d.ts +1 -0
  50. package/dist/src/services/servers/AgentGatewayService.d.ts +25 -18
  51. package/dist/src/services/servers/AgentGatewayWSAsync.d.ts +0 -1
  52. package/dist/src/services/servers/agentGatewayAgentContext.test.d.ts +1 -0
  53. package/dist/src/services/storageService.d.ts +16 -59
  54. package/dist/src/services/storageService.test.d.ts +1 -0
  55. package/dist/src/utils/index.d.ts +2 -6
  56. package/dist/src/utils/urlParser.d.ts +0 -1
  57. package/dist/tests/fakes/fakeRawWebSocket.d.ts +51 -0
  58. package/dist/tests/fakes/fakeStorage.d.ts +7 -0
  59. package/dist/tests/fakes/makeGateway.d.ts +24 -1
  60. package/dist/{useChatSessions-BQP7DhY1.js → useChatSessions-CpHq0e1n.js} +2 -2
  61. package/dist/{useChatSessions-BQP7DhY1.js.map → useChatSessions-CpHq0e1n.js.map} +1 -1
  62. package/dist/useContainerWidth-B40_i-NW.js +295 -0
  63. package/dist/{useContainerWidth-B3t1ZTlo.js.map → useContainerWidth-B40_i-NW.js.map} +1 -1
  64. package/dist/utils.js +340 -57
  65. package/dist/utils.js.map +1 -1
  66. package/package.json +1 -1
  67. package/dist/Memory-DjLZqgbF.js +0 -84
  68. package/dist/Memory-DjLZqgbF.js.map +0 -1
  69. package/dist/atMentions-C0dza8DD.js +0 -1000
  70. package/dist/atMentions-C0dza8DD.js.map +0 -1
  71. package/dist/auth-lluJZyQO.js +0 -524
  72. package/dist/auth-lluJZyQO.js.map +0 -1
  73. package/dist/environmentUtils-CUVZ6Dq1.js +0 -478
  74. package/dist/environmentUtils-CUVZ6Dq1.js.map +0 -1
  75. package/dist/httpArtifactService-CpbRpTHb.js.map +0 -1
  76. package/dist/serializer-BXSH9aYQ.js +0 -1360
  77. package/dist/serializer-BXSH9aYQ.js.map +0 -1
  78. package/dist/src/components/AiChat/useLiveSession.d.ts +0 -52
  79. package/dist/src/utils/jsonDetector.d.ts +0 -50
  80. package/dist/src/utils/jsonUtils.d.ts +0 -1
  81. package/dist/src/utils/materialIconsSvg.d.ts +0 -51
  82. package/dist/src/utils/objectUtils.d.ts +0 -31
  83. package/dist/src/utils/parseArtifact.d.ts +0 -3
  84. package/dist/src/utils/uriUtils.d.ts +0 -39
  85. package/dist/useContainerWidth-B3t1ZTlo.js +0 -309
@@ -1,7 +1,6 @@
1
1
  import { AiChatState, AiChatStore } from './stateConfiguration';
2
2
  import { ChatSession } from '../../models/ChatSession';
3
3
  import { SendMessageResponse } from '../../models/SendMessageResponse';
4
- import { AgentContext } from '../../models/contexts';
5
4
  import { IArtifactService } from '../../services/interfaces/artifactService';
6
5
  import { AgentGatewayService } from '../../services/servers/AgentGatewayService';
7
6
  import { ISessionService } from '../../services/servers/sessionService/ISessionService';
@@ -22,30 +21,43 @@ export declare class SessionStateManagerService {
22
21
  paused: boolean;
23
22
  waitTimeForRetry: number;
24
23
  sessionService: ISessionService;
25
- workingContext?: AgentContext;
26
24
  artifactService: IArtifactService;
27
25
  workingSessionId?: string;
26
+ /**
27
+ * Set by the first {@link bindAndOpenLiveSession}. The retry loop used to
28
+ * gate on `workingContext` being present — i.e. "has anyone armed this
29
+ * manager yet?" — so removing that field (issue #59) needs the same latch
30
+ * kept explicitly, or a heartbeat could dial a session no host ever asked for.
31
+ */
32
+ private armed;
28
33
  pendingClosePromise?: Promise<SendMessageResponse | null>;
29
34
  private onSessionEstablished?;
30
35
  constructor(agentGatewayService: AgentGatewayService, sessionService: ISessionService, artifactService: IArtifactService, sessionStore: AiChatStore, options?: SessionStateManagerOptions);
31
36
  /**
32
- * Update the agent context the manager will use on subsequent reconnects.
33
- * Called by AiChatProvider when its `agentContext` prop changes — without
34
- * this, the heartbeat-driven `processRetryLoop` would re-open with the
35
- * stale context captured at the initial bind.
37
+ * The agent this manager binds — read from the gateway on every bind, never
38
+ * cached. The gateway is the single owner (issue #59): the manager holding
39
+ * its own copy is exactly what let a reconnect re-open a conversation as a
40
+ * different agent than the one the socket had been sending as.
36
41
  */
37
- setAgentContext(context: AgentContext): void;
42
+ private get agentContext();
38
43
  pause(): void;
39
44
  start(): void;
40
45
  beat(): void;
41
- createSession(context: AgentContext, sessionId: string): Promise<ChatSession>;
42
- retrieveSession(_context: AgentContext, sessionId: string): Promise<ChatSession | null>;
46
+ /** Create a server-side session for the gateway's agent. The agent is NOT a parameter — see {@link agentContext}. */
47
+ createSession(sessionId: string): Promise<ChatSession>;
48
+ retrieveSession(sessionId: string): Promise<ChatSession | null>;
43
49
  /**
50
+ * Open the socket and bind a session FOR THE GATEWAY'S AGENT. There is
51
+ * deliberately no context parameter (issue #59): a caller that could pass
52
+ * one could open a conversation as an agent the gateway will never send as,
53
+ * which is precisely how a page bound to `expense-agent` ended up talking to
54
+ * `booking-flow-agent`.
55
+ *
44
56
  * @param options.resume keep the socket's replay cursor, so the server replays what was
45
57
  * emitted while we were away. Use it when redialling a session the client already holds
46
58
  * (an app returning to the foreground); leave it off for a fresh user-initiated open.
47
59
  */
48
- bindAndOpenLiveSession(context: AgentContext, sessionId?: string, options?: {
60
+ bindAndOpenLiveSession(sessionId?: string, options?: {
49
61
  resume?: boolean;
50
62
  }): Promise<void>;
51
63
  closeLiveConnection(stoneCold?: boolean, closeTurn?: boolean): Promise<void>;
@@ -0,0 +1,69 @@
1
+ import { AgentContext } from '../../models/contexts';
2
+ import { HttpPromptAssistService } from '../../services/httpPromptAssistService';
3
+ import { AiChatStore } from './stateConfiguration';
4
+ import { AiChatEngine, AiChatEngineConfig } from './aiChatEngine';
5
+ /**
6
+ * Get (or lazily create) the shared engine for `key`. The factory runs at most
7
+ * once per key. Compute the key with {@link engineKeyFor} — a hand-written key
8
+ * can name an engine after something other than its agent, which is the
9
+ * disagreement issue #59 removed.
10
+ */
11
+ export declare function getSharedAiChatEngine(key: string, factory: () => AiChatEngine): AiChatEngine;
12
+ /**
13
+ * Dispose + forget the shared engine for `key` (stops the manager, closes the
14
+ * socket). Hosts call this on a hard identity reset (e.g. full sign-out) if
15
+ * they want the next session to start from a clean socket. Normal navigation
16
+ * should NOT dispose — the whole point is that the engine persists.
17
+ */
18
+ export declare function disposeSharedAiChatEngine(key: string): Promise<void>;
19
+ export interface UseAgentEngineOptions {
20
+ /**
21
+ * Distinguishes two INDEPENDENT conversations with the SAME agent (a
22
+ * side-by-side comparison, a modal that must not resume the page's thread).
23
+ * It is a suffix on the agent-derived key, never a replacement for it —
24
+ * there is deliberately no way to name an engine after something other than
25
+ * its agent (issue #59).
26
+ */
27
+ scope?: string;
28
+ }
29
+ /**
30
+ * The registry key for an engine: `agent` or `agent:scope`. Derived from the
31
+ * agent so that "same key, different agent" cannot be expressed — the shape of
32
+ * the bug this replaced, where a surface reached for a shared engine under its
33
+ * own key and passed a different agent as a prop.
34
+ *
35
+ * @throws if the context carries neither an agent id nor a name — an engine with
36
+ * no agent has nothing to stamp on its sends.
37
+ */
38
+ export declare function engineKeyFor(context: AgentContext, scope?: string): string;
39
+ /**
40
+ * What {@link useAgentEngine} hands back: the shared engine plus the couple of
41
+ * per-consumer services a host reads directly (the prompt-assist client — live
42
+ * over `config.getUser` when supplied, otherwise token-bound and rebuilt on
43
+ * token change — and the session store).
44
+ */
45
+ export interface LiveSession {
46
+ engine: AiChatEngine;
47
+ /** Open the socket + bind a session (fresh, or an existing id). The warm-up entry point. */
48
+ openLiveSession: (sessionId?: string) => Promise<void>;
49
+ sessionStore: AiChatStore;
50
+ /** Prompt-assist REST client (auto-@ locations, date hints) — same base URL + bearer as the socket. */
51
+ promptAssistService: HttpPromptAssistService;
52
+ }
53
+ /**
54
+ * Open + hold a live session for ONE agent, WITHOUT mounting the `<AiChat>` UI
55
+ * (issue #236).
56
+ *
57
+ * The engine is shared under a key DERIVED from the agent (issue #59), so a
58
+ * component can warm a session and a *different* component (mounted after the
59
+ * first unmounts) continues it — the home page pre-warms while the user types,
60
+ * then the operations page mounts a scoped `<AiChat engine={liveSession.engine}>`
61
+ * that adopts the same socket and session. Two surfaces on two agents get two
62
+ * engines by construction; they cannot collide on one key and they cannot
63
+ * quietly overwrite each other's agent. Creating the engine touches no network;
64
+ * call {@link openLiveSession} (typically after the auth boot settles) to dial.
65
+ *
66
+ * The agent is NOT propagated on config change — it is the engine's identity,
67
+ * fixed for its lifetime. Only the live slices (the user's token) are pushed in.
68
+ */
69
+ export declare function useAgentEngine(config: AiChatEngineConfig, options?: UseAgentEngineOptions): LiveSession;
@@ -7,15 +7,15 @@ export { AiChatFloating } from './AiChat/AiChatFloating';
7
7
  export { AiChatServiceContext, useAiChatServices, useAiChatSessionStore, } from './AiChat/AiChatContext';
8
8
  export { useTurnOpen } from './AiChat/useTurnOpen';
9
9
  export type { AiChatContextState as AiChatServices } from './AiChat/AiChatContext';
10
- export type { AiChatProps, AiChatHandle, AiChatStyleProps, AiChatDrawerProps, AiChatFloatingProps, ConnectionInformation, AuthPromptContext, } from './AiChat/AiChatTypes';
10
+ export type { AiChatProps, AiChatBaseProps, AiChatEngineProps, AiChatHandle, AiChatStyleProps, AiChatDrawerProps, AiChatFloatingProps, ConnectionInformation, AuthPromptContext, } from './AiChat/AiChatTypes';
11
11
  export type { AiChatState, AiChatStore, SubAgentState } from './AiChat/stateConfiguration';
12
12
  export { createAiChatStore } from './AiChat/stateConfiguration';
13
13
  export { createAiChatSessionStore } from './AiChat/AiChatSessionStore';
14
14
  export { SessionStateManagerService, IDLE_TIMEOUT, WARNING_THRESHOLD, } from './AiChat/sessionStateManagerService';
15
15
  export { createAiChatEngine } from './AiChat/aiChatEngine';
16
16
  export type { AiChatEngine, AiChatEngineConfig } from './AiChat/aiChatEngine';
17
- export { useLiveSession, getSharedAiChatEngine, disposeSharedAiChatEngine, } from './AiChat/useLiveSession';
18
- export type { LiveSession, UseLiveSessionOptions } from './AiChat/useLiveSession';
17
+ export { useAgentEngine, engineKeyFor, getSharedAiChatEngine, disposeSharedAiChatEngine, } from './AiChat/useAgentEngine';
18
+ export type { LiveSession, UseAgentEngineOptions } from './AiChat/useAgentEngine';
19
19
  export { default as Message } from './AiChat/ChatPane/Message';
20
20
  export { default as SubAgentBox } from './AiChat/ChatPane/SubAgentBox';
21
21
  export type { SubAgentBoxProps } from './AiChat/ChatPane/SubAgentBox';
@@ -31,7 +31,7 @@ export { classifyPart, DEFAULT_PART_RENDERERS, TextPart, ThoughtPart, FunctionPa
31
31
  export type { PartKind, PartRendererProps, PartRenderer, PartRendererMap, } from './AiChat/ChatPane/parts';
32
32
  export { createUiToolRegistry, parseUiArgs, parseClientOutput } from './AiChat/ChatPane/parts';
33
33
  export type { UiToolRegistry, UiToolRegistryBuilder, UiToolContext, UiToolActionContext, UiToolArgs, UiToolRenderFn, UiToolActionFn, UiToolRenderOptions, UiToolActionOptions, UiToolEntry, UiToolRenderEntry, UiToolActionEntry, UiToolAskUserRenderers, UiToolAskUserQuestionFn, UiToolAskUserResponseFn, UiToolAskUserEntry, } from './AiChat/ChatPane/parts';
34
- export { useContainerWidth, useContainerRectangle } from '../hooks/useContainerWidth';
34
+ export { useContainerRectangle } from '../hooks/useContainerWidth';
35
35
  export { default as Stopwatch } from './Stopwatch';
36
36
  export { default as LoadingDots } from './Library/LoadingDots';
37
37
  export { default as MarkdownExtended } from './Library/MarkdowmExtended';
@@ -1,5 +1,5 @@
1
1
  export { default as useInterval } from './useIntervalHook';
2
- export { useContainerWidth, useContainerRectangle } from './useContainerWidth';
2
+ export { useContainerRectangle } from './useContainerWidth';
3
3
  export { useChatSessions } from './useChatSessions';
4
4
  export type { UseChatSessionsOptions, UseChatSessionsResult, ChatSessionListItem, ChatSessionGroup, } from './useChatSessions';
5
5
  export { usePromptAssist } from './usePromptAssist';
@@ -1,2 +1 @@
1
- export declare function useContainerWidth(ref: React.RefObject<HTMLElement | null>, renderId: string, initialWidth?: number): number;
2
1
  export declare function useContainerRectangle(ref: React.RefObject<HTMLElement | null>, renderId: string, initialWidth?: number, initialHeight?: number): number[];
@@ -21,10 +21,3 @@ export interface ArtifactData {
21
21
  interactionQuestion?: string;
22
22
  loadingPromise: Promise<Artifact | null> | null;
23
23
  }
24
- export interface Section {
25
- id: string;
26
- name: string;
27
- isDefault: boolean;
28
- created: string;
29
- iconType?: 'dashboard' | 'chart' | 'folder';
30
- }
@@ -3,10 +3,6 @@ import { AgentType, RunMode, SkillLevel } from './enums';
3
3
  import { Customer } from './Customer';
4
4
  import { User } from '../models/contexts';
5
5
  import { IDBStorable } from './IDBStorable';
6
- export interface SharedUser {
7
- email: string;
8
- permission: 'view' | 'interact';
9
- }
10
6
  export interface ChatSession extends IDBStorable {
11
7
  toolSessionId?: string;
12
8
  fullyLoaded: boolean;
@@ -27,31 +23,3 @@ export interface ChatSession extends IDBStorable {
27
23
  skillLevel?: SkillLevel;
28
24
  sessionRunMode: RunMode;
29
25
  }
30
- export declare class ChatSessionUtils {
31
- static truncateText(text: string, maxLength: number): string;
32
- static truncateSessionForStorage(chatSession: ChatSession): {
33
- toolSessionId?: string;
34
- fullyLoaded: boolean;
35
- loadError?: string;
36
- artifacts: string[];
37
- browserScopeId: string;
38
- interactions: Interaction[];
39
- userDescription?: string;
40
- overview: string;
41
- lastQuestion?: string | null;
42
- agentType: AgentType;
43
- customer?: Customer | null;
44
- activityCount: number;
45
- interactionsCount?: number;
46
- allPartsCount?: number;
47
- user: User;
48
- lastGeneratedOverview?: Date | null;
49
- skillLevel?: SkillLevel;
50
- sessionRunMode: RunMode;
51
- id?: string;
52
- created: Date;
53
- updatedAt?: Date;
54
- collectionName?: string;
55
- };
56
- static truncateInteractionsForStorage(originalInteractions: Interaction[]): Interaction[];
57
- }
@@ -30,9 +30,5 @@ export declare class ClientMessage {
30
30
  name: string;
31
31
  args?: string;
32
32
  };
33
- toPythonJson(): {
34
- mime_type: string;
35
- data: string;
36
- };
37
33
  constructor(data: string, mimeType: string, fake?: boolean, friendlyMessage?: string, images?: ClientMessageImage[]);
38
34
  }
@@ -1,7 +1,6 @@
1
1
  import { EventType } from './enums';
2
2
  import { InteractionPart } from './InteractionPart';
3
3
  import { EndMessageData } from './EndMessageData';
4
- import { ArtifactJson } from '../utils/jsonDetector';
5
4
  import { KernelContent, LlmArtifact, LlmEvent, PartType, SessionInformation, StreamingKernelContent } from './semanticKernelModel/models';
6
5
  export interface FunctionDetails {
7
6
  id: string;
@@ -94,40 +93,6 @@ export interface CodeExecutionResultDetails {
94
93
  outcome: string;
95
94
  output?: string;
96
95
  }
97
- interface CodeExecutionResult {
98
- outcome: string | null;
99
- output: string | null;
100
- }
101
- interface ExecutableCode {
102
- code: string | null;
103
- language: string | null;
104
- }
105
- interface PythonPart {
106
- thought?: boolean | null;
107
- code_execution_result?: CodeExecutionResult | null;
108
- executable_code?: ExecutableCode | null;
109
- function_call?: Partial<FunctionDetails> | null;
110
- function_response?: Partial<FunctionDetails> | null;
111
- text?: string | null;
112
- }
113
- export interface PythonEventMessage {
114
- mime_type: string;
115
- autor: string;
116
- turn_complete?: boolean;
117
- usage_metadata?: any;
118
- end_message_data?: EndMessageData | null;
119
- invocation_id?: string;
120
- serverError?: string | null;
121
- interrupted?: boolean | string;
122
- is_final_response?: boolean;
123
- session_information?: SessionInformation | null;
124
- part_data?: PythonPart | null;
125
- all_parts_data?: PythonPart[] | null;
126
- interaction_id: string | null;
127
- partial?: boolean | string;
128
- artifact_generated?: ArtifactJson[];
129
- async_final_response?: boolean;
130
- }
131
96
  export declare class ServerEvent {
132
97
  uniqueId: string;
133
98
  mimeType: string;
@@ -169,4 +134,3 @@ export declare class ServerEvent {
169
134
  static createFromFunctionName(functionName: string, interactionId: string, callData?: any): ServerEvent;
170
135
  static createFromText(message: string, interactionId: string, thinkingData?: string): ServerEvent;
171
136
  }
172
- export {};
@@ -41,7 +41,6 @@ export declare const EventType: {
41
41
  readonly Waiting: "waiting";
42
42
  readonly Suspended: "suspended";
43
43
  };
44
- export declare const GetEventTypeFromPythonName: (name: string) => EventType;
45
44
  export declare const GetEventTypeFromDotNetName: (name: string) => EventType;
46
45
  export declare const EventTypeDescriptions: {
47
46
  function_call: string;
@@ -2,7 +2,6 @@ export type { Interaction, MergeResult, TurnOpenCloseDetails } from './Interacti
2
2
  export type { InteractionPart } from './InteractionPart';
3
3
  export { InteractionPartUtils } from './InteractionPart';
4
4
  export type { ChatSession } from './ChatSession';
5
- export { ChatSessionUtils } from './ChatSession';
6
5
  export { ClientMessage } from './ClientMessage';
7
6
  export { ClientMessage as ClientMessageClass } from './ClientMessage';
8
7
  export type { ClientMessageImage } from './ClientMessage';
@@ -17,7 +16,7 @@ export type { IDBStorable } from './IDBStorable';
17
16
  export type { IEbiContextData } from './IAbiContext';
18
17
  export * from './enums';
19
18
  export type { Artifact } from './Artifact';
20
- export type { ArtifactData, Section } from './ArtifactData';
19
+ export type { ArtifactData } from './ArtifactData';
21
20
  export type { TodoList, TodoItem, TodoItemStatus } from './todoListModel';
22
21
  export type { SubAgentDto, SubAgentMessage, SubAgentStatus } from './subAgentModel';
23
22
  export { isSubAgentTerminalStatus, SUB_AGENT_TERMINAL_STATUSES } from './subAgentModel';
@@ -0,0 +1 @@
1
+ export {};
File without changes
@@ -13,6 +13,17 @@ export declare class InteractionPartGroup {
13
13
  isLastGroup: boolean;
14
14
  hasThoughts: boolean;
15
15
  lastWithThoughts: boolean;
16
+ /**
17
+ * A run of CONSECUTIVE thought parts — one continuous piece of reasoning
18
+ * that `merge` split at {@link MAX_CHAR_PER_TEXT_PART} to keep a very long
19
+ * prose from dragging the browser down.
20
+ *
21
+ * The split is a rendering optimisation and must not be legible as one: the
22
+ * reader gets a single "Pensando…" block whatever the chunk count, drawn by
23
+ * the run's chrome, while each chunk stays its own memoized MessagePart —
24
+ * which is where the CPU saving actually comes from.
25
+ */
26
+ isThoughtRun: boolean;
16
27
  type: InteractionPartGroupType;
17
28
  }
18
29
  export declare class InteractionService {
@@ -1,5 +1,6 @@
1
1
  import { ServerEvent, ToolEventDetails } from '../../models/ServerEvent';
2
2
  import { User, AgentContext } from '../../models/contexts';
3
+ import { Customer } from '../../models/Customer';
3
4
  import { ClientMessage } from '../../models/ClientMessage';
4
5
  import { Interaction, MergeResult } from '../../models/Interaction';
5
6
  import { EventBusService, FirstTokenEventDetails } from '../eventBusService';
@@ -66,29 +67,36 @@ export declare abstract class AgentGatewayService {
66
67
  */
67
68
  answerHumanTool(toolCallId: string, answer: string): 'sent' | 'queued';
68
69
  constructor(user: User, eventBusService: EventBusService, artifactService: IArtifactService, baseUrl: string, config: AgentContext, sessionStore: AiChatStore, notificationPort: INotificationPort, storageService: IStorageService, sessionId?: string, runMode?: RunMode);
70
+ /**
71
+ * The agent this gateway speaks to — the ONE truth for the conversation.
72
+ * `sendMessageInternal` stamps every outbound frame's `AgentId` from it,
73
+ * and the session manager binds/rebinds against it. Fixed at construction;
74
+ * see {@link forceAgentContext} for the single exception (issue #59).
75
+ */
69
76
  getAgentContext(): AgentContext;
70
77
  getModel(): string | undefined;
71
78
  setModel(modelId: string): void;
72
79
  /**
73
- * Live update for the agent / customer slice of the gateway's
74
- * config. Mirrors {@link setModel}'s in-place pattern so the
75
- * next outgoing message — `sendMessageInternal` reads
76
- * `this.config.agentConfig?.id` directly at send time, see
77
- * `AgentGatewayWSAsync.sendMessageInternal` — picks up the new
78
- * id without rebuilding the gateway or tearing down the
79
- * WebSocket. This is what the host calls from the agent picker
80
- * so switching agents preserves the current session's
81
- * connection, chat history, and any in-flight stream state
82
- * instead of remounting `AiChatProvider` and losing them.
80
+ * Live update for the ordinary, non-identity slice of the context — the
81
+ * dataset/customer the same agent works over. No "force" needed: swapping
82
+ * datasets mid-conversation is routine and changes nothing about who is
83
+ * answering.
84
+ */
85
+ setCustomer(customer: Customer): void;
86
+ /**
87
+ * Replace the AGENT mid-conversation. The escape hatch for an agent picker,
88
+ * and nothing else: the session already holds another agent's history, and
89
+ * the server stamps `Session.AgentId` on the first turn only — so the
90
+ * conversation keeps reporting the agent it STARTED as, however many times
91
+ * this is called. Prefer a new engine (new key, see `engineKeyFor`) per
92
+ * agent.
83
93
  *
84
- * Callers should pass the FULL replacement context (the same
85
- * shape they originally constructed the gateway with). The
86
- * gateway preserves the `model` slice from its current config
87
- * if the incoming context omits it — the model is owned
88
- * separately by `setModel` and shouldn't get clobbered by an
89
- * agent-only change.
94
+ * Callers pass the FULL replacement context (the same shape the gateway was
95
+ * constructed with). The `model` slice is preserved when the incoming
96
+ * context omits it — the model is owned separately by {@link setModel} and
97
+ * must not be clobbered by an agent-only change.
90
98
  */
91
- setAgentContext(config: AgentContext): void;
99
+ forceAgentContext(config: AgentContext): void;
92
100
  getSessionId(): string | undefined;
93
101
  getErrorEvent(errorMessage: string): {
94
102
  interaction_id: string | null;
@@ -164,7 +172,6 @@ export declare abstract class AgentGatewayService {
164
172
  abstract sendMessageInternal(message: ClientMessage, options?: GatewaySendMessageOptions): Promise<SendMessageResponse>;
165
173
  abstract isSuspended(): boolean;
166
174
  abstract suspend(): Promise<boolean>;
167
- abstract reset(user: User, config?: AgentContext): void;
168
175
  check(): Promise<boolean>;
169
176
  startAndForget(): void;
170
177
  forceReceiveMessage(serverEvent: ServerEvent): void;
@@ -15,7 +15,6 @@ import { IStorageService } from '../storageService';
15
15
  export type Reader = (response: AxiosResponse, wasSuspended: boolean, onFirstRead?: () => void) => void;
16
16
  export declare class AgentGatewayWSAsync extends AgentGatewayService {
17
17
  suspendState: boolean;
18
- reset(_user: User, _config?: AgentContext): void;
19
18
  startStream(_sendStartMessage?: boolean): Promise<StartStreamResponse>;
20
19
  isSuspended(): boolean;
21
20
  protected wsService: IWebSocketConnection;
@@ -1,73 +1,30 @@
1
- import { ArtifactData, Section } from '../models/ArtifactData';
2
1
  import { Prompt } from '../models/Prompt';
2
+ /**
3
+ * The prompt-history port. Three methods, all of them live:
4
+ * `storePrompt` on every sent turn, `getPrompts` for the two LastPrompts
5
+ * surfaces, `clearAllPrompts` for the clear control.
6
+ *
7
+ * Keep it this small. It is injected into the gateway, so anything added here
8
+ * has to be implemented by every test fake — and an 18-method interface that
9
+ * fakes could not honestly satisfy is precisely how `sendMessage` came to throw
10
+ * a TypeError in every gateway test without anyone noticing.
11
+ */
3
12
  export interface IStorageService {
4
- initializeStorage(): void;
5
- getSections(): Section[];
6
- getArtifacts(): ArtifactData[];
7
- createSection(name: string, iconType?: 'dashboard' | 'chart' | 'folder'): Section;
8
- updateSection(sectionId: string, updates: Partial<Section>): void;
9
- deleteSection(sectionId: string): void;
10
- storeArtifact(artifact: ArtifactData): void;
11
- moveArtifact(artifactId: string, newSectionId: string): void;
12
- deleteArtifact(artifactId: string): void;
13
- updateArtifact(artifactId: string, updates: Partial<ArtifactData>): void;
14
- getArtifactsBySection(sectionId: string): ArtifactData[];
15
13
  getPrompts(): Prompt[];
16
14
  storePrompt(prompt: Prompt): void;
17
- deletePrompt(promptId: string): void;
18
15
  clearAllPrompts(): void;
19
- getItem(key: string): any;
20
- setItem(key: string, value: any): void;
21
- removeItem(key: string): void;
22
16
  }
17
+ /** The only implementation — no consumer has ever supplied its own. */
23
18
  export declare class LocalStorageService implements IStorageService {
24
- getItem(key: string): string | null;
25
- setItem(key: string, value: any): void;
26
- removeItem(key: string): void;
27
- onPromptCreated: (prompt: Prompt) => void;
28
- initializeStorage(): void;
29
- getSections(): Section[];
30
- getArtifacts(): ArtifactData[];
31
- createSection(name: string, iconType?: 'dashboard' | 'chart' | 'folder'): Section;
32
- updateSection(sectionId: string, updates: Partial<Section>): void;
33
- deleteSection(sectionId: string): void;
34
- storeArtifact(artifact: ArtifactData): void;
35
- moveArtifact(artifactId: string, newSectionId: string): void;
36
- deleteArtifact(artifactId: string): void;
37
- updateArtifact(artifactId: string, updates: Partial<ArtifactData>): void;
38
- getArtifactsBySection(sectionId: string): ArtifactData[];
39
19
  getPrompts(): Prompt[];
40
20
  storePrompt(prompt: Prompt): void;
41
- deletePrompt(promptId: string): void;
42
- clearAllPrompts(): void;
43
- }
44
- export declare class MockStorageService implements IStorageService {
45
- getItem(_key: string): string;
46
- setItem(_key: string, _value: any): void;
47
- removeItem(_key: string): void;
48
- private artifacts;
49
- private sections;
50
- private prompts;
51
- onPromptCreated: (prompt: Prompt) => void;
52
- setMockArtifacts(artifacts: ArtifactData[]): void;
53
- setMockSections(sections: Section[]): void;
54
- setMockPrompts(prompts: Prompt[]): void;
55
- initializeStorage(): void;
56
- getSections(): Section[];
57
- getArtifacts(): ArtifactData[];
58
- createSection(name: string, iconType?: 'dashboard' | 'chart' | 'folder'): Section;
59
- updateSection(sectionId: string, updates: Partial<Section>): void;
60
- deleteSection(sectionId: string): void;
61
- storeArtifact(artifact: ArtifactData): void;
62
- moveArtifact(artifactId: string, newSectionId: string): void;
63
- deleteArtifact(artifactId: string): void;
64
- updateArtifact(artifactId: string, updates: Partial<ArtifactData>): void;
65
- getArtifactsBySection(sectionId: string): ArtifactData[];
66
- getPrompts(): Prompt[];
67
- storePrompt(prompt: Prompt): void;
68
- deletePrompt(promptId: string): void;
69
21
  clearAllPrompts(): void;
70
22
  }
23
+ /**
24
+ * A cheap change-signal over the stored prompts, so the LastPrompts surfaces
25
+ * re-render when a freshly sent prompt lands. It is a digest, not state: the
26
+ * count plus the first/last text and the newest timestamp.
27
+ */
71
28
  export declare const usePromptState: (storageService: IStorageService) => {
72
29
  promptState: string;
73
30
  };
@@ -0,0 +1 @@
1
+ export {};
@@ -3,12 +3,8 @@ export { getAgentBaseUrl } from './getAgentBaseUrl';
3
3
  export { getArtifactsBaseUrl } from './getAgentArtifactsBaseUrl';
4
4
  export { getDotNetBaseUrl } from './getDotNetBaseUrl';
5
5
  export { getRandomUUID, getEnvVar } from './envUtils';
6
- export { dateReviver } from './objectUtils';
7
- export { extractLinkAction, parseAndValidateArtifactUrl } from './urlParser';
8
- export { parseKnownNumbers, chunkArray, splitBigLinesWithSpaces } from './stringUtils';
9
- export { parseArtifactFromJson } from './parseArtifact';
10
- export { decodeBase64, encodeBase64, decodeUriFromPython, isBase64Encoded } from './jsonDetector';
11
- export { isUriEncoded, decodeUri, encodeUri, isValidUri, parseUriParams } from './uriUtils';
6
+ export { extractLinkAction } from './urlParser';
7
+ export { chunkArray, splitBigLinesWithSpaces } from './stringUtils';
12
8
  export { startsWithInteractionId, extractInteractionId, isValidInteractionId, } from './interactionIdChecker';
13
9
  export { setEbiContextSessionId, setEbiContextData } from './sessionWindowParameters';
14
10
  export { default as materialIcons, getIconByName, searchIcons, iconCategories, } from './materialIconsList';
@@ -1,4 +1,3 @@
1
- export declare const parseAndValidateArtifactUrl: (url: string) => string | null;
2
1
  export type LinkAction = 'Export' | 'Question' | 'OpenDashboard' | 'URL';
3
2
  export declare const extractLinkAction: (link: string, sessionId: string, content: string | null) => {
4
3
  action: LinkAction;
@@ -0,0 +1,51 @@
1
+ /** One fake socket instance — one `new WebSocket(url)` in the code under test. */
2
+ export declare class FakeRawWebSocket {
3
+ static readonly CONNECTING = 0;
4
+ static readonly OPEN = 1;
5
+ static readonly CLOSING = 2;
6
+ static readonly CLOSED = 3;
7
+ readonly url: string;
8
+ readyState: number;
9
+ /** Every frame the production code sent through this socket, parsed. */
10
+ readonly sent: any[];
11
+ /** `close(code, reason)` calls made BY the production code (not server-driven). */
12
+ readonly closedByClient: {
13
+ code?: number;
14
+ reason?: string;
15
+ }[];
16
+ onopen: ((event?: unknown) => void) | null;
17
+ onmessage: ((event: {
18
+ data: string;
19
+ }) => void) | null;
20
+ onerror: ((event?: unknown) => void) | null;
21
+ onclose: ((event: {
22
+ code: number;
23
+ reason: string;
24
+ }) => void) | null;
25
+ constructor(url: string);
26
+ send(data: string): void;
27
+ close(code?: number, reason?: string): void;
28
+ /** Complete the handshake. */
29
+ open(): void;
30
+ /** Deliver a raw frame (a JSON string, as the wire does). */
31
+ message(data: unknown): void;
32
+ /** The SERVER (or the network) closed us — the path that decides reconnect vs handoff. */
33
+ serverClose(code: number, reason?: string): void;
34
+ error(): void;
35
+ /** The query value the dial carried, or undefined when absent. */
36
+ param(name: string): string | undefined;
37
+ }
38
+ export interface FakeWebSocketHandle {
39
+ /** Every socket constructed since install, in order. */
40
+ readonly instances: FakeRawWebSocket[];
41
+ /** The most recently constructed socket — what the code under test is holding. */
42
+ readonly last: FakeRawWebSocket;
43
+ /** Dial URLs in order, handy for asserting a whole reconnect sequence at once. */
44
+ readonly urls: string[];
45
+ restore(): void;
46
+ }
47
+ /**
48
+ * Replace `globalThis.WebSocket` with the fake for the duration of a test.
49
+ * Returns a handle over every socket the code under test constructs.
50
+ */
51
+ export declare function installFakeWebSocket(): FakeWebSocketHandle;
@@ -0,0 +1,7 @@
1
+ import { IStorageService } from '../../src/services/storageService';
2
+ import { Prompt } from '../../src/models/Prompt';
3
+ export interface FakeStorage extends IStorageService {
4
+ /** Everything `storePrompt` received, oldest first. */
5
+ readonly stored: Prompt[];
6
+ }
7
+ export declare function fakeStorageService(): FakeStorage;