@urun-sh/openai 0.3.0 → 0.3.2
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-BYx3YLGo.d.ts +26 -0
- package/dist/ResponsesClient-Dft3bg3b.d.cts +26 -0
- package/dist/chunk-5NXM4IO3.js +2 -0
- package/dist/{chunk-3ED25N7E.js → chunk-AJYWEXQZ.js} +1 -1
- package/dist/chunk-CWJRDBDC.js +1 -0
- package/dist/chunk-FVFF5EWK.js +6 -0
- package/dist/chunk-G3NMGP4N.js +1 -0
- package/dist/chunk-M6ICU4F5.js +40 -0
- package/dist/chunk-UVAY7Q7Z.js +1 -0
- package/dist/gemini-live.cjs +2 -0
- package/dist/gemini-live.d.cts +120 -0
- package/dist/gemini-live.d.ts +79 -0
- package/dist/gemini-live.js +1 -0
- package/dist/hosted/bin.cjs +18 -18
- package/dist/hosted/bin.js +1 -1
- package/dist/hosted/index.cjs +17 -17
- package/dist/hosted/index.d.cts +4 -3
- package/dist/hosted/index.d.ts +4 -3
- 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.d.cts +2 -1
- package/dist/pi-extension/index.d.ts +2 -1
- package/dist/pi-extension/index.js +1 -1
- package/dist/pi-extension/standalone.cjs +53 -53
- package/dist/proxy/cli.cjs +37 -37
- package/dist/proxy/cli.js +1 -1
- package/dist/proxy/index.cjs +21 -21
- package/dist/proxy/index.d.cts +4 -31
- package/dist/proxy/index.d.ts +4 -6
- package/dist/proxy/index.js +1 -1
- package/dist/{server-DiQUIDDg.d.cts → server-BfME37pQ.d.cts} +20 -2
- package/dist/{server-BBKNv7hV.d.ts → server-l1himPxc.d.ts} +6 -2
- package/dist/translator-C9uPKypK.d.ts +130 -0
- package/dist/translator-CcDBEfvm.d.cts +227 -0
- package/dist/{ResponsesClient-y8g6OfNN.d.cts → types-lsVTbNcH.d.cts} +16 -24
- package/dist/{ResponsesClient-y8g6OfNN.d.ts → types-lsVTbNcH.d.ts} +8 -24
- package/dist/video-out-CWesbk12.d.ts +155 -0
- package/dist/video-out-D20UuJ8G.d.cts +298 -0
- package/package.json +12 -2
- package/dist/chunk-35LB5OHI.js +0 -1
- package/dist/chunk-EFBD3CGZ.js +0 -1
- package/dist/chunk-VG3X2LVG.js +0 -41
- package/dist/chunk-XHRPJIEK.js +0 -6
- package/dist/media-DCHTX3Ez.d.cts +0 -68
- package/dist/media-DCHTX3Ez.d.ts +0 -42
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import { k as VideoOutRecord } from './video-out-D20UuJ8G.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Gemini Live (BidiGenerateContent) ⇄ uRun Responses translation — PURE
|
|
5
|
+
* functions only, no I/O and no session state. The wire shapes mirror the
|
|
6
|
+
* official WebSocket reference (https://ai.google.dev/api/live): client
|
|
7
|
+
* messages are a union of exactly one of `setup` / `clientContent` /
|
|
8
|
+
* `realtimeInput` / `toolResponse`; server messages are a union of
|
|
9
|
+
* `setupComplete` / `serverContent` / `toolCall` / … with `usageMetadata` as
|
|
10
|
+
* a SIBLING of the union field on `BidiGenerateContentServerMessage`.
|
|
11
|
+
*
|
|
12
|
+
* Scope (this slice): setup + clientContent + realtimeInput TEXT + AUDIO +
|
|
13
|
+
* VIDEO + serverContent streaming + toolCall/toolResponse + sessionResumption
|
|
14
|
+
* (handles over the proxy's pooled-session identity seam) + goAway + MANUAL
|
|
15
|
+
* VAD/activity (setup.realtimeInputConfig.automaticActivityDetection.disabled
|
|
16
|
+
* + realtimeInput.activityStart/activityEnd + serverContent.interrupted
|
|
17
|
+
* barge-in). AUTOMATIC (server-side) activity detection is the DECLARED
|
|
18
|
+
* follow-up slice — requesting it fails loud naming the follow-up, never
|
|
19
|
+
* silently ignored (repo mandate: one canonical path, no silent fallbacks).
|
|
20
|
+
*
|
|
21
|
+
* AUTOMATIC activity detection is deliberately NOT emulated here: server-side
|
|
22
|
+
* VAD is a PLATFORM primitive (urun-python `urun.serve.turn_detection`
|
|
23
|
+
* `detect_turns` — `turn_start`/`turn_end` events on the session's §5 stream
|
|
24
|
+
* lane), never adapter-local DSP in the proxy. Until the Live lane's session
|
|
25
|
+
* shapes emit those events, requesting automatic detection fails loud.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/** The Live WS endpoint path (v1beta), verbatim from the Google reference. */
|
|
29
|
+
declare const GEMINI_LIVE_PATH = "/ws/google.ai.generativelanguage.v1beta.GenerativeService.BidiGenerateContent";
|
|
30
|
+
/** WS close code for protocol violations (invalid/unsupported payloads). */
|
|
31
|
+
declare const CLOSE_PROTOCOL = 1007;
|
|
32
|
+
/** WS close code for policy rejections (unknown model — sendUnknownModel's WS mirror). */
|
|
33
|
+
declare const CLOSE_UNKNOWN_MODEL = 1008;
|
|
34
|
+
/** WS close code for upstream failures (backhaul errored or ended without completing). */
|
|
35
|
+
declare const CLOSE_UPSTREAM = 1011;
|
|
36
|
+
/**
|
|
37
|
+
* WS close code when a `sessionResumption.handle` names a session that no
|
|
38
|
+
* longer exists (proxy restarted, handle expired/evicted, or never issued).
|
|
39
|
+
* Policy-shaped like CLOSE_UNKNOWN_MODEL: the client must reconnect WITHOUT
|
|
40
|
+
* the handle to start a new session — resume is never silently faked.
|
|
41
|
+
*/
|
|
42
|
+
declare const CLOSE_SESSION_GONE = 1008;
|
|
43
|
+
/** A loud, translatable failure: `closeCode` is the WS close code to die with. */
|
|
44
|
+
declare class GeminiLiveError extends Error {
|
|
45
|
+
readonly closeCode: number;
|
|
46
|
+
constructor(message: string, closeCode?: number);
|
|
47
|
+
}
|
|
48
|
+
type Rec = Record<string, unknown>;
|
|
49
|
+
/** The parsed client message union — exactly one of the four Bidi kinds. */
|
|
50
|
+
type ClientMessage = {
|
|
51
|
+
kind: 'setup';
|
|
52
|
+
setup: Rec;
|
|
53
|
+
} | {
|
|
54
|
+
kind: 'clientContent';
|
|
55
|
+
clientContent: Rec;
|
|
56
|
+
} | {
|
|
57
|
+
kind: 'realtimeInput';
|
|
58
|
+
realtimeInput: Rec;
|
|
59
|
+
} | {
|
|
60
|
+
kind: 'toolResponse';
|
|
61
|
+
toolResponse: Rec;
|
|
62
|
+
};
|
|
63
|
+
/** Parse one WS frame into the client-message union; anything else is loud. */
|
|
64
|
+
declare function parseClientMessage(raw: string): ClientMessage;
|
|
65
|
+
/** RealtimeInputConfig.ActivityHandling — the Live API's barge-in policy. */
|
|
66
|
+
type ActivityHandling = 'START_OF_ACTIVITY_INTERRUPTS' | 'NO_INTERRUPTION';
|
|
67
|
+
/** The VAD/activity posture distilled from setup.realtimeInputConfig. */
|
|
68
|
+
interface ActivityConfig {
|
|
69
|
+
/**
|
|
70
|
+
* True when `automaticActivityDetection.disabled === true`: the CLIENT owns
|
|
71
|
+
* activity boundaries and marks them with realtimeInput.activityStart/
|
|
72
|
+
* activityEnd (the Live API's manual-VAD mode). False (default) means no
|
|
73
|
+
* activity signaling at all in this slice — AUTOMATIC detection is the
|
|
74
|
+
* declared platform follow-up (serve turn_detection events, see header).
|
|
75
|
+
*/
|
|
76
|
+
manualActivity: boolean;
|
|
77
|
+
/** Whether activityStart barge-ins interrupt an in-flight generation (default) or not. */
|
|
78
|
+
activityHandling: ActivityHandling;
|
|
79
|
+
}
|
|
80
|
+
/** The per-connection config distilled from BidiGenerateContentSetup. */
|
|
81
|
+
interface LiveSessionConfig {
|
|
82
|
+
/** setup.model with the `models/` resource prefix stripped — fed to model routing. */
|
|
83
|
+
model: string;
|
|
84
|
+
/** systemInstruction as Responses input items (seeded once into the transcript). */
|
|
85
|
+
systemItems: Rec[];
|
|
86
|
+
/** functionDeclarations flattened to Responses `{type:'function', …}` tools. */
|
|
87
|
+
tools: Rec[] | undefined;
|
|
88
|
+
temperature: number | undefined;
|
|
89
|
+
maxOutputTokens: number | undefined;
|
|
90
|
+
/**
|
|
91
|
+
* `generationConfig.responseModalities` includes AUDIO — the handler opens
|
|
92
|
+
* the native audio lane (ProxyClients.openAudio → AudioBridge over
|
|
93
|
+
* rt-audio-in/rt-audio-out) EAGERLY at setup instead of on first audio chunk.
|
|
94
|
+
*/
|
|
95
|
+
audioModality: boolean;
|
|
96
|
+
/** VAD/activity posture from setup.realtimeInputConfig (manual mode only). */
|
|
97
|
+
activity: ActivityConfig;
|
|
98
|
+
/**
|
|
99
|
+
* setup.sessionResumption (SessionResumptionConfig): `enabled` when the
|
|
100
|
+
* field is present at all (the server then emits sessionResumptionUpdate
|
|
101
|
+
* messages); `handle` when the client is RESUMING a previous Live session.
|
|
102
|
+
*/
|
|
103
|
+
sessionResumption: {
|
|
104
|
+
enabled: boolean;
|
|
105
|
+
handle: string | null;
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* The client opted into the uRun video OUTPUT extension
|
|
109
|
+
* (`setup["urun.videoOut"]: {}` — a vendor-prefixed field the real Google
|
|
110
|
+
* schema can never collide with; Gemini Live itself has NO video OUT
|
|
111
|
+
* modality). The handler answers in setupComplete with the negotiated named
|
|
112
|
+
* §5 `rt-video-out` WT/QUIC endpoint, or omits the field (= unsupported).
|
|
113
|
+
*/
|
|
114
|
+
videoOut: boolean;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* The vendor-prefixed extension key, used verbatim in BOTH directions:
|
|
118
|
+
* `setup["urun.videoOut"]` opts in; `setupComplete["urun.videoOut"]` carries
|
|
119
|
+
* the granted {@link import('../../transport/video-out').VideoOutEndpoint}.
|
|
120
|
+
* Vanilla clients never send it and ignore it in setupComplete — parity holds.
|
|
121
|
+
*/
|
|
122
|
+
declare const VIDEO_OUT_SETUP_KEY = "urun.videoOut";
|
|
123
|
+
/**
|
|
124
|
+
* The videoOut capability ack (spec v2, WS-inline): the WS IS the transport,
|
|
125
|
+
* so the grant carries ONLY what the client needs to interpret the inline
|
|
126
|
+
* chunks — the framing id and the capability-level default codec. No urls,
|
|
127
|
+
* tokens, or cert hashes ever appear here.
|
|
128
|
+
*/
|
|
129
|
+
declare function videoOutAck(codec: string): Rec;
|
|
130
|
+
/**
|
|
131
|
+
* One native video-OUT record as the extension SERVER MESSAGE riding the SAME
|
|
132
|
+
* Bidi WS as the rest of the surface (spec v2): base64 AU inside JSON, the
|
|
133
|
+
* exact idiom the surface uses for audio bytes (serverContent inlineData) —
|
|
134
|
+
* vendor-keyed so vanilla clients ignore it.
|
|
135
|
+
*/
|
|
136
|
+
declare function videoOutChunkMsg(record: VideoOutRecord): Rec;
|
|
137
|
+
/** BidiGenerateContentSetup → session config. Everything unsupported is loud. */
|
|
138
|
+
declare function translateSetup(setup: Rec): LiveSessionConfig;
|
|
139
|
+
/**
|
|
140
|
+
* SessionResumptionUpdate per the Live WS reference: `newHandle` names a
|
|
141
|
+
* resumable state; sent ONLY when setup.sessionResumption was set.
|
|
142
|
+
*/
|
|
143
|
+
declare function sessionResumptionUpdateMsg(newHandle: string): Rec;
|
|
144
|
+
/**
|
|
145
|
+
* GoAway per the Live WS reference — `timeLeft` is a protobuf Duration in its
|
|
146
|
+
* JSON form ("3.5s"). null timeLeft (no native deadline known) renders "0s":
|
|
147
|
+
* the connection is being terminated NOW (see the missing-primitive note in
|
|
148
|
+
* handler.ts — core exposes no pre-expiry notice event yet).
|
|
149
|
+
*/
|
|
150
|
+
declare function goAwayMsg(timeLeftMs: number | null): Rec;
|
|
151
|
+
/** BidiGenerateContentClientContent → Responses input items + the turn trigger. */
|
|
152
|
+
declare function translateClientContent(cc: Rec): {
|
|
153
|
+
items: Rec[];
|
|
154
|
+
turnComplete: boolean;
|
|
155
|
+
};
|
|
156
|
+
/** Live spec input format: 16-bit little-endian PCM, 16 kHz, mono. */
|
|
157
|
+
declare const GEMINI_AUDIO_IN_RATE = 16000;
|
|
158
|
+
/** Mirror of the transport's native rate (media.ts NATIVE_AUDIO_SAMPLE_RATE). */
|
|
159
|
+
declare const GEMINI_AUDIO_OUT_RATE = 24000;
|
|
160
|
+
/** Live spec output format: 24 kHz 16-bit PCM — the native rate, so out is 1:1. */
|
|
161
|
+
declare const GEMINI_AUDIO_OUT_MIME = "audio/pcm;rate=24000";
|
|
162
|
+
/**
|
|
163
|
+
* One native Opus frame (20 ms @ 24 kHz = 480 samples) of silence, base64.
|
|
164
|
+
* `audioStreamEnd` appends this through the SAME `appendInputAudio` lane: the
|
|
165
|
+
* bridge's outbound framer accumulates 480-sample frames, so a sub-frame
|
|
166
|
+
* residue of real audio would otherwise sit in the accumulator forever — one
|
|
167
|
+
* full silence frame provably pushes every real sample out (the flush).
|
|
168
|
+
*/
|
|
169
|
+
declare const OUTBOUND_AUDIO_FLUSH_B64: string;
|
|
170
|
+
/**
|
|
171
|
+
* Linear-interpolation PCM16 resample (mono). Adapter-edge only: Gemini's
|
|
172
|
+
* 16 kHz input → the transport's native 24 kHz. Output length is
|
|
173
|
+
* floor(n·to/from); positions past the last input sample clamp to it.
|
|
174
|
+
*/
|
|
175
|
+
declare function resamplePcm16(samples: Int16Array, from: number, to: number): Int16Array;
|
|
176
|
+
/** The realtimeInput action union — exactly one lane per message. */
|
|
177
|
+
type RealtimeInputAction = {
|
|
178
|
+
kind: 'text';
|
|
179
|
+
text: string;
|
|
180
|
+
} | {
|
|
181
|
+
kind: 'audio';
|
|
182
|
+
base64Pcm24k: string;
|
|
183
|
+
} | {
|
|
184
|
+
kind: 'audioStreamEnd';
|
|
185
|
+
} | {
|
|
186
|
+
kind: 'activityStart';
|
|
187
|
+
} | {
|
|
188
|
+
kind: 'activityEnd';
|
|
189
|
+
} | {
|
|
190
|
+
kind: 'video';
|
|
191
|
+
jpegFrame: Uint8Array;
|
|
192
|
+
};
|
|
193
|
+
/**
|
|
194
|
+
* BidiGenerateContentRealtimeInput → the text lane, the audio lane
|
|
195
|
+
* (adapter-edge resampled onto the native AudioBridge path), the
|
|
196
|
+
* audioStreamEnd flush, the video frame lane (adapter-edge base64-decoded
|
|
197
|
+
* onto the native rt-video-in named-DATA path), or a manual activity marker.
|
|
198
|
+
* activityStart/activityEnd (ActivityStart/ActivityEnd — EMPTY marker
|
|
199
|
+
* messages per the reference) are only translated here; the handler enforces
|
|
200
|
+
* that they arrive in manual activity mode with a coherent open/close
|
|
201
|
+
* ordering. NOTHING is silently droppable.
|
|
202
|
+
*/
|
|
203
|
+
declare function translateRealtimeInput(ri: Rec): RealtimeInputAction;
|
|
204
|
+
/** BidiGenerateContentToolResponse → next-turn `function_call_output` items. */
|
|
205
|
+
declare function translateToolResponse(tr: Rec): Rec[];
|
|
206
|
+
/** One streamed text delta → a serverContent.modelTurn message (else null). */
|
|
207
|
+
declare function serverContentOfDelta(ev: {
|
|
208
|
+
type?: unknown;
|
|
209
|
+
delta?: unknown;
|
|
210
|
+
}): Rec | null;
|
|
211
|
+
/**
|
|
212
|
+
* One native `rt-audio-out` chunk (base64 PCM16 @24 kHz, exactly as the
|
|
213
|
+
* AudioBridge emits it — no conversion: the Live spec output rate IS the
|
|
214
|
+
* native rate) → a serverContent.modelTurn inlineData message.
|
|
215
|
+
*/
|
|
216
|
+
declare function serverContentOfAudio(base64Pcm24k: string): Rec;
|
|
217
|
+
/** What one completed upstream response contributes: wire messages + transcript items. */
|
|
218
|
+
interface TurnEnd {
|
|
219
|
+
/** Server messages to send, in order: toolCall? → generationComplete → turnComplete. */
|
|
220
|
+
messages: Rec[];
|
|
221
|
+
/** Items to append to the connection transcript (assistant text + function_call items). */
|
|
222
|
+
assistantItems: Rec[];
|
|
223
|
+
}
|
|
224
|
+
/** `response.completed` → toolCall / generationComplete / turnComplete (+usage). */
|
|
225
|
+
declare function turnEndOfCompleted(completed: unknown): TurnEnd;
|
|
226
|
+
|
|
227
|
+
export { type ActivityConfig as A, CLOSE_PROTOCOL as C, GEMINI_AUDIO_IN_RATE as G, type LiveSessionConfig as L, OUTBOUND_AUDIO_FLUSH_B64 as O, type RealtimeInputAction as R, type TurnEnd as T, VIDEO_OUT_SETUP_KEY as V, type ActivityHandling as a, CLOSE_SESSION_GONE as b, CLOSE_UNKNOWN_MODEL as c, CLOSE_UPSTREAM as d, type ClientMessage as e, GEMINI_AUDIO_OUT_MIME as f, GEMINI_AUDIO_OUT_RATE as g, GEMINI_LIVE_PATH as h, GeminiLiveError as i, goAwayMsg as j, serverContentOfDelta as k, sessionResumptionUpdateMsg as l, translateRealtimeInput as m, translateSetup as n, translateToolResponse as o, parseClientMessage as p, turnEndOfCompleted as q, resamplePcm16 as r, serverContentOfAudio as s, translateClientContent as t, videoOutChunkMsg as u, videoOutAck as v };
|
|
@@ -54,6 +54,21 @@ interface UrunSessionLike {
|
|
|
54
54
|
* lease stayed alive. Core's surface is `end()` / `disconnect()`.
|
|
55
55
|
*/
|
|
56
56
|
end?(): Promise<unknown>;
|
|
57
|
+
/**
|
|
58
|
+
* Negotiate this session's §5-over-QUIC data-lane endpoint (urun-infra#1608:
|
|
59
|
+
* the `TransportOfferResponse.webtransport` surface — url + sha-256 cert
|
|
60
|
+
* hashes (hex) + the per-leg gateway token — offered with `wtData: true`).
|
|
61
|
+
* The video OUT lane (`enableSessionVideoOut`) hands this endpoint to a
|
|
62
|
+
* consumer that dials the relay's WT gateway directly and reads the named
|
|
63
|
+
* uni streams. Optional structurally; the video OUT wiring fails LOUD when
|
|
64
|
+
* a session lacks it — a missing platform primitive is never a silent skip.
|
|
65
|
+
*/
|
|
66
|
+
wtDataEndpoint?(): Promise<{
|
|
67
|
+
url: string;
|
|
68
|
+
certHashes: string[];
|
|
69
|
+
token: string;
|
|
70
|
+
sessionId?: string;
|
|
71
|
+
}>;
|
|
57
72
|
}
|
|
58
73
|
/**
|
|
59
74
|
* One OpenAI chat-completions-chunk-style tool_call delta fragment as the
|
|
@@ -96,27 +111,4 @@ type LaneMessage = {
|
|
|
96
111
|
code?: string;
|
|
97
112
|
};
|
|
98
113
|
|
|
99
|
-
|
|
100
|
-
readonly requestId: string;
|
|
101
|
-
}
|
|
102
|
-
declare class UrunResponses {
|
|
103
|
-
private readonly transport;
|
|
104
|
-
constructor(session: UrunSessionLike);
|
|
105
|
-
readonly responses: {
|
|
106
|
-
create: (params: {
|
|
107
|
-
model?: string;
|
|
108
|
-
input: unknown;
|
|
109
|
-
stream?: boolean;
|
|
110
|
-
tools?: unknown;
|
|
111
|
-
tool_choice?: unknown;
|
|
112
|
-
temperature?: number;
|
|
113
|
-
max_output_tokens?: number;
|
|
114
|
-
top_p?: number;
|
|
115
|
-
stop?: string[];
|
|
116
|
-
reasoning_effort?: string;
|
|
117
|
-
chat_template_kwargs?: Record<string, unknown>;
|
|
118
|
-
}) => Promise<ResponsesStream>;
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
export { type LaneMessage as L, UrunResponses as U, type UrunSessionLike as a };
|
|
114
|
+
export type { LaneMessage as L, UrunDocLike as U, LaneToolCallDelta as a, UrunSessionLike as b, UrunStreamLike as c };
|
|
@@ -25,6 +25,13 @@ interface UrunSessionLike {
|
|
|
25
25
|
stream(name: string): UrunStreamLike;
|
|
26
26
|
|
|
27
27
|
end?(): Promise<unknown>;
|
|
28
|
+
|
|
29
|
+
wtDataEndpoint?(): Promise<{
|
|
30
|
+
url: string;
|
|
31
|
+
certHashes: string[];
|
|
32
|
+
token: string;
|
|
33
|
+
sessionId?: string;
|
|
34
|
+
}>;
|
|
28
35
|
}
|
|
29
36
|
|
|
30
37
|
interface LaneToolCallDelta {
|
|
@@ -54,27 +61,4 @@ type LaneMessage = {
|
|
|
54
61
|
code?: string;
|
|
55
62
|
};
|
|
56
63
|
|
|
57
|
-
|
|
58
|
-
readonly requestId: string;
|
|
59
|
-
}
|
|
60
|
-
declare class UrunResponses {
|
|
61
|
-
private readonly transport;
|
|
62
|
-
constructor(session: UrunSessionLike);
|
|
63
|
-
readonly responses: {
|
|
64
|
-
create: (params: {
|
|
65
|
-
model?: string;
|
|
66
|
-
input: unknown;
|
|
67
|
-
stream?: boolean;
|
|
68
|
-
tools?: unknown;
|
|
69
|
-
tool_choice?: unknown;
|
|
70
|
-
temperature?: number;
|
|
71
|
-
max_output_tokens?: number;
|
|
72
|
-
top_p?: number;
|
|
73
|
-
stop?: string[];
|
|
74
|
-
reasoning_effort?: string;
|
|
75
|
-
chat_template_kwargs?: Record<string, unknown>;
|
|
76
|
-
}) => Promise<ResponsesStream>;
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export { type LaneMessage as L, UrunResponses as U, type UrunSessionLike as a };
|
|
64
|
+
export type { LaneMessage as L, UrunDocLike as U, LaneToolCallDelta as a, UrunSessionLike as b, UrunStreamLike as c };
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { b as UrunSessionLike } from './types-lsVTbNcH.js';
|
|
2
|
+
|
|
3
|
+
declare const NATIVE_AUDIO_SAMPLE_RATE = 24000;
|
|
4
|
+
|
|
5
|
+
interface AudioSource {
|
|
6
|
+
track: unknown;
|
|
7
|
+
onData(frame: Int16Array): void;
|
|
8
|
+
}
|
|
9
|
+
interface AudioSink {
|
|
10
|
+
onframe: ((frame: {
|
|
11
|
+
samples: Int16Array;
|
|
12
|
+
}) => void) | null;
|
|
13
|
+
}
|
|
14
|
+
interface AudioBackend {
|
|
15
|
+
createSource(): AudioSource;
|
|
16
|
+
|
|
17
|
+
createSink(remoteTrack: unknown): AudioSink;
|
|
18
|
+
}
|
|
19
|
+
declare class AudioBridge {
|
|
20
|
+
private readonly backend;
|
|
21
|
+
private readonly opts;
|
|
22
|
+
private source;
|
|
23
|
+
private sink;
|
|
24
|
+
private outHandlers;
|
|
25
|
+
constructor(backend: AudioBackend, opts: {
|
|
26
|
+
sampleRate: number;
|
|
27
|
+
});
|
|
28
|
+
startOutbound(): Promise<unknown>;
|
|
29
|
+
|
|
30
|
+
appendInputAudio(base64Pcm16: string): void;
|
|
31
|
+
|
|
32
|
+
startInbound(remoteTrack: unknown): Promise<void>;
|
|
33
|
+
|
|
34
|
+
onOutputAudio(handler: (base64Pcm16: string) => void): () => void;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
declare function enableSessionAudio(session: UrunSessionLike, backend: AudioBackend, timeoutMs?: number): Promise<AudioBridge>;
|
|
38
|
+
|
|
39
|
+
declare const RT_VIDEO_IN_STREAM = "rt-video-in";
|
|
40
|
+
|
|
41
|
+
declare const VIDEO_FRAME_MESSAGE_BUDGET = 256000;
|
|
42
|
+
|
|
43
|
+
interface VideoFrameLane {
|
|
44
|
+
sendInputFrame(jpegFrame: Uint8Array): Promise<void>;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
declare function enableSessionVideo(session: UrunSessionLike): VideoFrameLane;
|
|
48
|
+
|
|
49
|
+
declare function weriftAudioBackend(): Promise<AudioBackend>;
|
|
50
|
+
|
|
51
|
+
declare function nodeAudioBackend(): Promise<AudioBackend>;
|
|
52
|
+
|
|
53
|
+
declare const RT_VIDEO_OUT_STREAM = "rt-video-out";
|
|
54
|
+
|
|
55
|
+
declare const VIDEO_OUT_FRAMING = "urun.videoOut.v1";
|
|
56
|
+
|
|
57
|
+
declare const VIDEO_OUT_DEFAULT_CODEC = "h264";
|
|
58
|
+
|
|
59
|
+
interface VideoOutRecordHeader {
|
|
60
|
+
v: 1;
|
|
61
|
+
seq: number;
|
|
62
|
+
ptsUs: number;
|
|
63
|
+
codec: string;
|
|
64
|
+
key: boolean;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
interface VideoOutRecord {
|
|
68
|
+
header: VideoOutRecordHeader;
|
|
69
|
+
au: Uint8Array;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
declare function encodeVideoOutRecord(header: Omit<VideoOutRecordHeader, 'v'>, au: Uint8Array): Uint8Array;
|
|
73
|
+
|
|
74
|
+
declare function decodeVideoOutRecord(payload: Uint8Array): VideoOutRecord;
|
|
75
|
+
|
|
76
|
+
interface VideoOutEndpoint {
|
|
77
|
+
transport: 'webtransport';
|
|
78
|
+
url: string;
|
|
79
|
+
|
|
80
|
+
certHashes: string[];
|
|
81
|
+
|
|
82
|
+
token: string;
|
|
83
|
+
|
|
84
|
+
sessionId: string;
|
|
85
|
+
stream: typeof RT_VIDEO_OUT_STREAM;
|
|
86
|
+
codec: string;
|
|
87
|
+
framing: typeof VIDEO_OUT_FRAMING;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
declare function negotiateSessionVideoOutQuic(session: UrunSessionLike): Promise<VideoOutEndpoint>;
|
|
91
|
+
|
|
92
|
+
declare const VIDEO_OUT_WS_FRAMING = "urun.videoOut.v2-ws";
|
|
93
|
+
|
|
94
|
+
interface VideoOutLane {
|
|
95
|
+
|
|
96
|
+
codec: string;
|
|
97
|
+
onOutputFrame(handler: (record: VideoOutRecord) => void): () => void;
|
|
98
|
+
|
|
99
|
+
onLaneError(handler: (err: Error) => void): () => void;
|
|
100
|
+
|
|
101
|
+
onEnd(handler: () => void): () => void;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
declare function openSessionVideoOutLane(session: UrunSessionLike): VideoOutLane;
|
|
105
|
+
|
|
106
|
+
interface VideoOutSink {
|
|
107
|
+
onFrame(record: VideoOutRecord): void;
|
|
108
|
+
|
|
109
|
+
onEnd?(): void;
|
|
110
|
+
|
|
111
|
+
onLaneError(err: Error): void;
|
|
112
|
+
}
|
|
113
|
+
interface WtByteReader {
|
|
114
|
+
read(): Promise<{
|
|
115
|
+
value?: Uint8Array;
|
|
116
|
+
done: boolean;
|
|
117
|
+
}>;
|
|
118
|
+
cancel?(reason?: unknown): Promise<void>;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
interface VideoOutWtSession {
|
|
122
|
+
ready: Promise<unknown>;
|
|
123
|
+
incomingUnidirectionalStreams: {
|
|
124
|
+
getReader(): {
|
|
125
|
+
read(): Promise<{
|
|
126
|
+
value?: {
|
|
127
|
+
getReader(): WtByteReader;
|
|
128
|
+
};
|
|
129
|
+
done: boolean;
|
|
130
|
+
}>;
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
createBidirectionalStream(): Promise<{
|
|
134
|
+
writable: {
|
|
135
|
+
getWriter(): {
|
|
136
|
+
write(chunk: Uint8Array): Promise<void>;
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
readable: {
|
|
140
|
+
getReader(): WtByteReader;
|
|
141
|
+
};
|
|
142
|
+
}>;
|
|
143
|
+
close?(info?: unknown): void;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
type VideoOutWtConnect = (url: string, options: {
|
|
147
|
+
serverCertificateHashes: Array<{
|
|
148
|
+
algorithm: 'sha-256';
|
|
149
|
+
value: Uint8Array;
|
|
150
|
+
}>;
|
|
151
|
+
}) => VideoOutWtSession;
|
|
152
|
+
|
|
153
|
+
declare function consumeVideoOut(endpoint: VideoOutEndpoint, sink: VideoOutSink, connect?: VideoOutWtConnect): Promise<void>;
|
|
154
|
+
|
|
155
|
+
export { type AudioBackend as A, NATIVE_AUDIO_SAMPLE_RATE as N, RT_VIDEO_IN_STREAM as R, VIDEO_FRAME_MESSAGE_BUDGET as V, AudioBridge as a, type AudioSink as b, type AudioSource as c, RT_VIDEO_OUT_STREAM as d, VIDEO_OUT_DEFAULT_CODEC as e, VIDEO_OUT_FRAMING as f, VIDEO_OUT_WS_FRAMING as g, type VideoFrameLane as h, type VideoOutEndpoint as i, type VideoOutLane as j, type VideoOutRecord as k, type VideoOutRecordHeader as l, type VideoOutSink as m, type VideoOutWtConnect as n, type VideoOutWtSession as o, consumeVideoOut as p, decodeVideoOutRecord as q, enableSessionAudio as r, enableSessionVideo as s, encodeVideoOutRecord as t, negotiateSessionVideoOutQuic as u, nodeAudioBackend as v, openSessionVideoOutLane as w, weriftAudioBackend as x };
|