@aintela/chat 0.4.6 → 0.4.8
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/{atMentions-DrCm42jN.js → atMentions-BlzXxKB9.js} +22 -22
- package/dist/{atMentions-DrCm42jN.js.map → atMentions-BlzXxKB9.js.map} +1 -1
- package/dist/components.js +2108 -2094
- package/dist/components.js.map +1 -1
- package/dist/{httpArtifactService-CqEs3x-Q.js → httpArtifactService-CO7Kl4xr.js} +418 -335
- package/dist/httpArtifactService-CO7Kl4xr.js.map +1 -0
- package/dist/index.js +2 -2
- package/dist/services.js +1 -1
- package/dist/src/components/AiChat/sessionStateManagerService.d.ts +6 -0
- package/dist/src/services/WebSocketConnection/WebSocketConnectionV2.d.ts +33 -3
- package/dist/src/services/servers/AgentGatewayWSAsync.d.ts +16 -0
- package/dist/src/services/servers/agentGatewayWSAsync.reconnect.test.d.ts +1 -0
- package/dist/src/utils/atMentions.d.ts +9 -1
- package/dist/tests/fakes/fakeWebSocket.d.ts +16 -1
- package/dist/utils.js +1 -1
- package/package.json +1 -1
- package/dist/httpArtifactService-CqEs3x-Q.js.map +0 -1
|
@@ -11,6 +11,14 @@ export declare const APPLICATION_CLOSED_CODE = 4001;
|
|
|
11
11
|
* close to the consumer instead.
|
|
12
12
|
*/
|
|
13
13
|
export declare const SESSION_ALREADY_ATTACHED_CODE = 4002;
|
|
14
|
+
/**
|
|
15
|
+
* Client-local close code used when the heartbeat declares the peer dead. It never
|
|
16
|
+
* goes on the wire (there is nobody left to receive it); it reaches `onClose` so a
|
|
17
|
+
* consumer can tell a detected dead peer from a server-initiated close. Retryable:
|
|
18
|
+
* the inner loop resumes the session with its replay cursor when the channel was
|
|
19
|
+
* proven, otherwise the outer state manager takes over as for any other drop.
|
|
20
|
+
*/
|
|
21
|
+
export declare const HEARTBEAT_TIMEOUT_CODE = 4100;
|
|
14
22
|
export declare class WebSocketConnecionV2 implements IWebSocketConnection {
|
|
15
23
|
ws: WebSocket | null;
|
|
16
24
|
stats: InteractionStatistics;
|
|
@@ -66,7 +74,8 @@ export declare class WebSocketConnecionV2 implements IWebSocketConnection {
|
|
|
66
74
|
streamingResponseSerializer: TypedJSON<StreamingResponse>;
|
|
67
75
|
events: [number, number][];
|
|
68
76
|
lastActivity: number;
|
|
69
|
-
|
|
77
|
+
/** When the outstanding heartbeat Ping went out; null while no reply is pending. */
|
|
78
|
+
private pingSentAt;
|
|
70
79
|
firstTokenInteractions: Set<string>;
|
|
71
80
|
/** Last sessionId we successfully had — used to resume on reconnect. */
|
|
72
81
|
private lastKnownSessionId?;
|
|
@@ -129,13 +138,20 @@ export declare class WebSocketConnecionV2 implements IWebSocketConnection {
|
|
|
129
138
|
* - 1000 normal closure
|
|
130
139
|
* - 1008 policy violation (auth rejected)
|
|
131
140
|
* - 4001 our own intentional disconnect
|
|
132
|
-
* -
|
|
141
|
+
* - 4002 the session is attached elsewhere (another tab) — retrying just bounces
|
|
142
|
+
* Retried, on purpose:
|
|
143
|
+
* - 4003 the server's idle close ("reconnect on next interaction"): resuming is
|
|
144
|
+
* cheap and lossless, and while the user is present the outer loop would redial
|
|
145
|
+
* anyway; when they are gone the client's own idle timer closes first.
|
|
146
|
+
* - 4100 HEARTBEAT_TIMEOUT_CODE, our own dead-peer verdict.
|
|
133
147
|
*/
|
|
134
148
|
private shouldAttemptReconnect;
|
|
135
149
|
private cancelPendingReconnect;
|
|
136
150
|
private computeBackoffDelay;
|
|
137
151
|
private scheduleReconnect;
|
|
138
152
|
sleep(ms: number): Promise<unknown>;
|
|
153
|
+
/** The session this instance believes it is on — for log lines, never for logic. */
|
|
154
|
+
private get sessionLabel();
|
|
139
155
|
/**
|
|
140
156
|
* Handle incoming messages from server
|
|
141
157
|
*/
|
|
@@ -177,11 +193,25 @@ export declare class WebSocketConnecionV2 implements IWebSocketConnection {
|
|
|
177
193
|
sendMessage(message: IMessage): void;
|
|
178
194
|
sendBaseMessage(message: IMessageBase): void;
|
|
179
195
|
sendSuspendMessage(message: IMessage): void;
|
|
196
|
+
/**
|
|
197
|
+
* Heartbeat: keep a quiet socket alive with a Ping every PING_INTERVAL_MS, and
|
|
198
|
+
* declare it dead when a Ping goes PONG_TIMEOUT_MS without ANY inbound frame.
|
|
199
|
+
* Started by `onopen`, stopped by `onclose`/`disconnect()`.
|
|
200
|
+
*/
|
|
180
201
|
monitor(): void;
|
|
181
202
|
/**
|
|
182
|
-
* Send a heartbeat ping
|
|
203
|
+
* Send a heartbeat ping and start the reply clock (unless one is already running).
|
|
183
204
|
*/
|
|
184
205
|
ping(): void;
|
|
206
|
+
/**
|
|
207
|
+
* Declare the current socket dead and run the close path NOW, without waiting
|
|
208
|
+
* for the browser: for a half-open peer `onclose` can lag by minutes or never
|
|
209
|
+
* come, and the decision has already been made. The dead socket's own onclose
|
|
210
|
+
* handler is invoked with a client-local code, so the reconnect-vs-handoff
|
|
211
|
+
* logic that runs is exactly the one a server close would run. Handlers are
|
|
212
|
+
* detached first so a late real close event cannot run it a second time.
|
|
213
|
+
*/
|
|
214
|
+
private failSocket;
|
|
185
215
|
/**
|
|
186
216
|
* Disconnect the WebSocket
|
|
187
217
|
*/
|
|
@@ -55,5 +55,21 @@ export declare class AgentGatewayWSAsync extends AgentGatewayService {
|
|
|
55
55
|
simulateDisconnect(code?: number, reason?: string): void;
|
|
56
56
|
sleep(ms: number): Promise<unknown>;
|
|
57
57
|
streamOpened: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Make sure the socket is OPEN before a send, redialling the SAME session when it is not.
|
|
60
|
+
*
|
|
61
|
+
* The socket can be down at send time for reasons the composer cannot see: the client's own
|
|
62
|
+
* idle close (5 min without input), the server's (6 min without a message, code 4003), a dead
|
|
63
|
+
* peer the heartbeat just detected, or a dial still in flight. Until this existed the send
|
|
64
|
+
* threw `WebSocket is not connected` AFTER the user's turn was already on the transcript — or
|
|
65
|
+
* the composer refused it outright — and the only way back was the 2 s heartbeat noticing
|
|
66
|
+
* mouse movement. A send IS the activity that reconnect was waiting for, so dial here.
|
|
67
|
+
*
|
|
68
|
+
* `resume: true` keeps the replay cursor: if the socket died mid-turn the server replays what
|
|
69
|
+
* we missed. `openConnection` de-duplicates against a dial already in flight (the state
|
|
70
|
+
* manager's retry loop, a host's own bind), so concurrent callers share one socket. A
|
|
71
|
+
* transport without `isConnected` semantics (the demo's fake gateway) is treated as up.
|
|
72
|
+
*/
|
|
73
|
+
private ensureConnected;
|
|
58
74
|
sendMessageInternal(message: ClientMessage, options?: GatewaySendMessageOptions, _openTurn?: boolean): Promise<SendMessageResponse>;
|
|
59
75
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -12,6 +12,11 @@ export type AtQueryVertical = 'air' | 'hotel';
|
|
|
12
12
|
* fetcher) so hosts that don't care keep compiling untouched — a function with fewer params is assignable. */
|
|
13
13
|
export interface AtQueryContext {
|
|
14
14
|
vertical: AtQueryVertical;
|
|
15
|
+
/** The hotel-intent head's SCORE for the current text (0..1), not the thresholded verdict. `vertical` is that
|
|
16
|
+
* score already cut at the server's 0.35; a source that merges two result sets needs the number, because the
|
|
17
|
+
* cut is where "weakest place outranks strongest airport" flips on one hundredth of a point. Undefined only
|
|
18
|
+
* when the host predates this field. */
|
|
19
|
+
hotelConfidence?: number;
|
|
15
20
|
}
|
|
16
21
|
export interface AtMentionFetchers {
|
|
17
22
|
/** Location source (airports / cities — or hotel places when `context.vertical` says so, issue #876). */
|
|
@@ -29,6 +34,9 @@ export interface AtMentionOptions {
|
|
|
29
34
|
personFirstThreshold?: number;
|
|
30
35
|
/** The search vertical for the location source (issue #876). Default 'air' — today's behavior. */
|
|
31
36
|
vertical?: AtQueryVertical;
|
|
37
|
+
/** Hotel-intent confidence from the analyze pass, handed to the location source alongside `vertical` so it can
|
|
38
|
+
* order its own two result sets by a score rather than by a verdict someone else thresholded. Default 0. */
|
|
39
|
+
hotelConfidence?: number;
|
|
32
40
|
}
|
|
33
41
|
/**
|
|
34
42
|
* Fetch `@` mention items from whichever sources are wired, as one flat list. When BOTH a location and a person
|
|
@@ -38,6 +46,6 @@ export interface AtMentionOptions {
|
|
|
38
46
|
* A single wired source returns an untagged flat list (unchanged behaviour). Each source is awaited in parallel and
|
|
39
47
|
* failures are isolated: one source erroring never sinks the other.
|
|
40
48
|
*/
|
|
41
|
-
export declare function fetchAtMentions(query: string, { onAtQuery, onAtPersonQuery }: AtMentionFetchers, { personConfidence, locationConfidence, personFirstThreshold, vertical }?: AtMentionOptions): Promise<AtMentionItem[]>;
|
|
49
|
+
export declare function fetchAtMentions(query: string, { onAtQuery, onAtPersonQuery }: AtMentionFetchers, { personConfidence, locationConfidence, personFirstThreshold, vertical, hotelConfidence }?: AtMentionOptions): Promise<AtMentionItem[]>;
|
|
42
50
|
/** True when `items[idx]` opens a new `@` section (its group differs from the previous item's). */
|
|
43
51
|
export declare function isSectionStart(items: AtMentionItem[], idx: number): boolean;
|
|
@@ -15,13 +15,28 @@ export declare class FakeWebSocketConnection implements IWebSocketConnection {
|
|
|
15
15
|
onRewindLost?: never;
|
|
16
16
|
readonly recordedSends: IMessage[];
|
|
17
17
|
sessionIdToReturn: string;
|
|
18
|
+
/** Every `connect()` call — the id and options the gateway dialled with, in order. */
|
|
19
|
+
readonly connectCalls: {
|
|
20
|
+
sessionId?: string;
|
|
21
|
+
options?: {
|
|
22
|
+
resume?: boolean;
|
|
23
|
+
};
|
|
24
|
+
}[];
|
|
18
25
|
private connected;
|
|
19
|
-
connect(
|
|
26
|
+
connect(sessionId?: string, options?: {
|
|
27
|
+
resume?: boolean;
|
|
28
|
+
}): Promise<string>;
|
|
20
29
|
sendMessage(message: IMessage): void;
|
|
21
30
|
suspendStream(): void;
|
|
22
31
|
disconnect(): void;
|
|
23
32
|
closeStream(): void;
|
|
24
33
|
isConnected(): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* The peer went away and the socket knows it — what the real transport looks like after
|
|
36
|
+
* an idle close, or after the heartbeat's dead-peer verdict. No callback fires: the
|
|
37
|
+
* consumer has (or has not) already reacted; the point is what it does at the next send.
|
|
38
|
+
*/
|
|
39
|
+
drop(): void;
|
|
25
40
|
/**
|
|
26
41
|
* Drive an event through `onEvent` *and await it*. Use this when the
|
|
27
42
|
* next assertion depends on the merger having finished (the gateway's
|
package/dist/utils.js
CHANGED
|
@@ -2,7 +2,7 @@ var u = Object.defineProperty;
|
|
|
2
2
|
var a = (e, t) => u(e, "name", { value: t, configurable: !0 });
|
|
3
3
|
import { a as c, b as s } from "./environmentUtils-VZNTCzEE.js";
|
|
4
4
|
import { A as k, D as U, g as x, c as M, d as V, e as G, f as R, i as H, r as W } from "./environmentUtils-VZNTCzEE.js";
|
|
5
|
-
import { S as Y, a as Z, b as j, c as q, d as z, e as Q, f as $, g as J, h as X, i as ee, j as te, k as oe, l as ae, p as re, m as ie, s as ne, o as se, q as le, t as ce } from "./atMentions-
|
|
5
|
+
import { S as Y, a as Z, b as j, c as q, d as z, e as Q, f as $, g as J, h as X, i as ee, j as te, k as oe, l as ae, p as re, m as ie, s as ne, o as se, q as le, t as ce } from "./atMentions-BlzXxKB9.js";
|
|
6
6
|
const m = "https://agent.tripapi.com.br", p = "http://localagent:8000", S = /* @__PURE__ */ a((e) => new URLSearchParams(e.location.search).get("local") === "true" ? p : c() ?? m, "getAgentBaseUrl"), f = "https://storage.googleapis.com/aibi_artifacts_bucket", I = /* @__PURE__ */ a(() => f, "getArtifactsBaseUrl"), n = {}, h = (n == null ? void 0 : n.VITE_CADDY) == "true";
|
|
7
7
|
function w() {
|
|
8
8
|
const e = h ? "http://wsserver.localhost" : "http://localhost:8000";
|