tevrocsdk 0.1.76 → 0.1.78

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/tevroc-sdk.esm.js CHANGED
@@ -3821,7 +3821,7 @@ var init_useGoogleAuth = __esm({
3821
3821
  debugLog("appId:", appId, "serviceUrl:", serviceUrl);
3822
3822
  debugLog(isCapacitor, isTauri);
3823
3823
  await initializeGoogleLogin();
3824
- let authUrl = `${serviceUrl}/login?mode=mobile&app=${encodeURIComponent(appId)}&name=${encodeURIComponent(appName)}`;
3824
+ let authUrl = `${serviceUrl}/auth/google/login?mode=mobile&app=${encodeURIComponent(appId)}&name=${encodeURIComponent(appName)}`;
3825
3825
  if (isCapacitor) {
3826
3826
  const { Browser: Browser3 } = await getCapacitorPlugins();
3827
3827
  await Browser3.open({ url: authUrl });
@@ -3830,7 +3830,7 @@ var init_useGoogleAuth = __esm({
3830
3830
  if (isTauri) {
3831
3831
  const WebviewWindow2 = await getTauriWebviewWindow();
3832
3832
  await closeAllTauriWebviews();
3833
- const url = `${serviceUrl}/login?mode=desktop&app=${encodeURIComponent(appId)}&name=${encodeURIComponent(appName)}`;
3833
+ const url = `${serviceUrl}/auth/google/login?mode=desktop&app=${encodeURIComponent(appId)}&name=${encodeURIComponent(appName)}`;
3834
3834
  const win = new WebviewWindow2("auth", {
3835
3835
  url,
3836
3836
  title: `${appName} Login`,
@@ -3851,7 +3851,7 @@ var init_useGoogleAuth = __esm({
3851
3851
  const isLocalhost = true;
3852
3852
  const detectedAppId = typeof window !== "undefined" ? window.location.host : appId;
3853
3853
  const mode = isLocalhost ? "localhost" : "netlify";
3854
- const finalUrl = `${serviceUrl}/login?mode=${mode}&app=${encodeURIComponent(
3854
+ const finalUrl = `${serviceUrl}/auth/google/login?mode=${mode}&app=${encodeURIComponent(
3855
3855
  detectedAppId
3856
3856
  )}&name=${encodeURIComponent(appName)}`;
3857
3857
  if (isLocalhost) {
@@ -40762,6 +40762,131 @@ function createPdfApi() {
40762
40762
  };
40763
40763
  }
40764
40764
 
40765
+ // src/services/notifications.js
40766
+ var isBrowser = () => typeof window !== "undefined" && typeof Notification !== "undefined";
40767
+ function createNotificationService() {
40768
+ const listeners2 = /* @__PURE__ */ new Set();
40769
+ const scheduled = /* @__PURE__ */ new Map();
40770
+ let nativeListenerInstalled = false;
40771
+ const emit2 = (event) => listeners2.forEach((listener) => listener(event));
40772
+ const appPlugin = () => globalThis?.Capacitor?.Plugins?.AppNotifications;
40773
+ const installNativeListener = () => {
40774
+ if (nativeListenerInstalled) return;
40775
+ const plugin = appPlugin();
40776
+ if (!plugin?.addListener) return;
40777
+ nativeListenerInstalled = true;
40778
+ plugin.addListener("notificationAction", (event) => {
40779
+ let data = event?.data || {};
40780
+ if (typeof data === "string") {
40781
+ try {
40782
+ data = JSON.parse(data);
40783
+ } catch {
40784
+ data = {};
40785
+ }
40786
+ }
40787
+ emit2({
40788
+ id: event?.id,
40789
+ action: event?.action || "open",
40790
+ reply: event?.reply || "",
40791
+ data,
40792
+ platform: "capacitor"
40793
+ });
40794
+ });
40795
+ plugin.consumePendingAction?.().catch?.(() => {
40796
+ });
40797
+ };
40798
+ const permission = async () => {
40799
+ const plugin = appPlugin();
40800
+ if (plugin?.checkPermissions) return plugin.checkPermissions();
40801
+ if (globalThis?.__TAURI_INTERNALS__) {
40802
+ try {
40803
+ const tauri = await new Function("name", "return import(name)")("@tauri-apps/plugin-notification");
40804
+ return { display: await tauri.isPermissionGranted() ? "granted" : "prompt" };
40805
+ } catch {
40806
+ return { display: "denied" };
40807
+ }
40808
+ }
40809
+ return { display: isBrowser() ? Notification.permission : "denied" };
40810
+ };
40811
+ const requestPermission = async () => {
40812
+ const plugin = appPlugin();
40813
+ if (plugin?.requestPermissions) return plugin.requestPermissions();
40814
+ if (globalThis?.__TAURI_INTERNALS__) {
40815
+ try {
40816
+ const tauri = await new Function("name", "return import(name)")("@tauri-apps/plugin-notification");
40817
+ return { display: await tauri.requestPermission() };
40818
+ } catch {
40819
+ return { display: "denied" };
40820
+ }
40821
+ }
40822
+ return { display: isBrowser() ? await Notification.requestPermission() : "denied" };
40823
+ };
40824
+ const show = async (options = {}) => {
40825
+ const id = String(options.id || `notification_${Date.now()}_${Math.random().toString(36).slice(2)}`);
40826
+ const request = {
40827
+ id,
40828
+ title: options.title || "Notification",
40829
+ body: options.body || "",
40830
+ data: options.data || {},
40831
+ actions: options.actions || [],
40832
+ silent: Boolean(options.silent),
40833
+ channel: options.channel || "general",
40834
+ style: options.style || {}
40835
+ };
40836
+ const plugin = appPlugin();
40837
+ if (plugin?.show) {
40838
+ installNativeListener();
40839
+ await plugin.show(request);
40840
+ return { id, platform: "capacitor" };
40841
+ }
40842
+ if (globalThis?.__TAURI_INTERNALS__) {
40843
+ try {
40844
+ const tauri = await new Function("name", "return import(name)")("@tauri-apps/plugin-notification");
40845
+ const current = await tauri.isPermissionGranted() ? "granted" : await tauri.requestPermission();
40846
+ if (current === "granted") {
40847
+ tauri.sendNotification({ title: request.title, body: request.body, extra: request.data });
40848
+ return { id, platform: "tauri" };
40849
+ }
40850
+ } catch {
40851
+ }
40852
+ }
40853
+ if (!isBrowser()) throw new Error("Notifications are not supported on this platform.");
40854
+ const state = Notification.permission === "default" ? await Notification.requestPermission() : Notification.permission;
40855
+ if (state !== "granted") throw new Error("Notification permission was not granted.");
40856
+ const notification = new Notification(request.title, { body: request.body, tag: id, data: request.data, silent: request.silent });
40857
+ notification.onclick = () => emit2({ id, action: "open", data: request.data, platform: "web" });
40858
+ return { id, platform: "web", notification };
40859
+ };
40860
+ const schedule = async (options = {}) => {
40861
+ const at2 = new Date(options.at || Date.now()).getTime();
40862
+ const delay = Math.max(0, at2 - Date.now());
40863
+ const id = String(options.id || `notification_${at2}_${Math.random().toString(36).slice(2)}`);
40864
+ const timeout = setTimeout(() => {
40865
+ scheduled.delete(id);
40866
+ show({ ...options, id }).catch((error) => emit2({ type: "error", error }));
40867
+ }, delay);
40868
+ scheduled.set(id, timeout);
40869
+ return { id, at: at2 };
40870
+ };
40871
+ const cancel = async (id) => {
40872
+ const timeout = scheduled.get(String(id));
40873
+ if (timeout) clearTimeout(timeout);
40874
+ scheduled.delete(String(id));
40875
+ await appPlugin()?.cancel?.({ id: String(id) });
40876
+ };
40877
+ const cancelAll = async () => {
40878
+ for (const timeout of scheduled.values()) clearTimeout(timeout);
40879
+ scheduled.clear();
40880
+ await appPlugin()?.cancelAll?.();
40881
+ };
40882
+ const onAction = (listener) => {
40883
+ installNativeListener();
40884
+ listeners2.add(listener);
40885
+ return () => listeners2.delete(listener);
40886
+ };
40887
+ return { permission, requestPermission, show, schedule, cancel, cancelAll, onAction };
40888
+ }
40889
+
40765
40890
  // src/services/agentNotifications.js
40766
40891
  var toList = (result) => Array.isArray(result) ? result : result?.data || [];
40767
40892
  var latestByTime = (records) => [...records].sort((a3, b2) => {
@@ -40770,6 +40895,7 @@ var latestByTime = (records) => [...records].sort((a3, b2) => {
40770
40895
  return right - left;
40771
40896
  })[0] || null;
40772
40897
  function createAgentNotificationService(client) {
40898
+ const notifications = client.notifications || createNotificationService();
40773
40899
  let timer = null;
40774
40900
  let stopped = true;
40775
40901
  const seen = /* @__PURE__ */ new Map();
@@ -40850,7 +40976,7 @@ function createAgentNotificationService(client) {
40850
40976
  if (action === "reject") return reject(session);
40851
40977
  if (action === "reply") return reply(session, text2);
40852
40978
  };
40853
- const showNative = (request) => client.notifications.show({
40979
+ const showNative = (request) => notifications.show({
40854
40980
  id: `agent-request-${request.sessionId}`,
40855
40981
  title: request.title,
40856
40982
  body: request.body,
@@ -40929,7 +41055,7 @@ function createAgentNotificationService(client) {
40929
41055
  listeners2.add(listener);
40930
41056
  return () => listeners2.delete(listener);
40931
41057
  };
40932
- client.notifications.onAction(({ action, data, reply: text2 }) => {
41058
+ notifications.onAction(({ action, data, reply: text2 }) => {
40933
41059
  if (data?.sessionId && String(data.kind || "").startsWith("agent_")) {
40934
41060
  dispatchAction({ action, sessionId: data.sessionId, reply: text2 }).catch((error) => notify({ type: "error", error }));
40935
41061
  }
@@ -40937,138 +41063,14 @@ function createAgentNotificationService(client) {
40937
41063
  return { start, stop, check, onEvent, accept, reject, reply, dispatchAction };
40938
41064
  }
40939
41065
 
40940
- // src/services/notifications.js
40941
- var isBrowser = () => typeof window !== "undefined" && typeof Notification !== "undefined";
40942
- function createNotificationService() {
40943
- const listeners2 = /* @__PURE__ */ new Set();
40944
- const scheduled = /* @__PURE__ */ new Map();
40945
- let nativeListenerInstalled = false;
40946
- const emit2 = (event) => listeners2.forEach((listener) => listener(event));
40947
- const appPlugin = () => globalThis?.Capacitor?.Plugins?.AppNotifications;
40948
- const installNativeListener = () => {
40949
- if (nativeListenerInstalled) return;
40950
- const plugin = appPlugin();
40951
- if (!plugin?.addListener) return;
40952
- nativeListenerInstalled = true;
40953
- plugin.addListener("notificationAction", (event) => {
40954
- let data = event?.data || {};
40955
- if (typeof data === "string") {
40956
- try {
40957
- data = JSON.parse(data);
40958
- } catch {
40959
- data = {};
40960
- }
40961
- }
40962
- emit2({
40963
- id: event?.id,
40964
- action: event?.action || "open",
40965
- reply: event?.reply || "",
40966
- data,
40967
- platform: "capacitor"
40968
- });
40969
- });
40970
- plugin.consumePendingAction?.().catch?.(() => {
40971
- });
40972
- };
40973
- const permission = async () => {
40974
- const plugin = appPlugin();
40975
- if (plugin?.checkPermissions) return plugin.checkPermissions();
40976
- if (globalThis?.__TAURI_INTERNALS__) {
40977
- try {
40978
- const tauri = await new Function("name", "return import(name)")("@tauri-apps/plugin-notification");
40979
- return { display: await tauri.isPermissionGranted() ? "granted" : "prompt" };
40980
- } catch {
40981
- return { display: "denied" };
40982
- }
40983
- }
40984
- return { display: isBrowser() ? Notification.permission : "denied" };
40985
- };
40986
- const requestPermission = async () => {
40987
- const plugin = appPlugin();
40988
- if (plugin?.requestPermissions) return plugin.requestPermissions();
40989
- if (globalThis?.__TAURI_INTERNALS__) {
40990
- try {
40991
- const tauri = await new Function("name", "return import(name)")("@tauri-apps/plugin-notification");
40992
- return { display: await tauri.requestPermission() };
40993
- } catch {
40994
- return { display: "denied" };
40995
- }
40996
- }
40997
- return { display: isBrowser() ? await Notification.requestPermission() : "denied" };
40998
- };
40999
- const show = async (options = {}) => {
41000
- const id = String(options.id || `notification_${Date.now()}_${Math.random().toString(36).slice(2)}`);
41001
- const request = {
41002
- id,
41003
- title: options.title || "Notification",
41004
- body: options.body || "",
41005
- data: options.data || {},
41006
- actions: options.actions || [],
41007
- silent: Boolean(options.silent),
41008
- channel: options.channel || "general",
41009
- style: options.style || {}
41010
- };
41011
- const plugin = appPlugin();
41012
- if (plugin?.show) {
41013
- installNativeListener();
41014
- await plugin.show(request);
41015
- return { id, platform: "capacitor" };
41016
- }
41017
- if (globalThis?.__TAURI_INTERNALS__) {
41018
- try {
41019
- const tauri = await new Function("name", "return import(name)")("@tauri-apps/plugin-notification");
41020
- const current = await tauri.isPermissionGranted() ? "granted" : await tauri.requestPermission();
41021
- if (current === "granted") {
41022
- tauri.sendNotification({ title: request.title, body: request.body, extra: request.data });
41023
- return { id, platform: "tauri" };
41024
- }
41025
- } catch {
41026
- }
41027
- }
41028
- if (!isBrowser()) throw new Error("Notifications are not supported on this platform.");
41029
- const state = Notification.permission === "default" ? await Notification.requestPermission() : Notification.permission;
41030
- if (state !== "granted") throw new Error("Notification permission was not granted.");
41031
- const notification = new Notification(request.title, { body: request.body, tag: id, data: request.data, silent: request.silent });
41032
- notification.onclick = () => emit2({ id, action: "open", data: request.data, platform: "web" });
41033
- return { id, platform: "web", notification };
41034
- };
41035
- const schedule = async (options = {}) => {
41036
- const at2 = new Date(options.at || Date.now()).getTime();
41037
- const delay = Math.max(0, at2 - Date.now());
41038
- const id = String(options.id || `notification_${at2}_${Math.random().toString(36).slice(2)}`);
41039
- const timeout = setTimeout(() => {
41040
- scheduled.delete(id);
41041
- show({ ...options, id }).catch((error) => emit2({ type: "error", error }));
41042
- }, delay);
41043
- scheduled.set(id, timeout);
41044
- return { id, at: at2 };
41045
- };
41046
- const cancel = async (id) => {
41047
- const timeout = scheduled.get(String(id));
41048
- if (timeout) clearTimeout(timeout);
41049
- scheduled.delete(String(id));
41050
- await appPlugin()?.cancel?.({ id: String(id) });
41051
- };
41052
- const cancelAll = async () => {
41053
- for (const timeout of scheduled.values()) clearTimeout(timeout);
41054
- scheduled.clear();
41055
- await appPlugin()?.cancelAll?.();
41056
- };
41057
- const onAction = (listener) => {
41058
- installNativeListener();
41059
- listeners2.add(listener);
41060
- return () => listeners2.delete(listener);
41061
- };
41062
- return { permission, requestPermission, show, schedule, cancel, cancelAll, onAction };
41063
- }
41064
-
41065
41066
  // src/services/chatNotifications.js
41066
41067
  function createChatNotificationService(client) {
41068
+ const notifications = client.notifications || createNotificationService();
41067
41069
  const listeners2 = /* @__PURE__ */ new Set();
41068
41070
  const emit2 = (event) => listeners2.forEach((listener) => listener(event));
41069
41071
  const showMessage = async ({ sessionId, title = "New chat message", body = "", data = {}, style } = {}) => {
41070
41072
  if (!sessionId) return null;
41071
- return client.notifications.show({
41073
+ return notifications.show({
41072
41074
  id: `chat-message-${sessionId}-${Date.now()}`,
41073
41075
  title,
41074
41076
  body,
@@ -41083,7 +41085,7 @@ function createChatNotificationService(client) {
41083
41085
  };
41084
41086
  const showStatus = async ({ sessionId, title = "Chat update", body = "", data = {}, style } = {}) => {
41085
41087
  if (!sessionId) return null;
41086
- return client.notifications.show({
41088
+ return notifications.show({
41087
41089
  id: `chat-status-${sessionId}-${Date.now()}`,
41088
41090
  title,
41089
41091
  body,
@@ -41097,7 +41099,7 @@ function createChatNotificationService(client) {
41097
41099
  listeners2.add(listener);
41098
41100
  return () => listeners2.delete(listener);
41099
41101
  };
41100
- client.notifications.onAction(({ action, data, reply }) => {
41102
+ notifications.onAction(({ action, data, reply }) => {
41101
41103
  if (data?.sessionId && ["chat_message", "chat_status"].includes(data.kind)) {
41102
41104
  emit2({ type: action === "reply" ? "reply" : action, action, sessionId: data.sessionId, reply: reply || "", data });
41103
41105
  }