@micdrop/client 2.0.5 → 2.0.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/dist/index.d.mts CHANGED
@@ -1,6 +1,4 @@
1
1
  import { EventEmitter } from 'eventemitter3';
2
- import { MicdropConversation as MicdropConversation$1, MicdropToolCall as MicdropToolCall$1, VAD as VAD$1 } from '@micdrop/client';
3
- import { Readable } from 'stream';
4
2
 
5
3
  interface AudioAnalyserEvents {
6
4
  volume: [number];
@@ -214,6 +212,54 @@ declare class VolumeVAD extends VAD {
214
212
  declare const Mic: Mic$1;
215
213
  declare const Speaker: Speaker$1;
216
214
 
215
+ declare enum MicdropClientCommands {
216
+ StartSpeaking = "StartSpeaking",
217
+ StopSpeaking = "StopSpeaking",
218
+ Mute = "Mute"
219
+ }
220
+ declare enum MicdropServerCommands {
221
+ Message = "Message",
222
+ CancelLastAssistantMessage = "CancelLastAssistantMessage",
223
+ CancelLastUserMessage = "CancelLastUserMessage",
224
+ SkipAnswer = "SkipAnswer",
225
+ EndCall = "EndCall",
226
+ ToolCall = "ToolCall"
227
+ }
228
+ interface MicdropCallSummary {
229
+ conversation: MicdropConversation;
230
+ duration: number;
231
+ }
232
+ type MicdropConversationItem = MicdropConversationMessage | MicdropConversationToolCall | MicdropConversationToolResult;
233
+ type MicdropConversation = Array<MicdropConversationItem>;
234
+ type MicdropAnswerMetadata = {
235
+ [key: string]: any;
236
+ };
237
+ interface MicdropConversationMessage<Data extends MicdropAnswerMetadata = MicdropAnswerMetadata> {
238
+ role: 'system' | 'user' | 'assistant';
239
+ content: string;
240
+ metadata?: Data;
241
+ }
242
+ interface MicdropConversationToolCall {
243
+ role: 'tool_call';
244
+ toolCallId: string;
245
+ toolName: string;
246
+ parameters: string;
247
+ }
248
+ interface MicdropConversationToolResult {
249
+ role: 'tool_result';
250
+ toolCallId: string;
251
+ toolName: string;
252
+ output: string;
253
+ }
254
+ interface MicdropToolCall {
255
+ name: string;
256
+ parameters: any;
257
+ output: any;
258
+ }
259
+ type DeepPartial<T> = T extends object ? {
260
+ [P in keyof T]?: DeepPartial<T[P]>;
261
+ } : T;
262
+
217
263
  declare enum MicdropClientErrorCode {
218
264
  MissingUrl = "MissingUrl",
219
265
  Mic = "Mic",
@@ -235,7 +281,7 @@ interface MicdropEvents {
235
281
  EndCall: [];
236
282
  Error: [MicdropClientError];
237
283
  StateChange: [MicdropState];
238
- ToolCall: [MicdropToolCall$1];
284
+ ToolCall: [MicdropToolCall];
239
285
  }
240
286
  interface MicdropOptions {
241
287
  url?: string;
@@ -258,13 +304,13 @@ interface MicdropState {
258
304
  speakerDeviceId: string | undefined;
259
305
  micDevices: MediaDeviceInfo[];
260
306
  speakerDevices: MediaDeviceInfo[];
261
- conversation: MicdropConversation$1;
307
+ conversation: MicdropConversation;
262
308
  error: MicdropClientError | undefined;
263
309
  }
264
310
  declare class MicdropClient extends EventEmitter<MicdropEvents> implements MicdropState {
265
311
  options: MicdropOptions;
266
312
  micRecorder?: MicRecorder;
267
- conversation: MicdropConversation$1;
313
+ conversation: MicdropConversation;
268
314
  error: MicdropClientError | undefined;
269
315
  speakerDevices: MediaDeviceInfo[];
270
316
  micDevices: MediaDeviceInfo[];
@@ -274,7 +320,7 @@ declare class MicdropClient extends EventEmitter<MicdropEvents> implements Micdr
274
320
  private _isProcessing;
275
321
  private _isPaused;
276
322
  constructor(options?: MicdropOptions);
277
- get vad(): VAD$1 | undefined;
323
+ get vad(): VAD | undefined;
278
324
  get isStarted(): boolean;
279
325
  get isStarting(): boolean;
280
326
  get isPaused(): boolean;
@@ -318,111 +364,4 @@ declare class MicdropClient extends EventEmitter<MicdropEvents> implements Micdr
318
364
 
319
365
  declare const Micdrop: MicdropClient;
320
366
 
321
- declare class Logger {
322
- private readonly name;
323
- constructor(name: string);
324
- log(...message: any[]): void;
325
- }
326
-
327
- interface AgentOptions {
328
- systemPrompt: string;
329
- }
330
- interface AgentEvents {
331
- Message: [MicdropConversationMessage];
332
- CancelLastUserMessage: [];
333
- CancelLastAssistantMessage: [];
334
- SkipAnswer: [];
335
- EndCall: [];
336
- ToolCall: [MicdropToolCall];
337
- }
338
- declare abstract class Agent<Options extends AgentOptions = AgentOptions> extends EventEmitter<AgentEvents> {
339
- protected options: Options;
340
- logger?: Logger;
341
- conversation: MicdropConversation;
342
- constructor(options: Options);
343
- abstract answer(): Readable;
344
- abstract cancel(): void;
345
- addUserMessage(text: string, metadata?: MicdropAnswerMetadata): void;
346
- addAssistantMessage(text: string, metadata?: MicdropAnswerMetadata): void;
347
- protected addMessage(role: 'user' | 'assistant' | 'system', text: string, metadata?: MicdropAnswerMetadata): void;
348
- protected endCall(): void;
349
- protected cancelLastUserMessage(): void;
350
- protected cancelLastAssistantMessage(): void;
351
- protected skipAnswer(): void;
352
- protected log(...message: any[]): void;
353
- destroy(): void;
354
- }
355
-
356
- declare const MIME_TYPE_TO_EXTENSION: {
357
- readonly 'audio/wav': "wav";
358
- readonly 'audio/ogg': "ogg";
359
- readonly 'audio/mpeg': "mp3";
360
- readonly 'audio/webm': "webm";
361
- readonly 'audio/mp4': "mp4";
362
- readonly 'audio/flac': "flac";
363
- };
364
- interface STTEvents {
365
- Transcript: [string];
366
- }
367
- declare abstract class STT extends EventEmitter<STTEvents> {
368
- protected mimeType?: keyof typeof MIME_TYPE_TO_EXTENSION;
369
- logger?: Logger;
370
- transcribe(audioStream: Readable): void;
371
- protected log(...message: any[]): void;
372
- destroy(): void;
373
- protected get extension(): string;
374
- private detectMimeType;
375
- }
376
-
377
- declare abstract class TTS {
378
- logger?: Logger;
379
- abstract speak(textStream: Readable): Readable;
380
- abstract cancel(): void;
381
- protected log(...message: any[]): void;
382
- destroy(): void;
383
- }
384
-
385
- declare enum MicdropClientCommands {
386
- StartSpeaking = "StartSpeaking",
387
- StopSpeaking = "StopSpeaking",
388
- Mute = "Mute"
389
- }
390
- declare enum MicdropServerCommands {
391
- Message = "Message",
392
- CancelLastAssistantMessage = "CancelLastAssistantMessage",
393
- CancelLastUserMessage = "CancelLastUserMessage",
394
- SkipAnswer = "SkipAnswer",
395
- EndCall = "EndCall",
396
- ToolCall = "ToolCall"
397
- }
398
- interface MicdropConfig {
399
- firstMessage?: string;
400
- generateFirstMessage?: boolean;
401
- agent: Agent;
402
- stt: STT;
403
- tts: TTS;
404
- onEnd?(call: MicdropCallSummary): void;
405
- }
406
- interface MicdropCallSummary {
407
- conversation: MicdropConversation;
408
- duration: number;
409
- }
410
- type MicdropConversation = MicdropConversationMessage[];
411
- type MicdropAnswerMetadata = {
412
- [key: string]: any;
413
- };
414
- interface MicdropConversationMessage<Data extends MicdropAnswerMetadata = MicdropAnswerMetadata> {
415
- role: 'system' | 'user' | 'assistant';
416
- content: string;
417
- metadata?: Data;
418
- }
419
- interface MicdropToolCall {
420
- name: string;
421
- parameters: any;
422
- output: any;
423
- }
424
- type DeepPartial<T> = T extends object ? {
425
- [P in keyof T]?: DeepPartial<T[P]>;
426
- } : T;
427
-
428
- export { type DeepPartial, LocalStorageKeys, Mic, MicRecorder, type MicRecorderEvents, type MicRecorderState, Micdrop, type MicdropAnswerMetadata, type MicdropCallSummary, MicdropClient, MicdropClientCommands, MicdropClientError, MicdropClientErrorCode, type MicdropConfig, type MicdropConversation, type MicdropConversationMessage, type MicdropEvents, type MicdropOptions, MicdropServerCommands, type MicdropState, type MicdropToolCall, MultipleVAD, SileroVAD, type SileroVADOptions, Speaker, VAD, type VADConfig, type VADConfigName, type VADEvents, VADStatus, VolumeVAD, type VolumeVADOptions, getClientErrorFromWSCloseEvent, getClientErrorFromWSCloseEventCode, getVAD };
367
+ export { type DeepPartial, LocalStorageKeys, Mic, MicRecorder, type MicRecorderEvents, type MicRecorderState, Micdrop, type MicdropAnswerMetadata, type MicdropCallSummary, MicdropClient, MicdropClientCommands, MicdropClientError, MicdropClientErrorCode, type MicdropConversation, type MicdropConversationItem, type MicdropConversationMessage, type MicdropConversationToolCall, type MicdropConversationToolResult, type MicdropEvents, type MicdropOptions, MicdropServerCommands, type MicdropState, type MicdropToolCall, MultipleVAD, SileroVAD, type SileroVADOptions, Speaker, VAD, type VADConfig, type VADConfigName, type VADEvents, VADStatus, VolumeVAD, type VolumeVADOptions, getClientErrorFromWSCloseEvent, getClientErrorFromWSCloseEventCode, getVAD };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,4 @@
1
1
  import { EventEmitter } from 'eventemitter3';
2
- import { MicdropConversation as MicdropConversation$1, MicdropToolCall as MicdropToolCall$1, VAD as VAD$1 } from '@micdrop/client';
3
- import { Readable } from 'stream';
4
2
 
5
3
  interface AudioAnalyserEvents {
6
4
  volume: [number];
@@ -214,6 +212,54 @@ declare class VolumeVAD extends VAD {
214
212
  declare const Mic: Mic$1;
215
213
  declare const Speaker: Speaker$1;
216
214
 
215
+ declare enum MicdropClientCommands {
216
+ StartSpeaking = "StartSpeaking",
217
+ StopSpeaking = "StopSpeaking",
218
+ Mute = "Mute"
219
+ }
220
+ declare enum MicdropServerCommands {
221
+ Message = "Message",
222
+ CancelLastAssistantMessage = "CancelLastAssistantMessage",
223
+ CancelLastUserMessage = "CancelLastUserMessage",
224
+ SkipAnswer = "SkipAnswer",
225
+ EndCall = "EndCall",
226
+ ToolCall = "ToolCall"
227
+ }
228
+ interface MicdropCallSummary {
229
+ conversation: MicdropConversation;
230
+ duration: number;
231
+ }
232
+ type MicdropConversationItem = MicdropConversationMessage | MicdropConversationToolCall | MicdropConversationToolResult;
233
+ type MicdropConversation = Array<MicdropConversationItem>;
234
+ type MicdropAnswerMetadata = {
235
+ [key: string]: any;
236
+ };
237
+ interface MicdropConversationMessage<Data extends MicdropAnswerMetadata = MicdropAnswerMetadata> {
238
+ role: 'system' | 'user' | 'assistant';
239
+ content: string;
240
+ metadata?: Data;
241
+ }
242
+ interface MicdropConversationToolCall {
243
+ role: 'tool_call';
244
+ toolCallId: string;
245
+ toolName: string;
246
+ parameters: string;
247
+ }
248
+ interface MicdropConversationToolResult {
249
+ role: 'tool_result';
250
+ toolCallId: string;
251
+ toolName: string;
252
+ output: string;
253
+ }
254
+ interface MicdropToolCall {
255
+ name: string;
256
+ parameters: any;
257
+ output: any;
258
+ }
259
+ type DeepPartial<T> = T extends object ? {
260
+ [P in keyof T]?: DeepPartial<T[P]>;
261
+ } : T;
262
+
217
263
  declare enum MicdropClientErrorCode {
218
264
  MissingUrl = "MissingUrl",
219
265
  Mic = "Mic",
@@ -235,7 +281,7 @@ interface MicdropEvents {
235
281
  EndCall: [];
236
282
  Error: [MicdropClientError];
237
283
  StateChange: [MicdropState];
238
- ToolCall: [MicdropToolCall$1];
284
+ ToolCall: [MicdropToolCall];
239
285
  }
240
286
  interface MicdropOptions {
241
287
  url?: string;
@@ -258,13 +304,13 @@ interface MicdropState {
258
304
  speakerDeviceId: string | undefined;
259
305
  micDevices: MediaDeviceInfo[];
260
306
  speakerDevices: MediaDeviceInfo[];
261
- conversation: MicdropConversation$1;
307
+ conversation: MicdropConversation;
262
308
  error: MicdropClientError | undefined;
263
309
  }
264
310
  declare class MicdropClient extends EventEmitter<MicdropEvents> implements MicdropState {
265
311
  options: MicdropOptions;
266
312
  micRecorder?: MicRecorder;
267
- conversation: MicdropConversation$1;
313
+ conversation: MicdropConversation;
268
314
  error: MicdropClientError | undefined;
269
315
  speakerDevices: MediaDeviceInfo[];
270
316
  micDevices: MediaDeviceInfo[];
@@ -274,7 +320,7 @@ declare class MicdropClient extends EventEmitter<MicdropEvents> implements Micdr
274
320
  private _isProcessing;
275
321
  private _isPaused;
276
322
  constructor(options?: MicdropOptions);
277
- get vad(): VAD$1 | undefined;
323
+ get vad(): VAD | undefined;
278
324
  get isStarted(): boolean;
279
325
  get isStarting(): boolean;
280
326
  get isPaused(): boolean;
@@ -318,111 +364,4 @@ declare class MicdropClient extends EventEmitter<MicdropEvents> implements Micdr
318
364
 
319
365
  declare const Micdrop: MicdropClient;
320
366
 
321
- declare class Logger {
322
- private readonly name;
323
- constructor(name: string);
324
- log(...message: any[]): void;
325
- }
326
-
327
- interface AgentOptions {
328
- systemPrompt: string;
329
- }
330
- interface AgentEvents {
331
- Message: [MicdropConversationMessage];
332
- CancelLastUserMessage: [];
333
- CancelLastAssistantMessage: [];
334
- SkipAnswer: [];
335
- EndCall: [];
336
- ToolCall: [MicdropToolCall];
337
- }
338
- declare abstract class Agent<Options extends AgentOptions = AgentOptions> extends EventEmitter<AgentEvents> {
339
- protected options: Options;
340
- logger?: Logger;
341
- conversation: MicdropConversation;
342
- constructor(options: Options);
343
- abstract answer(): Readable;
344
- abstract cancel(): void;
345
- addUserMessage(text: string, metadata?: MicdropAnswerMetadata): void;
346
- addAssistantMessage(text: string, metadata?: MicdropAnswerMetadata): void;
347
- protected addMessage(role: 'user' | 'assistant' | 'system', text: string, metadata?: MicdropAnswerMetadata): void;
348
- protected endCall(): void;
349
- protected cancelLastUserMessage(): void;
350
- protected cancelLastAssistantMessage(): void;
351
- protected skipAnswer(): void;
352
- protected log(...message: any[]): void;
353
- destroy(): void;
354
- }
355
-
356
- declare const MIME_TYPE_TO_EXTENSION: {
357
- readonly 'audio/wav': "wav";
358
- readonly 'audio/ogg': "ogg";
359
- readonly 'audio/mpeg': "mp3";
360
- readonly 'audio/webm': "webm";
361
- readonly 'audio/mp4': "mp4";
362
- readonly 'audio/flac': "flac";
363
- };
364
- interface STTEvents {
365
- Transcript: [string];
366
- }
367
- declare abstract class STT extends EventEmitter<STTEvents> {
368
- protected mimeType?: keyof typeof MIME_TYPE_TO_EXTENSION;
369
- logger?: Logger;
370
- transcribe(audioStream: Readable): void;
371
- protected log(...message: any[]): void;
372
- destroy(): void;
373
- protected get extension(): string;
374
- private detectMimeType;
375
- }
376
-
377
- declare abstract class TTS {
378
- logger?: Logger;
379
- abstract speak(textStream: Readable): Readable;
380
- abstract cancel(): void;
381
- protected log(...message: any[]): void;
382
- destroy(): void;
383
- }
384
-
385
- declare enum MicdropClientCommands {
386
- StartSpeaking = "StartSpeaking",
387
- StopSpeaking = "StopSpeaking",
388
- Mute = "Mute"
389
- }
390
- declare enum MicdropServerCommands {
391
- Message = "Message",
392
- CancelLastAssistantMessage = "CancelLastAssistantMessage",
393
- CancelLastUserMessage = "CancelLastUserMessage",
394
- SkipAnswer = "SkipAnswer",
395
- EndCall = "EndCall",
396
- ToolCall = "ToolCall"
397
- }
398
- interface MicdropConfig {
399
- firstMessage?: string;
400
- generateFirstMessage?: boolean;
401
- agent: Agent;
402
- stt: STT;
403
- tts: TTS;
404
- onEnd?(call: MicdropCallSummary): void;
405
- }
406
- interface MicdropCallSummary {
407
- conversation: MicdropConversation;
408
- duration: number;
409
- }
410
- type MicdropConversation = MicdropConversationMessage[];
411
- type MicdropAnswerMetadata = {
412
- [key: string]: any;
413
- };
414
- interface MicdropConversationMessage<Data extends MicdropAnswerMetadata = MicdropAnswerMetadata> {
415
- role: 'system' | 'user' | 'assistant';
416
- content: string;
417
- metadata?: Data;
418
- }
419
- interface MicdropToolCall {
420
- name: string;
421
- parameters: any;
422
- output: any;
423
- }
424
- type DeepPartial<T> = T extends object ? {
425
- [P in keyof T]?: DeepPartial<T[P]>;
426
- } : T;
427
-
428
- export { type DeepPartial, LocalStorageKeys, Mic, MicRecorder, type MicRecorderEvents, type MicRecorderState, Micdrop, type MicdropAnswerMetadata, type MicdropCallSummary, MicdropClient, MicdropClientCommands, MicdropClientError, MicdropClientErrorCode, type MicdropConfig, type MicdropConversation, type MicdropConversationMessage, type MicdropEvents, type MicdropOptions, MicdropServerCommands, type MicdropState, type MicdropToolCall, MultipleVAD, SileroVAD, type SileroVADOptions, Speaker, VAD, type VADConfig, type VADConfigName, type VADEvents, VADStatus, VolumeVAD, type VolumeVADOptions, getClientErrorFromWSCloseEvent, getClientErrorFromWSCloseEventCode, getVAD };
367
+ export { type DeepPartial, LocalStorageKeys, Mic, MicRecorder, type MicRecorderEvents, type MicRecorderState, Micdrop, type MicdropAnswerMetadata, type MicdropCallSummary, MicdropClient, MicdropClientCommands, MicdropClientError, MicdropClientErrorCode, type MicdropConversation, type MicdropConversationItem, type MicdropConversationMessage, type MicdropConversationToolCall, type MicdropConversationToolResult, type MicdropEvents, type MicdropOptions, MicdropServerCommands, type MicdropState, type MicdropToolCall, MultipleVAD, SileroVAD, type SileroVADOptions, Speaker, VAD, type VADConfig, type VADConfigName, type VADEvents, VADStatus, VolumeVAD, type VolumeVADOptions, getClientErrorFromWSCloseEvent, getClientErrorFromWSCloseEventCode, getVAD };
package/dist/index.js CHANGED
@@ -878,6 +878,23 @@ var Speaker2 = window.micdropSpeaker;
878
878
  // src/client/MicdropClient.ts
879
879
  var import_eventemitter36 = require("eventemitter3");
880
880
 
881
+ // ../server/src/types.ts
882
+ var MicdropClientCommands = /* @__PURE__ */ ((MicdropClientCommands2) => {
883
+ MicdropClientCommands2["StartSpeaking"] = "StartSpeaking";
884
+ MicdropClientCommands2["StopSpeaking"] = "StopSpeaking";
885
+ MicdropClientCommands2["Mute"] = "Mute";
886
+ return MicdropClientCommands2;
887
+ })(MicdropClientCommands || {});
888
+ var MicdropServerCommands = /* @__PURE__ */ ((MicdropServerCommands2) => {
889
+ MicdropServerCommands2["Message"] = "Message";
890
+ MicdropServerCommands2["CancelLastAssistantMessage"] = "CancelLastAssistantMessage";
891
+ MicdropServerCommands2["CancelLastUserMessage"] = "CancelLastUserMessage";
892
+ MicdropServerCommands2["SkipAnswer"] = "SkipAnswer";
893
+ MicdropServerCommands2["EndCall"] = "EndCall";
894
+ MicdropServerCommands2["ToolCall"] = "ToolCall";
895
+ return MicdropServerCommands2;
896
+ })(MicdropServerCommands || {});
897
+
881
898
  // src/client/MicdropClientError.ts
882
899
  var MicdropClientErrorCode = /* @__PURE__ */ ((MicdropClientErrorCode2) => {
883
900
  MicdropClientErrorCode2["MissingUrl"] = "MissingUrl";
@@ -1279,23 +1296,6 @@ if (!window.micdropClient) {
1279
1296
  window.micdropClient = new MicdropClient();
1280
1297
  }
1281
1298
  var Micdrop = window.micdropClient;
1282
-
1283
- // ../server/src/types.ts
1284
- var MicdropClientCommands = /* @__PURE__ */ ((MicdropClientCommands2) => {
1285
- MicdropClientCommands2["StartSpeaking"] = "StartSpeaking";
1286
- MicdropClientCommands2["StopSpeaking"] = "StopSpeaking";
1287
- MicdropClientCommands2["Mute"] = "Mute";
1288
- return MicdropClientCommands2;
1289
- })(MicdropClientCommands || {});
1290
- var MicdropServerCommands = /* @__PURE__ */ ((MicdropServerCommands2) => {
1291
- MicdropServerCommands2["Message"] = "Message";
1292
- MicdropServerCommands2["CancelLastAssistantMessage"] = "CancelLastAssistantMessage";
1293
- MicdropServerCommands2["CancelLastUserMessage"] = "CancelLastUserMessage";
1294
- MicdropServerCommands2["SkipAnswer"] = "SkipAnswer";
1295
- MicdropServerCommands2["EndCall"] = "EndCall";
1296
- MicdropServerCommands2["ToolCall"] = "ToolCall";
1297
- return MicdropServerCommands2;
1298
- })(MicdropServerCommands || {});
1299
1299
  // Annotate the CommonJS export names for ESM import in node:
1300
1300
  0 && (module.exports = {
1301
1301
  LocalStorageKeys,