@dropout-ai/runtime 0.2.7 → 0.2.9
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 +44 -51
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -73,13 +73,11 @@ function emitSessionEnd(reason) {
|
|
|
73
73
|
GLOBAL_OBJ.__dropout_session_ended__ = true;
|
|
74
74
|
|
|
75
75
|
emit({
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
},
|
|
82
|
-
timing: { created_at: Date.now() },
|
|
76
|
+
session_id: GLOBAL_OBJ.__dropout_session_id__,
|
|
77
|
+
turn_index: turnIndex,
|
|
78
|
+
direction: 'meta',
|
|
79
|
+
turn_role: 'system',
|
|
80
|
+
created_at: Date.now(),
|
|
83
81
|
metadata_flags: {
|
|
84
82
|
session_end: true,
|
|
85
83
|
end_reason: reason
|
|
@@ -177,23 +175,15 @@ if (typeof GLOBAL_OBJ.fetch === 'function' && !GLOBAL_OBJ.fetch.__dropout_patche
|
|
|
177
175
|
const isRetry = pHash && pHash === lastPromptHash;
|
|
178
176
|
|
|
179
177
|
const requestEvent = {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
provider_context: {
|
|
190
|
-
provider,
|
|
191
|
-
model
|
|
192
|
-
},
|
|
193
|
-
content: {
|
|
194
|
-
content_raw: config.privacyMode === 'full' ? pText : null,
|
|
195
|
-
content_hash: pHash
|
|
196
|
-
},
|
|
178
|
+
session_id: GLOBAL_OBJ.__dropout_session_id__,
|
|
179
|
+
turn_index: activeTurn,
|
|
180
|
+
direction: 'user_to_ai',
|
|
181
|
+
turn_role: 'user',
|
|
182
|
+
created_at: Date.now(),
|
|
183
|
+
provider,
|
|
184
|
+
model,
|
|
185
|
+
content_raw: config.privacyMode === 'full' ? pText : null,
|
|
186
|
+
content_hash: pHash,
|
|
197
187
|
metadata_flags: {
|
|
198
188
|
retry_like: isRetry ? 1 : 0
|
|
199
189
|
}
|
|
@@ -226,24 +216,16 @@ if (typeof GLOBAL_OBJ.fetch === 'function' && !GLOBAL_OBJ.fetch.__dropout_patche
|
|
|
226
216
|
const isNonAdaptive = oHash && oHash === lastResponseHash;
|
|
227
217
|
|
|
228
218
|
const responseEvent = {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
provider_context: {
|
|
240
|
-
provider,
|
|
241
|
-
model
|
|
242
|
-
},
|
|
243
|
-
content: {
|
|
244
|
-
content_raw: config.privacyMode === 'full' ? oText : null,
|
|
245
|
-
content_hash: oHash
|
|
246
|
-
},
|
|
219
|
+
session_id: GLOBAL_OBJ.__dropout_session_id__,
|
|
220
|
+
turn_index: activeTurn,
|
|
221
|
+
direction: 'ai_to_user',
|
|
222
|
+
turn_role: 'assistant',
|
|
223
|
+
created_at: Date.now(),
|
|
224
|
+
latency_ms: latency,
|
|
225
|
+
provider,
|
|
226
|
+
model,
|
|
227
|
+
content_raw: config.privacyMode === 'full' ? oText : null,
|
|
228
|
+
content_hash: oHash,
|
|
247
229
|
metadata_flags: {
|
|
248
230
|
non_adaptive_response: isNonAdaptive ? 1 : 0,
|
|
249
231
|
turn_boundary_confirmed: 1
|
|
@@ -252,7 +234,7 @@ if (typeof GLOBAL_OBJ.fetch === 'function' && !GLOBAL_OBJ.fetch.__dropout_patche
|
|
|
252
234
|
|
|
253
235
|
emit(responseEvent);
|
|
254
236
|
lastResponseHash = oHash;
|
|
255
|
-
lastTurnConfirmed = true;
|
|
237
|
+
lastTurnConfirmed = true;
|
|
256
238
|
|
|
257
239
|
return response;
|
|
258
240
|
};
|
|
@@ -293,19 +275,30 @@ async function capture(target, options = {}) {
|
|
|
293
275
|
|
|
294
276
|
// Emit Request
|
|
295
277
|
emit({
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
278
|
+
session_id: GLOBAL_OBJ.__dropout_session_id__,
|
|
279
|
+
turn_index: activeTurn,
|
|
280
|
+
direction: 'user_to_ai',
|
|
281
|
+
turn_role: 'user',
|
|
282
|
+
created_at: Date.now(),
|
|
283
|
+
provider: options.provider || 'manual',
|
|
284
|
+
model: options.model || 'unknown',
|
|
285
|
+
content_raw: mode === 'full' ? prompt : null,
|
|
286
|
+
content_hash: pHash,
|
|
300
287
|
metadata_flags: { retry_like: pHash === lastPromptHash ? 1 : 0 }
|
|
301
288
|
});
|
|
302
289
|
|
|
303
290
|
// Emit Response
|
|
304
291
|
emit({
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
292
|
+
session_id: GLOBAL_OBJ.__dropout_session_id__,
|
|
293
|
+
turn_index: activeTurn,
|
|
294
|
+
direction: 'ai_to_user',
|
|
295
|
+
turn_role: 'assistant',
|
|
296
|
+
created_at: Date.now(),
|
|
297
|
+
latency_ms,
|
|
298
|
+
provider: options.provider || 'manual',
|
|
299
|
+
model: options.model || 'unknown',
|
|
300
|
+
content_raw: mode === 'full' ? output : null,
|
|
301
|
+
content_hash: oHash,
|
|
309
302
|
metadata_flags: { non_adaptive_response: oHash === lastResponseHash ? 1 : 0, turn_boundary_confirmed: 1 }
|
|
310
303
|
});
|
|
311
304
|
|