getpatter 0.6.6 → 0.6.7

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/cli.js CHANGED
@@ -1279,6 +1279,7 @@ var BUFFER_MAX = 256;
1279
1279
  var noticeShown = false;
1280
1280
  var liveClients = /* @__PURE__ */ new Set();
1281
1281
  var exitHookRegistered = false;
1282
+ var pendingFlush = /* @__PURE__ */ new Set();
1282
1283
  function showNoticeOnce() {
1283
1284
  if (noticeShown) return;
1284
1285
  noticeShown = true;
@@ -1303,7 +1304,7 @@ var TelemetryClient = class {
1303
1304
  endpoint;
1304
1305
  debug;
1305
1306
  buffer = [];
1306
- flushing = false;
1307
+ inflight = null;
1307
1308
  closed = false;
1308
1309
  selfRef = new WeakRef(this);
1309
1310
  constructor(options) {
@@ -1341,6 +1342,7 @@ var TelemetryClient = class {
1341
1342
  try {
1342
1343
  if (this.buffer.length >= BUFFER_MAX) this.buffer.shift();
1343
1344
  this.buffer.push(event);
1345
+ pendingFlush.add(this);
1344
1346
  this.scheduleFlush();
1345
1347
  } catch (err) {
1346
1348
  getLogger().debug("telemetry enqueue failed", err);
@@ -1364,23 +1366,30 @@ var TelemetryClient = class {
1364
1366
  if (this.closed) return;
1365
1367
  this.closed = true;
1366
1368
  liveClients.delete(this.selfRef);
1367
- if (!this.enabledFlag || this.debug) return;
1369
+ if (!this.enabledFlag || this.debug) {
1370
+ pendingFlush.delete(this);
1371
+ return;
1372
+ }
1368
1373
  try {
1374
+ if (this.inflight) await this.inflight;
1369
1375
  await this.flush();
1370
1376
  } catch (err) {
1371
1377
  getLogger().debug("telemetry close flush failed", err);
1372
1378
  }
1379
+ pendingFlush.delete(this);
1373
1380
  }
1374
1381
  scheduleFlush() {
1375
- if (this.flushing) return;
1376
- this.flushing = true;
1377
- void this.flush().finally(() => {
1378
- this.flushing = false;
1382
+ if (this.inflight) return;
1383
+ this.inflight = this.flush().finally(() => {
1384
+ this.inflight = null;
1385
+ if (this.buffer.length > 0) this.scheduleFlush();
1379
1386
  });
1387
+ void this.inflight;
1380
1388
  }
1381
1389
  async flush() {
1382
1390
  if (this.buffer.length === 0) return;
1383
1391
  const events = this.buffer.splice(0, this.buffer.length);
1392
+ pendingFlush.delete(this);
1384
1393
  const controller = new AbortController();
1385
1394
  const timer = setTimeout(() => controller.abort(), TIMEOUT_MS);
1386
1395
  timer.unref?.();
package/dist/index.js CHANGED
@@ -35616,6 +35616,7 @@ var BUFFER_MAX = 256;
35616
35616
  var noticeShown = false;
35617
35617
  var liveClients = /* @__PURE__ */ new Set();
35618
35618
  var exitHookRegistered = false;
35619
+ var pendingFlush = /* @__PURE__ */ new Set();
35619
35620
  function showNoticeOnce() {
35620
35621
  if (noticeShown) return;
35621
35622
  noticeShown = true;
@@ -35640,7 +35641,7 @@ var TelemetryClient = class {
35640
35641
  endpoint;
35641
35642
  debug;
35642
35643
  buffer = [];
35643
- flushing = false;
35644
+ inflight = null;
35644
35645
  closed = false;
35645
35646
  selfRef = new WeakRef(this);
35646
35647
  constructor(options) {
@@ -35678,6 +35679,7 @@ var TelemetryClient = class {
35678
35679
  try {
35679
35680
  if (this.buffer.length >= BUFFER_MAX) this.buffer.shift();
35680
35681
  this.buffer.push(event);
35682
+ pendingFlush.add(this);
35681
35683
  this.scheduleFlush();
35682
35684
  } catch (err) {
35683
35685
  getLogger().debug("telemetry enqueue failed", err);
@@ -35701,23 +35703,30 @@ var TelemetryClient = class {
35701
35703
  if (this.closed) return;
35702
35704
  this.closed = true;
35703
35705
  liveClients.delete(this.selfRef);
35704
- if (!this.enabledFlag || this.debug) return;
35706
+ if (!this.enabledFlag || this.debug) {
35707
+ pendingFlush.delete(this);
35708
+ return;
35709
+ }
35705
35710
  try {
35711
+ if (this.inflight) await this.inflight;
35706
35712
  await this.flush();
35707
35713
  } catch (err) {
35708
35714
  getLogger().debug("telemetry close flush failed", err);
35709
35715
  }
35716
+ pendingFlush.delete(this);
35710
35717
  }
35711
35718
  scheduleFlush() {
35712
- if (this.flushing) return;
35713
- this.flushing = true;
35714
- void this.flush().finally(() => {
35715
- this.flushing = false;
35719
+ if (this.inflight) return;
35720
+ this.inflight = this.flush().finally(() => {
35721
+ this.inflight = null;
35722
+ if (this.buffer.length > 0) this.scheduleFlush();
35716
35723
  });
35724
+ void this.inflight;
35717
35725
  }
35718
35726
  async flush() {
35719
35727
  if (this.buffer.length === 0) return;
35720
35728
  const events = this.buffer.splice(0, this.buffer.length);
35729
+ pendingFlush.delete(this);
35721
35730
  const controller = new AbortController();
35722
35731
  const timer = setTimeout(() => controller.abort(), TIMEOUT_MS);
35723
35732
  timer.unref?.();
@@ -36436,7 +36445,17 @@ var Patter = class {
36436
36445
  /** Resolve user-supplied agent options against engine defaults and return the merged config. */
36437
36446
  agent(opts) {
36438
36447
  const family = telemetryEngineFamily(opts);
36439
- const stack = stackDimensions(opts.stt, opts.tts, opts.llm);
36448
+ let stack = { ...stackDimensions(opts.stt, opts.tts, opts.llm) };
36449
+ if (family === "realtime") {
36450
+ const engineModel = opts.engine?.model;
36451
+ stack = {
36452
+ ...stack,
36453
+ llm_model: modelToken(
36454
+ "openai",
36455
+ opts.model ?? engineModel ?? "gpt-realtime-mini"
36456
+ )
36457
+ };
36458
+ }
36440
36459
  const featureKey = family + "|" + Object.entries(stack).sort().map(([k, v]) => `${k}=${v}`).join(",");
36441
36460
  if (!this.telemetrySeenEngines.has(featureKey)) {
36442
36461
  this.telemetrySeenEngines.add(featureKey);
package/dist/index.mjs CHANGED
@@ -765,6 +765,7 @@ var BUFFER_MAX = 256;
765
765
  var noticeShown = false;
766
766
  var liveClients = /* @__PURE__ */ new Set();
767
767
  var exitHookRegistered = false;
768
+ var pendingFlush = /* @__PURE__ */ new Set();
768
769
  function showNoticeOnce() {
769
770
  if (noticeShown) return;
770
771
  noticeShown = true;
@@ -789,7 +790,7 @@ var TelemetryClient = class {
789
790
  endpoint;
790
791
  debug;
791
792
  buffer = [];
792
- flushing = false;
793
+ inflight = null;
793
794
  closed = false;
794
795
  selfRef = new WeakRef(this);
795
796
  constructor(options) {
@@ -827,6 +828,7 @@ var TelemetryClient = class {
827
828
  try {
828
829
  if (this.buffer.length >= BUFFER_MAX) this.buffer.shift();
829
830
  this.buffer.push(event);
831
+ pendingFlush.add(this);
830
832
  this.scheduleFlush();
831
833
  } catch (err) {
832
834
  getLogger().debug("telemetry enqueue failed", err);
@@ -850,23 +852,30 @@ var TelemetryClient = class {
850
852
  if (this.closed) return;
851
853
  this.closed = true;
852
854
  liveClients.delete(this.selfRef);
853
- if (!this.enabledFlag || this.debug) return;
855
+ if (!this.enabledFlag || this.debug) {
856
+ pendingFlush.delete(this);
857
+ return;
858
+ }
854
859
  try {
860
+ if (this.inflight) await this.inflight;
855
861
  await this.flush();
856
862
  } catch (err) {
857
863
  getLogger().debug("telemetry close flush failed", err);
858
864
  }
865
+ pendingFlush.delete(this);
859
866
  }
860
867
  scheduleFlush() {
861
- if (this.flushing) return;
862
- this.flushing = true;
863
- void this.flush().finally(() => {
864
- this.flushing = false;
868
+ if (this.inflight) return;
869
+ this.inflight = this.flush().finally(() => {
870
+ this.inflight = null;
871
+ if (this.buffer.length > 0) this.scheduleFlush();
865
872
  });
873
+ void this.inflight;
866
874
  }
867
875
  async flush() {
868
876
  if (this.buffer.length === 0) return;
869
877
  const events = this.buffer.splice(0, this.buffer.length);
878
+ pendingFlush.delete(this);
870
879
  const controller = new AbortController();
871
880
  const timer = setTimeout(() => controller.abort(), TIMEOUT_MS);
872
881
  timer.unref?.();
@@ -1581,7 +1590,17 @@ var Patter = class {
1581
1590
  /** Resolve user-supplied agent options against engine defaults and return the merged config. */
1582
1591
  agent(opts) {
1583
1592
  const family = telemetryEngineFamily(opts);
1584
- const stack = stackDimensions(opts.stt, opts.tts, opts.llm);
1593
+ let stack = { ...stackDimensions(opts.stt, opts.tts, opts.llm) };
1594
+ if (family === "realtime") {
1595
+ const engineModel = opts.engine?.model;
1596
+ stack = {
1597
+ ...stack,
1598
+ llm_model: modelToken(
1599
+ "openai",
1600
+ opts.model ?? engineModel ?? "gpt-realtime-mini"
1601
+ )
1602
+ };
1603
+ }
1585
1604
  const featureKey = family + "|" + Object.entries(stack).sort().map(([k, v]) => `${k}=${v}`).join(",");
1586
1605
  if (!this.telemetrySeenEngines.has(featureKey)) {
1587
1606
  this.telemetrySeenEngines.add(featureKey);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "getpatter",
3
- "version": "0.6.6",
3
+ "version": "0.6.7",
4
4
  "description": "Open-source voice AI SDK — connect any AI agent to real phone calls in 4 lines of code",
5
5
  "license": "MIT",
6
6
  "author": {