@mushi-mushi/core 1.33.6 → 1.35.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 CHANGED
@@ -1,17 +1,20 @@
1
1
  # @mushi-mushi/core
2
2
 
3
- > **Your AI wrote it. Mushi Mushi tells you why it broke.**
3
+ > **Your AI built it. Mushi Mushi makes it better.**
4
4
 
5
5
  The shared types, API client and utilities under every [Mushi Mushi](https://github.com/kensaurus/mushi-mushi) SDK.
6
6
 
7
7
  **You probably don't need to install this directly.** Run `npx mushi-mushi` and the wizard installs the SDK for your framework ([`react`](https://npmjs.com/package/@mushi-mushi/react), [`vue`](https://npmjs.com/package/@mushi-mushi/vue), [`svelte`](https://npmjs.com/package/@mushi-mushi/svelte), [`angular`](https://npmjs.com/package/@mushi-mushi/angular), [`react-native`](https://npmjs.com/package/@mushi-mushi/react-native), [`capacitor`](https://npmjs.com/package/@mushi-mushi/capacitor) or [`web`](https://npmjs.com/package/@mushi-mushi/web)), which depends on this one. Reach for `core` when you build your own adapter or need the types.
8
8
 
9
+ The same code ships in the [`mushi-mushi`](https://www.npmjs.com/package/mushi-mushi) package: `npm install mushi-mushi`, then `import { createPreFilter } from 'mushi-mushi/core'`. This package keeps working and keeps getting updates.
10
+
9
11
  ```bash
10
- npm install @mushi-mushi/core
12
+ npm install mushi-mushi # then import from 'mushi-mushi/core'
13
+ # or: npm install @mushi-mushi/core # same code; import from '@mushi-mushi/core'
11
14
  ```
12
15
 
13
16
  ```ts
14
- import { createPreFilter, captureEnvironment } from '@mushi-mushi/core';
17
+ import { createPreFilter, captureEnvironment } from 'mushi-mushi/core';
15
18
 
16
19
  const filter = createPreFilter();
17
20
  filter.check('asdf'); // { passed: false, reason: 'Too short (min 10 characters)' }
@@ -56,7 +59,7 @@ Pass `preset` instead of setting every `widget`, `capture` and `proactive` flag.
56
59
  The postures `production-calm`, `beta-loud`, `internal-debug` and `manual-only` also work. Precedence, highest first: **explicit config → `preset` → env vars (`NEXT_PUBLIC_MUSHI_*`, `VITE_MUSHI_*`) → SDK defaults.**
57
60
 
58
61
  ```typescript
59
- import { expandPreset, validateConfig } from '@mushi-mushi/core';
62
+ import { expandPreset, validateConfig } from 'mushi-mushi/core';
60
63
 
61
64
  validateConfig(config); // warns on typos or a bad preset, never throws (MUSHI_SILENT=1 hides it)
62
65
  const resolved = expandPreset(config); // preset → nested options, explicit values win
package/dist/index.cjs CHANGED
@@ -232,7 +232,7 @@ function createApiClient(options) {
232
232
  cbFailures += 1;
233
233
  if (cbFailures >= cbThreshold) cbOpenUntil = Date.now() + cbCooldownMs;
234
234
  };
235
- async function request(method, path, body, retries = maxRetries, internalKind, extraHeaders) {
235
+ async function request(method, path, body, retries = maxRetries, internalKind, extraHeaders, cache) {
236
236
  const tracked = internalKind !== "reporter-poll";
237
237
  if (tracked && cbIsOpen()) {
238
238
  return { ok: false, error: { code: "CIRCUIT_OPEN", message: "Endpoint temporarily unavailable; retrying later." } };
@@ -265,6 +265,7 @@ function createApiClient(options) {
265
265
  body: serialized,
266
266
  keepalive: isPageUnloading(),
267
267
  signal: controller.signal,
268
+ ...cache ? { cache } : {},
268
269
  ...internalKind ? { [MUSHI_INTERNAL_INIT_MARKER]: internalKind } : {}
269
270
  });
270
271
  clearTimeout(timer);
@@ -274,7 +275,7 @@ function createApiClient(options) {
274
275
  const targetBase = target.replace(/\/v1\/.*$/, "").replace(/\/$/, "");
275
276
  if (targetBase !== baseUrl) {
276
277
  baseUrl = targetBase;
277
- return request(method, path, body, retries - 1, internalKind, extraHeaders);
278
+ return request(method, path, body, retries - 1, internalKind, extraHeaders, cache);
278
279
  }
279
280
  }
280
281
  }
@@ -360,8 +361,8 @@ function createApiClient(options) {
360
361
  async getReportStatus(reportId) {
361
362
  return request("GET", `/v1/reports/${reportId}/status`, void 0, maxRetries, "report-status");
362
363
  },
363
- async getSdkConfig() {
364
- return request("GET", "/v1/sdk/config", void 0, maxRetries, "sdk-config");
364
+ async getSdkConfig(opts) {
365
+ return request("GET", "/v1/sdk/config", void 0, maxRetries, "sdk-config", void 0, opts?.fresh ? "no-store" : void 0);
365
366
  },
366
367
  async askAssistant(input) {
367
368
  return request(