@mushi-mushi/core 1.29.0 → 1.30.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/README.md +1 -1
- package/dist/index.cjs +19 -36
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +42 -5
- package/dist/index.d.ts +42 -5
- package/dist/index.js +19 -36
- package/dist/index.js.map +1 -1
- package/dist/reporter-ui.cjs +475 -0
- package/dist/reporter-ui.cjs.map +1 -0
- package/dist/reporter-ui.d.cts +131 -0
- package/dist/reporter-ui.d.ts +131 -0
- package/dist/reporter-ui.js +462 -0
- package/dist/reporter-ui.js.map +1 -0
- package/package.json +18 -1
package/README.md
CHANGED
|
@@ -141,4 +141,4 @@ MIT
|
|
|
141
141
|
<!-- mushi-readme-stats-footer -->
|
|
142
142
|
---
|
|
143
143
|
|
|
144
|
-
<sub>Monorepo scale (July 2026):
|
|
144
|
+
<sub>Monorepo scale (July 2026): 60 edge functions · 383 SQL migrations · 13 outbound plugins · 11 inbound adapters · 19 pipeline agents. Canonical counts: <a href="https://github.com/kensaurus/mushi-mushi/blob/master/docs/stats.md">docs/stats.md</a> · <code>pnpm docs-stats</code></sub>
|
package/dist/index.cjs
CHANGED
|
@@ -232,7 +232,8 @@ function createApiClient(options) {
|
|
|
232
232
|
if (cbFailures >= cbThreshold) cbOpenUntil = Date.now() + cbCooldownMs;
|
|
233
233
|
};
|
|
234
234
|
async function request(method, path, body, retries = maxRetries, internalKind, extraHeaders) {
|
|
235
|
-
|
|
235
|
+
const tracked = internalKind !== "reporter-poll";
|
|
236
|
+
if (tracked && cbIsOpen()) {
|
|
236
237
|
return { ok: false, error: { code: "CIRCUIT_OPEN", message: "Endpoint temporarily unavailable; retrying later." } };
|
|
237
238
|
}
|
|
238
239
|
const url = `${baseUrl}${path}`;
|
|
@@ -251,7 +252,7 @@ function createApiClient(options) {
|
|
|
251
252
|
...extraHeaders
|
|
252
253
|
};
|
|
253
254
|
const serialized = body ? JSON.stringify(body) : void 0;
|
|
254
|
-
if (serialized && method !== "GET") {
|
|
255
|
+
if (serialized && method !== "GET" && internalKind !== "reporter-poll") {
|
|
255
256
|
lastOutbound = { url, headers, body: serialized, path };
|
|
256
257
|
}
|
|
257
258
|
try {
|
|
@@ -291,8 +292,10 @@ function createApiClient(options) {
|
|
|
291
292
|
await sleep(retryAfterMs ?? getBackoffDelay(maxRetries - retries));
|
|
292
293
|
return request(method, path, body, retries - 1, internalKind, extraHeaders);
|
|
293
294
|
}
|
|
294
|
-
if (
|
|
295
|
-
|
|
295
|
+
if (tracked) {
|
|
296
|
+
if (unusable) cbRecordUnreachable();
|
|
297
|
+
else cbRecordReachable();
|
|
298
|
+
}
|
|
296
299
|
return {
|
|
297
300
|
ok: false,
|
|
298
301
|
error: {
|
|
@@ -304,7 +307,7 @@ function createApiClient(options) {
|
|
|
304
307
|
}
|
|
305
308
|
const payload = await response.json();
|
|
306
309
|
const data = payload && typeof payload === "object" && "ok" in payload && "data" in payload ? payload.data : payload;
|
|
307
|
-
cbRecordReachable();
|
|
310
|
+
if (tracked) cbRecordReachable();
|
|
308
311
|
return { ok: true, data };
|
|
309
312
|
} catch (error) {
|
|
310
313
|
clearTimeout(timer);
|
|
@@ -312,7 +315,7 @@ function createApiClient(options) {
|
|
|
312
315
|
await sleep(getBackoffDelay(maxRetries - retries));
|
|
313
316
|
return request(method, path, body, retries - 1, internalKind, extraHeaders);
|
|
314
317
|
}
|
|
315
|
-
cbRecordUnreachable();
|
|
318
|
+
if (tracked) cbRecordUnreachable();
|
|
316
319
|
return {
|
|
317
320
|
ok: false,
|
|
318
321
|
error: {
|
|
@@ -323,39 +326,17 @@ function createApiClient(options) {
|
|
|
323
326
|
}
|
|
324
327
|
}
|
|
325
328
|
async function requestForReporter(method, path, reporterToken, body) {
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
const response = await fetch(url, {
|
|
331
|
-
method,
|
|
332
|
-
headers: {
|
|
333
|
-
"Content-Type": "application/json",
|
|
334
|
-
"X-Mushi-Api-Key": apiKey,
|
|
335
|
-
"X-Mushi-Project": projectId,
|
|
336
|
-
...sdkPackage ? { [MUSHI_SDK_PACKAGE_HEADER]: sdkPackage } : {},
|
|
337
|
-
...sdkVersion ? { [MUSHI_SDK_VERSION_HEADER]: sdkVersion } : {},
|
|
338
|
-
[MUSHI_INTERNAL_HEADER]: "reporter-poll",
|
|
329
|
+
try {
|
|
330
|
+
const tokenHash = await sha256Hex(reporterToken);
|
|
331
|
+
const ts = String(Date.now());
|
|
332
|
+
return await request(method, path, body, maxRetries, "reporter-poll", {
|
|
339
333
|
"X-Reporter-Token-Hash": tokenHash,
|
|
340
334
|
"X-Reporter-Ts": ts,
|
|
341
|
-
"X-Reporter-Hmac":
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
[MUSHI_INTERNAL_INIT_MARKER]: "reporter-poll"
|
|
346
|
-
});
|
|
347
|
-
if (!response.ok) {
|
|
348
|
-
const errorBody = await response.json().catch(() => ({}));
|
|
349
|
-
return {
|
|
350
|
-
ok: false,
|
|
351
|
-
error: {
|
|
352
|
-
code: `HTTP_${response.status}`,
|
|
353
|
-
message: errorBody.error?.message ?? errorBody.message ?? `HTTP ${response.status} error`
|
|
354
|
-
}
|
|
355
|
-
};
|
|
335
|
+
"X-Reporter-Hmac": await hmacSha256Hex(apiKey, `${projectId}.${ts}.${tokenHash}`)
|
|
336
|
+
});
|
|
337
|
+
} catch (error) {
|
|
338
|
+
return { ok: false, error: { code: "NETWORK_ERROR", message: error instanceof Error ? error.message : "Unknown error" } };
|
|
356
339
|
}
|
|
357
|
-
const payload = await response.json();
|
|
358
|
-
return { ok: true, data: payload.data ?? payload };
|
|
359
340
|
}
|
|
360
341
|
return {
|
|
361
342
|
async submitReport(report) {
|
|
@@ -2296,10 +2277,12 @@ var MUSHI_EVENTS = {
|
|
|
2296
2277
|
invite_sent: { surface: "console", required: [] },
|
|
2297
2278
|
upgrade_clicked: { surface: "console", required: ["plan"] },
|
|
2298
2279
|
test_report_sent: { surface: "console", required: ["project_id"] },
|
|
2280
|
+
diagnosis_viewed: { surface: "console", required: ["report_id", "project_id", "surface"] },
|
|
2299
2281
|
// ── Server-emitted (edge functions) ──────────────────────────────────────
|
|
2300
2282
|
project_created: { surface: "server", required: ["project_id"] },
|
|
2301
2283
|
key_minted: { surface: "server", required: ["project_id"] },
|
|
2302
2284
|
first_report_received: { surface: "server", required: ["project_id"] },
|
|
2285
|
+
first_diagnosis_ready: { surface: "server", required: ["project_id"] },
|
|
2303
2286
|
fix_merged: { surface: "server", required: ["project_id"] },
|
|
2304
2287
|
upgrade_completed: { surface: "server", required: ["project_id", "plan"] },
|
|
2305
2288
|
// ── Growth loop (widget "Bug reports by Mushi" mark) ─────────────────────
|