@mushi-mushi/web 1.14.1 → 1.16.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/CONTRIBUTING.md +50 -9
- package/README.md +4 -1
- package/dist/index.cjs +266 -38
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +23 -2
- package/dist/index.d.ts +23 -2
- package/dist/index.js +267 -39
- package/dist/index.js.map +1 -1
- package/dist/mushi.loader.global.js +2133 -0
- package/dist/mushi.loader.global.js.map +1 -0
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MushiConfig, MushiSDKInstance, MushiDiagnosticsResult, MushiReportCategory, MushiReporterReport, MushiReporterComment, MushiWidgetConfig, MushiLeaderboardEntry, MushiCrossAppReport, MushiTesterReputation, MushiConsoleEntry, MushiNetworkEntry, MushiUrlMatcher, MushiTracePropagationConfig, MushiPrivacyConfig, MushiPerformanceMetrics, MushiSelectedElement, MushiTimelineEntry, MushiApiCascadeConfig } from '@mushi-mushi/core';
|
|
1
|
+
import { MushiConfig, MushiSDKInstance, MushiDiagnosticsResult, MushiReportCategory, MushiReporterReport, MushiReporterComment, MushiAssistantReply, MushiWidgetConfig, MushiLeaderboardEntry, MushiCrossAppReport, MushiTesterReputation, MushiConsoleEntry, MushiNetworkEntry, MushiUrlMatcher, MushiTracePropagationConfig, MushiPrivacyConfig, MushiPerformanceMetrics, MushiSelectedElement, MushiTimelineEntry, MushiApiCascadeConfig } from '@mushi-mushi/core';
|
|
2
2
|
export { MushiApiCascadeConfig, MushiConfig, MushiConsoleEntry, MushiDiagnosticsResult, MushiEnvironment, MushiEventHandler, MushiEventType, MushiNetworkEntry, MushiPerformanceMetrics, MushiReport, MushiReportCategory, MushiSDKInstance, MushiTimelineEntry, MushiTimelineKind, MushiUrlMatcher, MushiWidgetConfig } from '@mushi-mushi/core';
|
|
3
3
|
|
|
4
4
|
declare class Mushi {
|
|
@@ -36,7 +36,7 @@ declare class Mushi {
|
|
|
36
36
|
* - Behaviour-preserving move: bodies are identical to the pre-split widget.ts.
|
|
37
37
|
*/
|
|
38
38
|
|
|
39
|
-
type WidgetStep = 'category' | 'intent' | 'details' | 'success' | 'reports' | 'report-detail' | 'leaderboard' | 'roadmap' | 'account' | 'cross-app-reports';
|
|
39
|
+
type WidgetStep = 'category' | 'intent' | 'details' | 'success' | 'reports' | 'report-detail' | 'leaderboard' | 'roadmap' | 'account' | 'cross-app-reports' | 'assistant';
|
|
40
40
|
interface WidgetRewardsState {
|
|
41
41
|
tier: {
|
|
42
42
|
slug: string;
|
|
@@ -104,6 +104,14 @@ interface WidgetCallbacks {
|
|
|
104
104
|
/** Called when the user signs out of the in-widget community session.
|
|
105
105
|
* Host should clear any persisted tester JWT. */
|
|
106
106
|
onTesterSignOut?(): void;
|
|
107
|
+
/** Whether the assistant tab should be shown at all. */
|
|
108
|
+
assistantEnabled?: boolean;
|
|
109
|
+
/** Tab label + greeting + starter suggestions for the empty thread. */
|
|
110
|
+
assistantLabel?: string;
|
|
111
|
+
assistantGreeting?: string;
|
|
112
|
+
assistantSuggestions?: string[];
|
|
113
|
+
/** Send one assistant turn; resolves with the structured reply. */
|
|
114
|
+
onAssistantAsk?(message: string, threadId: string | null): Promise<MushiAssistantReply | null>;
|
|
107
115
|
}
|
|
108
116
|
|
|
109
117
|
declare class MushiWidget {
|
|
@@ -203,6 +211,10 @@ declare class MushiWidget {
|
|
|
203
211
|
private magicLinkEmail;
|
|
204
212
|
private magicLinkError;
|
|
205
213
|
private magicLinkSending;
|
|
214
|
+
private assistantTurns;
|
|
215
|
+
private assistantThreadId;
|
|
216
|
+
private assistantSending;
|
|
217
|
+
private assistantError;
|
|
206
218
|
constructor(config: MushiWidgetConfig | undefined, callbacks: WidgetCallbacks, sdkVersion?: string);
|
|
207
219
|
mount(): void;
|
|
208
220
|
getIsMounted(): boolean;
|
|
@@ -223,6 +235,10 @@ declare class MushiWidget {
|
|
|
223
235
|
featureRequest?: boolean;
|
|
224
236
|
}): void;
|
|
225
237
|
close(): void;
|
|
238
|
+
/** Open the panel directly on the assistant ("Ask") tab. */
|
|
239
|
+
openAssistantTab(): void;
|
|
240
|
+
/** Send one assistant turn and re-render as the reply streams back. */
|
|
241
|
+
sendAssistantMessage(message: string): Promise<void>;
|
|
226
242
|
/**
|
|
227
243
|
* Briefly highlight the trigger button (a soft pulse + tooltip) without
|
|
228
244
|
* opening the full reporter panel. Use for first-session welcome nudges
|
|
@@ -327,6 +343,11 @@ declare class MushiWidget {
|
|
|
327
343
|
* sticky nav bars, and sign-in CTAs.
|
|
328
344
|
*/
|
|
329
345
|
private computeAvoidTopPx;
|
|
346
|
+
/**
|
|
347
|
+
* Minimum bottom-offset in px so a bottom-anchored trigger clears avoided
|
|
348
|
+
* elements (tab bars, fixed CTAs). Mirrors {@link computeAvoidTopPx}.
|
|
349
|
+
*/
|
|
350
|
+
private computeAvoidBottomPx;
|
|
330
351
|
private applyInsetVars;
|
|
331
352
|
/** Storage key for the FAB position, scoped to projectId when available. */
|
|
332
353
|
private fabStorageKey;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MushiConfig, MushiSDKInstance, MushiDiagnosticsResult, MushiReportCategory, MushiReporterReport, MushiReporterComment, MushiWidgetConfig, MushiLeaderboardEntry, MushiCrossAppReport, MushiTesterReputation, MushiConsoleEntry, MushiNetworkEntry, MushiUrlMatcher, MushiTracePropagationConfig, MushiPrivacyConfig, MushiPerformanceMetrics, MushiSelectedElement, MushiTimelineEntry, MushiApiCascadeConfig } from '@mushi-mushi/core';
|
|
1
|
+
import { MushiConfig, MushiSDKInstance, MushiDiagnosticsResult, MushiReportCategory, MushiReporterReport, MushiReporterComment, MushiAssistantReply, MushiWidgetConfig, MushiLeaderboardEntry, MushiCrossAppReport, MushiTesterReputation, MushiConsoleEntry, MushiNetworkEntry, MushiUrlMatcher, MushiTracePropagationConfig, MushiPrivacyConfig, MushiPerformanceMetrics, MushiSelectedElement, MushiTimelineEntry, MushiApiCascadeConfig } from '@mushi-mushi/core';
|
|
2
2
|
export { MushiApiCascadeConfig, MushiConfig, MushiConsoleEntry, MushiDiagnosticsResult, MushiEnvironment, MushiEventHandler, MushiEventType, MushiNetworkEntry, MushiPerformanceMetrics, MushiReport, MushiReportCategory, MushiSDKInstance, MushiTimelineEntry, MushiTimelineKind, MushiUrlMatcher, MushiWidgetConfig } from '@mushi-mushi/core';
|
|
3
3
|
|
|
4
4
|
declare class Mushi {
|
|
@@ -36,7 +36,7 @@ declare class Mushi {
|
|
|
36
36
|
* - Behaviour-preserving move: bodies are identical to the pre-split widget.ts.
|
|
37
37
|
*/
|
|
38
38
|
|
|
39
|
-
type WidgetStep = 'category' | 'intent' | 'details' | 'success' | 'reports' | 'report-detail' | 'leaderboard' | 'roadmap' | 'account' | 'cross-app-reports';
|
|
39
|
+
type WidgetStep = 'category' | 'intent' | 'details' | 'success' | 'reports' | 'report-detail' | 'leaderboard' | 'roadmap' | 'account' | 'cross-app-reports' | 'assistant';
|
|
40
40
|
interface WidgetRewardsState {
|
|
41
41
|
tier: {
|
|
42
42
|
slug: string;
|
|
@@ -104,6 +104,14 @@ interface WidgetCallbacks {
|
|
|
104
104
|
/** Called when the user signs out of the in-widget community session.
|
|
105
105
|
* Host should clear any persisted tester JWT. */
|
|
106
106
|
onTesterSignOut?(): void;
|
|
107
|
+
/** Whether the assistant tab should be shown at all. */
|
|
108
|
+
assistantEnabled?: boolean;
|
|
109
|
+
/** Tab label + greeting + starter suggestions for the empty thread. */
|
|
110
|
+
assistantLabel?: string;
|
|
111
|
+
assistantGreeting?: string;
|
|
112
|
+
assistantSuggestions?: string[];
|
|
113
|
+
/** Send one assistant turn; resolves with the structured reply. */
|
|
114
|
+
onAssistantAsk?(message: string, threadId: string | null): Promise<MushiAssistantReply | null>;
|
|
107
115
|
}
|
|
108
116
|
|
|
109
117
|
declare class MushiWidget {
|
|
@@ -203,6 +211,10 @@ declare class MushiWidget {
|
|
|
203
211
|
private magicLinkEmail;
|
|
204
212
|
private magicLinkError;
|
|
205
213
|
private magicLinkSending;
|
|
214
|
+
private assistantTurns;
|
|
215
|
+
private assistantThreadId;
|
|
216
|
+
private assistantSending;
|
|
217
|
+
private assistantError;
|
|
206
218
|
constructor(config: MushiWidgetConfig | undefined, callbacks: WidgetCallbacks, sdkVersion?: string);
|
|
207
219
|
mount(): void;
|
|
208
220
|
getIsMounted(): boolean;
|
|
@@ -223,6 +235,10 @@ declare class MushiWidget {
|
|
|
223
235
|
featureRequest?: boolean;
|
|
224
236
|
}): void;
|
|
225
237
|
close(): void;
|
|
238
|
+
/** Open the panel directly on the assistant ("Ask") tab. */
|
|
239
|
+
openAssistantTab(): void;
|
|
240
|
+
/** Send one assistant turn and re-render as the reply streams back. */
|
|
241
|
+
sendAssistantMessage(message: string): Promise<void>;
|
|
226
242
|
/**
|
|
227
243
|
* Briefly highlight the trigger button (a soft pulse + tooltip) without
|
|
228
244
|
* opening the full reporter panel. Use for first-session welcome nudges
|
|
@@ -327,6 +343,11 @@ declare class MushiWidget {
|
|
|
327
343
|
* sticky nav bars, and sign-in CTAs.
|
|
328
344
|
*/
|
|
329
345
|
private computeAvoidTopPx;
|
|
346
|
+
/**
|
|
347
|
+
* Minimum bottom-offset in px so a bottom-anchored trigger clears avoided
|
|
348
|
+
* elements (tab bars, fixed CTAs). Mirrors {@link computeAvoidTopPx}.
|
|
349
|
+
*/
|
|
350
|
+
private computeAvoidBottomPx;
|
|
330
351
|
private applyInsetVars;
|
|
331
352
|
/** Storage key for the FAB position, scoped to projectId when available. */
|
|
332
353
|
private fabStorageKey;
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createLogger, noopLogger, createApiClient, createPreFilter, createOfflineQueue, createRateLimiter, createPiiScrubber, createBreadcrumbBuffer, getReporterToken, getDeviceFingerprintHash, MAX_SCREENSHOT_DATA_URL_BYTES, getSessionId, captureEnvironment, newUuid, DEFAULT_API_ENDPOINT, MUSHI_INTERNAL_INIT_MARKER, MUSHI_INTERNAL_HEADER, normaliseThrown } from '@mushi-mushi/core';
|
|
1
|
+
import { resolveEnvConfig, createLogger, noopLogger, createApiClient, createPreFilter, createOfflineQueue, createRateLimiter, createPiiScrubber, createBreadcrumbBuffer, getReporterToken, getDeviceFingerprintHash, MAX_SCREENSHOT_DATA_URL_BYTES, getSessionId, captureEnvironment, newUuid, DEFAULT_API_ENDPOINT, MUSHI_INTERNAL_INIT_MARKER, MUSHI_INTERNAL_HEADER, parseIdentityToken, normaliseThrown } from '@mushi-mushi/core';
|
|
2
2
|
|
|
3
3
|
// src/capture/compress-screenshot.ts
|
|
4
4
|
async function compressScreenshotDataUrl(dataUrl, maxBytes = MAX_SCREENSHOT_DATA_URL_BYTES) {
|
|
@@ -479,8 +479,8 @@ function getWidgetStyles(theme, accent = "", accentText = "") {
|
|
|
479
479
|
|
|
480
480
|
@keyframes mushi-pulse {
|
|
481
481
|
0% { box-shadow: 0 0 0 0 ${widgetAccent}; opacity: 1; }
|
|
482
|
-
70% { box-shadow: 0 0 0 8px
|
|
483
|
-
100% { box-shadow: 0 0 0 0
|
|
482
|
+
70% { box-shadow: 0 0 0 8px ${widgetAccent}00; opacity: 0.5; }
|
|
483
|
+
100% { box-shadow: 0 0 0 0 ${widgetAccent}00; opacity: 1; }
|
|
484
484
|
}
|
|
485
485
|
|
|
486
486
|
.mushi-panel {
|
|
@@ -1626,12 +1626,18 @@ function getWidgetStyles(theme, accent = "", accentText = "") {
|
|
|
1626
1626
|
position: fixed;
|
|
1627
1627
|
left: 0;
|
|
1628
1628
|
right: 0;
|
|
1629
|
-
height
|
|
1629
|
+
/* min-height (not fixed height) + border-box so the safe-area padding
|
|
1630
|
+
below extends the bar into the notch/home-indicator zone instead of
|
|
1631
|
+
letting content bleed under the status bar (mobile safe-area bleed
|
|
1632
|
+
fix \u2014 Workstream C). Horizontal padding also clears the left/right
|
|
1633
|
+
insets for landscape notches. */
|
|
1634
|
+
box-sizing: border-box;
|
|
1635
|
+
min-height: 36px;
|
|
1630
1636
|
display: flex;
|
|
1631
1637
|
align-items: center;
|
|
1632
1638
|
justify-content: center;
|
|
1633
1639
|
gap: 10px;
|
|
1634
|
-
padding: 0 16px;
|
|
1640
|
+
padding: 0 calc(16px + env(safe-area-inset-right, 0px)) 0 calc(16px + env(safe-area-inset-left, 0px));
|
|
1635
1641
|
font-family: ${fontMono};
|
|
1636
1642
|
font-size: 12px;
|
|
1637
1643
|
letter-spacing: 0.04em;
|
|
@@ -1641,8 +1647,8 @@ function getWidgetStyles(theme, accent = "", accentText = "") {
|
|
|
1641
1647
|
animation: mushi-banner-slide-in 0.3s ${easeStamp} both;
|
|
1642
1648
|
}
|
|
1643
1649
|
|
|
1644
|
-
.mushi-banner.top { top: 0; }
|
|
1645
|
-
.mushi-banner.bottom { bottom: 0; }
|
|
1650
|
+
.mushi-banner.top { top: 0; padding-top: env(safe-area-inset-top, 0px); }
|
|
1651
|
+
.mushi-banner.bottom { bottom: 0; padding-bottom: env(safe-area-inset-bottom, 0px); }
|
|
1646
1652
|
|
|
1647
1653
|
/* --- neon variant (electric lime \u2014 dev / beta tool aesthetic) --- */
|
|
1648
1654
|
.mushi-banner.neon {
|
|
@@ -1894,12 +1900,33 @@ function getWidgetStyles(theme, accent = "", accentText = "") {
|
|
|
1894
1900
|
.mushi-xapp-app-name{font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:.06em;margin:0 0 6px}
|
|
1895
1901
|
.mushi-xapp-group{margin-bottom:14px}
|
|
1896
1902
|
.mushi-label{display:block;font-weight:600;margin-bottom:6px}
|
|
1903
|
+
|
|
1904
|
+
/* \u2500\u2500 Assistant tab (P5) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
1905
|
+
.mushi-assistant{display:flex;flex-direction:column;height:100%;min-height:0;max-height:60vh}
|
|
1906
|
+
.mushi-assistant-log{flex:1;min-height:120px;overflow-y:auto;display:flex;flex-direction:column;gap:8px;padding:4px 2px 8px}
|
|
1907
|
+
.mushi-assistant-greeting{font:400 14px/1.5 ${fontBody};color:${inkMuted};padding:6px 2px}
|
|
1908
|
+
.mushi-assistant-suggestions{display:flex;flex-wrap:wrap;gap:6px;margin-top:4px}
|
|
1909
|
+
.mushi-assistant-chip{background:${widgetAccentWash};color:${widgetAccentInk};border:1px solid ${ruleStrong};border-radius:999px;padding:5px 12px;font-size:12px;cursor:pointer;font-family:${fontBody};transition:background .15s}
|
|
1910
|
+
.mushi-assistant-chip:hover{background:${isDark ? "rgba(255,90,71,0.22)" : "rgba(224,60,44,0.14)"}}
|
|
1911
|
+
.mushi-assistant-chip:focus-visible{outline:2px solid ${widgetAccent};outline-offset:2px}
|
|
1912
|
+
.mushi-assistant-msg{max-width:85%;padding:8px 12px;border-radius:12px;font:400 14px/1.45 ${fontBody};white-space:pre-wrap;word-break:break-word}
|
|
1913
|
+
.mushi-assistant-msg-user{align-self:flex-end;background:${widgetAccent};color:#fff;border-bottom-right-radius:4px}
|
|
1914
|
+
.mushi-assistant-msg-bot{align-self:flex-start;background:${isDark ? "rgba(255,255,255,0.06)" : "rgba(0,0,0,0.05)"};color:${ink};border-bottom-left-radius:4px}
|
|
1915
|
+
.mushi-assistant-thinking{opacity:0.6;font-size:18px;letter-spacing:2px}
|
|
1916
|
+
.mushi-assistant-error{align-self:flex-start;color:${isDark ? "#F87171" : "#DC2626"};font-size:12px;padding:4px 2px}
|
|
1917
|
+
.mushi-assistant-form{display:flex;align-items:flex-end;gap:8px;border-top:1px solid ${rule};padding-top:8px}
|
|
1918
|
+
.mushi-assistant-input{flex:1;resize:none;max-height:120px;border:1px solid ${ruleStrong};border-radius:10px;padding:8px 12px;font:400 14px/1.4 ${fontBody};background:${paper};color:${ink}}
|
|
1919
|
+
.mushi-assistant-input:focus-visible{outline:2px solid ${widgetAccent};outline-offset:1px}
|
|
1920
|
+
.mushi-assistant-submit{flex-shrink:0;width:36px;height:36px;border:none;border-radius:50%;background:${widgetAccent};color:#fff;font-size:18px;line-height:1;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:transform .15s,opacity .15s}
|
|
1921
|
+
.mushi-assistant-submit:hover{transform:translateY(-1px)}
|
|
1922
|
+
.mushi-assistant-submit:disabled{opacity:0.5;cursor:default;transform:none}
|
|
1923
|
+
.mushi-assistant-submit:focus-visible{outline:2px solid ${widgetAccent};outline-offset:2px}
|
|
1897
1924
|
`;
|
|
1898
1925
|
}
|
|
1899
1926
|
|
|
1900
1927
|
// src/version.ts
|
|
1901
1928
|
var MUSHI_SDK_PACKAGE = "@mushi-mushi/web";
|
|
1902
|
-
var MUSHI_SDK_VERSION = "1.
|
|
1929
|
+
var MUSHI_SDK_VERSION = "1.16.0" ;
|
|
1903
1930
|
|
|
1904
1931
|
// src/widget-helpers.ts
|
|
1905
1932
|
var CATEGORY_ICONS = {
|
|
@@ -2045,8 +2072,43 @@ function renderStep(ctx) {
|
|
|
2045
2072
|
return renderAccountStep(ctx);
|
|
2046
2073
|
case "cross-app-reports":
|
|
2047
2074
|
return renderCrossAppReportsStep(ctx);
|
|
2075
|
+
case "assistant":
|
|
2076
|
+
return renderAssistantStep(ctx);
|
|
2048
2077
|
}
|
|
2049
2078
|
}
|
|
2079
|
+
function renderAssistantStep(ctx) {
|
|
2080
|
+
const label = ctx.callbacks.assistantLabel || "Ask";
|
|
2081
|
+
const greeting = ctx.callbacks.assistantGreeting || "Ask me anything about this app.";
|
|
2082
|
+
const suggestions = ctx.callbacks.assistantSuggestions ?? [];
|
|
2083
|
+
const empty = ctx.assistantTurns.length === 0;
|
|
2084
|
+
const transcript = empty ? `<div class="mushi-assistant-greeting">${escapeHtml(greeting)}</div>
|
|
2085
|
+
${suggestions.length ? `<div class="mushi-assistant-suggestions">${suggestions.map((s) => `<button type="button" class="mushi-assistant-chip" data-action="assistant-suggest" data-value="${escapeHtml(s)}">${escapeHtml(s)}</button>`).join("")}</div>` : ""}` : ctx.assistantTurns.map((turn) => {
|
|
2086
|
+
const cls = turn.role === "user" ? "mushi-assistant-msg-user" : "mushi-assistant-msg-bot";
|
|
2087
|
+
const opts = turn.options && turn.options.length ? `<div class="mushi-assistant-suggestions">${turn.options.map((o) => `<button type="button" class="mushi-assistant-chip" data-action="assistant-suggest" data-value="${escapeHtml(o)}">${escapeHtml(o)}</button>`).join("")}</div>` : "";
|
|
2088
|
+
return `<div class="mushi-assistant-msg ${cls}">${escapeHtml(turn.text)}</div>${opts}`;
|
|
2089
|
+
}).join("");
|
|
2090
|
+
const thinking = ctx.assistantSending ? `<div class="mushi-assistant-msg mushi-assistant-msg-bot mushi-assistant-thinking">\u2026</div>` : "";
|
|
2091
|
+
const error = ctx.assistantError ? `<div class="mushi-assistant-error" role="alert">${escapeHtml(ctx.assistantError)}</div>` : "";
|
|
2092
|
+
return `
|
|
2093
|
+
${renderHeader(ctx, { title: label, showBack: true })}
|
|
2094
|
+
<div class="mushi-assistant">
|
|
2095
|
+
<div class="mushi-assistant-log">
|
|
2096
|
+
${transcript}
|
|
2097
|
+
${thinking}
|
|
2098
|
+
${error}
|
|
2099
|
+
</div>
|
|
2100
|
+
<form class="mushi-assistant-form" data-action="assistant-send">
|
|
2101
|
+
<textarea
|
|
2102
|
+
class="mushi-assistant-input"
|
|
2103
|
+
rows="1"
|
|
2104
|
+
placeholder="Type your question\u2026"
|
|
2105
|
+
${ctx.assistantSending ? "disabled" : ""}
|
|
2106
|
+
></textarea>
|
|
2107
|
+
<button type="submit" class="mushi-assistant-submit" ${ctx.assistantSending ? "disabled" : ""} aria-label="Send">\u2191</button>
|
|
2108
|
+
</form>
|
|
2109
|
+
</div>
|
|
2110
|
+
`;
|
|
2111
|
+
}
|
|
2050
2112
|
function renderOutdatedBanner(ctx) {
|
|
2051
2113
|
if (!ctx.sdkFreshness) return "";
|
|
2052
2114
|
if (ctx.config.outdatedBanner === "off" || ctx.config.outdatedBanner === "console-only") return "";
|
|
@@ -2666,7 +2728,6 @@ function renderSuccessRewards(ctx) {
|
|
|
2666
2728
|
|
|
2667
2729
|
// src/widget.ts
|
|
2668
2730
|
var MushiWidget = class _MushiWidget {
|
|
2669
|
-
// double-submit guard
|
|
2670
2731
|
constructor(config = {}, callbacks, sdkVersion = MUSHI_SDK_VERSION) {
|
|
2671
2732
|
this.sdkVersion = sdkVersion;
|
|
2672
2733
|
this.config = {
|
|
@@ -2811,6 +2872,12 @@ var MushiWidget = class _MushiWidget {
|
|
|
2811
2872
|
magicLinkEmail = "";
|
|
2812
2873
|
magicLinkError = "";
|
|
2813
2874
|
magicLinkSending = false;
|
|
2875
|
+
// double-submit guard
|
|
2876
|
+
// ─── Assistant tab (P5) ──────────────────────────────────────────
|
|
2877
|
+
assistantTurns = [];
|
|
2878
|
+
assistantThreadId = null;
|
|
2879
|
+
assistantSending = false;
|
|
2880
|
+
assistantError = null;
|
|
2814
2881
|
mount() {
|
|
2815
2882
|
if (this.host.isConnected) return;
|
|
2816
2883
|
this.syncHostChromeState();
|
|
@@ -2914,10 +2981,18 @@ var MushiWidget = class _MushiWidget {
|
|
|
2914
2981
|
this.viaFeatureRequest = true;
|
|
2915
2982
|
this.step = "details";
|
|
2916
2983
|
} else if (options?.category) {
|
|
2917
|
-
this.selectedCategory = options.category;
|
|
2918
|
-
this.selectedIntent = null;
|
|
2919
2984
|
const custom = this.resolveCustomCategory(options.category);
|
|
2920
|
-
|
|
2985
|
+
const builtIn = ["bug", "slow", "visual", "confusing", "other"];
|
|
2986
|
+
const isKnown = builtIn.includes(options.category) || custom !== void 0;
|
|
2987
|
+
if (!isKnown) {
|
|
2988
|
+
this.selectedCategory = null;
|
|
2989
|
+
this.selectedIntent = null;
|
|
2990
|
+
this.step = "category";
|
|
2991
|
+
} else {
|
|
2992
|
+
this.selectedCategory = options.category;
|
|
2993
|
+
this.selectedIntent = null;
|
|
2994
|
+
this.step = custom && (!custom.intents || custom.intents.length === 0) ? "details" : "intent";
|
|
2995
|
+
}
|
|
2921
2996
|
} else {
|
|
2922
2997
|
this.selectedCategory = null;
|
|
2923
2998
|
this.selectedIntent = null;
|
|
@@ -2932,6 +3007,58 @@ var MushiWidget = class _MushiWidget {
|
|
|
2932
3007
|
this.render();
|
|
2933
3008
|
this.callbacks.onClose();
|
|
2934
3009
|
}
|
|
3010
|
+
/** Open the panel directly on the assistant ("Ask") tab. */
|
|
3011
|
+
openAssistantTab() {
|
|
3012
|
+
if (!this.callbacks.assistantEnabled) {
|
|
3013
|
+
this.open();
|
|
3014
|
+
return;
|
|
3015
|
+
}
|
|
3016
|
+
if (!this.isOpen) {
|
|
3017
|
+
this.isOpen = true;
|
|
3018
|
+
this.callbacks.onOpen();
|
|
3019
|
+
}
|
|
3020
|
+
this.step = "assistant";
|
|
3021
|
+
this.assistantError = null;
|
|
3022
|
+
this.render();
|
|
3023
|
+
setTimeout(() => {
|
|
3024
|
+
this.shadow.querySelector(".mushi-assistant-input")?.focus();
|
|
3025
|
+
}, 0);
|
|
3026
|
+
}
|
|
3027
|
+
/** Send one assistant turn and re-render as the reply streams back. */
|
|
3028
|
+
async sendAssistantMessage(message) {
|
|
3029
|
+
const text = message.trim();
|
|
3030
|
+
if (!text || this.assistantSending || !this.callbacks.onAssistantAsk) return;
|
|
3031
|
+
this.assistantSending = true;
|
|
3032
|
+
this.assistantError = null;
|
|
3033
|
+
this.assistantTurns.push({ role: "user", text });
|
|
3034
|
+
this.render();
|
|
3035
|
+
try {
|
|
3036
|
+
const reply = await this.callbacks.onAssistantAsk(text, this.assistantThreadId);
|
|
3037
|
+
if (reply) {
|
|
3038
|
+
if (reply.threadId) this.assistantThreadId = reply.threadId;
|
|
3039
|
+
if (reply.kind === "clarify") {
|
|
3040
|
+
this.assistantTurns.push({
|
|
3041
|
+
role: "assistant",
|
|
3042
|
+
text: reply.question ?? "Could you tell me a bit more?",
|
|
3043
|
+
...reply.options && reply.options.length ? { options: reply.options } : {}
|
|
3044
|
+
});
|
|
3045
|
+
} else {
|
|
3046
|
+
this.assistantTurns.push({ role: "assistant", text: reply.text ?? "\u2026" });
|
|
3047
|
+
}
|
|
3048
|
+
} else {
|
|
3049
|
+
this.assistantError = "No response \u2014 please try again.";
|
|
3050
|
+
}
|
|
3051
|
+
} catch {
|
|
3052
|
+
this.assistantError = "Something went wrong. Please try again.";
|
|
3053
|
+
} finally {
|
|
3054
|
+
this.assistantSending = false;
|
|
3055
|
+
this.render();
|
|
3056
|
+
setTimeout(() => {
|
|
3057
|
+
const log = this.shadow.querySelector(".mushi-assistant-log");
|
|
3058
|
+
if (log) log.scrollTop = log.scrollHeight;
|
|
3059
|
+
}, 0);
|
|
3060
|
+
}
|
|
3061
|
+
}
|
|
2935
3062
|
/**
|
|
2936
3063
|
* Briefly highlight the trigger button (a soft pulse + tooltip) without
|
|
2937
3064
|
* opening the full reporter panel. Use for first-session welcome nudges
|
|
@@ -3553,6 +3680,28 @@ var MushiWidget = class _MushiWidget {
|
|
|
3553
3680
|
}
|
|
3554
3681
|
return maxBottom > 0 ? Math.ceil(maxBottom) + gap : null;
|
|
3555
3682
|
}
|
|
3683
|
+
/**
|
|
3684
|
+
* Minimum bottom-offset in px so a bottom-anchored trigger clears avoided
|
|
3685
|
+
* elements (tab bars, fixed CTAs). Mirrors {@link computeAvoidTopPx}.
|
|
3686
|
+
*/
|
|
3687
|
+
computeAvoidBottomPx(gap = 8) {
|
|
3688
|
+
const sels = this.config.avoidSelectors;
|
|
3689
|
+
if (!sels?.length) return null;
|
|
3690
|
+
let maxClearance = 0;
|
|
3691
|
+
for (const sel of sels) {
|
|
3692
|
+
try {
|
|
3693
|
+
const el = document.querySelector(sel);
|
|
3694
|
+
if (!el) continue;
|
|
3695
|
+
const r = el.getBoundingClientRect();
|
|
3696
|
+
if (r.width > 0 && r.height > 0) {
|
|
3697
|
+
const clearance = window.innerHeight - r.top + gap;
|
|
3698
|
+
if (clearance > maxClearance) maxClearance = clearance;
|
|
3699
|
+
}
|
|
3700
|
+
} catch {
|
|
3701
|
+
}
|
|
3702
|
+
}
|
|
3703
|
+
return maxClearance > 0 ? Math.ceil(maxClearance) : null;
|
|
3704
|
+
}
|
|
3556
3705
|
applyInsetVars(el) {
|
|
3557
3706
|
const { anchor } = this.config;
|
|
3558
3707
|
if (anchor && Object.keys(anchor).length > 0) {
|
|
@@ -3575,13 +3724,20 @@ var MushiWidget = class _MushiWidget {
|
|
|
3575
3724
|
});
|
|
3576
3725
|
el.style.setProperty("--mushi-safe-area", this.config.respectSafeArea ? "1" : "0");
|
|
3577
3726
|
}
|
|
3578
|
-
const isTopAnchored = anchor?.top !== void 0 || this.config.position?.startsWith("top")
|
|
3727
|
+
const isTopAnchored = anchor?.top !== void 0 || this.config.position?.startsWith("top");
|
|
3728
|
+
const isBottomAnchored = anchor?.bottom !== void 0 || this.config.position?.startsWith("bottom") || !this.config.position;
|
|
3579
3729
|
if (isTopAnchored) {
|
|
3580
3730
|
const avoidPx = this.computeAvoidTopPx();
|
|
3581
3731
|
if (avoidPx !== null) {
|
|
3582
3732
|
el.style.setProperty("--mushi-top", `${avoidPx}px`);
|
|
3583
3733
|
}
|
|
3584
3734
|
}
|
|
3735
|
+
if (isBottomAnchored) {
|
|
3736
|
+
const avoidBottomPx = this.computeAvoidBottomPx();
|
|
3737
|
+
if (avoidBottomPx !== null) {
|
|
3738
|
+
el.style.setProperty("--mushi-bottom", `${avoidBottomPx}px`);
|
|
3739
|
+
}
|
|
3740
|
+
}
|
|
3585
3741
|
}
|
|
3586
3742
|
// ─── Draggable FAB ──────────────────────────────────────────────────────────
|
|
3587
3743
|
/** Storage key for the FAB position, scoped to projectId when available. */
|
|
@@ -3818,7 +3974,10 @@ var MushiWidget = class _MushiWidget {
|
|
|
3818
3974
|
resolveCustomCategory: (id) => this.resolveCustomCategory(id),
|
|
3819
3975
|
effectiveMinLength: () => this.effectiveMinLength(),
|
|
3820
3976
|
categoryLabel: (id) => this.categoryLabel(id),
|
|
3821
|
-
categoryIcon: (id) => this.categoryIcon(id)
|
|
3977
|
+
categoryIcon: (id) => this.categoryIcon(id),
|
|
3978
|
+
assistantTurns: this.assistantTurns,
|
|
3979
|
+
assistantSending: this.assistantSending,
|
|
3980
|
+
assistantError: this.assistantError
|
|
3822
3981
|
};
|
|
3823
3982
|
}
|
|
3824
3983
|
attachHandlers(panel) {
|
|
@@ -3847,9 +4006,38 @@ var MushiWidget = class _MushiWidget {
|
|
|
3847
4006
|
this.step = "reports";
|
|
3848
4007
|
} else if (this.step === "roadmap") {
|
|
3849
4008
|
this.step = "category";
|
|
4009
|
+
} else if (this.step === "assistant") {
|
|
4010
|
+
this.step = "category";
|
|
3850
4011
|
}
|
|
3851
4012
|
this.render();
|
|
3852
4013
|
});
|
|
4014
|
+
panel.querySelector('[data-action="assistant"]')?.addEventListener("click", () => {
|
|
4015
|
+
this.openAssistantTab();
|
|
4016
|
+
});
|
|
4017
|
+
panel.querySelectorAll('[data-action="assistant-suggest"]').forEach((btn) => {
|
|
4018
|
+
btn.addEventListener("click", () => {
|
|
4019
|
+
const value = btn.dataset.value;
|
|
4020
|
+
if (value) void this.sendAssistantMessage(value);
|
|
4021
|
+
});
|
|
4022
|
+
});
|
|
4023
|
+
{
|
|
4024
|
+
const form = panel.querySelector('[data-action="assistant-send"]');
|
|
4025
|
+
if (form) {
|
|
4026
|
+
const input = form.querySelector(".mushi-assistant-input");
|
|
4027
|
+
form.addEventListener("submit", (e) => {
|
|
4028
|
+
e.preventDefault();
|
|
4029
|
+
const value = input?.value ?? "";
|
|
4030
|
+
if (input) input.value = "";
|
|
4031
|
+
void this.sendAssistantMessage(value);
|
|
4032
|
+
});
|
|
4033
|
+
input?.addEventListener("keydown", (e) => {
|
|
4034
|
+
if (e.key === "Enter" && !e.shiftKey) {
|
|
4035
|
+
e.preventDefault();
|
|
4036
|
+
form.requestSubmit();
|
|
4037
|
+
}
|
|
4038
|
+
});
|
|
4039
|
+
}
|
|
4040
|
+
}
|
|
3853
4041
|
panel.querySelector('[data-action="reports"]')?.addEventListener("click", () => {
|
|
3854
4042
|
void this.loadReporterReports();
|
|
3855
4043
|
});
|
|
@@ -4737,16 +4925,10 @@ function matchesUrl(url, matcher) {
|
|
|
4737
4925
|
}
|
|
4738
4926
|
function normalizeUrlPrefix(url) {
|
|
4739
4927
|
if (!url) return null;
|
|
4740
|
-
|
|
4741
|
-
|
|
4742
|
-
|
|
4743
|
-
|
|
4744
|
-
try {
|
|
4745
|
-
const parsed = new URL(url);
|
|
4746
|
-
return parsed.hostname === "localhost" || parsed.hostname === "127.0.0.1" || parsed.hostname === "::1" || parsed.hostname.endsWith(".localhost");
|
|
4747
|
-
} catch {
|
|
4748
|
-
return /\blocalhost\b|127\.0\.0\.1/.test(url);
|
|
4749
|
-
}
|
|
4928
|
+
const normalized = normalizeComparableUrl(url);
|
|
4929
|
+
let end = normalized.length;
|
|
4930
|
+
while (end > 0 && normalized.charCodeAt(end - 1) === 47) end--;
|
|
4931
|
+
return normalized.slice(0, end);
|
|
4750
4932
|
}
|
|
4751
4933
|
function normalizeComparableUrl(url) {
|
|
4752
4934
|
try {
|
|
@@ -6329,16 +6511,17 @@ var Mushi = class {
|
|
|
6329
6511
|
createLogger({ scope: "mushi", level: "warn", format: "pretty" }).warn("Already initialized \u2014 call destroy() first to reinitialize");
|
|
6330
6512
|
return instance;
|
|
6331
6513
|
}
|
|
6332
|
-
|
|
6333
|
-
|
|
6514
|
+
const resolved = { ...resolveEnvConfig(), ...config };
|
|
6515
|
+
if (!resolved.projectId) {
|
|
6516
|
+
throw new Error("[mushi] projectId is required \u2014 set NEXT_PUBLIC_MUSHI_PROJECT_ID / VITE_MUSHI_PROJECT_ID / MUSHI_PROJECT_ID or pass it explicitly");
|
|
6334
6517
|
}
|
|
6335
|
-
if (!
|
|
6336
|
-
throw new Error("[mushi] apiKey is required");
|
|
6518
|
+
if (!resolved.apiKey) {
|
|
6519
|
+
throw new Error("[mushi] apiKey is required \u2014 set NEXT_PUBLIC_MUSHI_API_KEY / VITE_MUSHI_API_KEY / MUSHI_API_KEY or pass it explicitly");
|
|
6337
6520
|
}
|
|
6338
|
-
if (
|
|
6521
|
+
if (resolved.enabled === false) {
|
|
6339
6522
|
return createNoopInstance();
|
|
6340
6523
|
}
|
|
6341
|
-
instance = createInstance(
|
|
6524
|
+
instance = createInstance(resolved);
|
|
6342
6525
|
return instance;
|
|
6343
6526
|
}
|
|
6344
6527
|
static getInstance() {
|
|
@@ -6356,10 +6539,13 @@ function createInstance(config) {
|
|
|
6356
6539
|
const bootstrapConfig = applyPresetConfig(config);
|
|
6357
6540
|
let activeConfig = bootstrapConfig;
|
|
6358
6541
|
const log = config.debug ?? false ? createLogger({ scope: "mushi", level: "debug", format: "pretty" }) : noopLogger;
|
|
6542
|
+
let userToken = null;
|
|
6543
|
+
let currentPageContext = null;
|
|
6359
6544
|
const apiClient2 = createApiClient({
|
|
6360
6545
|
projectId: bootstrapConfig.projectId,
|
|
6361
6546
|
apiKey: bootstrapConfig.apiKey,
|
|
6362
|
-
...bootstrapConfig.apiEndpoint ? { apiEndpoint: bootstrapConfig.apiEndpoint } : {}
|
|
6547
|
+
...bootstrapConfig.apiEndpoint ? { apiEndpoint: bootstrapConfig.apiEndpoint } : {},
|
|
6548
|
+
getUserToken: () => userToken
|
|
6363
6549
|
});
|
|
6364
6550
|
const preFilter = createPreFilter(bootstrapConfig.preFilter);
|
|
6365
6551
|
const offlineQueue = createOfflineQueue(bootstrapConfig.offline);
|
|
@@ -6420,12 +6606,12 @@ function createInstance(config) {
|
|
|
6420
6606
|
return;
|
|
6421
6607
|
}
|
|
6422
6608
|
const status = statusResult.data;
|
|
6423
|
-
if (!status.is_tester) {
|
|
6609
|
+
if (!status.is_tester || !status.tester_id) {
|
|
6424
6610
|
clearTesterJwt();
|
|
6425
6611
|
return;
|
|
6426
6612
|
}
|
|
6427
6613
|
widget.setTesterSession(jwt, {
|
|
6428
|
-
id:
|
|
6614
|
+
id: status.tester_id,
|
|
6429
6615
|
public_handle: status.public_handle ?? null,
|
|
6430
6616
|
display_name: status.display_name ?? null
|
|
6431
6617
|
});
|
|
@@ -6778,6 +6964,19 @@ function createInstance(config) {
|
|
|
6778
6964
|
},
|
|
6779
6965
|
onTesterSignOut() {
|
|
6780
6966
|
clearTesterJwt();
|
|
6967
|
+
},
|
|
6968
|
+
// ── Assistant tab (P5) ───────────────────────────────────────────────
|
|
6969
|
+
assistantEnabled: bootstrapConfig.assistant?.enabled === true,
|
|
6970
|
+
...bootstrapConfig.assistant?.label ? { assistantLabel: bootstrapConfig.assistant.label } : {},
|
|
6971
|
+
...bootstrapConfig.assistant?.greeting ? { assistantGreeting: bootstrapConfig.assistant.greeting } : {},
|
|
6972
|
+
...bootstrapConfig.assistant?.suggestions ? { assistantSuggestions: bootstrapConfig.assistant.suggestions } : {},
|
|
6973
|
+
async onAssistantAsk(message, threadId) {
|
|
6974
|
+
const res = await apiClient2.askAssistant({
|
|
6975
|
+
message,
|
|
6976
|
+
threadId,
|
|
6977
|
+
context: currentPageContext
|
|
6978
|
+
});
|
|
6979
|
+
return res.ok ? res.data ?? null : null;
|
|
6781
6980
|
}
|
|
6782
6981
|
}, MUSHI_SDK_VERSION);
|
|
6783
6982
|
syncCaptureModules();
|
|
@@ -6867,8 +7066,8 @@ function createInstance(config) {
|
|
|
6867
7066
|
}).catch((err) => {
|
|
6868
7067
|
log.debug("Runtime SDK config fetch failed", { error: err instanceof Error ? err.message : String(err) });
|
|
6869
7068
|
});
|
|
6870
|
-
} else
|
|
6871
|
-
log.debug("Runtime SDK config
|
|
7069
|
+
} else {
|
|
7070
|
+
log.debug("Runtime SDK config disabled via runtimeConfig:false; using static bootstrap config");
|
|
6872
7071
|
}
|
|
6873
7072
|
void checkSdkFreshness();
|
|
6874
7073
|
log.info("Initialized", { projectId: config.projectId });
|
|
@@ -7323,6 +7522,28 @@ function createInstance(config) {
|
|
|
7323
7522
|
}
|
|
7324
7523
|
}
|
|
7325
7524
|
},
|
|
7525
|
+
identifyWithToken(token) {
|
|
7526
|
+
userToken = token && typeof token === "string" ? token : null;
|
|
7527
|
+
if (userToken) {
|
|
7528
|
+
const claims = parseIdentityToken(userToken);
|
|
7529
|
+
if (claims?.sub) {
|
|
7530
|
+
userInfo = {
|
|
7531
|
+
id: claims.sub,
|
|
7532
|
+
...claims.email ? { email: claims.email } : {},
|
|
7533
|
+
...claims.name ? { name: claims.name } : {}
|
|
7534
|
+
};
|
|
7535
|
+
}
|
|
7536
|
+
breadcrumbs.add({ category: "lifecycle", level: "info", message: "Mushi.identifyWithToken()" });
|
|
7537
|
+
} else {
|
|
7538
|
+
breadcrumbs.add({ category: "lifecycle", level: "info", message: "Mushi.identifyWithToken(null)" });
|
|
7539
|
+
}
|
|
7540
|
+
},
|
|
7541
|
+
publishPageContext(context) {
|
|
7542
|
+
currentPageContext = context && context.route ? context : null;
|
|
7543
|
+
},
|
|
7544
|
+
openAssistant() {
|
|
7545
|
+
widget.openAssistantTab();
|
|
7546
|
+
},
|
|
7326
7547
|
addBreadcrumb(crumb) {
|
|
7327
7548
|
breadcrumbs.add(crumb);
|
|
7328
7549
|
},
|
|
@@ -7446,6 +7667,9 @@ function mergeRuntimeConfig(config, runtime) {
|
|
|
7446
7667
|
const nativeTrigger = runtime.native?.triggerMode;
|
|
7447
7668
|
const runtimeLauncher = runtime.widget?.launcher;
|
|
7448
7669
|
const widgetTrigger = runtimeLauncher ?? runtime.widget?.trigger ?? (nativeTrigger === "none" || nativeTrigger === "shake" ? "manual" : void 0);
|
|
7670
|
+
const explicitHidden = runtimeLauncher === "hidden" || runtime.widget?.trigger === "hidden";
|
|
7671
|
+
const hostTrigger = config.widget?.trigger;
|
|
7672
|
+
const safeWidgetTrigger = widgetTrigger === "hidden" && !explicitHidden && hostTrigger && hostTrigger !== "hidden" ? hostTrigger : widgetTrigger;
|
|
7449
7673
|
const runtimeWidget = runtime.widget;
|
|
7450
7674
|
const runtimeBannerVariant = runtimeWidget?.bannerVariant;
|
|
7451
7675
|
const runtimeBannerPosition = runtimeWidget?.bannerPosition;
|
|
@@ -7469,7 +7693,7 @@ function mergeRuntimeConfig(config, runtime) {
|
|
|
7469
7693
|
widget: {
|
|
7470
7694
|
...config.widget,
|
|
7471
7695
|
...runtime.widget,
|
|
7472
|
-
...
|
|
7696
|
+
...safeWidgetTrigger ? { trigger: safeWidgetTrigger } : {},
|
|
7473
7697
|
...derivedBannerConfig ? { bannerConfig: derivedBannerConfig } : {},
|
|
7474
7698
|
// betaMode is local-only: set by the host app, not the dashboard.
|
|
7475
7699
|
// Restore it after the runtime spread so it is never silently cleared.
|
|
@@ -7545,9 +7769,7 @@ function resolveApiEndpoint(config) {
|
|
|
7545
7769
|
return config.apiEndpoint ?? DEFAULT_API_ENDPOINT;
|
|
7546
7770
|
}
|
|
7547
7771
|
function shouldUseRuntimeConfig(config) {
|
|
7548
|
-
|
|
7549
|
-
if (config.runtimeConfig === true) return true;
|
|
7550
|
-
return !isLocalhostEndpoint(resolveApiEndpoint(config));
|
|
7772
|
+
return config.runtimeConfig !== false;
|
|
7551
7773
|
}
|
|
7552
7774
|
async function runDiagnostics(options) {
|
|
7553
7775
|
const endpoint = await probeApiEndpoint(options.apiEndpoint);
|
|
@@ -7709,6 +7931,12 @@ function createNoopInstance() {
|
|
|
7709
7931
|
captureException: async () => null,
|
|
7710
7932
|
identify: () => {
|
|
7711
7933
|
},
|
|
7934
|
+
identifyWithToken: () => {
|
|
7935
|
+
},
|
|
7936
|
+
publishPageContext: () => {
|
|
7937
|
+
},
|
|
7938
|
+
openAssistant: () => {
|
|
7939
|
+
},
|
|
7712
7940
|
addBreadcrumb: () => {
|
|
7713
7941
|
},
|
|
7714
7942
|
getBreadcrumbs: () => [],
|