@aintela/chat 0.4.37 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components.js +7075 -7049
- package/dist/components.js.map +1 -1
- package/dist/hooks.js +1 -1
- package/dist/httpArtifactService-EEhF_mp9.js +1744 -0
- package/dist/httpArtifactService-EEhF_mp9.js.map +1 -0
- package/dist/{httpSessionService-CUujaUo6.js → httpSessionService-wBby4ggl.js} +51 -53
- package/dist/httpSessionService-wBby4ggl.js.map +1 -0
- package/dist/index.js +232 -227
- package/dist/models.js +1 -1
- package/dist/{serializer-DX-yGa_k.js → serializer-CC-nM3ig.js} +497 -498
- package/dist/serializer-CC-nM3ig.js.map +1 -0
- package/dist/services.js +12 -10
- package/dist/src/components/AiChat/ChatPane/CurrentMessage.d.ts +9 -9
- package/dist/src/components/AiChat/ChatPane/Message.d.ts +1 -3
- package/dist/src/components/AiChat/ChatPane/MessageAgent.d.ts +9 -8
- package/dist/src/components/AiChat/ChatPane/MessageScope.d.ts +32 -0
- package/dist/src/components/AiChat/ChatPane/MessageUser.d.ts +0 -1
- package/dist/src/components/AiChat/ChatPane/StickyQuestionHeader.d.ts +0 -1
- package/dist/src/components/AiChat/ChatPane/groupParts.d.ts +32 -0
- package/dist/src/components/AiChat/ChatPane/parts/ConnectionOutagePart.d.ts +9 -0
- package/dist/src/components/AiChat/ChatPane/parts/types.d.ts +6 -4
- package/dist/src/components/AiChat/ChatPane/reasoningHeadlines.d.ts +4 -9
- package/dist/src/components/AiChat/sessionStateManagerService.d.ts +36 -35
- package/dist/src/components/AiChat/stateConfiguration.d.ts +18 -0
- package/dist/src/components/index.d.ts +6 -2
- package/dist/src/interfaces/index.d.ts +0 -1
- package/dist/src/models/Interaction.d.ts +0 -9
- package/dist/src/models/InteractionPart.d.ts +4 -3
- package/dist/src/models/Notification.d.ts +7 -1
- package/dist/src/models/ServerEvent.d.ts +4 -0
- package/dist/src/models/index.d.ts +1 -1
- package/dist/src/services/WebSocketConnection/WebSocketConnectionV2.d.ts +28 -108
- package/dist/src/services/WebSocketConnection/closeCodes.d.ts +24 -0
- package/dist/src/services/WebSocketConnection/streamStats.d.ts +41 -0
- package/dist/src/services/WebSocketConnection/streamStats.test.d.ts +1 -0
- package/dist/src/services/WebSocketConnection/webSocketConnection.d.ts +15 -12
- package/dist/src/services/eventBusService.d.ts +28 -67
- package/dist/src/services/index.d.ts +2 -1
- package/dist/src/services/interaction/reduceInteraction.d.ts +28 -0
- package/dist/src/services/interactionService.d.ts +15 -32
- package/dist/src/services/interactionService.invariants.test.d.ts +1 -0
- package/dist/src/services/servers/AgentGatewayService.d.ts +3 -182
- package/dist/src/services/servers/AgentGatewayWSAsync.d.ts +145 -46
- package/dist/src/services/servers/connectionSupervisor.d.ts +173 -0
- package/dist/src/services/servers/connectionSupervisor.test.d.ts +1 -0
- package/dist/src/services/servers/connectionSupervisor.wire.test.d.ts +0 -0
- package/dist/src/services/servers/gatewayErrorClosesTurn.test.d.ts +1 -0
- package/dist/src/services/servers/gatewayFixes.test.d.ts +1 -0
- package/dist/src/services/servers/throttledEmit.test.d.ts +1 -0
- package/dist/src/services/servers/throttledEmitter.d.ts +38 -0
- package/dist/src/services/streamPipeline.characterization.test.d.ts +1 -0
- package/dist/src/services/wire/decodeFrame.d.ts +21 -0
- package/dist/src/services/wire/decodeFrame.test.d.ts +1 -0
- package/dist/tests/bench/streamPipeline.bench.d.ts +1 -0
- package/dist/tests/fakes/fakeRawWebSocket.d.ts +2 -0
- package/dist/tests/fakes/fakeWebSocket.d.ts +4 -3
- package/dist/tests/fakes/makeGateway.d.ts +7 -0
- package/dist/tests/wire/journey.d.ts +47 -0
- package/dist/{useChatSessions-BXYvvd4S.js → useChatSessions-C6sYF4U6.js} +2 -2
- package/dist/{useChatSessions-BXYvvd4S.js.map → useChatSessions-C6sYF4U6.js.map} +1 -1
- package/package.json +2 -1
- package/dist/httpArtifactService-GdGsaFKS.js +0 -1979
- package/dist/httpArtifactService-GdGsaFKS.js.map +0 -1
- package/dist/httpSessionService-CUujaUo6.js.map +0 -1
- package/dist/serializer-DX-yGa_k.js.map +0 -1
- package/dist/src/interfaces/IHeartbeatPort.d.ts +0 -4
- /package/dist/src/components/AiChat/{sessionStateManagerService.idle.test.d.ts → ChatPane/groupParts.test.d.ts} +0 -0
- /package/dist/src/{services/interactionServiceGrouping.test.d.ts → components/AiChat/ChatPane/parts/connectionOutagePart.test.d.ts} +0 -0
|
@@ -1,109 +1,79 @@
|
|
|
1
1
|
import { EndMessageData } from '../models/EndMessageData';
|
|
2
|
-
import {
|
|
3
|
-
import { ChatSession } from '../models/ChatSession';
|
|
4
|
-
import { Interaction, MergeResult } from '../models/Interaction';
|
|
2
|
+
import { Interaction } from '../models/Interaction';
|
|
5
3
|
import { FunctionDetails } from '../models/ServerEvent';
|
|
6
4
|
import { Artifact } from '../models/Artifact';
|
|
7
|
-
import { ConnectionState } from '../models/connectionState';
|
|
8
|
-
import { InteractionStatistics } from '../models/semanticKernelModel/models';
|
|
9
5
|
export interface FirstTokenEventDetails {
|
|
10
6
|
interactionId: string;
|
|
11
7
|
callId?: string;
|
|
12
8
|
}
|
|
13
9
|
export declare class EventTypes {
|
|
14
|
-
activityLost: string;
|
|
15
10
|
artifactGenerated: string;
|
|
16
11
|
artifactSelected: string;
|
|
17
|
-
artifactDeleted: string;
|
|
18
12
|
gatewayMessage: string;
|
|
19
13
|
gatewayTurnComplete: string;
|
|
20
14
|
gatewayStreamError: string;
|
|
15
|
+
gatewayConnected: string;
|
|
21
16
|
gatewayTurnOpen: string;
|
|
22
|
-
sessionCreated: string;
|
|
23
|
-
sessionUpdated: string;
|
|
24
17
|
gatewayFunctionResponse: string;
|
|
25
|
-
uiUnsavedPopoverToggle: string;
|
|
26
18
|
uiAskQuestion: string;
|
|
27
|
-
artifactsStorageUpdated: string;
|
|
28
|
-
gatewayStreamEnded: string;
|
|
29
|
-
streamNewChunk: string;
|
|
30
19
|
gatewayEndMessageData: string;
|
|
31
|
-
connectionStateChange: string;
|
|
32
20
|
onMessageSent: string;
|
|
33
21
|
onMessageError: string;
|
|
34
22
|
onToolEvent: string;
|
|
35
23
|
gatewayFirstToken: string;
|
|
36
24
|
}
|
|
37
25
|
export declare const allEventTypes: EventTypes;
|
|
26
|
+
type Listener = (...args: any) => Promise<void>;
|
|
38
27
|
export declare class EventBusService {
|
|
39
28
|
protected listeners: {
|
|
40
|
-
[methodName: string]:
|
|
41
|
-
};
|
|
42
|
-
protected listenersCount: {
|
|
43
|
-
[methodName: string]: number;
|
|
29
|
+
[methodName: string]: Listener[];
|
|
44
30
|
};
|
|
45
31
|
protected callListeners(eventName: string, ...args: any[]): void;
|
|
46
|
-
protected addListener(eventName: string, listener:
|
|
47
|
-
|
|
48
|
-
activityOnLost(listener: (...args: any) => Promise<void>): void;
|
|
49
|
-
activityEmitLost(): void;
|
|
32
|
+
protected addListener(eventName: string, listener: Listener): void;
|
|
33
|
+
protected removeListener(eventName: string, listener: Listener): void;
|
|
50
34
|
artifactOnGenerated(listener: (artifact: Artifact) => Promise<void>): void;
|
|
51
35
|
artifactEmitGenerated(artifact: Artifact): void;
|
|
52
36
|
artifactOffGenerated(listener: (artifact: Artifact) => Promise<void>): void;
|
|
53
37
|
artifactOnSelected(listener: (artifact: Artifact | string) => Promise<void>): void;
|
|
54
38
|
artifactEmitSelected(artifact: Artifact | string): void;
|
|
55
39
|
artifactOffSelected(listener: (artifact: Artifact | string) => Promise<void>): void;
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
gatewayOnMessage(listener: (interaction: Interaction, messageDetails: MergeResult | null) => Promise<void>): void;
|
|
40
|
+
gatewayOnMessage(listener: (interaction: Interaction) => Promise<void>): void;
|
|
41
|
+
gatewayEmitMessage(agentInteraction: Interaction): void;
|
|
42
|
+
gatewayOffMessage(listener: (interaction: Interaction) => Promise<void>): void;
|
|
60
43
|
gatewayOnTurnComplete(listener: (interactionId: string, interaction: Interaction) => Promise<void>): void;
|
|
61
|
-
gatewayOnTurnOpen(listener: (interactionId: string) => Promise<void>): void;
|
|
62
|
-
gatewayOnStreamError(listener: (...args: any[]) => Promise<void>): void;
|
|
63
|
-
gatewayOnStreamEnded(listener: (...args: any[]) => Promise<void>): void;
|
|
64
|
-
gatewayOffStreamEnded(listener: (...args: any[]) => Promise<void>): void;
|
|
65
|
-
gatewayEmitStreamEnded(interactionId: string, interaction: Interaction): void;
|
|
66
|
-
gatewayEmitMessage(agentInteraction: Interaction, messageDetails?: MergeResult | null): void;
|
|
67
44
|
gatewayEmitTurnComplete(interactionId: string, agentInteraction: Interaction): void;
|
|
68
|
-
gatewayEmitStreamError(errorMessage: string): void;
|
|
69
|
-
gatewayEmitTurnOpen(interactionId: string): void;
|
|
70
|
-
gatewayOffMessage(listener: (interaction: Interaction, messageDetails: MergeResult | null) => Promise<void>): void;
|
|
71
45
|
gatewayOffTurnComplete(listener: (interactionId: string, interaction: Interaction) => Promise<void>): void;
|
|
46
|
+
gatewayOnTurnOpen(listener: (interactionId: string) => Promise<void>): void;
|
|
47
|
+
gatewayEmitTurnOpen(interactionId: string): void;
|
|
72
48
|
gatewayOffTurnOpen(listener: (interactionId: string) => Promise<void>): void;
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
49
|
+
gatewayOnStreamError(listener: (errorMessage: string) => Promise<void>): void;
|
|
50
|
+
gatewayEmitStreamError(errorMessage: string): void;
|
|
51
|
+
gatewayOffStreamError(listener: (errorMessage: string) => Promise<void>): void;
|
|
52
|
+
/** The live socket is up and the session proven — on the first open and on every reconnect (`info.reconnect`). */
|
|
53
|
+
gatewayOnConnected(listener: (sessionId: string, info: {
|
|
54
|
+
reconnect: boolean;
|
|
55
|
+
}) => Promise<void>): void;
|
|
56
|
+
gatewayEmitConnected(sessionId: string, info: {
|
|
57
|
+
reconnect: boolean;
|
|
58
|
+
}): void;
|
|
59
|
+
gatewayOffConnected(listener: (sessionId: string, info: {
|
|
60
|
+
reconnect: boolean;
|
|
61
|
+
}) => Promise<void>): void;
|
|
62
|
+
chatOnMessageSent(listener: (message: string, interaction: Interaction) => Promise<void>): void;
|
|
76
63
|
chatOffMessageSent(listener: (...args: any[]) => Promise<void>): void;
|
|
77
64
|
ChatEmitMessageSent(message: string, interaction: Interaction): void;
|
|
78
65
|
chatOnMessageError(listener: (error: string) => Promise<void>): void;
|
|
79
66
|
chatOffMessageError(listener: (...args: any[]) => Promise<void>): void;
|
|
80
67
|
ChatEmitMessageError(error: string): void;
|
|
81
|
-
|
|
82
|
-
sessionEmitCreated(session: ChatSession): void;
|
|
83
|
-
sessionEmitUpdated(session: ChatSession): void;
|
|
84
|
-
sessionOffCreated(listener: (...args: any[]) => Promise<void>): void;
|
|
85
|
-
sessionOffUpdated(listener: (...args: any[]) => Promise<void>): void;
|
|
68
|
+
gatewayOnFunctionResponse(listener: (functionDetails: FunctionDetails) => Promise<void>): void;
|
|
86
69
|
gatewayEmitFunctionResponse(functionDetails: FunctionDetails): void;
|
|
87
|
-
gatewayOffFunctionResponse(listener: (
|
|
88
|
-
gatewayOnFunctionResponse(listener: (...args: any[]) => Promise<void>): void;
|
|
89
|
-
uiOnUnsavedPopoverToggle(listener: (anchorEl: HTMLElement | null) => Promise<void>): void;
|
|
90
|
-
uiEmitUnsavedPopoverToggle(anchorEl: HTMLElement | null): void;
|
|
91
|
-
uiOffUnsavedPopoverToggle(listener: (anchorEl: HTMLElement | null) => Promise<void>): void;
|
|
70
|
+
gatewayOffFunctionResponse(listener: (functionDetails: FunctionDetails) => Promise<void>): void;
|
|
92
71
|
uiOnAskQuestion(listener: (question: string) => Promise<void>): void;
|
|
93
72
|
uiEmitAskQuestion(question: string): void;
|
|
94
73
|
uiOffAskQuestion(listener: (question: string) => Promise<void>): void;
|
|
95
|
-
artifactsOnStorageUpdated(listener: () => Promise<void>): void;
|
|
96
|
-
artifactsEmitStorageUpdated(): void;
|
|
97
|
-
artifactsOffStorageUpdated(listener: () => Promise<void>): void;
|
|
98
|
-
streamOnNewChunk(listener: (stats: InteractionStatistics) => Promise<void>): void;
|
|
99
|
-
streamEmitNewChunk(stats: InteractionStatistics): void;
|
|
100
|
-
streamOffNewChunk(listener: (stats: InteractionStatistics) => Promise<void>): void;
|
|
101
74
|
gatewayOnEndMessageData(listener: (data: EndMessageData) => Promise<void>): void;
|
|
102
75
|
gatewayEmitEndMessageData(data: EndMessageData): void;
|
|
103
76
|
gatewayOffEndMessageData(listener: (data: EndMessageData) => Promise<void>): void;
|
|
104
|
-
gatewayOnConnectionStateChange(listener: (state: ConnectionState) => Promise<void>): void;
|
|
105
|
-
gatewayEmitConnectionStateChange(state: ConnectionState): void;
|
|
106
|
-
gatewayOffConnectionStateChange(listener: (state: ConnectionState) => Promise<void>): void;
|
|
107
77
|
gatewayOnToolEvent(listener: (eventName: string, eventData: string, sessionId?: string) => Promise<void>): void;
|
|
108
78
|
gatewayEmitToolEvent(eventName: string, eventData: string, sessionId?: string): void;
|
|
109
79
|
gatewayOffToolEvent(listener: (eventName: string, eventData: string, sessionId?: string) => Promise<void>): void;
|
|
@@ -111,13 +81,4 @@ export declare class EventBusService {
|
|
|
111
81
|
gatewayEmitFirstToken(details: FirstTokenEventDetails): void;
|
|
112
82
|
gatewayOffFirstToken(listener: (details: FirstTokenEventDetails) => Promise<void>): void;
|
|
113
83
|
}
|
|
114
|
-
export
|
|
115
|
-
constructor();
|
|
116
|
-
gatewayEmitConnectionStateChange(_state: ConnectionState): void;
|
|
117
|
-
gatewayEmitMessage(agentInteraction: Interaction, _messageDetails?: MergeResult): void;
|
|
118
|
-
gatewayEmitTurnComplete(_interactionId: string, _agentInteraction: Interaction): void;
|
|
119
|
-
gatewayEmitTurnOpen(_interactionId: string): void;
|
|
120
|
-
gatewayEmitFunctionResponse(_functionDetails: FunctionDetails): void;
|
|
121
|
-
gatewayOnFunctionResponse(listener: (...args: any[]) => Promise<void>): void;
|
|
122
|
-
gatewayOffFunctionResponse(listener: (...args: any[]) => Promise<void>): void;
|
|
123
|
-
}
|
|
84
|
+
export {};
|
|
@@ -10,7 +10,8 @@ export { AgentGatewayWSAsync } from './servers/AgentGatewayWSAsync';
|
|
|
10
10
|
export { WebSocketConnecionV2 } from './WebSocketConnection/WebSocketConnectionV2';
|
|
11
11
|
export type { IWebSocketConnection, IMessage } from './WebSocketConnection/webSocketConnection';
|
|
12
12
|
export { ArtifactHtmlHandler } from './artifactHtmlHandler';
|
|
13
|
-
export { InteractionService } from './interactionService';
|
|
13
|
+
export { InteractionService, reduceInteraction, MAX_CHAR_PER_TEXT_PART } from './interactionService';
|
|
14
|
+
export type { ReduceEffects } from './interactionService';
|
|
14
15
|
export { decodeSessionEvents } from './sessionEventDecoder';
|
|
15
16
|
export { HttpSessionService } from './httpSessionService';
|
|
16
17
|
export { HttpArtifactService } from './httpArtifactService';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Interaction } from '../../models/Interaction';
|
|
2
|
+
import { FunctionDetails, ServerEvent } from '../../models/ServerEvent';
|
|
3
|
+
/**
|
|
4
|
+
* The cap on one text / thought part. The markdown renderer re-parses the LIVE
|
|
5
|
+
* part's whole text on every tick, so the cost per tick is proportional to this,
|
|
6
|
+
* not to the answer's length. A settled part is never re-parsed: it keeps its
|
|
7
|
+
* object identity across reductions (see `appendText`), so `MessagePart`'s memo
|
|
8
|
+
* holds for it.
|
|
9
|
+
*
|
|
10
|
+
* Soft: the check runs BEFORE a delta is appended, so a part ends up in
|
|
11
|
+
* (cap, cap + one delta]. Since SDK v0.18 the server coalesces deltas into
|
|
12
|
+
* ~50 ms / 4096-char frames, so a single delta can be larger than the cap.
|
|
13
|
+
*/
|
|
14
|
+
export declare const MAX_CHAR_PER_TEXT_PART = 2000;
|
|
15
|
+
export interface ReduceEffects {
|
|
16
|
+
/** Called once per reduction that settles a tool RESULT onto its call (the fold). */
|
|
17
|
+
onFunctionResponse?: (functionDetails: FunctionDetails) => void;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The next interaction after one server event. Pure with respect to `prev`: no
|
|
21
|
+
* part or array on the prior tree is mutated, and every part the event did not
|
|
22
|
+
* touch keeps its object identity in the result.
|
|
23
|
+
*
|
|
24
|
+
* Steps, in order: flatten the event to one part; decide push-or-append; fold a
|
|
25
|
+
* parked prefill, fold a known call, or open a new part; append text to the live
|
|
26
|
+
* tail; merge artifacts; assemble.
|
|
27
|
+
*/
|
|
28
|
+
export declare function reduceInteraction(prev: Interaction, serverEvent: ServerEvent, effects?: ReduceEffects): Interaction;
|
|
@@ -1,39 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { InteractionPart } from '../models/InteractionPart';
|
|
1
|
+
import { Interaction } from '../models/Interaction';
|
|
3
2
|
import { ServerEvent } from '../models/ServerEvent';
|
|
4
|
-
import { EventType } from '../models/enums';
|
|
5
3
|
import { EventBusService } from './eventBusService';
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
hasThoughts: boolean;
|
|
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;
|
|
27
|
-
type: InteractionPartGroupType;
|
|
28
|
-
}
|
|
4
|
+
export { MAX_CHAR_PER_TEXT_PART, reduceInteraction } from './interaction/reduceInteraction';
|
|
5
|
+
export type { ReduceEffects } from './interaction/reduceInteraction';
|
|
6
|
+
/**
|
|
7
|
+
* The stateful face of {@link reduceInteraction}: holds the current tree for one
|
|
8
|
+
* interaction and swaps it atomically after each event. Hosts drive the merge
|
|
9
|
+
* through this (obtapp's part-stability tests do), so the constructor and
|
|
10
|
+
* `merge` are a published contract; the logic lives in the reducer.
|
|
11
|
+
*/
|
|
29
12
|
export declare class InteractionService {
|
|
30
13
|
interaction: Interaction;
|
|
31
14
|
eventBusService: EventBusService;
|
|
32
15
|
constructor(interaction: Interaction, eventBusService: EventBusService);
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
merge(serverEvent: ServerEvent):
|
|
16
|
+
/**
|
|
17
|
+
* Computes the next interaction from a server event and makes it current.
|
|
18
|
+
* Pure with respect to the previous tree: snapshots already handed out to
|
|
19
|
+
* throttled subscribers cannot diverge from live state.
|
|
20
|
+
*/
|
|
21
|
+
merge(serverEvent: ServerEvent): Interaction;
|
|
39
22
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,182 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { ClientMessage } from '../../models/ClientMessage';
|
|
5
|
-
import { Interaction, MergeResult } from '../../models/Interaction';
|
|
6
|
-
import { EventBusService, FirstTokenEventDetails } from '../eventBusService';
|
|
7
|
-
import { InteractionService } from '../interactionService';
|
|
8
|
-
import { RunMode } from '../../models/enums';
|
|
9
|
-
import { InteractionPart } from '../../models/InteractionPart';
|
|
10
|
-
import { StartStreamResponse, SendMessageResponse } from '../../models/SendMessageResponse';
|
|
11
|
-
import { IArtifactService } from '../interfaces/artifactService';
|
|
12
|
-
import { Artifact } from '../../models/Artifact';
|
|
13
|
-
import { AiChatState, AiChatStore } from '../../components/AiChat/stateConfiguration';
|
|
14
|
-
import { INotificationPort } from '../../interfaces/INotificationPort';
|
|
15
|
-
import { EndMessageData } from '../../models/EndMessageData';
|
|
16
|
-
import { IStorageService } from '../storageService';
|
|
17
|
-
export interface GatewaySendMessageOptions {
|
|
18
|
-
callId?: string;
|
|
19
|
-
}
|
|
20
|
-
export declare abstract class AgentGatewayService {
|
|
21
|
-
base_production_url: string;
|
|
22
|
-
base_url_local: string;
|
|
23
|
-
base_url: string;
|
|
24
|
-
isLocal: boolean;
|
|
25
|
-
msg_order: number;
|
|
26
|
-
static SUSPENSION_MSG: string;
|
|
27
|
-
protected lastPing: Date;
|
|
28
|
-
protected interactionsMap: Map<string, Interaction>;
|
|
29
|
-
protected interactionsServiceMap: Map<string, InteractionService>;
|
|
30
|
-
protected user: User;
|
|
31
|
-
protected config: AgentContext;
|
|
32
|
-
protected currentIS: InteractionService | null;
|
|
33
|
-
protected server_session_id?: string | null;
|
|
34
|
-
protected model_session_id?: string | null;
|
|
35
|
-
protected runMode: RunMode;
|
|
36
|
-
protected sessionState: AiChatState;
|
|
37
|
-
protected storageService: IStorageService;
|
|
38
|
-
protected notificationPort: INotificationPort;
|
|
39
|
-
protected interactionCallIds: Map<string, string>;
|
|
40
|
-
protected rawJwt: string;
|
|
41
|
-
protected sessionId?: string;
|
|
42
|
-
isInited: boolean;
|
|
43
|
-
eventBusService: EventBusService;
|
|
44
|
-
artifactService: IArtifactService;
|
|
45
|
-
onTurnOpen: (listener: (...args: any[]) => Promise<void>) => void;
|
|
46
|
-
offTurnOpen: (listener: (...args: any[]) => Promise<void>) => void;
|
|
47
|
-
onTurnComplete: (listener: (...args: any[]) => Promise<void>) => void;
|
|
48
|
-
offTurnComplete: (listener: (...args: any[]) => Promise<void>) => void;
|
|
49
|
-
onStreamError: (listener: (...args: any[]) => Promise<void>) => void;
|
|
50
|
-
offStreamError: (listener: (...args: any[]) => Promise<void>) => void;
|
|
51
|
-
onStreamEnded: (listener: (...args: any[]) => Promise<void>) => void;
|
|
52
|
-
offStreamEnded: (listener: (...args: any[]) => Promise<void>) => void;
|
|
53
|
-
onMessage: (listener: (...args: any[]) => Promise<void>) => void;
|
|
54
|
-
offMessage: (listener: (...args: any[]) => Promise<void>) => void;
|
|
55
|
-
onFirstToken: (listener: (details: FirstTokenEventDetails) => Promise<void>) => void;
|
|
56
|
-
offFirstToken: (listener: (details: FirstTokenEventDetails) => Promise<void>) => void;
|
|
57
|
-
onEndMessageData(listener: (data: EndMessageData) => Promise<void>): void;
|
|
58
|
-
offEndMessageData(listener: (data: EndMessageData) => Promise<void>): void;
|
|
59
|
-
onFunctionResponse: (listener: (...args: any[]) => Promise<void>) => void;
|
|
60
|
-
offFunctionResponse: (listener: (...args: any[]) => Promise<void>) => void;
|
|
61
|
-
toolSessionId: string | null;
|
|
62
|
-
/**
|
|
63
|
-
* Send the user's answer to a parked `ask_user` tool call back to the agent.
|
|
64
|
-
* Default no-op; the WebSocket gateway (AgentGatewayWSAsync) overrides it to emit
|
|
65
|
-
* a ChatAction.AnswerHumanTool frame. Returns 'sent' when it went out immediately,
|
|
66
|
-
* 'queued' when the socket was down and the answer will flush on reconnect.
|
|
67
|
-
*/
|
|
68
|
-
answerHumanTool(toolCallId: string, answer: string): 'sent' | 'queued';
|
|
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
|
-
*/
|
|
76
|
-
getAgentContext(): AgentContext;
|
|
77
|
-
getModel(): string | undefined;
|
|
78
|
-
setModel(modelId: string): void;
|
|
79
|
-
/**
|
|
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.
|
|
93
|
-
*
|
|
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.
|
|
98
|
-
*/
|
|
99
|
-
forceAgentContext(config: AgentContext): void;
|
|
100
|
-
getSessionId(): string | undefined;
|
|
101
|
-
getErrorEvent(errorMessage: string): {
|
|
102
|
-
interaction_id: string | null;
|
|
103
|
-
model_session_id: string;
|
|
104
|
-
mime_type: string;
|
|
105
|
-
partial: boolean;
|
|
106
|
-
serverError: string;
|
|
107
|
-
};
|
|
108
|
-
setSession(sessionId: string, toolSessionId: string): void;
|
|
109
|
-
startInteraction(interactionQuestion: string, wasSuspended?: boolean | undefined, idOverrideForTests?: string): Interaction;
|
|
110
|
-
getInteractions(): Interaction[];
|
|
111
|
-
getRecentInteractions(filterMs?: number): Interaction[];
|
|
112
|
-
protected updateMap(serverEvent: ServerEvent): MergeResult | undefined;
|
|
113
|
-
getCurrentInteractionId(): string | null;
|
|
114
|
-
getCurrentInteraction(): Interaction | null;
|
|
115
|
-
getInteraction(interactionId: string): Interaction | undefined;
|
|
116
|
-
hasState(): boolean;
|
|
117
|
-
protected buildAgentParams(): string;
|
|
118
|
-
abstract finalResponse(interactionId: string, agentInteraction: Interaction, author: string, subAgentId?: string): void;
|
|
119
|
-
/**
|
|
120
|
-
* Open the live connection. `options.resume` asks the transport to keep its replay cursor,
|
|
121
|
-
* so the server sends back whatever was emitted while we were disconnected — see
|
|
122
|
-
* WebSocketConnectionV2.connect.
|
|
123
|
-
*/
|
|
124
|
-
openConnection(sessionId?: string, options?: {
|
|
125
|
-
resume?: boolean;
|
|
126
|
-
}): Promise<string>;
|
|
127
|
-
abstract closeConnection(closeTurn: boolean): Promise<SendMessageResponse | null>;
|
|
128
|
-
protected Error(errorMessage?: string | undefined): Promise<void>;
|
|
129
|
-
private pendingCurrentMessage;
|
|
130
|
-
private lastCurrentMessageUpdate;
|
|
131
|
-
private static readonly CURRENT_MSG_THROTTLE_MS;
|
|
132
|
-
hasServerSessionId(): boolean;
|
|
133
|
-
runningRequests: Map<string, Promise<Artifact | null>>;
|
|
134
|
-
asyncLoadArtifact(artifactId: string): Promise<Artifact | null>;
|
|
135
|
-
protected processComands(serverEvent: ServerEvent): boolean;
|
|
136
|
-
lastToolInteraction: string;
|
|
137
|
-
protected subAgentInteractions: Map<string, Interaction>;
|
|
138
|
-
protected subAgentInteractionServices: Map<string, InteractionService>;
|
|
139
|
-
protected getOrCreateSubAgentInteraction(subAgentId: string, interactionId: string, subAgentName?: string): {
|
|
140
|
-
interaction: Interaction;
|
|
141
|
-
service: InteractionService;
|
|
142
|
-
};
|
|
143
|
-
protected handleSubAgentEvent(serverEvent: ServerEvent): void;
|
|
144
|
-
Message(event: MessageEvent | ServerEvent): Promise<void>;
|
|
145
|
-
hasOneCompleteInteraction(): boolean;
|
|
146
|
-
protected localEmitToolEvent(toolDetails: ToolEventDetails): void;
|
|
147
|
-
protected registerInteractionCallId(interactionId: string, options?: GatewaySendMessageOptions): void;
|
|
148
|
-
protected localEmitFirstToken(interactionId: string): void;
|
|
149
|
-
private lastThorttledTimeout;
|
|
150
|
-
private doEmitMessage;
|
|
151
|
-
protected localEmitMessage(message: Interaction, mergeResult?: MergeResult): void;
|
|
152
|
-
protected localOpen(interactionId: string, _author: string): void;
|
|
153
|
-
/**
|
|
154
|
-
* Drop any throttled `currentMessage` emit still queued by
|
|
155
|
-
* `localEmitMessage`. The throttle's trailing edge is a `setTimeout` that
|
|
156
|
-
* calls `setCurrentMessage(...)`; if it fires *after* the turn has been
|
|
157
|
-
* committed (`setNewMessage` moved the interaction into `messages` and
|
|
158
|
-
* nulled `currentMessage`), it re-publishes the now-committed interaction
|
|
159
|
-
* as the live message — so the chat renders the turn twice: once in
|
|
160
|
-
* history (`MessageAgent` with `onGoing=false`, which drops Thought parts)
|
|
161
|
-
* and once as the live `currentMessage` (`onGoing=true`, which keeps them).
|
|
162
|
-
* That is the duplicated-bubble bug (the two copies even look different —
|
|
163
|
-
* only the live one shows the "thought" strip). Call this on turn commit.
|
|
164
|
-
*/
|
|
165
|
-
private cancelPendingCurrentMessage;
|
|
166
|
-
protected turnComplete(interactionId: string, agentInteraction: Interaction, _author: string, subAgentId?: string): Promise<void>;
|
|
167
|
-
protected lastPingStatus: boolean;
|
|
168
|
-
protected handlePing(): Promise<boolean>;
|
|
169
|
-
sendMessage(message: ClientMessage, options?: GatewaySendMessageOptions): Promise<SendMessageResponse>;
|
|
170
|
-
abstract startStream(sendStartMessage?: boolean): Promise<StartStreamResponse>;
|
|
171
|
-
abstract stopStream(): void;
|
|
172
|
-
abstract sendMessageInternal(message: ClientMessage, options?: GatewaySendMessageOptions): Promise<SendMessageResponse>;
|
|
173
|
-
abstract isSuspended(): boolean;
|
|
174
|
-
abstract suspend(): Promise<boolean>;
|
|
175
|
-
check(): Promise<boolean>;
|
|
176
|
-
startAndForget(): void;
|
|
177
|
-
forceReceiveMessage(serverEvent: ServerEvent): void;
|
|
178
|
-
sendStatusMessage(question: string, parts: InteractionPart[], interactionId: string): void;
|
|
179
|
-
clearStatus(): void;
|
|
180
|
-
ping(): Promise<boolean>;
|
|
181
|
-
protected getNewInteractionId(): string;
|
|
182
|
-
}
|
|
1
|
+
export { AgentGatewayWSAsync as AgentGatewayService } from './AgentGatewayWSAsync';
|
|
2
|
+
export type { GatewaySendMessageOptions } from './AgentGatewayWSAsync';
|
|
3
|
+
export type { OpenOptions as GatewayOpenOptions, HaltReason } from './connectionSupervisor';
|