@noodleseed/assistant 1.29.0 → 1.31.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.
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  createAssistantClient
4
- } from "../chunk-3VZ3M5BE.js";
4
+ } from "../chunk-5EVZFPTD.js";
5
5
  import "../chunk-P223CYPO.js";
6
6
  import "../chunk-3YYTUJPJ.js";
7
7
  import "../chunk-5FUTL2UF.js";
package/dist/react.cjs CHANGED
@@ -27924,6 +27924,32 @@ function isAbortError2(error51) {
27924
27924
  return error51 instanceof DOMException && error51.name === "AbortError";
27925
27925
  }
27926
27926
 
27927
+ // src/visitor-id.ts
27928
+ var STORAGE_PREFIX = "noodleseed.assistant.visitor.";
27929
+ function randomVisitorId() {
27930
+ try {
27931
+ return globalThis.crypto.randomUUID();
27932
+ } catch {
27933
+ return void 0;
27934
+ }
27935
+ }
27936
+ function visitorIdForSource(sourceKey) {
27937
+ const key = `${STORAGE_PREFIX}${sourceKey}`;
27938
+ try {
27939
+ const stored = globalThis.localStorage?.getItem(key);
27940
+ if (typeof stored === "string" && stored.length > 0) return stored;
27941
+ } catch {
27942
+ return void 0;
27943
+ }
27944
+ const created = randomVisitorId();
27945
+ if (created === void 0) return void 0;
27946
+ try {
27947
+ globalThis.localStorage?.setItem(key, created);
27948
+ } catch {
27949
+ }
27950
+ return created;
27951
+ }
27952
+
27927
27953
  // src/client.ts
27928
27954
  var DefaultAssistantClient = class {
27929
27955
  #source;
@@ -28318,11 +28344,12 @@ var DefaultAssistantClient = class {
28318
28344
  }
28319
28345
  async #createSession(signal) {
28320
28346
  const source = this.#source;
28347
+ const visitorId = source.kind === "public" ? visitorIdForSource(sessionSourceKey({ embedId: source.embedId, serviceUrl: source.url })) : void 0;
28321
28348
  const response = await this.#requestSession(source, {
28322
28349
  method: "POST",
28323
28350
  headers: { Accept: "application/json", "Content-Type": "application/json" },
28324
28351
  body: JSON.stringify(
28325
- source.kind === "public" ? { embedId: source.embedId } : this.#context ? { context: this.#context } : {}
28352
+ source.kind === "public" ? { embedId: source.embedId, ...visitorId ? { visitorId } : {} } : this.#context ? { context: this.#context } : {}
28326
28353
  ),
28327
28354
  credentials: source.kind === "public" ? "omit" : "same-origin",
28328
28355
  signal
@@ -33193,7 +33220,7 @@ var AssistantElementWebMcpController = class {
33193
33220
  #bridge;
33194
33221
  /** Guards against a late `startWebMcpBridge` resolving after the session it belonged to is gone. */
33195
33222
  #generation = 0;
33196
- /** Called when resolved configuration arrives; the deployment's opt-in is the only source. */
33223
+ /** Called when resolved configuration arrives; the server already resolved surface over deployment. */
33197
33224
  configure(enabled) {
33198
33225
  this.#enabled = enabled;
33199
33226
  if (!enabled) this.stop();