@frequencytalk/agent 0.1.1 → 0.1.2

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/index.d.ts CHANGED
@@ -560,13 +560,23 @@ interface Heard {
560
560
  samples: Int16Array;
561
561
  firstTimestamp: number;
562
562
  }
563
+ interface ListenerOptions {
564
+ /**
565
+ * Record the session's own stream too. Off by default: the node sends a connection its own
566
+ * audio back whenever it listens on the channel its stream is homed on (self-monitoring, the
567
+ * audio-routing contract), which on a one-channel room such as a call is always. An agent
568
+ * transcribing a call wants the other side, not itself (0.1.2).
569
+ */
570
+ includeOwn?: boolean;
571
+ }
563
572
  declare class Listener {
564
573
  private readonly session;
574
+ private readonly options;
565
575
  private codec;
566
576
  private readonly streams;
567
577
  private detach;
568
- constructor(session: NativeSession);
569
- /** Start recording everything the session hears. */
578
+ constructor(session: NativeSession, options?: ListenerOptions);
579
+ /** Start recording everything the session hears (its own stream excepted, see `ListenerOptions`). */
570
580
  start(): Promise<void>;
571
581
  /** Stop and return what was heard, per stream. */
572
582
  stop(): Heard[];
@@ -654,9 +664,9 @@ declare class Agent {
654
664
  }): Promise<NativeSession>;
655
665
  closeSession(frequencyId: string): Promise<void>;
656
666
  speaker(session: NativeSession): Speaker;
657
- listener(session: NativeSession): Listener;
667
+ listener(session: NativeSession, options?: ListenerOptions): Listener;
658
668
  close(): Promise<void>;
659
669
  }
660
670
 
661
671
  export { Agent, Calls, Chat, Contacts, FRAME_SAMPLES, Frequencies, FrequencyClient, FrequencyError, Listener, NativeSession, PaymentRequired, Realtime, SAMPLE_RATE, Speaker, WS_CLOSE_SESSION_REVOKED, WS_CLOSE_UNAUTHORIZED, createOpus, downmix, frames, loadKey, readWav, resample, writeWav };
662
- export type { AgentKeySource, AgentOptions, ApiClient, ChannelSummary, ChatMessage, Contact, FrequencyClientOptions, FrequencySummary, Heard, IncomingRing, NativeAudioFrame, NativeReceiveStats, NativeResyncStats, NativeSessionOptions, NativeStreamAnnouncement, NativeTransportBlock, OpusCodec, PlacedCall, RealtimeEvent, RealtimeOptions, RequestOptions, RosterMember, TuneResult };
672
+ export type { AgentKeySource, AgentOptions, ApiClient, ChannelSummary, ChatMessage, Contact, FrequencyClientOptions, FrequencySummary, Heard, IncomingRing, ListenerOptions, NativeAudioFrame, NativeReceiveStats, NativeResyncStats, NativeSessionOptions, NativeStreamAnnouncement, NativeTransportBlock, OpusCodec, PlacedCall, RealtimeEvent, RealtimeOptions, RequestOptions, RosterMember, TuneResult };
package/dist/index.js CHANGED
@@ -5109,18 +5109,21 @@ var Speaker = class {
5109
5109
 
5110
5110
  // src/listener.ts
5111
5111
  var Listener = class {
5112
- constructor(session) {
5112
+ constructor(session, options = {}) {
5113
5113
  this.session = session;
5114
+ this.options = options;
5114
5115
  }
5115
5116
  session;
5117
+ options;
5116
5118
  codec = null;
5117
5119
  streams = /* @__PURE__ */ new Map();
5118
5120
  detach = null;
5119
- /** Start recording everything the session hears. */
5121
+ /** Start recording everything the session hears (its own stream excepted, see `ListenerOptions`). */
5120
5122
  async start() {
5121
5123
  this.codec ??= await createOpus();
5122
5124
  const codec = this.codec;
5123
5125
  const handler = (frame) => {
5126
+ if (!this.options.includeOwn && frame.connectionId === this.session.connectionId) return;
5124
5127
  let s = this.streams.get(frame.streamId);
5125
5128
  if (!s) {
5126
5129
  s = { connectionId: frame.connectionId, chunks: [], lastTimestamp: null, first: frame.timestamp };
@@ -5241,8 +5244,8 @@ var Agent = class _Agent {
5241
5244
  speaker(session) {
5242
5245
  return new Speaker(session);
5243
5246
  }
5244
- listener(session) {
5245
- return new Listener(session);
5247
+ listener(session, options) {
5248
+ return new Listener(session, options);
5246
5249
  }
5247
5250
  async close() {
5248
5251
  for (const id of [...this.sessions.keys()]) await this.closeSession(id);