@dropout-ai/runtime 0.2.11 → 0.2.13
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/package.json +1 -1
- package/src/index.js +31 -25
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @dropout-ai/runtime
|
|
3
|
-
* Role: Passive observer
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* it only: Observes, Normalizes, Emits signals.
|
|
3
|
+
* Role: Passive observer.
|
|
4
|
+
* Behavior: Fire-and-forget raw JSON to Supabase.
|
|
5
|
+
* Authentication: None (Public Endpoint).
|
|
7
6
|
*/
|
|
8
7
|
|
|
9
8
|
const crypto = require('crypto');
|
|
10
9
|
|
|
10
|
+
// --- CONFIGURATION ---
|
|
11
|
+
// Public ingestion endpoint (No keys required)
|
|
12
|
+
const SUPABASE_FUNCTION_URL = "https://hipughmjlwmwjxzyxfzs.supabase.co/functions/v1/capture-sealed";
|
|
13
|
+
|
|
11
14
|
// --- Identity & State ---
|
|
12
15
|
const GLOBAL_OBJ = typeof window !== 'undefined' ? window : global;
|
|
13
16
|
|
|
@@ -28,43 +31,40 @@ let lastTurnConfirmed = true;
|
|
|
28
31
|
let lastPromptHash = null;
|
|
29
32
|
let lastResponseHash = null;
|
|
30
33
|
|
|
31
|
-
const SUPABASE_FUNCTION_URL = "https://hipughmjlwmwjxzyxfzs.supabase.co/functions/v1/capture-sealed";
|
|
32
|
-
|
|
33
|
-
// --- Runtime Guarantees ---
|
|
34
34
|
let config = {
|
|
35
35
|
maxOutputBytes: 32768,
|
|
36
36
|
captureEndpoint: SUPABASE_FUNCTION_URL,
|
|
37
|
-
|
|
38
|
-
privacyMode: (typeof process !== 'undefined' && process.env.DROPOUT_PRIVACY_MODE) || 'safe'
|
|
37
|
+
privacyMode: (typeof process !== 'undefined' && process.env.DROPOUT_PRIVACY_MODE) || 'full'
|
|
39
38
|
};
|
|
40
39
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const fetchFn = GLOBAL_OBJ.__dropout_original_fetch__ || GLOBAL_OBJ.fetch;
|
|
44
|
-
if (typeof fetchFn !== 'function') return;
|
|
45
|
-
try {
|
|
46
|
-
const resp = await fetchFn(config.configEndpoint);
|
|
47
|
-
const remote = await resp.json();
|
|
48
|
-
if (remote && typeof remote === 'object') {
|
|
49
|
-
config = Object.assign(config, remote);
|
|
50
|
-
}
|
|
51
|
-
} catch (e) { }
|
|
52
|
-
}, 0);
|
|
53
|
-
|
|
40
|
+
console.log("[Dropout Debug] Runtime Initializing...");
|
|
41
|
+
console.log("[Dropout Debug] Session ID:", GLOBAL_OBJ.__dropout_session_id__ || "Not set");
|
|
54
42
|
/**
|
|
55
43
|
* Telemetry Emitter (Non-blocking, Fire-and-forget)
|
|
56
44
|
*/
|
|
57
45
|
function emit(payload) {
|
|
46
|
+
console.log("[Dropout Debug] emit() called with payload:", JSON.stringify(payload).slice(0, 100) + "...");
|
|
58
47
|
const fetchFn = GLOBAL_OBJ.__dropout_original_fetch__ || GLOBAL_OBJ.fetch;
|
|
59
48
|
if (typeof fetchFn !== 'function') return;
|
|
60
49
|
|
|
61
50
|
setTimeout(() => {
|
|
62
51
|
fetchFn(config.captureEndpoint, {
|
|
63
52
|
method: 'POST',
|
|
64
|
-
headers: {
|
|
53
|
+
headers: {
|
|
54
|
+
'Content-Type': 'application/json'
|
|
55
|
+
// No Authorization header needed since Enforce JWT is OFF
|
|
56
|
+
},
|
|
65
57
|
body: JSON.stringify(payload),
|
|
66
58
|
keepalive: true
|
|
67
|
-
}).
|
|
59
|
+
}).then(res => {
|
|
60
|
+
console.log(`[Dropout Debug] Supabase Response: ${res.status} ${res.statusText}`);
|
|
61
|
+
if (!res.ok) {
|
|
62
|
+
res.text().then(t => console.error("[Dropout Debug] Error Body:", t));
|
|
63
|
+
}
|
|
64
|
+
}).catch(() => {
|
|
65
|
+
// Silent fail (Fire & Forget) to ensure no impact on host app
|
|
66
|
+
console.error("[Dropout Debug] NETWORK ERROR:", err);
|
|
67
|
+
});
|
|
68
68
|
}, 0);
|
|
69
69
|
}
|
|
70
70
|
|
|
@@ -144,6 +144,12 @@ if (typeof GLOBAL_OBJ.fetch === 'function' && !GLOBAL_OBJ.fetch.__dropout_patche
|
|
|
144
144
|
|
|
145
145
|
GLOBAL_OBJ.fetch = async function (input, init) {
|
|
146
146
|
const url = typeof input === 'string' ? input : (input && input.url);
|
|
147
|
+
|
|
148
|
+
// GUARD: Avoid infinite loops
|
|
149
|
+
if (url && url.includes(config.captureEndpoint)) {
|
|
150
|
+
return GLOBAL_OBJ.__dropout_original_fetch__(input, init);
|
|
151
|
+
}
|
|
152
|
+
|
|
147
153
|
const isAI = url && (
|
|
148
154
|
url.includes('openai.com') ||
|
|
149
155
|
url.includes('anthropic.com') ||
|
|
@@ -317,4 +323,4 @@ module.exports = {
|
|
|
317
323
|
lastPromptHash = null;
|
|
318
324
|
lastResponseHash = null;
|
|
319
325
|
}
|
|
320
|
-
};
|
|
326
|
+
};
|