@fonoster/apiserver 0.27.0 → 0.31.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.
Files changed (376) hide show
  1. package/dist/applications/buildService.d.ts +5 -1
  2. package/dist/applications/buildService.js +10 -7
  3. package/dist/applications/createCreateApplication.d.ts +6 -2
  4. package/dist/applications/createCreateApplication.js +24 -16
  5. package/dist/applications/createCreateTestToken.d.ts +3 -1
  6. package/dist/applications/createCreateTestToken.js +18 -13
  7. package/dist/applications/createGetApplication.js +2 -2
  8. package/dist/applications/createGetFnUtil.d.ts +22 -18
  9. package/dist/applications/createGetFnUtil.js +3 -5
  10. package/dist/applications/createListApplications.js +3 -4
  11. package/dist/applications/createRotateSigningSecret.d.ts +9 -0
  12. package/dist/{calls/createFetchSingleCall.js → applications/createRotateSigningSecret.js} +23 -20
  13. package/dist/applications/createUpdateApplication.d.ts +6 -2
  14. package/dist/applications/createUpdateApplication.js +35 -36
  15. package/dist/applications/evalKeys.d.ts +9 -0
  16. package/dist/{voice/handlers/dial/recordChannel.js → applications/evalKeys.js} +17 -12
  17. package/dist/applications/session/appModel.d.ts +225 -0
  18. package/dist/applications/session/appModel.js +331 -0
  19. package/dist/applications/types.d.ts +1 -27
  20. package/dist/billing/buildService.d.ts +24 -0
  21. package/dist/billing/buildService.js +116 -0
  22. package/dist/bin/entrypoint.d.ts +1 -0
  23. package/dist/bin/entrypoint.js +180 -0
  24. package/dist/bin/healthcheck.d.ts +2 -0
  25. package/dist/{voice/utils/VoiceServiceClientConstructor.js → bin/healthcheck.js} +24 -9
  26. package/dist/bin/regionHubSetup.d.ts +2 -0
  27. package/dist/bin/regionHubSetup.js +67 -0
  28. package/dist/bin/usage.d.ts +2 -0
  29. package/dist/bin/usage.js +119 -0
  30. package/dist/calls/buildService.d.ts +1 -20
  31. package/dist/calls/buildService.js +59 -6
  32. package/dist/calls/createCall.d.ts +17 -2
  33. package/dist/calls/createCall.js +64 -11
  34. package/dist/calls/createCallPublisher.d.ts +40 -2
  35. package/dist/calls/createCallPublisher.js +43 -9
  36. package/dist/calls/createIsWorkspaceNumber.d.ts +41 -0
  37. package/dist/calls/createIsWorkspaceNumber.js +39 -0
  38. package/dist/calls/createTrackCall.d.ts +55 -2
  39. package/dist/calls/createTrackCall.js +230 -16
  40. package/dist/calls/getCall.d.ts +4 -2
  41. package/dist/calls/getCall.js +2 -3
  42. package/dist/calls/listCalls.d.ts +4 -2
  43. package/dist/calls/listCalls.js +2 -3
  44. package/dist/calls/types.d.ts +11 -2
  45. package/dist/calls/types.js +10 -0
  46. package/dist/{core/buildWelcomeDemoService.d.ts → capabilities/buildService.d.ts} +8 -8
  47. package/dist/capabilities/buildService.js +17 -0
  48. package/dist/capabilities/createGetCapabilities.d.ts +78 -0
  49. package/dist/capabilities/createGetCapabilities.js +98 -0
  50. package/dist/{voice/handlers/utils → capabilities}/index.d.ts +2 -3
  51. package/dist/{voice/handlers/utils → capabilities}/index.js +4 -3
  52. package/dist/config/index.d.ts +23 -0
  53. package/dist/config/index.js +102 -0
  54. package/dist/config/schema.d.ts +1919 -0
  55. package/dist/config/schema.js +357 -0
  56. package/dist/core/allowList.js +2 -1
  57. package/dist/core/applyCatalog.d.ts +10 -0
  58. package/dist/{voice/client/GrpcClientHandler.js → core/applyCatalog.js} +45 -51
  59. package/dist/core/db.d.ts +3 -1
  60. package/dist/core/db.js +2 -1
  61. package/dist/core/durableConsumer.d.ts +41 -0
  62. package/dist/core/durableConsumer.js +104 -0
  63. package/dist/core/httpBridge.d.ts +24 -6
  64. package/dist/core/httpBridge.js +3 -25
  65. package/dist/core/identityConfig.d.ts +2 -35
  66. package/dist/core/identityConfig.js +3 -36
  67. package/dist/core/regionHooks.d.ts +15 -0
  68. package/dist/{calls/influxdb.js → core/regionHooks.js} +4 -8
  69. package/dist/core/runServices.js +98 -15
  70. package/dist/core/services.d.ts +96 -6
  71. package/dist/core/services.js +49 -10
  72. package/dist/{voice/errors/index.d.ts → core/telemetry.d.ts} +2 -2
  73. package/dist/core/telemetry.js +42 -0
  74. package/dist/{applications/utils/convertToApplicationData.d.ts → core/telemetryInterceptor.d.ts} +10 -4
  75. package/dist/core/telemetryInterceptor.js +57 -0
  76. package/dist/core/testTokenConfig.js +4 -1
  77. package/dist/core/upsertRoomrPeer.d.ts +6 -0
  78. package/dist/core/{upsertDefaultPeer.js → upsertRoomrPeer.js} +31 -30
  79. package/dist/envs.d.ts +136 -23
  80. package/dist/envs.js +108 -143
  81. package/dist/index.js +39 -21
  82. package/dist/outbound/createNodeDirectory.d.ts +86 -0
  83. package/dist/outbound/createNodeDirectory.js +140 -0
  84. package/dist/{voice/integrations → outbound}/index.d.ts +4 -1
  85. package/dist/{voice/errors → outbound}/index.js +4 -2
  86. package/dist/outbound/placeOutboundCall.d.ts +96 -0
  87. package/dist/outbound/placeOutboundCall.js +172 -0
  88. package/dist/outbound/placementSweep.d.ts +56 -0
  89. package/dist/outbound/placementSweep.js +127 -0
  90. package/dist/outbound/runOutboundCalls.d.ts +52 -0
  91. package/dist/outbound/runOutboundCalls.js +171 -0
  92. package/dist/providers/createProvidersHandlers.d.ts +39 -0
  93. package/dist/providers/createProvidersHandlers.js +229 -0
  94. package/dist/providers/index.d.ts +47 -0
  95. package/dist/{voice/client → providers}/index.js +15 -6
  96. package/dist/providers/registryUsage.d.ts +48 -0
  97. package/dist/providers/registryUsage.js +236 -0
  98. package/dist/records/createIndexRecord.d.ts +42 -0
  99. package/dist/records/createIndexRecord.js +185 -0
  100. package/dist/records/createRecordsRouter.d.ts +61 -0
  101. package/dist/records/createRecordsRouter.js +330 -0
  102. package/dist/records/createSearchRecords.d.ts +51 -0
  103. package/dist/records/createSearchRecords.js +134 -0
  104. package/dist/{voice/filters → records}/index.d.ts +6 -6
  105. package/dist/{voice/filters → records}/index.js +6 -6
  106. package/dist/records/maintenance.d.ts +33 -0
  107. package/dist/records/maintenance.js +166 -0
  108. package/dist/records/runCallRecords.d.ts +48 -0
  109. package/dist/records/runCallRecords.js +49 -0
  110. package/dist/{events/createPerCallCache.d.ts → records/stores.d.ts} +4 -7
  111. package/dist/{voice/handlers/utils/isDtmf.js → records/stores.js} +9 -3
  112. package/dist/records/types.d.ts +104 -0
  113. package/dist/regions/configSync.d.ts +130 -0
  114. package/dist/regions/configSync.js +316 -0
  115. package/dist/regions/createRegionsRouter.d.ts +151 -0
  116. package/dist/regions/createRegionsRouter.js +391 -0
  117. package/dist/regions/endpoints.d.ts +41 -0
  118. package/dist/regions/endpoints.js +90 -0
  119. package/dist/regions/enrollmentToken.d.ts +41 -0
  120. package/dist/regions/enrollmentToken.js +94 -0
  121. package/dist/regions/httpAuth.d.ts +39 -0
  122. package/dist/regions/httpAuth.js +78 -0
  123. package/dist/regions/ids.d.ts +15 -0
  124. package/dist/regions/ids.js +81 -0
  125. package/dist/{voice/client → regions}/index.d.ts +17 -6
  126. package/dist/regions/index.js +51 -0
  127. package/dist/regions/link.d.ts +17 -0
  128. package/dist/regions/link.js +170 -0
  129. package/dist/regions/natsAuth.d.ts +41 -0
  130. package/dist/regions/natsAuth.js +64 -0
  131. package/dist/regions/natsJwt.d.ts +23 -0
  132. package/dist/regions/natsJwt.js +26 -0
  133. package/dist/regions/relay.d.ts +45 -0
  134. package/dist/regions/relay.js +203 -0
  135. package/dist/regions/relayHttp.d.ts +7 -0
  136. package/dist/regions/relayHttp.js +107 -0
  137. package/dist/regions/relaySlots.d.ts +18 -0
  138. package/dist/regions/relaySlots.js +118 -0
  139. package/dist/regions/runRegions.d.ts +111 -0
  140. package/dist/regions/runRegions.js +235 -0
  141. package/dist/regions/service.d.ts +129 -0
  142. package/dist/regions/service.js +558 -0
  143. package/dist/regions/sources.d.ts +20 -0
  144. package/dist/regions/sources.js +191 -0
  145. package/dist/regions/status.d.ts +35 -0
  146. package/dist/regions/status.js +63 -0
  147. package/dist/regions/types.d.ts +123 -0
  148. package/dist/regions/types.js +41 -0
  149. package/dist/{voice/integrations/getSttConfig.d.ts → regions/withConfigChangeHook.d.ts} +13 -7
  150. package/dist/regions/withConfigChangeHook.js +44 -0
  151. package/dist/secrets/createGetFnUtil.d.ts +2 -2
  152. package/dist/session/createSessionRouter.d.ts +49 -0
  153. package/dist/session/createSessionRouter.js +206 -0
  154. package/dist/{voice/handlers/dial → session}/index.d.ts +1 -1
  155. package/dist/{voice/handlers/dial → session}/index.js +1 -1
  156. package/dist/usage/buildService.d.ts +16 -0
  157. package/dist/{voice/integrations/getTtsConfig.js → usage/buildService.js} +13 -7
  158. package/dist/{voice/tts/utils/convertUlawToPCM16.d.ts → usage/createGetUsage.d.ts} +7 -6
  159. package/dist/usage/createGetUsage.js +118 -0
  160. package/dist/usage/ingestUsage.d.ts +7 -0
  161. package/dist/usage/ingestUsage.js +87 -0
  162. package/dist/usage/publishRecordedUsage.d.ts +52 -0
  163. package/dist/usage/publishRecordedUsage.js +103 -0
  164. package/dist/{utils/createHandleDialEventsWithNats.d.ts → usage/publishUsage.d.ts} +10 -4
  165. package/dist/usage/publishUsage.js +50 -0
  166. package/dist/usage/rebuildUsage.d.ts +48 -0
  167. package/dist/usage/rebuildUsage.js +104 -0
  168. package/dist/usage/runUsageConsumer.d.ts +22 -0
  169. package/dist/usage/runUsageConsumer.js +78 -0
  170. package/dist/usage/snapshotStorage.d.ts +14 -0
  171. package/dist/usage/snapshotStorage.js +95 -0
  172. package/dist/{voice/integrations/getTtsConfig.d.ts → usage/types.d.ts} +17 -6
  173. package/dist/utils/createCheckNumberPreconditions.js +4 -0
  174. package/dist/utils/index.d.ts +0 -2
  175. package/dist/utils/index.js +0 -2
  176. package/dist/voice/stt/Deepgram.d.ts +4 -57
  177. package/dist/voice/stt/Deepgram.js +15 -286
  178. package/dist/voice/stt/Google.d.ts +4 -15
  179. package/dist/voice/stt/Google.js +7 -103
  180. package/dist/voice/stt/types.d.ts +2 -38
  181. package/dist/voice/stt/types.js +25 -3
  182. package/dist/voice/tts/Azure.d.ts +4 -34
  183. package/dist/voice/tts/Azure.js +25 -105
  184. package/dist/voice/tts/Deepgram.d.ts +4 -38
  185. package/dist/voice/tts/Deepgram.js +25 -82
  186. package/dist/voice/tts/ElevenLabs.d.ts +4 -18
  187. package/dist/voice/tts/ElevenLabs.js +6 -97
  188. package/dist/voice/tts/Google.d.ts +4 -38
  189. package/dist/voice/tts/Google.js +25 -91
  190. package/dist/webhooks/createWebhooksHandlers.d.ts +37 -0
  191. package/dist/webhooks/createWebhooksHandlers.js +217 -0
  192. package/dist/webhooks/index.d.ts +37 -0
  193. package/dist/webhooks/index.js +51 -0
  194. package/dist/webhooks/lostCalls.d.ts +49 -0
  195. package/dist/webhooks/lostCalls.js +147 -0
  196. package/dist/webhooks/nodeCallEvents.d.ts +73 -0
  197. package/dist/webhooks/nodeCallEvents.js +177 -0
  198. package/dist/webhooks/runWebhookFanout.d.ts +44 -0
  199. package/dist/webhooks/runWebhookFanout.js +202 -0
  200. package/package.json +21 -31
  201. package/dist/applications/utils/applicationWithEncodedStruct.d.ts +0 -3
  202. package/dist/applications/utils/applicationWithEncodedStruct.js +0 -50
  203. package/dist/applications/utils/convertToApplicationData.js +0 -37
  204. package/dist/applications/validation/assistantWithoutApiKeySchema.d.ts +0 -786
  205. package/dist/applications/validation/assistantWithoutApiKeySchema.js +0 -35
  206. package/dist/applications/validation/createValidationSchema.d.ts +0 -1474
  207. package/dist/applications/validation/createValidationSchema.js +0 -67
  208. package/dist/applications/validation/prepareForValidation.d.ts +0 -21
  209. package/dist/applications/validation/prepareForValidation.js +0 -35
  210. package/dist/applications/validation/speechValidators.d.ts +0 -47
  211. package/dist/applications/validation/speechValidators.js +0 -50
  212. package/dist/applications/validation/validOrThrow.d.ts +0 -21
  213. package/dist/applications/validation/validOrThrow.js +0 -15
  214. package/dist/calls/createFetchCalls.d.ts +0 -22
  215. package/dist/calls/createFetchCalls.js +0 -88
  216. package/dist/calls/createFetchSingleCall.d.ts +0 -22
  217. package/dist/calls/influxdb.d.ts +0 -2
  218. package/dist/calls/runCallManager.d.ts +0 -8
  219. package/dist/calls/runCallManager.js +0 -75
  220. package/dist/core/buildWelcomeDemoService.js +0 -97
  221. package/dist/core/upsertDefaultPeer.d.ts +0 -2
  222. package/dist/events/amdResultCache.d.ts +0 -23
  223. package/dist/events/amdResultCache.js +0 -35
  224. package/dist/events/createInfluxDbPub.d.ts +0 -13
  225. package/dist/events/createInfluxDbPub.js +0 -89
  226. package/dist/events/createPerCallCache.js +0 -46
  227. package/dist/events/mapCallDirectionToEnum.d.ts +0 -21
  228. package/dist/events/mapCallDirectionToEnum.js +0 -37
  229. package/dist/events/nats.d.ts +0 -10
  230. package/dist/events/nats.js +0 -82
  231. package/dist/events/transformEvent.d.ts +0 -2
  232. package/dist/events/transformEvent.js +0 -87
  233. package/dist/events/types.d.ts +0 -26
  234. package/dist/utils/createHandleDialEventsWithNats.js +0 -24
  235. package/dist/utils/createHandleDialEventsWithVoiceClient.d.ts +0 -23
  236. package/dist/utils/createHandleDialEventsWithVoiceClient.js +0 -27
  237. package/dist/utils/getIntegrationsFromFile.d.ts +0 -2
  238. package/dist/utils/getIntegrationsFromFile.js +0 -49
  239. package/dist/utils/mapDialStatus.d.ts +0 -21
  240. package/dist/utils/mapDialStatus.js +0 -38
  241. package/dist/voice/VoiceDispatcher.d.ts +0 -21
  242. package/dist/voice/VoiceDispatcher.js +0 -122
  243. package/dist/voice/amd/mapAsteriskAmd.d.ts +0 -38
  244. package/dist/voice/amd/mapAsteriskAmd.js +0 -68
  245. package/dist/voice/client/AudioSocketHandler.d.ts +0 -38
  246. package/dist/voice/client/AudioSocketHandler.js +0 -70
  247. package/dist/voice/client/AuthorizationHandler.d.ts +0 -13
  248. package/dist/voice/client/AuthorizationHandler.js +0 -78
  249. package/dist/voice/client/ExternalMediaHandler.d.ts +0 -32
  250. package/dist/voice/client/ExternalMediaHandler.js +0 -59
  251. package/dist/voice/client/GrpcClientHandler.d.ts +0 -36
  252. package/dist/voice/client/SpeechHandler.d.ts +0 -60
  253. package/dist/voice/client/SpeechHandler.js +0 -120
  254. package/dist/voice/client/VoiceClientImpl.d.ts +0 -79
  255. package/dist/voice/client/VoiceClientImpl.js +0 -198
  256. package/dist/voice/connectToAri.d.ts +0 -2
  257. package/dist/voice/connectToAri.js +0 -81
  258. package/dist/voice/createCreateVoiceClient.d.ts +0 -9
  259. package/dist/voice/createCreateVoiceClient.js +0 -97
  260. package/dist/voice/errors/ChannelVarNotFoundError.d.ts +0 -23
  261. package/dist/voice/errors/ChannelVarNotFoundError.js +0 -10
  262. package/dist/voice/errors/MethodNotImplementedError.d.ts +0 -22
  263. package/dist/voice/errors/MethodNotImplementedError.js +0 -27
  264. package/dist/voice/filters/AudioFilterFactory.d.ts +0 -35
  265. package/dist/voice/filters/AudioFilterFactory.js +0 -94
  266. package/dist/voice/filters/aiCoustics/createAiCousticsFilter.d.ts +0 -64
  267. package/dist/voice/filters/aiCoustics/createAiCousticsFilter.js +0 -252
  268. package/dist/voice/filters/aiCoustics/types.d.ts +0 -45
  269. package/dist/voice/filters/aiCoustics/types.js +0 -29
  270. package/dist/voice/filters/createAudioFilterChain.d.ts +0 -9
  271. package/dist/voice/filters/createAudioFilterChain.js +0 -171
  272. package/dist/voice/filters/createAudioFilterSession.d.ts +0 -15
  273. package/dist/voice/filters/createAudioFilterSession.js +0 -114
  274. package/dist/voice/filters/pcm.d.ts +0 -21
  275. package/dist/voice/filters/pcm.js +0 -37
  276. package/dist/voice/filters/types.d.ts +0 -61
  277. package/dist/voice/filters/types.js +0 -26
  278. package/dist/voice/handlers/createAnswerHandler.d.ts +0 -23
  279. package/dist/voice/handlers/createAnswerHandler.js +0 -24
  280. package/dist/voice/handlers/createHangupHandler.d.ts +0 -23
  281. package/dist/voice/handlers/createHangupHandler.js +0 -28
  282. package/dist/voice/handlers/createMuteHandler.d.ts +0 -4
  283. package/dist/voice/handlers/createMuteHandler.js +0 -27
  284. package/dist/voice/handlers/createPlayDtmfHandler.d.ts +0 -4
  285. package/dist/voice/handlers/createPlayDtmfHandler.js +0 -27
  286. package/dist/voice/handlers/createPlayHandler.d.ts +0 -4
  287. package/dist/voice/handlers/createPlayHandler.js +0 -33
  288. package/dist/voice/handlers/createPlaybackControlHandler.d.ts +0 -4
  289. package/dist/voice/handlers/createPlaybackControlHandler.js +0 -62
  290. package/dist/voice/handlers/createRecordHandler.d.ts +0 -4
  291. package/dist/voice/handlers/createRecordHandler.js +0 -58
  292. package/dist/voice/handlers/createSayHandler.d.ts +0 -4
  293. package/dist/voice/handlers/createSayHandler.js +0 -31
  294. package/dist/voice/handlers/createSetAudioFiltersHandler.d.ts +0 -11
  295. package/dist/voice/handlers/createSetAudioFiltersHandler.js +0 -74
  296. package/dist/voice/handlers/createStopSayHandler.d.ts +0 -3
  297. package/dist/voice/handlers/createStopSayHandler.js +0 -34
  298. package/dist/voice/handlers/createStreamGatherHandler.d.ts +0 -3
  299. package/dist/voice/handlers/createStreamGatherHandler.js +0 -74
  300. package/dist/voice/handlers/createStreamHandler.d.ts +0 -3
  301. package/dist/voice/handlers/createStreamHandler.js +0 -70
  302. package/dist/voice/handlers/createUnmuteHandler.d.ts +0 -4
  303. package/dist/voice/handlers/createUnmuteHandler.js +0 -27
  304. package/dist/voice/handlers/dial/createDialHandler.d.ts +0 -23
  305. package/dist/voice/handlers/dial/createDialHandler.js +0 -78
  306. package/dist/voice/handlers/dial/handleChannelLeftBridge.d.ts +0 -24
  307. package/dist/voice/handlers/dial/handleChannelLeftBridge.js +0 -29
  308. package/dist/voice/handlers/dial/handleStasisEnd.d.ts +0 -21
  309. package/dist/voice/handlers/dial/handleStasisEnd.js +0 -19
  310. package/dist/voice/handlers/dial/handleStasisStart.d.ts +0 -27
  311. package/dist/voice/handlers/dial/handleStasisStart.js +0 -52
  312. package/dist/voice/handlers/dial/recordChannel.d.ts +0 -22
  313. package/dist/voice/handlers/gather/createGatherHandler.d.ts +0 -3
  314. package/dist/voice/handlers/gather/createGatherHandler.js +0 -86
  315. package/dist/voice/handlers/gather/getTimeoutPromise.d.ts +0 -26
  316. package/dist/voice/handlers/gather/getTimeoutPromise.js +0 -18
  317. package/dist/voice/handlers/index.d.ts +0 -33
  318. package/dist/voice/handlers/index.js +0 -49
  319. package/dist/voice/handlers/utils/awaitForPlaybackFinished.d.ts +0 -21
  320. package/dist/voice/handlers/utils/awaitForPlaybackFinished.js +0 -25
  321. package/dist/voice/handlers/utils/awaitForRecordingFinished.d.ts +0 -5
  322. package/dist/voice/handlers/utils/awaitForRecordingFinished.js +0 -53
  323. package/dist/voice/handlers/utils/isDtmf.d.ts +0 -20
  324. package/dist/voice/handlers/utils/textChunksByClause.d.ts +0 -2
  325. package/dist/voice/handlers/utils/textChunksByClause.js +0 -41
  326. package/dist/voice/handlers/utils/textChunksByFirstNaturalPause.d.ts +0 -2
  327. package/dist/voice/handlers/utils/textChunksByFirstNaturalPause.js +0 -34
  328. package/dist/voice/handlers/utils/withErrorHandling.d.ts +0 -22
  329. package/dist/voice/handlers/utils/withErrorHandling.js +0 -38
  330. package/dist/voice/integrations/ApplicationNotFoundError.d.ts +0 -22
  331. package/dist/voice/integrations/ApplicationNotFoundError.js +0 -28
  332. package/dist/voice/integrations/createCreateContainer.d.ts +0 -4
  333. package/dist/voice/integrations/createCreateContainer.js +0 -76
  334. package/dist/voice/integrations/getSttConfig.js +0 -30
  335. package/dist/voice/integrations/index.js +0 -35
  336. package/dist/voice/integrations/types.d.ts +0 -29
  337. package/dist/voice/stt/AbstractSpeechToText.d.ts +0 -33
  338. package/dist/voice/stt/AbstractSpeechToText.js +0 -19
  339. package/dist/voice/stt/SpeechToTextFactory.d.ts +0 -9
  340. package/dist/voice/stt/SpeechToTextFactory.js +0 -43
  341. package/dist/voice/transcribeOnConnection.d.ts +0 -35
  342. package/dist/voice/transcribeOnConnection.js +0 -91
  343. package/dist/voice/tts/AbstractTextToSpeech.d.ts +0 -40
  344. package/dist/voice/tts/AbstractTextToSpeech.js +0 -50
  345. package/dist/voice/tts/TextToSpeechFactory.d.ts +0 -8
  346. package/dist/voice/tts/TextToSpeechFactory.js +0 -47
  347. package/dist/voice/tts/types.d.ts +0 -48
  348. package/dist/voice/tts/types.js +0 -2
  349. package/dist/voice/tts/utils/convertUlawToPCM16.js +0 -40
  350. package/dist/voice/tts/utils/createChunkedSynthesisStream.d.ts +0 -28
  351. package/dist/voice/tts/utils/createChunkedSynthesisStream.js +0 -78
  352. package/dist/voice/tts/utils/createErrorStream.d.ts +0 -21
  353. package/dist/voice/tts/utils/createErrorStream.js +0 -28
  354. package/dist/voice/tts/utils/index.d.ts +0 -23
  355. package/dist/voice/tts/utils/index.js +0 -39
  356. package/dist/voice/tts/utils/isSsml.d.ts +0 -20
  357. package/dist/voice/tts/utils/isSsml.js +0 -25
  358. package/dist/voice/tts/utils/streamToBuffer.d.ts +0 -20
  359. package/dist/voice/tts/utils/streamToBuffer.js +0 -60
  360. package/dist/voice/types/ari.d.ts +0 -43
  361. package/dist/voice/types/ari.js +0 -48
  362. package/dist/voice/types/index.d.ts +0 -20
  363. package/dist/voice/types/index.js +0 -36
  364. package/dist/voice/types/voice.d.ts +0 -67
  365. package/dist/voice/types/voice.js +0 -2
  366. package/dist/voice/utils/VoiceServiceClientConstructor.d.ts +0 -3
  367. package/dist/voice/utils/createExternalMediaConfig.d.ts +0 -12
  368. package/dist/voice/utils/createExternalMediaConfig.js +0 -37
  369. package/dist/voice/utils/createGetChannelVar.d.ts +0 -22
  370. package/dist/voice/utils/createGetChannelVar.js +0 -27
  371. package/dist/voice/utils/createGetChannelVarWithoutThrow.d.ts +0 -22
  372. package/dist/voice/utils/createGetChannelVarWithoutThrow.js +0 -26
  373. package/dist/voice/utils/index.d.ts +0 -22
  374. package/dist/voice/utils/index.js +0 -38
  375. /package/dist/{events → records}/types.js +0 -0
  376. /package/dist/{voice/integrations → usage}/types.js +0 -0
