@urun-sh/openai 0.6.46 → 0.6.47

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.
@@ -300,6 +300,8 @@ declare class OpenAIRealtimeConnection<S = unknown> {
300
300
  private readonly operatorLog;
301
301
  /** The turn-stall bound in ms (see {@link REALTIME_TURN_STALL_MS}). */
302
302
  private readonly turnStallMs;
303
+ /** The whole-response lifetime bound in ms (see {@link REALTIME_RESPONSE_DEADLINE_MS}). */
304
+ private readonly responseDeadlineMs;
303
305
  private config;
304
306
  private readonly sessionId;
305
307
  private readonly conversationId;
@@ -332,6 +334,17 @@ declare class OpenAIRealtimeConnection<S = unknown> {
332
334
  */
333
335
  private turnCancelled;
334
336
  private wakeTurnCancelled;
337
+ /**
338
+ * The DIAL gate: cuts a pending upstream dial — but ONLY for the lifetime
339
+ * deadline and socket teardown. `response.cancel` deliberately does NOT
340
+ * abort a pending dial (the ENG-446 ruling: the dial's own settlement
341
+ * speaks, `response.cancelled` rides its `inFlight.finally`) — only the
342
+ * two no-requester-left cases cut it.
343
+ */
344
+ private turnDialGate;
345
+ private wakeTurnDialGate;
346
+ /** Set when the response's LIFETIME deadline fired (vs a client `response.cancel`) — the body's cut-through exit ends the turn `incomplete` instead of `cancelled`. */
347
+ private deadlineFired;
335
348
  /** Output events already flowed for the active response (post-flush faults → error event, pre-flush → response.failed). */
336
349
  private responseFlushed;
337
350
  private cancelled;
@@ -409,6 +422,14 @@ declare class OpenAIRealtimeConnection<S = unknown> {
409
422
  * default.
410
423
  */
411
424
  turnStallMs?: number;
425
+ /**
426
+ * The whole-response lifetime bound in ms (see
427
+ * {@link REALTIME_RESPONSE_DEADLINE_MS}): a turn whose source never
428
+ * yields AND never ends is cut through at the deadline and ends
429
+ * VISIBLY (`response.done` status `incomplete`). `0` disables. Tests
430
+ * shrink it; prod rides the default.
431
+ */
432
+ responseDeadlineMs?: number;
412
433
  });
413
434
  /**
414
435
  * Consume the backend's OWN turn/transcript lane (§5 stt stream): the
@@ -645,11 +666,21 @@ declare class OpenAIRealtimeConnection<S = unknown> {
645
666
  private upstreamTurnFault;
646
667
  private emitUpstreamFault;
647
668
  /**
648
- * Cancel the in-flight response. The upstream iterator is stopped through
649
- * the for-await `break` protocol (its `return()` runs — no bespoke cancel
650
- * machinery); the turn stops at the NEXT upstream event and the partial
651
- * output is NEVER adopted into the transcript (see closeOpenItems being
652
- * skipped on the cancelled path).
669
+ * Cut the in-flight turn through the waits `response.cancel` cuts — the
670
+ * stream waits racing the cancel gate, the composite tts leg, the
671
+ * transcript park. `cutDial` extends the cut to a PENDING upstream dial:
672
+ * only the lifetime deadline and socket teardown do that (an orphaned
673
+ * response must not outlive its requester); a client `response.cancel`
674
+ * deliberately leaves the dial to settle on its own (the ENG-446 ruling —
675
+ * its own settlement speaks, `response.cancelled` rides its
676
+ * `inFlight.finally`).
677
+ */
678
+ private cutThroughTurnWaits;
679
+ /**
680
+ * Cancel the in-flight response. The turn is cut through the cancel gate
681
+ * (above); the turn body's catch takes the cancelled exit — the partial
682
+ * output is NEVER adopted into the transcript — and this method's
683
+ * `inFlight.finally` below emits `response.cancelled`.
653
684
  */
654
685
  private cancelResponse;
655
686
  private pushItem;
@@ -65,6 +65,8 @@ declare class OpenAIRealtimeConnection<S = unknown> {
65
65
  private readonly operatorLog;
66
66
 
67
67
  private readonly turnStallMs;
68
+
69
+ private readonly responseDeadlineMs;
68
70
  private config;
69
71
  private readonly sessionId;
70
72
  private readonly conversationId;
@@ -84,6 +86,11 @@ declare class OpenAIRealtimeConnection<S = unknown> {
84
86
  private turnCancelled;
85
87
  private wakeTurnCancelled;
86
88
 
89
+ private turnDialGate;
90
+ private wakeTurnDialGate;
91
+
92
+ private deadlineFired;
93
+
87
94
  private responseFlushed;
88
95
  private cancelled;
89
96
 
@@ -119,6 +126,8 @@ declare class OpenAIRealtimeConnection<S = unknown> {
119
126
  operatorLog?: (line: string) => void;
120
127
 
121
128
  turnStallMs?: number;
129
+
130
+ responseDeadlineMs?: number;
122
131
  });
123
132
 
124
133
  private startTurnLane;
@@ -184,6 +193,8 @@ declare class OpenAIRealtimeConnection<S = unknown> {
184
193
  private upstreamTurnFault;
185
194
  private emitUpstreamFault;
186
195
 
196
+ private cutThroughTurnWaits;
197
+
187
198
  private cancelResponse;
188
199
  private pushItem;
189
200
 
@@ -1 +1 @@
1
- import{F as I,a as n,b as p,c as m,k as l,l as a,m as x,o as s,r as O,s as f}from"../chunk-U6TUJPC3.js";import{a as o,h as t}from"../chunk-X5BLQXHK.js";import"../chunk-64VO62LW.js";import"../chunk-2AFSBZLN.js";import{i as r,j as i}from"../chunk-CUO2JOW4.js";import{c as e}from"../chunk-YSFSRI3D.js";e();export{o as GEMINI_LIVE_PATH,a as OPENAI_REALTIME_PATH,l as OpenAIRealtimeConnection,n as ResumptionRegistry,i as SessionGoneError,r as UnknownModelError,t as VIDEO_OUT_SETUP_KEY,p as attachGeminiLive,x as attachOpenAIRealtime,I as createOpenAIProxy,f as fixedClientsResolver,O as realtimeBindingFor,s as realtimeModelOf,m as serveGeminiLiveSocket};
1
+ import{F as I,a as n,b as p,c as m,k as l,l as a,m as x,o as s,r as O,s as f}from"../chunk-P2YVKUSQ.js";import{a as o,h as t}from"../chunk-X5BLQXHK.js";import"../chunk-64VO62LW.js";import"../chunk-5D7TVOAX.js";import{i as r,j as i}from"../chunk-C452ZIU5.js";import{c as e}from"../chunk-YSFSRI3D.js";e();export{o as GEMINI_LIVE_PATH,a as OPENAI_REALTIME_PATH,l as OpenAIRealtimeConnection,n as ResumptionRegistry,i as SessionGoneError,r as UnknownModelError,t as VIDEO_OUT_SETUP_KEY,p as attachGeminiLive,x as attachOpenAIRealtime,I as createOpenAIProxy,f as fixedClientsResolver,O as realtimeBindingFor,s as realtimeModelOf,m as serveGeminiLiveSocket};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@urun-sh/openai",
3
- "version": "0.6.46",
3
+ "version": "0.6.47",
4
4
  "description": "OpenAI-compatible Realtime + Responses SDK over uRun session primitives (not websockets).",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -70,7 +70,7 @@
70
70
  "build:bin": "bun build --compile --external @roamhq/wrtc src/proxy/bin.ts --outfile dist/bin/urun-openai && node scripts/assert-bin-transport.mjs"
71
71
  },
72
72
  "peerDependencies": {
73
- "@urun-sh/core": "^0.6.46"
73
+ "@urun-sh/core": "^0.6.47"
74
74
  },
75
75
  "dependencies": {
76
76
  "@prometheus-io/client": "^0.16.1",