@urun-sh/openai 0.5.4 → 0.5.6
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 → ResponsesClient-BE3-hx3m.d.ts} +2 -0
- package/dist/{ResponsesClient-Dft3bg3b.d.cts → ResponsesClient-DjZWjlFH.d.cts} +2 -0
- package/dist/chunk-2T2YYBVX.js +1 -0
- package/dist/chunk-3WAJD62J.js +4 -0
- package/dist/{chunk-K23AZPI4.js → chunk-5HKWNK3O.js} +1 -1
- package/dist/chunk-7M6LY6DR.js +2 -0
- package/dist/chunk-BSHT6RZZ.js +1 -0
- package/dist/{chunk-GBBY3PCZ.js → chunk-FP4RSAIE.js} +1 -1
- package/dist/chunk-HR5H6S7L.js +1 -0
- package/dist/chunk-NY23USZF.js +57 -0
- package/dist/chunk-VLRMJRLS.js +6 -0
- package/dist/gemini-live.cjs +2 -2
- package/dist/gemini-live.d.cts +17 -2
- package/dist/gemini-live.d.ts +7 -2
- package/dist/gemini-live.js +1 -1
- package/dist/hosted/bin.cjs +65 -37
- package/dist/hosted/bin.js +3 -3
- package/dist/hosted/index.cjs +46 -19
- package/dist/hosted/index.d.cts +760 -272
- package/dist/hosted/index.d.ts +203 -107
- 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/{models-NYMZrklp.d.cts → models-DUdx_Y6X.d.cts} +1 -1
- package/dist/pi-extension/index.cjs +7 -7
- package/dist/pi-extension/index.d.cts +1 -1
- package/dist/pi-extension/index.d.ts +1 -1
- package/dist/pi-extension/index.js +1 -1
- package/dist/pi-extension/standalone.cjs +48 -48
- package/dist/proxy/cli.cjs +54 -40
- package/dist/proxy/cli.js +14 -14
- package/dist/proxy/index.cjs +33 -22
- package/dist/proxy/index.d.cts +546 -4
- package/dist/proxy/index.d.ts +185 -4
- package/dist/proxy/index.js +1 -1
- package/dist/responses-turn-Dr37N3kH.d.ts +486 -0
- package/dist/responses-turn-tNUHq5b0.d.cts +1807 -0
- package/dist/{translator-C9uPKypK.d.ts → translator-BCoRFaTs.d.ts} +1 -1
- package/dist/{translator-CcDBEfvm.d.cts → translator-Bh0Bp_Ie.d.cts} +3 -3
- package/dist/{video-out-D20UuJ8G.d.cts → video-out-CCksIcj8.d.cts} +5 -5
- package/package.json +12 -11
- package/dist/chunk-4MSBS7M6.js +0 -1
- package/dist/chunk-5NXM4IO3.js +0 -2
- package/dist/chunk-CWJRDBDC.js +0 -1
- package/dist/chunk-OI2OY32M.js +0 -1
- package/dist/chunk-RQBD4OAA.js +0 -6
- package/dist/chunk-STFRT5OY.js +0 -1
- package/dist/chunk-VNM4M4P3.js +0 -40
- package/dist/server-DuH_5OD9.d.ts +0 -84
- package/dist/server-wmUnMewW.d.cts +0 -206
- /package/dist/{chunk-YSFSRI3D.js → chunk-5CCJUNH7.js} +0 -0
- /package/dist/{models-NYMZrklp.d.ts → models-DUdx_Y6X.d.ts} +0 -0
- /package/dist/{video-out-CWesbk12.d.ts → video-out-IGQ4YQ-c.d.ts} +0 -0
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
import { IncomingMessage, Server } from 'node:http';
|
|
2
|
-
import { a as AudioBridge, h as VideoFrameLane, j as VideoOutLane } from './video-out-D20UuJ8G.cjs';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* WHAT a proxy serves — the `identity` block on `GET /stats`. Reuse of a
|
|
6
|
-
* running proxy is allowed iff every field matches the launching invocation
|
|
7
|
-
* EXACTLY: a partial match (same app, different fn; same everything, older
|
|
8
|
-
* proxy_version) silently routes the agent at the wrong backend, which is
|
|
9
|
-
* worse than any error.
|
|
10
|
-
*/
|
|
11
|
-
interface ProxyIdentity {
|
|
12
|
-
app: string;
|
|
13
|
-
org: string;
|
|
14
|
-
fn: string;
|
|
15
|
-
/**
|
|
16
|
-
* The control-plane URL the proxy's backhaul session opens against
|
|
17
|
-
* (URUN_BASE_URL verbatim — same org/app/fn on staging vs prod are
|
|
18
|
-
* DIFFERENT backends; review finding, #285). Compared exactly: a cosmetic
|
|
19
|
-
* difference (trailing slash) merely refuses reuse and spawns an ephemeral
|
|
20
|
-
* proxy — the safe direction.
|
|
21
|
-
*/
|
|
22
|
-
base_url: string;
|
|
23
|
-
proxy_version: string;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* The local OpenAI-compatible proxy — `npx @urun-sh/openai proxy`.
|
|
28
|
-
*
|
|
29
|
-
* A loopback HTTP server speaking the OpenAI REST surface (`/v1/models`,
|
|
30
|
-
* `/v1/responses`, `/v1/chat/completions`, SSE streaming included), so any
|
|
31
|
-
* OpenAI-env-var tool — coding agents first — integrates with uRun with ZERO
|
|
32
|
-
* code changes: point `OPENAI_BASE_URL` at it and keep making plain, local,
|
|
33
|
-
* "inefficient" HTTP requests. The proxy backhauls each request over the uRun
|
|
34
|
-
* session transport (the `@urun-sh/openai` Responses client → session doc
|
|
35
|
-
* lanes + streams — no public OpenAI-style HTTP leaves the machine), which is
|
|
36
|
-
* also where the delta-sync chat-state doc lane (urun-python
|
|
37
|
-
* `urun/serve/chat_state.py`) plugs in as the transport evolves.
|
|
38
|
-
*
|
|
39
|
-
* Local-trust model: binds 127.0.0.1 by default; `apiKey` (when set) must
|
|
40
|
-
* match the agent's `Authorization: Bearer` — otherwise any local bearer is
|
|
41
|
-
* accepted (the key the agent sends is NEVER forwarded upstream; uRun auth is
|
|
42
|
-
* the session's own).
|
|
43
|
-
*/
|
|
44
|
-
|
|
45
|
-
/** The request envelope every Responses-shaped upstream call carries. */
|
|
46
|
-
interface ResponsesCreateParams {
|
|
47
|
-
model?: string;
|
|
48
|
-
input: unknown;
|
|
49
|
-
stream?: boolean;
|
|
50
|
-
tools?: unknown;
|
|
51
|
-
tool_choice?: unknown;
|
|
52
|
-
temperature?: number;
|
|
53
|
-
max_output_tokens?: number;
|
|
54
|
-
top_p?: number;
|
|
55
|
-
stop?: string[];
|
|
56
|
-
/**
|
|
57
|
-
* Reasoning controls (urun-python #1667): forwarded VERBATIM to the serve
|
|
58
|
-
* envelope — `chat_template_kwargs.enable_thinking:false` is the think-off
|
|
59
|
-
* switch. Absent -> absent (no default injection; server-side validation).
|
|
60
|
-
*/
|
|
61
|
-
reasoning_effort?: string;
|
|
62
|
-
chat_template_kwargs?: Record<string, unknown>;
|
|
63
|
-
}
|
|
64
|
-
/** How one pinned session ended (the native phase machinery's terminal step). */
|
|
65
|
-
interface SessionEndInfo {
|
|
66
|
-
/**
|
|
67
|
-
* Milliseconds until the session's native deadline (`endsAt`), or null when
|
|
68
|
-
* the app declared no maximum session length. NOTE (missing primitive,
|
|
69
|
-
* called out in the PR): core exposes no PRE-expiry notice event — this
|
|
70
|
-
* callback fires AT terminal loss, so timeLeftMs is ~0 on expiry.
|
|
71
|
-
*/
|
|
72
|
-
timeLeftMs: number | null;
|
|
73
|
-
/** The terminal reason (expired / ended / error), for the loud close. */
|
|
74
|
-
reason: string;
|
|
75
|
-
}
|
|
76
|
-
/** The upstream calls the proxy makes — injectable (tests; alt transports). */
|
|
77
|
-
interface ProxyClients {
|
|
78
|
-
/** `UrunResponses(session).responses.create` — an async iterable of Responses stream events. */
|
|
79
|
-
createResponse(params: ResponsesCreateParams): Promise<AsyncIterable<unknown>> | AsyncIterable<unknown>;
|
|
80
|
-
/** `listModels(...)` result (an OpenAI model list object). */
|
|
81
|
-
listModels(): Promise<unknown>;
|
|
82
|
-
/**
|
|
83
|
-
* The OpenRouter provider document (`GET /v1/models?format=openrouter`).
|
|
84
|
-
* Optional at the seam: hand-built test clients may omit it, in which case
|
|
85
|
-
* the format=openrouter branch answers 501 — loud, never a silent empty.
|
|
86
|
-
*/
|
|
87
|
-
openRouterModels?(): Promise<unknown>;
|
|
88
|
-
/**
|
|
89
|
-
* Open (or reuse) the NATIVE audio lanes on the pooled session `model` routes
|
|
90
|
-
* to — the same first-party machinery as RealtimeClient.enableAudio
|
|
91
|
-
* (transport/media.ts `enableSessionAudio`: AudioBridge over the session's
|
|
92
|
-
* `rt-audio-in`/`rt-audio-out` stream lanes at 24 kHz). One lane per pooled
|
|
93
|
-
* session; repeat calls return the same lane. Optional at the seam because
|
|
94
|
-
* text-only embeddings exist — but a surface that RECEIVES audio while the
|
|
95
|
-
* embedder wired no `openAudio` must fail LOUD, never drop chunks.
|
|
96
|
-
*/
|
|
97
|
-
openAudio?(model: string | undefined): Promise<ProxyAudioLane>;
|
|
98
|
-
/**
|
|
99
|
-
* Open (or reuse) the NATIVE video FRAME lane on the pooled session `model`
|
|
100
|
-
* routes to (transport/media.ts `enableSessionVideo`: discrete JPEG frames →
|
|
101
|
-
* `stream('rt-video-in').emit`, the §5 named-DATA image-bytes path — NOT the
|
|
102
|
-
* RTP media plane, which requires an already-H.264-encoded track). One lane
|
|
103
|
-
* per pooled session; repeat calls return the same lane. Optional at the seam
|
|
104
|
-
* because text-only embeddings exist — but a surface that RECEIVES video
|
|
105
|
-
* frames while the embedder wired no `openVideo` must fail LOUD, never drop
|
|
106
|
-
* frames.
|
|
107
|
-
*/
|
|
108
|
-
openVideo?(model: string | undefined): Promise<ProxyVideoLane>;
|
|
109
|
-
/**
|
|
110
|
-
* Open (or reuse) the NATIVE video OUTPUT lane on the pooled session
|
|
111
|
-
* `model` routes to (transport/video-out.ts `openSessionVideoOutLane`):
|
|
112
|
-
* decoded spec-v1 records consumed from the session's named §5
|
|
113
|
-
* `rt-video-out` downstream. The Live adapter fans each record onto the
|
|
114
|
-
* SAME Bidi WS as an extension server message (spec v2, WS-inline) — no
|
|
115
|
-
* side-channel transport. Optional at the seam; an ABSENT seam means the
|
|
116
|
-
* `urun.videoOut` capability is refused by omission in setupComplete
|
|
117
|
-
* (vanilla parity), while a wired seam that cannot open the lane must
|
|
118
|
-
* throw LOUD — never a quiet downgrade.
|
|
119
|
-
*/
|
|
120
|
-
openVideoOut?(model: string | undefined): Promise<ProxyVideoOutLane>;
|
|
121
|
-
/**
|
|
122
|
-
* SESSION-IDENTITY SEAM (ModelRouter.handleFor): the opaque stable handle
|
|
123
|
-
* for the pooled session currently serving `model`'s turns. Derived from
|
|
124
|
-
* native identity (app slug + uRun session id) — the same identity the
|
|
125
|
-
* serve-side session-affinity tag rides (urun-python#1556/#1582).
|
|
126
|
-
*/
|
|
127
|
-
sessionHandle(model: string | undefined): Promise<string>;
|
|
128
|
-
/**
|
|
129
|
-
* createResponse PINNED to the exact session a handle names
|
|
130
|
-
* (ModelRouter.sessionForHandle). Throws SessionGoneError LOUDLY when that
|
|
131
|
-
* session is gone or was replaced — never silently opens a fresh session
|
|
132
|
-
* while claiming resume. Deliberately NO re-home on this path: re-homing
|
|
133
|
-
* would swap the pinned session out from under the caller.
|
|
134
|
-
*/
|
|
135
|
-
createResponseOn(handle: string, params: ResponsesCreateParams): Promise<AsyncIterable<unknown>> | AsyncIterable<unknown>;
|
|
136
|
-
/**
|
|
137
|
-
* Subscribe to the pinned session's terminal end via core's NATIVE phase
|
|
138
|
-
* machinery (Session.onPhase → terminal 'expired'/'ended'/'error'). Fires
|
|
139
|
-
* `cb` once. Throws SessionGoneError if the handle's session is already
|
|
140
|
-
* gone — which doubles as the loud reattach check at resume time. Returns
|
|
141
|
-
* the unsubscribe.
|
|
142
|
-
*/
|
|
143
|
-
onSessionEnd(handle: string, cb: (end: SessionEndInfo) => void): Promise<() => void>;
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* The audio lane handle `openAudio` returns — structurally the transport
|
|
147
|
-
* AudioBridge (media.ts): base64 PCM16 @24 kHz mono in both directions.
|
|
148
|
-
*/
|
|
149
|
-
type ProxyAudioLane = Pick<AudioBridge, 'appendInputAudio' | 'onOutputAudio'>;
|
|
150
|
-
/**
|
|
151
|
-
* The video frame-lane handle `openVideo` returns — structurally the transport
|
|
152
|
-
* VideoFrameLane (media.ts): one raw encoded JPEG frame per call, input-only
|
|
153
|
-
* (Live-style protocols have no video OUT modality).
|
|
154
|
-
*/
|
|
155
|
-
type ProxyVideoLane = Pick<VideoFrameLane, 'sendInputFrame'>;
|
|
156
|
-
/**
|
|
157
|
-
* The video-OUT lane handle `openVideoOut` returns — structurally the
|
|
158
|
-
* transport VideoOutLane (video-out.ts): the codec plus frame/error fan-out
|
|
159
|
-
* the WS-inline delivery subscribes.
|
|
160
|
-
*/
|
|
161
|
-
type ProxyVideoOutLane = Pick<VideoOutLane, 'codec' | 'onOutputFrame' | 'onLaneError'>;
|
|
162
|
-
/**
|
|
163
|
-
* Per-request `ProxyClients` resolution — the seam the HOSTED multi-tenant
|
|
164
|
-
* server (`src/hosted/`) plugs into so ONE handler implementation serves
|
|
165
|
-
* every org: the hosted server resolves the caller's org from its Bearer API
|
|
166
|
-
* key and returns THAT org's backhaul. The local CLI passes a fixed
|
|
167
|
-
* `ProxyClients` instead; both go through the identical handler body below.
|
|
168
|
-
*
|
|
169
|
-
* Throwing from here is the loud path: the thrown error surfaces in the
|
|
170
|
-
* lane's native error envelope (see {@link ProxyHandlerOptions.statusOf}).
|
|
171
|
-
*/
|
|
172
|
-
type ProxyClientsFor = (req: IncomingMessage) => ProxyClients | Promise<ProxyClients>;
|
|
173
|
-
interface ProxyHandlerOptions {
|
|
174
|
-
/** A fixed backhaul (local CLI) or a per-request resolver (hosted server). */
|
|
175
|
-
clients: ProxyClients | ProxyClientsFor;
|
|
176
|
-
/** Optional bearer the local agent must present (never forwarded upstream). */
|
|
177
|
-
apiKey?: string;
|
|
178
|
-
/**
|
|
179
|
-
* WHAT this proxy serves (app/org/fn/base_url + proxy_version), surfaced as
|
|
180
|
-
* the `identity` block on `GET /stats` so a second `urun compat` invocation
|
|
181
|
-
* can reuse this proxy iff the identity matches its own exactly. Only the
|
|
182
|
-
* standalone `urun compat proxy` command sets it — a launch-mode proxy is
|
|
183
|
-
* child-owned (it dies with its child) and an embedder that omits it is
|
|
184
|
-
* simply never reused.
|
|
185
|
-
*/
|
|
186
|
-
identity?: ProxyIdentity;
|
|
187
|
-
/**
|
|
188
|
-
* Map a thrown error onto an HTTP status + error `type` before the generic
|
|
189
|
-
* 500. The hosted server uses it to turn its auth/tenancy failures into a
|
|
190
|
-
* 401 in the OpenAI envelope. Returning null means "not mine" — the error
|
|
191
|
-
* takes the ordinary loud 500 path.
|
|
192
|
-
*/
|
|
193
|
-
statusOf?: (err: unknown) => {
|
|
194
|
-
status: number;
|
|
195
|
-
openaiType: string;
|
|
196
|
-
anthropicType: string;
|
|
197
|
-
} | null;
|
|
198
|
-
}
|
|
199
|
-
/** The proxy server's own options: a FIXED backhaul (the local CLI lane). */
|
|
200
|
-
interface OpenAIProxyOptions extends ProxyHandlerOptions {
|
|
201
|
-
clients: ProxyClients;
|
|
202
|
-
}
|
|
203
|
-
/** Build (not listen) the proxy server — the caller owns listen/close. */
|
|
204
|
-
declare function createOpenAIProxy(options: OpenAIProxyOptions): Server;
|
|
205
|
-
|
|
206
|
-
export { type OpenAIProxyOptions as O, type ProxyClients as P, type ProxyIdentity as a, type ProxyVideoOutLane as b, createOpenAIProxy as c };
|
|
File without changes
|
|
File without changes
|
|
File without changes
|