@syntrologie/adapt-chatbot 2.8.0-canary.262 → 2.8.0-canary.264
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;CAyYpE,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,10 +10956,30 @@ 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,
|
|
10972
|
+
// Snapshot of the agent backend URL so PostHog queries can group
|
|
10973
|
+
// fallback events by customer environment (demo-api vs
|
|
10974
|
+
// dev-api). Cheap to attach; the SDK already has it in scope.
|
|
10975
|
+
backendUrl: streamUrl
|
|
10944
10976
|
};
|
|
10945
10977
|
runtime.events.publish("chatbot.fallback_rendered", payload);
|
|
10946
|
-
|
|
10978
|
+
const statusLabel = lastErrorPayload?.status ?? "no-status";
|
|
10979
|
+
console.warn(
|
|
10980
|
+
`[adaptive-chatbot] fallback rendered mountId=${mountId} reason=${reason} botCheck=${botCheckOutcome} errorStatus=${statusLabel} messagesSent=${messagesSent}`,
|
|
10981
|
+
payload
|
|
10982
|
+
);
|
|
10947
10983
|
transport?.disconnect();
|
|
10948
10984
|
el.remove();
|
|
10949
10985
|
container.innerHTML = renderFallbackHtml(chatbotConfig.fallback);
|
|
@@ -10967,7 +11003,42 @@ var ChatAssistantLitMountable = {
|
|
|
10967
11003
|
el.transport = transport;
|
|
10968
11004
|
unsubscribe = transport.subscribe((event) => {
|
|
10969
11005
|
if (isUnmounted) return;
|
|
11006
|
+
debug("transport event", { type: event.type, hasSucceeded, fallbackRendered });
|
|
10970
11007
|
if (event.type === "error") {
|
|
11008
|
+
const errEvent = event;
|
|
11009
|
+
lastErrorPayload = {
|
|
11010
|
+
message: errEvent.message,
|
|
11011
|
+
status: errEvent.status ?? null,
|
|
11012
|
+
body: errEvent.body ?? null,
|
|
11013
|
+
errorName: errEvent.errorName ?? null
|
|
11014
|
+
};
|
|
11015
|
+
runtime.events.publish("chatbot.transport_error", {
|
|
11016
|
+
tileId: resolvedTileId,
|
|
11017
|
+
mountId,
|
|
11018
|
+
mountAgeMs: mountAgeMs(),
|
|
11019
|
+
messagesSentBeforeError: messagesSent,
|
|
11020
|
+
hasSucceeded,
|
|
11021
|
+
wouldFallback: !hasSucceeded && !errorDebounceTimer,
|
|
11022
|
+
errorMessage: errEvent.message ?? null,
|
|
11023
|
+
errorStatus: errEvent.status ?? null,
|
|
11024
|
+
errorBody: errEvent.body ?? null,
|
|
11025
|
+
errorName: errEvent.errorName ?? null
|
|
11026
|
+
});
|
|
11027
|
+
const statusLabel = errEvent.status ?? "no-status";
|
|
11028
|
+
const bodySnippet = errEvent.body ? errEvent.body.slice(0, 120) : "<no-body>";
|
|
11029
|
+
console.warn(
|
|
11030
|
+
`[adaptive-chatbot] transport error mountId=${mountId} status=${statusLabel} hasSucceeded=${hasSucceeded} body=${JSON.stringify(bodySnippet)}`,
|
|
11031
|
+
{
|
|
11032
|
+
mountId,
|
|
11033
|
+
status: errEvent.status,
|
|
11034
|
+
body: errEvent.body,
|
|
11035
|
+
errorName: errEvent.errorName,
|
|
11036
|
+
errorMessage: errEvent.message,
|
|
11037
|
+
hasSucceeded,
|
|
11038
|
+
messagesSent,
|
|
11039
|
+
mountAgeMs: mountAgeMs()
|
|
11040
|
+
}
|
|
11041
|
+
);
|
|
10971
11042
|
if (hasSucceeded || errorDebounceTimer) return;
|
|
10972
11043
|
errorDebounceTimer = setTimeout(() => {
|
|
10973
11044
|
errorDebounceTimer = null;
|
|
@@ -10977,12 +11048,15 @@ var ChatAssistantLitMountable = {
|
|
|
10977
11048
|
}
|
|
10978
11049
|
if (event.type === "session-ready" || event.type === "messages-snapshot") return;
|
|
10979
11050
|
if (event.type === "typing") return;
|
|
10980
|
-
|
|
10981
|
-
|
|
10982
|
-
|
|
10983
|
-
unsubscribe();
|
|
10984
|
-
unsubscribe = null;
|
|
11051
|
+
if (event.type === "message-append") {
|
|
11052
|
+
messagesSent += 1;
|
|
11053
|
+
debug("successful message", { messagesSent });
|
|
10985
11054
|
}
|
|
11055
|
+
if (!hasSucceeded) {
|
|
11056
|
+
hasSucceeded = true;
|
|
11057
|
+
debug("hasSucceeded transitioned to true via", event.type);
|
|
11058
|
+
}
|
|
11059
|
+
clearTimers();
|
|
10986
11060
|
});
|
|
10987
11061
|
container.appendChild(el);
|
|
10988
11062
|
};
|
|
@@ -11030,6 +11104,12 @@ var ChatAssistantLitMountable = {
|
|
|
11030
11104
|
setupTransport(null);
|
|
11031
11105
|
}
|
|
11032
11106
|
return () => {
|
|
11107
|
+
debug("unmount", {
|
|
11108
|
+
ageMs: mountAgeMs(),
|
|
11109
|
+
hasSucceeded,
|
|
11110
|
+
fallbackRendered,
|
|
11111
|
+
messagesSent
|
|
11112
|
+
});
|
|
11033
11113
|
isUnmounted = true;
|
|
11034
11114
|
clearTimers();
|
|
11035
11115
|
acquireAbort.abort();
|
|
@@ -11111,4 +11191,4 @@ fast-json-patch/module/duplex.mjs:
|
|
|
11111
11191
|
* MIT license
|
|
11112
11192
|
*)
|
|
11113
11193
|
*/
|
|
11114
|
-
//# sourceMappingURL=chunk-
|
|
11194
|
+
//# sourceMappingURL=chunk-SSVUE6E6.js.map
|