@framers/agentos 0.1.74 → 0.1.76

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.
Files changed (138) hide show
  1. package/README.md +139 -34
  2. package/dist/core/agency/AgentCommunicationBus.d.ts +1 -0
  3. package/dist/core/agency/AgentCommunicationBus.d.ts.map +1 -1
  4. package/dist/core/agency/AgentCommunicationBus.js +62 -8
  5. package/dist/core/agency/AgentCommunicationBus.js.map +1 -1
  6. package/dist/core/agency/IAgentCommunicationBus.d.ts +1 -1
  7. package/dist/core/agency/IAgentCommunicationBus.d.ts.map +1 -1
  8. package/dist/orchestration/builders/index.d.ts +1 -1
  9. package/dist/orchestration/builders/index.d.ts.map +1 -1
  10. package/dist/orchestration/builders/index.js +1 -1
  11. package/dist/orchestration/builders/index.js.map +1 -1
  12. package/dist/orchestration/builders/nodes.d.ts +15 -0
  13. package/dist/orchestration/builders/nodes.d.ts.map +1 -1
  14. package/dist/orchestration/builders/nodes.js +33 -0
  15. package/dist/orchestration/builders/nodes.js.map +1 -1
  16. package/dist/orchestration/runtime/LoopController.d.ts +10 -10
  17. package/dist/orchestration/runtime/LoopController.d.ts.map +1 -1
  18. package/dist/orchestration/runtime/LoopController.js +1 -1
  19. package/dist/orchestration/runtime/LoopController.js.map +1 -1
  20. package/dist/orchestration/runtime/index.d.ts +1 -1
  21. package/dist/orchestration/runtime/index.d.ts.map +1 -1
  22. package/dist/orchestration/runtime/index.js.map +1 -1
  23. package/dist/speech/FallbackProxy.d.ts +104 -0
  24. package/dist/speech/FallbackProxy.d.ts.map +1 -0
  25. package/dist/speech/FallbackProxy.js +151 -0
  26. package/dist/speech/FallbackProxy.js.map +1 -0
  27. package/dist/speech/SpeechProviderResolver.d.ts +103 -0
  28. package/dist/speech/SpeechProviderResolver.d.ts.map +1 -0
  29. package/dist/speech/SpeechProviderResolver.js +256 -0
  30. package/dist/speech/SpeechProviderResolver.js.map +1 -0
  31. package/dist/speech/SpeechRuntime.d.ts +23 -1
  32. package/dist/speech/SpeechRuntime.d.ts.map +1 -1
  33. package/dist/speech/SpeechRuntime.js +82 -8
  34. package/dist/speech/SpeechRuntime.js.map +1 -1
  35. package/dist/speech/index.d.ts +6 -0
  36. package/dist/speech/index.d.ts.map +1 -1
  37. package/dist/speech/index.js +6 -0
  38. package/dist/speech/index.js.map +1 -1
  39. package/dist/speech/providerCatalog.d.ts.map +1 -1
  40. package/dist/speech/providerCatalog.js +15 -1
  41. package/dist/speech/providerCatalog.js.map +1 -1
  42. package/dist/speech/providers/AssemblyAISTTProvider.d.ts +49 -0
  43. package/dist/speech/providers/AssemblyAISTTProvider.d.ts.map +1 -0
  44. package/dist/speech/providers/AssemblyAISTTProvider.js +151 -0
  45. package/dist/speech/providers/AssemblyAISTTProvider.js.map +1 -0
  46. package/dist/speech/providers/AzureSpeechSTTProvider.d.ts +48 -0
  47. package/dist/speech/providers/AzureSpeechSTTProvider.d.ts.map +1 -0
  48. package/dist/speech/providers/AzureSpeechSTTProvider.js +90 -0
  49. package/dist/speech/providers/AzureSpeechSTTProvider.js.map +1 -0
  50. package/dist/speech/providers/AzureSpeechTTSProvider.d.ts +60 -0
  51. package/dist/speech/providers/AzureSpeechTTSProvider.d.ts.map +1 -0
  52. package/dist/speech/providers/AzureSpeechTTSProvider.js +127 -0
  53. package/dist/speech/providers/AzureSpeechTTSProvider.js.map +1 -0
  54. package/dist/speech/providers/DeepgramBatchSTTProvider.d.ts +55 -0
  55. package/dist/speech/providers/DeepgramBatchSTTProvider.d.ts.map +1 -0
  56. package/dist/speech/providers/DeepgramBatchSTTProvider.js +102 -0
  57. package/dist/speech/providers/DeepgramBatchSTTProvider.js.map +1 -0
  58. package/dist/speech/types.d.ts +35 -0
  59. package/dist/speech/types.d.ts.map +1 -1
  60. package/dist/voice/CallManager.d.ts +1 -1
  61. package/dist/voice/CallManager.d.ts.map +1 -1
  62. package/dist/voice/CallManager.js +9 -0
  63. package/dist/voice/CallManager.js.map +1 -1
  64. package/dist/voice/MediaStreamParser.d.ts +83 -0
  65. package/dist/voice/MediaStreamParser.d.ts.map +1 -0
  66. package/dist/voice/MediaStreamParser.js +2 -0
  67. package/dist/voice/MediaStreamParser.js.map +1 -0
  68. package/dist/voice/TelephonyStreamTransport.d.ts +112 -0
  69. package/dist/voice/TelephonyStreamTransport.d.ts.map +1 -0
  70. package/dist/voice/TelephonyStreamTransport.js +208 -0
  71. package/dist/voice/TelephonyStreamTransport.js.map +1 -0
  72. package/dist/voice/index.d.ts +10 -0
  73. package/dist/voice/index.d.ts.map +1 -1
  74. package/dist/voice/index.js +11 -0
  75. package/dist/voice/index.js.map +1 -1
  76. package/dist/voice/parsers/PlivoMediaStreamParser.d.ts +43 -0
  77. package/dist/voice/parsers/PlivoMediaStreamParser.d.ts.map +1 -0
  78. package/dist/voice/parsers/PlivoMediaStreamParser.js +92 -0
  79. package/dist/voice/parsers/PlivoMediaStreamParser.js.map +1 -0
  80. package/dist/voice/parsers/TelnyxMediaStreamParser.d.ts +51 -0
  81. package/dist/voice/parsers/TelnyxMediaStreamParser.d.ts.map +1 -0
  82. package/dist/voice/parsers/TelnyxMediaStreamParser.js +103 -0
  83. package/dist/voice/parsers/TelnyxMediaStreamParser.js.map +1 -0
  84. package/dist/voice/parsers/TwilioMediaStreamParser.d.ts +50 -0
  85. package/dist/voice/parsers/TwilioMediaStreamParser.d.ts.map +1 -0
  86. package/dist/voice/parsers/TwilioMediaStreamParser.js +144 -0
  87. package/dist/voice/parsers/TwilioMediaStreamParser.js.map +1 -0
  88. package/dist/voice/providers/plivo.d.ts +77 -0
  89. package/dist/voice/providers/plivo.d.ts.map +1 -0
  90. package/dist/voice/providers/plivo.js +180 -0
  91. package/dist/voice/providers/plivo.js.map +1 -0
  92. package/dist/voice/providers/telnyx.d.ts +93 -0
  93. package/dist/voice/providers/telnyx.d.ts.map +1 -0
  94. package/dist/voice/providers/telnyx.js +193 -0
  95. package/dist/voice/providers/telnyx.js.map +1 -0
  96. package/dist/voice/providers/twilio.d.ts +79 -0
  97. package/dist/voice/providers/twilio.d.ts.map +1 -0
  98. package/dist/voice/providers/twilio.js +191 -0
  99. package/dist/voice/providers/twilio.js.map +1 -0
  100. package/dist/voice/twiml.d.ts +69 -0
  101. package/dist/voice/twiml.d.ts.map +1 -0
  102. package/dist/voice/twiml.js +92 -0
  103. package/dist/voice/twiml.js.map +1 -0
  104. package/dist/voice/types.d.ts +9 -1
  105. package/dist/voice/types.d.ts.map +1 -1
  106. package/dist/voice-pipeline/AcousticEndpointDetector.d.ts +90 -0
  107. package/dist/voice-pipeline/AcousticEndpointDetector.d.ts.map +1 -0
  108. package/dist/voice-pipeline/AcousticEndpointDetector.js +123 -0
  109. package/dist/voice-pipeline/AcousticEndpointDetector.js.map +1 -0
  110. package/dist/voice-pipeline/HardCutBargeinHandler.d.ts +67 -0
  111. package/dist/voice-pipeline/HardCutBargeinHandler.d.ts.map +1 -0
  112. package/dist/voice-pipeline/HardCutBargeinHandler.js +55 -0
  113. package/dist/voice-pipeline/HardCutBargeinHandler.js.map +1 -0
  114. package/dist/voice-pipeline/HeuristicEndpointDetector.d.ts +128 -0
  115. package/dist/voice-pipeline/HeuristicEndpointDetector.d.ts.map +1 -0
  116. package/dist/voice-pipeline/HeuristicEndpointDetector.js +240 -0
  117. package/dist/voice-pipeline/HeuristicEndpointDetector.js.map +1 -0
  118. package/dist/voice-pipeline/SoftFadeBargeinHandler.d.ts +96 -0
  119. package/dist/voice-pipeline/SoftFadeBargeinHandler.d.ts.map +1 -0
  120. package/dist/voice-pipeline/SoftFadeBargeinHandler.js +69 -0
  121. package/dist/voice-pipeline/SoftFadeBargeinHandler.js.map +1 -0
  122. package/dist/voice-pipeline/VoicePipelineOrchestrator.d.ts +122 -0
  123. package/dist/voice-pipeline/VoicePipelineOrchestrator.d.ts.map +1 -0
  124. package/dist/voice-pipeline/VoicePipelineOrchestrator.js +317 -0
  125. package/dist/voice-pipeline/VoicePipelineOrchestrator.js.map +1 -0
  126. package/dist/voice-pipeline/WebSocketStreamTransport.d.ts +148 -0
  127. package/dist/voice-pipeline/WebSocketStreamTransport.d.ts.map +1 -0
  128. package/dist/voice-pipeline/WebSocketStreamTransport.js +207 -0
  129. package/dist/voice-pipeline/WebSocketStreamTransport.js.map +1 -0
  130. package/dist/voice-pipeline/index.d.ts +13 -0
  131. package/dist/voice-pipeline/index.d.ts.map +1 -0
  132. package/dist/voice-pipeline/index.js +13 -0
  133. package/dist/voice-pipeline/index.js.map +1 -0
  134. package/dist/voice-pipeline/types.d.ts +905 -0
  135. package/dist/voice-pipeline/types.d.ts.map +1 -0
  136. package/dist/voice-pipeline/types.js +23 -0
  137. package/dist/voice-pipeline/types.js.map +1 -0
  138. package/package.json +6 -1
