@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/CONTRIBUTING.md
CHANGED
|
@@ -58,12 +58,12 @@ packages/
|
|
|
58
58
|
react-native/ React Native SDK (MIT)
|
|
59
59
|
cli/ CLI tool (MIT)
|
|
60
60
|
mcp/ MCP server for coding agents (MIT)
|
|
61
|
-
server/ Supabase Edge Functions (
|
|
62
|
-
agents/ Agentic fix pipeline (
|
|
63
|
-
verify/ Fix verification (
|
|
61
|
+
server/ Supabase Edge Functions (AGPLv3)
|
|
62
|
+
agents/ Agentic fix pipeline (AGPLv3)
|
|
63
|
+
verify/ Fix verification (AGPLv3)
|
|
64
64
|
apps/
|
|
65
65
|
admin/ Admin dashboard (React + Tailwind)
|
|
66
|
-
docs/ Documentation site (
|
|
66
|
+
docs/ Documentation site (Nextra — apps/docs)
|
|
67
67
|
tooling/
|
|
68
68
|
eslint-config/ Shared ESLint flat config
|
|
69
69
|
tsconfig/ Shared TypeScript configs
|
|
@@ -81,6 +81,30 @@ tooling/
|
|
|
81
81
|
```
|
|
82
82
|
6. Open a pull request
|
|
83
83
|
|
|
84
|
+
### Documentation (docs-as-code)
|
|
85
|
+
|
|
86
|
+
If your PR changes **user-visible SDK or CLI behavior**, update docs in the **same PR**:
|
|
87
|
+
|
|
88
|
+
| Surface | When to update |
|
|
89
|
+
| --- | --- |
|
|
90
|
+
| `packages/*/README.md` | npm-facing install/API/config changes for that package |
|
|
91
|
+
| `apps/docs/content/**/*.mdx` | Long-form guides, quickstarts, admin console docs |
|
|
92
|
+
| Root `README.md` | Marketing stats only when counts change — run `pnpm check:docs-stats` |
|
|
93
|
+
|
|
94
|
+
Guardrails (run locally before pushing):
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
pnpm check:docs-stats # root README stat badges
|
|
98
|
+
pnpm check:sdk-version-matrix # apps/docs/content/sdks/index.mdx versions
|
|
99
|
+
pnpm check:internal-doc-links # dead /foo links in MDX
|
|
100
|
+
pnpm check:onboarding-drift # phantom MCP env vars / stale tool names
|
|
101
|
+
pnpm check:bundle-docs # @mushi-mushi/web size-limit vs README
|
|
102
|
+
pnpm gen:llms-txt # regenerate apps/docs/public/llms.txt after nav changes
|
|
103
|
+
pnpm gen:mcp-tools-doc # regenerate sdks/mcp-tools.generated.mdx from catalog.ts
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
README changes on npm packages only appear on [npmjs.com](https://www.npmjs.com) after the next **Changesets publish**.
|
|
107
|
+
|
|
84
108
|
## Changesets
|
|
85
109
|
|
|
86
110
|
We use [Changesets](https://github.com/changesets/changesets) for versioning. If your PR modifies a published package (`core`, `web`, `react`, `vue`, `svelte`, `angular`, `react-native`, `cli`, `mcp`), add a changeset:
|
|
@@ -93,13 +117,30 @@ Select the affected packages, the semver bump type, and write a summary. The cha
|
|
|
93
117
|
|
|
94
118
|
## Release flow
|
|
95
119
|
|
|
96
|
-
Releases are fully automated. Maintainers don't run
|
|
120
|
+
Releases are fully automated once the version PR is merged. Maintainers don't run
|
|
121
|
+
`npm publish` by hand for routine bumps. See **[`docs/DEPLOYMENT.md`](docs/DEPLOYMENT.md)**
|
|
122
|
+
for the full production runbook (edge functions, admin SPA, docs site, migrations).
|
|
97
123
|
|
|
98
124
|
1. PRs land on `master` with one or more changeset files in `.changeset/`.
|
|
99
|
-
|
|
100
|
-
|
|
125
|
+
Orphaned changesets (only ignored packages) fail `pnpm check:changeset-orphans`.
|
|
126
|
+
2. `release.yml` runs on every push to `master`. It opens (or updates) a
|
|
127
|
+
**`chore: version packages`** PR on `changeset-release/master` that bumps
|
|
128
|
+
affected `package.json` files, rolls up changelogs, and deletes consumed
|
|
129
|
+
changesets.
|
|
130
|
+
3. **Wait for CI on the version PR.** If checks don't appear (bot-branch
|
|
131
|
+
suppression), push an empty commit to `changeset-release/master`. If
|
|
132
|
+
`check:sdk-version-matrix` fails, run `pnpm gen:sdk-version-matrix` on that
|
|
133
|
+
branch and commit `apps/docs/content/sdks/index.mdx`.
|
|
134
|
+
4. Merge the version PR. The publish step uses **OIDC Trusted Publishers** +
|
|
135
|
+
Sigstore provenance (with `NPM_TOKEN` only for brand-new package bootstrap).
|
|
136
|
+
5. **Manually dispatch Release** unless a run starts within ~2 minutes:
|
|
137
|
+
**Actions → Release → Run workflow → `master`**. Squash-merges attributed to
|
|
138
|
+
`github-actions[bot]` usually suppress the auto `push` trigger — manual
|
|
139
|
+
dispatch is the normal path, not a fallback of last resort.
|
|
101
140
|
|
|
102
|
-
|
|
141
|
+
```bash
|
|
142
|
+
gh workflow run release.yml --ref master
|
|
143
|
+
```
|
|
103
144
|
|
|
104
145
|
### Adding a brand-new publishable package
|
|
105
146
|
|
|
@@ -146,7 +187,7 @@ chore: bump dependencies
|
|
|
146
187
|
## License
|
|
147
188
|
|
|
148
189
|
- SDK packages are MIT — your contributions will be MIT-licensed
|
|
149
|
-
- Server/agents/verify are
|
|
190
|
+
- Server/agents/verify are AGPLv3 — contributions to those packages fall under AGPLv3
|
|
150
191
|
|
|
151
192
|
## Questions?
|
|
152
193
|
|
package/README.md
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
# @mushi-mushi/web
|
|
2
2
|
|
|
3
|
+
> **Your AI wrote it. Mushi tells you why it broke.**
|
|
4
|
+
> Plain-English diagnosis + a paste-ready fix, right inside Cursor. MIT-licensed SDKs · self-hostable · no second LLM key.
|
|
5
|
+
|
|
3
6
|
Browser SDK for Mushi Mushi — embeddable bug reporting widget with Shadow DOM isolation.
|
|
4
7
|
|
|
5
8
|
> **One-command setup:** `npx mushi-mushi` installs this package for vanilla-JS apps (or alongside the framework SDK for Vue, Svelte, Angular).
|
|
@@ -85,7 +88,7 @@ Each trigger respects its config flag — set `rageClick: false` to disable rage
|
|
|
85
88
|
|
|
86
89
|
## Bundle Size
|
|
87
90
|
|
|
88
|
-
~7 KB brotli, enforced at **
|
|
91
|
+
~7 KB brotli, enforced at **70 KB gzipped** (105 KB uncompressed) via `size-limit` in CI — budget raised for the 2026 editorial widget refresh. Requires `@mushi-mushi/core` as a dependency (not bundled inline). The `./test-utils` entry is a separate artifact and is never pulled into production bundles.
|
|
89
92
|
|
|
90
93
|
## Quick Start
|
|
91
94
|
|
package/dist/index.cjs
CHANGED
|
@@ -481,8 +481,8 @@ function getWidgetStyles(theme, accent = "", accentText = "") {
|
|
|
481
481
|
|
|
482
482
|
@keyframes mushi-pulse {
|
|
483
483
|
0% { box-shadow: 0 0 0 0 ${widgetAccent}; opacity: 1; }
|
|
484
|
-
70% { box-shadow: 0 0 0 8px
|
|
485
|
-
100% { box-shadow: 0 0 0 0
|
|
484
|
+
70% { box-shadow: 0 0 0 8px ${widgetAccent}00; opacity: 0.5; }
|
|
485
|
+
100% { box-shadow: 0 0 0 0 ${widgetAccent}00; opacity: 1; }
|
|
486
486
|
}
|
|
487
487
|
|
|
488
488
|
.mushi-panel {
|
|
@@ -1628,12 +1628,18 @@ function getWidgetStyles(theme, accent = "", accentText = "") {
|
|
|
1628
1628
|
position: fixed;
|
|
1629
1629
|
left: 0;
|
|
1630
1630
|
right: 0;
|
|
1631
|
-
height
|
|
1631
|
+
/* min-height (not fixed height) + border-box so the safe-area padding
|
|
1632
|
+
below extends the bar into the notch/home-indicator zone instead of
|
|
1633
|
+
letting content bleed under the status bar (mobile safe-area bleed
|
|
1634
|
+
fix \u2014 Workstream C). Horizontal padding also clears the left/right
|
|
1635
|
+
insets for landscape notches. */
|
|
1636
|
+
box-sizing: border-box;
|
|
1637
|
+
min-height: 36px;
|
|
1632
1638
|
display: flex;
|
|
1633
1639
|
align-items: center;
|
|
1634
1640
|
justify-content: center;
|
|
1635
1641
|
gap: 10px;
|
|
1636
|
-
padding: 0 16px;
|
|
1642
|
+
padding: 0 calc(16px + env(safe-area-inset-right, 0px)) 0 calc(16px + env(safe-area-inset-left, 0px));
|
|
1637
1643
|
font-family: ${fontMono};
|
|
1638
1644
|
font-size: 12px;
|
|
1639
1645
|
letter-spacing: 0.04em;
|
|
@@ -1643,8 +1649,8 @@ function getWidgetStyles(theme, accent = "", accentText = "") {
|
|
|
1643
1649
|
animation: mushi-banner-slide-in 0.3s ${easeStamp} both;
|
|
1644
1650
|
}
|
|
1645
1651
|
|
|
1646
|
-
.mushi-banner.top { top: 0; }
|
|
1647
|
-
.mushi-banner.bottom { bottom: 0; }
|
|
1652
|
+
.mushi-banner.top { top: 0; padding-top: env(safe-area-inset-top, 0px); }
|
|
1653
|
+
.mushi-banner.bottom { bottom: 0; padding-bottom: env(safe-area-inset-bottom, 0px); }
|
|
1648
1654
|
|
|
1649
1655
|
/* --- neon variant (electric lime \u2014 dev / beta tool aesthetic) --- */
|
|
1650
1656
|
.mushi-banner.neon {
|
|
@@ -1896,12 +1902,33 @@ function getWidgetStyles(theme, accent = "", accentText = "") {
|
|
|
1896
1902
|
.mushi-xapp-app-name{font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:.06em;margin:0 0 6px}
|
|
1897
1903
|
.mushi-xapp-group{margin-bottom:14px}
|
|
1898
1904
|
.mushi-label{display:block;font-weight:600;margin-bottom:6px}
|
|
1905
|
+
|
|
1906
|
+
/* \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 */
|
|
1907
|
+
.mushi-assistant{display:flex;flex-direction:column;height:100%;min-height:0;max-height:60vh}
|
|
1908
|
+
.mushi-assistant-log{flex:1;min-height:120px;overflow-y:auto;display:flex;flex-direction:column;gap:8px;padding:4px 2px 8px}
|
|
1909
|
+
.mushi-assistant-greeting{font:400 14px/1.5 ${fontBody};color:${inkMuted};padding:6px 2px}
|
|
1910
|
+
.mushi-assistant-suggestions{display:flex;flex-wrap:wrap;gap:6px;margin-top:4px}
|
|
1911
|
+
.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}
|
|
1912
|
+
.mushi-assistant-chip:hover{background:${isDark ? "rgba(255,90,71,0.22)" : "rgba(224,60,44,0.14)"}}
|
|
1913
|
+
.mushi-assistant-chip:focus-visible{outline:2px solid ${widgetAccent};outline-offset:2px}
|
|
1914
|
+
.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}
|
|
1915
|
+
.mushi-assistant-msg-user{align-self:flex-end;background:${widgetAccent};color:#fff;border-bottom-right-radius:4px}
|
|
1916
|
+
.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}
|
|
1917
|
+
.mushi-assistant-thinking{opacity:0.6;font-size:18px;letter-spacing:2px}
|
|
1918
|
+
.mushi-assistant-error{align-self:flex-start;color:${isDark ? "#F87171" : "#DC2626"};font-size:12px;padding:4px 2px}
|
|
1919
|
+
.mushi-assistant-form{display:flex;align-items:flex-end;gap:8px;border-top:1px solid ${rule};padding-top:8px}
|
|
1920
|
+
.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}}
|
|
1921
|
+
.mushi-assistant-input:focus-visible{outline:2px solid ${widgetAccent};outline-offset:1px}
|
|
1922
|
+
.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}
|
|
1923
|
+
.mushi-assistant-submit:hover{transform:translateY(-1px)}
|
|
1924
|
+
.mushi-assistant-submit:disabled{opacity:0.5;cursor:default;transform:none}
|
|
1925
|
+
.mushi-assistant-submit:focus-visible{outline:2px solid ${widgetAccent};outline-offset:2px}
|
|
1899
1926
|
`;
|
|
1900
1927
|
}
|
|
1901
1928
|
|
|
1902
1929
|
// src/version.ts
|
|
1903
1930
|
var MUSHI_SDK_PACKAGE = "@mushi-mushi/web";
|
|
1904
|
-
var MUSHI_SDK_VERSION = "1.
|
|
1931
|
+
var MUSHI_SDK_VERSION = "1.16.0" ;
|
|
1905
1932
|
|
|
1906
1933
|
// src/widget-helpers.ts
|
|
1907
1934
|
var CATEGORY_ICONS = {
|
|
@@ -2047,8 +2074,43 @@ function renderStep(ctx) {
|
|
|
2047
2074
|
return renderAccountStep(ctx);
|
|
2048
2075
|
case "cross-app-reports":
|
|
2049
2076
|
return renderCrossAppReportsStep(ctx);
|
|
2077
|
+
case "assistant":
|
|
2078
|
+
return renderAssistantStep(ctx);
|
|
2050
2079
|
}
|
|
2051
2080
|
}
|
|
2081
|
+
function renderAssistantStep(ctx) {
|
|
2082
|
+
const label = ctx.callbacks.assistantLabel || "Ask";
|
|
2083
|
+
const greeting = ctx.callbacks.assistantGreeting || "Ask me anything about this app.";
|
|
2084
|
+
const suggestions = ctx.callbacks.assistantSuggestions ?? [];
|
|
2085
|
+
const empty = ctx.assistantTurns.length === 0;
|
|
2086
|
+
const transcript = empty ? `<div class="mushi-assistant-greeting">${escapeHtml(greeting)}</div>
|
|
2087
|
+
${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) => {
|
|
2088
|
+
const cls = turn.role === "user" ? "mushi-assistant-msg-user" : "mushi-assistant-msg-bot";
|
|
2089
|
+
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>` : "";
|
|
2090
|
+
return `<div class="mushi-assistant-msg ${cls}">${escapeHtml(turn.text)}</div>${opts}`;
|
|
2091
|
+
}).join("");
|
|
2092
|
+
const thinking = ctx.assistantSending ? `<div class="mushi-assistant-msg mushi-assistant-msg-bot mushi-assistant-thinking">\u2026</div>` : "";
|
|
2093
|
+
const error = ctx.assistantError ? `<div class="mushi-assistant-error" role="alert">${escapeHtml(ctx.assistantError)}</div>` : "";
|
|
2094
|
+
return `
|
|
2095
|
+
${renderHeader(ctx, { title: label, showBack: true })}
|
|
2096
|
+
<div class="mushi-assistant">
|
|
2097
|
+
<div class="mushi-assistant-log">
|
|
2098
|
+
${transcript}
|
|
2099
|
+
${thinking}
|
|
2100
|
+
${error}
|
|
2101
|
+
</div>
|
|
2102
|
+
<form class="mushi-assistant-form" data-action="assistant-send">
|
|
2103
|
+
<textarea
|
|
2104
|
+
class="mushi-assistant-input"
|
|
2105
|
+
rows="1"
|
|
2106
|
+
placeholder="Type your question\u2026"
|
|
2107
|
+
${ctx.assistantSending ? "disabled" : ""}
|
|
2108
|
+
></textarea>
|
|
2109
|
+
<button type="submit" class="mushi-assistant-submit" ${ctx.assistantSending ? "disabled" : ""} aria-label="Send">\u2191</button>
|
|
2110
|
+
</form>
|
|
2111
|
+
</div>
|
|
2112
|
+
`;
|
|
2113
|
+
}
|
|
2052
2114
|
function renderOutdatedBanner(ctx) {
|
|
2053
2115
|
if (!ctx.sdkFreshness) return "";
|
|
2054
2116
|
if (ctx.config.outdatedBanner === "off" || ctx.config.outdatedBanner === "console-only") return "";
|
|
@@ -2668,7 +2730,6 @@ function renderSuccessRewards(ctx) {
|
|
|
2668
2730
|
|
|
2669
2731
|
// src/widget.ts
|
|
2670
2732
|
var MushiWidget = class _MushiWidget {
|
|
2671
|
-
// double-submit guard
|
|
2672
2733
|
constructor(config = {}, callbacks, sdkVersion = MUSHI_SDK_VERSION) {
|
|
2673
2734
|
this.sdkVersion = sdkVersion;
|
|
2674
2735
|
this.config = {
|
|
@@ -2813,6 +2874,12 @@ var MushiWidget = class _MushiWidget {
|
|
|
2813
2874
|
magicLinkEmail = "";
|
|
2814
2875
|
magicLinkError = "";
|
|
2815
2876
|
magicLinkSending = false;
|
|
2877
|
+
// double-submit guard
|
|
2878
|
+
// ─── Assistant tab (P5) ──────────────────────────────────────────
|
|
2879
|
+
assistantTurns = [];
|
|
2880
|
+
assistantThreadId = null;
|
|
2881
|
+
assistantSending = false;
|
|
2882
|
+
assistantError = null;
|
|
2816
2883
|
mount() {
|
|
2817
2884
|
if (this.host.isConnected) return;
|
|
2818
2885
|
this.syncHostChromeState();
|
|
@@ -2916,10 +2983,18 @@ var MushiWidget = class _MushiWidget {
|
|
|
2916
2983
|
this.viaFeatureRequest = true;
|
|
2917
2984
|
this.step = "details";
|
|
2918
2985
|
} else if (options?.category) {
|
|
2919
|
-
this.selectedCategory = options.category;
|
|
2920
|
-
this.selectedIntent = null;
|
|
2921
2986
|
const custom = this.resolveCustomCategory(options.category);
|
|
2922
|
-
|
|
2987
|
+
const builtIn = ["bug", "slow", "visual", "confusing", "other"];
|
|
2988
|
+
const isKnown = builtIn.includes(options.category) || custom !== void 0;
|
|
2989
|
+
if (!isKnown) {
|
|
2990
|
+
this.selectedCategory = null;
|
|
2991
|
+
this.selectedIntent = null;
|
|
2992
|
+
this.step = "category";
|
|
2993
|
+
} else {
|
|
2994
|
+
this.selectedCategory = options.category;
|
|
2995
|
+
this.selectedIntent = null;
|
|
2996
|
+
this.step = custom && (!custom.intents || custom.intents.length === 0) ? "details" : "intent";
|
|
2997
|
+
}
|
|
2923
2998
|
} else {
|
|
2924
2999
|
this.selectedCategory = null;
|
|
2925
3000
|
this.selectedIntent = null;
|
|
@@ -2934,6 +3009,58 @@ var MushiWidget = class _MushiWidget {
|
|
|
2934
3009
|
this.render();
|
|
2935
3010
|
this.callbacks.onClose();
|
|
2936
3011
|
}
|
|
3012
|
+
/** Open the panel directly on the assistant ("Ask") tab. */
|
|
3013
|
+
openAssistantTab() {
|
|
3014
|
+
if (!this.callbacks.assistantEnabled) {
|
|
3015
|
+
this.open();
|
|
3016
|
+
return;
|
|
3017
|
+
}
|
|
3018
|
+
if (!this.isOpen) {
|
|
3019
|
+
this.isOpen = true;
|
|
3020
|
+
this.callbacks.onOpen();
|
|
3021
|
+
}
|
|
3022
|
+
this.step = "assistant";
|
|
3023
|
+
this.assistantError = null;
|
|
3024
|
+
this.render();
|
|
3025
|
+
setTimeout(() => {
|
|
3026
|
+
this.shadow.querySelector(".mushi-assistant-input")?.focus();
|
|
3027
|
+
}, 0);
|
|
3028
|
+
}
|
|
3029
|
+
/** Send one assistant turn and re-render as the reply streams back. */
|
|
3030
|
+
async sendAssistantMessage(message) {
|
|
3031
|
+
const text = message.trim();
|
|
3032
|
+
if (!text || this.assistantSending || !this.callbacks.onAssistantAsk) return;
|
|
3033
|
+
this.assistantSending = true;
|
|
3034
|
+
this.assistantError = null;
|
|
3035
|
+
this.assistantTurns.push({ role: "user", text });
|
|
3036
|
+
this.render();
|
|
3037
|
+
try {
|
|
3038
|
+
const reply = await this.callbacks.onAssistantAsk(text, this.assistantThreadId);
|
|
3039
|
+
if (reply) {
|
|
3040
|
+
if (reply.threadId) this.assistantThreadId = reply.threadId;
|
|
3041
|
+
if (reply.kind === "clarify") {
|
|
3042
|
+
this.assistantTurns.push({
|
|
3043
|
+
role: "assistant",
|
|
3044
|
+
text: reply.question ?? "Could you tell me a bit more?",
|
|
3045
|
+
...reply.options && reply.options.length ? { options: reply.options } : {}
|
|
3046
|
+
});
|
|
3047
|
+
} else {
|
|
3048
|
+
this.assistantTurns.push({ role: "assistant", text: reply.text ?? "\u2026" });
|
|
3049
|
+
}
|
|
3050
|
+
} else {
|
|
3051
|
+
this.assistantError = "No response \u2014 please try again.";
|
|
3052
|
+
}
|
|
3053
|
+
} catch {
|
|
3054
|
+
this.assistantError = "Something went wrong. Please try again.";
|
|
3055
|
+
} finally {
|
|
3056
|
+
this.assistantSending = false;
|
|
3057
|
+
this.render();
|
|
3058
|
+
setTimeout(() => {
|
|
3059
|
+
const log = this.shadow.querySelector(".mushi-assistant-log");
|
|
3060
|
+
if (log) log.scrollTop = log.scrollHeight;
|
|
3061
|
+
}, 0);
|
|
3062
|
+
}
|
|
3063
|
+
}
|
|
2937
3064
|
/**
|
|
2938
3065
|
* Briefly highlight the trigger button (a soft pulse + tooltip) without
|
|
2939
3066
|
* opening the full reporter panel. Use for first-session welcome nudges
|
|
@@ -3555,6 +3682,28 @@ var MushiWidget = class _MushiWidget {
|
|
|
3555
3682
|
}
|
|
3556
3683
|
return maxBottom > 0 ? Math.ceil(maxBottom) + gap : null;
|
|
3557
3684
|
}
|
|
3685
|
+
/**
|
|
3686
|
+
* Minimum bottom-offset in px so a bottom-anchored trigger clears avoided
|
|
3687
|
+
* elements (tab bars, fixed CTAs). Mirrors {@link computeAvoidTopPx}.
|
|
3688
|
+
*/
|
|
3689
|
+
computeAvoidBottomPx(gap = 8) {
|
|
3690
|
+
const sels = this.config.avoidSelectors;
|
|
3691
|
+
if (!sels?.length) return null;
|
|
3692
|
+
let maxClearance = 0;
|
|
3693
|
+
for (const sel of sels) {
|
|
3694
|
+
try {
|
|
3695
|
+
const el = document.querySelector(sel);
|
|
3696
|
+
if (!el) continue;
|
|
3697
|
+
const r = el.getBoundingClientRect();
|
|
3698
|
+
if (r.width > 0 && r.height > 0) {
|
|
3699
|
+
const clearance = window.innerHeight - r.top + gap;
|
|
3700
|
+
if (clearance > maxClearance) maxClearance = clearance;
|
|
3701
|
+
}
|
|
3702
|
+
} catch {
|
|
3703
|
+
}
|
|
3704
|
+
}
|
|
3705
|
+
return maxClearance > 0 ? Math.ceil(maxClearance) : null;
|
|
3706
|
+
}
|
|
3558
3707
|
applyInsetVars(el) {
|
|
3559
3708
|
const { anchor } = this.config;
|
|
3560
3709
|
if (anchor && Object.keys(anchor).length > 0) {
|
|
@@ -3577,13 +3726,20 @@ var MushiWidget = class _MushiWidget {
|
|
|
3577
3726
|
});
|
|
3578
3727
|
el.style.setProperty("--mushi-safe-area", this.config.respectSafeArea ? "1" : "0");
|
|
3579
3728
|
}
|
|
3580
|
-
const isTopAnchored = anchor?.top !== void 0 || this.config.position?.startsWith("top")
|
|
3729
|
+
const isTopAnchored = anchor?.top !== void 0 || this.config.position?.startsWith("top");
|
|
3730
|
+
const isBottomAnchored = anchor?.bottom !== void 0 || this.config.position?.startsWith("bottom") || !this.config.position;
|
|
3581
3731
|
if (isTopAnchored) {
|
|
3582
3732
|
const avoidPx = this.computeAvoidTopPx();
|
|
3583
3733
|
if (avoidPx !== null) {
|
|
3584
3734
|
el.style.setProperty("--mushi-top", `${avoidPx}px`);
|
|
3585
3735
|
}
|
|
3586
3736
|
}
|
|
3737
|
+
if (isBottomAnchored) {
|
|
3738
|
+
const avoidBottomPx = this.computeAvoidBottomPx();
|
|
3739
|
+
if (avoidBottomPx !== null) {
|
|
3740
|
+
el.style.setProperty("--mushi-bottom", `${avoidBottomPx}px`);
|
|
3741
|
+
}
|
|
3742
|
+
}
|
|
3587
3743
|
}
|
|
3588
3744
|
// ─── Draggable FAB ──────────────────────────────────────────────────────────
|
|
3589
3745
|
/** Storage key for the FAB position, scoped to projectId when available. */
|
|
@@ -3820,7 +3976,10 @@ var MushiWidget = class _MushiWidget {
|
|
|
3820
3976
|
resolveCustomCategory: (id) => this.resolveCustomCategory(id),
|
|
3821
3977
|
effectiveMinLength: () => this.effectiveMinLength(),
|
|
3822
3978
|
categoryLabel: (id) => this.categoryLabel(id),
|
|
3823
|
-
categoryIcon: (id) => this.categoryIcon(id)
|
|
3979
|
+
categoryIcon: (id) => this.categoryIcon(id),
|
|
3980
|
+
assistantTurns: this.assistantTurns,
|
|
3981
|
+
assistantSending: this.assistantSending,
|
|
3982
|
+
assistantError: this.assistantError
|
|
3824
3983
|
};
|
|
3825
3984
|
}
|
|
3826
3985
|
attachHandlers(panel) {
|
|
@@ -3849,9 +4008,38 @@ var MushiWidget = class _MushiWidget {
|
|
|
3849
4008
|
this.step = "reports";
|
|
3850
4009
|
} else if (this.step === "roadmap") {
|
|
3851
4010
|
this.step = "category";
|
|
4011
|
+
} else if (this.step === "assistant") {
|
|
4012
|
+
this.step = "category";
|
|
3852
4013
|
}
|
|
3853
4014
|
this.render();
|
|
3854
4015
|
});
|
|
4016
|
+
panel.querySelector('[data-action="assistant"]')?.addEventListener("click", () => {
|
|
4017
|
+
this.openAssistantTab();
|
|
4018
|
+
});
|
|
4019
|
+
panel.querySelectorAll('[data-action="assistant-suggest"]').forEach((btn) => {
|
|
4020
|
+
btn.addEventListener("click", () => {
|
|
4021
|
+
const value = btn.dataset.value;
|
|
4022
|
+
if (value) void this.sendAssistantMessage(value);
|
|
4023
|
+
});
|
|
4024
|
+
});
|
|
4025
|
+
{
|
|
4026
|
+
const form = panel.querySelector('[data-action="assistant-send"]');
|
|
4027
|
+
if (form) {
|
|
4028
|
+
const input = form.querySelector(".mushi-assistant-input");
|
|
4029
|
+
form.addEventListener("submit", (e) => {
|
|
4030
|
+
e.preventDefault();
|
|
4031
|
+
const value = input?.value ?? "";
|
|
4032
|
+
if (input) input.value = "";
|
|
4033
|
+
void this.sendAssistantMessage(value);
|
|
4034
|
+
});
|
|
4035
|
+
input?.addEventListener("keydown", (e) => {
|
|
4036
|
+
if (e.key === "Enter" && !e.shiftKey) {
|
|
4037
|
+
e.preventDefault();
|
|
4038
|
+
form.requestSubmit();
|
|
4039
|
+
}
|
|
4040
|
+
});
|
|
4041
|
+
}
|
|
4042
|
+
}
|
|
3855
4043
|
panel.querySelector('[data-action="reports"]')?.addEventListener("click", () => {
|
|
3856
4044
|
void this.loadReporterReports();
|
|
3857
4045
|
});
|
|
@@ -4739,16 +4927,10 @@ function matchesUrl(url, matcher) {
|
|
|
4739
4927
|
}
|
|
4740
4928
|
function normalizeUrlPrefix(url) {
|
|
4741
4929
|
if (!url) return null;
|
|
4742
|
-
|
|
4743
|
-
|
|
4744
|
-
|
|
4745
|
-
|
|
4746
|
-
try {
|
|
4747
|
-
const parsed = new URL(url);
|
|
4748
|
-
return parsed.hostname === "localhost" || parsed.hostname === "127.0.0.1" || parsed.hostname === "::1" || parsed.hostname.endsWith(".localhost");
|
|
4749
|
-
} catch {
|
|
4750
|
-
return /\blocalhost\b|127\.0\.0\.1/.test(url);
|
|
4751
|
-
}
|
|
4930
|
+
const normalized = normalizeComparableUrl(url);
|
|
4931
|
+
let end = normalized.length;
|
|
4932
|
+
while (end > 0 && normalized.charCodeAt(end - 1) === 47) end--;
|
|
4933
|
+
return normalized.slice(0, end);
|
|
4752
4934
|
}
|
|
4753
4935
|
function normalizeComparableUrl(url) {
|
|
4754
4936
|
try {
|
|
@@ -6331,16 +6513,17 @@ var Mushi = class {
|
|
|
6331
6513
|
core.createLogger({ scope: "mushi", level: "warn", format: "pretty" }).warn("Already initialized \u2014 call destroy() first to reinitialize");
|
|
6332
6514
|
return instance;
|
|
6333
6515
|
}
|
|
6334
|
-
|
|
6335
|
-
|
|
6516
|
+
const resolved = { ...core.resolveEnvConfig(), ...config };
|
|
6517
|
+
if (!resolved.projectId) {
|
|
6518
|
+
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");
|
|
6336
6519
|
}
|
|
6337
|
-
if (!
|
|
6338
|
-
throw new Error("[mushi] apiKey is required");
|
|
6520
|
+
if (!resolved.apiKey) {
|
|
6521
|
+
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");
|
|
6339
6522
|
}
|
|
6340
|
-
if (
|
|
6523
|
+
if (resolved.enabled === false) {
|
|
6341
6524
|
return createNoopInstance();
|
|
6342
6525
|
}
|
|
6343
|
-
instance = createInstance(
|
|
6526
|
+
instance = createInstance(resolved);
|
|
6344
6527
|
return instance;
|
|
6345
6528
|
}
|
|
6346
6529
|
static getInstance() {
|
|
@@ -6358,10 +6541,13 @@ function createInstance(config) {
|
|
|
6358
6541
|
const bootstrapConfig = applyPresetConfig(config);
|
|
6359
6542
|
let activeConfig = bootstrapConfig;
|
|
6360
6543
|
const log = config.debug ?? false ? core.createLogger({ scope: "mushi", level: "debug", format: "pretty" }) : core.noopLogger;
|
|
6544
|
+
let userToken = null;
|
|
6545
|
+
let currentPageContext = null;
|
|
6361
6546
|
const apiClient2 = core.createApiClient({
|
|
6362
6547
|
projectId: bootstrapConfig.projectId,
|
|
6363
6548
|
apiKey: bootstrapConfig.apiKey,
|
|
6364
|
-
...bootstrapConfig.apiEndpoint ? { apiEndpoint: bootstrapConfig.apiEndpoint } : {}
|
|
6549
|
+
...bootstrapConfig.apiEndpoint ? { apiEndpoint: bootstrapConfig.apiEndpoint } : {},
|
|
6550
|
+
getUserToken: () => userToken
|
|
6365
6551
|
});
|
|
6366
6552
|
const preFilter = core.createPreFilter(bootstrapConfig.preFilter);
|
|
6367
6553
|
const offlineQueue = core.createOfflineQueue(bootstrapConfig.offline);
|
|
@@ -6422,12 +6608,12 @@ function createInstance(config) {
|
|
|
6422
6608
|
return;
|
|
6423
6609
|
}
|
|
6424
6610
|
const status = statusResult.data;
|
|
6425
|
-
if (!status.is_tester) {
|
|
6611
|
+
if (!status.is_tester || !status.tester_id) {
|
|
6426
6612
|
clearTesterJwt();
|
|
6427
6613
|
return;
|
|
6428
6614
|
}
|
|
6429
6615
|
widget.setTesterSession(jwt, {
|
|
6430
|
-
id:
|
|
6616
|
+
id: status.tester_id,
|
|
6431
6617
|
public_handle: status.public_handle ?? null,
|
|
6432
6618
|
display_name: status.display_name ?? null
|
|
6433
6619
|
});
|
|
@@ -6780,6 +6966,19 @@ function createInstance(config) {
|
|
|
6780
6966
|
},
|
|
6781
6967
|
onTesterSignOut() {
|
|
6782
6968
|
clearTesterJwt();
|
|
6969
|
+
},
|
|
6970
|
+
// ── Assistant tab (P5) ───────────────────────────────────────────────
|
|
6971
|
+
assistantEnabled: bootstrapConfig.assistant?.enabled === true,
|
|
6972
|
+
...bootstrapConfig.assistant?.label ? { assistantLabel: bootstrapConfig.assistant.label } : {},
|
|
6973
|
+
...bootstrapConfig.assistant?.greeting ? { assistantGreeting: bootstrapConfig.assistant.greeting } : {},
|
|
6974
|
+
...bootstrapConfig.assistant?.suggestions ? { assistantSuggestions: bootstrapConfig.assistant.suggestions } : {},
|
|
6975
|
+
async onAssistantAsk(message, threadId) {
|
|
6976
|
+
const res = await apiClient2.askAssistant({
|
|
6977
|
+
message,
|
|
6978
|
+
threadId,
|
|
6979
|
+
context: currentPageContext
|
|
6980
|
+
});
|
|
6981
|
+
return res.ok ? res.data ?? null : null;
|
|
6783
6982
|
}
|
|
6784
6983
|
}, MUSHI_SDK_VERSION);
|
|
6785
6984
|
syncCaptureModules();
|
|
@@ -6869,8 +7068,8 @@ function createInstance(config) {
|
|
|
6869
7068
|
}).catch((err) => {
|
|
6870
7069
|
log.debug("Runtime SDK config fetch failed", { error: err instanceof Error ? err.message : String(err) });
|
|
6871
7070
|
});
|
|
6872
|
-
} else
|
|
6873
|
-
log.debug("Runtime SDK config
|
|
7071
|
+
} else {
|
|
7072
|
+
log.debug("Runtime SDK config disabled via runtimeConfig:false; using static bootstrap config");
|
|
6874
7073
|
}
|
|
6875
7074
|
void checkSdkFreshness();
|
|
6876
7075
|
log.info("Initialized", { projectId: config.projectId });
|
|
@@ -7325,6 +7524,28 @@ function createInstance(config) {
|
|
|
7325
7524
|
}
|
|
7326
7525
|
}
|
|
7327
7526
|
},
|
|
7527
|
+
identifyWithToken(token) {
|
|
7528
|
+
userToken = token && typeof token === "string" ? token : null;
|
|
7529
|
+
if (userToken) {
|
|
7530
|
+
const claims = core.parseIdentityToken(userToken);
|
|
7531
|
+
if (claims?.sub) {
|
|
7532
|
+
userInfo = {
|
|
7533
|
+
id: claims.sub,
|
|
7534
|
+
...claims.email ? { email: claims.email } : {},
|
|
7535
|
+
...claims.name ? { name: claims.name } : {}
|
|
7536
|
+
};
|
|
7537
|
+
}
|
|
7538
|
+
breadcrumbs.add({ category: "lifecycle", level: "info", message: "Mushi.identifyWithToken()" });
|
|
7539
|
+
} else {
|
|
7540
|
+
breadcrumbs.add({ category: "lifecycle", level: "info", message: "Mushi.identifyWithToken(null)" });
|
|
7541
|
+
}
|
|
7542
|
+
},
|
|
7543
|
+
publishPageContext(context) {
|
|
7544
|
+
currentPageContext = context && context.route ? context : null;
|
|
7545
|
+
},
|
|
7546
|
+
openAssistant() {
|
|
7547
|
+
widget.openAssistantTab();
|
|
7548
|
+
},
|
|
7328
7549
|
addBreadcrumb(crumb) {
|
|
7329
7550
|
breadcrumbs.add(crumb);
|
|
7330
7551
|
},
|
|
@@ -7448,6 +7669,9 @@ function mergeRuntimeConfig(config, runtime) {
|
|
|
7448
7669
|
const nativeTrigger = runtime.native?.triggerMode;
|
|
7449
7670
|
const runtimeLauncher = runtime.widget?.launcher;
|
|
7450
7671
|
const widgetTrigger = runtimeLauncher ?? runtime.widget?.trigger ?? (nativeTrigger === "none" || nativeTrigger === "shake" ? "manual" : void 0);
|
|
7672
|
+
const explicitHidden = runtimeLauncher === "hidden" || runtime.widget?.trigger === "hidden";
|
|
7673
|
+
const hostTrigger = config.widget?.trigger;
|
|
7674
|
+
const safeWidgetTrigger = widgetTrigger === "hidden" && !explicitHidden && hostTrigger && hostTrigger !== "hidden" ? hostTrigger : widgetTrigger;
|
|
7451
7675
|
const runtimeWidget = runtime.widget;
|
|
7452
7676
|
const runtimeBannerVariant = runtimeWidget?.bannerVariant;
|
|
7453
7677
|
const runtimeBannerPosition = runtimeWidget?.bannerPosition;
|
|
@@ -7471,7 +7695,7 @@ function mergeRuntimeConfig(config, runtime) {
|
|
|
7471
7695
|
widget: {
|
|
7472
7696
|
...config.widget,
|
|
7473
7697
|
...runtime.widget,
|
|
7474
|
-
...
|
|
7698
|
+
...safeWidgetTrigger ? { trigger: safeWidgetTrigger } : {},
|
|
7475
7699
|
...derivedBannerConfig ? { bannerConfig: derivedBannerConfig } : {},
|
|
7476
7700
|
// betaMode is local-only: set by the host app, not the dashboard.
|
|
7477
7701
|
// Restore it after the runtime spread so it is never silently cleared.
|
|
@@ -7547,9 +7771,7 @@ function resolveApiEndpoint(config) {
|
|
|
7547
7771
|
return config.apiEndpoint ?? core.DEFAULT_API_ENDPOINT;
|
|
7548
7772
|
}
|
|
7549
7773
|
function shouldUseRuntimeConfig(config) {
|
|
7550
|
-
|
|
7551
|
-
if (config.runtimeConfig === true) return true;
|
|
7552
|
-
return !isLocalhostEndpoint(resolveApiEndpoint(config));
|
|
7774
|
+
return config.runtimeConfig !== false;
|
|
7553
7775
|
}
|
|
7554
7776
|
async function runDiagnostics(options) {
|
|
7555
7777
|
const endpoint = await probeApiEndpoint(options.apiEndpoint);
|
|
@@ -7711,6 +7933,12 @@ function createNoopInstance() {
|
|
|
7711
7933
|
captureException: async () => null,
|
|
7712
7934
|
identify: () => {
|
|
7713
7935
|
},
|
|
7936
|
+
identifyWithToken: () => {
|
|
7937
|
+
},
|
|
7938
|
+
publishPageContext: () => {
|
|
7939
|
+
},
|
|
7940
|
+
openAssistant: () => {
|
|
7941
|
+
},
|
|
7714
7942
|
addBreadcrumb: () => {
|
|
7715
7943
|
},
|
|
7716
7944
|
getBreadcrumbs: () => [],
|