@urun-sh/core 0.6.36 → 0.6.38
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/adapter/index.js +5 -5
- package/dist/adapter/index.mjs +1 -1
- package/dist/{app-U7LBEKWS.mjs → app-X5AIPZM6.mjs} +1 -1
- package/dist/{backoff-C60lcU4l.d.ts → backoff-ByTp2Mje.d.mts} +4 -0
- package/dist/{backoff-C60lcU4l.d.mts → backoff-ByTp2Mje.d.ts} +4 -0
- package/dist/{backoff-C36bg4oV.d.mts → backoff-CUDoxMRr.d.mts} +4 -0
- package/dist/{backoff-C36bg4oV.d.ts → backoff-CUDoxMRr.d.ts} +4 -0
- package/dist/{chunk-W52BJWP6.mjs → chunk-CI4SPS6T.mjs} +2 -2
- package/dist/{chunk-N7XWLJO5.mjs → chunk-MTZRCKDF.mjs} +4 -4
- package/dist/chunk-PIXUSDYT.mjs +30 -0
- package/dist/index.browser.d.mts +4 -2
- package/dist/index.browser.d.ts +4 -2
- package/dist/index.browser.js +4 -4
- package/dist/index.browser.mjs +2 -2
- package/dist/index.d.mts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +6 -6
- package/dist/index.mjs +1 -1
- package/dist/internal.browser.d.mts +2 -2
- package/dist/internal.browser.d.ts +2 -2
- package/dist/internal.browser.js +2 -2
- package/dist/internal.browser.mjs +1 -1
- package/dist/internal.d.mts +2 -2
- package/dist/internal.d.ts +2 -2
- package/dist/internal.js +5 -5
- package/dist/internal.mjs +1 -1
- package/package.json +1 -1
- package/dist/chunk-VHDCUDOI.mjs +0 -30
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$ as B,A as P,B as q,F as N,M as L,W as I,Z as _,_ as A,a as M,aa as H,b as T,ba as j,ga as Y,ha as F,ia as S,ja as v,ka as Q,la as w,ma as z,y as O,z as $}from"./chunk-
|
|
1
|
+
import{$ as B,A as P,B as q,F as N,M as L,W as I,Z as _,_ as A,a as M,aa as H,b as T,ba as j,ga as Y,ha as F,ia as S,ja as v,ka as Q,la as w,ma as z,y as O,z as $}from"./chunk-CI4SPS6T.mjs";var J="llm",K="llm-resp",k=class{items=[];waiters=[];closed=!1;push(e){this.items.push(e),e===null&&(this.closed=!0);for(let t of this.waiters.splice(0))t()}async*drain(){for(;;){for(;this.items.length>0;){let e=this.items.shift();if(e==null)return;yield e}if(this.closed)return;await new Promise(e=>this.waiters.push(e))}}};function E(a,e){if(a){let t=a.message;if(typeof t=="string"&&t.length>0)return t;let r=a.code??a.type??a.error;if(typeof r=="string"&&r.length>0)return`serve error: ${r}`;let o=JSON.stringify(a);if(o&&o!=="{}")return`serve error: ${o.slice(0,300)}`}return e??"serve error"}var C=class{constructor(e){this.opts=e;if(this.wsCtor=e.WebSocketPolyfill??globalThis.WebSocket,!this.wsCtor)throw new Error("[hub-serve] no WebSocket implementation (pass ws in Node)");this.consumerId=e.consumerId??`serve-client-${Math.random().toString(36).slice(2,10)}`,this.grantQuery=`token=${encodeURIComponent(e.attach.token)}&gen=${e.attach.gen}`;let t=v({serverUrl:S(this.sfuWsUrl()),sessionId:e.sessionId,attach:{url:e.sfuUrl,token:e.attach.token,gen:e.attach.gen},WebSocketPolyfill:this.wsCtor}),r=(o,n,m)=>(this.docConnection=t(o,n,m),this.docConnection);this.doc=new w(J,e.sessionId,r)}opts;doc;docConnection;wsCtor;grantQuery;consumerId;streamSockets=new Set;async ready(e=3e4){this.doc.synced||await new Promise((t,r)=>{let o=setTimeout(()=>r(new Error("[hub-serve] doc sync timeout")),e);this.doc.onSynced(()=>{clearTimeout(o),t()})})}request(e){let t=`req_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`,r=`${K}:${t}`,o=e.stream!==!1,n={request_id:t,consumer_id:this.consumerId,respond_on:r,stream:o};e.model&&(n.model=e.model),e.messages!==void 0?(n.kind="chat",n.messages=e.messages):(n.kind="responses",n.input=e.input),e.instructions!==void 0&&(n.instructions=e.instructions),e.temperature!==void 0&&(n.temperature=e.temperature),e.max_output_tokens!==void 0&&(n.max_output_tokens=e.max_output_tokens);let m=`${this.sfuWsUrl()}/stream/${encodeURIComponent(this.opts.sessionId)}/${encodeURIComponent(r)}?${this.grantQuery}`,c=new this.wsCtor(m);this.streamSockets.add(c),c.addEventListener?.("close",()=>this.streamSockets.delete(c));let p=new k,b,u,R=new Promise((g,i)=>{b=g,u=i});R.catch(()=>{});let U=new A,h,f,l,x=!1,W=()=>{try{this.doc.set({requests:{[t]:null}})}catch{}},y=()=>{x||(x=!0,p.push(null),W(),h!==void 0?b(h):u(f!==void 0?new Error(E(f,l)):l!==void 0?new Error(l):new Error("[hub-serve] the response lane ended without a terminal response")))};return this.doc.set({requests:{[t]:{payload:n,consumer_id:this.consumerId,stream:o}}}),c.onmessage=g=>{let i=g.data,D=i instanceof ArrayBuffer?new Uint8Array(i):i instanceof Uint8Array?i:new Uint8Array(i.buffer,i.byteOffset,i.byteLength),d;try{d=_(D)}catch{if(d=U.feed(D),d===void 0)return}if(d===I){y();return}let s=d;s&&typeof s=="object"&&typeof s.t=="string"&&(s.t==="delta"&&typeof s.delta=="string"?p.push(s.delta):s.t==="response"?h=s.body??{}:s.t==="error"&&(f=s,l=E(f,void 0)))},c.onerror=()=>{l??="response lane socket error",y()},c.onclose=()=>{l??="response lane closed before the terminal",y()},{requestId:t,lane:r,deltas:p.drain(),result:R,cancel:()=>{this.doc.set({requests:{[t]:null}})}}}async destroy(){for(let e of this.streamSockets)try{e.close()}catch{}this.streamSockets.clear();try{this.doc.disconnect()}catch{}this.docConnection?.destroy()}sfuWsUrl(){return this.opts.sfuUrl.replace(/^http/,"ws").replace(/\/+$/,"")}};export{M as ChannelMultiplexer,F as DOC_SYNC_WIRE_CONTRACT_VERSION,T as DeferredChannelMultiplexer,Q as DeferredDocConnector,C as HubServeClient,B as LoopbackStreamData,w as SessionDocumentImpl,Y as TransportSession,L as allocateSession,N as computeBackoffDelay,z as createPresence,v as createWebsocketDocConnector,S as deriveYjsServerUrl,q as ensureNodeWebRTC,O as isNodeRuntime,$ as nodeMediasoupHandlerName,P as nodeWebRTCUnavailableReason,j as streamDataLabel,H as transportStreamData};
|
package/dist/internal.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { aw as SfuAttachCredential } from './backoff-
|
|
2
|
-
export { A as AccessTokenOptions, e as AllocateSessionOptions, f as AllocatedSession, m as ChannelMessage, n as ChannelMultiplexer, o as ChannelName, r as DOC_SYNC_WIRE_CONTRACT_VERSION, s as DeferredChannelMultiplexer, t as DeferredDocConnector, w as DocConnection, x as DocConnectionState, y as DocConnector, z as DocServerUrlResolver, E as DocTokenSupplier, L as LoopbackStreamData, aj as SessionDocumentImpl, aq as SessionStartOptions, aD as StreamDataTransport, aJ as TransportSession, aK as TransportSessionOptions, a_ as allocateSession, a$ as computeBackoffDelay, b1 as createPresence, b2 as createWebsocketDocConnector, b4 as deriveYjsServerUrl, bg as streamDataLabel, bh as transportStreamData } from './backoff-
|
|
1
|
+
import { aw as SfuAttachCredential } from './backoff-CUDoxMRr.mjs';
|
|
2
|
+
export { A as AccessTokenOptions, e as AllocateSessionOptions, f as AllocatedSession, m as ChannelMessage, n as ChannelMultiplexer, o as ChannelName, r as DOC_SYNC_WIRE_CONTRACT_VERSION, s as DeferredChannelMultiplexer, t as DeferredDocConnector, w as DocConnection, x as DocConnectionState, y as DocConnector, z as DocServerUrlResolver, E as DocTokenSupplier, L as LoopbackStreamData, aj as SessionDocumentImpl, aq as SessionStartOptions, aD as StreamDataTransport, aJ as TransportSession, aK as TransportSessionOptions, a_ as allocateSession, a$ as computeBackoffDelay, b1 as createPresence, b2 as createWebsocketDocConnector, b4 as deriveYjsServerUrl, bg as streamDataLabel, bh as transportStreamData } from './backoff-CUDoxMRr.mjs';
|
|
3
3
|
import 'yjs';
|
|
4
4
|
import 'y-protocols/awareness';
|
|
5
5
|
|
package/dist/internal.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { aw as SfuAttachCredential } from './backoff-
|
|
2
|
-
export { A as AccessTokenOptions, e as AllocateSessionOptions, f as AllocatedSession, m as ChannelMessage, n as ChannelMultiplexer, o as ChannelName, r as DOC_SYNC_WIRE_CONTRACT_VERSION, s as DeferredChannelMultiplexer, t as DeferredDocConnector, w as DocConnection, x as DocConnectionState, y as DocConnector, z as DocServerUrlResolver, E as DocTokenSupplier, L as LoopbackStreamData, aj as SessionDocumentImpl, aq as SessionStartOptions, aD as StreamDataTransport, aJ as TransportSession, aK as TransportSessionOptions, a_ as allocateSession, a$ as computeBackoffDelay, b1 as createPresence, b2 as createWebsocketDocConnector, b4 as deriveYjsServerUrl, bg as streamDataLabel, bh as transportStreamData } from './backoff-
|
|
1
|
+
import { aw as SfuAttachCredential } from './backoff-CUDoxMRr.js';
|
|
2
|
+
export { A as AccessTokenOptions, e as AllocateSessionOptions, f as AllocatedSession, m as ChannelMessage, n as ChannelMultiplexer, o as ChannelName, r as DOC_SYNC_WIRE_CONTRACT_VERSION, s as DeferredChannelMultiplexer, t as DeferredDocConnector, w as DocConnection, x as DocConnectionState, y as DocConnector, z as DocServerUrlResolver, E as DocTokenSupplier, L as LoopbackStreamData, aj as SessionDocumentImpl, aq as SessionStartOptions, aD as StreamDataTransport, aJ as TransportSession, aK as TransportSessionOptions, a_ as allocateSession, a$ as computeBackoffDelay, b1 as createPresence, b2 as createWebsocketDocConnector, b4 as deriveYjsServerUrl, bg as streamDataLabel, bh as transportStreamData } from './backoff-CUDoxMRr.js';
|
|
3
3
|
import 'yjs';
|
|
4
4
|
import 'y-protocols/awareness';
|
|
5
5
|
|