@urun-sh/openai 0.5.5 → 0.6.0

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 (56) hide show
  1. package/dist/{ResponsesClient-BYx3YLGo.d.ts → ResponsesClient-CSSrOYD8.d.ts} +7 -1
  2. package/dist/{ResponsesClient-Dft3bg3b.d.cts → ResponsesClient-_OZERUjH.d.cts} +11 -1
  3. package/dist/chunk-3JWYIKHM.js +2 -0
  4. package/dist/chunk-45FJ5GTP.js +7 -0
  5. package/dist/chunk-6M5JK4YC.js +1 -0
  6. package/dist/chunk-QTVTCMJU.js +1 -0
  7. package/dist/chunk-TDRZZGUK.js +1 -0
  8. package/dist/chunk-TPH77ZOW.js +58 -0
  9. package/dist/chunk-WCMX5VOF.js +4 -0
  10. package/dist/chunk-YXK42SKC.js +1 -0
  11. package/dist/gemini-live.cjs +2 -2
  12. package/dist/gemini-live.d.cts +79 -7
  13. package/dist/gemini-live.d.ts +32 -7
  14. package/dist/gemini-live.js +1 -1
  15. package/dist/hosted/bin.cjs +43 -27
  16. package/dist/hosted/bin.js +4 -4
  17. package/dist/hosted/index.cjs +41 -26
  18. package/dist/hosted/index.d.cts +710 -17
  19. package/dist/hosted/index.d.ts +171 -6
  20. package/dist/hosted/index.js +1 -1
  21. package/dist/index.cjs +1 -1
  22. package/dist/index.d.cts +5 -5
  23. package/dist/index.d.ts +5 -5
  24. package/dist/index.js +1 -1
  25. package/dist/{models-NYMZrklp.d.cts → models-DUdx_Y6X.d.cts} +1 -1
  26. package/dist/pi-extension/index.cjs +7 -7
  27. package/dist/pi-extension/index.d.cts +2 -2
  28. package/dist/pi-extension/index.d.ts +2 -2
  29. package/dist/pi-extension/index.js +1 -1
  30. package/dist/pi-extension/standalone.cjs +53 -53
  31. package/dist/proxy/cli.cjs +55 -43
  32. package/dist/proxy/cli.js +14 -13
  33. package/dist/proxy/index.cjs +31 -28
  34. package/dist/proxy/index.d.cts +132 -18
  35. package/dist/proxy/index.d.ts +28 -11
  36. package/dist/proxy/index.js +1 -6
  37. package/dist/responses-turn-BfdBbey8.d.cts +2394 -0
  38. package/dist/responses-turn-CdhIre_a.d.ts +652 -0
  39. package/dist/{translator-CcDBEfvm.d.cts → translator-CO8W_hmJ.d.cts} +3 -3
  40. package/dist/{translator-C9uPKypK.d.ts → translator-Ddd65sXR.d.ts} +1 -1
  41. package/dist/{types-lsVTbNcH.d.cts → types-CHPtJx6d.d.cts} +13 -0
  42. package/dist/{types-lsVTbNcH.d.ts → types-CHPtJx6d.d.ts} +4 -0
  43. package/dist/{video-out-D20UuJ8G.d.cts → video-out-BsuLqlID.d.cts} +6 -6
  44. package/dist/{video-out-CWesbk12.d.ts → video-out-Cawtm7SF.d.ts} +1 -1
  45. package/package.json +14 -11
  46. package/dist/chunk-5BZCM3RS.js +0 -4
  47. package/dist/chunk-5NXM4IO3.js +0 -2
  48. package/dist/chunk-CWJRDBDC.js +0 -1
  49. package/dist/chunk-DMD5UENK.js +0 -1
  50. package/dist/chunk-GBBY3PCZ.js +0 -1
  51. package/dist/chunk-I2Q3B3OG.js +0 -6
  52. package/dist/chunk-OI2OY32M.js +0 -1
  53. package/dist/chunk-QVF7NF7G.js +0 -44
  54. package/dist/responses-turn-KOAoIqZ-.d.ts +0 -200
  55. package/dist/responses-turn-OrO4euEN.d.cts +0 -513
  56. /package/dist/{models-NYMZrklp.d.ts → models-DUdx_Y6X.d.ts} +0 -0
