@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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +44 -51
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dropout-ai/runtime",
3
- "version": "0.2.07",
3
+ "version": "0.2.09",
4
4
  "description": "Invisible Node.js runtime for capturing AI interactions.",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
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
- identity: {
77
- session_id: GLOBAL_OBJ.__dropout_session_id__,
78
- turn_index: turnIndex,
79
- direction: 'meta',
80
- turn_role: 'system'
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
- identity: {
181
- session_id: GLOBAL_OBJ.__dropout_session_id__,
182
- turn_index: activeTurn,
183
- direction: 'request',
184
- turn_role: 'user'
185
- },
186
- timing: {
187
- created_at: Date.now()
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
- identity: {
230
- session_id: GLOBAL_OBJ.__dropout_session_id__,
231
- turn_index: activeTurn,
232
- direction: 'response',
233
- turn_role: 'assistant'
234
- },
235
- timing: {
236
- created_at: Date.now(),
237
- latency_ms: latency
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; // Confirmation Rule locked
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
- identity: { session_id: GLOBAL_OBJ.__dropout_session_id__, turn_index: activeTurn, direction: 'request', turn_role: 'user' },
297
- timing: { created_at: Date.now() },
298
- provider_context: { provider: options.provider || 'manual', model: options.model || 'unknown' },
299
- content: { content_raw: mode === 'full' ? prompt : null, content_hash: pHash },
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
- identity: { session_id: GLOBAL_OBJ.__dropout_session_id__, turn_index: activeTurn, direction: 'response', turn_role: 'assistant' },
306
- timing: { created_at: Date.now(), latency_ms },
307
- provider_context: { provider: options.provider || 'manual', model: options.model || 'unknown' },
308
- content: { content_raw: mode === 'full' ? output : null, content_hash: oHash },
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