@dropout-ai/runtime 0.2.10 → 0.2.12
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 +23 -24
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,27 +31,12 @@ let lastTurnConfirmed = true;
|
|
|
28
31
|
let lastPromptHash = null;
|
|
29
32
|
let lastResponseHash = null;
|
|
30
33
|
|
|
31
|
-
// --- Runtime Guarantees ---
|
|
32
34
|
let config = {
|
|
33
35
|
maxOutputBytes: 32768,
|
|
34
|
-
captureEndpoint:
|
|
35
|
-
|
|
36
|
-
privacyMode: (typeof process !== 'undefined' && process.env.DROPOUT_PRIVACY_MODE) || 'safe'
|
|
36
|
+
captureEndpoint: SUPABASE_FUNCTION_URL,
|
|
37
|
+
privacyMode: (typeof process !== 'undefined' && process.env.DROPOUT_PRIVACY_MODE) || 'full'
|
|
37
38
|
};
|
|
38
39
|
|
|
39
|
-
// Remote config fetch (Non-blocking)
|
|
40
|
-
setTimeout(async () => {
|
|
41
|
-
const fetchFn = GLOBAL_OBJ.__dropout_original_fetch__ || GLOBAL_OBJ.fetch;
|
|
42
|
-
if (typeof fetchFn !== 'function') return;
|
|
43
|
-
try {
|
|
44
|
-
const resp = await fetchFn(config.configEndpoint);
|
|
45
|
-
const remote = await resp.json();
|
|
46
|
-
if (remote && typeof remote === 'object') {
|
|
47
|
-
config = Object.assign(config, remote);
|
|
48
|
-
}
|
|
49
|
-
} catch (e) { }
|
|
50
|
-
}, 0);
|
|
51
|
-
|
|
52
40
|
/**
|
|
53
41
|
* Telemetry Emitter (Non-blocking, Fire-and-forget)
|
|
54
42
|
*/
|
|
@@ -59,10 +47,15 @@ function emit(payload) {
|
|
|
59
47
|
setTimeout(() => {
|
|
60
48
|
fetchFn(config.captureEndpoint, {
|
|
61
49
|
method: 'POST',
|
|
62
|
-
headers: {
|
|
50
|
+
headers: {
|
|
51
|
+
'Content-Type': 'application/json'
|
|
52
|
+
// No Authorization header needed since Enforce JWT is OFF
|
|
53
|
+
},
|
|
63
54
|
body: JSON.stringify(payload),
|
|
64
55
|
keepalive: true
|
|
65
|
-
}).catch(() => {
|
|
56
|
+
}).catch(() => {
|
|
57
|
+
// Silent fail (Fire & Forget) to ensure no impact on host app
|
|
58
|
+
});
|
|
66
59
|
}, 0);
|
|
67
60
|
}
|
|
68
61
|
|
|
@@ -142,6 +135,12 @@ if (typeof GLOBAL_OBJ.fetch === 'function' && !GLOBAL_OBJ.fetch.__dropout_patche
|
|
|
142
135
|
|
|
143
136
|
GLOBAL_OBJ.fetch = async function (input, init) {
|
|
144
137
|
const url = typeof input === 'string' ? input : (input && input.url);
|
|
138
|
+
|
|
139
|
+
// GUARD: Avoid infinite loops
|
|
140
|
+
if (url && url.includes(config.captureEndpoint)) {
|
|
141
|
+
return GLOBAL_OBJ.__dropout_original_fetch__(input, init);
|
|
142
|
+
}
|
|
143
|
+
|
|
145
144
|
const isAI = url && (
|
|
146
145
|
url.includes('openai.com') ||
|
|
147
146
|
url.includes('anthropic.com') ||
|
|
@@ -315,4 +314,4 @@ module.exports = {
|
|
|
315
314
|
lastPromptHash = null;
|
|
316
315
|
lastResponseHash = null;
|
|
317
316
|
}
|
|
318
|
-
};
|
|
317
|
+
};
|