@@ -54,17 +54,17 @@ export interface LoopContext {
54
54
  * Implementations should never throw — instead return a result with
55
55
  * `success: false` and a populated `error` field.
56
56
  */
57
- executeTool: (toolCall: ToolCallRequest) => Promise<ToolCallResult>;
57
+ executeTool: (toolCall: LoopToolCallRequest) => Promise<LoopToolCallResult>;
58
58
  /**
59
59
  * Feed tool results back into the conversation so the next `generateStream`
60
60
  * call has access to them. Typically appends tool messages to the message list.
61
61
  */
62
- addToolResults: (results: ToolCallResult[]) => void;
62
+ addToolResults: (results: LoopToolCallResult[]) => void;
63
63
  }
64
64
  /**
65
65
  * A single tool invocation requested by the LLM.
66
66
  */
67
- export interface ToolCallRequest {
67
+ export interface LoopToolCallRequest {
68
68
  /** Unique identifier for this tool call within a response (matches the tool result). */
69
69
  id: string;
70
70
  /** Name of the tool to invoke. */
@@ -73,10 +73,10 @@ export interface ToolCallRequest {
73
73
  arguments: Record<string, unknown>;
74
74
  }
75
75
  /**
76
- * The outcome of executing a {@link ToolCallRequest}.
76
+ * The outcome of executing a {@link LoopToolCallRequest}.
77
77
  */
78
- export interface ToolCallResult {
79
- /** Matches the originating {@link ToolCallRequest.id}. */
78
+ export interface LoopToolCallResult {
79
+ /** Matches the originating {@link LoopToolCallRequest.id}. */
80
80
  id: string;
81
81
  /** Name of the tool that was called. */
82
82
  name: string;
@@ -100,7 +100,7 @@ export interface LoopChunk {
100
100
  /** Present when `type === 'text_delta'`. */
101
101
  content?: string;
102
102
  /** Present when `type === 'tool_call_request'`. */
103
- toolCalls?: ToolCallRequest[];
103
+ toolCalls?: LoopToolCallRequest[];
104
104
  }
105
105
  /**
106
106
  * The final return value of `generateStream` (carried in the generator's
@@ -113,7 +113,7 @@ export interface LoopOutput {
113
113
  * All tool calls requested in this iteration. An empty array signals that
114
114
  * the LLM is done and the loop should terminate.
115
115
  */
116
- toolCalls: ToolCallRequest[];
116
+ toolCalls: LoopToolCallRequest[];
117
117
  /**
118
118
  * The LLM finish reason (e.g. `'stop'`, `'tool_calls'`, `'length'`).
119
119
  * Informational; not used for loop-control decisions.
@@ -129,11 +129,11 @@ export type LoopEvent = {
129
129
  content: string;
130
130
  } | {
131
131
  type: 'tool_call_request';
132
- toolCalls: ToolCallRequest[];
132
+ toolCalls: LoopToolCallRequest[];
133
133
  } | {
134
134
  type: 'tool_result';
135
135
  toolName: string;
136
- result: ToolCallResult;
136
+ result: LoopToolCallResult;
137
137
  } | {
138
138
  type: 'tool_error';
139
139
  toolName: string;
@@ -1 +1 @@
1
- {"version":3,"file":"LoopController.d.ts","sourceRoot":"","sources":["../../../src/orchestration/runtime/LoopController.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAMH;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,iFAAiF;IACjF,aAAa,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,aAAa,EAAE,OAAO,CAAC;IAEvB;;;;OAIG;IACH,WAAW,EAAE,WAAW,GAAG,aAAa,CAAC;IAEzC;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAMD;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B;;;;OAIG;IACH,cAAc,EAAE,MAAM,cAAc,CAAC,SAAS,EAAE,UAAU,EAAE,SAAS,CAAC,CAA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AQ,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACvD;IAAE,IAAI,EAAE,wBAAwB,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GACrD;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,eAAe,EAAE,MAAM,CAAA;CAAE,CAAC;AAMvD;;;;;;;;;;;;;GAaG;AACH,qBAAa,cAAc;IACzB;;;;;;;OAOG;IACI,OAAO,CACZ,MAAM,EAAE,UAAU,EAClB,OAAO,EAAE,WAAW,GACnB,cAAc,CAAC,SAAS,CAAC;CAuG7B"}
@@ -84,7 +84,7 @@ export class LoopController {
84
84
  results = settled.map((s, i) => {
85
85
  if (s.status === 'fulfilled')
86
86
  return s.value;
87
- // Convert a rejected promise into a failed ToolCallResult so
87
+ // Convert a rejected promise into a failed LoopToolCallResult so
88
88
  // downstream handling is uniform.
89
89
  return {
90
90
  id: toolCalls[i].id,
@@ -1 +1 @@
1
- {"version":3,"file":"LoopController.js","sourceRoot":"","sources":["../../../src/orchestration/runtime/LoopController.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAiKH,8EAA8E;AAC9E,iBAAiB;AACjB,8EAA8E;AAE9E;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,cAAc;IACzB;;;;;;;OAOG;IACH,KAAK,CAAC,CAAC,OAAO,CACZ,MAAkB,EAClB,OAAoB;QAEpB,IAAI,SAAS,GAAG,CAAC,CAAC;QAElB,OAAO,SAAS,GAAG,MAAM,CAAC,aAAa,EAAE,CAAC;YACxC,SAAS,EAAE,CAAC;YAEZ,qEAAqE;YACrE,kEAAkE;YAClE,oEAAoE;YACpE,qDAAqD;YACrD,qEAAqE;YACrE,MAAM,GAAG,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;YACrC,IAAI,SAAiC,CAAC;YAEtC,OAAO,IAAI,EAAE,CAAC;gBACZ,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,MAAM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AC;YAED,uEAAuE;YACvE,qDAAqD;YACrD,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;QAClC,CAAC;QAED,iDAAiD;QACjD,MAAM,EAAE,IAAI,EAAE,wBAAwB,EAAE,SAAS,EAAE,MAAM,CAAC,aAAa,EAAE,CAAC;IAC5E,CAAC;CACF"}
1
+ {"version":3,"file":"LoopController.js","sourceRoot":"","sources":["../../../src/orchestration/runtime/LoopController.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAiKH,8EAA8E;AAC9E,iBAAiB;AACjB,8EAA8E;AAE9E;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,cAAc;IACzB;;;;;;;OAOG;IACH,KAAK,CAAC,CAAC,OAAO,CACZ,MAAkB,EAClB,OAAoB;QAEpB,IAAI,SAAS,GAAG,CAAC,CAAC;QAElB,OAAO,SAAS,GAAG,MAAM,CAAC,aAAa,EAAE,CAAC;YACxC,SAAS,EAAE,CAAC;YAEZ,qEAAqE;YACrE,kEAAkE;YAClE,oEAAoE;YACpE,qDAAqD;YACrD,qEAAqE;YACrE,MAAM,GAAG,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;YACrC,IAAI,SAAiC,CAAC;YAEtC,OAAO,IAAI,EAAE,CAAC;gBACZ,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;gBAEzC,IAAI,IAAI,EAAE,CAAC;oBACT,0DAA0D;oBAC1D,SAAS,GAAG,KAAmB,CAAC;oBAChC,MAAM;gBACR,CAAC;gBAED,oCAAoC;gBACpC,MAAM,KAAK,GAAG,KAAkB,CAAC;gBAEjC,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;oBACjD,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;gBACvD,CAAC;gBAED,IAAI,KAA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,GAAG,EAAE,CAAC;gBACb,KAAK,MAAM,EAAE,IAAI,SAAS,EAAE,CAAC;oBAC3B,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;oBAC7C,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gBACvB,CAAC;YACH,CAAC;YAED,qEAAqE;YACrE,iEAAiE;YACjE,qEAAqE;YACrE,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;gBAC7B,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;oBACnB,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC;gBAC/D,CAAC;qBAAM,CAAC;oBACN,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,IAAI,eAAe,CAAC;oBACjD,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;oBAErE,IAAI,MAAM,CAAC,WAAW,KAAK,aAAa,EAAE,CAAC;wBACzC,MAAM,IAAI,KAAK,CACb,QAAQ,MAAM,CAAC,IAAI,0BAA0B,QAAQ,EAAE,CACxD,CAAC;oBACJ,CAAC;oBACD,4DAA4D;gBAC9D,CAAC;YACH,CAAC;YAED,uEAAuE;YACvE,qDAAqD;YACrD,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;QAClC,CAAC;QAED,iDAAiD;QACjD,MAAM,EAAE,IAAI,EAAE,wBAAwB,EAAE,SAAS,EAAE,MAAM,CAAC,aAAa,EAAE,CAAC;IAC5E,CAAC;CACF"}
@@ -8,7 +8,7 @@
8
8
  export { StateManager } from './StateManager.js';
9
9
  export { NodeScheduler } from './NodeScheduler.js';
10
10
  export { LoopController } from './LoopController.js';
11
- export type { LoopConfig, LoopContext, LoopEvent } from './LoopController.js';
11
+ export type { LoopConfig, LoopContext, LoopEvent, LoopToolCallRequest, LoopToolCallResult, } from './LoopController.js';
12
12
  export { NodeExecutor } from './NodeExecutor.js';
13
13
  export type { NodeExecutionResult } from './NodeExecutor.js';
14
14
  export { GraphRuntime } from './GraphRuntime.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/orchestration/runtime/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,YAAY,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,YAAY,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/orchestration/runtime/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,YAAY,EACV,UAAU,EACV,WAAW,EACX,SAAS,EACT,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,YAAY,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,YAAY,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/orchestration/runtime/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/orchestration/runtime/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAQrD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,104 @@
1
+ import { EventEmitter } from 'events';
2
+ import type { SpeechToTextProvider, TextToSpeechProvider, SpeechAudioInput, SpeechTranscriptionOptions, SpeechTranscriptionResult, SpeechSynthesisOptions, SpeechSynthesisResult, SpeechVoice } from './types.js';
3
+ /**
4
+ * Payload emitted on the `provider_fallback` event when a provider in the chain
5
+ * fails and the proxy advances to the next candidate.
6
+ */
7
+ export interface ProviderFallbackEvent {
8
+ /** ID of the provider that failed. */
9
+ from: string;
10
+ /** ID of the provider that will be tried next. */
11
+ to: string;
12
+ /** Whether this is an STT or TTS chain. */
13
+ kind: 'stt' | 'tts';
14
+ /** The error thrown by the failing provider. */
15
+ error: unknown;
16
+ }
17
+ /**
18
+ * A {@link SpeechToTextProvider} that wraps an ordered chain of STT providers.
19
+ * Providers are tried left-to-right; the first successful result is returned.
20
+ * On each failure (except the last) a `provider_fallback` event is emitted on
21
+ * the supplied {@link EventEmitter} so callers can observe the fallback path.
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * const proxy = new FallbackSTTProxy([whisperProvider, deepgramProvider], emitter);
26
+ * const result = await proxy.transcribe(audio);
27
+ * ```
28
+ */
29
+ export declare class FallbackSTTProxy implements SpeechToTextProvider {
30
+ private readonly chain;
31
+ private readonly emitter;
32
+ /** Derived from the first provider in the chain (or `'fallback-stt'` for empty chains). */
33
+ readonly id: string;
34
+ /** Human-readable name showing the full chain: `"Fallback STT (p1 → p2)"`. */
35
+ readonly displayName: string;
36
+ /** `true` only when the first provider in the chain supports streaming. */
37
+ readonly supportsStreaming: boolean;
38
+ /**
39
+ * @param chain Ordered list of STT providers to try. Must contain at least one entry
40
+ * for `transcribe()` to succeed, though an empty chain is allowed
41
+ * (it will always throw).
42
+ * @param emitter EventEmitter on which `provider_fallback` events are published.
43
+ */
44
+ constructor(chain: SpeechToTextProvider[], emitter: EventEmitter);
45
+ /**
46
+ * Attempt transcription using each provider in order.
47
+ *
48
+ * Emits a `provider_fallback` event (typed as {@link ProviderFallbackEvent})
49
+ * whenever a non-final provider throws. Re-throws the last provider's error
50
+ * when the entire chain is exhausted, and throws `Error('No providers in
51
+ * fallback chain')` when `chain` is empty.
52
+ */
53
+ transcribe(audio: SpeechAudioInput, options?: SpeechTranscriptionOptions): Promise<SpeechTranscriptionResult>;
54
+ /** Delegates to the first provider in the chain, or returns `'fallback'` for an empty chain. */
55
+ getProviderName(): string;
56
+ }
57
+ /**
58
+ * A {@link TextToSpeechProvider} that wraps an ordered chain of TTS providers.
59
+ * Providers are tried left-to-right; the first successful result is returned.
60
+ * On each failure (except the last) a `provider_fallback` event is emitted on
61
+ * the supplied {@link EventEmitter}.
62
+ *
63
+ * Voice listing is delegated to the first provider that exposes
64
+ * `listAvailableVoices()`. If none do, an empty array is returned.
65
+ *
66
+ * @example
67
+ * ```ts
68
+ * const proxy = new FallbackTTSProxy([elevenlabsProvider, openaiTtsProvider], emitter);
69
+ * const audio = await proxy.synthesize('Hello world');
70
+ * ```
71
+ */
72
+ export declare class FallbackTTSProxy implements TextToSpeechProvider {
73
+ private readonly chain;
74
+ private readonly emitter;
75
+ /** Derived from the first provider in the chain (or `'fallback-tts'` for empty chains). */
76
+ readonly id: string;
77
+ /** Human-readable name showing the full chain: `"Fallback TTS (p1 → p2)"`. */
78
+ readonly displayName: string;
79
+ /** `true` only when the first provider in the chain supports streaming. */
80
+ readonly supportsStreaming: boolean;
81
+ /**
82
+ * @param chain Ordered list of TTS providers to try.
83
+ * @param emitter EventEmitter on which `provider_fallback` events are published.
84
+ */
85
+ constructor(chain: TextToSpeechProvider[], emitter: EventEmitter);
86
+ /**
87
+ * Attempt synthesis using each provider in order.
88
+ *
89
+ * Emits a `provider_fallback` event (typed as {@link ProviderFallbackEvent})
90
+ * whenever a non-final provider throws. Re-throws the last provider's error
91
+ * when the entire chain is exhausted, and throws `Error('No providers in
92
+ * fallback chain')` when `chain` is empty.
93
+ */
94
+ synthesize(text: string, options?: SpeechSynthesisOptions): Promise<SpeechSynthesisResult>;
95
+ /** Delegates to the first provider in the chain, or returns `'fallback'` for an empty chain. */
96
+ getProviderName(): string;
97
+ /**
98
+ * Returns voice list from the first provider in the chain that exposes
99
+ * `listAvailableVoices()`. Falls back to an empty array when no provider
100
+ * supports this method.
101
+ */
102
+ listAvailableVoices(): Promise<SpeechVoice[]>;
103
+ }
104
+ //# sourceMappingURL=FallbackProxy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FallbackProxy.d.ts","sourceRoot":"","sources":["../../src/speech/FallbackProxy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EACV,oBAAoB,EACpB,oBAAoB,EACpB,gBAAgB,EAChB,0BAA0B,EAC1B,yBAAyB,EACzB,sBAAsB,EACtB,qB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AE,YAAY;IAOxC;;;;;;;OAOG;IACG,UAAU,CACd,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,sBAAsB,GAC/B,OAAO,CAAC,qBAAqB,CAAC;IA2BjC,gGAAgG;IAChG,eAAe,IAAI,MAAM;IAIzB;;;;OAIG;IACG,mBAAmB,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;CAQpD"}
@@ -0,0 +1,151 @@
1
+ // ---------------------------------------------------------------------------
2
+ // FallbackSTTProxy
3
+ // ---------------------------------------------------------------------------
4
+ /**
5
+ * A {@link SpeechToTextProvider} that wraps an ordered chain of STT providers.
6
+ * Providers are tried left-to-right; the first successful result is returned.
7
+ * On each failure (except the last) a `provider_fallback` event is emitted on
8
+ * the supplied {@link EventEmitter} so callers can observe the fallback path.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * const proxy = new FallbackSTTProxy([whisperProvider, deepgramProvider], emitter);
13
+ * const result = await proxy.transcribe(audio);
14
+ * ```
15
+ */
16
+ export class FallbackSTTProxy {
17
+ /**
18
+ * @param chain Ordered list of STT providers to try. Must contain at least one entry
19
+ * for `transcribe()` to succeed, though an empty chain is allowed
20
+ * (it will always throw).
21
+ * @param emitter EventEmitter on which `provider_fallback` events are published.
22
+ */
23
+ constructor(chain, emitter) {
24
+ this.chain = chain;
25
+ this.emitter = emitter;
26
+ this.id = chain[0]?.id ?? 'fallback-stt';
27
+ this.displayName = `Fallback STT (${chain.map((p) => p.id).join(' → ')})`;
28
+ this.supportsStreaming = chain[0]?.supportsStreaming ?? false;
29
+ }
30
+ /**
31
+ * Attempt transcription using each provider in order.
32
+ *
33
+ * Emits a `provider_fallback` event (typed as {@link ProviderFallbackEvent})
34
+ * whenever a non-final provider throws. Re-throws the last provider's error
35
+ * when the entire chain is exhausted, and throws `Error('No providers in
36
+ * fallback chain')` when `chain` is empty.
37
+ */
38
+ async transcribe(audio, options) {
39
+ if (this.chain.length === 0) {
40
+ throw new Error('No providers in fallback chain');
41
+ }
42
+ for (let i = 0; i < this.chain.length; i++) {
43
+ try {
44
+ return await this.chain[i].transcribe(audio, options);
45
+ }
46
+ catch (error) {
47
+ if (i < this.chain.length - 1) {
48
+ const event = {
49
+ from: this.chain[i].id,
50
+ to: this.chain[i + 1].id,
51
+ kind: 'stt',
52
+ error,
53
+ };
54
+ this.emitter.emit('provider_fallback', event);
55
+ }
56
+ else {
57
+ throw error;
58
+ }
59
+ }
60
+ }
61
+ // Unreachable — TypeScript requires an explicit throw after the loop.
62
+ throw new Error('No providers in fallback chain');
63
+ }
64
+ /** Delegates to the first provider in the chain, or returns `'fallback'` for an empty chain. */
65
+ getProviderName() {
66
+ return this.chain[0]?.getProviderName() ?? 'fallback';
67
+ }
68
+ }
69
+ // ---------------------------------------------------------------------------
70
+ // FallbackTTSProxy
71
+ // ---------------------------------------------------------------------------
72
+ /**
73
+ * A {@link TextToSpeechProvider} that wraps an ordered chain of TTS providers.
74
+ * Providers are tried left-to-right; the first successful result is returned.
75
+ * On each failure (except the last) a `provider_fallback` event is emitted on
76
+ * the supplied {@link EventEmitter}.
77
+ *
78
+ * Voice listing is delegated to the first provider that exposes
79
+ * `listAvailableVoices()`. If none do, an empty array is returned.
80
+ *
81
+ * @example
82
+ * ```ts
83
+ * const proxy = new FallbackTTSProxy([elevenlabsProvider, openaiTtsProvider], emitter);
84
+ * const audio = await proxy.synthesize('Hello world');
85
+ * ```
86
+ */
87
+ export class FallbackTTSProxy {
88
+ /**
89
+ * @param chain Ordered list of TTS providers to try.
90
+ * @param emitter EventEmitter on which `provider_fallback` events are published.
91
+ */
92
+ constructor(chain, emitter) {
93
+ this.chain = chain;
94
+ this.emitter = emitter;
95
+ this.id = chain[0]?.id ?? 'fallback-tts';
96
+ this.displayName = `Fallback TTS (${chain.map((p) => p.id).join(' → ')})`;
97
+ this.supportsStreaming = chain[0]?.supportsStreaming ?? false;
98
+ }
99
+ /**
100
+ * Attempt synthesis using each provider in order.
101
+ *
102
+ * Emits a `provider_fallback` event (typed as {@link ProviderFallbackEvent})
103
+ * whenever a non-final provider throws. Re-throws the last provider's error
104
+ * when the entire chain is exhausted, and throws `Error('No providers in
105
+ * fallback chain')` when `chain` is empty.
106
+ */
107
+ async synthesize(text, options) {
108
+ if (this.chain.length === 0) {
109
+ throw new Error('No providers in fallback chain');
110
+ }
111
+ for (let i = 0; i < this.chain.length; i++) {
112
+ try {
113
+ return await this.chain[i].synthesize(text, options);
114
+ }
115
+ catch (error) {
116
+ if (i < this.chain.length - 1) {
117
+ const event = {
118
+ from: this.chain[i].id,
119
+ to: this.chain[i + 1].id,
120
+ kind: 'tts',
121
+ error,
122
+ };
123
+ this.emitter.emit('provider_fallback', event);
124
+ }
125
+ else {
126
+ throw error;
127
+ }
128
+ }
129
+ }
130
+ // Unreachable — TypeScript requires an explicit throw after the loop.
131
+ throw new Error('No providers in fallback chain');
132
+ }
133
+ /** Delegates to the first provider in the chain, or returns `'fallback'` for an empty chain. */
134
+ getProviderName() {
135
+ return this.chain[0]?.getProviderName() ?? 'fallback';
136
+ }
137
+ /**
138
+ * Returns voice list from the first provider in the chain that exposes
139
+ * `listAvailableVoices()`. Falls back to an empty array when no provider
140
+ * supports this method.
141
+ */
142
+ async listAvailableVoices() {
143
+ for (const provider of this.chain) {
144
+ if (typeof provider.listAvailableVoices === 'function') {
145
+ return provider.listAvailableVoices();
146
+ }
147
+ }
148
+ return [];
149
+ }
150
+ }
151
+ //# sourceMappingURL=FallbackProxy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FallbackProxy.js","sourceRoot":"","sources":["../../src/speech/FallbackProxy.ts"],"names":[],"mappings":"AA2BA,8EAA8E;AAC9E,mBAAmB;AACnB,8EAA8E;AAE9E;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,gBAAgB;IAU3B;;;;;OAKG;IACH,YACmB,KAA6B,EAC7B,OAAqB;QADrB,UAAK,GAAL,KAAK,CAAwB;QAC7B,YAAO,GAAP,OAAO,CAAc;QAEtC,IAAI,CAAC,EAAE,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O,KAAK,EAAE,CAAC;gBACf,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBAC9B,MAAM,KAAK,GAA0B;wBACnC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE;wBACtB,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;wBACxB,IAAI,EAAE,KAAK;wBACX,KAAK;qBACN,CAAC;oBACF,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,mBAAmB,EAAE,KAAK,CAAC,CAAC;gBAChD,CAAC;qBAAM,CAAC;oBACN,MAAM,KAAK,CAAC;gBACd,CAAC;YACH,CAAC;QACH,CAAC;QAED,sEAAsE;QACtE,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;IACpD,CAAC;IAED,gGAAgG;IAChG,eAAe;QACb,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,IAAI,UAAU,CAAC;IACxD,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,mBAAmB;QACvB,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YAClC,IAAI,OAAO,QAAQ,CAAC,mBAAmB,KAAK,UAAU,EAAE,CAAC;gBACvD,OAAO,QAAQ,CAAC,mBAAmB,EAAE,CAAC;YACxC,CAAC;QACH,CAAC;QACD,OAAO,EAAE,CAAC;IACZ,CAAC;CACF"}
@@ -0,0 +1,103 @@
1
+ import { EventEmitter } from 'events';
2
+ import type { SpeechProviderKind, SpeechToTextProvider, TextToSpeechProvider, SpeechVadProvider, WakeWordProvider, SpeechResolverConfig, ProviderRequirements, ProviderRegistration } from './types.js';
3
+ /**
4
+ * Central resolver for speech providers (STT, TTS, VAD, wake-word).
5
+ *
6
+ * Providers are registered with a kind, priority, and catalog metadata.
7
+ * Resolution filters by `isConfigured`, applies {@link ProviderRequirements},
8
+ * and optionally wraps multiple candidates in a {@link FallbackSTTProxy} or
9
+ * {@link FallbackTTSProxy} when fallback mode is enabled in the config.
10
+ *
11
+ * Emits:
12
+ * - `provider_registered` — when a new provider is registered via {@link register}.
13
+ */
14
+ export declare class SpeechProviderResolver extends EventEmitter {
15
+ private readonly config?;
16
+ private readonly env;
17
+ /** All registered providers keyed by id. */
18
+ private registrations;
19
+ /**
20
+ * @param config Optional resolver configuration (preferred providers, fallback mode).
21
+ * @param env Environment variable map used to check provider availability.
22
+ */
23
+ constructor(config?: SpeechResolverConfig | undefined, env?: Record<string, string | undefined>);
24
+ /**
25
+ * Register a provider. Overwrites any existing registration with the same id.
26
+ * Emits a `provider_registered` event with `{ id, kind, source }`.
27
+ */
28
+ register(reg: ProviderRegistration): void;
29
+ /**
30
+ * List all registrations for a given kind, sorted ascending by priority
31
+ * (lower number = higher priority).
32
+ */
33
+ listProviders(kind: SpeechProviderKind): ProviderRegistration[];
34
+ /**
35
+ * Resolve the best STT provider matching optional {@link ProviderRequirements}.
36
+ *
37
+ * When `config.stt.fallback` is true and multiple candidates exist, wraps them
38
+ * in a {@link FallbackSTTProxy}. Otherwise returns the single best match.
39
+ *
40
+ * @throws When no configured STT provider matches requirements.
41
+ */
42
+ resolveSTT(requirements?: ProviderRequirements): SpeechToTextProvider;
43
+ /**
44
+ * Resolve the best TTS provider matching optional {@link ProviderRequirements}.
45
+ *
46
+ * When `config.tts.fallback` is true and multiple candidates exist, wraps them
47
+ * in a {@link FallbackTTSProxy}. Otherwise returns the single best match.
48
+ *
49
+ * @throws When no configured TTS provider matches requirements.
50
+ */
51
+ resolveTTS(requirements?: ProviderRequirements): TextToSpeechProvider;
52
+ /**
53
+ * Resolve the highest-priority configured VAD provider.
54
+ *
55
+ * @throws When no VAD provider is registered and configured.
56
+ */
57
+ resolveVAD(): SpeechVadProvider;
58
+ /**
59
+ * Resolve the highest-priority configured wake-word provider, or `null`
60
+ * when none is registered.
61
+ */
62
+ resolveWakeWord(): WakeWordProvider | null;
63
+ /**
64
+ * Register core providers from the static catalog and optionally discover
65
+ * extension providers from an ExtensionManager-like object. Also applies
66
+ * user-configured preferred priorities afterwards.
67
+ *
68
+ * @param extensionManager Optional object exposing `getDescriptorsByKind(kind)`.
69
+ */
70
+ refresh(extensionManager?: any): Promise<void>;
71
+ /**
72
+ * Core resolution algorithm shared by {@link resolveSTT} and {@link resolveTTS}.
73
+ *
74
+ * When `requirements.preferredIds` is provided, returns matches in that order.
75
+ * Otherwise returns all configured providers matching requirements, sorted by
76
+ * priority (ascending).
77
+ */
78
+ private resolveByKind;
79
+ /**
80
+ * Check whether a registration satisfies the given requirements
81
+ * (streaming, local, features).
82
+ */
83
+ private matchesRequirements;
84
+ /**
85
+ * Register providers from the static core list. Each provider is marked
86
+ * `isConfigured` based on whether the required environment variables are set.
87
+ * Providers with `available === false` in the catalog are skipped.
88
+ */
89
+ private registerCoreProviders;
90
+ /**
91
+ * Discover speech providers exposed by an ExtensionManager via
92
+ * `getDescriptorsByKind()`. Extension providers default to priority 200
93
+ * (lower than core's 100) unless the user overrides via preferred config.
94
+ */
95
+ private discoverExtensionProviders;
96
+ /**
97
+ * Boost priority for providers listed in `config.stt.preferred` /
98
+ * `config.tts.preferred`. Earlier entries get lower (= higher priority)
99
+ * numbers starting at 50.
100
+ */
101
+ private applyPreferredPriorities;
102
+ }
103
+ //# sourceMappingURL=SpeechProviderResolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SpeechProviderResolver.d.ts","sourceRoot":"","sources":["../../src/speech/SpeechProviderResolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EACV,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,EAEhB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACrB,MAAM,YAAY,CAAC;AAIpB;;;;;;;;;;GAUG;AACH,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