@@ -1,6 +1,7 @@
1
1
  import { Prisma } from "../core/db";
2
+ import { SessionAppsConfig } from "./session/appModel";
2
3
  import { TestTokenConfiguration } from "./types";
3
- declare function buildService(prisma: Prisma, testTokenConfig: TestTokenConfiguration): {
4
+ declare function buildService(prisma: Prisma, testTokenConfig: TestTokenConfiguration, config?: SessionAppsConfig, findCallerEmail?: (userRef: string) => Promise<string | undefined>): {
4
5
  definition: {
5
6
  serviceName: string;
6
7
  pckg: string;
@@ -23,6 +24,9 @@ declare function buildService(prisma: Prisma, testTokenConfig: TestTokenConfigur
23
24
  updateApplication: (call: {
24
25
  request: unknown;
25
26
  }, callback: (error?: import("@fonoster/common").GrpcErrorMessage, response?: unknown) => void) => Promise<void>;
27
+ rotateSigningSecret: (call: {
28
+ request: unknown;
29
+ }, callback: (error?: import("@fonoster/common").GrpcErrorMessage, response?: unknown) => void) => Promise<void>;
26
30
  evaluateIntelligence: (call: {
27
31
  request: import("@fonoster/autopilot").EvaluateIntelligenceRequest;
28
32
  write: (chunk: Record<string, unknown>) => void;
@@ -21,15 +21,17 @@ exports.buildService = buildService;
21
21
  */
22
22
  const autopilot_1 = require("@fonoster/autopilot");
23
23
  const envs_1 = require("../envs");
24
- const getIntegrationsFromFile_1 = require("../utils/getIntegrationsFromFile");
24
+ const publishUsage_1 = require("../usage/publishUsage");
25
25
  const createCreateApplication_1 = require("./createCreateApplication");
26
26
  const createCreateTestToken_1 = require("./createCreateTestToken");
27
27
  const createDeleteApplication_1 = require("./createDeleteApplication");
28
28
  const createGetApplication_1 = require("./createGetApplication");
29
29
  const createListApplications_1 = require("./createListApplications");
30
+ const createRotateSigningSecret_1 = require("./createRotateSigningSecret");
30
31
  const createUpdateApplication_1 = require("./createUpdateApplication");
31
- function buildService(prisma, testTokenConfig) {
32
- const integrations = (0, getIntegrationsFromFile_1.getIntegrationsFromFile)(envs_1.INTEGRATIONS_FILE);
32
+ const evalKeys_1 = require("./evalKeys");
33
+ function buildService(prisma, testTokenConfig, config = envs_1.SESSION_APPS, findCallerEmail) {
34
+ const evaluateIntelligence = (0, autopilot_1.createEvaluateIntelligence)((0, evalKeys_1.createEvalKeys)(prisma, envs_1.EVALUATIONS.credentials), publishUsage_1.reportEvalUsage);
33
35
  return {
34
36
  definition: {
35
37
  serviceName: "Applications",
@@ -38,13 +40,14 @@ function buildService(prisma, testTokenConfig) {
38
40
  proto: "applications.proto"
39
41
  },
40
42
  handlers: {
41
- createApplication: (0, createCreateApplication_1.createCreateApplication)(prisma),
43
+ createApplication: (0, createCreateApplication_1.createCreateApplication)(prisma, config),
42
44
  getApplication: (0, createGetApplication_1.createGetApplication)(prisma),
43
45
  listApplications: (0, createListApplications_1.createListApplications)(prisma),
44
46
  deleteApplication: (0, createDeleteApplication_1.createDeleteApplication)(prisma),
45
- updateApplication: (0, createUpdateApplication_1.createUpdateApplication)(prisma),
46
- evaluateIntelligence: (0, autopilot_1.createEvaluateIntelligence)(integrations),
47
- createTestToken: (0, createCreateTestToken_1.createCreateTestToken)(testTokenConfig)
47
+ updateApplication: (0, createUpdateApplication_1.createUpdateApplication)(prisma, config),
48
+ rotateSigningSecret: (0, createRotateSigningSecret_1.createRotateSigningSecret)(prisma, config),
49
+ evaluateIntelligence,
50
+ createTestToken: (0, createCreateTestToken_1.createCreateTestToken)(testTokenConfig, findCallerEmail)
48
51
  }
49
52
  };
50
53
  }
@@ -17,8 +17,12 @@
17
17
  * limitations under the License.
18
18
  */
19
19
  import { GrpcErrorMessage } from "@fonoster/common";
20
- import { Prisma } from "../core/db";
21
- declare function createCreateApplication(prisma: Prisma): (call: {
20
+ import { AppsDb, SessionAppsConfig } from "./session/appModel";
21
+ /**
22
+ * Creates an application (a stream or an Autopilot agent). The response carries the signing secret, the only time it is shown.
23
+ * Autopilot apps share the configured Autopilot secret when one is set (CP-B3).
24
+ */
25
+ declare function createCreateApplication(prisma: AppsDb, config: SessionAppsConfig): (call: {
22
26
  request: unknown;
23
27
  }, callback: (error?: GrpcErrorMessage, response?: unknown) => void) => Promise<void>;
24
28
  export { createCreateApplication };
@@ -30,30 +30,38 @@ exports.createCreateApplication = createCreateApplication;
30
30
  */
31
31
  const common_1 = require("@fonoster/common");
32
32
  const logger_1 = require("@fonoster/logger");
33
- const client_1 = require("@prisma/client");
34
- const convertToApplicationData_1 = require("./utils/convertToApplicationData");
35
- const validOrThrow_1 = require("./validation/validOrThrow");
33
+ const appModel_1 = require("./session/appModel");
36
34
  const logger = (0, logger_1.getLogger)({ service: "apiserver", filePath: __filename });
37
- function createCreateApplication(prisma) {
35
+ /**
36
+ * Creates an application (a stream or an Autopilot agent). The response carries the signing secret, the only time it is shown.
37
+ * Autopilot apps share the configured Autopilot secret when one is set (CP-B3).
38
+ */
39
+ function createCreateApplication(prisma, config) {
38
40
  const createApplication = (call, callback) => __awaiter(this, void 0, void 0, function* () {
39
- const { request } = call;
40
- const { type } = request;
41
41
  const accessKeyId = (0, common_1.getAccessKeyIdFromCall)(call);
42
+ const request = call.request;
42
43
  logger.verbose("call to createApplication", {
43
44
  accessKeyId,
44
- type
45
+ type: request.type
45
46
  });
46
- if (type === client_1.ApplicationType.AUTOPILOT && !request.endpoint) {
47
- logger.verbose("setting default endpoint for autopilot application", {
48
- autopilotEndpoint: common_1.AUTOPILOT_SPECIAL_LOCAL_ADDRESS
49
- });
50
- request.endpoint = common_1.AUTOPILOT_SPECIAL_LOCAL_ADDRESS;
51
- }
52
- (0, validOrThrow_1.validOrThrow)(request);
47
+ const { columns, agent, autopilot } = yield (0, appModel_1.toAppColumns)(prisma, request, {
48
+ accessKeyId,
49
+ config
50
+ });
51
+ const shared = autopilot ? config.autopilotSigningSecret : undefined;
52
+ const signingSecret = shared !== null && shared !== void 0 ? shared : (0, appModel_1.newSigningSecret)();
53
+ const intelligence = agent
54
+ ? { create: yield (0, appModel_1.agentRow)(prisma, agent) }
55
+ : undefined;
53
56
  const result = yield prisma.application.create({
54
- data: Object.assign(Object.assign({}, (0, convertToApplicationData_1.convertToApplicationData)(request)), { accessKeyId })
57
+ data: Object.assign(Object.assign({}, columns), { signingSecret, accessKeyId, intelligence })
58
+ });
59
+ callback(null, {
60
+ ref: result.ref,
61
+ // A shared Autopilot secret is the operator's, not the app's to show.
62
+ signingSecret: shared ? "" : signingSecret,
63
+ signingSecretHint: (0, appModel_1.secretHint)(signingSecret)
55
64
  });
56
- callback(null, { ref: result.ref });
57
65
  });
58
66
  return (0, common_1.withErrorHandling)(createApplication);
59
67
  }
@@ -18,7 +18,9 @@
18
18
  */
19
19
  import { GrpcErrorMessage } from "@fonoster/common";
20
20
  import { TestTokenConfiguration } from "./types";
21
- declare function createCreateTestToken(config: TestTokenConfiguration): (call: {
21
+ /** The email of the user a ref names, for the token's `caller` (#1060). */
22
+ type FindCallerEmail = (userRef: string) => Promise<string | undefined>;
23
+ declare function createCreateTestToken(config: TestTokenConfiguration, findCallerEmail?: FindCallerEmail): (call: {
22
24
  request: unknown;
23
25
  }, callback: (error?: GrpcErrorMessage, response?: unknown) => void) => Promise<void>;
24
26
  export { createCreateTestToken };
@@ -38,25 +38,30 @@ const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
38
38
  const uuid_1 = require("uuid");
39
39
  const envs_1 = require("../envs");
40
40
  const logger = (0, logger_1.getLogger)({ service: "apiserver", filePath: __filename });
41
- function createCreateTestToken(config) {
41
+ function createCreateTestToken(config, findCallerEmail) {
42
42
  const createApplication = (call, callback) => __awaiter(this, void 0, void 0, function* () {
43
43
  const accessKeyId = (0, common_1.getAccessKeyIdFromCall)(call);
44
44
  logger.verbose("call to createTestToken", {
45
45
  accessKeyId
46
46
  });
47
+ // Who is testing: the signed-in user behind the access token, recorded as the call's
48
+ // caller instead of the SIP leg's internal name. A lookup failure only leaves it out.
49
+ let caller;
50
+ try {
51
+ const token = (0, common_1.getTokenFromCall)(call);
52
+ const sub = token
53
+ ? (0, common_1.decodeToken)(token).sub
54
+ : undefined;
55
+ caller =
56
+ typeof sub === "string" && findCallerEmail
57
+ ? yield findCallerEmail(sub)
58
+ : undefined;
59
+ }
60
+ catch (err) {
61
+ logger.verbose("test token without a caller", { error: err });
62
+ }
47
63
  // Build payload
48
- const payload = {
49
- ref: (0, uuid_1.v4)(),
50
- domain: config.domain,
51
- displayName: config.displayName,
52
- signalingServer: config.signalingServer,
53
- targetAor: config.targetAor,
54
- username: config.username,
55
- accessKeyId,
56
- aorLink: config.targetAor,
57
- privacy: "NONE",
58
- allowedMethods: ["INVITE"]
59
- };
64
+ const payload = Object.assign(Object.assign({}, (caller ? { caller } : {})), { ref: (0, uuid_1.v4)(), domain: config.domain, displayName: config.displayName, signalingServer: config.signalingServer, targetAor: config.targetAor, username: config.username, accessKeyId, aorLink: config.targetAor, privacy: "NONE", allowedMethods: ["INVITE"] });
60
65
  // Sign JWT
61
66
  let token;
62
67
  try {
@@ -32,7 +32,7 @@ const common_1 = require("@fonoster/common");
32
32
  const logger_1 = require("@fonoster/logger");
33
33
  const withErrorHandlingAndValidationAndAccess_1 = require("../utils/withErrorHandlingAndValidationAndAccess");
34
34
  const createGetFnUtil_1 = require("./createGetFnUtil");
35
- const applicationWithEncodedStruct_1 = require("./utils/applicationWithEncodedStruct");
35
+ const appModel_1 = require("./session/appModel");
36
36
  const logger = (0, logger_1.getLogger)({ service: "apiserver", filePath: __filename });
37
37
  function createGetApplication(prisma) {
38
38
  const getFn = (0, createGetFnUtil_1.createGetFnUtil)(prisma);
@@ -40,7 +40,7 @@ function createGetApplication(prisma) {
40
40
  const { ref } = call.request;
41
41
  logger.verbose("call to getApplication", { ref });
42
42
  const result = yield getFn(ref);
43
- return result ? (0, applicationWithEncodedStruct_1.applicationWithEncodedStruct)(result) : null;
43
+ return result ? (0, appModel_1.rowToApplication)(result) : null;
44
44
  });
45
45
  return (0, withErrorHandlingAndValidationAndAccess_1.withErrorHandlingAndValidationAndAccess)(getApplication, (ref) => getFn(ref), common_1.Validators.emptySchema);
46
46
  }
@@ -3,33 +3,37 @@ declare function createGetFnUtil(prisma: Prisma): (ref: string) => Promise<{
3
3
  extended: {
4
4
  accessKeyId: string;
5
5
  };
6
- textToSpeech: {
7
- ref: string;
8
- config: import("@prisma/client/runtime/library").JsonValue;
9
- credentials: string | null;
10
- productRef: string;
11
- applicationRef: string;
12
- };
13
- speechToText: {
14
- ref: string;
15
- config: import("@prisma/client/runtime/library").JsonValue;
16
- credentials: string | null;
17
- productRef: string;
18
- applicationRef: string;
19
- };
20
6
  intelligence: {
7
+ credentials: string | null;
21
8
  ref: string;
22
9
  config: import("@prisma/client/runtime/library").JsonValue;
23
- credentials: string | null;
24
10
  productRef: string;
25
11
  applicationRef: string;
26
12
  };
27
- ref: string;
28
- accessKeyId: string;
29
13
  type: import(".prisma/client").$Enums.ApplicationType;
30
- name: string;
31
14
  endpoint: string;
15
+ accessKeyId: string;
16
+ name: string;
17
+ url: string | null;
18
+ ref: string;
19
+ speechVoice: string | null;
20
+ speechTtsModel: string | null;
21
+ speechSttModel: string | null;
32
22
  createdAt: Date;
33
23
  updatedAt: Date;
24
+ recording: string | null;
25
+ silenceTimeoutMs: number | null;
26
+ patience: string | null;
27
+ protocol: string | null;
28
+ audio: import("@prisma/client/runtime/library").JsonValue | null;
29
+ fallbackAppRef: string | null;
30
+ fallbackMessage: string | null;
31
+ listeners: import("@prisma/client/runtime/library").JsonValue | null;
32
+ amd: boolean;
33
+ filters: import("@prisma/client/runtime/library").JsonValue | null;
34
+ signingSecret: string | null;
35
+ speechLanguage: string | null;
36
+ amdWindowMs: number | null;
37
+ speechSettings: import("@prisma/client/runtime/library").JsonValue | null;
34
38
  }>;
35
39
  export { createGetFnUtil };
@@ -37,11 +37,9 @@ function createGetFnUtil(prisma) {
37
37
  }
38
38
  const response = yield prisma.application.findUnique({
39
39
  where: { ref },
40
- include: {
41
- textToSpeech: true,
42
- speechToText: true,
43
- intelligence: true
44
- }
40
+ // The legacy TextToSpeech/SpeechToText rows (and their credentials) are not read any more
41
+ // (add-provider-registry 5.2): speech defaults are columns on the app.
42
+ include: { intelligence: true }
45
43
  });
46
44
  if (!response) {
47
45
  throw (0, notFoundError_1.notFoundError)("Application not found");
@@ -30,7 +30,7 @@ exports.createListApplications = createListApplications;
30
30
  */
31
31
  const common_1 = require("@fonoster/common");
32
32
  const logger_1 = require("@fonoster/logger");
33
- const applicationWithEncodedStruct_1 = require("./utils/applicationWithEncodedStruct");
33
+ const appModel_1 = require("./session/appModel");
34
34
  const logger = (0, logger_1.getLogger)({ service: "apiserver", filePath: __filename });
35
35
  function createListApplications(prisma) {
36
36
  const listApplications = (call, callback) => __awaiter(this, void 0, void 0, function* () {
@@ -45,15 +45,14 @@ function createListApplications(prisma) {
45
45
  const result = yield prisma.application.findMany({
46
46
  where: { accessKeyId },
47
47
  include: {
48
- textToSpeech: true,
49
- speechToText: true,
50
48
  intelligence: true
51
49
  },
50
+ orderBy: [{ createdAt: "desc" }, { ref: "asc" }],
52
51
  take: pageSize,
53
52
  skip: pageToken ? 1 : 0,
54
53
  cursor: pageToken ? { ref: pageToken } : undefined
55
54
  });
56
- const items = result.map(applicationWithEncodedStruct_1.applicationWithEncodedStruct);
55
+ const items = result.map((row) => (0, appModel_1.rowToApplication)(row));
57
56
  callback(null, {
58
57
  items,
59
58
  nextPageToken: items.length < pageSize ? "" : (_a = result[result.length - 1]) === null || _a === void 0 ? void 0 : _a.ref
@@ -0,0 +1,9 @@
1
+ import { AppsDb, SessionAppsConfig } from "./session/appModel";
2
+ /**
3
+ * New signing secret for an app. It takes effect at once: the old one stops working with no
4
+ * overlap window (owner ruling B25), so the app must redeploy in step.
5
+ */
6
+ declare function createRotateSigningSecret(prisma: AppsDb, config: SessionAppsConfig): (call: {
7
+ request: unknown;
8
+ }, callback: (error?: import("@fonoster/common").GrpcErrorMessage, response?: unknown) => void) => Promise<void>;
9
+ export { createRotateSigningSecret };
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.createFetchSingleCall = createFetchSingleCall;
12
+ exports.createRotateSigningSecret = createRotateSigningSecret;
13
13
  /**
14
14
  * Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
15
15
  * http://github.com/fonoster/fonoster
@@ -29,26 +29,29 @@ exports.createFetchSingleCall = createFetchSingleCall;
29
29
  * limitations under the License.
30
30
  */
31
31
  const common_1 = require("@fonoster/common");
32
+ const identity_1 = require("@fonoster/identity");
32
33
  const logger_1 = require("@fonoster/logger");
33
- const influxdb_client_1 = require("@influxdata/influxdb-client");
34
+ const createGetFnUtil_1 = require("./createGetFnUtil");
35
+ const appModel_1 = require("./session/appModel");
34
36
  const logger = (0, logger_1.getLogger)({ service: "apiserver", filePath: __filename });
35
- function createFetchSingleCall(influxdb) {
36
- return (accessKeyId, ref) => __awaiter(this, void 0, void 0, function* () {
37
- // "ref" is a tag, so this filters before pivot runs and only ever
38
- // touches the one matching series instead of every call in the range.
39
- const query = (0, influxdb_client_1.flux) `from(bucket: "${common_1.INFLUXDB_CALLS_BUCKET}")
40
- |> range(start: -30d)
41
- |> filter(fn: (r) => r._measurement == "${common_1.CALL_DETAIL_RECORD_MEASUREMENT}" and r.ref == "${ref}")
42
- |> pivot(rowKey: ["callId"], columnKey: ["_field"], valueColumn: "_value")
43
- |> map(fn: (r) => ({
44
- r with
45
- duration: int(v: r.endedAt) - int(v: r.startedAt)
46
- }))
47
- |> filter(fn: (r) => r.accessKeyId == "${accessKeyId}")
48
- |> sort(columns: ["_time"], desc: true)
49
- |> limit(n: 1)`;
50
- logger.verbose("fetch single call request", { accessKeyId, ref });
51
- const items = (yield influxdb.collectRows(query));
52
- return items.length > 0 ? items[0] : null;
37
+ /**
38
+ * New signing secret for an app. It takes effect at once: the old one stops working with no
39
+ * overlap window (owner ruling B25), so the app must redeploy in step.
40
+ */
41
+ function createRotateSigningSecret(prisma, config) {
42
+ const getFn = (0, createGetFnUtil_1.createGetFnUtil)(prisma);
43
+ const rotateSigningSecret = (call) => __awaiter(this, void 0, void 0, function* () {
44
+ const { ref } = call.request;
45
+ const app = yield getFn(ref);
46
+ if (app.type === "AUTOPILOT" && config.autopilotSigningSecret)
47
+ throw (0, appModel_1.invalid)("Autopilot apps use the platform's Autopilot secret; it is rotated by the operator");
48
+ const signingSecret = (0, appModel_1.newSigningSecret)();
49
+ yield prisma.application.update({
50
+ where: { ref },
51
+ data: { signingSecret, updatedAt: new Date() }
52
+ });
53
+ logger.verbose("rotated the signing secret", { ref });
54
+ return { ref, signingSecret, signingSecretHint: (0, appModel_1.secretHint)(signingSecret) };
53
55
  });
56
+ return (0, common_1.withErrorHandling)((0, identity_1.withAccess)(rotateSigningSecret, (ref) => getFn(ref)));
54
57
  }
@@ -1,5 +1,9 @@
1
- import { Prisma } from "../core/db";
2
- declare function createUpdateApplication(prisma: Prisma): (call: {
1
+ import { AppsDb, SessionAppsConfig } from "./session/appModel";
2
+ /**
3
+ * Replaces an app's settings (PUT semantics, CP-B2): fields left out go back to their defaults.
4
+ * The signing secret is kept; rotate it with RotateSigningSecret.
5
+ */
6
+ declare function createUpdateApplication(prisma: AppsDb, config: SessionAppsConfig): (call: {
3
7
  request: unknown;
4
8
  }, callback: (error?: import("@fonoster/common").GrpcErrorMessage, response?: unknown) => void) => Promise<void>;
5
9
  export { createUpdateApplication };
@@ -31,53 +31,52 @@ exports.createUpdateApplication = createUpdateApplication;
31
31
  const common_1 = require("@fonoster/common");
32
32
  const identity_1 = require("@fonoster/identity");
33
33
  const logger_1 = require("@fonoster/logger");
34
- const types_1 = require("@fonoster/types");
35
34
  const createGetFnUtil_1 = require("./createGetFnUtil");
36
- const convertToApplicationData_1 = require("./utils/convertToApplicationData");
37
- const validOrThrow_1 = require("./validation/validOrThrow");
35
+ const appModel_1 = require("./session/appModel");
38
36
  const logger = (0, logger_1.getLogger)({ service: "apiserver", filePath: __filename });
39
- function createUpdateApplication(prisma) {
37
+ /**
38
+ * Replaces an app's settings (PUT semantics, CP-B2): fields left out go back to their defaults.
39
+ * The signing secret is kept; rotate it with RotateSigningSecret.
40
+ */
41
+ function createUpdateApplication(prisma, config) {
40
42
  const getFn = (0, createGetFnUtil_1.createGetFnUtil)(prisma);
41
43
  const updateApplication = (call) => __awaiter(this, void 0, void 0, function* () {
42
- const { request } = call;
43
- const { type, ref: applicationRef } = request;
44
+ const { ref } = call.request;
44
45
  const accessKeyId = (0, common_1.getAccessKeyIdFromCall)(call);
45
- if (type === types_1.ApplicationType.AUTOPILOT && !request.endpoint) {
46
- logger.verbose("setting default endpoint for autopilot application", {
47
- autopilotEndpoint: common_1.AUTOPILOT_SPECIAL_LOCAL_ADDRESS
48
- });
49
- request.endpoint = common_1.AUTOPILOT_SPECIAL_LOCAL_ADDRESS;
50
- }
51
- (0, validOrThrow_1.validOrThrow)(request);
52
- logger.verbose("call to updateApplication", {
46
+ const existing = (yield getFn(ref));
47
+ const request = Object.assign(Object.assign({}, call.request), { name: call.request.name || existing.name, type: call.request.type || existing.type });
48
+ logger.verbose("call to updateApplication", { accessKeyId, ref });
49
+ const { columns, agent, autopilot } = yield (0, appModel_1.toAppColumns)(prisma, request, {
53
50
  accessKeyId,
54
- type
51
+ ref,
52
+ config
55
53
  });
54
+ const intelligence = agent ? yield (0, appModel_1.agentRow)(prisma, agent) : undefined;
55
+ // An app that became an Autopilot app takes the shared secret; one that stopped being one
56
+ // needs its own.
57
+ let signingSecret;
58
+ if (autopilot && config.autopilotSigningSecret)
59
+ signingSecret = config.autopilotSigningSecret;
60
+ else if (!existing.signingSecret ||
61
+ existing.signingSecret === config.autopilotSigningSecret)
62
+ signingSecret = (0, appModel_1.newSigningSecret)();
56
63
  yield prisma.$transaction([
57
- prisma.textToSpeech.deleteMany({
58
- where: {
59
- applicationRef
60
- }
61
- }),
62
- prisma.speechToText.deleteMany({
63
- where: {
64
- applicationRef
65
- }
66
- }),
67
- prisma.intelligence.deleteMany({
68
- where: {
69
- applicationRef
70
- }
71
- }),
64
+ prisma.intelligence.deleteMany({ where: { applicationRef: ref } }),
72
65
  prisma.application.update({
73
- where: {
74
- ref: applicationRef,
75
- accessKeyId
76
- },
77
- data: (0, convertToApplicationData_1.convertToApplicationData)(request)
66
+ where: { ref, accessKeyId },
67
+ data: Object.assign(Object.assign(Object.assign(Object.assign({}, columns), (signingSecret ? { signingSecret } : {})), { updatedAt: new Date() }), (intelligence ? { intelligence: { create: intelligence } } : {}))
78
68
  })
79
69
  ]);
80
- return { ref: applicationRef };
70
+ // A secret generated here is returned once, like on create; the shared Autopilot secret
71
+ // never is (CP review).
72
+ const generated = signingSecret && signingSecret !== config.autopilotSigningSecret
73
+ ? signingSecret
74
+ : undefined;
75
+ return {
76
+ ref,
77
+ signingSecret: generated !== null && generated !== void 0 ? generated : "",
78
+ signingSecretHint: generated ? (0, appModel_1.secretHint)(generated) : ""
79
+ };
81
80
  });
82
81
  return (0, common_1.withErrorHandling)((0, identity_1.withAccess)(updateApplication, (ref) => getFn(ref)));
83
82
  }
@@ -0,0 +1,9 @@
1
+ type EvalDb = any;
2
+ export declare function createEvalKeys(db: EvalDb, platform: Record<string, string>): (providerId: string, workspaceRef: string) => Promise<{
3
+ key: string;
4
+ source: "workspace";
5
+ } | {
6
+ key: string;
7
+ source: "platform";
8
+ }>;
9
+ export {};
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.recordChannel = recordChannel;
12
+ exports.createEvalKeys = createEvalKeys;
13
13
  /**
14
14
  * Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
15
15
  * http://github.com/fonoster/fonoster
@@ -29,18 +29,23 @@ exports.recordChannel = recordChannel;
29
29
  * limitations under the License.
30
30
  */
31
31
  const common_1 = require("@fonoster/common");
32
- function recordChannel(ari, direction, mediaSessionRef) {
33
- return __awaiter(this, void 0, void 0, function* () {
34
- const spy = direction.toLowerCase();
35
- const channel = yield ari.channels.snoopChannel({
36
- app: common_1.STASIS_APP_NAME,
37
- channelId: mediaSessionRef,
38
- spy
32
+ function createEvalKeys(db, platform) {
33
+ const workspaceKeys = new common_1.Registry.PrismaWorkspaceKeys(db);
34
+ return (providerId, workspaceRef) => __awaiter(this, void 0, void 0, function* () {
35
+ var _a;
36
+ // An unreadable key never falls back to the platform's (remove-platform-key-fallback).
37
+ const own = yield workspaceKeys
38
+ .get(workspaceRef, providerId)
39
+ .catch((e) => {
40
+ throw new Error(`key_unavailable: the workspace's ${providerId} key could not be read (${e.message})`);
39
41
  });
40
- return ari.channels.record({
41
- channelId: channel.id,
42
- format: common_1.RecordFormat.WAV,
43
- name: `${mediaSessionRef}_${spy}`
42
+ if (own)
43
+ return { key: own, source: "workspace" };
44
+ const provider = yield db.registryProvider.findUnique({
45
+ where: { id: providerId }
44
46
  });
47
+ const ref = (_a = provider === null || provider === void 0 ? void 0 : provider.credentialRef) !== null && _a !== void 0 ? _a : `${providerId}-default`;
48
+ const key = platform[ref];
49
+ return key ? { key, source: "platform" } : undefined;
45
50
  });
46
51
  }