@azure/ai-projects 2.6.0 → 2.7.0
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/README.md +62 -1
- package/dist/browser/aiProjectClient.d.ts +1 -0
- package/dist/browser/aiProjectClient.d.ts.map +1 -1
- package/dist/browser/aiProjectClient.js +16 -1
- package/dist/browser/aiProjectClient.js.map +1 -1
- package/dist/browser/api/agents/index.d.ts +1 -1
- package/dist/browser/api/agents/index.d.ts.map +1 -1
- package/dist/browser/api/agents/index.js.map +1 -1
- package/dist/browser/api/agents/options.d.ts +91 -1
- package/dist/browser/api/agents/options.d.ts.map +1 -1
- package/dist/browser/api/agents/options.js.map +1 -1
- package/dist/browser/api/aiProjectContext.d.ts +3 -0
- package/dist/browser/api/aiProjectContext.d.ts.map +1 -1
- package/dist/browser/api/aiProjectContext.js.map +1 -1
- package/dist/browser/api/beta/agents/index.d.ts +2 -2
- package/dist/browser/api/beta/agents/index.d.ts.map +1 -1
- package/dist/browser/api/beta/agents/index.js +1 -1
- package/dist/browser/api/beta/agents/index.js.map +1 -1
- package/dist/browser/api/beta/agents/operations.d.ts +9 -2
- package/dist/browser/api/beta/agents/operations.d.ts.map +1 -1
- package/dist/browser/api/beta/agents/operations.js +38 -1
- package/dist/browser/api/beta/agents/operations.js.map +1 -1
- package/dist/browser/api/beta/agents/options.d.ts +3 -0
- package/dist/browser/api/beta/agents/options.d.ts.map +1 -1
- package/dist/browser/api/beta/agents/options.js.map +1 -1
- package/dist/browser/api/beta/voiceAgents/conversations/index.d.ts +3 -0
- package/dist/browser/api/beta/voiceAgents/conversations/index.d.ts.map +1 -0
- package/dist/browser/api/beta/voiceAgents/conversations/index.js +4 -0
- package/dist/browser/api/beta/voiceAgents/conversations/index.js.map +1 -0
- package/dist/browser/api/beta/voiceAgents/conversations/operations.d.ts +140 -0
- package/dist/browser/api/beta/voiceAgents/conversations/operations.d.ts.map +1 -0
- package/dist/browser/api/beta/voiceAgents/conversations/operations.js +635 -0
- package/dist/browser/api/beta/voiceAgents/conversations/operations.js.map +1 -0
- package/dist/browser/api/beta/voiceAgents/conversations/options.d.ts +133 -0
- package/dist/browser/api/beta/voiceAgents/conversations/options.d.ts.map +1 -0
- package/dist/browser/api/beta/voiceAgents/conversations/options.js +4 -0
- package/dist/browser/api/beta/voiceAgents/conversations/options.js.map +1 -0
- package/dist/browser/api/beta/voiceAgents/telephony/index.d.ts +3 -0
- package/dist/browser/api/beta/voiceAgents/telephony/index.d.ts.map +1 -0
- package/dist/browser/api/beta/voiceAgents/telephony/index.js +4 -0
- package/dist/browser/api/beta/voiceAgents/telephony/index.js.map +1 -0
- package/dist/browser/api/beta/voiceAgents/telephony/operations.d.ts +62 -0
- package/dist/browser/api/beta/voiceAgents/telephony/operations.d.ts.map +1 -0
- package/dist/browser/api/beta/voiceAgents/telephony/operations.js +559 -0
- package/dist/browser/api/beta/voiceAgents/telephony/operations.js.map +1 -0
- package/dist/browser/api/beta/voiceAgents/telephony/options.d.ts +133 -0
- package/dist/browser/api/beta/voiceAgents/telephony/options.d.ts.map +1 -0
- package/dist/browser/api/beta/voiceAgents/telephony/options.js +4 -0
- package/dist/browser/api/beta/voiceAgents/telephony/options.js.map +1 -0
- package/dist/browser/api/datasets/operations.d.ts.map +1 -1
- package/dist/browser/api/datasets/operations.js +1 -3
- package/dist/browser/api/datasets/operations.js.map +1 -1
- package/dist/browser/api/toolboxes/index.d.ts +2 -2
- package/dist/browser/api/toolboxes/index.d.ts.map +1 -1
- package/dist/browser/api/toolboxes/index.js +1 -1
- package/dist/browser/api/toolboxes/index.js.map +1 -1
- package/dist/browser/api/toolboxes/operations.d.ts +6 -2
- package/dist/browser/api/toolboxes/operations.d.ts.map +1 -1
- package/dist/browser/api/toolboxes/operations.js +33 -0
- package/dist/browser/api/toolboxes/operations.js.map +1 -1
- package/dist/browser/api/toolboxes/options.d.ts +3 -0
- package/dist/browser/api/toolboxes/options.d.ts.map +1 -1
- package/dist/browser/api/toolboxes/options.js.map +1 -1
- package/dist/browser/classic/beta/agents/index.d.ts +8 -3
- package/dist/browser/classic/beta/agents/index.d.ts.map +1 -1
- package/dist/browser/classic/beta/agents/index.js +3 -4
- package/dist/browser/classic/beta/agents/index.js.map +1 -1
- package/dist/browser/classic/beta/index.d.ts +6 -1
- package/dist/browser/classic/beta/index.d.ts.map +1 -1
- package/dist/browser/classic/beta/index.js +4 -1
- package/dist/browser/classic/beta/index.js.map +1 -1
- package/dist/browser/classic/beta/voiceAgents/conversations/index.d.ts +115 -0
- package/dist/browser/classic/beta/voiceAgents/conversations/index.d.ts.map +1 -0
- package/dist/browser/classic/beta/voiceAgents/conversations/index.js +25 -0
- package/dist/browser/classic/beta/voiceAgents/conversations/index.js.map +1 -0
- package/dist/browser/classic/beta/voiceAgents/index.d.ts +16 -0
- package/dist/browser/classic/beta/voiceAgents/index.d.ts.map +1 -0
- package/dist/browser/classic/beta/voiceAgents/index.js +16 -0
- package/dist/browser/classic/beta/voiceAgents/index.js.map +1 -0
- package/dist/browser/classic/beta/voiceAgents/telephony/index.d.ts +37 -0
- package/dist/browser/classic/beta/voiceAgents/telephony/index.d.ts.map +1 -0
- package/dist/browser/classic/beta/voiceAgents/telephony/index.js +25 -0
- package/dist/browser/classic/beta/voiceAgents/telephony/index.js.map +1 -0
- package/dist/browser/classic/index.d.ts +3 -0
- package/dist/browser/classic/index.d.ts.map +1 -1
- package/dist/browser/classic/index.js.map +1 -1
- package/dist/browser/classic/toolboxes/index.d.ts +4 -2
- package/dist/browser/classic/toolboxes/index.d.ts.map +1 -1
- package/dist/browser/classic/toolboxes/index.js +2 -1
- package/dist/browser/classic/toolboxes/index.js.map +1 -1
- package/dist/browser/constants.d.ts +1 -1
- package/dist/browser/constants.js +1 -1
- package/dist/browser/constants.js.map +1 -1
- package/dist/browser/deprecate.interface.d.ts +16 -4
- package/dist/browser/deprecate.interface.d.ts.map +1 -1
- package/dist/browser/deprecate.interface.js.map +1 -1
- package/dist/browser/index.d.ts +15 -4
- package/dist/browser/index.d.ts.map +1 -1
- package/dist/browser/index.js +2 -0
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/models/index.d.ts +2 -1
- package/dist/browser/models/index.d.ts.map +1 -1
- package/dist/browser/models/index.js.map +1 -1
- package/dist/browser/models/models.d.ts +4198 -28
- package/dist/browser/models/models.d.ts.map +1 -1
- package/dist/browser/models/models.js +4881 -22
- package/dist/browser/models/models.js.map +1 -1
- package/dist/browser/package.json +1 -1
- package/dist/browser/realtime/asyncQueue.d.ts +29 -0
- package/dist/browser/realtime/asyncQueue.d.ts.map +1 -0
- package/dist/browser/realtime/asyncQueue.js +105 -0
- package/dist/browser/realtime/asyncQueue.js.map +1 -0
- package/dist/browser/realtime/errors.d.ts +34 -0
- package/dist/browser/realtime/errors.d.ts.map +1 -0
- package/dist/browser/realtime/errors.js +40 -0
- package/dist/browser/realtime/errors.js.map +1 -0
- package/dist/browser/realtime/events.d.ts +24 -0
- package/dist/browser/realtime/events.d.ts.map +1 -0
- package/dist/browser/realtime/events.js +4 -0
- package/dist/browser/realtime/events.js.map +1 -0
- package/dist/browser/realtime/protocol.d.ts +7 -0
- package/dist/browser/realtime/protocol.d.ts.map +1 -0
- package/dist/browser/realtime/protocol.js +262 -0
- package/dist/browser/realtime/protocol.js.map +1 -0
- package/dist/browser/realtime/voiceAgentRealtimeClient.d.ts +145 -0
- package/dist/browser/realtime/voiceAgentRealtimeClient.d.ts.map +1 -0
- package/dist/browser/realtime/voiceAgentRealtimeClient.js +376 -0
- package/dist/browser/realtime/voiceAgentRealtimeClient.js.map +1 -0
- package/dist/browser/realtime/webSocketTransportLike.d.ts +44 -0
- package/dist/browser/realtime/webSocketTransportLike.d.ts.map +1 -0
- package/dist/browser/realtime/webSocketTransportLike.js +4 -0
- package/dist/browser/realtime/webSocketTransportLike.js.map +1 -0
- package/dist/browser/webSocketTransport.d.ts +31 -0
- package/dist/browser/webSocketTransport.d.ts.map +1 -0
- package/dist/browser/webSocketTransport.js +218 -0
- package/dist/browser/webSocketTransport.js.map +1 -0
- package/dist/commonjs/aiProjectClient.d.ts +1 -0
- package/dist/commonjs/aiProjectClient.d.ts.map +1 -1
- package/dist/commonjs/aiProjectClient.js +16 -1
- package/dist/commonjs/aiProjectClient.js.map +2 -2
- package/dist/commonjs/api/agents/index.d.ts +1 -1
- package/dist/commonjs/api/agents/index.d.ts.map +1 -1
- package/dist/commonjs/api/agents/index.js.map +1 -1
- package/dist/commonjs/api/agents/options.d.ts +91 -1
- package/dist/commonjs/api/agents/options.d.ts.map +1 -1
- package/dist/commonjs/api/agents/options.js.map +1 -1
- package/dist/commonjs/api/aiProjectContext.d.ts +3 -0
- package/dist/commonjs/api/aiProjectContext.d.ts.map +1 -1
- package/dist/commonjs/api/aiProjectContext.js.map +2 -2
- package/dist/commonjs/api/beta/agents/index.d.ts +2 -2
- package/dist/commonjs/api/beta/agents/index.d.ts.map +1 -1
- package/dist/commonjs/api/beta/agents/index.js +2 -0
- package/dist/commonjs/api/beta/agents/index.js.map +2 -2
- package/dist/commonjs/api/beta/agents/operations.d.ts +9 -2
- package/dist/commonjs/api/beta/agents/operations.d.ts.map +1 -1
- package/dist/commonjs/api/beta/agents/operations.js +43 -0
- package/dist/commonjs/api/beta/agents/operations.js.map +2 -2
- package/dist/commonjs/api/beta/agents/options.d.ts +3 -0
- package/dist/commonjs/api/beta/agents/options.d.ts.map +1 -1
- package/dist/commonjs/api/beta/agents/options.js.map +1 -1
- package/dist/commonjs/api/beta/voiceAgents/conversations/index.d.ts +3 -0
- package/dist/commonjs/api/beta/voiceAgents/conversations/index.d.ts.map +1 -0
- package/dist/commonjs/api/beta/voiceAgents/conversations/index.js +54 -0
- package/dist/commonjs/api/beta/voiceAgents/conversations/index.js.map +7 -0
- package/dist/commonjs/api/beta/voiceAgents/conversations/operations.d.ts +140 -0
- package/dist/commonjs/api/beta/voiceAgents/conversations/operations.d.ts.map +1 -0
- package/dist/commonjs/api/beta/voiceAgents/conversations/operations.js +747 -0
- package/dist/commonjs/api/beta/voiceAgents/conversations/operations.js.map +7 -0
- package/dist/commonjs/api/beta/voiceAgents/conversations/options.d.ts +133 -0
- package/dist/commonjs/api/beta/voiceAgents/conversations/options.d.ts.map +1 -0
- package/dist/commonjs/api/beta/voiceAgents/conversations/options.js +16 -0
- package/dist/commonjs/api/beta/voiceAgents/conversations/options.js.map +7 -0
- package/dist/commonjs/api/beta/voiceAgents/telephony/index.d.ts +3 -0
- package/dist/commonjs/api/beta/voiceAgents/telephony/index.d.ts.map +1 -0
- package/dist/commonjs/api/beta/voiceAgents/telephony/index.js +54 -0
- package/dist/commonjs/api/beta/voiceAgents/telephony/index.js.map +7 -0
- package/dist/commonjs/api/beta/voiceAgents/telephony/operations.d.ts +62 -0
- package/dist/commonjs/api/beta/voiceAgents/telephony/operations.d.ts.map +1 -0
- package/dist/commonjs/api/beta/voiceAgents/telephony/operations.js +683 -0
- package/dist/commonjs/api/beta/voiceAgents/telephony/operations.js.map +7 -0
- package/dist/commonjs/api/beta/voiceAgents/telephony/options.d.ts +133 -0
- package/dist/commonjs/api/beta/voiceAgents/telephony/options.d.ts.map +1 -0
- package/dist/commonjs/api/beta/voiceAgents/telephony/options.js +16 -0
- package/dist/commonjs/api/beta/voiceAgents/telephony/options.js.map +7 -0
- package/dist/commonjs/api/datasets/operations.d.ts.map +1 -1
- package/dist/commonjs/api/datasets/operations.js +0 -6
- package/dist/commonjs/api/datasets/operations.js.map +2 -2
- package/dist/commonjs/api/toolboxes/index.d.ts +2 -2
- package/dist/commonjs/api/toolboxes/index.d.ts.map +1 -1
- package/dist/commonjs/api/toolboxes/index.js +2 -0
- package/dist/commonjs/api/toolboxes/index.js.map +2 -2
- package/dist/commonjs/api/toolboxes/operations.d.ts +6 -2
- package/dist/commonjs/api/toolboxes/operations.d.ts.map +1 -1
- package/dist/commonjs/api/toolboxes/operations.js +42 -0
- package/dist/commonjs/api/toolboxes/operations.js.map +2 -2
- package/dist/commonjs/api/toolboxes/options.d.ts +3 -0
- package/dist/commonjs/api/toolboxes/options.d.ts.map +1 -1
- package/dist/commonjs/api/toolboxes/options.js.map +1 -1
- package/dist/commonjs/classic/beta/agents/index.d.ts +8 -3
- package/dist/commonjs/classic/beta/agents/index.d.ts.map +1 -1
- package/dist/commonjs/classic/beta/agents/index.js +3 -4
- package/dist/commonjs/classic/beta/agents/index.js.map +2 -2
- package/dist/commonjs/classic/beta/index.d.ts +6 -1
- package/dist/commonjs/classic/beta/index.d.ts.map +1 -1
- package/dist/commonjs/classic/beta/index.js +5 -2
- package/dist/commonjs/classic/beta/index.js.map +2 -2
- package/dist/commonjs/classic/beta/voiceAgents/conversations/index.d.ts +115 -0
- package/dist/commonjs/classic/beta/voiceAgents/conversations/index.d.ts.map +1 -0
- package/dist/commonjs/classic/beta/voiceAgents/conversations/index.js +49 -0
- package/dist/commonjs/classic/beta/voiceAgents/conversations/index.js.map +7 -0
- package/dist/commonjs/classic/beta/voiceAgents/index.d.ts +16 -0
- package/dist/commonjs/classic/beta/voiceAgents/index.d.ts.map +1 -0
- package/dist/commonjs/classic/beta/voiceAgents/index.js +40 -0
- package/dist/commonjs/classic/beta/voiceAgents/index.js.map +7 -0
- package/dist/commonjs/classic/beta/voiceAgents/telephony/index.d.ts +37 -0
- package/dist/commonjs/classic/beta/voiceAgents/telephony/index.d.ts.map +1 -0
- package/dist/commonjs/classic/beta/voiceAgents/telephony/index.js +49 -0
- package/dist/commonjs/classic/beta/voiceAgents/telephony/index.js.map +7 -0
- package/dist/commonjs/classic/index.d.ts +3 -0
- package/dist/commonjs/classic/index.d.ts.map +1 -1
- package/dist/commonjs/classic/index.js.map +1 -1
- package/dist/commonjs/classic/toolboxes/index.d.ts +4 -2
- package/dist/commonjs/classic/toolboxes/index.d.ts.map +1 -1
- package/dist/commonjs/classic/toolboxes/index.js +1 -0
- package/dist/commonjs/classic/toolboxes/index.js.map +2 -2
- package/dist/commonjs/constants.d.ts +1 -1
- package/dist/commonjs/constants.js +1 -1
- package/dist/commonjs/constants.js.map +1 -1
- package/dist/commonjs/deprecate.interface.d.ts +16 -4
- package/dist/commonjs/deprecate.interface.d.ts.map +1 -1
- package/dist/commonjs/deprecate.interface.js.map +1 -1
- package/dist/commonjs/index.d.ts +15 -4
- package/dist/commonjs/index.d.ts.map +1 -1
- package/dist/commonjs/index.js +14 -0
- package/dist/commonjs/index.js.map +2 -2
- package/dist/commonjs/models/index.d.ts +2 -1
- package/dist/commonjs/models/index.d.ts.map +1 -1
- package/dist/commonjs/models/index.js.map +1 -1
- package/dist/commonjs/models/models.d.ts +4198 -28
- package/dist/commonjs/models/models.d.ts.map +1 -1
- package/dist/commonjs/models/models.js +5809 -32
- package/dist/commonjs/models/models.js.map +2 -2
- package/dist/commonjs/package.json +1 -1
- package/dist/commonjs/realtime/asyncQueue.d.ts +29 -0
- package/dist/commonjs/realtime/asyncQueue.d.ts.map +1 -0
- package/dist/commonjs/realtime/asyncQueue.js +127 -0
- package/dist/commonjs/realtime/asyncQueue.js.map +7 -0
- package/dist/commonjs/realtime/errors.d.ts +34 -0
- package/dist/commonjs/realtime/errors.d.ts.map +1 -0
- package/dist/commonjs/realtime/errors.js +66 -0
- package/dist/commonjs/realtime/errors.js.map +7 -0
- package/dist/commonjs/realtime/events.d.ts +24 -0
- package/dist/commonjs/realtime/events.d.ts.map +1 -0
- package/dist/commonjs/realtime/events.js +16 -0
- package/dist/commonjs/realtime/events.js.map +7 -0
- package/dist/commonjs/realtime/protocol.d.ts +7 -0
- package/dist/commonjs/realtime/protocol.d.ts.map +1 -0
- package/dist/commonjs/realtime/protocol.js +297 -0
- package/dist/commonjs/realtime/protocol.js.map +7 -0
- package/dist/commonjs/realtime/voiceAgentRealtimeClient.d.ts +145 -0
- package/dist/commonjs/realtime/voiceAgentRealtimeClient.d.ts.map +1 -0
- package/dist/commonjs/realtime/voiceAgentRealtimeClient.js +443 -0
- package/dist/commonjs/realtime/voiceAgentRealtimeClient.js.map +7 -0
- package/dist/commonjs/realtime/webSocketTransportLike.d.ts +44 -0
- package/dist/commonjs/realtime/webSocketTransportLike.d.ts.map +1 -0
- package/dist/commonjs/realtime/webSocketTransportLike.js +16 -0
- package/dist/commonjs/realtime/webSocketTransportLike.js.map +7 -0
- package/dist/commonjs/tsdoc-metadata.json +1 -1
- package/dist/commonjs/webSocketTransport.d.ts +15 -0
- package/dist/commonjs/webSocketTransport.d.ts.map +1 -0
- package/dist/commonjs/webSocketTransport.js +232 -0
- package/dist/commonjs/webSocketTransport.js.map +7 -0
- package/dist/esm/aiProjectClient.d.ts +1 -0
- package/dist/esm/aiProjectClient.d.ts.map +1 -1
- package/dist/esm/aiProjectClient.js +16 -1
- package/dist/esm/aiProjectClient.js.map +1 -1
- package/dist/esm/api/agents/index.d.ts +1 -1
- package/dist/esm/api/agents/index.d.ts.map +1 -1
- package/dist/esm/api/agents/index.js.map +1 -1
- package/dist/esm/api/agents/options.d.ts +91 -1
- package/dist/esm/api/agents/options.d.ts.map +1 -1
- package/dist/esm/api/agents/options.js.map +1 -1
- package/dist/esm/api/aiProjectContext.d.ts +3 -0
- package/dist/esm/api/aiProjectContext.d.ts.map +1 -1
- package/dist/esm/api/aiProjectContext.js.map +1 -1
- package/dist/esm/api/beta/agents/index.d.ts +2 -2
- package/dist/esm/api/beta/agents/index.d.ts.map +1 -1
- package/dist/esm/api/beta/agents/index.js +1 -1
- package/dist/esm/api/beta/agents/index.js.map +1 -1
- package/dist/esm/api/beta/agents/operations.d.ts +9 -2
- package/dist/esm/api/beta/agents/operations.d.ts.map +1 -1
- package/dist/esm/api/beta/agents/operations.js +38 -1
- package/dist/esm/api/beta/agents/operations.js.map +1 -1
- package/dist/esm/api/beta/agents/options.d.ts +3 -0
- package/dist/esm/api/beta/agents/options.d.ts.map +1 -1
- package/dist/esm/api/beta/agents/options.js.map +1 -1
- package/dist/esm/api/beta/voiceAgents/conversations/index.d.ts +3 -0
- package/dist/esm/api/beta/voiceAgents/conversations/index.d.ts.map +1 -0
- package/dist/esm/api/beta/voiceAgents/conversations/index.js +4 -0
- package/dist/esm/api/beta/voiceAgents/conversations/index.js.map +1 -0
- package/dist/esm/api/beta/voiceAgents/conversations/operations.d.ts +140 -0
- package/dist/esm/api/beta/voiceAgents/conversations/operations.d.ts.map +1 -0
- package/dist/esm/api/beta/voiceAgents/conversations/operations.js +635 -0
- package/dist/esm/api/beta/voiceAgents/conversations/operations.js.map +1 -0
- package/dist/esm/api/beta/voiceAgents/conversations/options.d.ts +133 -0
- package/dist/esm/api/beta/voiceAgents/conversations/options.d.ts.map +1 -0
- package/dist/esm/api/beta/voiceAgents/conversations/options.js +4 -0
- package/dist/esm/api/beta/voiceAgents/conversations/options.js.map +1 -0
- package/dist/esm/api/beta/voiceAgents/telephony/index.d.ts +3 -0
- package/dist/esm/api/beta/voiceAgents/telephony/index.d.ts.map +1 -0
- package/dist/esm/api/beta/voiceAgents/telephony/index.js +4 -0
- package/dist/esm/api/beta/voiceAgents/telephony/index.js.map +1 -0
- package/dist/esm/api/beta/voiceAgents/telephony/operations.d.ts +62 -0
- package/dist/esm/api/beta/voiceAgents/telephony/operations.d.ts.map +1 -0
- package/dist/esm/api/beta/voiceAgents/telephony/operations.js +559 -0
- package/dist/esm/api/beta/voiceAgents/telephony/operations.js.map +1 -0
- package/dist/esm/api/beta/voiceAgents/telephony/options.d.ts +133 -0
- package/dist/esm/api/beta/voiceAgents/telephony/options.d.ts.map +1 -0
- package/dist/esm/api/beta/voiceAgents/telephony/options.js +4 -0
- package/dist/esm/api/beta/voiceAgents/telephony/options.js.map +1 -0
- package/dist/esm/api/datasets/operations.d.ts.map +1 -1
- package/dist/esm/api/datasets/operations.js +1 -3
- package/dist/esm/api/datasets/operations.js.map +1 -1
- package/dist/esm/api/toolboxes/index.d.ts +2 -2
- package/dist/esm/api/toolboxes/index.d.ts.map +1 -1
- package/dist/esm/api/toolboxes/index.js +1 -1
- package/dist/esm/api/toolboxes/index.js.map +1 -1
- package/dist/esm/api/toolboxes/operations.d.ts +6 -2
- package/dist/esm/api/toolboxes/operations.d.ts.map +1 -1
- package/dist/esm/api/toolboxes/operations.js +33 -0
- package/dist/esm/api/toolboxes/operations.js.map +1 -1
- package/dist/esm/api/toolboxes/options.d.ts +3 -0
- package/dist/esm/api/toolboxes/options.d.ts.map +1 -1
- package/dist/esm/api/toolboxes/options.js.map +1 -1
- package/dist/esm/classic/beta/agents/index.d.ts +8 -3
- package/dist/esm/classic/beta/agents/index.d.ts.map +1 -1
- package/dist/esm/classic/beta/agents/index.js +3 -4
- package/dist/esm/classic/beta/agents/index.js.map +1 -1
- package/dist/esm/classic/beta/index.d.ts +6 -1
- package/dist/esm/classic/beta/index.d.ts.map +1 -1
- package/dist/esm/classic/beta/index.js +4 -1
- package/dist/esm/classic/beta/index.js.map +1 -1
- package/dist/esm/classic/beta/voiceAgents/conversations/index.d.ts +115 -0
- package/dist/esm/classic/beta/voiceAgents/conversations/index.d.ts.map +1 -0
- package/dist/esm/classic/beta/voiceAgents/conversations/index.js +25 -0
- package/dist/esm/classic/beta/voiceAgents/conversations/index.js.map +1 -0
- package/dist/esm/classic/beta/voiceAgents/index.d.ts +16 -0
- package/dist/esm/classic/beta/voiceAgents/index.d.ts.map +1 -0
- package/dist/esm/classic/beta/voiceAgents/index.js +16 -0
- package/dist/esm/classic/beta/voiceAgents/index.js.map +1 -0
- package/dist/esm/classic/beta/voiceAgents/telephony/index.d.ts +37 -0
- package/dist/esm/classic/beta/voiceAgents/telephony/index.d.ts.map +1 -0
- package/dist/esm/classic/beta/voiceAgents/telephony/index.js +25 -0
- package/dist/esm/classic/beta/voiceAgents/telephony/index.js.map +1 -0
- package/dist/esm/classic/index.d.ts +3 -0
- package/dist/esm/classic/index.d.ts.map +1 -1
- package/dist/esm/classic/index.js.map +1 -1
- package/dist/esm/classic/toolboxes/index.d.ts +4 -2
- package/dist/esm/classic/toolboxes/index.d.ts.map +1 -1
- package/dist/esm/classic/toolboxes/index.js +2 -1
- package/dist/esm/classic/toolboxes/index.js.map +1 -1
- package/dist/esm/constants.d.ts +1 -1
- package/dist/esm/constants.js +1 -1
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/deprecate.interface.d.ts +16 -4
- package/dist/esm/deprecate.interface.d.ts.map +1 -1
- package/dist/esm/deprecate.interface.js.map +1 -1
- package/dist/esm/index.d.ts +15 -4
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/models/index.d.ts +2 -1
- package/dist/esm/models/index.d.ts.map +1 -1
- package/dist/esm/models/index.js.map +1 -1
- package/dist/esm/models/models.d.ts +4198 -28
- package/dist/esm/models/models.d.ts.map +1 -1
- package/dist/esm/models/models.js +4881 -22
- package/dist/esm/models/models.js.map +1 -1
- package/dist/esm/package.json +1 -1
- package/dist/esm/realtime/asyncQueue.d.ts +29 -0
- package/dist/esm/realtime/asyncQueue.d.ts.map +1 -0
- package/dist/esm/realtime/asyncQueue.js +105 -0
- package/dist/esm/realtime/asyncQueue.js.map +1 -0
- package/dist/esm/realtime/errors.d.ts +34 -0
- package/dist/esm/realtime/errors.d.ts.map +1 -0
- package/dist/esm/realtime/errors.js +40 -0
- package/dist/esm/realtime/errors.js.map +1 -0
- package/dist/esm/realtime/events.d.ts +24 -0
- package/dist/esm/realtime/events.d.ts.map +1 -0
- package/dist/esm/realtime/events.js +4 -0
- package/dist/esm/realtime/events.js.map +1 -0
- package/dist/esm/realtime/protocol.d.ts +7 -0
- package/dist/esm/realtime/protocol.d.ts.map +1 -0
- package/dist/esm/realtime/protocol.js +262 -0
- package/dist/esm/realtime/protocol.js.map +1 -0
- package/dist/esm/realtime/voiceAgentRealtimeClient.d.ts +145 -0
- package/dist/esm/realtime/voiceAgentRealtimeClient.d.ts.map +1 -0
- package/dist/esm/realtime/voiceAgentRealtimeClient.js +376 -0
- package/dist/esm/realtime/voiceAgentRealtimeClient.js.map +1 -0
- package/dist/esm/realtime/webSocketTransportLike.d.ts +44 -0
- package/dist/esm/realtime/webSocketTransportLike.d.ts.map +1 -0
- package/dist/esm/realtime/webSocketTransportLike.js +4 -0
- package/dist/esm/realtime/webSocketTransportLike.js.map +1 -0
- package/dist/esm/webSocketTransport.d.ts +15 -0
- package/dist/esm/webSocketTransport.d.ts.map +1 -0
- package/dist/esm/webSocketTransport.js +220 -0
- package/dist/esm/webSocketTransport.js.map +1 -0
- package/dist/react-native/aiProjectClient.d.ts +1 -0
- package/dist/react-native/aiProjectClient.d.ts.map +1 -1
- package/dist/react-native/aiProjectClient.js +16 -1
- package/dist/react-native/aiProjectClient.js.map +1 -1
- package/dist/react-native/api/agents/index.d.ts +1 -1
- package/dist/react-native/api/agents/index.d.ts.map +1 -1
- package/dist/react-native/api/agents/index.js.map +1 -1
- package/dist/react-native/api/agents/options.d.ts +91 -1
- package/dist/react-native/api/agents/options.d.ts.map +1 -1
- package/dist/react-native/api/agents/options.js.map +1 -1
- package/dist/react-native/api/aiProjectContext.d.ts +3 -0
- package/dist/react-native/api/aiProjectContext.d.ts.map +1 -1
- package/dist/react-native/api/aiProjectContext.js.map +1 -1
- package/dist/react-native/api/beta/agents/index.d.ts +2 -2
- package/dist/react-native/api/beta/agents/index.d.ts.map +1 -1
- package/dist/react-native/api/beta/agents/index.js +1 -1
- package/dist/react-native/api/beta/agents/index.js.map +1 -1
- package/dist/react-native/api/beta/agents/operations.d.ts +9 -2
- package/dist/react-native/api/beta/agents/operations.d.ts.map +1 -1
- package/dist/react-native/api/beta/agents/operations.js +38 -1
- package/dist/react-native/api/beta/agents/operations.js.map +1 -1
- package/dist/react-native/api/beta/agents/options.d.ts +3 -0
- package/dist/react-native/api/beta/agents/options.d.ts.map +1 -1
- package/dist/react-native/api/beta/agents/options.js.map +1 -1
- package/dist/react-native/api/beta/voiceAgents/conversations/index.d.ts +3 -0
- package/dist/react-native/api/beta/voiceAgents/conversations/index.d.ts.map +1 -0
- package/dist/react-native/api/beta/voiceAgents/conversations/index.js +4 -0
- package/dist/react-native/api/beta/voiceAgents/conversations/index.js.map +1 -0
- package/dist/react-native/api/beta/voiceAgents/conversations/operations.d.ts +140 -0
- package/dist/react-native/api/beta/voiceAgents/conversations/operations.d.ts.map +1 -0
- package/dist/react-native/api/beta/voiceAgents/conversations/operations.js +635 -0
- package/dist/react-native/api/beta/voiceAgents/conversations/operations.js.map +1 -0
- package/dist/react-native/api/beta/voiceAgents/conversations/options.d.ts +133 -0
- package/dist/react-native/api/beta/voiceAgents/conversations/options.d.ts.map +1 -0
- package/dist/react-native/api/beta/voiceAgents/conversations/options.js +4 -0
- package/dist/react-native/api/beta/voiceAgents/conversations/options.js.map +1 -0
- package/dist/react-native/api/beta/voiceAgents/telephony/index.d.ts +3 -0
- package/dist/react-native/api/beta/voiceAgents/telephony/index.d.ts.map +1 -0
- package/dist/react-native/api/beta/voiceAgents/telephony/index.js +4 -0
- package/dist/react-native/api/beta/voiceAgents/telephony/index.js.map +1 -0
- package/dist/react-native/api/beta/voiceAgents/telephony/operations.d.ts +62 -0
- package/dist/react-native/api/beta/voiceAgents/telephony/operations.d.ts.map +1 -0
- package/dist/react-native/api/beta/voiceAgents/telephony/operations.js +559 -0
- package/dist/react-native/api/beta/voiceAgents/telephony/operations.js.map +1 -0
- package/dist/react-native/api/beta/voiceAgents/telephony/options.d.ts +133 -0
- package/dist/react-native/api/beta/voiceAgents/telephony/options.d.ts.map +1 -0
- package/dist/react-native/api/beta/voiceAgents/telephony/options.js +4 -0
- package/dist/react-native/api/beta/voiceAgents/telephony/options.js.map +1 -0
- package/dist/react-native/api/datasets/operations.d.ts.map +1 -1
- package/dist/react-native/api/datasets/operations.js +1 -3
- package/dist/react-native/api/datasets/operations.js.map +1 -1
- package/dist/react-native/api/toolboxes/index.d.ts +2 -2
- package/dist/react-native/api/toolboxes/index.d.ts.map +1 -1
- package/dist/react-native/api/toolboxes/index.js +1 -1
- package/dist/react-native/api/toolboxes/index.js.map +1 -1
- package/dist/react-native/api/toolboxes/operations.d.ts +6 -2
- package/dist/react-native/api/toolboxes/operations.d.ts.map +1 -1
- package/dist/react-native/api/toolboxes/operations.js +33 -0
- package/dist/react-native/api/toolboxes/operations.js.map +1 -1
- package/dist/react-native/api/toolboxes/options.d.ts +3 -0
- package/dist/react-native/api/toolboxes/options.d.ts.map +1 -1
- package/dist/react-native/api/toolboxes/options.js.map +1 -1
- package/dist/react-native/classic/beta/agents/index.d.ts +8 -3
- package/dist/react-native/classic/beta/agents/index.d.ts.map +1 -1
- package/dist/react-native/classic/beta/agents/index.js +3 -4
- package/dist/react-native/classic/beta/agents/index.js.map +1 -1
- package/dist/react-native/classic/beta/index.d.ts +6 -1
- package/dist/react-native/classic/beta/index.d.ts.map +1 -1
- package/dist/react-native/classic/beta/index.js +4 -1
- package/dist/react-native/classic/beta/index.js.map +1 -1
- package/dist/react-native/classic/beta/voiceAgents/conversations/index.d.ts +115 -0
- package/dist/react-native/classic/beta/voiceAgents/conversations/index.d.ts.map +1 -0
- package/dist/react-native/classic/beta/voiceAgents/conversations/index.js +25 -0
- package/dist/react-native/classic/beta/voiceAgents/conversations/index.js.map +1 -0
- package/dist/react-native/classic/beta/voiceAgents/index.d.ts +16 -0
- package/dist/react-native/classic/beta/voiceAgents/index.d.ts.map +1 -0
- package/dist/react-native/classic/beta/voiceAgents/index.js +16 -0
- package/dist/react-native/classic/beta/voiceAgents/index.js.map +1 -0
- package/dist/react-native/classic/beta/voiceAgents/telephony/index.d.ts +37 -0
- package/dist/react-native/classic/beta/voiceAgents/telephony/index.d.ts.map +1 -0
- package/dist/react-native/classic/beta/voiceAgents/telephony/index.js +25 -0
- package/dist/react-native/classic/beta/voiceAgents/telephony/index.js.map +1 -0
- package/dist/react-native/classic/index.d.ts +3 -0
- package/dist/react-native/classic/index.d.ts.map +1 -1
- package/dist/react-native/classic/index.js.map +1 -1
- package/dist/react-native/classic/toolboxes/index.d.ts +4 -2
- package/dist/react-native/classic/toolboxes/index.d.ts.map +1 -1
- package/dist/react-native/classic/toolboxes/index.js +2 -1
- package/dist/react-native/classic/toolboxes/index.js.map +1 -1
- package/dist/react-native/constants.d.ts +1 -1
- package/dist/react-native/constants.js +1 -1
- package/dist/react-native/constants.js.map +1 -1
- package/dist/react-native/deprecate.interface.d.ts +16 -4
- package/dist/react-native/deprecate.interface.d.ts.map +1 -1
- package/dist/react-native/deprecate.interface.js.map +1 -1
- package/dist/react-native/index.d.ts +15 -4
- package/dist/react-native/index.d.ts.map +1 -1
- package/dist/react-native/index.js +2 -0
- package/dist/react-native/index.js.map +1 -1
- package/dist/react-native/models/index.d.ts +2 -1
- package/dist/react-native/models/index.d.ts.map +1 -1
- package/dist/react-native/models/index.js.map +1 -1
- package/dist/react-native/models/models.d.ts +4198 -28
- package/dist/react-native/models/models.d.ts.map +1 -1
- package/dist/react-native/models/models.js +4881 -22
- package/dist/react-native/models/models.js.map +1 -1
- package/dist/react-native/package.json +1 -1
- package/dist/react-native/realtime/asyncQueue.d.ts +29 -0
- package/dist/react-native/realtime/asyncQueue.d.ts.map +1 -0
- package/dist/react-native/realtime/asyncQueue.js +105 -0
- package/dist/react-native/realtime/asyncQueue.js.map +1 -0
- package/dist/react-native/realtime/errors.d.ts +34 -0
- package/dist/react-native/realtime/errors.d.ts.map +1 -0
- package/dist/react-native/realtime/errors.js +40 -0
- package/dist/react-native/realtime/errors.js.map +1 -0
- package/dist/react-native/realtime/events.d.ts +24 -0
- package/dist/react-native/realtime/events.d.ts.map +1 -0
- package/dist/react-native/realtime/events.js +4 -0
- package/dist/react-native/realtime/events.js.map +1 -0
- package/dist/react-native/realtime/protocol.d.ts +7 -0
- package/dist/react-native/realtime/protocol.d.ts.map +1 -0
- package/dist/react-native/realtime/protocol.js +262 -0
- package/dist/react-native/realtime/protocol.js.map +1 -0
- package/dist/react-native/realtime/voiceAgentRealtimeClient.d.ts +145 -0
- package/dist/react-native/realtime/voiceAgentRealtimeClient.d.ts.map +1 -0
- package/dist/react-native/realtime/voiceAgentRealtimeClient.js +376 -0
- package/dist/react-native/realtime/voiceAgentRealtimeClient.js.map +1 -0
- package/dist/react-native/realtime/webSocketTransportLike.d.ts +44 -0
- package/dist/react-native/realtime/webSocketTransportLike.d.ts.map +1 -0
- package/dist/react-native/realtime/webSocketTransportLike.js +4 -0
- package/dist/react-native/realtime/webSocketTransportLike.js.map +1 -0
- package/dist/react-native/webSocketTransport-browser.d.mts +31 -0
- package/dist/react-native/webSocketTransport-browser.d.mts.map +1 -0
- package/dist/react-native/webSocketTransport-browser.mjs +218 -0
- package/dist/react-native/webSocketTransport-browser.mjs.map +1 -0
- package/dist/react-native/webSocketTransport.d.ts +2 -0
- package/dist/react-native/webSocketTransport.d.ts.map +1 -0
- package/dist/react-native/webSocketTransport.js +6 -0
- package/dist/react-native/webSocketTransport.js.map +1 -0
- package/package.json +8 -6
|
@@ -0,0 +1,443 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var voiceAgentRealtimeClient_exports = {};
|
|
29
|
+
__export(voiceAgentRealtimeClient_exports, {
|
|
30
|
+
KnownVoiceAgentConnectionState: () => KnownVoiceAgentConnectionState,
|
|
31
|
+
VoiceAgentRealtimeClient: () => VoiceAgentRealtimeClient
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(voiceAgentRealtimeClient_exports);
|
|
34
|
+
var import_core_util = require("@azure/core-util");
|
|
35
|
+
var import_constants = require("../constants.js");
|
|
36
|
+
var import_logger = require("../logger.js");
|
|
37
|
+
var import_asyncQueue = require("./asyncQueue.js");
|
|
38
|
+
var import_errors = require("./errors.js");
|
|
39
|
+
var import_protocol = require("./protocol.js");
|
|
40
|
+
const defaultCredentialScope = "https://ai.azure.com/.default";
|
|
41
|
+
const voiceAgentsPreview = "VoiceAgents=V1Preview";
|
|
42
|
+
const KnownVoiceAgentConnectionState = {
|
|
43
|
+
Disconnected: "disconnected",
|
|
44
|
+
Connecting: "connecting",
|
|
45
|
+
Connected: "connected",
|
|
46
|
+
Closing: "closing"
|
|
47
|
+
};
|
|
48
|
+
class VoiceAgentRealtimeClient {
|
|
49
|
+
endpoint;
|
|
50
|
+
credential;
|
|
51
|
+
options;
|
|
52
|
+
constructor(endpoint, credential, options = {}) {
|
|
53
|
+
if (!endpoint.trim()) {
|
|
54
|
+
throw new TypeError("endpoint must not be empty.");
|
|
55
|
+
}
|
|
56
|
+
this.endpoint = endpoint;
|
|
57
|
+
this.credential = credential;
|
|
58
|
+
this.options = {
|
|
59
|
+
...options,
|
|
60
|
+
connectionTimeoutInMs: options.connectionTimeoutInMs ?? 3e4,
|
|
61
|
+
apiVersion: options.apiVersion ?? "v1"
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
/** Establishes a WebSocket connection to a managed voice agent. */
|
|
65
|
+
async connect(agentName, options = {}) {
|
|
66
|
+
if (!agentName.trim()) {
|
|
67
|
+
throw new TypeError("agentName must not be empty.");
|
|
68
|
+
}
|
|
69
|
+
const factory = this.options.webSocketFactory ?? (await import("../webSocketTransport.js")).createDefaultVoiceAgentWebSocketFactory();
|
|
70
|
+
const connection = new VoiceAgentConnectionImpl(
|
|
71
|
+
normalizeEndpoint(this.endpoint),
|
|
72
|
+
agentName,
|
|
73
|
+
this.credential,
|
|
74
|
+
this.options,
|
|
75
|
+
options,
|
|
76
|
+
factory
|
|
77
|
+
);
|
|
78
|
+
await connection.open();
|
|
79
|
+
return connection;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
class VoiceAgentConnectionImpl {
|
|
83
|
+
constructor(endpoint, agentName, credential, clientOptions, connectOptions, factory) {
|
|
84
|
+
this.endpoint = endpoint;
|
|
85
|
+
this.agentName = agentName;
|
|
86
|
+
this.credential = credential;
|
|
87
|
+
this.clientOptions = clientOptions;
|
|
88
|
+
this.connectOptions = connectOptions;
|
|
89
|
+
this.events = new import_asyncQueue.AsyncQueue(1e4, {
|
|
90
|
+
onOverflow: (error) => this.handleEventQueueOverflow(error)
|
|
91
|
+
});
|
|
92
|
+
this.transport = factory.create();
|
|
93
|
+
this.closePromise = new Promise((resolve) => {
|
|
94
|
+
this.resolveClose = resolve;
|
|
95
|
+
});
|
|
96
|
+
this.transport.setHandlers({
|
|
97
|
+
onMessage: (data) => this.handleMessage(data),
|
|
98
|
+
onClose: (code, reason, wasClean) => this.handleClose(code, reason, wasClean),
|
|
99
|
+
onError: (error) => this.handleTransportError(error)
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
endpoint;
|
|
103
|
+
agentName;
|
|
104
|
+
credential;
|
|
105
|
+
clientOptions;
|
|
106
|
+
connectOptions;
|
|
107
|
+
events;
|
|
108
|
+
transport;
|
|
109
|
+
closePromise;
|
|
110
|
+
resolveClose;
|
|
111
|
+
currentState = KnownVoiceAgentConnectionState.Disconnected;
|
|
112
|
+
iteratorStarted = false;
|
|
113
|
+
finished = false;
|
|
114
|
+
get state() {
|
|
115
|
+
return this.currentState;
|
|
116
|
+
}
|
|
117
|
+
get closed() {
|
|
118
|
+
return this.closePromise;
|
|
119
|
+
}
|
|
120
|
+
async open() {
|
|
121
|
+
this.setState(KnownVoiceAgentConnectionState.Connecting);
|
|
122
|
+
let token;
|
|
123
|
+
try {
|
|
124
|
+
const accessToken = await this.credential.getToken(
|
|
125
|
+
this.clientOptions.credentialScopes ?? defaultCredentialScope,
|
|
126
|
+
{ abortSignal: this.connectOptions.abortSignal }
|
|
127
|
+
);
|
|
128
|
+
if (!accessToken) {
|
|
129
|
+
throw new import_errors.VoiceAgentAuthenticationError("The credential returned no access token.");
|
|
130
|
+
}
|
|
131
|
+
token = accessToken.token;
|
|
132
|
+
} catch (error) {
|
|
133
|
+
if (this.connectOptions.abortSignal?.aborted) {
|
|
134
|
+
const cancelledError = new import_errors.VoiceAgentConnectionError(
|
|
135
|
+
"Voice-agent connection was cancelled.",
|
|
136
|
+
"operationCancelled",
|
|
137
|
+
{ cause: error }
|
|
138
|
+
);
|
|
139
|
+
this.finish(1006, cancelledError.message, false, cancelledError);
|
|
140
|
+
throw cancelledError;
|
|
141
|
+
}
|
|
142
|
+
const authenticationError = error instanceof import_errors.VoiceAgentAuthenticationError ? error : new import_errors.VoiceAgentAuthenticationError("Failed to acquire a Voice Agents access token.", {
|
|
143
|
+
cause: error
|
|
144
|
+
});
|
|
145
|
+
this.finish(1006, authenticationError.message, false, authenticationError);
|
|
146
|
+
throw authenticationError;
|
|
147
|
+
}
|
|
148
|
+
try {
|
|
149
|
+
await this.transport.connect({
|
|
150
|
+
url: buildWebSocketUrl(
|
|
151
|
+
this.endpoint,
|
|
152
|
+
this.agentName,
|
|
153
|
+
this.clientOptions.apiVersion,
|
|
154
|
+
this.connectOptions
|
|
155
|
+
),
|
|
156
|
+
protocols: ["realtime"],
|
|
157
|
+
headers: buildHeaders(token, this.clientOptions, this.connectOptions),
|
|
158
|
+
connectionTimeoutInMs: this.connectOptions.connectionTimeoutInMs ?? this.clientOptions.connectionTimeoutInMs,
|
|
159
|
+
abortSignal: this.connectOptions.abortSignal
|
|
160
|
+
});
|
|
161
|
+
this.setState(KnownVoiceAgentConnectionState.Connected);
|
|
162
|
+
import_logger.logger.info("Connected to voice agent", { agentName: this.agentName });
|
|
163
|
+
} catch (error) {
|
|
164
|
+
const cancelled = this.connectOptions.abortSignal?.aborted === true;
|
|
165
|
+
const connectionError = new import_errors.VoiceAgentConnectionError(
|
|
166
|
+
cancelled ? "Voice-agent connection was cancelled." : "Failed to connect to the voice agent.",
|
|
167
|
+
cancelled ? "operationCancelled" : "connectionFailed",
|
|
168
|
+
{ cause: error }
|
|
169
|
+
);
|
|
170
|
+
this.finish(1006, connectionError.message, false, connectionError);
|
|
171
|
+
throw connectionError;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
async sendEvent(event, options = {}) {
|
|
175
|
+
if (this.state !== KnownVoiceAgentConnectionState.Connected) {
|
|
176
|
+
throw new import_errors.VoiceAgentConnectionError(
|
|
177
|
+
`Cannot send while the connection is ${this.state}.`,
|
|
178
|
+
"invalidState"
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
if (options.abortSignal?.aborted) {
|
|
182
|
+
throw new import_errors.VoiceAgentConnectionError("Send operation was cancelled.", "operationCancelled");
|
|
183
|
+
}
|
|
184
|
+
try {
|
|
185
|
+
await this.transport.send((0, import_protocol.serializeVoiceAgentClientEvent)(event), options.abortSignal);
|
|
186
|
+
} catch (error) {
|
|
187
|
+
if (error instanceof import_errors.VoiceAgentProtocolError) {
|
|
188
|
+
throw error;
|
|
189
|
+
}
|
|
190
|
+
throw new import_errors.VoiceAgentConnectionError("Failed to send a voice-agent event.", "sendFailed", {
|
|
191
|
+
cause: error
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
configureSession(session, options = {}) {
|
|
196
|
+
return this.sendEvent({ type: "session.update", event_id: options.eventId, session }, options);
|
|
197
|
+
}
|
|
198
|
+
async sendText(text, options = {}) {
|
|
199
|
+
await this.sendEvent(
|
|
200
|
+
{
|
|
201
|
+
type: "conversation.item.create",
|
|
202
|
+
event_id: options.eventId,
|
|
203
|
+
previous_item_id: options.previousItemId,
|
|
204
|
+
// `RealtimeConversationItemUnion` no longer enumerates a "message" item in the generated
|
|
205
|
+
// models, but the wire protocol still accepts this shape; see the TypeSpec regeneration
|
|
206
|
+
// report for details.
|
|
207
|
+
item: {
|
|
208
|
+
type: "message",
|
|
209
|
+
role: "user",
|
|
210
|
+
content: [{ type: "input_text", text }]
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
options
|
|
214
|
+
);
|
|
215
|
+
if (options.createResponse !== false) {
|
|
216
|
+
await this.requestResponse({ abortSignal: options.abortSignal });
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
sendAudio(audio, options = {}) {
|
|
220
|
+
const bytes = audio instanceof Uint8Array ? audio : new Uint8Array(audio);
|
|
221
|
+
return this.sendEvent(
|
|
222
|
+
{
|
|
223
|
+
type: "input_audio_buffer.append",
|
|
224
|
+
event_id: options.eventId,
|
|
225
|
+
audio: (0, import_core_util.uint8ArrayToString)(bytes, "base64")
|
|
226
|
+
},
|
|
227
|
+
options
|
|
228
|
+
);
|
|
229
|
+
}
|
|
230
|
+
commitAudio(options = {}) {
|
|
231
|
+
return this.sendEvent(
|
|
232
|
+
{ type: "input_audio_buffer.commit", event_id: options.eventId },
|
|
233
|
+
options
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
clearInputAudio(options = {}) {
|
|
237
|
+
return this.sendEvent({ type: "input_audio_buffer.clear", event_id: options.eventId }, options);
|
|
238
|
+
}
|
|
239
|
+
clearOutputAudio(options = {}) {
|
|
240
|
+
return this.sendEvent(
|
|
241
|
+
{ type: "output_audio_buffer.clear", event_id: options.eventId },
|
|
242
|
+
options
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
async sendToolOutput(callId, output, options = {}) {
|
|
246
|
+
await this.sendEvent(
|
|
247
|
+
{
|
|
248
|
+
type: "conversation.item.create",
|
|
249
|
+
event_id: options.eventId,
|
|
250
|
+
item: { type: "function_call_output", call_id: callId, output }
|
|
251
|
+
},
|
|
252
|
+
options
|
|
253
|
+
);
|
|
254
|
+
if (options.createResponse !== false) {
|
|
255
|
+
await this.requestResponse({ abortSignal: options.abortSignal });
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
requestResponse(options = {}) {
|
|
259
|
+
return this.sendEvent(
|
|
260
|
+
{ type: "response.create", event_id: options.eventId, response: options.response },
|
|
261
|
+
options
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
cancelResponse(options = {}) {
|
|
265
|
+
return this.sendEvent(
|
|
266
|
+
{ type: "response.cancel", event_id: options.eventId, response_id: options.responseId },
|
|
267
|
+
options
|
|
268
|
+
);
|
|
269
|
+
}
|
|
270
|
+
async close(code = 1e3, reason = "Client closed the voice-agent connection.") {
|
|
271
|
+
if (this.state === KnownVoiceAgentConnectionState.Disconnected || this.state === KnownVoiceAgentConnectionState.Closing) {
|
|
272
|
+
await this.closed;
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
this.setState(KnownVoiceAgentConnectionState.Closing);
|
|
276
|
+
try {
|
|
277
|
+
await this.transport.close(code, reason);
|
|
278
|
+
} finally {
|
|
279
|
+
this.finish(code, reason, false);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
dispose() {
|
|
283
|
+
return this.close();
|
|
284
|
+
}
|
|
285
|
+
async *[Symbol.asyncIterator]() {
|
|
286
|
+
if (this.iteratorStarted) {
|
|
287
|
+
throw new import_errors.VoiceAgentConnectionError(
|
|
288
|
+
"A voice-agent connection supports one active event iterator.",
|
|
289
|
+
"invalidState"
|
|
290
|
+
);
|
|
291
|
+
}
|
|
292
|
+
this.iteratorStarted = true;
|
|
293
|
+
try {
|
|
294
|
+
while (true) {
|
|
295
|
+
const result = await this.events.next();
|
|
296
|
+
if (result.done) {
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
yield result.value;
|
|
300
|
+
}
|
|
301
|
+
} finally {
|
|
302
|
+
if (this.state === KnownVoiceAgentConnectionState.Connected) {
|
|
303
|
+
await this.close();
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
handleMessage(data) {
|
|
308
|
+
try {
|
|
309
|
+
this.events.enqueue((0, import_protocol.deserializeVoiceAgentServerEvent)(data));
|
|
310
|
+
} catch (error) {
|
|
311
|
+
const protocolError = error instanceof import_errors.VoiceAgentProtocolError ? error : new import_errors.VoiceAgentProtocolError("Failed to process a voice-agent event.", { cause: error });
|
|
312
|
+
this.finish(1002, protocolError.message, false, protocolError);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
handleEventQueueOverflow(cause) {
|
|
316
|
+
if (this.finished) {
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
const error = new import_errors.VoiceAgentConnectionError(cause.message, "connectionClosed", {
|
|
320
|
+
cause
|
|
321
|
+
});
|
|
322
|
+
this.finish(1006, error.message, false, error);
|
|
323
|
+
}
|
|
324
|
+
handleClose(code, reason, wasClean) {
|
|
325
|
+
if (this.finished) {
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
if (wasClean || this.state === KnownVoiceAgentConnectionState.Closing) {
|
|
329
|
+
this.finish(code, reason, wasClean);
|
|
330
|
+
} else {
|
|
331
|
+
const error = new import_errors.VoiceAgentConnectionError(
|
|
332
|
+
`Voice-agent connection closed unexpectedly (${code}${reason ? `: ${reason}` : ""}).`,
|
|
333
|
+
"connectionClosed",
|
|
334
|
+
{ closeCode: code }
|
|
335
|
+
);
|
|
336
|
+
this.finish(code, reason, false, error);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
handleTransportError(cause) {
|
|
340
|
+
if (this.finished) {
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
const error = new import_errors.VoiceAgentConnectionError(
|
|
344
|
+
"Voice-agent WebSocket transport failed.",
|
|
345
|
+
"connectionClosed",
|
|
346
|
+
{
|
|
347
|
+
cause
|
|
348
|
+
}
|
|
349
|
+
);
|
|
350
|
+
this.finish(1006, cause.message, false, error);
|
|
351
|
+
}
|
|
352
|
+
finish(code, reason, wasClean, error) {
|
|
353
|
+
if (this.finished) {
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
this.finished = true;
|
|
357
|
+
if (error) {
|
|
358
|
+
this.events.fail(error);
|
|
359
|
+
} else {
|
|
360
|
+
this.events.close();
|
|
361
|
+
}
|
|
362
|
+
this.setState(KnownVoiceAgentConnectionState.Disconnected);
|
|
363
|
+
this.resolveClose({ code, reason, wasClean, error });
|
|
364
|
+
import_logger.logger.info("Voice-agent connection closed", { code, reason, wasClean });
|
|
365
|
+
void this.closeTransportQuietly(code, reason);
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Closes the transport, logging rather than rejecting: this is best-effort cleanup running after
|
|
369
|
+
* the connection has already settled. A no-op if the transport is already closed.
|
|
370
|
+
*/
|
|
371
|
+
async closeTransportQuietly(code, reason) {
|
|
372
|
+
try {
|
|
373
|
+
await this.transport.close(code, reason);
|
|
374
|
+
} catch (error) {
|
|
375
|
+
import_logger.logger.warning("Failed to close the voice-agent transport", { error });
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
setState(state) {
|
|
379
|
+
if (state === this.currentState) {
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
const previousState = this.currentState;
|
|
383
|
+
this.currentState = state;
|
|
384
|
+
try {
|
|
385
|
+
this.connectOptions.onConnectionStateChange?.(state, previousState);
|
|
386
|
+
} catch (error) {
|
|
387
|
+
import_logger.logger.warning("onConnectionStateChange callback threw an error", { error });
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
function normalizeEndpoint(endpoint) {
|
|
392
|
+
const normalized = endpoint.trim();
|
|
393
|
+
if (!normalized) {
|
|
394
|
+
throw new TypeError("endpoint must not be empty.");
|
|
395
|
+
}
|
|
396
|
+
const url = new URL(normalized.includes("://") ? normalized : `https://${normalized}`);
|
|
397
|
+
if (url.protocol !== "https:") {
|
|
398
|
+
throw new TypeError(
|
|
399
|
+
"endpoint must use https; a plaintext endpoint would send the bearer token over an unencrypted connection."
|
|
400
|
+
);
|
|
401
|
+
}
|
|
402
|
+
return url.toString().replace(/\/$/, "");
|
|
403
|
+
}
|
|
404
|
+
function buildWebSocketUrl(endpoint, agentName, apiVersion, options) {
|
|
405
|
+
const url = new URL(endpoint);
|
|
406
|
+
url.protocol = "wss:";
|
|
407
|
+
url.pathname = `${url.pathname.replace(/\/$/, "")}/agents/${encodeURIComponent(agentName)}/endpoint/protocols/voice`;
|
|
408
|
+
url.searchParams.set("api-version", apiVersion);
|
|
409
|
+
url.searchParams.set("x-ms-client-sdk", `azsdk-js-ai-projects/${import_constants.SDK_VERSION}`);
|
|
410
|
+
if (options.agentSessionId) {
|
|
411
|
+
url.searchParams.set("agent_session_id", options.agentSessionId);
|
|
412
|
+
}
|
|
413
|
+
if (options.store !== void 0) {
|
|
414
|
+
url.searchParams.set("store", String(options.store));
|
|
415
|
+
}
|
|
416
|
+
if (options.agentVersionOverride) {
|
|
417
|
+
url.searchParams.set("x-agent-version-override", options.agentVersionOverride);
|
|
418
|
+
}
|
|
419
|
+
return url.toString();
|
|
420
|
+
}
|
|
421
|
+
function buildHeaders(token, clientOptions, connectOptions) {
|
|
422
|
+
const sdkUserAgent = `azsdk-js-ai-projects/${import_constants.SDK_VERSION}`;
|
|
423
|
+
const headers = {
|
|
424
|
+
authorization: `Bearer ${token}`,
|
|
425
|
+
"foundry-features": voiceAgentsPreview,
|
|
426
|
+
"x-ms-client-request-id": createRequestId(),
|
|
427
|
+
"x-ms-client-sdk": sdkUserAgent,
|
|
428
|
+
"user-agent": clientOptions.userAgentPrefix ? `${clientOptions.userAgentPrefix} ${sdkUserAgent}` : sdkUserAgent
|
|
429
|
+
};
|
|
430
|
+
if (connectOptions.structuredInputs) {
|
|
431
|
+
headers["x-ms-voice-structured-inputs"] = JSON.stringify(connectOptions.structuredInputs);
|
|
432
|
+
}
|
|
433
|
+
return headers;
|
|
434
|
+
}
|
|
435
|
+
function createRequestId() {
|
|
436
|
+
return globalThis.crypto?.randomUUID?.() ?? `${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
437
|
+
}
|
|
438
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
439
|
+
0 && (module.exports = {
|
|
440
|
+
KnownVoiceAgentConnectionState,
|
|
441
|
+
VoiceAgentRealtimeClient
|
|
442
|
+
});
|
|
443
|
+
//# sourceMappingURL=voiceAgentRealtimeClient.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/realtime/voiceAgentRealtimeClient.ts"],
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AbortSignalLike } from \"@azure/abort-controller\";\nimport type { TokenCredential } from \"@azure/core-auth\";\nimport type { OperationOptions } from \"@azure-rest/core-client\";\nimport { uint8ArrayToString } from \"@azure/core-util\";\nimport { SDK_VERSION } from \"../constants.js\";\nimport type {\n RealtimeConversationItemUnion,\n VoiceAgentClientEvent,\n VoiceAgentResponseCreateParams,\n VoiceAgentSessionUpdateConfig,\n} from \"../models/models.js\";\nimport { logger } from \"../logger.js\";\nimport { AsyncQueue } from \"./asyncQueue.js\";\nimport {\n VoiceAgentAuthenticationError,\n VoiceAgentConnectionError,\n VoiceAgentProtocolError,\n} from \"./errors.js\";\nimport { deserializeVoiceAgentServerEvent, serializeVoiceAgentClientEvent } from \"./protocol.js\";\nimport type { VoiceAgentRealtimeEvent } from \"./events.js\";\nimport type {\n VoiceAgentWebSocketFactory,\n VoiceAgentWebSocketTransport,\n} from \"./webSocketTransportLike.js\";\n\nconst defaultCredentialScope = \"https://ai.azure.com/.default\";\nconst voiceAgentsPreview = \"VoiceAgents=V1Preview\";\n\n/** Known values of {@link VoiceAgentConnectionState} reported by a voice-agent realtime connection. */\nexport const KnownVoiceAgentConnectionState = {\n Disconnected: \"disconnected\",\n Connecting: \"connecting\",\n Connected: \"connected\",\n Closing: \"closing\",\n} as const;\n\n/** Connection states reported by a voice-agent realtime connection. */\nexport type VoiceAgentConnectionState =\n (typeof KnownVoiceAgentConnectionState)[keyof typeof KnownVoiceAgentConnectionState];\n\n/** Called when a voice-agent connection changes state. */\nexport type VoiceAgentConnectionStateChangedHandler = (\n state: VoiceAgentConnectionState,\n previousState: VoiceAgentConnectionState,\n) => void;\n\n/** Options for the Voice Agents realtime client. */\nexport interface VoiceAgentRealtimeClientOptions {\n /** Microsoft Entra scopes used to acquire a WebSocket access token. */\n credentialScopes?: string | string[];\n /** Default connection timeout in milliseconds. */\n connectionTimeoutInMs?: number;\n /** API version sent during the WebSocket upgrade. */\n apiVersion?: string;\n /** Prefix added to the SDK user-agent value in Node.js. */\n userAgentPrefix?: string;\n /**\n * Overrides the transport used to establish the realtime WebSocket connection. Defaults to the\n * platform transport (`ws` in Node.js, the browser's native `WebSocket` in browsers/React Native).\n * Provide a custom factory to customize connection establishment.\n */\n webSocketFactory?: VoiceAgentWebSocketFactory;\n}\n\n/** Options for connecting the realtime client to a voice agent. */\nexport interface VoiceAgentRealtimeClientConnectOptions extends OperationOptions {\n /** Identifier used to correlate the voice session. */\n agentSessionId?: string;\n /** Overrides whether the conversation created by this session is persisted. */\n store?: boolean;\n /** Selects a specific immutable agent version. */\n agentVersionOverride?: string;\n /** Values used to render the agent's structured prompt inputs. */\n structuredInputs?: Record<string, unknown>;\n /** Overrides the client connection timeout in milliseconds. */\n connectionTimeoutInMs?: number;\n /** Cancels the connection attempt. */\n abortSignal?: AbortSignalLike;\n /** Receives connection-state transitions. */\n onConnectionStateChange?: VoiceAgentConnectionStateChangedHandler;\n}\n\n/** Result supplied when a voice-agent connection closes. */\nexport interface VoiceAgentCloseResult {\n /** WebSocket close code. */\n code: number;\n /** WebSocket close reason. */\n reason: string;\n /** Whether the peer completed a normal WebSocket close handshake. */\n wasClean: boolean;\n /** Transport or protocol error associated with the close, if any. */\n error?: Error;\n}\n\n/** Options shared by realtime send operations. */\nexport interface VoiceAgentSendOptions extends OperationOptions {}\n\n/** Options shared by operations that build a protocol event on the caller's behalf. */\nexport interface VoiceAgentEventOptions extends VoiceAgentSendOptions {\n /** Client-generated event identifier. */\n eventId?: string;\n}\n\n/** Options shared by operations that add a conversation item and, by default, request a response. */\nexport interface VoiceAgentSendItemOptions extends VoiceAgentEventOptions {\n /** Whether to request a response after adding the item. Defaults to true. */\n createResponse?: boolean;\n}\n\n/** Options for sending text input. */\nexport interface VoiceAgentSendTextOptions extends VoiceAgentSendItemOptions {\n /** Item after which the new text item is inserted. */\n previousItemId?: string;\n}\n\n/** Options for returning a function result. */\nexport interface VoiceAgentSendToolOutputOptions extends VoiceAgentSendItemOptions {}\n\n/** Options for updating the live session. */\nexport interface VoiceAgentSessionUpdateOptions extends VoiceAgentEventOptions {}\n\n/** Options for creating a response. */\nexport interface VoiceAgentResponseOptions extends VoiceAgentEventOptions {\n /** Response-specific configuration. */\n response?: VoiceAgentResponseCreateParams;\n}\n\n/** Options for cancelling a response. */\nexport interface VoiceAgentCancelResponseOptions extends VoiceAgentEventOptions {\n /** Specific response to cancel. The active default-conversation response is used when omitted. */\n responseId?: string;\n}\n\n/**\n * A connected, bidirectional voice-agent stream.\n *\n * Supports exactly one `for await` iteration over server events; a second attempt throws.\n * Exiting the loop early (`break`, `return`, or an uncaught error in the loop body) closes\n * the connection as a side effect.\n * Unrecognized server event types are delivered as {@link VoiceAgentUnknownEvent} without\n * interrupting the stream. Malformed events still fail the iteration with a protocol error.\n */\nexport interface VoiceAgentConnection extends AsyncIterable<VoiceAgentRealtimeEvent> {\n /** Current connection state. */\n readonly state: VoiceAgentConnectionState;\n /** Resolves once the connection is closed. */\n readonly closed: Promise<VoiceAgentCloseResult>;\n /** Sends any generated client protocol event. */\n sendEvent(event: VoiceAgentClientEvent, options?: VoiceAgentSendOptions): Promise<void>;\n /** Updates supported live-session settings. */\n configureSession(\n session: VoiceAgentSessionUpdateConfig,\n options?: VoiceAgentSessionUpdateOptions,\n ): Promise<void>;\n /** Adds a user text item and, by default, requests a response. */\n sendText(text: string, options?: VoiceAgentSendTextOptions): Promise<void>;\n /** Appends base64-encoded audio bytes to the input buffer. */\n sendAudio(audio: Uint8Array | ArrayBuffer, options?: VoiceAgentEventOptions): Promise<void>;\n /** Commits buffered input audio. */\n commitAudio(options?: VoiceAgentEventOptions): Promise<void>;\n /** Clears buffered input audio. */\n clearInputAudio(options?: VoiceAgentEventOptions): Promise<void>;\n /** Clears pending output audio at the service. */\n clearOutputAudio(options?: VoiceAgentEventOptions): Promise<void>;\n /** Returns a client-executed function result to the agent. */\n sendToolOutput(\n callId: string,\n output: string,\n options?: VoiceAgentSendToolOutputOptions,\n ): Promise<void>;\n /** Requests a new response. */\n requestResponse(options?: VoiceAgentResponseOptions): Promise<void>;\n /** Cancels an in-progress response. */\n cancelResponse(options?: VoiceAgentCancelResponseOptions): Promise<void>;\n /** Gracefully closes the WebSocket connection. */\n close(code?: number, reason?: string): Promise<void>;\n /** Releases the connection. Equivalent to close(). */\n dispose(): Promise<void>;\n}\n\n/** Client for establishing realtime sessions with managed Foundry voice agents. */\nexport class VoiceAgentRealtimeClient {\n private readonly endpoint: string;\n private readonly credential: TokenCredential;\n private readonly options: Required<\n Pick<VoiceAgentRealtimeClientOptions, \"connectionTimeoutInMs\" | \"apiVersion\">\n > &\n VoiceAgentRealtimeClientOptions;\n\n public constructor(\n endpoint: string,\n credential: TokenCredential,\n options: VoiceAgentRealtimeClientOptions = {},\n ) {\n // Endpoint validation (https-only) is deferred to connect() so that merely constructing an\n // AIProjectClient (which eagerly creates this client) doesn't reject callers who intentionally\n // use an insecure local endpoint for the REST surface and never touch realtime connections.\n if (!endpoint.trim()) {\n throw new TypeError(\"endpoint must not be empty.\");\n }\n this.endpoint = endpoint;\n this.credential = credential;\n this.options = {\n ...options,\n connectionTimeoutInMs: options.connectionTimeoutInMs ?? 30_000,\n apiVersion: options.apiVersion ?? \"v1\",\n };\n }\n\n /** Establishes a WebSocket connection to a managed voice agent. */\n public async connect(\n agentName: string,\n options: VoiceAgentRealtimeClientConnectOptions = {},\n ): Promise<VoiceAgentConnection> {\n if (!agentName.trim()) {\n throw new TypeError(\"agentName must not be empty.\");\n }\n const factory =\n this.options.webSocketFactory ??\n (await import(\"#platform/webSocketTransport\")).createDefaultVoiceAgentWebSocketFactory();\n const connection = new VoiceAgentConnectionImpl(\n normalizeEndpoint(this.endpoint),\n agentName,\n this.credential,\n this.options,\n options,\n factory,\n );\n await connection.open();\n return connection;\n }\n}\n\nclass VoiceAgentConnectionImpl implements VoiceAgentConnection {\n private readonly events: AsyncQueue<VoiceAgentRealtimeEvent>;\n private readonly transport: VoiceAgentWebSocketTransport;\n private readonly closePromise: Promise<VoiceAgentCloseResult>;\n private resolveClose!: (result: VoiceAgentCloseResult) => void;\n private currentState: VoiceAgentConnectionState = KnownVoiceAgentConnectionState.Disconnected;\n private iteratorStarted = false;\n private finished = false;\n\n public constructor(\n private readonly endpoint: string,\n private readonly agentName: string,\n private readonly credential: TokenCredential,\n private readonly clientOptions: VoiceAgentRealtimeClientOptions & {\n connectionTimeoutInMs: number;\n apiVersion: string;\n },\n private readonly connectOptions: VoiceAgentRealtimeClientConnectOptions,\n factory: VoiceAgentWebSocketFactory,\n ) {\n this.events = new AsyncQueue<VoiceAgentRealtimeEvent>(10_000, {\n onOverflow: (error) => this.handleEventQueueOverflow(error),\n });\n this.transport = factory.create();\n this.closePromise = new Promise<VoiceAgentCloseResult>((resolve) => {\n this.resolveClose = resolve;\n });\n this.transport.setHandlers({\n onMessage: (data) => this.handleMessage(data),\n onClose: (code, reason, wasClean) => this.handleClose(code, reason, wasClean),\n onError: (error) => this.handleTransportError(error),\n });\n }\n\n public get state(): VoiceAgentConnectionState {\n return this.currentState;\n }\n\n public get closed(): Promise<VoiceAgentCloseResult> {\n return this.closePromise;\n }\n\n public async open(): Promise<void> {\n this.setState(KnownVoiceAgentConnectionState.Connecting);\n let token: string;\n try {\n const accessToken = await this.credential.getToken(\n this.clientOptions.credentialScopes ?? defaultCredentialScope,\n { abortSignal: this.connectOptions.abortSignal },\n );\n if (!accessToken) {\n throw new VoiceAgentAuthenticationError(\"The credential returned no access token.\");\n }\n token = accessToken.token;\n } catch (error) {\n if (this.connectOptions.abortSignal?.aborted) {\n const cancelledError = new VoiceAgentConnectionError(\n \"Voice-agent connection was cancelled.\",\n \"operationCancelled\",\n { cause: error },\n );\n this.finish(1006, cancelledError.message, false, cancelledError);\n throw cancelledError;\n }\n const authenticationError =\n error instanceof VoiceAgentAuthenticationError\n ? error\n : new VoiceAgentAuthenticationError(\"Failed to acquire a Voice Agents access token.\", {\n cause: error,\n });\n this.finish(1006, authenticationError.message, false, authenticationError);\n throw authenticationError;\n }\n\n try {\n await this.transport.connect({\n url: buildWebSocketUrl(\n this.endpoint,\n this.agentName,\n this.clientOptions.apiVersion,\n this.connectOptions,\n ),\n protocols: [\"realtime\"],\n headers: buildHeaders(token, this.clientOptions, this.connectOptions),\n connectionTimeoutInMs:\n this.connectOptions.connectionTimeoutInMs ?? this.clientOptions.connectionTimeoutInMs,\n abortSignal: this.connectOptions.abortSignal,\n });\n this.setState(KnownVoiceAgentConnectionState.Connected);\n logger.info(\"Connected to voice agent\", { agentName: this.agentName });\n } catch (error) {\n const cancelled = this.connectOptions.abortSignal?.aborted === true;\n const connectionError = new VoiceAgentConnectionError(\n cancelled\n ? \"Voice-agent connection was cancelled.\"\n : \"Failed to connect to the voice agent.\",\n cancelled ? \"operationCancelled\" : \"connectionFailed\",\n { cause: error },\n );\n this.finish(1006, connectionError.message, false, connectionError);\n throw connectionError;\n }\n }\n\n public async sendEvent(\n event: VoiceAgentClientEvent,\n options: VoiceAgentSendOptions = {},\n ): Promise<void> {\n if (this.state !== KnownVoiceAgentConnectionState.Connected) {\n throw new VoiceAgentConnectionError(\n `Cannot send while the connection is ${this.state}.`,\n \"invalidState\",\n );\n }\n if (options.abortSignal?.aborted) {\n throw new VoiceAgentConnectionError(\"Send operation was cancelled.\", \"operationCancelled\");\n }\n\n try {\n await this.transport.send(serializeVoiceAgentClientEvent(event), options.abortSignal);\n } catch (error) {\n if (error instanceof VoiceAgentProtocolError) {\n throw error;\n }\n throw new VoiceAgentConnectionError(\"Failed to send a voice-agent event.\", \"sendFailed\", {\n cause: error,\n });\n }\n }\n\n public configureSession(\n session: VoiceAgentSessionUpdateConfig,\n options: VoiceAgentSessionUpdateOptions = {},\n ): Promise<void> {\n return this.sendEvent({ type: \"session.update\", event_id: options.eventId, session }, options);\n }\n\n public async sendText(text: string, options: VoiceAgentSendTextOptions = {}): Promise<void> {\n await this.sendEvent(\n {\n type: \"conversation.item.create\",\n event_id: options.eventId,\n previous_item_id: options.previousItemId,\n // `RealtimeConversationItemUnion` no longer enumerates a \"message\" item in the generated\n // models, but the wire protocol still accepts this shape; see the TypeSpec regeneration\n // report for details.\n item: {\n type: \"message\",\n role: \"user\",\n content: [{ type: \"input_text\", text }],\n } as unknown as RealtimeConversationItemUnion,\n },\n options,\n );\n if (options.createResponse !== false) {\n await this.requestResponse({ abortSignal: options.abortSignal });\n }\n }\n\n public sendAudio(\n audio: Uint8Array | ArrayBuffer,\n options: VoiceAgentEventOptions = {},\n ): Promise<void> {\n const bytes = audio instanceof Uint8Array ? audio : new Uint8Array(audio);\n return this.sendEvent(\n {\n type: \"input_audio_buffer.append\",\n event_id: options.eventId,\n audio: uint8ArrayToString(bytes, \"base64\"),\n },\n options,\n );\n }\n\n public commitAudio(options: VoiceAgentEventOptions = {}): Promise<void> {\n return this.sendEvent(\n { type: \"input_audio_buffer.commit\", event_id: options.eventId },\n options,\n );\n }\n\n public clearInputAudio(options: VoiceAgentEventOptions = {}): Promise<void> {\n return this.sendEvent({ type: \"input_audio_buffer.clear\", event_id: options.eventId }, options);\n }\n\n public clearOutputAudio(options: VoiceAgentEventOptions = {}): Promise<void> {\n return this.sendEvent(\n { type: \"output_audio_buffer.clear\", event_id: options.eventId },\n options,\n );\n }\n\n public async sendToolOutput(\n callId: string,\n output: string,\n options: VoiceAgentSendToolOutputOptions = {},\n ): Promise<void> {\n await this.sendEvent(\n {\n type: \"conversation.item.create\",\n event_id: options.eventId,\n item: { type: \"function_call_output\", call_id: callId, output },\n },\n options,\n );\n if (options.createResponse !== false) {\n await this.requestResponse({ abortSignal: options.abortSignal });\n }\n }\n\n public requestResponse(options: VoiceAgentResponseOptions = {}): Promise<void> {\n return this.sendEvent(\n { type: \"response.create\", event_id: options.eventId, response: options.response },\n options,\n );\n }\n\n public cancelResponse(options: VoiceAgentCancelResponseOptions = {}): Promise<void> {\n return this.sendEvent(\n { type: \"response.cancel\", event_id: options.eventId, response_id: options.responseId },\n options,\n );\n }\n\n public async close(\n code = 1000,\n reason = \"Client closed the voice-agent connection.\",\n ): Promise<void> {\n if (\n this.state === KnownVoiceAgentConnectionState.Disconnected ||\n this.state === KnownVoiceAgentConnectionState.Closing\n ) {\n await this.closed;\n return;\n }\n this.setState(KnownVoiceAgentConnectionState.Closing);\n try {\n await this.transport.close(code, reason);\n } finally {\n this.finish(code, reason, false);\n }\n }\n\n public dispose(): Promise<void> {\n return this.close();\n }\n\n public async *[Symbol.asyncIterator](): AsyncIterator<VoiceAgentRealtimeEvent> {\n if (this.iteratorStarted) {\n throw new VoiceAgentConnectionError(\n \"A voice-agent connection supports one active event iterator.\",\n \"invalidState\",\n );\n }\n this.iteratorStarted = true;\n try {\n while (true) {\n const result = await this.events.next();\n if (result.done) {\n return;\n }\n yield result.value;\n }\n } finally {\n if (this.state === KnownVoiceAgentConnectionState.Connected) {\n await this.close();\n }\n }\n }\n\n private handleMessage(data: string | ArrayBuffer): void {\n try {\n this.events.enqueue(deserializeVoiceAgentServerEvent(data));\n } catch (error) {\n const protocolError =\n error instanceof VoiceAgentProtocolError\n ? error\n : new VoiceAgentProtocolError(\"Failed to process a voice-agent event.\", { cause: error });\n // finish() closes the transport itself, so no additional close is needed here.\n this.finish(1002, protocolError.message, false, protocolError);\n }\n }\n\n private handleEventQueueOverflow(cause: Error): void {\n if (this.finished) {\n return;\n }\n const error = new VoiceAgentConnectionError(cause.message, \"connectionClosed\", {\n cause,\n });\n this.finish(1006, error.message, false, error);\n }\n\n private handleClose(code: number, reason: string, wasClean: boolean): void {\n if (this.finished) {\n return;\n }\n if (wasClean || this.state === KnownVoiceAgentConnectionState.Closing) {\n this.finish(code, reason, wasClean);\n } else {\n const error = new VoiceAgentConnectionError(\n `Voice-agent connection closed unexpectedly (${code}${reason ? `: ${reason}` : \"\"}).`,\n \"connectionClosed\",\n { closeCode: code },\n );\n this.finish(code, reason, false, error);\n }\n }\n\n private handleTransportError(cause: Error): void {\n if (this.finished) {\n return;\n }\n const error = new VoiceAgentConnectionError(\n \"Voice-agent WebSocket transport failed.\",\n \"connectionClosed\",\n {\n cause,\n },\n );\n this.finish(1006, cause.message, false, error);\n }\n\n private finish(code: number, reason: string, wasClean: boolean, error?: Error): void {\n if (this.finished) {\n return;\n }\n this.finished = true;\n if (error) {\n this.events.fail(error);\n } else {\n this.events.close();\n }\n this.setState(KnownVoiceAgentConnectionState.Disconnected);\n this.resolveClose({ code, reason, wasClean, error });\n logger.info(\"Voice-agent connection closed\", { code, reason, wasClean });\n // Ensure the socket never outlives the connection, even on paths that never closed it\n // themselves. Not awaited: finish() is synchronous because its callers are.\n void this.closeTransportQuietly(code, reason);\n }\n\n /**\n * Closes the transport, logging rather than rejecting: this is best-effort cleanup running after\n * the connection has already settled. A no-op if the transport is already closed.\n */\n private async closeTransportQuietly(code: number, reason: string): Promise<void> {\n try {\n await this.transport.close(code, reason);\n } catch (error) {\n logger.warning(\"Failed to close the voice-agent transport\", { error });\n }\n }\n\n private setState(state: VoiceAgentConnectionState): void {\n if (state === this.currentState) {\n return;\n }\n const previousState = this.currentState;\n this.currentState = state;\n try {\n this.connectOptions.onConnectionStateChange?.(state, previousState);\n } catch (error) {\n // A throwing caller callback must never interrupt connection lifecycle/cleanup.\n logger.warning(\"onConnectionStateChange callback threw an error\", { error });\n }\n }\n}\n\nfunction normalizeEndpoint(endpoint: string): string {\n const normalized = endpoint.trim();\n if (!normalized) {\n throw new TypeError(\"endpoint must not be empty.\");\n }\n const url = new URL(normalized.includes(\"://\") ? normalized : `https://${normalized}`);\n if (url.protocol !== \"https:\") {\n throw new TypeError(\n \"endpoint must use https; a plaintext endpoint would send the bearer token over an unencrypted connection.\",\n );\n }\n return url.toString().replace(/\\/$/, \"\");\n}\n\nfunction buildWebSocketUrl(\n endpoint: string,\n agentName: string,\n apiVersion: string,\n options: VoiceAgentRealtimeClientConnectOptions,\n): string {\n const url = new URL(endpoint);\n url.protocol = \"wss:\";\n url.pathname = `${url.pathname.replace(/\\/$/, \"\")}/agents/${encodeURIComponent(agentName)}/endpoint/protocols/voice`;\n url.searchParams.set(\"api-version\", apiVersion);\n url.searchParams.set(\"x-ms-client-sdk\", `azsdk-js-ai-projects/${SDK_VERSION}`);\n if (options.agentSessionId) {\n url.searchParams.set(\"agent_session_id\", options.agentSessionId);\n }\n if (options.store !== undefined) {\n url.searchParams.set(\"store\", String(options.store));\n }\n if (options.agentVersionOverride) {\n url.searchParams.set(\"x-agent-version-override\", options.agentVersionOverride);\n }\n return url.toString();\n}\n\nfunction buildHeaders(\n token: string,\n clientOptions: VoiceAgentRealtimeClientOptions,\n connectOptions: VoiceAgentRealtimeClientConnectOptions,\n): Record<string, string> {\n const sdkUserAgent = `azsdk-js-ai-projects/${SDK_VERSION}`;\n const headers: Record<string, string> = {\n authorization: `Bearer ${token}`,\n \"foundry-features\": voiceAgentsPreview,\n \"x-ms-client-request-id\": createRequestId(),\n \"x-ms-client-sdk\": sdkUserAgent,\n \"user-agent\": clientOptions.userAgentPrefix\n ? `${clientOptions.userAgentPrefix} ${sdkUserAgent}`\n : sdkUserAgent,\n };\n if (connectOptions.structuredInputs) {\n headers[\"x-ms-voice-structured-inputs\"] = JSON.stringify(connectOptions.structuredInputs);\n }\n return headers;\n}\n\nfunction createRequestId(): string {\n return (\n globalThis.crypto?.randomUUID?.() ?? `${Date.now()}-${Math.random().toString(36).slice(2)}`\n );\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,uBAAmC;AACnC,uBAA4B;AAO5B,oBAAuB;AACvB,wBAA2B;AAC3B,oBAIO;AACP,sBAAiF;AAOjF,MAAM,yBAAyB;AAC/B,MAAM,qBAAqB;AAGpB,MAAM,iCAAiC;AAAA,EAC5C,cAAc;AAAA,EACd,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,SAAS;AACX;AAmJO,MAAM,yBAAyB;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,EAKV,YACL,UACA,YACA,UAA2C,CAAC,GAC5C;AAIA,QAAI,CAAC,SAAS,KAAK,GAAG;AACpB,YAAM,IAAI,UAAU,6BAA6B;AAAA,IACnD;AACA,SAAK,WAAW;AAChB,SAAK,aAAa;AAClB,SAAK,UAAU;AAAA,MACb,GAAG;AAAA,MACH,uBAAuB,QAAQ,yBAAyB;AAAA,MACxD,YAAY,QAAQ,cAAc;AAAA,IACpC;AAAA,EACF;AAAA;AAAA,EAGA,MAAa,QACX,WACA,UAAkD,CAAC,GACpB;AAC/B,QAAI,CAAC,UAAU,KAAK,GAAG;AACrB,YAAM,IAAI,UAAU,8BAA8B;AAAA,IACpD;AACA,UAAM,UACJ,KAAK,QAAQ,qBACZ,MAAM,OAAO,8BAA8B,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AA,IACnB,cAAc,cAAc,kBACxB,GAAG,cAAc,eAAe,IAAI,YAAY,KAChD;AAAA,EACN;AACA,MAAI,eAAe,kBAAkB;AACnC,YAAQ,8BAA8B,IAAI,KAAK,UAAU,eAAe,gBAAgB;AAAA,EAC1F;AACA,SAAO;AACT;AAEA,SAAS,kBAA0B;AACjC,SACE,WAAW,QAAQ,aAAa,KAAK,GAAG,KAAK,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,MAAM,CAAC,CAAC;AAE7F;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { AbortSignalLike } from "@azure/abort-controller";
|
|
2
|
+
/** Callbacks invoked by a {@link VoiceAgentWebSocketTransport} as connection events occur. */
|
|
3
|
+
export interface VoiceAgentWebSocketHandlers {
|
|
4
|
+
/** Invoked when a message is received from the service. */
|
|
5
|
+
onMessage: (data: string | ArrayBuffer) => void;
|
|
6
|
+
/** Invoked when the connection closes. */
|
|
7
|
+
onClose: (code: number, reason: string, wasClean: boolean) => void;
|
|
8
|
+
/** Invoked when the transport encounters an error. */
|
|
9
|
+
onError: (error: Error) => void;
|
|
10
|
+
}
|
|
11
|
+
/** Options passed to {@link VoiceAgentWebSocketTransport.connect}. */
|
|
12
|
+
export interface VoiceAgentWebSocketConnectOptions {
|
|
13
|
+
/** The WebSocket URL to connect to. */
|
|
14
|
+
url: string;
|
|
15
|
+
/** The WebSocket subprotocols to negotiate. */
|
|
16
|
+
protocols: string[];
|
|
17
|
+
/** Headers to send with the connection upgrade request, where supported by the transport. */
|
|
18
|
+
headers: Record<string, string>;
|
|
19
|
+
/** Connection timeout, in milliseconds. */
|
|
20
|
+
connectionTimeoutInMs: number;
|
|
21
|
+
/** Cancels the connection attempt. */
|
|
22
|
+
abortSignal?: AbortSignalLike;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* A pluggable WebSocket transport used by {@link VoiceAgentRealtimeClient}. Implement this
|
|
26
|
+
* interface to customize how the realtime connection is established, for example to route it
|
|
27
|
+
* through an authenticated relay.
|
|
28
|
+
*/
|
|
29
|
+
export interface VoiceAgentWebSocketTransport {
|
|
30
|
+
/** Registers the handlers invoked as connection events occur. */
|
|
31
|
+
setHandlers(handlers: VoiceAgentWebSocketHandlers): void;
|
|
32
|
+
/** Establishes the WebSocket connection. */
|
|
33
|
+
connect(options: VoiceAgentWebSocketConnectOptions): Promise<void>;
|
|
34
|
+
/** Sends a message over the connection. */
|
|
35
|
+
send(data: string, abortSignal?: AbortSignalLike): Promise<void>;
|
|
36
|
+
/** Closes the connection. */
|
|
37
|
+
close(code: number, reason: string): Promise<void>;
|
|
38
|
+
}
|
|
39
|
+
/** Creates {@link VoiceAgentWebSocketTransport} instances for {@link VoiceAgentRealtimeClient}. */
|
|
40
|
+
export interface VoiceAgentWebSocketFactory {
|
|
41
|
+
/** Creates a new transport instance for a single connection attempt. */
|
|
42
|
+
create(): VoiceAgentWebSocketTransport;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=webSocketTransportLike.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webSocketTransportLike.d.ts","sourceRoot":"","sources":["../../../src/realtime/webSocketTransportLike.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE/D,8FAA8F;AAC9F,MAAM,WAAW,2BAA2B;IAC1C,2DAA2D;IAC3D,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,KAAK,IAAI,CAAC;IAChD,0CAA0C;IAC1C,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;IACnE,sDAAsD;IACtD,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CACjC;AAED,sEAAsE;AACtE,MAAM,WAAW,iCAAiC;IAChD,uCAAuC;IACvC,GAAG,EAAE,MAAM,CAAC;IACZ,+CAA+C;IAC/C,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,6FAA6F;IAC7F,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,2CAA2C;IAC3C,qBAAqB,EAAE,MAAM,CAAC;IAC9B,sCAAsC;IACtC,WAAW,CAAC,EAAE,eAAe,CAAC;CAC/B;AAED;;;;GAIG;AACH,MAAM,WAAW,4BAA4B;IAC3C,iEAAiE;IACjE,WAAW,CAAC,QAAQ,EAAE,2BAA2B,GAAG,IAAI,CAAC;IACzD,4CAA4C;IAC5C,OAAO,CAAC,OAAO,EAAE,iCAAiC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnE,2CAA2C;IAC3C,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjE,6BAA6B;IAC7B,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACpD;AAED,mGAAmG;AACnG,MAAM,WAAW,0BAA0B;IACzC,wEAAwE;IACxE,MAAM,IAAI,4BAA4B,CAAC;CACxC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
+
var webSocketTransportLike_exports = {};
|
|
15
|
+
module.exports = __toCommonJS(webSocketTransportLike_exports);
|
|
16
|
+
//# sourceMappingURL=webSocketTransportLike.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/realtime/webSocketTransportLike.ts"],
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AbortSignalLike } from \"@azure/abort-controller\";\n\n/** Callbacks invoked by a {@link VoiceAgentWebSocketTransport} as connection events occur. */\nexport interface VoiceAgentWebSocketHandlers {\n /** Invoked when a message is received from the service. */\n onMessage: (data: string | ArrayBuffer) => void;\n /** Invoked when the connection closes. */\n onClose: (code: number, reason: string, wasClean: boolean) => void;\n /** Invoked when the transport encounters an error. */\n onError: (error: Error) => void;\n}\n\n/** Options passed to {@link VoiceAgentWebSocketTransport.connect}. */\nexport interface VoiceAgentWebSocketConnectOptions {\n /** The WebSocket URL to connect to. */\n url: string;\n /** The WebSocket subprotocols to negotiate. */\n protocols: string[];\n /** Headers to send with the connection upgrade request, where supported by the transport. */\n headers: Record<string, string>;\n /** Connection timeout, in milliseconds. */\n connectionTimeoutInMs: number;\n /** Cancels the connection attempt. */\n abortSignal?: AbortSignalLike;\n}\n\n/**\n * A pluggable WebSocket transport used by {@link VoiceAgentRealtimeClient}. Implement this\n * interface to customize how the realtime connection is established, for example to route it\n * through an authenticated relay.\n */\nexport interface VoiceAgentWebSocketTransport {\n /** Registers the handlers invoked as connection events occur. */\n setHandlers(handlers: VoiceAgentWebSocketHandlers): void;\n /** Establishes the WebSocket connection. */\n connect(options: VoiceAgentWebSocketConnectOptions): Promise<void>;\n /** Sends a message over the connection. */\n send(data: string, abortSignal?: AbortSignalLike): Promise<void>;\n /** Closes the connection. */\n close(code: number, reason: string): Promise<void>;\n}\n\n/** Creates {@link VoiceAgentWebSocketTransport} instances for {@link VoiceAgentRealtimeClient}. */\nexport interface VoiceAgentWebSocketFactory {\n /** Creates a new transport instance for a single connection attempt. */\n create(): VoiceAgentWebSocketTransport;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { AbortSignalLike } from "@azure/abort-controller";
|
|
2
|
+
import type { VoiceAgentWebSocketConnectOptions, VoiceAgentWebSocketFactory, VoiceAgentWebSocketHandlers, VoiceAgentWebSocketTransport } from "./realtime/webSocketTransportLike.js";
|
|
3
|
+
export declare class NodeWebSocketTransport implements VoiceAgentWebSocketTransport {
|
|
4
|
+
private webSocket?;
|
|
5
|
+
private handlers?;
|
|
6
|
+
private readonly closeTimeoutInMs;
|
|
7
|
+
constructor(closeTimeoutInMs?: number);
|
|
8
|
+
setHandlers(handlers: VoiceAgentWebSocketHandlers): void;
|
|
9
|
+
connect(options: VoiceAgentWebSocketConnectOptions): Promise<void>;
|
|
10
|
+
send(data: string, abortSignal?: AbortSignalLike): Promise<void>;
|
|
11
|
+
close(code: number, reason: string): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
/** @internal */
|
|
14
|
+
export declare function createDefaultVoiceAgentWebSocketFactory(): VoiceAgentWebSocketFactory;
|
|
15
|
+
//# sourceMappingURL=webSocketTransport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webSocketTransport.d.ts","sourceRoot":"","sources":["../../src/webSocketTransport.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE/D,OAAO,KAAK,EACV,iCAAiC,EACjC,0BAA0B,EAC1B,2BAA2B,EAC3B,4BAA4B,EAC7B,MAAM,sCAAsC,CAAC;AAE9C,qBAAa,sBAAuB,YAAW,4BAA4B;IACzE,OAAO,CAAC,SAAS,CAAC,CAAY;IAC9B,OAAO,CAAC,QAAQ,CAAC,CAA8B;IAC/C,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAS;gBAEvB,gBAAgB,SAAQ;IAIpC,WAAW,CAAC,QAAQ,EAAE,2BAA2B,GAAG,IAAI;IAIlD,OAAO,CAAC,OAAO,EAAE,iCAAiC,GAAG,OAAO,CAAC,IAAI,CAAC;IAwBlE,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAUhE,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAwBhE;AAuKD,gBAAgB;AAChB,wBAAgB,uCAAuC,IAAI,0BAA0B,CAEpF"}
|