@smooai/chat-widget 0.5.1 → 0.5.2
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/chat-widget.global.js +119 -69
- package/dist/chat-widget.global.js.map +1 -1
- package/dist/index.js +67 -35
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -49,6 +49,44 @@ var SmoothAgentChat = (function(exports) {
|
|
|
49
49
|
return !resolved.allowAnonymous && (resolved.requireName || resolved.requireEmail || resolved.requirePhone);
|
|
50
50
|
}
|
|
51
51
|
//#endregion
|
|
52
|
+
//#region \0@oxc-project+runtime@0.134.0/helpers/esm/typeof.js
|
|
53
|
+
function _typeof(o) {
|
|
54
|
+
"@babel/helpers - typeof";
|
|
55
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
56
|
+
return typeof o;
|
|
57
|
+
} : function(o) {
|
|
58
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
59
|
+
}, _typeof(o);
|
|
60
|
+
}
|
|
61
|
+
//#endregion
|
|
62
|
+
//#region \0@oxc-project+runtime@0.134.0/helpers/esm/toPrimitive.js
|
|
63
|
+
function toPrimitive(t, r) {
|
|
64
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
65
|
+
var e = t[Symbol.toPrimitive];
|
|
66
|
+
if (void 0 !== e) {
|
|
67
|
+
var i = e.call(t, r || "default");
|
|
68
|
+
if ("object" != _typeof(i)) return i;
|
|
69
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
70
|
+
}
|
|
71
|
+
return ("string" === r ? String : Number)(t);
|
|
72
|
+
}
|
|
73
|
+
//#endregion
|
|
74
|
+
//#region \0@oxc-project+runtime@0.134.0/helpers/esm/toPropertyKey.js
|
|
75
|
+
function toPropertyKey(t) {
|
|
76
|
+
var i = toPrimitive(t, "string");
|
|
77
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
78
|
+
}
|
|
79
|
+
//#endregion
|
|
80
|
+
//#region \0@oxc-project+runtime@0.134.0/helpers/esm/defineProperty.js
|
|
81
|
+
function _defineProperty(e, r, t) {
|
|
82
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
83
|
+
value: t,
|
|
84
|
+
enumerable: !0,
|
|
85
|
+
configurable: !0,
|
|
86
|
+
writable: !0
|
|
87
|
+
}) : e[r] = t, e;
|
|
88
|
+
}
|
|
89
|
+
//#endregion
|
|
52
90
|
//#region node_modules/.pnpm/@smooai+smooth-operator@1.8.0/node_modules/@smooai/smooth-operator/dist/transport.js
|
|
53
91
|
/**
|
|
54
92
|
* Transport abstraction for the client.
|
|
@@ -69,14 +107,14 @@ var SmoothAgentChat = (function(exports) {
|
|
|
69
107
|
* Node, or a mock in tests).
|
|
70
108
|
*/
|
|
71
109
|
var WebSocketTransport = class {
|
|
72
|
-
socket = null;
|
|
73
|
-
url;
|
|
74
|
-
factory;
|
|
75
|
-
connectTimeout;
|
|
76
|
-
messageHandlers = /* @__PURE__ */ new Set();
|
|
77
|
-
closeHandlers = /* @__PURE__ */ new Set();
|
|
78
|
-
errorHandlers = /* @__PURE__ */ new Set();
|
|
79
110
|
constructor(url, factory, connectTimeout = DEFAULT_CONNECT_TIMEOUT) {
|
|
111
|
+
_defineProperty(this, "socket", null);
|
|
112
|
+
_defineProperty(this, "url", void 0);
|
|
113
|
+
_defineProperty(this, "factory", void 0);
|
|
114
|
+
_defineProperty(this, "connectTimeout", void 0);
|
|
115
|
+
_defineProperty(this, "messageHandlers", /* @__PURE__ */ new Set());
|
|
116
|
+
_defineProperty(this, "closeHandlers", /* @__PURE__ */ new Set());
|
|
117
|
+
_defineProperty(this, "errorHandlers", /* @__PURE__ */ new Set());
|
|
80
118
|
this.url = url;
|
|
81
119
|
this.connectTimeout = connectTimeout;
|
|
82
120
|
if (factory) this.factory = factory;
|
|
@@ -215,6 +253,7 @@ var SmoothAgentChat = (function(exports) {
|
|
|
215
253
|
* - **No live server required.** Correctness is fully unit-testable with a mock
|
|
216
254
|
* transport (see `test/client.test.ts`).
|
|
217
255
|
*/
|
|
256
|
+
let _Symbol$asyncIterator;
|
|
218
257
|
/** A timeout that yields no terminal event. */
|
|
219
258
|
var RequestTimeoutError = class extends Error {
|
|
220
259
|
constructor(requestId, ms) {
|
|
@@ -228,24 +267,25 @@ var SmoothAgentChat = (function(exports) {
|
|
|
228
267
|
* and its async iteration throws it, so a stuck server can never hang the caller.
|
|
229
268
|
*/
|
|
230
269
|
var TurnTimeoutError = class extends Error {
|
|
231
|
-
requestId;
|
|
232
270
|
constructor(requestId, ms) {
|
|
233
271
|
super(`Turn ${requestId} timed out after ${ms}ms without a terminal response`);
|
|
272
|
+
_defineProperty(this, "requestId", void 0);
|
|
234
273
|
this.name = "TurnTimeoutError";
|
|
235
274
|
this.requestId = requestId;
|
|
236
275
|
}
|
|
237
276
|
};
|
|
238
277
|
/** A protocol-level error event surfaced as a throwable. */
|
|
239
278
|
var ProtocolError = class extends Error {
|
|
240
|
-
code;
|
|
241
|
-
requestId;
|
|
242
279
|
constructor(code, message, requestId) {
|
|
243
280
|
super(message);
|
|
281
|
+
_defineProperty(this, "code", void 0);
|
|
282
|
+
_defineProperty(this, "requestId", void 0);
|
|
244
283
|
this.name = "ProtocolError";
|
|
245
284
|
this.code = code;
|
|
246
285
|
this.requestId = requestId;
|
|
247
286
|
}
|
|
248
287
|
};
|
|
288
|
+
_Symbol$asyncIterator = Symbol.asyncIterator;
|
|
249
289
|
/**
|
|
250
290
|
* A streaming message turn. Await it for the terminal {@link EventualResponse},
|
|
251
291
|
* or async-iterate it to receive every intermediate event in arrival order.
|
|
@@ -259,19 +299,23 @@ var SmoothAgentChat = (function(exports) {
|
|
|
259
299
|
* ```
|
|
260
300
|
*/
|
|
261
301
|
var MessageTurn = class {
|
|
262
|
-
/** The requestId this turn is correlated on. */
|
|
263
|
-
requestId;
|
|
264
|
-
queue = [];
|
|
265
|
-
waiter = null;
|
|
266
|
-
done = false;
|
|
267
|
-
finalEvent = null;
|
|
268
|
-
error = null;
|
|
269
|
-
settled;
|
|
270
|
-
settle;
|
|
271
|
-
fail;
|
|
272
|
-
onClose;
|
|
273
|
-
timeoutTimer;
|
|
274
302
|
constructor(requestId, onClose, turnTimeout = 0) {
|
|
303
|
+
_defineProperty(
|
|
304
|
+
this,
|
|
305
|
+
/** The requestId this turn is correlated on. */
|
|
306
|
+
"requestId",
|
|
307
|
+
void 0
|
|
308
|
+
);
|
|
309
|
+
_defineProperty(this, "queue", []);
|
|
310
|
+
_defineProperty(this, "waiter", null);
|
|
311
|
+
_defineProperty(this, "done", false);
|
|
312
|
+
_defineProperty(this, "finalEvent", null);
|
|
313
|
+
_defineProperty(this, "error", null);
|
|
314
|
+
_defineProperty(this, "settled", void 0);
|
|
315
|
+
_defineProperty(this, "settle", void 0);
|
|
316
|
+
_defineProperty(this, "fail", void 0);
|
|
317
|
+
_defineProperty(this, "onClose", void 0);
|
|
318
|
+
_defineProperty(this, "timeoutTimer", void 0);
|
|
275
319
|
this.requestId = requestId;
|
|
276
320
|
this.onClose = onClose;
|
|
277
321
|
this.settled = new Promise((resolve, reject) => {
|
|
@@ -333,7 +377,7 @@ var SmoothAgentChat = (function(exports) {
|
|
|
333
377
|
});
|
|
334
378
|
}
|
|
335
379
|
}
|
|
336
|
-
[
|
|
380
|
+
[_Symbol$asyncIterator]() {
|
|
337
381
|
return { next: () => {
|
|
338
382
|
if (this.queue.length > 0) return Promise.resolve({
|
|
339
383
|
value: this.queue.shift(),
|
|
@@ -359,18 +403,30 @@ var SmoothAgentChat = (function(exports) {
|
|
|
359
403
|
}
|
|
360
404
|
};
|
|
361
405
|
var SmoothAgentClient = class {
|
|
362
|
-
transport;
|
|
363
|
-
generateRequestId;
|
|
364
|
-
requestTimeout;
|
|
365
|
-
turnTimeout;
|
|
366
|
-
/** requestId → single-response waiter (create_session, get_session, ping, …). */
|
|
367
|
-
pending = /* @__PURE__ */ new Map();
|
|
368
|
-
/** requestId → active streaming turn (send_message, and HITL resumes). */
|
|
369
|
-
turns = /* @__PURE__ */ new Map();
|
|
370
|
-
/** Unsolicited-event listeners (keepalive, server-push). */
|
|
371
|
-
listeners = /* @__PURE__ */ new Set();
|
|
372
|
-
unsubscribe = [];
|
|
373
406
|
constructor(options) {
|
|
407
|
+
_defineProperty(this, "transport", void 0);
|
|
408
|
+
_defineProperty(this, "generateRequestId", void 0);
|
|
409
|
+
_defineProperty(this, "requestTimeout", void 0);
|
|
410
|
+
_defineProperty(this, "turnTimeout", void 0);
|
|
411
|
+
_defineProperty(
|
|
412
|
+
this,
|
|
413
|
+
/** requestId → single-response waiter (create_session, get_session, ping, …). */
|
|
414
|
+
"pending",
|
|
415
|
+
/* @__PURE__ */ new Map()
|
|
416
|
+
);
|
|
417
|
+
_defineProperty(
|
|
418
|
+
this,
|
|
419
|
+
/** requestId → active streaming turn (send_message, and HITL resumes). */
|
|
420
|
+
"turns",
|
|
421
|
+
/* @__PURE__ */ new Map()
|
|
422
|
+
);
|
|
423
|
+
_defineProperty(
|
|
424
|
+
this,
|
|
425
|
+
/** Unsolicited-event listeners (keepalive, server-push). */
|
|
426
|
+
"listeners",
|
|
427
|
+
/* @__PURE__ */ new Set()
|
|
428
|
+
);
|
|
429
|
+
_defineProperty(this, "unsubscribe", []);
|
|
374
430
|
this.transport = options.transport ?? new WebSocketTransport(withConnectionToken(options.url, options.token), options.webSocketFactory);
|
|
375
431
|
this.requestTimeout = options.requestTimeout ?? 3e4;
|
|
376
432
|
this.turnTimeout = options.turnTimeout ?? 12e4;
|
|
@@ -612,19 +668,17 @@ var SmoothAgentChat = (function(exports) {
|
|
|
612
668
|
return out;
|
|
613
669
|
}
|
|
614
670
|
var ConversationController = class {
|
|
615
|
-
config;
|
|
616
|
-
events;
|
|
617
|
-
client = null;
|
|
618
|
-
sessionId = null;
|
|
619
|
-
messages = [];
|
|
620
|
-
status = "idle";
|
|
621
|
-
seq = 0;
|
|
622
|
-
/** Visitor identity, seeded from config and updated by the pre-chat form. */
|
|
623
|
-
identity;
|
|
624
|
-
/** requestId of the in-flight turn — used to resume OTP / tool confirmations. */
|
|
625
|
-
activeRequestId = null;
|
|
626
|
-
interrupt = null;
|
|
627
671
|
constructor(config, events) {
|
|
672
|
+
_defineProperty(this, "config", void 0);
|
|
673
|
+
_defineProperty(this, "events", void 0);
|
|
674
|
+
_defineProperty(this, "client", null);
|
|
675
|
+
_defineProperty(this, "sessionId", null);
|
|
676
|
+
_defineProperty(this, "messages", []);
|
|
677
|
+
_defineProperty(this, "status", "idle");
|
|
678
|
+
_defineProperty(this, "seq", 0);
|
|
679
|
+
_defineProperty(this, "identity", void 0);
|
|
680
|
+
_defineProperty(this, "activeRequestId", null);
|
|
681
|
+
_defineProperty(this, "interrupt", null);
|
|
628
682
|
this.config = config;
|
|
629
683
|
this.events = events;
|
|
630
684
|
this.identity = {
|
|
@@ -1444,31 +1498,27 @@ var SmoothAgentChat = (function(exports) {
|
|
|
1444
1498
|
static get observedAttributes() {
|
|
1445
1499
|
return OBSERVED;
|
|
1446
1500
|
}
|
|
1447
|
-
root;
|
|
1448
|
-
controller = null;
|
|
1449
|
-
overrides = {};
|
|
1450
|
-
open = false;
|
|
1451
|
-
messages = [];
|
|
1452
|
-
status = "idle";
|
|
1453
|
-
mounted = false;
|
|
1454
|
-
/** True once the visitor has cleared the pre-chat identity gate (or it's not needed). */
|
|
1455
|
-
userInfoSatisfied = false;
|
|
1456
|
-
/** True after the visitor has sent their first message (hides starter chips). */
|
|
1457
|
-
hasSent = false;
|
|
1458
|
-
/** Starter prompts shown as chips in the empty state. */
|
|
1459
|
-
examplePrompts = [];
|
|
1460
|
-
/** Current mid-turn interrupt (OTP / tool-confirmation), or null. */
|
|
1461
|
-
interrupt = null;
|
|
1462
|
-
interruptEl = null;
|
|
1463
|
-
panelEl = null;
|
|
1464
|
-
launcherEl = null;
|
|
1465
|
-
messagesEl = null;
|
|
1466
|
-
statusEl = null;
|
|
1467
|
-
dotEl = null;
|
|
1468
|
-
inputEl = null;
|
|
1469
|
-
sendBtn = null;
|
|
1470
1501
|
constructor() {
|
|
1471
1502
|
super();
|
|
1503
|
+
_defineProperty(this, "root", void 0);
|
|
1504
|
+
_defineProperty(this, "controller", null);
|
|
1505
|
+
_defineProperty(this, "overrides", {});
|
|
1506
|
+
_defineProperty(this, "open", false);
|
|
1507
|
+
_defineProperty(this, "messages", []);
|
|
1508
|
+
_defineProperty(this, "status", "idle");
|
|
1509
|
+
_defineProperty(this, "mounted", false);
|
|
1510
|
+
_defineProperty(this, "userInfoSatisfied", false);
|
|
1511
|
+
_defineProperty(this, "hasSent", false);
|
|
1512
|
+
_defineProperty(this, "examplePrompts", []);
|
|
1513
|
+
_defineProperty(this, "interrupt", null);
|
|
1514
|
+
_defineProperty(this, "interruptEl", null);
|
|
1515
|
+
_defineProperty(this, "panelEl", null);
|
|
1516
|
+
_defineProperty(this, "launcherEl", null);
|
|
1517
|
+
_defineProperty(this, "messagesEl", null);
|
|
1518
|
+
_defineProperty(this, "statusEl", null);
|
|
1519
|
+
_defineProperty(this, "dotEl", null);
|
|
1520
|
+
_defineProperty(this, "inputEl", null);
|
|
1521
|
+
_defineProperty(this, "sendBtn", null);
|
|
1472
1522
|
this.root = this.attachShadow({ mode: "open" });
|
|
1473
1523
|
}
|
|
1474
1524
|
connectedCallback() {
|