@dropout-ai/runtime 0.4.2 → 0.4.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/package.json +1 -1
- package/src/index.js +9 -34
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -69,7 +69,7 @@ class Dropout {
|
|
|
69
69
|
this.apiKey = config.apiKey;
|
|
70
70
|
this.debug = config.debug || false;
|
|
71
71
|
this.privacy = config.privacy || 'full';
|
|
72
|
-
this.captureEndpoint = SUPABASE_FUNCTION_URL;
|
|
72
|
+
this.captureEndpoint = config.captureEndpoint || SUPABASE_FUNCTION_URL;
|
|
73
73
|
this.maxOutputBytes = 32768;
|
|
74
74
|
|
|
75
75
|
// State
|
|
@@ -103,9 +103,6 @@ class Dropout {
|
|
|
103
103
|
// 4. Start Network Interceptor
|
|
104
104
|
this.patchNetwork();
|
|
105
105
|
|
|
106
|
-
// 5. SEND STARTUP PING
|
|
107
|
-
this.sendStartupSignal();
|
|
108
|
-
|
|
109
106
|
// Lock the instance
|
|
110
107
|
Dropout.instance = this;
|
|
111
108
|
|
|
@@ -128,35 +125,6 @@ class Dropout {
|
|
|
128
125
|
}
|
|
129
126
|
}
|
|
130
127
|
|
|
131
|
-
// --- HEARTBEAT ---
|
|
132
|
-
sendStartupSignal() {
|
|
133
|
-
const payload = JSON.stringify({
|
|
134
|
-
project_id: this.projectId,
|
|
135
|
-
session_id: 'system_boot_' + Date.now(),
|
|
136
|
-
turn_role: 'system',
|
|
137
|
-
turn_index: 0,
|
|
138
|
-
content: 'Dropout SDK Initialized',
|
|
139
|
-
metadata_flags: {
|
|
140
|
-
type: 'system_boot',
|
|
141
|
-
environment: process.env.NODE_ENV || 'development',
|
|
142
|
-
runtime: 'node'
|
|
143
|
-
},
|
|
144
|
-
received_at: new Date().toISOString()
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
const req = https.request(this.captureEndpoint, {
|
|
148
|
-
method: 'POST',
|
|
149
|
-
headers: {
|
|
150
|
-
'Content-Type': 'application/json',
|
|
151
|
-
'x-dropout-key': this.apiKey
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
req.on('error', (e) => this.log("❌ Startup Signal Failed", e.message));
|
|
156
|
-
req.write(payload);
|
|
157
|
-
req.end();
|
|
158
|
-
}
|
|
159
|
-
|
|
160
128
|
hash(text) {
|
|
161
129
|
if (!text) return null;
|
|
162
130
|
try {
|
|
@@ -208,6 +176,8 @@ class Dropout {
|
|
|
208
176
|
session_id: payload.session_id,
|
|
209
177
|
turn_index: payload.turn_index,
|
|
210
178
|
turn_role: payload.turn_role,
|
|
179
|
+
// ✅ DIRECTION LOGIC APPLIED HERE
|
|
180
|
+
direction: payload.turn_role === 'user' ? 'user_to_ai' : 'ai_to_user',
|
|
211
181
|
provider: payload.provider,
|
|
212
182
|
model: payload.model,
|
|
213
183
|
latency_ms: payload.latency_ms || null,
|
|
@@ -219,7 +189,10 @@ class Dropout {
|
|
|
219
189
|
|
|
220
190
|
this.log(`🚀 Sending Capture [${payload.turn_role}]`);
|
|
221
191
|
|
|
222
|
-
const
|
|
192
|
+
const isHttp = this.captureEndpoint.startsWith('http:');
|
|
193
|
+
const requestModule = isHttp ? http : https;
|
|
194
|
+
|
|
195
|
+
const req = requestModule.request(this.captureEndpoint, {
|
|
223
196
|
method: 'POST',
|
|
224
197
|
headers: {
|
|
225
198
|
'Content-Type': 'application/json',
|
|
@@ -444,4 +417,6 @@ if (typeof process !== 'undefined' && process.env.DROPOUT_PROJECT_ID && process.
|
|
|
444
417
|
});
|
|
445
418
|
}
|
|
446
419
|
|
|
420
|
+
// 🛡️ DUAL EXPORT FIX (Crucial for TypeScript + Require compatibility)
|
|
421
|
+
Dropout.default = Dropout;
|
|
447
422
|
module.exports = Dropout;
|