codex-grok-bridge 1.8.4 → 1.8.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/src/voice.mjs CHANGED
@@ -260,6 +260,10 @@ export function rememberLocalCall(id = randomUUID()) {
260
260
  return id;
261
261
  }
262
262
 
263
+ export function forgetLocalCall(id) {
264
+ localCalls.delete(id);
265
+ }
266
+
263
267
  function callIdIn(url) {
264
268
  const text = String(url ?? "");
265
269
  for (const id of localCalls) {
@@ -276,7 +280,14 @@ export function encodeServerFrame(opcode, payload) {
276
280
  const data = Buffer.isBuffer(payload) ? payload : Buffer.from(String(payload));
277
281
  let header;
278
282
  if (data.length < 126) header = Buffer.from([0x80 | opcode, data.length]);
279
- else header = Buffer.from([0x80 | opcode, 126, data.length >> 8, data.length & 0xff]);
283
+ else if (data.length < 65536)
284
+ header = Buffer.from([0x80 | opcode, 126, data.length >> 8, data.length & 0xff]);
285
+ else {
286
+ header = Buffer.alloc(10);
287
+ header[0] = 0x80 | opcode;
288
+ header[1] = 127;
289
+ header.writeBigUInt64BE(BigInt(data.length), 2);
290
+ }
280
291
  return Buffer.concat([header, data]);
281
292
  }
282
293
 
@@ -1269,7 +1280,10 @@ export async function answerVoiceCall({
1269
1280
  if (speechTimer) clearTimeout(speechTimer);
1270
1281
  voiceState.closing = true;
1271
1282
  active.delete(session);
1272
- if (session.id) sessionsById.delete(session.id);
1283
+ if (session.id) {
1284
+ sessionsById.delete(session.id);
1285
+ forgetLocalCall(session.id);
1286
+ }
1273
1287
  try {
1274
1288
  bridge?.close();
1275
1289
  socket?.close();