@pagelines/sdk 1.0.223 → 1.0.225

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/dist/agent.js CHANGED
@@ -1,10 +1,10 @@
1
1
  var A = Object.defineProperty;
2
2
  var c = (e, r) => A(e, "name", { value: r, configurable: !0 });
3
- import { _ as C, a as M } from "./AgentWrap.vue_vue_type_script_setup_true_lang-Bv9-HnDD.js";
4
- import { b as K, A as L, A as Q, E as R } from "./AgentWrap.vue_vue_type_script_setup_true_lang-Bv9-HnDD.js";
3
+ import { _ as C, a as M } from "./AgentWrap.vue_vue_type_script_setup_true_lang-BThCK162.js";
4
+ import { b as K, A as L, A as Q, E as R } from "./AgentWrap.vue_vue_type_script_setup_true_lang-BThCK162.js";
5
5
  import { defineComponent as x, createBlock as g, openBlock as l, withCtx as b, createElementVNode as o, createVNode as $, ref as h, watch as z, nextTick as E, createElementBlock as f, createCommentVNode as u, normalizeClass as p, normalizeStyle as N } from "vue";
6
6
  import { _ as B } from "./FModal.vue_vue_type_script_setup_true_lang-cL0BFEkZ.js";
7
- import { _ } from "./AgentProvider.vue_vue_type_script_setup_true_lang-Bm-bqBBB.js";
7
+ import { _ } from "./AgentProvider.vue_vue_type_script_setup_true_lang-Cg6HUUjN.js";
8
8
  import { Agent as Y } from "@pagelines/core";
