@enhearten/knowledge-base-module 1.0.3 → 1.0.4

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/backend/.env CHANGED
@@ -1,3 +1,3 @@
1
1
  COMPOSIO_API_KEY=ak_98QH038j63Jg1gVRIK_5
2
- GOOGLE_API_KEY=AIzaSyDkELFOfve9WPbT7wDiOqwULHmrMdbS1zw
2
+ GOOGLE_API_KEY=AIzaSyBQVW8kgEo8E5JLD9qCgh0JNbzela20Keo
3
3
  PORT=3000
@@ -1 +1 @@
1
- {"version":3,"file":"useServiceConnection.d.ts","sourceRoot":"","sources":["../../src/hooks/useServiceConnection.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,oBAAoB,GAAI,SAAS,MAAM,EAAE,UAAU,MAAM,EAAE,cAAa,MAAM,EAAc;;;;;;;;CA4FxG,CAAC"}
1
+ {"version":3,"file":"useServiceConnection.d.ts","sourceRoot":"","sources":["../../src/hooks/useServiceConnection.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,oBAAoB,GAAI,SAAS,MAAM,EAAE,UAAU,MAAM,EAAE,cAAa,MAAM,EAAc;;;;;;;;CAgHxG,CAAC"}
@@ -36,12 +36,29 @@ export const useServiceConnection = (appName, entityId, searchTerms = [appName])
36
36
  Alert.alert('Configuration Missing', 'Please configure the backend URL and API keys in settings.');
37
37
  return;
38
38
  }
39
+ // SAFARI FIX: Open window immediately while still in user gesture context
40
+ // This must happen BEFORE any async operations to avoid popup blocker
41
+ let popup = null;
42
+ if (typeof window !== 'undefined') {
43
+ popup = window.open('about:blank', '_blank');
44
+ }
39
45
  try {
40
46
  setLoading(true);
41
47
  setError(null);
42
48
  const data = await startConnection(appName, entityId);
43
- if (data.url)
44
- await Linking.openURL(data.url);
49
+ if (data.url) {
50
+ // Redirect the pre-opened popup, or fallback to Linking
51
+ if (popup) {
52
+ popup.location.href = data.url;
53
+ }
54
+ else {
55
+ await Linking.openURL(data.url);
56
+ }
57
+ }
58
+ else if (popup) {
59
+ // Close popup if no URL was returned
60
+ popup.close();
61
+ }
45
62
  // Start polling for connection status
46
63
  let attempts = 0;
47
64
  const maxAttempts = 60; // 2 minutes approx (2s interval)
@@ -61,6 +78,9 @@ export const useServiceConnection = (appName, entityId, searchTerms = [appName])
61
78
  }, 2000);
62
79
  }
63
80
  catch (error) {
81
+ // Close the pre-opened popup on error
82
+ if (popup)
83
+ popup.close();
64
84
  console.error(error);
65
85
  console.error(`Failed to connect ${appName}`);
66
86
  setError(`Failed to connect ${appName}`);
@@ -176,7 +176,7 @@ export const getGiftIdeas = async (options) => {
176
176
  prompt += ` The occasion is: ${occasion}.`;
177
177
  if (budget)
178
178
  prompt += ` Budget: ${budget}.`;
179
- prompt += ` Look for their interests, hobbies, recent conversations, and anything that might hint at what they would appreciate.`;
179
+ prompt += `.`;
180
180
  return executeAction(prompt, entityId);
181
181
  };
182
182
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enhearten/knowledge-base-module",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "Connect accounts (Gmail, GitHub, Discord, etc.) and search across them with AI to execute actions",
5
5
  "main": "index.ts",
6
6
  "module": "dist/index.mjs",
@@ -40,11 +40,29 @@ export const useServiceConnection = (appName: string, entityId: string, searchTe
40
40
  return;
41
41
  }
42
42
 
43
+ // SAFARI FIX: Open window immediately while still in user gesture context
44
+ // This must happen BEFORE any async operations to avoid popup blocker
45
+ let popup: Window | null = null;
46
+ if (typeof window !== 'undefined') {
47
+ popup = window.open('about:blank', '_blank');
48
+ }
49
+
43
50
  try {
44
51
  setLoading(true);
45
52
  setError(null);
46
53
  const data = await startConnection(appName, entityId);
47
- if (data.url) await Linking.openURL(data.url);
54
+
55
+ if (data.url) {
56
+ // Redirect the pre-opened popup, or fallback to Linking
57
+ if (popup) {
58
+ popup.location.href = data.url;
59
+ } else {
60
+ await Linking.openURL(data.url);
61
+ }
62
+ } else if (popup) {
63
+ // Close popup if no URL was returned
64
+ popup.close();
65
+ }
48
66
 
49
67
  // Start polling for connection status
50
68
  let attempts = 0;
@@ -64,6 +82,8 @@ export const useServiceConnection = (appName: string, entityId: string, searchTe
64
82
  }, 2000);
65
83
 
66
84
  } catch (error) {
85
+ // Close the pre-opened popup on error
86
+ if (popup) popup.close();
67
87
  console.error(error);
68
88
  console.error(`Failed to connect ${appName}`);
69
89
  setError(`Failed to connect ${appName}`);
@@ -212,7 +212,7 @@ export const getGiftIdeas = async (options: GiftIdeasOptions) => {
212
212
  let prompt = `Based on my connected accounts, suggest gift ideas for ${personName}.`;
213
213
  if (occasion) prompt += ` The occasion is: ${occasion}.`;
214
214
  if (budget) prompt += ` Budget: ${budget}.`;
215
- prompt += ` Look for their interests, hobbies, recent conversations, and anything that might hint at what they would appreciate.`;
215
+ prompt += `.`;
216
216
  return executeAction(prompt, entityId);
217
217
  };
218
218