@urun-sh/openai 0.6.42 → 0.6.43
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/dist/{ResponsesClient-gfg7qUoE.d.ts → ResponsesClient-2EsjJUz1.d.ts} +1 -1
- package/dist/{ResponsesClient-6QsC7NPJ.d.cts → ResponsesClient-BIcQ6p6Z.d.cts} +1 -1
- package/dist/{chunk-XKCWX72M.js → chunk-27HP3RMZ.js} +1 -1
- package/dist/chunk-2NKCALKY.js +22 -0
- package/dist/chunk-2RO722HS.js +2 -0
- package/dist/chunk-7DUSLXPG.js +1 -0
- package/dist/chunk-BFIKVTQB.js +1 -0
- package/dist/{chunk-4NMMWAKD.js → chunk-FF3RWDFM.js} +1 -1
- package/dist/chunk-GDH2D3S6.js +1 -0
- package/dist/chunk-J3KCHTSA.js +6 -0
- package/dist/{chunk-QTHFMDZY.js → chunk-JMSVHETI.js} +1 -1
- package/dist/{chunk-L4QBHSVY.js → chunk-MJSK6W3W.js} +1 -1
- package/dist/chunk-MOX5FG2R.js +1 -0
- package/dist/chunk-YRBUHHI3.js +2 -0
- package/dist/chunk-ZCF6EV4Y.js +65 -0
- package/dist/{composite-B-F2J0NK.d.cts → composite-BoS9-74g.d.cts} +320 -4
- package/dist/{composite-B--rGI5m.d.ts → composite-D4_XPSas.d.ts} +91 -4
- package/dist/gemini-live.cjs +2 -2
- package/dist/gemini-live.d.cts +4 -4
- package/dist/gemini-live.d.ts +4 -4
- package/dist/gemini-live.js +1 -1
- package/dist/hosted/bin.cjs +44 -43
- package/dist/hosted/bin.js +1 -1
- package/dist/hosted/index.cjs +43 -42
- package/dist/hosted/index.d.cts +54 -10
- package/dist/hosted/index.d.ts +11 -5
- package/dist/hosted/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1 -1
- package/dist/pi-extension/index.cjs +7 -7
- package/dist/pi-extension/index.d.cts +2 -2
- package/dist/pi-extension/index.d.ts +2 -2
- package/dist/pi-extension/index.js +1 -1
- package/dist/pi-extension/standalone.cjs +55 -55
- package/dist/pooler/bin.cjs +40 -41
- package/dist/pooler/bin.js +39 -40
- package/dist/proxy/cli.cjs +54 -53
- package/dist/proxy/cli.js +1 -1
- package/dist/proxy/conformance-probe.cjs +1 -1
- package/dist/proxy/conformance-probe.js +1 -1
- package/dist/proxy/index.cjs +33 -32
- package/dist/proxy/index.d.cts +37 -214
- package/dist/proxy/index.d.ts +17 -65
- package/dist/proxy/index.js +1 -1
- package/dist/{translator-BqpmZ-vh.d.ts → translator-BemK1Of5.d.ts} +1 -1
- package/dist/{translator-Dox25ky9.d.cts → translator-PsmsZT62.d.cts} +1 -1
- package/dist/{types-CHPtJx6d.d.cts → types-CxWQ84Ew.d.cts} +5 -0
- package/dist/{types-CHPtJx6d.d.ts → types-CxWQ84Ew.d.ts} +2 -0
- package/dist/{video-out-DnCKUUO2.d.cts → video-out-DPLqpGbQ.d.cts} +17 -3
- package/dist/{video-out-REmiQMBJ.d.ts → video-out-DkMqKSOi.d.ts} +6 -2
- package/package.json +2 -2
- package/dist/chunk-7KRHHEKZ.js +0 -1
- package/dist/chunk-G7CSAISC.js +0 -1
- package/dist/chunk-GX243AIV.js +0 -1
- package/dist/chunk-HPUX2H65.js +0 -6
- package/dist/chunk-IFYB6QUQ.js +0 -64
- package/dist/chunk-KKCUIOL4.js +0 -1
- package/dist/chunk-OZ7HE3VG.js +0 -23
- package/dist/chunk-QNJKRB7Q.js +0 -2
- package/dist/chunk-Z3QCHKJB.js +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { C as CatalogRow } from './models-D7F0bLJ3.cjs';
|
|
2
|
-
import { IncomingMessage } from 'node:http';
|
|
3
|
-
import { a as AudioBridge, h as VideoFrameLane, j as VideoOutLane } from './video-out-
|
|
2
|
+
import { IncomingMessage, Server } from 'node:http';
|
|
3
|
+
import { a as AudioBridge, h as VideoFrameLane, j as VideoOutLane } from './video-out-DPLqpGbQ.cjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* THE BILLING CORRELATION SEAM — one uuid per `/v1` request, returned as the
|
|
@@ -133,6 +133,15 @@ interface InferenceRecord {
|
|
|
133
133
|
readonly output_minutes: number | null;
|
|
134
134
|
/** THE OUTPUT-SECONDS METER — see {@link InferenceTurn.outputSeconds}. */
|
|
135
135
|
readonly output_seconds: number | null;
|
|
136
|
+
/**
|
|
137
|
+
* THE LIVE SESSION-TIME METER (DDR addendum) — the CONNECTED SESSION
|
|
138
|
+
* SECONDS a realtime (`/v1/realtime`, Gemini Live) stream was up, measured
|
|
139
|
+
* by the realtime lane at teardown. NULL for every HTTP lane (the quantity
|
|
140
|
+
* does not exist there) and for a realtime dial that never connected —
|
|
141
|
+
* never zero of it. On the record rather than read separately by the ledger
|
|
142
|
+
* writer for the reason the record exists at all: one object, every sink.
|
|
143
|
+
*/
|
|
144
|
+
readonly session_seconds: number | null;
|
|
136
145
|
/**
|
|
137
146
|
* THE INSTANCE that served this request — see
|
|
138
147
|
* {@link InferenceTurn.sessionId}. On the log line as well as the ledger,
|
|
@@ -209,6 +218,267 @@ interface SessionTurnLaneEvent {
|
|
|
209
218
|
startMs?: number;
|
|
210
219
|
}
|
|
211
220
|
|
|
221
|
+
/**
|
|
222
|
+
* `attachOpenAIRealtime(server, options)` — the WS upgrade hook for the OpenAI
|
|
223
|
+
* Realtime surface (GA protocol subset; see protocol.ts for the event subset).
|
|
224
|
+
*
|
|
225
|
+
* Contract (Main-owned composition; this lane claims ONLY `/v1/realtime`):
|
|
226
|
+
* - Upgrades on any other path are passed through UNTOUCHED — a plain
|
|
227
|
+
* `next()` listener, so sibling lanes (Gemini Live, Responses WS) and the
|
|
228
|
+
* hosted composition keep their own upgrade hooks.
|
|
229
|
+
* - Clients are resolved/authenticated ASYNCHRONOUSLY BEFORE the upgrade is
|
|
230
|
+
* accepted: no 101 is written until `resolver.resolve(req, signal)`
|
|
231
|
+
* settles. A thrown error maps `err.status` (default 502) to the HTTP
|
|
232
|
+
* reject; 401/403 keep their status.
|
|
233
|
+
* - THE CLIENT SOCKET'S OWN CLOSE is the cancellation signal for the wait:
|
|
234
|
+
* a `close`/`error` on the raw pre-upgrade socket aborts the signal the
|
|
235
|
+
* resolver rides. A resolver that settles AFTER the client vanished never
|
|
236
|
+
* upgrades — its binding is released through the binding's own `release`
|
|
237
|
+
* seam (the native detach; a still-queued admission ticket is cancelled
|
|
238
|
+
* underneath it by the backhaul's abort path). A client that closes after
|
|
239
|
+
* admission tears down through the connection's own ws-close wiring.
|
|
240
|
+
* - ONE structured log line per upgrade lifecycle event (`realtime_upgrade`:
|
|
241
|
+
* accept → admit → close, with the binding's session id and the client
|
|
242
|
+
* close reason) — the lane was previously invisible in the process log.
|
|
243
|
+
* - The resolved binding carries a PRIVATE native uRun session (fresh or
|
|
244
|
+
* explicitly-resumed) and, iff voice, a PRIVATE audio bridge — never the
|
|
245
|
+
* pooled tenant lane. The connection's cross-caller claim is invariant
|
|
246
|
+
* validation, not capacity policy.
|
|
247
|
+
* - Returns an async close function: waits for every touched socket to
|
|
248
|
+
* settle, then closes the internal WebSocketServer. It does NOT end the
|
|
249
|
+
* native uRun sessions (detach ≠ session death — resume is Main-owned;
|
|
250
|
+
* the binding seam decides lifetime).
|
|
251
|
+
*/
|
|
252
|
+
|
|
253
|
+
declare const OPENAI_REALTIME_PATH = "/v1/realtime";
|
|
254
|
+
/**
|
|
255
|
+
* The resolver seam — the ONLY credential, modality, and session-allocation
|
|
256
|
+
* authority this adapter recognizes. Implemented by Main's composition (and
|
|
257
|
+
* by tests with an injected fake). Accepted in EITHER form: a bare
|
|
258
|
+
* `(req, signal) => Promise<binding>` (the {@link ProxyClientsFor}-style
|
|
259
|
+
* convention) or a `{ resolve(req, signal) }` object. `signal` aborts when
|
|
260
|
+
* the CLIENT SOCKET closes/errors before the upgrade is accepted — the
|
|
261
|
+
* resolver SHOULD abandon its admission wait on it (the backhaul's
|
|
262
|
+
* `openAudioOn` rides the same signal into core `whenLive`'s own abort
|
|
263
|
+
* support); a resolver that ignores it still cannot admit an upgrade to a
|
|
264
|
+
* vanished client: the settled binding is released, never upgraded.
|
|
265
|
+
*/
|
|
266
|
+
/**
|
|
267
|
+
* One ADMISSION WAITING-STATUS update the resolver reports while the dial
|
|
268
|
+
* waits for a seat (owner semantics: a dedicated realtime dial that cannot
|
|
269
|
+
* get a seat is NEVER refused and NEVER hangs blindly — the client sees a
|
|
270
|
+
* WAITING/QUEUED status and gets served when capacity appears). The `status`
|
|
271
|
+
* word rides the gateway's own vocabulary (core `SessionGatewayStatus`):
|
|
272
|
+
* `queued`, `pending`, `waiting_for_capacity` — a WAITING word, never a
|
|
273
|
+
* terminal one. Surfaced to the client as a `urun.admission` frame on the
|
|
274
|
+
* ALREADY-UPGRADED socket (see {@link RealtimeAdmissionNotifier}).
|
|
275
|
+
*/
|
|
276
|
+
interface RealtimeAdmissionStatus {
|
|
277
|
+
status: string;
|
|
278
|
+
reason?: string;
|
|
279
|
+
queue?: {
|
|
280
|
+
position: number;
|
|
281
|
+
depth: number;
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* The resolver's admission-reporting callback. The FIRST call completes the
|
|
286
|
+
* WS upgrade IMMEDIATELY and sends the waiting frame — the client's dial
|
|
287
|
+
* resolves instead of hanging on a pending handshake — and every later call
|
|
288
|
+
* rides the SAME open socket. Frames the client sends between the upgrade
|
|
289
|
+
* and the binding's resolution (its open-time `session.update`) are buffered
|
|
290
|
+
* and replayed into the connection when the resolver settles. A resolver
|
|
291
|
+
* that never calls it keeps the byte-identical pre-upgrade behavior.
|
|
292
|
+
*/
|
|
293
|
+
type RealtimeAdmissionNotifier = (update: RealtimeAdmissionStatus) => void;
|
|
294
|
+
type OpenAIRealtimeResolver<S = unknown> = ((req: IncomingMessage, signal?: AbortSignal, onAdmission?: RealtimeAdmissionNotifier) => Promise<RealtimeBinding<S>>) | {
|
|
295
|
+
resolve(req: IncomingMessage, signal?: AbortSignal, onAdmission?: RealtimeAdmissionNotifier): Promise<RealtimeBinding<S>>;
|
|
296
|
+
};
|
|
297
|
+
interface RealtimeBinding<S = unknown> {
|
|
298
|
+
/**
|
|
299
|
+
* The PRIVATE native uRun session serving this conversation (the shared
|
|
300
|
+
* per-conversation factory in hosted/tenants.ts allocates it; reuse/multi-
|
|
301
|
+
* attach is sanctioned ONLY for the SAME authorized conversation on an
|
|
302
|
+
* explicit resume — two different conversations MUST NOT receive one
|
|
303
|
+
* session). The upstream turn seam is EITHER form:
|
|
304
|
+
* - `session.sendResponseCreate(params, input, requestId)` (the direct
|
|
305
|
+
* SdkTransport-style seam), or
|
|
306
|
+
* - `clients.createResponse(params)` — the canonical ProxyClients seam
|
|
307
|
+
* shape (`input` rides inside `params`). The shared binding composition
|
|
308
|
+
* (binding.ts, ENG-446) hands out a PINNED view of it: the call dials
|
|
309
|
+
* `createResponseOn(handle, …)` on the ONE pooled session the binding
|
|
310
|
+
* resolved with the audio bridge, so no turn on the connection can
|
|
311
|
+
* reach a second pooled session behind the bridge's back.
|
|
312
|
+
* A binding with neither is rejected at upgrade time, LOUD.
|
|
313
|
+
*/
|
|
314
|
+
session?: S & {
|
|
315
|
+
sendResponseCreate?(params: unknown, input: unknown[], requestId: string): Promise<AsyncIterable<unknown>>;
|
|
316
|
+
};
|
|
317
|
+
clients?: Pick<ProxyClients, 'createResponse'>;
|
|
318
|
+
/**
|
|
319
|
+
* Authoritative modality verdict from the resolver. A function NAME proves
|
|
320
|
+
* nothing — without `voice: true`, audio events are refused and no audio
|
|
321
|
+
* primitive is ever opened on the session.
|
|
322
|
+
*/
|
|
323
|
+
voice: boolean;
|
|
324
|
+
/** The PRIVATE audio bridge for THIS conversation (required iff `voice`). */
|
|
325
|
+
audioSession?: {
|
|
326
|
+
audio: {
|
|
327
|
+
appendInputAudio(base64Pcm16: string, captureWallMs?: number): void;
|
|
328
|
+
onOutputAudio(handler: (b64: string) => void): () => void;
|
|
329
|
+
/**
|
|
330
|
+
* The pooled uRun session this lane rides (backhaul `openAudioOn`
|
|
331
|
+
* reports core `Session.id`), when the backhaul knows it — the field the
|
|
332
|
+
* `realtime_upgrade` log line puts on every lifecycle event so an
|
|
333
|
+
* orphaned session is traceable from the proxy log alone. Null is the
|
|
334
|
+
* honest absence (an id-less session reports no id); sessionIdOf
|
|
335
|
+
* normalizes it to the omitted field below.
|
|
336
|
+
*/
|
|
337
|
+
sessionId?: string | null;
|
|
338
|
+
};
|
|
339
|
+
/** Cross-caller reuse registry (invariant validation; see connection.ts). */
|
|
340
|
+
openaiRealtimeClaims?: Set<RealtimeBinding['audioSession']>;
|
|
341
|
+
};
|
|
342
|
+
/** `model` the binding names for this conversation (overrides session config default). */
|
|
343
|
+
model?: string;
|
|
344
|
+
/**
|
|
345
|
+
* THE DIAL-TIME BILLING IDENTITY (session-time billing) — the catalog
|
|
346
|
+
* identity the session dial resolved, captured at resolution time by the
|
|
347
|
+
* shared binding composition and carried here for the teardown hook's
|
|
348
|
+
* ledger row. Absent (no oracle wired, or the composite lane) ⇒ the
|
|
349
|
+
* ledger row is skipped LOUD (`model_unresolved`), never guessed.
|
|
350
|
+
*/
|
|
351
|
+
catalog?: TurnCatalogIdentity;
|
|
352
|
+
/**
|
|
353
|
+
* The NATIVE video frame lane (the §5 `rt-video-in` named-DATA path —
|
|
354
|
+
* enableSessionVideo on a pooled session, the lane stream relay's
|
|
355
|
+
* `rt-video-in` channel on a proxy-hosted lane), resolved on the SAME
|
|
356
|
+
* pooled session identity the voice binding rides. LAZY: the lane opens on
|
|
357
|
+
* the first `conversation.item.create` `input_image` frame, never at
|
|
358
|
+
* binding time. Optional at the seam: an absent opener means the embedder
|
|
359
|
+
* wired no video seam — the connection answers image frames with the LOUD
|
|
360
|
+
* error event, never a silent drop.
|
|
361
|
+
*/
|
|
362
|
+
video?: () => Promise<ProxyVideoLane>;
|
|
363
|
+
/**
|
|
364
|
+
* The GA transcription-session intent (`?intent=transcription`): this
|
|
365
|
+
* connection is a TRANSCRIPTION session — transcription events flow
|
|
366
|
+
* without the client opting in, and `response.create` answers the loud
|
|
367
|
+
* `unsupported` error (the connection stays open) because there are no
|
|
368
|
+
* model turns to create. Set by the shared binding composition (binding.ts)
|
|
369
|
+
* only when the resolver's URL carried the intent AND the model's catalog
|
|
370
|
+
* row vouches stt (the binding carries `turns`). Absent = the realtime
|
|
371
|
+
* (voice) session, today's behaviour.
|
|
372
|
+
*/
|
|
373
|
+
intent?: 'transcription';
|
|
374
|
+
/** True when `session` is a resumed authorized session (vs a fresh private one). */
|
|
375
|
+
resumed?: boolean;
|
|
376
|
+
/**
|
|
377
|
+
* The backend's OWN turn/transcript lane — the §5 `stt` named stream
|
|
378
|
+
* (urun.serve.transcribe_bridge wire shape: `t` = delta/final/turn_start/
|
|
379
|
+
* turn_end/turn_eager_end/turn_resumed, `delta` text, additive `start_ms`
|
|
380
|
+
* and semantic-VAD `confidence`). The resolver maps `session.stream('stt')
|
|
381
|
+
* .messages()` onto this. Its `turn_end` IS the native commit and
|
|
382
|
+
* `turn_start` IS the native barge-in — the adapter drives server-VAD
|
|
383
|
+
* emulation, real transcription events, and model-visible committed audio
|
|
384
|
+
* from it. Absent = the backend wired no turn lane: manual mode only.
|
|
385
|
+
*
|
|
386
|
+
* The CONSUMER passes its own lifecycle `signal` (the realtime connection's
|
|
387
|
+
* turn-lane controller): the lane must END its stream subscription when it
|
|
388
|
+
* aborts — the transport races its pulls against it — so the subscription
|
|
389
|
+
* never outlives the consumer. A consumer that passes none gets an
|
|
390
|
+
* un-raced lane (its own teardown is then its own problem).
|
|
391
|
+
*/
|
|
392
|
+
turns?: (signal?: AbortSignal) => AsyncIterable<{
|
|
393
|
+
kind: 'delta' | 'final' | 'turn_start' | 'turn_end' | 'turn_eager_end' | 'turn_resumed';
|
|
394
|
+
text?: string;
|
|
395
|
+
confidence?: number;
|
|
396
|
+
startMs?: number;
|
|
397
|
+
}>;
|
|
398
|
+
/**
|
|
399
|
+
* THE COMPOSITE LANE (ENG-451, openai-realtime/composite.ts): this binding
|
|
400
|
+
* composes THREE pinned sessions — the `stt` leg behind `turns` and the
|
|
401
|
+
* composed bridge's IN side, the bound chat row behind
|
|
402
|
+
* `clients.createResponse`, and the `tts` leg behind the bridge's OUT side
|
|
403
|
+
* and the per-sentence synthesis turns. The connection keys its
|
|
404
|
+
* live-transcription-in semantics on this marker: appends stream to the
|
|
405
|
+
* stt leg live, the client's commits own turn boundaries, a committed
|
|
406
|
+
* item's pending transcript gates the model turn (and is written into the
|
|
407
|
+
* item — it is the chat leg's input), and `turn_detection: null` is the
|
|
408
|
+
* only accepted mode. A dead leg's failure is a `SessionGoneError` NAMING
|
|
409
|
+
* the leg — the loud `session_gone` close carries the name.
|
|
410
|
+
*/
|
|
411
|
+
composite?: true;
|
|
412
|
+
/**
|
|
413
|
+
* THE COMPOSITE TURN'S PROMPT CANCEL (ENG-451): stop the ACTIVE turn's
|
|
414
|
+
* legs beyond the turn seam — the composite binding aborts its per-turn
|
|
415
|
+
* controller, which unwinds the tts leg's in-flight synthesis read and
|
|
416
|
+
* drops its queued sentence chunks NOW. The connection calls it from
|
|
417
|
+
* `response.cancel` and from teardown; the for-await `break` alone only
|
|
418
|
+
* unwinds at the turn stream's NEXT event, which is too late for legs
|
|
419
|
+
* that keep consuming GPU on their own. Absent (every one-session
|
|
420
|
+
* binding) = nothing to stop beyond the stream, exactly as before.
|
|
421
|
+
*/
|
|
422
|
+
cancelActiveTurn?: () => void;
|
|
423
|
+
/**
|
|
424
|
+
* Release THIS attachment when the socket closes (the hosted
|
|
425
|
+
* conversation-factory seam — the twin of the Gemini Live binding's
|
|
426
|
+
* `release`): per-attachment release, native detach underneath, the named
|
|
427
|
+
* session itself stays live. Absent (the local fixed-clients lane) = the
|
|
428
|
+
* pooled sessions are the process's own and outlive the socket.
|
|
429
|
+
*/
|
|
430
|
+
release?: () => Promise<void> | void;
|
|
431
|
+
}
|
|
432
|
+
interface OpenAIRealtimeOptions<S = unknown> {
|
|
433
|
+
resolver: OpenAIRealtimeResolver<S>;
|
|
434
|
+
/**
|
|
435
|
+
* Where the per-upgrade structured `realtime_upgrade` lines go (ONE
|
|
436
|
+
* newline-terminated JSON object per lifecycle event: accept → admit →
|
|
437
|
+
* close). Absent, the line goes to this process's stdout through the repo's
|
|
438
|
+
* canonical guarded write — the hosted container's collected log stream.
|
|
439
|
+
* Emitted unconditionally, never behind a verbosity flag: this lane's
|
|
440
|
+
* lifecycle was previously invisible in the process log, which is exactly
|
|
441
|
+
* why an orphaned queued admission could only be diagnosed from the
|
|
442
|
+
* session-server side.
|
|
443
|
+
*/
|
|
444
|
+
log?: (line: string) => void;
|
|
445
|
+
/**
|
|
446
|
+
* Where the caller-message boundary's WITHHOLD receipts go (ENG-538): every
|
|
447
|
+
* time a realtime event keeps raw error text off the wire, the raw text is
|
|
448
|
+
* owed here — one newline-terminated line per withheld failure, carrying the
|
|
449
|
+
* connection/session ids for correlation. Absent, the receipt goes to
|
|
450
|
+
* `console.error` of THIS process; the hosted proxy passes its canonical
|
|
451
|
+
* operator sink so nothing is ever dropped on the floor.
|
|
452
|
+
*/
|
|
453
|
+
operatorLog?: (line: string) => void;
|
|
454
|
+
/**
|
|
455
|
+
* THE LIVE-SESSION LEDGER HOOK (session-time billing, DDR addendum):
|
|
456
|
+
* called ONCE per ADMITTED connection at teardown — the moment the live
|
|
457
|
+
* stream ended — with the connected window this adapter measured
|
|
458
|
+
* (acceptBinding → onClosed, wall-clock). The hosted composition turns it
|
|
459
|
+
* into the `task='realtime'` ledger row priced from
|
|
460
|
+
* `session_seconds = connected_ms / 1000`; see hosted/server.ts. NEVER
|
|
461
|
+
* called for a dial that was still queued when its client vanished (no
|
|
462
|
+
* connected stream, no row — an allocated-but-never-connected segment is
|
|
463
|
+
* not delivered product, the DDR principle verbatim).
|
|
464
|
+
*/
|
|
465
|
+
onSessionEnded?: (info: {
|
|
466
|
+
/** The ORIGINAL upgrade request (the bearer the ledger write rides). */
|
|
467
|
+
req: IncomingMessage;
|
|
468
|
+
/** The binding that served the live stream. */
|
|
469
|
+
binding: RealtimeBinding<S>;
|
|
470
|
+
/** CONNECTED SESSION TIME in whole milliseconds (admit → close). */
|
|
471
|
+
connected_ms: number;
|
|
472
|
+
/** The close reason the connection itself reported. */
|
|
473
|
+
reason: string;
|
|
474
|
+
}) => void;
|
|
475
|
+
}
|
|
476
|
+
/**
|
|
477
|
+
* Attach the OpenAI Realtime WS endpoint to `server`. Upgrades on any other
|
|
478
|
+
* path pass through untouched. Returns an async close function.
|
|
479
|
+
*/
|
|
480
|
+
declare function attachOpenAIRealtime<S = unknown>(server: Server, options: OpenAIRealtimeOptions<S>): () => Promise<void>;
|
|
481
|
+
|
|
212
482
|
/**
|
|
213
483
|
* WHAT a proxy serves — the `identity` block on `GET /stats`. Reuse of a
|
|
214
484
|
* running proxy is allowed iff every field matches the launching invocation
|
|
@@ -1027,6 +1297,21 @@ declare class ModelRouter<S> {
|
|
|
1027
1297
|
* opens NOTHING.
|
|
1028
1298
|
*/
|
|
1029
1299
|
resolveTargetFor(model: string | undefined): Promise<RouteTarget>;
|
|
1300
|
+
/**
|
|
1301
|
+
* THE REALTIME LANE'S BILLING IDENTITY (session-time billing, DDR
|
|
1302
|
+
* addendum): the {@link TurnCatalogIdentity} the model's dial resolves —
|
|
1303
|
+
* the SAME {@link resolveTarget} answer the session dial's acquisition
|
|
1304
|
+
* uses. The realtime resolver calls this ONCE at resolution time (the same
|
|
1305
|
+
* handler tick as the session dial, so the capture rides the dial's own
|
|
1306
|
+
* cache window) and the answer rides the binding to the connection's
|
|
1307
|
+
* teardown, where the ledger row is built — never a re-resolution after
|
|
1308
|
+
* the session closed, the drift the per-request ledger's own docs warn
|
|
1309
|
+
* against. A catalog identity is ALWAYS returned here: an undeployed
|
|
1310
|
+
* model throws {@link UnknownModelError} (the lane's loud 404), and a
|
|
1311
|
+
* caller-org app target carries its slug flavour — the same two flavours
|
|
1312
|
+
* {@link billingIdentityOf} travels.
|
|
1313
|
+
*/
|
|
1314
|
+
realtimeBillingIdentityFor(model: string | undefined): Promise<TurnCatalogIdentity>;
|
|
1030
1315
|
/**
|
|
1031
1316
|
* The SPEECH lane's pooled session for a model — the SAME resolution and
|
|
1032
1317
|
* acquisition as {@link sessionFor}, stored under a LANE-SCOPED pool key
|
|
@@ -1804,6 +2089,16 @@ interface LedgerWrite {
|
|
|
1804
2089
|
* still relays the seconds (the weights stay null).
|
|
1805
2090
|
*/
|
|
1806
2091
|
output_seconds: number | null;
|
|
2092
|
+
/**
|
|
2093
|
+
* THE LIVE SESSION-TIME METER (DDR addendum) — the CONNECTED SESSION
|
|
2094
|
+
* SECONDS a realtime (`/v1/realtime`, Gemini Live) stream was up, measured
|
|
2095
|
+
* by the realtime lane at teardown (admit → close). The control plane
|
|
2096
|
+
* prices a `per_session_second` task from THIS field (`task_billing_units`
|
|
2097
|
+
* declares `realtime` exactly so, urun-infra 20271266000000). NULL = the
|
|
2098
|
+
* lane is not a live session (every HTTP lane) or never connected — never
|
|
2099
|
+
* zero of it, and never coerced: an unmeasured window prices nothing.
|
|
2100
|
+
*/
|
|
2101
|
+
session_seconds: number | null;
|
|
1807
2102
|
/**
|
|
1808
2103
|
* THE WEIGHT (ENG-417) — the serve runtime's own residency in whole
|
|
1809
2104
|
* milliseconds. An allocation input, never GPU time and never a cost. NULL
|
|
@@ -2436,8 +2731,15 @@ interface ProxyClients {
|
|
|
2436
2731
|
* client-gone wait rides the SAME per-entry refcount as {@link openAudio}:
|
|
2437
2732
|
* one of several waiters aborting rejects only that caller's open, the
|
|
2438
2733
|
* queued admission going back only at the LAST waiter's abort.
|
|
2734
|
+
*
|
|
2735
|
+
* `onAdmission` is the WAITING-STATUS surface (the dedicated realtime
|
|
2736
|
+
* dial's `urun.admission` frame, attach.ts): called once when the handle's
|
|
2737
|
+
* session is not yet live — the dial's admission is pending — with the
|
|
2738
|
+
* gateway-vocabulary waiting word (`queued` / `pending` /
|
|
2739
|
+
* `waiting_for_capacity`). Absent ⇒ no status surface (the speech lane
|
|
2740
|
+
* passes none; a live session never triggers a call).
|
|
2439
2741
|
*/
|
|
2440
|
-
openAudioOn?(handle: string, signal?: AbortSignal, connectionTag?: string): Promise<PinnedAudioLane>;
|
|
2742
|
+
openAudioOn?(handle: string, signal?: AbortSignal, connectionTag?: string, onAdmission?: RealtimeAdmissionNotifier): Promise<PinnedAudioLane>;
|
|
2441
2743
|
/**
|
|
2442
2744
|
* The HANDLE-ADDRESSED video frame lane open (the realtime binding's
|
|
2443
2745
|
* `input_image` camera frames): the SAME native rt-video-in frame path
|
|
@@ -2538,6 +2840,20 @@ interface ProxyClients {
|
|
|
2538
2840
|
* compat proxy and existing test doubles are untouched.
|
|
2539
2841
|
*/
|
|
2540
2842
|
dedicatedSessionHandle?(model: string | undefined): Promise<string>;
|
|
2843
|
+
/**
|
|
2844
|
+
* THE REALTIME LANE'S BILLING IDENTITY (session-time billing, DDR
|
|
2845
|
+
* addendum): the {@link TurnCatalogIdentity} the model's dial resolves,
|
|
2846
|
+
* captured AT RESOLUTION TIME — the same handler tick the session dial
|
|
2847
|
+
* runs in, so the capture rides the dial's own cache window and the ledger
|
|
2848
|
+
* row names the catalog row that actually vouched the session. The realtime
|
|
2849
|
+
* binding is PINNED to its one session for the connection's whole life
|
|
2850
|
+
* (ENG-446 — no mid-session re-home), so a dial-time capture is correct for
|
|
2851
|
+
* the session's entire connected window; the per-request re-pin discipline
|
|
2852
|
+
* (`repinOnDial`) has no realtime analog because there is no second dial.
|
|
2853
|
+
* Optional at the seam: absent ⇒ the binding carries no identity and the
|
|
2854
|
+
* ledger row is skipped LOUD (`model_unresolved`), never guessed.
|
|
2855
|
+
*/
|
|
2856
|
+
realtimeBillingIdentityFor?(model: string | undefined): Promise<TurnCatalogIdentity>;
|
|
2541
2857
|
/**
|
|
2542
2858
|
* THE SPEECH LANE'S OWN HANDLE (greptile urun-ts#500): the opaque handle
|
|
2543
2859
|
* for the SPEECH-SCOPED pooled session (`speech:<pool key>` — routing.ts
|
|
@@ -2806,4 +3122,4 @@ interface RealtimeCompanions {
|
|
|
2806
3122
|
*/
|
|
2807
3123
|
type RealtimeCompanionsFor = (model: string | undefined) => Promise<RealtimeCompanions | null>;
|
|
2808
3124
|
|
|
2809
|
-
export { type DialObserver as D, type InferenceRecord as I, type LedgerFailure as L, ModelRouter as M, type ProxyClients as P, type
|
|
3125
|
+
export { type DialObserver as D, type InferenceRecord as I, type LedgerFailure as L, ModelRouter as M, OPENAI_REALTIME_PATH as O, type ProxyClients as P, type RealtimeAdmissionNotifier as R, SessionGoneError as S, UnknownModelError as U, type DialReport as a, type InferenceUsageRecord as b, type LedgerOutcome as c, type LedgerRecorded as d, type LedgerWrite as e, type OpenAIRealtimeOptions as f, type OpenAIRealtimeResolver as g, type ProxyHandlerOptions as h, type ProxyIdentity as i, type ProxyVideoOutLane as j, type RealtimeBinding as k, type RealtimeCompanionsFor as l, type RouteTarget as m, type UsageRowReporter as n, attachOpenAIRealtime as o, billingIdentityOf as p };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { C as CatalogRow } from './models-D7F0bLJ3.js';
|
|
2
|
-
import { IncomingMessage } from 'node:http';
|
|
3
|
-
import { a as AudioBridge, h as VideoFrameLane, j as VideoOutLane } from './video-out-
|
|
2
|
+
import { IncomingMessage, Server } from 'node:http';
|
|
3
|
+
import { a as AudioBridge, h as VideoFrameLane, j as VideoOutLane } from './video-out-DkMqKSOi.js';
|
|
4
4
|
|
|
5
5
|
type TurnCatalogIdentity = {
|
|
6
6
|
kind: 'catalog';
|
|
@@ -46,6 +46,8 @@ interface InferenceRecord {
|
|
|
46
46
|
|
|
47
47
|
readonly output_seconds: number | null;
|
|
48
48
|
|
|
49
|
+
readonly session_seconds: number | null;
|
|
50
|
+
|
|
49
51
|
readonly session_id: string | null;
|
|
50
52
|
|
|
51
53
|
readonly queue_ms: number | null;
|
|
@@ -71,6 +73,85 @@ interface SessionTurnLaneEvent {
|
|
|
71
73
|
startMs?: number;
|
|
72
74
|
}
|
|
73
75
|
|
|
76
|
+
declare const OPENAI_REALTIME_PATH = "/v1/realtime";
|
|
77
|
+
|
|
78
|
+
interface RealtimeAdmissionStatus {
|
|
79
|
+
status: string;
|
|
80
|
+
reason?: string;
|
|
81
|
+
queue?: {
|
|
82
|
+
position: number;
|
|
83
|
+
depth: number;
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
type RealtimeAdmissionNotifier = (update: RealtimeAdmissionStatus) => void;
|
|
88
|
+
type OpenAIRealtimeResolver<S = unknown> = ((req: IncomingMessage, signal?: AbortSignal, onAdmission?: RealtimeAdmissionNotifier) => Promise<RealtimeBinding<S>>) | {
|
|
89
|
+
resolve(req: IncomingMessage, signal?: AbortSignal, onAdmission?: RealtimeAdmissionNotifier): Promise<RealtimeBinding<S>>;
|
|
90
|
+
};
|
|
91
|
+
interface RealtimeBinding<S = unknown> {
|
|
92
|
+
|
|
93
|
+
session?: S & {
|
|
94
|
+
sendResponseCreate?(params: unknown, input: unknown[], requestId: string): Promise<AsyncIterable<unknown>>;
|
|
95
|
+
};
|
|
96
|
+
clients?: Pick<ProxyClients, 'createResponse'>;
|
|
97
|
+
|
|
98
|
+
voice: boolean;
|
|
99
|
+
|
|
100
|
+
audioSession?: {
|
|
101
|
+
audio: {
|
|
102
|
+
appendInputAudio(base64Pcm16: string, captureWallMs?: number): void;
|
|
103
|
+
onOutputAudio(handler: (b64: string) => void): () => void;
|
|
104
|
+
|
|
105
|
+
sessionId?: string | null;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
openaiRealtimeClaims?: Set<RealtimeBinding['audioSession']>;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
model?: string;
|
|
112
|
+
|
|
113
|
+
catalog?: TurnCatalogIdentity;
|
|
114
|
+
|
|
115
|
+
video?: () => Promise<ProxyVideoLane>;
|
|
116
|
+
|
|
117
|
+
intent?: 'transcription';
|
|
118
|
+
|
|
119
|
+
resumed?: boolean;
|
|
120
|
+
|
|
121
|
+
turns?: (signal?: AbortSignal) => AsyncIterable<{
|
|
122
|
+
kind: 'delta' | 'final' | 'turn_start' | 'turn_end' | 'turn_eager_end' | 'turn_resumed';
|
|
123
|
+
text?: string;
|
|
124
|
+
confidence?: number;
|
|
125
|
+
startMs?: number;
|
|
126
|
+
}>;
|
|
127
|
+
|
|
128
|
+
composite?: true;
|
|
129
|
+
|
|
130
|
+
cancelActiveTurn?: () => void;
|
|
131
|
+
|
|
132
|
+
release?: () => Promise<void> | void;
|
|
133
|
+
}
|
|
134
|
+
interface OpenAIRealtimeOptions<S = unknown> {
|
|
135
|
+
resolver: OpenAIRealtimeResolver<S>;
|
|
136
|
+
|
|
137
|
+
log?: (line: string) => void;
|
|
138
|
+
|
|
139
|
+
operatorLog?: (line: string) => void;
|
|
140
|
+
|
|
141
|
+
onSessionEnded?: (info: {
|
|
142
|
+
|
|
143
|
+
req: IncomingMessage;
|
|
144
|
+
|
|
145
|
+
binding: RealtimeBinding<S>;
|
|
146
|
+
|
|
147
|
+
connected_ms: number;
|
|
148
|
+
|
|
149
|
+
reason: string;
|
|
150
|
+
}) => void;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
declare function attachOpenAIRealtime<S = unknown>(server: Server, options: OpenAIRealtimeOptions<S>): () => Promise<void>;
|
|
154
|
+
|
|
74
155
|
interface ProxyIdentity {
|
|
75
156
|
app: string;
|
|
76
157
|
org: string;
|
|
@@ -304,6 +385,8 @@ declare class ModelRouter<S> {
|
|
|
304
385
|
|
|
305
386
|
resolveTargetFor(model: string | undefined): Promise<RouteTarget>;
|
|
306
387
|
|
|
388
|
+
realtimeBillingIdentityFor(model: string | undefined): Promise<TurnCatalogIdentity>;
|
|
389
|
+
|
|
307
390
|
speechSessionFor(model: string | undefined): Promise<{
|
|
308
391
|
app: string;
|
|
309
392
|
entry: S;
|
|
@@ -471,6 +554,8 @@ interface LedgerWrite {
|
|
|
471
554
|
|
|
472
555
|
output_seconds: number | null;
|
|
473
556
|
|
|
557
|
+
session_seconds: number | null;
|
|
558
|
+
|
|
474
559
|
queue_ms: number | null;
|
|
475
560
|
prefill_ms: number | null;
|
|
476
561
|
decode_ms: number | null;
|
|
@@ -600,7 +685,7 @@ interface ProxyClients {
|
|
|
600
685
|
|
|
601
686
|
openAudio?(model: string | undefined, signal?: AbortSignal): Promise<ProxyAudioLane>;
|
|
602
687
|
|
|
603
|
-
openAudioOn?(handle: string, signal?: AbortSignal, connectionTag?: string): Promise<PinnedAudioLane>;
|
|
688
|
+
openAudioOn?(handle: string, signal?: AbortSignal, connectionTag?: string, onAdmission?: RealtimeAdmissionNotifier): Promise<PinnedAudioLane>;
|
|
604
689
|
|
|
605
690
|
openVideoOn?(handle: string, signal?: AbortSignal): Promise<ProxyVideoLane>;
|
|
606
691
|
|
|
@@ -618,6 +703,8 @@ interface ProxyClients {
|
|
|
618
703
|
|
|
619
704
|
dedicatedSessionHandle?(model: string | undefined): Promise<string>;
|
|
620
705
|
|
|
706
|
+
realtimeBillingIdentityFor?(model: string | undefined): Promise<TurnCatalogIdentity>;
|
|
707
|
+
|
|
621
708
|
speechSessionHandle?(model: string | undefined): Promise<string>;
|
|
622
709
|
|
|
623
710
|
evictSpeechSession?(handle: string): Promise<void>;
|
|
@@ -679,4 +766,4 @@ interface RealtimeCompanions {
|
|
|
679
766
|
|
|
680
767
|
type RealtimeCompanionsFor = (model: string | undefined) => Promise<RealtimeCompanions | null>;
|
|
681
768
|
|
|
682
|
-
export { type DialObserver as D, type InferenceRecord as I, type LedgerFailure as L, ModelRouter as M, type ProxyClients as P, type
|
|
769
|
+
export { type DialObserver as D, type InferenceRecord as I, type LedgerFailure as L, ModelRouter as M, OPENAI_REALTIME_PATH as O, type ProxyClients as P, type RealtimeAdmissionNotifier as R, SessionGoneError as S, UnknownModelError as U, type DialReport as a, type InferenceUsageRecord as b, type LedgerOutcome as c, type LedgerRecorded as d, type LedgerWrite as e, type OpenAIRealtimeOptions as f, type OpenAIRealtimeResolver as g, type ProxyHandlerOptions as h, type ProxyIdentity as i, type ProxyVideoOutLane as j, type RealtimeBinding as k, type RealtimeCompanionsFor as l, type RouteTarget as m, type UsageRowReporter as n, attachOpenAIRealtime as o, billingIdentityOf as p };
|