9
9
  const T = { class: "relative w-full h-[80vh] md:h-[600px]" }, F = /* @__PURE__ */ x({
10
10
  name: "AgentModal",
package/dist/api.d.ts CHANGED
@@ -5,6 +5,11 @@ export interface ApiClientSettings {
5
5
  apiBase?: string;
6
6
  [key: string]: unknown;
7
7
  }
8
+ /**
9
+ * Resolve API base URL from settings.
10
+ * Centralizes the isDev/apiBase/production URL logic used across SDK clients.
11
+ */
12
+ export declare function resolveApiBase(apiBase?: string, isDev?: boolean): string;
8
13
  /**
9
14
  * Create fully typed Hono RPC client for PageLines SDK
10
15
  *
package/dist/sdk.js CHANGED
@@ -1,4 +1,4 @@
1
- import { A as t, C as r, P as s, U as o } from "./sdkClient-IfuVpXGX.js";
1
+ import { A as t, C as r, P as s, U as o } from "./sdkClient-Cxrx9Fsc.js";
2
2
  import { MediaSchema as i } from "@pagelines/core";
3
3
  import { S as m } from "./socialPlatforms-Ck-b3SnQ.js";
4
4
  export {
@@ -1,14 +1,18 @@
1
- var M = Object.defineProperty;
2
- var J = (n, t, e) => t in n ? M(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
3
- var u = (n, t) => M(n, "name", { value: t, configurable: !0 });
4
- var i = (n, t, e) => J(n, typeof t != "symbol" ? t + "" : t, e);
5
- import { APP_PORT as A, APP_PROD_URL as E, cookieUtil as x, createLogger as z, objectId as T, SettingsObject as Q } from "@pagelines/core";
6
- import { watch as N, ref as I, computed as W } from "vue";
7
- import { hc as K } from "hono/client";
8
- function V(n, t) {
9
- const e = n.apiBase || (n.isDev ? `http://localhost:${A}` : E);
10
- return K(e, {
11
- fetch: /* @__PURE__ */ u(async (o, s) => {
1
+ var N = Object.defineProperty;
2
+ var z = (i, t, e) => t in i ? N(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
3
+ var c = (i, t) => N(i, "name", { value: t, configurable: !0 });
4
+ var a = (i, t, e) => z(i, typeof t != "symbol" ? t + "" : t, e);
5
+ import { cookieUtil as x, APP_PORT as H, APP_PROD_URL as K, createLogger as Q, objectId as $, SettingsObject as V } from "@pagelines/core";
6
+ import { watch as M, ref as S, computed as W } from "vue";
7
+ import { hc as X } from "hono/client";
8
+ function T(i, t) {
9
+ return i || (t ? `http://localhost:${H}` : K);
10
+ }
11
+ c(T, "resolveApiBase");
12
+ function Y(i, t) {
13
+ const e = T(i.apiBase, i.isDev);
14
+ return X(e, {
15
+ fetch: /* @__PURE__ */ c(async (o, s) => {
12
16
  const g = x.getAuthToken(), d = await fetch(o, {
13
17
  ...s,
14
18
  headers: {
@@ -23,17 +27,17 @@ function V(n, t) {
23
27
  if (t) {
24
28
  const v = d.json.bind(d);
25
29
  d.json = async () => {
26
- const a = await v();
27
- return typeof a == "object" && a !== null && "ok" in a && ("user" in a || "token" in a) && t(a), a;
30
+ const n = await v();
31
+ return typeof n == "object" && n !== null && "ok" in n && ("user" in n || "token" in n) && t(n), n;
28
32
  };
29
33
  }
30
34
  return d;
31
35
  }, "fetch")
32
36
  });
33
37
  }
34
- u(V, "createApiClient");
35
- let H = /* @__PURE__ */ Symbol("clean"), h = [], f = 0;
36
- const k = 4, q = /* @__PURE__ */ u(/* @__NO_SIDE_EFFECTS__ */ (n) => {
38
+ c(Y, "createApiClient");
39
+ let Z = /* @__PURE__ */ Symbol("clean"), h = [], f = 0;
40
+ const U = 4, J = /* @__PURE__ */ c(/* @__NO_SIDE_EFFECTS__ */ (i) => {
37
41
  let t = [], e = {
38
42
  get() {
39
43
  return e.lc || e.listen(() => {
@@ -42,8 +46,8 @@ const k = 4, q = /* @__PURE__ */ u(/* @__NO_SIDE_EFFECTS__ */ (n) => {
42
46
  lc: 0,
43
47
  listen(r) {
44
48
  return e.lc = t.push(r), () => {
45
- for (let s = f + k; s < h.length; )
46
- h[s] === r ? h.splice(s, k) : s += k;
49
+ for (let s = f + U; s < h.length; )
50
+ h[s] === r ? h.splice(s, U) : s += U;
47
51
  let o = t.indexOf(r);
48
52
  ~o && (t.splice(o, 1), --e.lc || e.off());
49
53
  };
@@ -53,7 +57,7 @@ const k = 4, q = /* @__PURE__ */ u(/* @__NO_SIDE_EFFECTS__ */ (n) => {
53
57
  for (let g of t)
54
58
  h.push(g, e.value, r, o);
55
59
  if (s) {
56
- for (f = 0; f < h.length; f += k)
60
+ for (f = 0; f < h.length; f += U)
57
61
  h[f](
58
62
  h[f + 1],
59
63
  h[f + 2],
@@ -74,14 +78,14 @@ const k = 4, q = /* @__PURE__ */ u(/* @__NO_SIDE_EFFECTS__ */ (n) => {
74
78
  let o = e.listen(r);
75
79
  return r(e.value), o;
76
80
  },
77
- value: n
81
+ value: i
78
82
  };
79
- return process.env.NODE_ENV !== "production" && (e[H] = () => {
83
+ return process.env.NODE_ENV !== "production" && (e[Z] = () => {
80
84
  t = [], e.lc = 0, e.off();
81
85
  }), e;
82
- }, "atom"), S = /* @__PURE__ */ q(void 0), U = /* @__PURE__ */ q(null), B = class B {
86
+ }, "atom"), y = globalThis, b = y.__PL_AUTH_USER__ ?? (y.__PL_AUTH_USER__ = /* @__PURE__ */ J(void 0)), A = y.__PL_AUTH_TOKEN__ ?? (y.__PL_AUTH_TOKEN__ = /* @__PURE__ */ J(null)), R = class R {
83
87
  constructor() {
84
- i(this, "logger", z("SDKStorage"));
88
+ a(this, "logger", Q("SDKStorage"));
85
89
  }
86
90
  /**
87
91
  * Check if localStorage is fully functional (some test environments provide partial mocks)
@@ -93,14 +97,14 @@ const k = 4, q = /* @__PURE__ */ u(/* @__NO_SIDE_EFFECTS__ */ (n) => {
93
97
  * Sync Vue reactive refs with global nanostores for cross-page persistence
94
98
  */
95
99
  syncWithGlobalStores(t, e) {
96
- const r = S.get(), o = U.get();
97
- r && (t.value = r), o && (e.value = o), N(t, (s) => {
98
- S.set(s);
99
- }, { immediate: !0 }), N(e, (s) => {
100
- U.set(s);
101
- }, { immediate: !0 }), S.subscribe((s) => {
100
+ const r = b.get(), o = A.get();
101
+ r && (t.value = r), o && (e.value = o), M(t, (s) => {
102
+ b.set(s);
103
+ }, { immediate: !0 }), M(e, (s) => {
104
+ A.set(s);
105
+ }, { immediate: !0 }), b.subscribe((s) => {
102
106
  s !== t.value && (t.value = s);
103
- }), U.subscribe((s) => {
107
+ }), A.subscribe((s) => {
104
108
  s !== e.value && (e.value = s);
105
109
  });
106
110
  }
@@ -141,7 +145,7 @@ const k = 4, q = /* @__PURE__ */ u(/* @__NO_SIDE_EFFECTS__ */ (n) => {
141
145
  } catch (t) {
142
146
  this.logger.error("Failed to clear user from localStorage", { data: t });
143
147
  }
144
- S.set(void 0), U.set(null);
148
+ b.set(void 0), A.set(null);
145
149
  }
146
150
  }
147
151
  /**
@@ -168,157 +172,159 @@ const k = 4, q = /* @__PURE__ */ u(/* @__NO_SIDE_EFFECTS__ */ (n) => {
168
172
  }
169
173
  }
170
174
  };
171
- u(B, "SDKStorage");
172
- let L = B;
173
- const D = class D {
175
+ c(R, "SDKStorage");
176
+ let j = R;
177
+ async function p(i, t) {
178
+ i.loading.value = !0, i.error.value = null;
179
+ try {
180
+ return await t();
181
+ } finally {
182
+ i.loading.value = !1;
183
+ }
184
+ }
185
+ c(p, "withLoadingState");
186
+ const _ = class _ {
174
187
  constructor(t) {
175
188
  this.ctx = t;
176
189
  }
177
190
  async sendCode(t) {
178
- this.ctx.loading.value = !0, this.ctx.error.value = null;
179
- try {
180
- const r = await (await this.ctx.api.auth["check-email"].$post({
181
- json: { email: t }
182
- })).json();
183
- if (!r.ok)
184
- throw this.ctx.error.value = r.error, new Error(r.error);
185
- } catch (e) {
186
- this.ctx.logger.error("Send code error", { data: e });
187
- const r = e instanceof Error ? e.message : "Failed to send verification code";
188
- throw this.ctx.error.value = r, e;
189
- } finally {
190
- this.ctx.loading.value = !1;
191
- }
191
+ return p(this.ctx, async () => {
192
+ try {
193
+ const r = await (await this.ctx.api.auth["check-email"].$post({
194
+ json: { email: t }
195
+ })).json();
196
+ if (!r.ok)
197
+ throw this.ctx.error.value = r.error, new Error(r.error);
198
+ } catch (e) {
199
+ this.ctx.logger.error("Send code error", { data: e });
200
+ const r = e instanceof Error ? e.message : "Failed to send verification code";
201
+ throw this.ctx.error.value = r, e;
202
+ }
203
+ });
192
204
  }
193
205
  async verifyCode(t, e) {
194
- this.ctx.loading.value = !0, this.ctx.error.value = null;
195
- try {
196
- const o = await (await this.ctx.api.auth["verify-code"].$post({
197
- json: { email: t, code: e }
198
- })).json();
199
- if (!o.ok)
200
- throw this.ctx.error.value = o.error, new Error(o.error);
201
- } catch (r) {
202
- this.ctx.logger.error("Verify code error", { data: r });
203
- const o = r instanceof Error ? r.message : "Failed to verify code";
204
- throw this.ctx.error.value = o, r;
205
- } finally {
206
- this.ctx.loading.value = !1;
207
- }
206
+ return p(this.ctx, async () => {
207
+ try {
208
+ const o = await (await this.ctx.api.auth["verify-code"].$post({
209
+ json: { email: t, code: e }
210
+ })).json();
211
+ if (!o.ok)
212
+ throw this.ctx.error.value = o.error, new Error(o.error);
213
+ } catch (r) {
214
+ this.ctx.logger.error("Verify code error", { data: r });
215
+ const o = r instanceof Error ? r.message : "Failed to verify code";
216
+ throw this.ctx.error.value = o, r;
217
+ }
218
+ });
208
219
  }
209
220
  async login(t, e) {
210
- this.ctx.loading.value = !0, this.ctx.error.value = null;
211
- try {
212
- const o = await (await this.ctx.api.auth.login.$post({
213
- json: { email: t, password: e }
214
- })).json();
215
- if (!o.ok)
216
- throw this.ctx.error.value = o.error, new Error(o.error);
217
- } catch (r) {
218
- this.ctx.logger.error("Login error", { data: r });
219
- const o = r instanceof Error ? r.message : "Login failed";
220
- throw this.ctx.error.value = o, r;
221
- } finally {
222
- this.ctx.loading.value = !1;
223
- }
221
+ return p(this.ctx, async () => {
222
+ try {
223
+ const o = await (await this.ctx.api.auth.login.$post({
224
+ json: { email: t, password: e }
225
+ })).json();
226
+ if (!o.ok)
227
+ throw this.ctx.error.value = o.error, new Error(o.error);
228
+ } catch (r) {
229
+ this.ctx.logger.error("Login error", { data: r });
230
+ const o = r instanceof Error ? r.message : "Login failed";
231
+ throw this.ctx.error.value = o, r;
232
+ }
233
+ });
224
234
  }
225
235
  async logout() {
226
- this.ctx.loading.value = !0, this.ctx.error.value = null;
227
- try {
228
- await this.ctx.api.auth.logout.$post(), this.ctx.activeUser.value = void 0, this.ctx.token.value = null, this.ctx.storage.clearStorage();
229
- } catch (t) {
230
- this.ctx.logger.error("Logout error (user still logged out locally)", { data: t }), this.ctx.activeUser.value = void 0, this.ctx.token.value = null, this.ctx.storage.clearStorage();
231
- } finally {
232
- this.ctx.loading.value = !1;
233
- }
236
+ return p(this.ctx, async () => {
237
+ try {
238
+ await this.ctx.api.auth.logout.$post();
239
+ } catch (t) {
240
+ this.ctx.logger.error("Logout error (user still logged out locally)", { data: t });
241
+ }
242
+ this.ctx.activeUser.value = void 0, this.ctx.token.value = null, this.ctx.storage.clearStorage();
243
+ });
234
244
  }
235
245
  async getCurrentUser() {
236
- if (this.ctx.token.value) {
237
- this.ctx.loading.value = !0;
238
- try {
239
- const e = await (await this.ctx.api.auth.me.$get()).json();
240
- if (!e.ok) {
241
- this.ctx.error.value = e.error, e.error.includes("Authentication") && (this.ctx.activeUser.value = void 0, this.ctx.token.value = null, this.ctx.storage.clearStorage());
246
+ if (this.ctx.token.value)
247
+ return p(this.ctx, async () => {
248
+ try {
249
+ const e = await (await this.ctx.api.auth.me.$get()).json();
250
+ if (!e.ok) {
251
+ this.ctx.error.value = e.error, e.error.includes("Authentication") && (this.ctx.activeUser.value = void 0, this.ctx.token.value = null, this.ctx.storage.clearStorage());
252
+ return;
253
+ }
254
+ return e.user;
255
+ } catch (t) {
256
+ this.ctx.logger.error("Get current user error", { data: t }), this.ctx.error.value = t instanceof Error ? t.message : "Failed to get user info";
242
257
  return;
243
258
  }
244
- return e.user;
245
- } catch (t) {
246
- this.ctx.logger.error("Get current user error", { data: t }), this.ctx.error.value = t instanceof Error ? t.message : "Failed to get user info";
247
- return;
248
- } finally {
249
- this.ctx.loading.value = !1;
250
- }
251
- }
259
+ });
252
260
  }
253
261
  async requestAuthCode(t) {
254
- this.ctx.loading.value = !0, this.ctx.error.value = null;
255
- try {
256
- const r = await (await this.ctx.api.auth["check-email"].$post({
257
- json: { email: t.email }
258
- })).json();
259
- return r.ok ? (this.ctx.logger.info("Auth code requested successfully", { email: t.email }), !0) : (this.ctx.error.value = r.error, this.ctx.logger.error("Failed to request auth code", { email: t.email, error: r.error }), !1);
260
- } catch (e) {
261
- return this.ctx.logger.error("Request auth code error", { email: t.email, error: e }), this.ctx.error.value = e instanceof Error ? e.message : "Failed to request auth code", !1;
262
- } finally {
263
- this.ctx.loading.value = !1;
264
- }
262
+ return p(this.ctx, async () => {
263
+ try {
264
+ const r = await (await this.ctx.api.auth["check-email"].$post({
265
+ json: { email: t.email }
266
+ })).json();
267
+ return r.ok ? (this.ctx.logger.info("Auth code requested successfully", { email: t.email }), !0) : (this.ctx.error.value = r.error, this.ctx.logger.error("Failed to request auth code", { email: t.email, error: r.error }), !1);
268
+ } catch (e) {
269
+ return this.ctx.logger.error("Request auth code error", { email: t.email, error: e }), this.ctx.error.value = e instanceof Error ? e.message : "Failed to request auth code", !1;
270
+ }
271
+ });
265
272
  }
266
273
  async loginWithCode(t) {
267
- this.ctx.loading.value = !0, this.ctx.error.value = null;
268
- try {
269
- const r = await (await this.ctx.api.auth["verify-code"].$post({
270
- json: { email: t.email, code: t.code }
271
- })).json();
272
- return r.ok ? (this.ctx.logger.info("Login successful", { email: t.email }), !0) : (this.ctx.error.value = r.error, this.ctx.logger.error("Login failed", { email: t.email, error: r.error }), !1);
273
- } catch (e) {
274
- return this.ctx.logger.error("Login with code error", { email: t.email, error: e }), this.ctx.error.value = e instanceof Error ? e.message : "Login failed", !1;
275
- } finally {
276
- this.ctx.loading.value = !1;
277
- }
274
+ return p(this.ctx, async () => {
275
+ try {
276
+ const r = await (await this.ctx.api.auth["verify-code"].$post({
277
+ json: { email: t.email, code: t.code }
278
+ })).json();
279
+ return r.ok ? (this.ctx.logger.info("Login successful", { email: t.email }), !0) : (this.ctx.error.value = r.error, this.ctx.logger.error("Login failed", { email: t.email, error: r.error }), !1);
280
+ } catch (e) {
281
+ return this.ctx.logger.error("Login with code error", { email: t.email, error: e }), this.ctx.error.value = e instanceof Error ? e.message : "Login failed", !1;
282
+ }
283
+ });
278
284
  }
279
285
  loginWithGoogle(t) {
280
286
  if (typeof window > "u") {
281
287
  this.ctx.logger.error("loginWithGoogle: Only available in browser");
282
288
  return;
283
289
  }
284
- const e = this.ctx.apiBase || (this.ctx.isDev ? `http://localhost:${A}` : E), r = window.location.origin, o = `${e}/auth/google-popup?origin=${encodeURIComponent(r)}`, s = 500, g = 600, d = window.screenX + (window.outerWidth - s) / 2, v = window.screenY + (window.outerHeight - g) / 2, a = window.open(
290
+ const e = T(this.ctx.apiBase, this.ctx.isDev), r = window.location.origin, o = `${e}/auth/google-popup?origin=${encodeURIComponent(r)}`, s = 500, g = 600, d = window.screenX + (window.outerWidth - s) / 2, v = window.screenY + (window.outerHeight - g) / 2, n = window.open(
285
291
  o,
286
292
  "google-auth",
287
293
  `width=${s},height=${g},left=${d},top=${v},popup=yes`
288
294
  );
289
- if (!a) {
295
+ if (!n) {
290
296
  const l = "Popup was blocked. Please allow popups for this site.";
291
297
  this.ctx.error.value = l, t?.onError?.(l);
292
298
  return;
293
299
  }
294
- const p = /* @__PURE__ */ u((l) => {
295
- const w = new URL(e).origin;
296
- if (l.origin === w) {
300
+ const m = /* @__PURE__ */ c((l) => {
301
+ const k = new URL(e).origin;
302
+ if (l.origin === k) {
297
303
  if (l.data?.type === "auth-success") {
298
- window.removeEventListener("message", p);
299
- const { token: c, user: m } = l.data;
300
- this.ctx.processApiResponse({ ok: !0, data: {}, token: c, user: m }), this.ctx.logger.info("Google login successful"), t?.onSuccess?.(m);
304
+ window.removeEventListener("message", m);
305
+ const { token: u, user: w } = l.data;
306
+ this.ctx.processApiResponse({ ok: !0, data: {}, token: u, user: w }), this.ctx.logger.info("Google login successful"), t?.onSuccess?.(w);
301
307
  } else if (l.data?.type === "auth-error") {
302
- window.removeEventListener("message", p);
303
- const c = l.data.error || "Google authentication failed";
304
- this.ctx.error.value = c, this.ctx.logger.error("Google login failed", { error: c }), t?.onError?.(c);
308
+ window.removeEventListener("message", m);
309
+ const u = l.data.error || "Google authentication failed";
310
+ this.ctx.error.value = u, this.ctx.logger.error("Google login failed", { error: u }), t?.onError?.(u);
305
311
  }
306
312
  }
307
313
  }, "handler");
308
- window.addEventListener("message", p);
309
- const y = setInterval(() => {
310
- a.closed && (clearInterval(y), window.removeEventListener("message", p));
314
+ window.addEventListener("message", m);
315
+ const I = setInterval(() => {
316
+ n.closed && (clearInterval(I), window.removeEventListener("message", m));
311
317
  }, 500);
312
318
  }
313
319
  };
314
- u(D, "AuthClient");
315
- let j = D;
316
- const R = class R {
320
+ c(_, "AuthClient");
321
+ let C = _;
322
+ const D = class D {
317
323
  constructor(t) {
318
324
  this.ctx = t;
319
325
  }
320
326
  async chatStream(t) {
321
- const r = `${this.ctx.apiBase || (this.ctx.isDev ? `http://localhost:${A}` : E)}/api/agent/public/${encodeURIComponent(t.handle)}/chat/stream`;
327
+ const r = `${T(this.ctx.apiBase, this.ctx.isDev)}/api/agent/public/${encodeURIComponent(t.handle)}/chat/stream`;
322
328
  try {
323
329
  const o = await fetch(r, {
324
330
  method: "POST",
@@ -333,8 +339,8 @@ const R = class R {
333
339
  })
334
340
  });
335
341
  if (!o.ok) {
336
- const a = await o.json().catch(() => ({ error: "Request failed" }));
337
- t.onError(a.error || `HTTP ${o.status}`);
342
+ const n = await o.json().catch(() => ({ error: "Request failed" }));
343
+ t.onError(n.error || `HTTP ${o.status}`);
338
344
  return;
339
345
  }
340
346
  const s = o.body?.getReader();
@@ -345,30 +351,30 @@ const R = class R {
345
351
  const g = new TextDecoder();
346
352
  let d = "", v = t.conversationId || "";
347
353
  for (; ; ) {
348
- const { done: a, value: p } = await s.read();
349
- if (a)
354
+ const { done: n, value: m } = await s.read();
355
+ if (n)
350
356
  break;
351
- d += g.decode(p, { stream: !0 });
352
- const y = d.split(`
357
+ d += g.decode(m, { stream: !0 });
358
+ const I = d.split(`
353
359
  `);
354
- d = y.pop() || "";
355
- for (const l of y) {
360
+ d = I.pop() || "";
361
+ for (const l of I) {
356
362
  if (!l.startsWith("data: "))
357
363
  continue;
358
- const w = l.slice(6).trim();
359
- if (w === "[DONE]") {
364
+ const k = l.slice(6).trim();
365
+ if (k === "[DONE]") {
360
366
  t.onDone(v);
361
367
  return;
362
368
  }
363
369
  try {
364
- const c = JSON.parse(w);
365
- if (c.pl_status) {
366
- t.onStatus?.(c.pl_status);
370
+ const u = JSON.parse(k);
371
+ if (u.pl_status) {
372
+ t.onStatus?.(u.pl_status);
367
373
  continue;
368
374
  }
369
- c.pl_metadata?.conversationId && (v = c.pl_metadata.conversationId);
370
- const m = c.choices?.[0]?.delta;
371
- m?.content && t.onDelta(m.content);
375
+ u.pl_metadata?.conversationId && (v = u.pl_metadata.conversationId);
376
+ const w = u.choices?.[0]?.delta;
377
+ w?.content && t.onDelta(w.content);
372
378
  } catch {
373
379
  }
374
380
  }
@@ -379,7 +385,7 @@ const R = class R {
379
385
  }
380
386
  }
381
387
  async chatMessage(t) {
382
- const r = `${this.ctx.apiBase || (this.ctx.isDev ? `http://localhost:${A}` : E)}/api/agent/public/${encodeURIComponent(t.handle)}/chat`;
388
+ const r = `${T(this.ctx.apiBase, this.ctx.isDev)}/api/agent/public/${encodeURIComponent(t.handle)}/chat`;
383
389
  try {
384
390
  const s = await (await fetch(r, {
385
391
  method: "POST",
@@ -405,8 +411,8 @@ const R = class R {
405
411
  }
406
412
  }
407
413
  };
408
- u(R, "ChatClient");
409
- let C = R;
414
+ c(D, "ChatClient");
415
+ let P = D;
410
416
  const O = class O {
411
417
  constructor(t) {
412
418
  this.ctx = t;
@@ -450,7 +456,7 @@ const O = class O {
450
456
  generateAnonId() {
451
457
  const t = "pagelinesAnonId";
452
458
  let e = this.ctx.storage.getItem(t);
453
- return e || (e = T({ prefix: "anon" }), this.ctx.storage.setItem(t, e)), e;
459
+ return e || (e = $({ prefix: "anon" }), this.ctx.storage.setItem(t, e)), e;
454
460
  }
455
461
  track(t) {
456
462
  try {
@@ -465,11 +471,11 @@ const O = class O {
465
471
  }
466
472
  }
467
473
  };
468
- u(O, "UserClient");
474
+ c(O, "UserClient");
469
475
  let F = O;
470
476
  const G = class G {
471
477
  constructor() {
472
- i(this, "key", "__PAGELINES_SDK__");
478
+ a(this, "key", "__PAGELINES_SDK__");
473
479
  }
474
480
  get() {
475
481
  if (!(typeof window > "u"))
@@ -482,29 +488,29 @@ const G = class G {
482
488
  typeof window < "u" && delete globalThis[this.key];
483
489
  }
484
490
  };
485
- u(G, "SDKGlobal");
486
- let P = G;
487
- const b = new P(), $ = class $ extends Q {
491
+ c(G, "SDKGlobal");
492
+ let B = G;
493
+ const E = new B(), L = class L extends V {
488
494
  constructor(e = {}) {
489
- const r = b.get();
495
+ const r = E.get();
490
496
  if (r)
491
497
  return console.debug("[PageLinesSDK] Returning existing singleton instance"), r;
492
498
  super("PageLinesSDK", e);
493
499
  // Vue reactive state
494
- i(this, "activeUser", I());
495
- i(this, "token", I(null));
496
- i(this, "loading", I(!1));
497
- i(this, "error", I(null));
498
- i(this, "apiBase", this.settings.apiBase || void 0);
500
+ a(this, "activeUser", S());
501
+ a(this, "token", S(null));
502
+ a(this, "loading", S(!1));
503
+ a(this, "error", S(null));
504
+ a(this, "apiBase", this.settings.apiBase || void 0);
499
505
  // Storage handler for persistence
500
- i(this, "storage", new L());
506
+ a(this, "storage", new j());
501
507
  // Auto-managed session ID for usage tracking
502
- i(this, "sessionId", T({ prefix: "ses" }));
508
+ a(this, "sessionId", $({ prefix: "ses" }));
503
509
  // Typed Hono RPC client - uses SDKAppType (auth/self/usage routes only)
504
510
  // Initialized in constructor (definite assignment via singleton pattern)
505
- i(this, "apiClient");
511
+ a(this, "apiClient");
506
512
  // Computed properties derived from activeUser (matches UserClient pattern)
507
- i(this, "currentAgent", W(() => {
513
+ a(this, "currentAgent", W(() => {
508
514
  const e = this.activeUser.value;
509
515
  if (!e?.agents)
510
516
  return;
@@ -512,7 +518,7 @@ const b = new P(), $ = class $ extends Q {
512
518
  if (r)
513
519
  return e.agents.find((o) => o.agentId === r);
514
520
  }));
515
- i(this, "currentOrg", W(() => {
521
+ a(this, "currentOrg", W(() => {
516
522
  const e = this.currentAgent.value;
517
523
  if (!e?.orgId)
518
524
  return;
@@ -521,13 +527,13 @@ const b = new P(), $ = class $ extends Q {
521
527
  return r.orgs.find((o) => o.orgId === e.orgId);
522
528
  }));
523
529
  // Initialization state
524
- i(this, "initialized");
525
- i(this, "resolveUser");
530
+ a(this, "initialized");
531
+ a(this, "resolveUser");
526
532
  // Sub-clients (new preferred API surface)
527
- i(this, "auth");
528
- i(this, "chat");
529
- i(this, "user");
530
- b.set(this), this.apiClient = V(
533
+ a(this, "auth");
534
+ a(this, "chat");
535
+ a(this, "user");
536
+ E.set(this), this.apiClient = Y(
531
537
  { isDev: this.isDev, apiBase: this.apiBase },
532
538
  this.processApiResponse.bind(this)
533
539
  );
@@ -545,7 +551,7 @@ const b = new P(), $ = class $ extends Q {
545
551
  logger: this.logger,
546
552
  processApiResponse: this.processApiResponse.bind(this)
547
553
  };
548
- this.auth = new j(o), this.chat = new C(o), this.user = new F(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) => {
554
+ this.auth = new C(o), this.chat = new P(o), this.user = new F(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) => {
549
555
  this.resolveUser = s;
550
556
  }), this.token.value && !this.activeUser.value ? this.getCurrentUser().then((s) => {
551
557
  this.resolveUser && (this.resolveUser(s), this.resolveUser = void 0);
@@ -559,7 +565,7 @@ const b = new P(), $ = class $ extends Q {
559
565
  * Recommended: Use this instead of constructor for shared state
560
566
  */
561
567
  static getInstance(e = {}) {
562
- return b.get() || new $(e);
568
+ return E.get() || new L(e);
563
569
  }
564
570
  get isDev() {
565
571
  return this.settings.isDev ?? (typeof window < "u" ? window.location.hostname === "localhost" || window.location.hostname.includes("127.0.0.1") : !1);
@@ -579,7 +585,7 @@ const b = new P(), $ = class $ extends Q {
579
585
  }
580
586
  // Full reset - clears session + state + destroys singleton
581
587
  clear() {
582
- this.logger.info("Clearing SDK completely"), this.clearSession(), this.loading.value = !1, this.sessionId = T({ prefix: "ses" }), b.delete();
588
+ this.logger.info("Clearing SDK completely"), this.clearSession(), this.loading.value = !1, this.sessionId = $({ prefix: "ses" }), E.delete();
583
589
  }
584
590
  // Backward-compatible delegates — these forward to sub-clients
585
591
  // Can be removed in a future breaking change
@@ -626,12 +632,12 @@ const b = new P(), $ = class $ extends Q {
626
632
  return this.user.track(e);
627
633
  }
628
634
  };
629
- u($, "PageLinesSDK");
630
- let _ = $;
635
+ c(L, "PageLinesSDK");
636
+ let q = L;
631
637
  export {
632
- j as A,
633
- C,
634
- _ as P,
638
+ C as A,
639
+ P as C,
640
+ q as P,
635
641
  F as U
636
642
  };
637
- //# sourceMappingURL=sdkClient-IfuVpXGX.js.map
643
+ //# sourceMappingURL=sdkClient-Cxrx9Fsc.js.map