@syntrologie/adapt-chatbot 2.8.0-canary.261 → 2.8.0-canary.263
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatAssistantLit.d.ts","sourceRoot":"","sources":["../src/ChatAssistantLit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAGH,OAAO,mBAAmB,CAAC;AAK3B,OAAO,KAAK,EAAE,aAAa,EAAmB,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEvF,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,aAAa,CAAC;IACtB,OAAO,EAAE,oBAAoB,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAuGD,MAAM,WAAW,uBAAuB;IACtC;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,UAAU,GAAG,QAAQ,GAAG,SAAS,GAAG,WAAW,CAAC;IACvD;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,QAAQ,GAAG,SAAS,GAAG,kBAAkB,CAAC;IACvD;;;;;;;OAOG;IACH,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,MAAM,IAAI,CAAC;IACjC;;;;;OAKG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,qBAAqB,CACzC,IAAI,GAAE,uBAA4B,GACjC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAgHxB;AAqGD,eAAO,MAAM,yBAAyB;qBACnB,WAAW,gBAAgB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ChatAssistantLit.d.ts","sourceRoot":"","sources":["../src/ChatAssistantLit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAGH,OAAO,mBAAmB,CAAC;AAK3B,OAAO,KAAK,EAAE,aAAa,EAAmB,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEvF,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,aAAa,CAAC;IACtB,OAAO,EAAE,oBAAoB,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAuGD,MAAM,WAAW,uBAAuB;IACtC;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,UAAU,GAAG,QAAQ,GAAG,SAAS,GAAG,WAAW,CAAC;IACvD;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,QAAQ,GAAG,SAAS,GAAG,kBAAkB,CAAC;IACvD;;;;;;;OAOG;IACH,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,MAAM,IAAI,CAAC;IACjC;;;;;OAKG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,qBAAqB,CACzC,IAAI,GAAE,uBAA4B,GACjC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAgHxB;AAqGD,eAAO,MAAM,yBAAyB;qBACnB,WAAW,gBAAgB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAqXpE,CAAC"}
|
package/dist/ChatAssistantLit.js
CHANGED
|
@@ -10424,7 +10424,12 @@ var AgUiTransport = class {
|
|
|
10424
10424
|
}
|
|
10425
10425
|
agent.runAgent(void 0, this._buildSubscriber()).catch((err) => {
|
|
10426
10426
|
const message = err instanceof Error ? err.message : "Agent run failed";
|
|
10427
|
-
|
|
10427
|
+
const errorName = err instanceof Error ? err.name : null;
|
|
10428
|
+
const e = err;
|
|
10429
|
+
const status = typeof e.status === "number" ? e.status : typeof e.statusCode === "number" ? e.statusCode : typeof e.response?.status === "number" ? e.response.status : null;
|
|
10430
|
+
const rawBody = e.body ?? e.response?.body ?? null;
|
|
10431
|
+
const body = typeof rawBody === "string" ? rawBody.slice(0, 500) : rawBody != null ? JSON.stringify(rawBody).slice(0, 500) : null;
|
|
10432
|
+
this._emit({ type: "error", message, status, body, errorName });
|
|
10428
10433
|
this._emit({ type: "typing", isTyping: false });
|
|
10429
10434
|
});
|
|
10430
10435
|
}
|
|
@@ -10907,6 +10912,15 @@ var ChatAssistantLitMountable = {
|
|
|
10907
10912
|
if (cft) h["CF-Turnstile-Token"] = cft;
|
|
10908
10913
|
return h;
|
|
10909
10914
|
};
|
|
10915
|
+
const mountId = `m_${Math.random().toString(36).slice(2, 8)}`;
|
|
10916
|
+
const mountStartedAt = Date.now();
|
|
10917
|
+
const mountAgeMs = () => Date.now() - mountStartedAt;
|
|
10918
|
+
const debug = (...args) => {
|
|
10919
|
+
if (window.__SYNTRO_CHAT_DEBUG__) {
|
|
10920
|
+
console.debug(`[adaptive-chatbot ${mountId}]`, ...args);
|
|
10921
|
+
}
|
|
10922
|
+
};
|
|
10923
|
+
debug("mount", { tileId: resolvedTileId, instanceId, baseUrl });
|
|
10910
10924
|
const el = document.createElement("syntro-chat");
|
|
10911
10925
|
el.greeting = chatbotConfig.greeting;
|
|
10912
10926
|
if (chatbotConfig.suggestions) {
|
|
@@ -10920,6 +10934,8 @@ var ChatAssistantLitMountable = {
|
|
|
10920
10934
|
let failureTimer = null;
|
|
10921
10935
|
let errorDebounceTimer = null;
|
|
10922
10936
|
let fallbackRendered = false;
|
|
10937
|
+
let messagesSent = 0;
|
|
10938
|
+
let lastErrorPayload = null;
|
|
10923
10939
|
const clearTimers = () => {
|
|
10924
10940
|
if (failureTimer) {
|
|
10925
10941
|
clearTimeout(failureTimer);
|
|
@@ -10940,7 +10956,19 @@ var ChatAssistantLitMountable = {
|
|
|
10940
10956
|
tileId: resolvedTileId,
|
|
10941
10957
|
reason,
|
|
10942
10958
|
hadTurnstileToken,
|
|
10943
|
-
botCheckOutcome
|
|
10959
|
+
botCheckOutcome,
|
|
10960
|
+
// Diagnostic fields — let us tell "fallback on first send because
|
|
10961
|
+
// backend 403'd the bot-check" from "fallback after 3 successful
|
|
10962
|
+
// messages because token expired mid-session" from "fallback
|
|
10963
|
+
// before any send because Turnstile failed". All bounded so the
|
|
10964
|
+
// PostHog payload stays under their per-event size cap.
|
|
10965
|
+
mountId,
|
|
10966
|
+
mountAgeMs: mountAgeMs(),
|
|
10967
|
+
messagesSentBeforeFallback: messagesSent,
|
|
10968
|
+
errorStatus: lastErrorPayload?.status ?? null,
|
|
10969
|
+
errorBody: lastErrorPayload?.body ?? null,
|
|
10970
|
+
errorMessage: lastErrorPayload?.message ?? null,
|
|
10971
|
+
errorName: lastErrorPayload?.errorName ?? null
|
|
10944
10972
|
};
|
|
10945
10973
|
runtime.events.publish("chatbot.fallback_rendered", payload);
|
|
10946
10974
|
console.warn("[adaptive-chatbot] fallback rendered", payload);
|
|
@@ -10967,7 +10995,33 @@ var ChatAssistantLitMountable = {
|
|
|
10967
10995
|
el.transport = transport;
|
|
10968
10996
|
unsubscribe = transport.subscribe((event) => {
|
|
10969
10997
|
if (isUnmounted) return;
|
|
10998
|
+
debug("transport event", { type: event.type, hasSucceeded, fallbackRendered });
|
|
10970
10999
|
if (event.type === "error") {
|
|
11000
|
+
const errEvent = event;
|
|
11001
|
+
lastErrorPayload = {
|
|
11002
|
+
message: errEvent.message,
|
|
11003
|
+
status: errEvent.status ?? null,
|
|
11004
|
+
body: errEvent.body ?? null,
|
|
11005
|
+
errorName: errEvent.errorName ?? null
|
|
11006
|
+
};
|
|
11007
|
+
runtime.events.publish("chatbot.transport_error", {
|
|
11008
|
+
tileId: resolvedTileId,
|
|
11009
|
+
mountId,
|
|
11010
|
+
mountAgeMs: mountAgeMs(),
|
|
11011
|
+
messagesSentBeforeError: messagesSent,
|
|
11012
|
+
hasSucceeded,
|
|
11013
|
+
wouldFallback: !hasSucceeded && !errorDebounceTimer,
|
|
11014
|
+
errorMessage: errEvent.message ?? null,
|
|
11015
|
+
errorStatus: errEvent.status ?? null,
|
|
11016
|
+
errorBody: errEvent.body ?? null,
|
|
11017
|
+
errorName: errEvent.errorName ?? null
|
|
11018
|
+
});
|
|
11019
|
+
console.warn("[adaptive-chatbot] transport error", {
|
|
11020
|
+
mountId,
|
|
11021
|
+
status: errEvent.status,
|
|
11022
|
+
body: errEvent.body,
|
|
11023
|
+
hasSucceeded
|
|
11024
|
+
});
|
|
10971
11025
|
if (hasSucceeded || errorDebounceTimer) return;
|
|
10972
11026
|
errorDebounceTimer = setTimeout(() => {
|
|
10973
11027
|
errorDebounceTimer = null;
|
|
@@ -10977,12 +11031,15 @@ var ChatAssistantLitMountable = {
|
|
|
10977
11031
|
}
|
|
10978
11032
|
if (event.type === "session-ready" || event.type === "messages-snapshot") return;
|
|
10979
11033
|
if (event.type === "typing") return;
|
|
10980
|
-
|
|
10981
|
-
|
|
10982
|
-
|
|
10983
|
-
|
|
10984
|
-
|
|
11034
|
+
if (event.type === "message-append") {
|
|
11035
|
+
messagesSent += 1;
|
|
11036
|
+
debug("successful message", { messagesSent });
|
|
11037
|
+
}
|
|
11038
|
+
if (!hasSucceeded) {
|
|
11039
|
+
hasSucceeded = true;
|
|
11040
|
+
debug("hasSucceeded transitioned to true via", event.type);
|
|
10985
11041
|
}
|
|
11042
|
+
clearTimers();
|
|
10986
11043
|
});
|
|
10987
11044
|
container.appendChild(el);
|
|
10988
11045
|
};
|
|
@@ -11030,6 +11087,12 @@ var ChatAssistantLitMountable = {
|
|
|
11030
11087
|
setupTransport(null);
|
|
11031
11088
|
}
|
|
11032
11089
|
return () => {
|
|
11090
|
+
debug("unmount", {
|
|
11091
|
+
ageMs: mountAgeMs(),
|
|
11092
|
+
hasSucceeded,
|
|
11093
|
+
fallbackRendered,
|
|
11094
|
+
messagesSent
|
|
11095
|
+
});
|
|
11033
11096
|
isUnmounted = true;
|
|
11034
11097
|
clearTimers();
|
|
11035
11098
|
acquireAbort.abort();
|
|
@@ -11111,4 +11174,4 @@ fast-json-patch/module/duplex.mjs:
|
|
|
11111
11174
|
* MIT license
|
|
11112
11175
|
*)
|
|
11113
11176
|
*/
|
|
11114
|
-
//# sourceMappingURL=chunk-
|
|
11177
|
+
//# sourceMappingURL=chunk-VA222HQK.js.map
|