@pagelines/sdk 1.0.153 → 1.0.155

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.
Files changed (32) hide show
  1. package/dist/{AgentProvider.vue_vue_type_script_setup_true_lang-B0TWM6dY.js → AgentProvider.vue_vue_type_script_setup_true_lang-vzGl9adQ.js} +16 -14
  2. package/dist/AgentProvider.vue_vue_type_script_setup_true_lang-vzGl9adQ.js.map +1 -0
  3. package/dist/AgentWidgetInline-xKwzOBQ7.js +37 -0
  4. package/dist/AgentWidgetInline-xKwzOBQ7.js.map +1 -0
  5. package/dist/{AgentWidgetModal-C4MD7yII.js → AgentWidgetModal-BesI4epW.js} +23 -21
  6. package/dist/AgentWidgetModal-BesI4epW.js.map +1 -0
  7. package/dist/{AgentWidgetPopup-DpR4jkw4.js → AgentWidgetPopup-KU7OGmSO.js} +48 -46
  8. package/dist/AgentWidgetPopup-KU7OGmSO.js.map +1 -0
  9. package/dist/{AgentWrap.vue_vue_type_script_setup_true_lang-Cr7I8qea.js → AgentWrap.vue_vue_type_script_setup_true_lang-Dnt1w4Uv.js} +1150 -1109
  10. package/dist/AgentWrap.vue_vue_type_script_setup_true_lang-Dnt1w4Uv.js.map +1 -0
  11. package/dist/agent/ui/AgentChat.vue.d.ts +1 -0
  12. package/dist/agent/ui/AgentProvider.vue.d.ts +1 -0
  13. package/dist/agent.js +3 -3
  14. package/dist/clients/ChatClient.d.ts +2 -0
  15. package/dist/sdk.css +1 -1
  16. package/dist/sdk.js +1 -1
  17. package/dist/{sdkClient-yg_rc4B7.js → sdkClient-DlvpHeVt.js} +163 -161
  18. package/dist/sdkClient-DlvpHeVt.js.map +1 -0
  19. package/dist/widget/PLWidget.d.ts +7 -0
  20. package/dist/widget/ui/AgentWidgetInline.vue.d.ts +1 -0
  21. package/dist/widget/ui/AgentWidgetModal.vue.d.ts +1 -0
  22. package/dist/widget/ui/AgentWidgetPopup.vue.d.ts +1 -0
  23. package/dist/widget.js +109 -81
  24. package/dist/widget.js.map +1 -1
  25. package/package.json +2 -2
  26. package/dist/AgentProvider.vue_vue_type_script_setup_true_lang-B0TWM6dY.js.map +0 -1
  27. package/dist/AgentWidgetInline-DAihjazO.js +0 -35
  28. package/dist/AgentWidgetInline-DAihjazO.js.map +0 -1
  29. package/dist/AgentWidgetModal-C4MD7yII.js.map +0 -1
  30. package/dist/AgentWidgetPopup-DpR4jkw4.js.map +0 -1
  31. package/dist/AgentWrap.vue_vue_type_script_setup_true_lang-Cr7I8qea.js.map +0 -1
  32. package/dist/sdkClient-yg_rc4B7.js.map +0 -1
@@ -6,14 +6,14 @@ import { watch as Z, ref as E, computed as ee } from "vue";
6
6
  import { APP_PORT as F, APP_PROD_URL as D } from "@pagelines/types";
7
7
  import { hc as ie } from "hono/client";
8
8
  function N(h = {}) {
9
- const { prefix: e = "id_" } = h, t = e.length >= 3 ? e.substring(0, 3) : e.padEnd(3, "_"), r = Math.floor(Date.now() / 1e3).toString(16).padStart(8, "0");
10
- let o = "";
9
+ const { prefix: e = "id_" } = h, t = e.length >= 3 ? e.substring(0, 3) : e.padEnd(3, "_"), o = Math.floor(Date.now() / 1e3).toString(16).padStart(8, "0");
10
+ let r = "";
11
11
  for (let s = 0; s < 16; s++)
12
- o += Math.floor(Math.random() * 16).toString(16);
13
- return t + r + o;
12
+ r += Math.floor(Math.random() * 16).toString(16);
13
+ return t + o + r;
14
14
  }
15
15
  c(N, "objectId");
16
- const S = globalThis.process, m = typeof window < "u", B = typeof S < "u" && !m, x = m ? typeof window < "u" && window.location && !window.location.hostname.includes("localhost") : B && typeof S < "u" && S.env?.NODE_ENV === "production", ne = !x, A = {
16
+ const S = globalThis.process, m = typeof window < "u", B = typeof S < "u" && !m, w = m ? typeof window < "u" && window.location && !window.location.hostname.includes("localhost") : B && typeof S < "u" && S.env?.NODE_ENV === "production", ne = !w, A = {
17
17
  error: { priority: 50, color: "#FF0000", nodeColor: "\x1B[31m" },
18
18
  warn: { priority: 40, color: "#FFA500", nodeColor: "\x1B[33m" },
19
19
  info: { priority: 30, color: "#00ABFF", nodeColor: "\x1B[36m" },
@@ -38,13 +38,13 @@ const S = globalThis.process, m = typeof window < "u", B = typeof S < "u" && !m,
38
38
  if (e)
39
39
  return e;
40
40
  }
41
- return x ? "info" : "debug";
41
+ return w ? "info" : "debug";
42
42
  }