package/dist/proxy/cli.js CHANGED
@@ -1,15 +1,16 @@
1
1
  #!/usr/bin/env node
2
- import{a as k,b as $,c as h,d as C,e as U,f as N,g as L,h as O,i as I,j as G,k as E,l as _,m,o as W,p as A,q as j,r as B,s as D,t as K,u as v,v as M,w as F,x as J}from"../chunk-I2Q3B3OG.js";import"../chunk-K23AZPI4.js";import{g as T}from"../chunk-QVF7NF7G.js";import"../chunk-GBBY3PCZ.js";import"../chunk-DMD5UENK.js";import"../chunk-5NXM4IO3.js";import{g as R}from"../chunk-CWJRDBDC.js";import"../chunk-OI2OY32M.js";import{c as w}from"../chunk-YSFSRI3D.js";w();import{spawn as Q}from"child_process";import{appendFileSync as H,createWriteStream as ae,existsSync as ie,mkdirSync as se}from"fs";import le from"path";import t from"process";w();import{ensureNodeWebRTC as re,nodeWebRTCUnavailableReason as ne}from"@urun-sh/core/internal";var oe={ensureWebRTC:re,webrtcUnavailableReason:ne,audioBackend:R};async function Y(e=oe){try{await e.ensureWebRTC()}catch(n){return{ok:!1,reason:`the WebRTC bootstrap threw: ${String(n)}`}}let i=e.webrtcUnavailableReason();if(i)return{ok:!1,reason:`${i} \u2014 this artifact would join every session doc/KV-only and every token stream would error. Either "werift" is missing from the deployment directory (npm lane), or it was marked --external in a single-file build, where nothing can ever resolve it (bunfs: "Cannot find package 'werift' from '/$bunfs/root/\u2026'").`};try{(await e.audioBackend()).createSource()}catch(n){return{ok:!1,reason:`the werift/opus audio backend could not be constructed: ${String(n)}`}}return{ok:!0,reason:null}}function ue(e,i){let n=(e.URUN_CATALOG_URL??"").trim(),l=n?W(n,"URUN_CATALOG_URL"):"",o=(e.URUN_CATALOG_ANON_KEY??"").trim();return!l||!o?(i(`urun compat: catalog oracle off (URUN_CATALOG_URL/URUN_CATALOG_ANON_KEY unset) \u2014 an undeployed uRun CATALOG model name falls through to the default app instead of a loud 404; deployed apps still resolve exactly, and /stats.models records every mapping
3
- `),null):{catalogUrl:l,anonKey:o}}function ce(e){return k({baseUrl:e.baseUrl,orgId:e.orgId,defaultApp:e.appId,fnName:e.fnName,apiUrl:e.apiUrl,auth:e.auth,catalog:ue(t.env,i=>t.stderr.write(i))})}async function V(e,i,n){let l=Q(e,i,{stdio:"inherit",env:n});return new Promise(o=>{l.once("exit",a=>o(a??1)),l.once("error",a=>{t.stderr.write(`failed to launch ${e}: ${String(a)}
4
- `),o(127)})})}function q(){return I(t.env,import.meta.url,ie)}function X(e){for(let[i,n]of Object.entries(C(e)))t.stdout.write(`export ${i}=${n}
5
- `)}async function z(e,i){let n=m(t.env),l=i?A(n):void 0,o=ce(n),a=T({clients:$(o),identity:l});try{await new Promise((s,d)=>{a.once("error",d),a.listen(e,"127.0.0.1",s)})}catch(s){throw await o.closeAll().catch(()=>{}),s.code==="EADDRINUSE"?new Error(J(e,await j(e))):s}let u=a.address().port;return i&&(t.stdout.write(`urun openai proxy listening on http://127.0.0.1:${u}/v1
6
- `),X(u)),{port:u,close:async()=>{let s=new Promise(d=>a.close(()=>d()));a.closeAllConnections(),await s,await o.closeAll()}}}async function de(){let e=t.argv.slice(2),i=G(e),n=e.shift()??"proxy";if(n==="env")return X(_(i??E(e))),0;if(n==="selftest"){let{ok:o,reason:a}=await Y();return o?(t.stdout.write(`urun-openai selftest: OK \u2014 werift WebRTC peer globals installed and the werift/opus audio backend constructed from this artifact
7
- `),0):(t.stderr.write(`urun-openai selftest: FAIL \u2014 ${a}
8
- `),1)}if(n==="proxy"){let o=i??E(e),a=await z(o,!0);return await new Promise(u=>{t.once("SIGINT",u),t.once("SIGTERM",u)}),await a.close(),0}let l=n==="run"?e.shift():n;{if(!l)throw new Error(`launch needs an agent (${Object.keys(h).join("|")}) or \`-- <cmd>\``);if(l==="pi"){let r=m(t.env);return V("pi",["-e",q(),...L(r.appId,e)],t.env)}if(l==="omp"){let r=m(t.env);return V("omp",["-e",q(),...O(r.appId,e)],t.env)}let o,a,u="openai";if(l==="--"){if(o=e.shift()??"",a=e,!o)throw new Error("`-- <cmd>` needs a command to launch")}else{let r=h[l];if(!r)throw new Error(`unknown command/agent ${l}; commands: proxy | env; agents: ${Object.keys(h).join(" | ")} \u2014 or \`-- <cmd>\``);o=r.bin,a=[...r.args??[],...e],u=r.env}let s=await B(i,A(m(t.env))),d=null,f=s.port;s.mode==="reuse"?t.stdout.write(`reusing the running urun openai proxy on http://127.0.0.1:${f} (app ${s.identity.app}, fn ${s.identity.fn}, v${s.identity.proxy_version})
9
- `):s.reason&&t.stderr.write(`urun compat: ${s.reason}
10
- `);let c=null,b=null,g=null,p=null;s.mode!=="reuse"&&(d=await z(s.port,!1),f=d.port,p=D(f),se(le.dirname(p),{recursive:!0}),g=ae(p,{flags:"a"}),b=M({streams:t,note:r=>H(p,r)}).uninstall,g.on("error",r=>{c?.(),c=null,v(t.stderr,`urun compat: proxy log ${p} failed: ${String(r)} \u2014 proxy output continues on the terminal
11
- `)}),t.stdout.write(`urun openai proxy on http://127.0.0.1:${f}/v1 \u2014 proxy logs: ${p}
12
- `),c=K(g)),l==="codex"&&(a=N(f,m(t.env).appId,a));let x=Q(o,a,{stdio:"inherit",env:U(t.env,f,u)}),Z=p!==null?F({logPath:p,appendSync:H,restore:()=>{c?.(),c=null},writeStderr:r=>t.stderr.write(r),killChild:()=>x.kill("SIGTERM"),exit:r=>t.exit(r),proc:t}):null,P=await new Promise(r=>{x.once("exit",S=>r(S??1)),x.once("error",S=>{c?.(),c=null,v(t.stderr,`failed to launch ${o}: ${String(S)}
13
- `),r(127)})});Z?.();let y=null;try{d&&await d.close()}catch(r){y=r}finally{c?.(),c=null,b?.(),b=null,g?.end()}return y!==null&&v(t.stderr,`urun compat: proxy teardown failed after the harness exited (harness exit code ${P} preserved): ${String(y instanceof Error?y.message:y)}
14
- `),P}}de().then(e=>t.exit(e),e=>{t.stderr.write(`${String(e instanceof Error?e.message:e)}
2
+ import{a as q,b as Y}from"../chunk-TDRZZGUK.js";import"../chunk-K23AZPI4.js";import{A as M,Q as F,S as J,f as h,g as U,h as $,i as C,j as N,k as L,l as I,m as O,n as x,o as G,p as m,r as _,s as P,t as D,u as W,v as A,w as B,x as v,y as K,z as j}from"../chunk-TPH77ZOW.js";import"../chunk-YXK42SKC.js";import"../chunk-WCMX5VOF.js";import"../chunk-3JWYIKHM.js";import{g as T}from"../chunk-6M5JK4YC.js";import"../chunk-QTVTCMJU.js";import{c as w}from"../chunk-YSFSRI3D.js";w();import{spawn as X}from"child_process";import{appendFileSync as k,createWriteStream as ue,existsSync as ce,mkdirSync as Z}from"fs";import ee from"path";import t from"process";w();import{ensureNodeWebRTC as se,nodeWebRTCUnavailableReason as ae}from"@urun-sh/core/internal";var le={ensureWebRTC:se,webrtcUnavailableReason:ae,audioBackend:T};async function H(e=le){try{await e.ensureWebRTC()}catch(r){return{ok:!1,reason:`the WebRTC bootstrap threw: ${String(r)}`}}let o=e.webrtcUnavailableReason();if(o)return{ok:!1,reason:`${o} \u2014 this artifact would join every session doc/KV-only and every token stream would error. Either "werift" is missing from the deployment directory (npm lane), or it was marked --external in a single-file build, where nothing can ever resolve it (bunfs: "Cannot find package 'werift' from '/$bunfs/root/\u2026'").`};try{(await e.audioBackend()).createSource()}catch(r){return{ok:!1,reason:`the werift/opus audio backend could not be constructed: ${String(r)}`}}return{ok:!0,reason:null}}function de(e,o){let r=(e.URUN_CATALOG_URL??"").trim(),u=r?_(r,"URUN_CATALOG_URL"):"",i=(e.URUN_CATALOG_ANON_KEY??"").trim();return!u||!i?(o(`urun compat: catalog oracle off (URUN_CATALOG_URL/URUN_CATALOG_ANON_KEY unset) \u2014 an undeployed uRun CATALOG model name falls through to the default app instead of a loud 404; deployed apps still resolve exactly, and /stats.models records every mapping
3
+ `),null):{catalogUrl:u,anonKey:i}}function pe(e){return q({baseUrl:e.baseUrl,orgId:e.orgId,defaultApp:e.appId,fnName:e.fnName,apiUrl:e.apiUrl,auth:e.auth,catalog:de(t.env,o=>t.stderr.write(o)),statelessDirect:te(e)})}function te(e){return e.decisionSecret!==""&&e.auth.lane==="api-key"}function fe(e,o){if(te(e))return t.stderr.write(`urun compat: stateless direct path ENABLED (POST /v1/decision answered by the serving pods)
4
+ `),new F({targetFor:r=>o.targetFor(r),apiUrl:e.apiUrl,fnName:e.fnName,apiKey:e.auth.apiKey,orgId:e.orgId,secret:e.decisionSecret})}async function V(e,o,r){let u=X(e,o,{stdio:"inherit",env:r});return new Promise(i=>{u.once("exit",s=>i(s??1)),u.once("error",s=>{t.stderr.write(`failed to launch ${e}: ${String(s)}
5
+ `),i(127)})})}function z(){return I(t.env,import.meta.url,ce)}function re(e){for(let[o,r]of Object.entries(U(e)))t.stdout.write(`export ${o}=${r}
6
+ `)}async function Q(e,o){let r=m(t.env),u=o?P(r):void 0,i=pe(r),s=null,f=c=>{if(s===null){let l=a.address();if(l===null)throw new Error("urun compat: a /v1 request was recorded before the proxy socket was listening");s=A(l.port),Z(ee.dirname(s),{recursive:!0})}k(s,c)},a=J({clients:Y(i,void 0,void 0,fe(r,i)),identity:u,...o?{requestLog:f}:{}});try{await new Promise((c,l)=>{a.once("error",l),a.listen(e,"127.0.0.1",c)})}catch(c){throw await i.closeAll().catch(()=>{}),c.code==="EADDRINUSE"?new Error(M(e,await D(e))):c}let d=a.address().port;return o&&(t.stdout.write(`urun openai proxy listening on http://127.0.0.1:${d}/v1
7
+ `),re(d)),{port:d,close:async()=>{let c=new Promise(l=>a.close(()=>l()));a.closeAllConnections(),await c,await i.closeAll()}}}async function me(){let e=t.argv.slice(2),o=O(e),r=e.shift()??"proxy";if(r==="env")return re(G(o??x(e))),0;if(r==="selftest"){let{ok:i,reason:s}=await H();return i?(t.stdout.write(`urun-openai selftest: OK \u2014 werift WebRTC peer globals installed and the werift/opus audio backend constructed from this artifact
8
+ `),0):(t.stderr.write(`urun-openai selftest: FAIL \u2014 ${s}
9
+ `),1)}if(r==="proxy"){let i=o??x(e),s=await Q(i,!0);return await new Promise(f=>{t.once("SIGINT",f),t.once("SIGTERM",f)}),await s.close(),0}let u=r==="run"?e.shift():r;{if(!u)throw new Error(`launch needs an agent (${Object.keys(h).join("|")}) or \`-- <cmd>\``);if(u==="pi"){let n=m(t.env);return V("pi",["-e",z(),...N(n.appId,e)],t.env)}if(u==="omp"){let n=m(t.env);return V("omp",["-e",z(),...L(n.appId,e)],t.env)}let i,s,f="openai";if(u==="--"){if(i=e.shift()??"",s=e,!i)throw new Error("`-- <cmd>` needs a command to launch")}else{let n=h[u];if(!n)throw new Error(`unknown command/agent ${u}; commands: proxy | env; agents: ${Object.keys(h).join(" | ")} \u2014 or \`-- <cmd>\``);i=n.bin,s=[...n.args??[],...e],f=n.env}let a=await W(o,P(m(t.env))),d=null,c=a.port;a.mode==="reuse"?t.stdout.write(`reusing the running urun openai proxy on http://127.0.0.1:${c} (app ${a.identity.app}, fn ${a.identity.fn}, v${a.identity.proxy_version})
10
+ `):a.reason&&t.stderr.write(`urun compat: ${a.reason}
11
+ `);let l=null,b=null,y=null,p=null;a.mode!=="reuse"&&(d=await Q(a.port,!1),c=d.port,p=A(c),Z(ee.dirname(p),{recursive:!0}),y=ue(p,{flags:"a"}),b=K({streams:t,note:n=>k(p,n)}).uninstall,y.on("error",n=>{l?.(),l=null,v(t.stderr,`urun compat: proxy log ${p} failed: ${String(n)} \u2014 proxy output continues on the terminal
12
+ `)}),t.stdout.write(`urun openai proxy on http://127.0.0.1:${c}/v1 \u2014 proxy logs: ${p}
13
+ `),l=B(y)),u==="codex"&&(s=C(c,m(t.env).appId,s));let S=X(i,s,{stdio:"inherit",env:$(t.env,c,f)}),ne=p!==null?j({logPath:p,appendSync:k,restore:()=>{l?.(),l=null},writeStderr:n=>t.stderr.write(n),killChild:()=>S.kill("SIGTERM"),exit:n=>t.exit(n),proc:t}):null,R=await new Promise(n=>{S.once("exit",E=>n(E??1)),S.once("error",E=>{l?.(),l=null,v(t.stderr,`failed to launch ${i}: ${String(E)}
14
+ `),n(127)})});ne?.();let g=null;try{d&&await d.close()}catch(n){g=n}finally{l?.(),l=null,b?.(),b=null,y?.end()}return g!==null&&v(t.stderr,`urun compat: proxy teardown failed after the harness exited (harness exit code ${R} preserved): ${String(g instanceof Error?g.message:g)}
15
+ `),R}}me().then(e=>t.exit(e),e=>{t.stderr.write(`${String(e instanceof Error?e.message:e)}
15
16
  `),t.exit(1)});