43
43
  initBrowserLogging() {
44
44
  if (!m)
45
45
  return;
46
- const t = typeof localStorage?.getItem == "function" && localStorage.getItem("PAGELINES_LOG") === "true", r = window.location?.hostname || "";
47
- this.enabledInBrowser = ne || t || r === "localhost" || r.includes("127.0.0.1"), x && !t && !y.hasShownHelp && (console.log(
46
+ const t = typeof localStorage?.getItem == "function" && localStorage.getItem("PAGELINES_LOG") === "true", o = window.location?.hostname || "";
47
+ this.enabledInBrowser = ne || t || o === "localhost" || o.includes("127.0.0.1"), w && !t && !y.hasShownHelp && (console.log(
48
48
  "%cPageLines Logger (disabled in production)",
49
49
  "color: #888; font-size: 12px"
50
50
  ), console.log(
@@ -55,8 +55,8 @@ const S = globalThis.process, m = typeof window < "u", B = typeof S < "u" && !m,
55
55
  shouldLog(e) {
56
56
  if (!this.settings.enabled || m && !this.enabledInBrowser)
57
57
  return !1;
58
- const t = A[e].priority, r = A[this.settings.minLevel].priority;
59
- return t >= r;
58
+ const t = A[e].priority, o = A[this.settings.minLevel].priority;
59
+ return t >= o;
60
60
  }
61
61
  formatTimestamp() {
62
62
  return (/* @__PURE__ */ new Date()).toLocaleTimeString("en-GB", {
@@ -73,16 +73,16 @@ const S = globalThis.process, m = typeof window < "u", B = typeof S < "u" && !m,
73
73
  if (typeof e != "object" || e === null)
74
74
  return e;
75
75
  if (Array.isArray(e))
76
- return e.map((r) => this.redactSensitive(r));
76
+ return e.map((o) => this.redactSensitive(o));
77
77
  const t = {};
78
- for (const [r, o] of Object.entries(e)) {
79
- const s = r.toLowerCase();
80
- ae.some((i) => s.includes(i)) ? t[r] = "[REDACTED]" : typeof o == "object" && o !== null ? t[r] = this.redactSensitive(o) : t[r] = o;
78
+ for (const [o, r] of Object.entries(e)) {
79
+ const s = o.toLowerCase();
80
+ ae.some((i) => s.includes(i)) ? t[o] = "[REDACTED]" : typeof r == "object" && r !== null ? t[o] = this.redactSensitive(r) : t[o] = r;
81
81
  }
82
82
  return t;
83
83
  }
84
- formatData(e, t = 3, r = 0) {
85
- if (r >= t)
84
+ formatData(e, t = 3, o = 0) {
85
+ if (o >= t)
86
86
  return "[Max Depth]";
87
87
  if (e == null)
88
88
  return e;
@@ -90,7 +90,7 @@ const S = globalThis.process, m = typeof window < "u", B = typeof S < "u" && !m,
90
90
  return {
91
91
  name: e.name,
92
92
  message: e.message,
93
- stack: x ? e.stack?.split(`
93
+ stack: w ? e.stack?.split(`
94
94
  `).slice(0, 3).join(`
95
95
  `) : e.stack,
96
96
  ...e
@@ -101,12 +101,12 @@ const S = globalThis.process, m = typeof window < "u", B = typeof S < "u" && !m,
101
101
  if (typeof e != "object")
102
102
  return e;
103
103
  if (Array.isArray(e))
104
- return e.length > 20 && x ? `Array(${e.length}) [${e.slice(0, 3).map((o) => this.formatData(o, t, r + 1)).join(", ")}, ...]` : e.map((o) => this.formatData(o, t, r + 1));
104
+ return e.length > 20 && w ? `Array(${e.length}) [${e.slice(0, 3).map((r) => this.formatData(r, t, o + 1)).join(", ")}, ...]` : e.map((r) => this.formatData(r, t, o + 1));
105
105
  try {
106
- const o = {}, s = Object.entries(e), i = x ? 50 : 200;
106
+ const r = {}, s = Object.entries(e), i = w ? 50 : 200;
107
107
  for (const [l, u] of s.slice(0, i))
108
- o[l] = this.formatData(u, t, r + 1);
109
- return s.length > i && (o["..."] = `${s.length - i} more properties`), this.redactSensitive(o);
108
+ r[l] = this.formatData(u, t, o + 1);
109
+ return s.length > i && (r["..."] = `${s.length - i} more properties`), this.redactSensitive(r);
110
110
  } catch {
111
111
  return "[Unserializable]";
112
112
  }
@@ -114,21 +114,21 @@ const S = globalThis.process, m = typeof window < "u", B = typeof S < "u" && !m,
114
114
  logToBrowser(e) {
115
115
  if (!m || !this.shouldLog(e.level))
116
116
  return;
117
- const { level: t, description: r, context: o, data: s, error: i } = e, l = A[t], a = `[${o || this.context || "www"}] ${t.toUpperCase()}:`, d = `color: ${l.color}; font-weight: bold;`;
118
- s !== void 0 ? console[t](`%c${a}`, d, r, this.formatData(s)) : console[t](`%c${a}`, d, r), i && (i instanceof Error ? console.error(i) : console.error("Error details:", i));
117
+ const { level: t, description: o, context: r, data: s, error: i } = e, l = A[t], a = `[${r || this.context || "www"}] ${t.toUpperCase()}:`, d = `color: ${l.color}; font-weight: bold;`;
118
+ s !== void 0 ? console[t](`%c${a}`, d, o, this.formatData(s)) : console[t](`%c${a}`, d, o), i && (i instanceof Error ? console.error(i) : console.error("Error details:", i));
119
119
  }
120
120
  logToNode(e) {
121
121
  if (!B || !this.shouldLog(e.level))
122
122
  return;
123
- const { level: t, description: r, context: o, data: s, error: i } = e, l = o || this.context || "www";
124
- if (x) {
123
+ const { level: t, description: o, context: r, data: s, error: i } = e, l = r || this.context || "www";
124
+ if (w) {
125
125
  const u = {
126
126
  timestamp: this.formatISOTimestamp(),
127
127
  level: t.toUpperCase()
128
128
  };
129
- s && (u.data = this.formatData(s)), i && (u.error = this.formatData(i)), console[t](`${u.timestamp} ${u.level} [${l}] ${r}`, s || i ? JSON.stringify({ data: s, error: i }) : "");
129
+ s && (u.data = this.formatData(s)), i && (u.error = this.formatData(i)), console[t](`${u.timestamp} ${u.level} [${l}] ${o}`, s || i ? JSON.stringify({ data: s, error: i }) : "");
130
130
  } else {
131
- const u = A[t], a = this.formatTimestamp(), d = "\x1B[0m", I = "\x1B[2m", g = u.nodeColor || "", k = `${I}${a}${d} ${g}${t.toUpperCase()} (${l}):${d} ${r}`;
131
+ const u = A[t], a = this.formatTimestamp(), d = "\x1B[0m", I = "\x1B[2m", g = u.nodeColor || "", k = `${I}${a}${d} ${g}${t.toUpperCase()} (${l}):${d} ${o}`;
132
132
  console[t](k), s !== void 0 && console.log(JSON.stringify(this.formatData(s), null, 2)), i && (i instanceof Error ? (console.error(`\x1B[31mError:${d}`, i.message), i.stack && console.error(`\x1B[90m${i.stack}${d}`)) : console.error("Error:", i));
133
133
  }
134
134
  }
@@ -159,22 +159,22 @@ const S = globalThis.process, m = typeof window < "u", B = typeof S < "u" && !m,
159
159
  createContextLogger(e) {
160
160
  const t = new y(this.settings, e);
161
161
  return {
162
- error: /* @__PURE__ */ c((r, o) => t.error(r, o), "error"),
163
- warn: /* @__PURE__ */ c((r, o) => t.warn(r, o), "warn"),
164
- info: /* @__PURE__ */ c((r, o) => t.info(r, o), "info"),
165
- debug: /* @__PURE__ */ c((r, o) => t.debug(r, o), "debug"),
166
- trace: /* @__PURE__ */ c((r, o) => t.trace(r, o), "trace"),
162
+ error: /* @__PURE__ */ c((o, r) => t.error(o, r), "error"),
163
+ warn: /* @__PURE__ */ c((o, r) => t.warn(o, r), "warn"),
164
+ info: /* @__PURE__ */ c((o, r) => t.info(o, r), "info"),
165
+ debug: /* @__PURE__ */ c((o, r) => t.debug(o, r), "debug"),
166
+ trace: /* @__PURE__ */ c((o, r) => t.trace(o, r), "trace"),
167
167
  isEnabled: /* @__PURE__ */ c(() => t.isEnabled(), "isEnabled"),
168
- setLevel: /* @__PURE__ */ c((r) => t.setLevel(r), "setLevel")
168
+ setLevel: /* @__PURE__ */ c((o) => t.setLevel(o), "setLevel")
169
169
  };
170
170
  }
171
171
  };
172
172
  c(y, "Logger"), n(y, "hasShownHelp", !1);
173
173
  let P = y;
174
- function re(h) {
175
- return new P({}, h).createContextLogger(h);
174
+ function oe(h) {
175
+ return new P({}, h);
176
176
  }
177
- c(re, "createLogger");
177
+ c(oe, "createLogger");
178
178
  const p = new P();
179
179
  p.error.bind(p);
180
180
  p.warn.bind(p);
@@ -186,7 +186,7 @@ const K = class K {
186
186
  n(this, "name");
187
187
  n(this, "settings");
188
188
  n(this, "logger");
189
- this.name = e, this.settings = t, this.logger = re(e);
189
+ this.name = e, this.settings = t, this.logger = oe(e);
190
190
  }
191
191
  };
192
192
  c(K, "SettingsObject");
@@ -208,9 +208,9 @@ const z = class z {
208
208
  if (typeof document > "u")
209
209
  return null;
210
210
  const t = document.cookie.split(";");
211
- for (const r of t) {
212
- const [o, s] = r.trim().split("=");
213
- if (o === e)
211
+ for (const o of t) {
212
+ const [r, s] = o.trim().split("=");
213
+ if (r === e)
214
214
  return decodeURIComponent(s || "");
215
215
  }
216
216
  return null;
@@ -218,19 +218,19 @@ const z = class z {
218
218
  /**
219
219
  * Set cookie with secure defaults
220
220
  */
221
- setCookie(e, t, r = {}) {
221
+ setCookie(e, t, o = {}) {
222
222
  if (typeof document > "u")
223
223
  return;
224
224
  const {
225
- secure: o = !0,
225
+ secure: r = !0,
226
226
  sameSite: s = "lax",
227
227
  maxAge: i = 3600 * 24 * 7,
228
228
  // 7 days default
229
229
  domain: l,
230
230
  path: u = "/"
231
- } = r;
231
+ } = o;
232
232
  let a = `${e}=${encodeURIComponent(t)}`;
233
- a += `; Path=${u}`, a += `; Max-Age=${i}`, a += `; SameSite=${s}`, o && (a += "; Secure"), l && (a += `; Domain=${l}`), document.cookie = a;
233
+ a += `; Path=${u}`, a += `; Max-Age=${i}`, a += `; SameSite=${s}`, r && (a += "; Secure"), l && (a += `; Domain=${l}`), document.cookie = a;
234
234
  }
235
235
  /**
236
236
  * Remove cookie by setting expired date
@@ -288,8 +288,8 @@ const C = new M();
288
288
  function ce(h, e) {
289
289
  const t = h.apiBase || (h.isDev ? `http://localhost:${F}` : D);
290
290
  return ie(t, {
291
- fetch: /* @__PURE__ */ c(async (o, s) => {
292
- const i = C.getAuthToken(), l = await fetch(o, {
291
+ fetch: /* @__PURE__ */ c(async (r, s) => {
292
+ const i = C.getAuthToken(), l = await fetch(r, {
293
293
  ...s,
294
294
  headers: {
295
295
  ...s?.headers,
@@ -312,32 +312,32 @@ function ce(h, e) {
312
312
  });
313
313
  }
314
314
  c(ce, "createApiClient");
315
- let le = /* @__PURE__ */ Symbol("clean"), f = [], w = 0;
316
- const $ = 4, oe = /* @__PURE__ */ c(/* @__NO_SIDE_EFFECTS__ */ (h) => {
315
+ let le = /* @__PURE__ */ Symbol("clean"), f = [], x = 0;
316
+ const $ = 4, re = /* @__PURE__ */ c(/* @__NO_SIDE_EFFECTS__ */ (h) => {
317
317
  let e = [], t = {
318
318
  get() {
319
319
  return t.lc || t.listen(() => {
320
320
  })(), t.value;
321
321
  },
322
322
  lc: 0,
323
- listen(r) {
324
- return t.lc = e.push(r), () => {
325
- for (let s = w + $; s < f.length; )
326
- f[s] === r ? f.splice(s, $) : s += $;
327
- let o = e.indexOf(r);
328
- ~o && (e.splice(o, 1), --t.lc || t.off());
323
+ listen(o) {
324
+ return t.lc = e.push(o), () => {
325
+ for (let s = x + $; s < f.length; )
326
+ f[s] === o ? f.splice(s, $) : s += $;
327
+ let r = e.indexOf(o);
328
+ ~r && (e.splice(r, 1), --t.lc || t.off());
329
329
  };
330
330
  },
331
- notify(r, o) {
331
+ notify(o, r) {
332
332
  let s = !f.length;
333
333
  for (let i of e)
334
- f.push(i, t.value, r, o);
334
+ f.push(i, t.value, o, r);
335
335
  if (s) {
336
- for (w = 0; w < f.length; w += $)
337
- f[w](
338
- f[w + 1],
339
- f[w + 2],
340
- f[w + 3]
336
+ for (x = 0; x < f.length; x += $)
337
+ f[x](
338
+ f[x + 1],
339
+ f[x + 2],
340
+ f[x + 3]
341
341
  );
342
342
  f.length = 0;
343
343
  }
@@ -346,22 +346,22 @@ const $ = 4, oe = /* @__PURE__ */ c(/* @__NO_SIDE_EFFECTS__ */ (h) => {
346
346
  We will redefine it in onMount and onStop. */
347
347
  off() {
348
348
  },
349
- set(r) {
350
- let o = t.value;
351
- o !== r && (t.value = r, t.notify(o));
349
+ set(o) {
350
+ let r = t.value;
351
+ r !== o && (t.value = o, t.notify(r));
352
352
  },
353
- subscribe(r) {
354
- let o = t.listen(r);
355
- return r(t.value), o;
353
+ subscribe(o) {
354
+ let r = t.listen(o);
355
+ return o(t.value), r;
356
356
  },
357
357
  value: h
358
358
  };
359
359
  return process.env.NODE_ENV !== "production" && (t[le] = () => {
360
360
  e = [], t.lc = 0, t.off();
361
361
  }), t;
362
- }, "atom"), L = /* @__PURE__ */ oe(void 0), U = /* @__PURE__ */ oe(null), J = class J {
362
+ }, "atom"), L = /* @__PURE__ */ re(void 0), U = /* @__PURE__ */ re(null), J = class J {
363
363
  constructor() {
364
- n(this, "logger", re("SDKStorage"));
364
+ n(this, "logger", oe("SDKStorage"));
365
365
  }
366
366
  /**
367
367
  * Check if localStorage is fully functional (some test environments provide partial mocks)
@@ -373,8 +373,8 @@ const $ = 4, oe = /* @__PURE__ */ c(/* @__NO_SIDE_EFFECTS__ */ (h) => {
373
373
  * Sync Vue reactive refs with global nanostores for cross-page persistence
374
374
  */
375
375
  syncWithGlobalStores(e, t) {
376
- const r = L.get(), o = U.get();
377
- r && (e.value = r), o && (t.value = o), Z(e, (s) => {
376
+ const o = L.get(), r = U.get();
377
+ o && (e.value = o), r && (t.value = r), Z(e, (s) => {
378
378
  L.set(s);
379
379
  }, { immediate: !0 }), Z(t, (s) => {
380
380
  U.set(s);
@@ -390,13 +390,13 @@ const $ = 4, oe = /* @__PURE__ */ c(/* @__NO_SIDE_EFFECTS__ */ (h) => {
390
390
  loadFromStorage(e, t) {
391
391
  if (typeof window > "u")
392
392
  return;
393
- const r = C.getAuthToken();
394
- if (r && (t.value = r), this.isLocalStorageFunctional())
393
+ const o = C.getAuthToken();
394
+ if (o && (t.value = o), this.isLocalStorageFunctional())
395
395
  try {
396
- const o = localStorage.getItem("pagelines-user");
397
- o && (e.value = JSON.parse(o));
398
- } catch (o) {
399
- this.logger.error("Failed to load user from localStorage", { data: o });
396
+ const r = localStorage.getItem("pagelines-user");
397
+ r && (e.value = JSON.parse(r));
398
+ } catch (r) {
399
+ this.logger.error("Failed to load user from localStorage", { data: r });
400
400
  }
401
401
  }
402
402
  /**
@@ -406,8 +406,8 @@ const $ = 4, oe = /* @__PURE__ */ c(/* @__NO_SIDE_EFFECTS__ */ (h) => {
406
406
  if (!(typeof window > "u") && (t.value ? C.setAuthToken(t.value) : C.removeAuthToken(), this.isLocalStorageFunctional()))
407
407
  try {
408
408
  e.value ? localStorage.setItem("pagelines-user", JSON.stringify(e.value)) : localStorage.removeItem("pagelines-user");
409
- } catch (r) {
410
- this.logger.error("Failed to save user to localStorage", { data: r });
409
+ } catch (o) {
410
+ this.logger.error("Failed to save user to localStorage", { data: o });
411
411
  }
412
412
  }
413
413
  /**
@@ -443,8 +443,8 @@ const $ = 4, oe = /* @__PURE__ */ c(/* @__NO_SIDE_EFFECTS__ */ (h) => {
443
443
  if (this.isLocalStorageFunctional())
444
444
  try {
445
445
  localStorage.setItem(e, t);
446
- } catch (r) {
447
- this.logger.error("Failed to set item in localStorage", { key: e, error: r });
446
+ } catch (o) {
447
+ this.logger.error("Failed to set item in localStorage", { key: e, error: o });
448
448
  }
449
449
  }
450
450
  };
@@ -457,15 +457,15 @@ const V = class V {
457
457
  async sendCode(e) {
458
458
  this.ctx.loading.value = !0, this.ctx.error.value = null;
459
459
  try {
460
- const r = await (await this.ctx.api.auth["check-email"].$post({
460
+ const o = await (await this.ctx.api.auth["check-email"].$post({
461
461
  json: { email: e }
462
462
  })).json();
463
- if (!r.ok)
464
- throw this.ctx.error.value = r.error, new Error(r.error);
463
+ if (!o.ok)
464
+ throw this.ctx.error.value = o.error, new Error(o.error);
465
465
  } catch (t) {
466
466
  this.ctx.logger.error("Send code error", { data: t });
467
- const r = t instanceof Error ? t.message : "Failed to send verification code";
468
- throw this.ctx.error.value = r, t;
467
+ const o = t instanceof Error ? t.message : "Failed to send verification code";
468
+ throw this.ctx.error.value = o, t;
469
469
  } finally {
470
470
  this.ctx.loading.value = !1;
471
471
  }
@@ -473,15 +473,15 @@ const V = class V {
473
473
  async verifyCode(e, t) {
474
474
  this.ctx.loading.value = !0, this.ctx.error.value = null;
475
475
  try {
476
- const o = await (await this.ctx.api.auth["verify-code"].$post({
476
+ const r = await (await this.ctx.api.auth["verify-code"].$post({
477
477
  json: { email: e, code: t }
478
478
  })).json();
479
- if (!o.ok)
480
- throw this.ctx.error.value = o.error, new Error(o.error);
481
- } catch (r) {
482
- this.ctx.logger.error("Verify code error", { data: r });
483
- const o = r instanceof Error ? r.message : "Failed to verify code";
484
- throw this.ctx.error.value = o, r;
479
+ if (!r.ok)
480
+ throw this.ctx.error.value = r.error, new Error(r.error);
481
+ } catch (o) {
482
+ this.ctx.logger.error("Verify code error", { data: o });
483
+ const r = o instanceof Error ? o.message : "Failed to verify code";
484
+ throw this.ctx.error.value = r, o;
485
485
  } finally {
486
486
  this.ctx.loading.value = !1;
487
487
  }
@@ -489,15 +489,15 @@ const V = class V {
489
489
  async login(e, t) {
490
490
  this.ctx.loading.value = !0, this.ctx.error.value = null;
491
491
  try {
492
- const o = await (await this.ctx.api.auth.login.$post({
492
+ const r = await (await this.ctx.api.auth.login.$post({
493
493
  json: { email: e, password: t }
494
494
  })).json();
495
- if (!o.ok)
496
- throw this.ctx.error.value = o.error, new Error(o.error);
497
- } catch (r) {
498
- this.ctx.logger.error("Login error", { data: r });
499
- const o = r instanceof Error ? r.message : "Login failed";
500
- throw this.ctx.error.value = o, r;
495
+ if (!r.ok)
496
+ throw this.ctx.error.value = r.error, new Error(r.error);
497
+ } catch (o) {
498
+ this.ctx.logger.error("Login error", { data: o });
499
+ const r = o instanceof Error ? o.message : "Login failed";
500
+ throw this.ctx.error.value = r, o;
501
501
  } finally {
502
502
  this.ctx.loading.value = !1;
503
503
  }
@@ -533,10 +533,10 @@ const V = class V {
533
533
  async requestAuthCode(e) {
534
534
  this.ctx.loading.value = !0, this.ctx.error.value = null;
535
535
  try {
536
- const r = await (await this.ctx.api.auth["check-email"].$post({
536
+ const o = await (await this.ctx.api.auth["check-email"].$post({
537
537
  json: { email: e.email }
538
538
  })).json();
539
- return r.ok ? (this.ctx.logger.info("Auth code requested successfully", { email: e.email }), !0) : (this.ctx.error.value = r.error, this.ctx.logger.error("Failed to request auth code", { email: e.email, error: r.error }), !1);
539
+ return o.ok ? (this.ctx.logger.info("Auth code requested successfully", { email: e.email }), !0) : (this.ctx.error.value = o.error, this.ctx.logger.error("Failed to request auth code", { email: e.email, error: o.error }), !1);
540
540
  } catch (t) {
541
541
  return this.ctx.logger.error("Request auth code error", { email: e.email, error: t }), this.ctx.error.value = t instanceof Error ? t.message : "Failed to request auth code", !1;
542
542
  } finally {
@@ -546,17 +546,17 @@ const V = class V {
546
546
  async loginWithCode(e) {
547
547
  this.ctx.loading.value = !0, this.ctx.error.value = null;
548
548
  try {
549
- const r = await (await this.ctx.api.auth["verify-code"].$post({
549
+ const o = await (await this.ctx.api.auth["verify-code"].$post({
550
550
  json: { email: e.email, code: e.code }
551
551
  })).json();
552
552
  return this.ctx.logger.info("Login with code response", {
553
- hasUser: !!r.user,
554
- hasToken: !!r.token,
555
- ok: r.ok
556
- }), r.ok ? (this.ctx.logger.info("Login successful", { email: e.email }), e.orgId && e.autoCreateContact !== !1 && this.ctx.activeUser.value?.userId && await this.autoCreateContact({
553
+ hasUser: !!o.user,
554
+ hasToken: !!o.token,
555
+ ok: o.ok
556
+ }), o.ok ? (this.ctx.logger.info("Login successful", { email: e.email }), e.orgId && e.autoCreateContact !== !1 && this.ctx.activeUser.value?.userId && await this.autoCreateContact({
557
557
  userId: this.ctx.activeUser.value.userId,
558
558
  orgId: e.orgId
559
- }), !0) : (this.ctx.error.value = r.error, this.ctx.logger.error("Login failed", { email: e.email, error: r.error }), !1);
559
+ }), !0) : (this.ctx.error.value = o.error, this.ctx.logger.error("Login failed", { email: e.email, error: o.error }), !1);
560
560
  } catch (t) {
561
561
  return this.ctx.logger.error("Login with code error", { email: e.email, error: t }), this.ctx.error.value = t instanceof Error ? t.message : "Login failed", !1;
562
562
  } finally {
@@ -565,10 +565,10 @@ const V = class V {
565
565
  }
566
566
  async autoCreateContact(e) {
567
567
  try {
568
- const r = await (await this.ctx.api.contact.resolve.$post({
568
+ const o = await (await this.ctx.api.contact.resolve.$post({
569
569
  json: { userId: e.userId, orgId: e.orgId }
570
570
  })).json();
571
- return r.ok ? (this.ctx.logger.info("Contact resolved", { userId: e.userId, orgId: e.orgId }), !0) : (this.ctx.logger.error("Failed to auto-create contact", { error: r.error, args: e }), !1);
571
+ return o.ok ? (this.ctx.logger.info("Contact resolved", { userId: e.userId, orgId: e.orgId }), !0) : (this.ctx.logger.error("Failed to auto-create contact", { error: o.error, args: e }), !1);
572
572
  } catch (t) {
573
573
  return this.ctx.logger.error("Auto-create contact error", { error: t, args: e }), !1;
574
574
  }
@@ -578,8 +578,8 @@ const V = class V {
578
578
  this.ctx.logger.error("loginWithGoogle: Only available in browser");
579
579
  return;
580
580
  }
581
- const t = this.ctx.apiBase || (this.ctx.isDev ? `http://localhost:${F}` : D), r = window.location.origin, o = `${t}/auth/google-popup?origin=${encodeURIComponent(r)}`, s = 500, i = 600, l = window.screenX + (window.outerWidth - s) / 2, u = window.screenY + (window.outerHeight - i) / 2, a = window.open(
582
- o,
581
+ const t = this.ctx.apiBase || (this.ctx.isDev ? `http://localhost:${F}` : D), o = window.location.origin, r = `${t}/auth/google-popup?origin=${encodeURIComponent(o)}`, s = 500, i = 600, l = window.screenX + (window.outerWidth - s) / 2, u = window.screenY + (window.outerHeight - i) / 2, a = window.open(
582
+ r,
583
583
  "google-auth",
584
584
  `width=${s},height=${i},left=${l},top=${u},popup=yes`
585
585
  );
@@ -615,24 +615,25 @@ const H = class H {
615
615
  this.ctx = e;
616
616
  }
617
617
  async chatStream(e) {
618
- const r = `${this.ctx.apiBase || (this.ctx.isDev ? `http://localhost:${F}` : D)}/api/agent/public/${encodeURIComponent(e.handle)}/chat/stream`;
618
+ const o = `${this.ctx.apiBase || (this.ctx.isDev ? `http://localhost:${F}` : D)}/api/agent/public/${encodeURIComponent(e.handle)}/chat/stream`;
619
619
  try {
620
- const o = await fetch(r, {
620
+ const r = await fetch(o, {
621
621
  method: "POST",
622
622
  headers: { "Content-Type": "application/json" },
623
623
  body: JSON.stringify({
624
624
  message: e.message,
625
625
  conversationId: e.conversationId,
626
626
  history: e.history,
627
- visitorId: e.visitorId
627
+ visitorId: e.visitorId,
628
+ context: e.context
628
629
  })
629
630
  });
630
- if (!o.ok) {
631
- const a = await o.json().catch(() => ({ error: "Request failed" }));
632
- e.onError(a.error || `HTTP ${o.status}`);
631
+ if (!r.ok) {
632
+ const a = await r.json().catch(() => ({ error: "Request failed" }));
633
+ e.onError(a.error || `HTTP ${r.status}`);
633
634
  return;
634
635
  }
635
- const s = o.body?.getReader();
636
+ const s = r.body?.getReader();
636
637
  if (!s) {
637
638
  e.onError("No response stream");
638
639
  return;
@@ -665,20 +666,21 @@ const H = class H {
665
666
  }
666
667
  }
667
668
  e.onDone(u);
668
- } catch (o) {
669
- e.onError(o instanceof Error ? o.message : "Stream failed");
669
+ } catch (r) {
670
+ e.onError(r instanceof Error ? r.message : "Stream failed");
670
671
  }
671
672
  }
672
673
  async chatMessage(e) {
673
- const r = `${this.ctx.apiBase || (this.ctx.isDev ? `http://localhost:${F}` : D)}/api/agent/public/${encodeURIComponent(e.handle)}/chat`;
674
+ const o = `${this.ctx.apiBase || (this.ctx.isDev ? `http://localhost:${F}` : D)}/api/agent/public/${encodeURIComponent(e.handle)}/chat`;
674
675
  try {
675
- const s = await (await fetch(r, {
676
+ const s = await (await fetch(o, {
676
677
  method: "POST",
677
678
  headers: { "Content-Type": "application/json" },
678
679
  body: JSON.stringify({
679
680
  message: e.message,
680
681
  conversationId: e.conversationId,
681
- visitorId: e.visitorId
682
+ visitorId: e.visitorId,
683
+ context: e.context
682
684
  })
683
685
  })).json();
684
686
  if (!s.ok || !s.data) {
@@ -689,14 +691,14 @@ const H = class H {
689
691
  conversationId: s.data.conversationId,
690
692
  content: s.data.message.content
691
693
  };
692
- } catch (o) {
693
- this.ctx.logger.error("chatMessage error", { error: o });
694
+ } catch (r) {
695
+ this.ctx.logger.error("chatMessage error", { error: r });
694
696
  return;
695
697
  }
696
698
  }
697
699
  async saveMessage(e) {
698
700
  try {
699
- const r = await (await this.ctx.api.conversation.messages.$post({
701
+ const o = await (await this.ctx.api.conversation.messages.$post({
700
702
  json: {
701
703
  sessionId: e.conversationId,
702
704
  participantId: e.participantId,
@@ -704,7 +706,7 @@ const H = class H {
704
706
  role: e.role
705
707
  }
706
708
  })).json();
707
- return r.ok ? !0 : (this.ctx.logger.error("Failed to save message", { error: "error" in r ? r.error : "Unknown error", args: e }), !1);
709
+ return o.ok ? !0 : (this.ctx.logger.error("Failed to save message", { error: "error" in o ? o.error : "Unknown error", args: e }), !1);
708
710
  } catch (t) {
709
711
  return this.ctx.logger.error("Save message error", { error: t, args: e }), !1;
710
712
  }
@@ -719,14 +721,14 @@ const Q = class Q {
719
721
  async getPublicAgent(e) {
720
722
  this.ctx.loading.value = !0, this.ctx.error.value = null;
721
723
  try {
722
- const r = await (await this.ctx.api.agent.public[":handle"].$get({
724
+ const o = await (await this.ctx.api.agent.public[":handle"].$get({
723
725
  param: { handle: e.handle }
724
726
  })).json();
725
- if (!r.ok) {
726
- this.ctx.error.value = r.error, this.ctx.logger.error("Failed to fetch public agent", { handle: e.handle, error: r.error });
727
+ if (!o.ok) {
728
+ this.ctx.error.value = o.error, this.ctx.logger.error("Failed to fetch public agent", { handle: e.handle, error: o.error });
727
729
  return;
728
730
  }
729
- return r.data;
731
+ return o.data;
730
732
  } catch (t) {
731
733
  this.ctx.logger.error("Get public agent error", { handle: e.handle, error: t }), this.ctx.error.value = t instanceof Error ? t.message : "Failed to fetch agent";
732
734
  return;
@@ -737,14 +739,14 @@ const Q = class Q {
737
739
  async getAgentByEmail(e) {
738
740
  this.ctx.loading.value = !0, this.ctx.error.value = null;
739
741
  try {
740
- const r = await (await this.ctx.api.agent["by-email"][":email"].$get({
742
+ const o = await (await this.ctx.api.agent["by-email"][":email"].$get({
741
743
  param: { email: e.email }
742
744
  })).json();
743
- if (!r.ok) {
744
- this.ctx.error.value = r.error, this.ctx.logger.error("Failed to fetch agent by email", { email: e.email, error: r.error });
745
+ if (!o.ok) {
746
+ this.ctx.error.value = o.error, this.ctx.logger.error("Failed to fetch agent by email", { email: e.email, error: o.error });
745
747
  return;
746
748
  }
747
- return r.data;
749
+ return o.data;
748
750
  } catch (t) {
749
751
  this.ctx.logger.error("Get agent by email error", { email: e.email, error: t }), this.ctx.error.value = t instanceof Error ? t.message : "Failed to fetch agent";
750
752
  return;
@@ -757,7 +759,7 @@ const Q = class Q {
757
759
  const t = this.ctx.currentAgent.value;
758
760
  if (!t?.orgId)
759
761
  return this.ctx.logger.error("Cannot track usage: no current agent with orgId", { args: e }), !1;
760
- const o = await (await this.ctx.api.usage.record.$post({
762
+ const r = await (await this.ctx.api.usage.record.$post({
761
763
  json: {
762
764
  orgId: t.orgId,
763
765
  agentId: e.agentId,
@@ -769,7 +771,7 @@ const Q = class Q {
769
771
  userId: e.participantId || this.ctx.activeUser.value?.userId || "anonymous"
770
772
  }
771
773
  })).json();
772
- return o.ok ? !0 : (this.ctx.logger.error("Failed to track usage", { error: o.error, args: e }), !1);
774
+ return r.ok ? !0 : (this.ctx.logger.error("Failed to track usage", { error: r.error, args: e }), !1);
773
775
  } catch (t) {
774
776
  return this.ctx.logger.error("Track usage error", { error: t, args: e }), !1;
775
777
  }
@@ -781,7 +783,7 @@ const Q = class Q {
781
783
  this.ctx.logger.error("Cannot start conversation: no current agent with orgId", { args: e });
782
784
  return;
783
785
  }
784
- const o = await (await this.ctx.api.conversation.start.$post({
786
+ const r = await (await this.ctx.api.conversation.start.$post({
785
787
  json: {
786
788
  orgId: t.orgId,
787
789
  agentId: e.agentId,
@@ -790,12 +792,12 @@ const Q = class Q {
790
792
  channel: e.channel
791
793
  }
792
794
  })).json();
793
- if (!o.ok || !o.data) {
794
- const s = o.ok ? "No conversation data returned" : "error" in o ? o.error : "Unknown error";
795
+ if (!r.ok || !r.data) {
796
+ const s = r.ok ? "No conversation data returned" : "error" in r ? r.error : "Unknown error";
795
797
  this.ctx.logger.error("Failed to start conversation", { error: s, args: e });
796
798
  return;
797
799
  }
798
- return this.ctx.logger.info("Conversation started", { conversationId: o.data.conversationId }), o.data;
800
+ return this.ctx.logger.info("Conversation started", { conversationId: r.data.conversationId }), r.data;
799
801
  } catch (t) {
800
802
  this.ctx.logger.error("Start conversation error", { error: t, args: e });
801
803
  return;
@@ -803,10 +805,10 @@ const Q = class Q {
803
805
  }
804
806
  async autoCreateContact(e) {
805
807
  try {
806
- const r = await (await this.ctx.api.contact.resolve.$post({
808
+ const o = await (await this.ctx.api.contact.resolve.$post({
807
809
  json: { userId: e.userId, orgId: e.orgId }
808
810
  })).json();
809
- return r.ok ? (this.ctx.logger.info("Contact resolved", { userId: e.userId, orgId: e.orgId }), !0) : (this.ctx.logger.error("Failed to auto-create contact", { error: r.error, args: e }), !1);
811
+ return o.ok ? (this.ctx.logger.info("Contact resolved", { userId: e.userId, orgId: e.orgId }), !0) : (this.ctx.logger.error("Failed to auto-create contact", { error: o.error, args: e }), !1);
810
812
  } catch (t) {
811
813
  return this.ctx.logger.error("Auto-create contact error", { error: t, args: e }), !1;
812
814
  }
@@ -850,9 +852,9 @@ c(Y, "SDKGlobal");
850
852
  let W = Y;
851
853
  const T = new W(), j = class j extends O {
852
854
  constructor(t = {}) {
853
- const r = T.get();
854
- if (r)
855
- return console.debug("[PageLinesSDK] Returning existing singleton instance"), r;
855
+ const o = T.get();
856
+ if (o)
857
+ return console.debug("[PageLinesSDK] Returning existing singleton instance"), o;
856
858
  super("PageLinesSDK", t);
857
859
  // Vue reactive state
858
860
  n(this, "activeUser", E());
@@ -872,17 +874,17 @@ const T = new W(), j = class j extends O {
872
874
  const t = this.activeUser.value;
873
875
  if (!t?.agents)
874
876
  return;
875
- const r = t.primaryAgentId || t.agents[0]?.agentId;
876
- if (r)
877
- return t.agents.find((o) => o.agentId === r);
877
+ const o = t.primaryAgentId || t.agents[0]?.agentId;
878
+ if (o)
879
+ return t.agents.find((r) => r.agentId === o);
878
880
  }));
879
881
  n(this, "currentOrg", ee(() => {
880
882
  const t = this.currentAgent.value;
881
883
  if (!t?.orgId)
882
884
  return;
883
- const r = this.activeUser.value;
884
- if (r?.orgs)
885
- return r.orgs.find((o) => o.orgId === t.orgId);
885
+ const o = this.activeUser.value;
886
+ if (o?.orgs)
887
+ return o.orgs.find((r) => r.orgId === t.orgId);
886
888
  }));
887
889
  // Initialization state
888
890
  n(this, "initialized");
@@ -895,7 +897,7 @@ const T = new W(), j = class j extends O {
895
897
  { isDev: this.isDev, apiBase: this.apiBase },
896
898
  this.processApiResponse.bind(this)
897
899
  );
898
- const o = {
900
+ const r = {
899
901
  api: this.api,
900
902
  apiBase: this.apiBase,
901
903
  isDev: this.isDev,
@@ -909,7 +911,7 @@ const T = new W(), j = class j extends O {
909
911
  logger: this.logger,
910
912
  processApiResponse: this.processApiResponse.bind(this)
911
913
  };
912
- this.auth = new R(o), this.chat = new _(o), this.user = new q(o), this.logger.info("PageLinesSDK initialized"), this.storage.loadFromStorage(this.activeUser, this.token), this.storage.syncWithGlobalStores(this.activeUser, this.token), this.initialized = new Promise((s) => {
914
+ this.auth = new R(r), this.chat = new _(r), this.user = new q(r), this.logger.info("PageLinesSDK initialized"), this.storage.loadFromStorage(this.activeUser, this.token), this.storage.syncWithGlobalStores(this.activeUser, this.token), this.initialized = new Promise((s) => {
913
915
  this.resolveUser = s;
914
916
  }), this.token.value && !this.activeUser.value ? this.getCurrentUser().then((s) => {
915
917
  this.resolveUser && (this.resolveUser(s), this.resolveUser = void 0);
@@ -950,11 +952,11 @@ const T = new W(), j = class j extends O {
950
952
  async sendCode(t) {
951
953
  return this.auth.sendCode(t);
952
954
  }
953
- async verifyCode(t, r) {
954
- return this.auth.verifyCode(t, r);
955
+ async verifyCode(t, o) {
956
+ return this.auth.verifyCode(t, o);
955
957
  }
956
- async login(t, r) {
957
- return this.auth.login(t, r);
958
+ async login(t, o) {
959
+ return this.auth.login(t, o);
958
960
  }
959
961
  async logout() {
960
962
  return this.auth.logout();
@@ -1010,6 +1012,6 @@ export {
1010
1012
  te as P,
1011
1013
  O as S,
1012
1014
  q as U,
1013
- re as c
1015
+ oe as c
1014
1016
  };
1015
- //# sourceMappingURL=sdkClient-yg_rc4B7.js.map
1017
+ //# sourceMappingURL=sdkClient-DlvpHeVt.js.map