@signalwire/sdk 2.0.4 → 3.5.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/CHANGELOG.md +785 -0
- package/LICENSE +21 -0
- package/README.md +163 -68
- package/dist/AGENTS.md +13 -0
- package/dist/AgentBase.d.ts +550 -163
- package/dist/AgentBase.js +1640 -514
- package/dist/AgentBase.js.map +1 -1
- package/dist/AgentServer.d.ts +21 -0
- package/dist/AgentServer.js +154 -47
- package/dist/AgentServer.js.map +1 -1
- package/dist/AuthHandler.d.ts +14 -2
- package/dist/AuthHandler.js +7 -2
- package/dist/AuthHandler.js.map +1 -1
- package/dist/ConfigLoader.d.ts +5 -13
- package/dist/ConfigLoader.js +15 -29
- package/dist/ConfigLoader.js.map +1 -1
- package/dist/ContextBuilder.d.ts +202 -9
- package/dist/ContextBuilder.js +219 -36
- package/dist/ContextBuilder.js.map +1 -1
- package/dist/DataMap.d.ts +158 -45
- package/dist/DataMap.js +167 -52
- package/dist/DataMap.js.map +1 -1
- package/dist/FunctionResult.d.ts +277 -83
- package/dist/FunctionResult.js +444 -116
- package/dist/FunctionResult.js.map +1 -1
- package/dist/Logger.d.ts +30 -5
- package/dist/Logger.js +77 -19
- package/dist/Logger.js.map +1 -1
- package/dist/POM/PromptObjectModel.d.ts +163 -0
- package/dist/POM/PromptObjectModel.js +481 -0
- package/dist/POM/PromptObjectModel.js.map +1 -0
- package/dist/ParameterSchema.d.ts +306 -0
- package/dist/ParameterSchema.js +251 -0
- package/dist/ParameterSchema.js.map +1 -0
- package/dist/PlatformContracts.d.ts +21 -0
- package/dist/PlatformContracts.generated.d.ts +109 -0
- package/dist/PlatformContracts.generated.js +8 -0
- package/dist/PlatformContracts.generated.js.map +1 -0
- package/dist/PlatformContracts.js +2 -0
- package/dist/PlatformContracts.js.map +1 -0
- package/dist/PomBuilder.d.ts +28 -0
- package/dist/PomBuilder.js +81 -3
- package/dist/PomBuilder.js.map +1 -1
- package/dist/PostPrompt.d.ts +110 -0
- package/dist/PostPrompt.js +204 -0
- package/dist/PostPrompt.js.map +1 -0
- package/dist/PromptManager.d.ts +29 -1
- package/dist/PromptManager.js +37 -1
- package/dist/PromptManager.js.map +1 -1
- package/dist/PublicFetch.d.ts +132 -0
- package/dist/PublicFetch.js +311 -0
- package/dist/PublicFetch.js.map +1 -0
- package/dist/RobotsTxt.d.ts +41 -0
- package/dist/RobotsTxt.js +152 -0
- package/dist/RobotsTxt.js.map +1 -0
- package/dist/SWMLHandler.js.map +1 -1
- package/dist/SWMLService.d.ts +265 -66
- package/dist/SWMLService.js +652 -112
- package/dist/SWMLService.js.map +1 -1
- package/dist/SchemaUtils.d.ts +115 -2
- package/dist/SchemaUtils.js +444 -12
- package/dist/SchemaUtils.js.map +1 -1
- package/dist/SecurityUtils.d.ts +55 -8
- package/dist/SecurityUtils.js +162 -49
- package/dist/SecurityUtils.js.map +1 -1
- package/dist/ServerlessAdapter.d.ts +156 -7
- package/dist/ServerlessAdapter.js +399 -42
- package/dist/ServerlessAdapter.js.map +1 -1
- package/dist/SessionManager.d.ts +11 -2
- package/dist/SessionManager.js +50 -18
- package/dist/SessionManager.js.map +1 -1
- package/dist/SslConfig.d.ts +2 -1
- package/dist/SslConfig.js +4 -1
- package/dist/SslConfig.js.map +1 -1
- package/dist/SwaigActions.generated.d.ts +23 -0
- package/dist/SwaigActions.generated.js +8 -0
- package/dist/SwaigActions.generated.js.map +1 -0
- package/dist/SwaigContracts.d.ts +15 -0
- package/dist/SwaigContracts.generated.d.ts +264 -0
- package/dist/SwaigContracts.generated.js +12 -0
- package/dist/SwaigContracts.generated.js.map +1 -0
- package/dist/SwaigContracts.js +2 -0
- package/dist/SwaigContracts.js.map +1 -0
- package/dist/SwaigFunction.d.ts +110 -4
- package/dist/SwaigFunction.js +151 -19
- package/dist/SwaigFunction.js.map +1 -1
- package/dist/SwmlBuilder.d.ts +68 -19
- package/dist/SwmlBuilder.js +74 -38
- package/dist/SwmlBuilder.js.map +1 -1
- package/dist/SwmlVerbMethods.generated.d.ts +41 -4
- package/dist/SwmlVerbMethods.generated.js +1 -1
- package/dist/TypeInference.d.ts +39 -3
- package/dist/TypeInference.js +256 -16
- package/dist/TypeInference.js.map +1 -1
- package/dist/WebService.d.ts +79 -11
- package/dist/WebService.js +320 -109
- package/dist/WebService.js.map +1 -1
- package/dist/WebhookMiddleware.d.ts +119 -0
- package/dist/WebhookMiddleware.js +271 -0
- package/dist/WebhookMiddleware.js.map +1 -0
- package/dist/WebhookValidator.d.ts +92 -0
- package/dist/WebhookValidator.js +409 -0
- package/dist/WebhookValidator.js.map +1 -0
- package/dist/agents/BedrockAgent.d.ts +162 -0
- package/dist/agents/BedrockAgent.js +323 -0
- package/dist/agents/BedrockAgent.js.map +1 -0
- package/dist/ai-chat/AIChatClient.d.ts +316 -0
- package/dist/ai-chat/AIChatClient.js +535 -0
- package/dist/ai-chat/AIChatClient.js.map +1 -0
- package/dist/ai-chat/ChatGateway.d.ts +408 -0
- package/dist/ai-chat/ChatGateway.js +747 -0
- package/dist/ai-chat/ChatGateway.js.map +1 -0
- package/dist/ai-chat/HandoffRouter.d.ts +282 -0
- package/dist/ai-chat/HandoffRouter.js +518 -0
- package/dist/ai-chat/HandoffRouter.js.map +1 -0
- package/dist/ai-chat/index.d.ts +12 -0
- package/dist/ai-chat/index.js +10 -0
- package/dist/ai-chat/index.js.map +1 -0
- package/dist/capabilities.d.ts +64 -0
- package/dist/capabilities.js +95 -0
- package/dist/capabilities.js.map +1 -0
- package/dist/cli/agent-loader.d.ts +32 -6
- package/dist/cli/agent-loader.js +95 -34
- package/dist/cli/agent-loader.js.map +1 -1
- package/dist/cli/datamap-exec.d.ts +175 -0
- package/dist/cli/datamap-exec.js +1284 -0
- package/dist/cli/datamap-exec.js.map +1 -0
- package/dist/cli/function-args.d.ts +40 -0
- package/dist/cli/function-args.js +146 -0
- package/dist/cli/function-args.js.map +1 -0
- package/dist/cli/simulation.d.ts +99 -0
- package/dist/cli/simulation.js +490 -0
- package/dist/cli/simulation.js.map +1 -0
- package/dist/cli/swaig-test.d.ts +12 -25
- package/dist/cli/swaig-test.js +935 -367
- package/dist/cli/swaig-test.js.map +1 -1
- package/dist/cli/tsdocs/agentsNote.d.ts +30 -0
- package/dist/cli/tsdocs/agentsNote.js +92 -0
- package/dist/cli/tsdocs/agentsNote.js.map +1 -0
- package/dist/cli/tsdocs/api-index.json +1 -0
- package/dist/cli/tsdocs/api.d.ts +91 -0
- package/dist/cli/tsdocs/api.js +372 -0
- package/dist/cli/tsdocs/api.js.map +1 -0
- package/dist/cli/tsdocs/apiTypes.d.ts +64 -0
- package/dist/cli/tsdocs/apiTypes.js +7 -0
- package/dist/cli/tsdocs/apiTypes.js.map +1 -0
- package/dist/cli/tsdocs/bin.d.ts +6 -0
- package/dist/cli/tsdocs/bin.js +23 -0
- package/dist/cli/tsdocs/bin.js.map +1 -0
- package/dist/cli/tsdocs/files.d.ts +108 -0
- package/dist/cli/tsdocs/files.js +287 -0
- package/dist/cli/tsdocs/files.js.map +1 -0
- package/dist/cli/tsdocs/index.d.ts +28 -0
- package/dist/cli/tsdocs/index.js +307 -0
- package/dist/cli/tsdocs/index.js.map +1 -0
- package/dist/cli/tsdocs/live.d.ts +41 -0
- package/dist/cli/tsdocs/live.js +202 -0
- package/dist/cli/tsdocs/live.js.map +1 -0
- package/dist/cli/tsdocs/locate.d.ts +51 -0
- package/dist/cli/tsdocs/locate.js +75 -0
- package/dist/cli/tsdocs/locate.js.map +1 -0
- package/dist/cli/tsdocs/render.d.ts +75 -0
- package/dist/cli/tsdocs/render.js +323 -0
- package/dist/cli/tsdocs/render.js.map +1 -0
- package/dist/cli/tsdocs/topics.d.ts +43 -0
- package/dist/cli/tsdocs/topics.js +916 -0
- package/dist/cli/tsdocs/topics.js.map +1 -0
- package/dist/index.d.ts +102 -39
- package/dist/index.js +107 -30
- package/dist/index.js.map +1 -1
- package/dist/livewire/index.d.ts +229 -155
- package/dist/livewire/index.js +298 -195
- package/dist/livewire/index.js.map +1 -1
- package/dist/llms.txt +65 -0
- package/dist/prefabs/CallSessionStore.d.ts +52 -0
- package/dist/prefabs/CallSessionStore.js +72 -0
- package/dist/prefabs/CallSessionStore.js.map +1 -0
- package/dist/prefabs/ConciergeAgent.d.ts +13 -1
- package/dist/prefabs/ConciergeAgent.js +36 -31
- package/dist/prefabs/ConciergeAgent.js.map +1 -1
- package/dist/prefabs/FAQBotAgent.d.ts +9 -1
- package/dist/prefabs/FAQBotAgent.js +113 -47
- package/dist/prefabs/FAQBotAgent.js.map +1 -1
- package/dist/prefabs/InfoGathererAgent.d.ts +22 -3
- package/dist/prefabs/InfoGathererAgent.js +67 -58
- package/dist/prefabs/InfoGathererAgent.js.map +1 -1
- package/dist/prefabs/ReceptionistAgent.d.ts +16 -5
- package/dist/prefabs/ReceptionistAgent.js +39 -31
- package/dist/prefabs/ReceptionistAgent.js.map +1 -1
- package/dist/prefabs/SurveyAgent.d.ts +22 -4
- package/dist/prefabs/SurveyAgent.js +84 -68
- package/dist/prefabs/SurveyAgent.js.map +1 -1
- package/dist/relay/Action.d.ts +44 -21
- package/dist/relay/Action.js +75 -17
- package/dist/relay/Action.js.map +1 -1
- package/dist/relay/Call.d.ts +312 -47
- package/dist/relay/Call.js +369 -18
- package/dist/relay/Call.js.map +1 -1
- package/dist/relay/Deferred.js.map +1 -1
- package/dist/relay/Message.d.ts +26 -5
- package/dist/relay/Message.js +36 -6
- package/dist/relay/Message.js.map +1 -1
- package/dist/relay/RelayClient.d.ts +79 -14
- package/dist/relay/RelayClient.js +268 -61
- package/dist/relay/RelayClient.js.map +1 -1
- package/dist/relay/RelayError.d.ts +14 -0
- package/dist/relay/RelayError.js +15 -0
- package/dist/relay/RelayError.js.map +1 -1
- package/dist/relay/RelayEvent.d.ts +96 -65
- package/dist/relay/RelayEvent.js +85 -56
- package/dist/relay/RelayEvent.js.map +1 -1
- package/dist/relay/closedSets.d.ts +111 -0
- package/dist/relay/closedSets.js +83 -0
- package/dist/relay/closedSets.js.map +1 -0
- package/dist/relay/index.d.ts +3 -1
- package/dist/relay/index.js +1 -0
- package/dist/relay/index.js.map +1 -1
- package/dist/relay/normalize.js.map +1 -1
- package/dist/relay/protocol.types.generated.d.ts +1195 -0
- package/dist/relay/protocol.types.generated.js +8 -0
- package/dist/relay/protocol.types.generated.js.map +1 -0
- package/dist/relay/types.d.ts +81 -39
- package/dist/rest/HttpClient.d.ts +36 -8
- package/dist/rest/HttpClient.js +233 -40
- package/dist/rest/HttpClient.js.map +1 -1
- package/dist/rest/RequestOptions.d.ts +110 -0
- package/dist/rest/RequestOptions.js +113 -0
- package/dist/rest/RequestOptions.js.map +1 -0
- package/dist/rest/RestError.d.ts +52 -6
- package/dist/rest/RestError.js +89 -5
- package/dist/rest/RestError.js.map +1 -1
- package/dist/rest/base/CrudResource.d.ts +16 -26
- package/dist/rest/base/CrudResource.js +19 -33
- package/dist/rest/base/CrudResource.js.map +1 -1
- package/dist/rest/base/CrudWithAddresses.d.ts +3 -2
- package/dist/rest/base/CrudWithAddresses.js +2 -2
- package/dist/rest/base/CrudWithAddresses.js.map +1 -1
- package/dist/rest/base/FabricResource.d.ts +15 -0
- package/dist/rest/base/FabricResource.js +16 -0
- package/dist/rest/base/FabricResource.js.map +1 -0
- package/dist/rest/base/ReadResource.d.ts +62 -0
- package/dist/rest/base/ReadResource.js +69 -0
- package/dist/rest/base/ReadResource.js.map +1 -0
- package/dist/rest/callHandler.d.ts +63 -0
- package/dist/rest/callHandler.js +62 -0
- package/dist/rest/callHandler.js.map +1 -0
- package/dist/rest/index.d.ts +19 -76
- package/dist/rest/index.js +49 -120
- package/dist/rest/index.js.map +1 -1
- package/dist/rest/namespaces/_client_tree_generated.d.ts +103 -0
- package/dist/rest/namespaces/_client_tree_generated.js +171 -0
- package/dist/rest/namespaces/_client_tree_generated.js.map +1 -0
- package/dist/rest/namespaces/addresses.d.ts +3 -42
- package/dist/rest/namespaces/addresses.js +3 -50
- package/dist/rest/namespaces/addresses.js.map +1 -1
- package/dist/rest/namespaces/calling.d.ts +6 -378
- package/dist/rest/namespaces/calling.js +6 -473
- package/dist/rest/namespaces/calling.js.map +1 -1
- package/dist/rest/namespaces/calling.resources.generated.d.ts +165 -0
- package/dist/rest/namespaces/calling.resources.generated.js +477 -0
- package/dist/rest/namespaces/calling.resources.generated.js.map +1 -0
- package/dist/rest/namespaces/calling.types.generated.d.ts +2917 -0
- package/dist/rest/namespaces/calling.types.generated.js +8 -0
- package/dist/rest/namespaces/calling.types.generated.js.map +1 -0
- package/dist/rest/namespaces/chat.d.ts +4 -18
- package/dist/rest/namespaces/chat.js +4 -21
- package/dist/rest/namespaces/chat.js.map +1 -1
- package/dist/rest/namespaces/chat.resources.generated.d.ts +12 -0
- package/dist/rest/namespaces/chat.resources.generated.js +29 -0
- package/dist/rest/namespaces/chat.resources.generated.js.map +1 -0
- package/dist/rest/namespaces/chat.types.generated.d.ts +56 -0
- package/dist/rest/namespaces/chat.types.generated.js +8 -0
- package/dist/rest/namespaces/chat.types.generated.js.map +1 -0
- package/dist/rest/namespaces/datasphere.d.ts +6 -62
- package/dist/rest/namespaces/datasphere.js +6 -72
- package/dist/rest/namespaces/datasphere.js.map +1 -1
- package/dist/rest/namespaces/datasphere.resources.generated.d.ts +25 -0
- package/dist/rest/namespaces/datasphere.resources.generated.js +50 -0
- package/dist/rest/namespaces/datasphere.resources.generated.js.map +1 -0
- package/dist/rest/namespaces/datasphere.types.generated.d.ts +180 -0
- package/dist/rest/namespaces/datasphere.types.generated.js +8 -0
- package/dist/rest/namespaces/datasphere.types.generated.js.map +1 -0
- package/dist/rest/namespaces/fabric.d.ts +11 -273
- package/dist/rest/namespaces/fabric.js +14 -363
- package/dist/rest/namespaces/fabric.js.map +1 -1
- package/dist/rest/namespaces/fabric.resources.generated.d.ts +195 -0
- package/dist/rest/namespaces/fabric.resources.generated.js +399 -0
- package/dist/rest/namespaces/fabric.resources.generated.js.map +1 -0
- package/dist/rest/namespaces/fabric.types.generated.d.ts +4557 -0
- package/dist/rest/namespaces/fabric.types.generated.js +8 -0
- package/dist/rest/namespaces/fabric.types.generated.js.map +1 -0
- package/dist/rest/namespaces/fax.resources.generated.d.ts +6 -0
- package/dist/rest/namespaces/fax.resources.generated.js +14 -0
- package/dist/rest/namespaces/fax.resources.generated.js.map +1 -0
- package/dist/rest/namespaces/fax.types.generated.d.ts +131 -0
- package/dist/rest/namespaces/fax.types.generated.js +8 -0
- package/dist/rest/namespaces/fax.types.generated.js.map +1 -0
- package/dist/rest/namespaces/imported-numbers.d.ts +3 -18
- package/dist/rest/namespaces/imported-numbers.js +3 -21
- package/dist/rest/namespaces/imported-numbers.js.map +1 -1
- package/dist/rest/namespaces/logs.d.ts +10 -101
- package/dist/rest/namespaces/logs.js +10 -128
- package/dist/rest/namespaces/logs.js.map +1 -1
- package/dist/rest/namespaces/logs.resources.generated.d.ts +9 -0
- package/dist/rest/namespaces/logs.resources.generated.js +17 -0
- package/dist/rest/namespaces/logs.resources.generated.js.map +1 -0
- package/dist/rest/namespaces/logs.types.generated.d.ts +131 -0
- package/dist/rest/namespaces/logs.types.generated.js +8 -0
- package/dist/rest/namespaces/logs.types.generated.js.map +1 -0
- package/dist/rest/namespaces/lookup.d.ts +3 -25
- package/dist/rest/namespaces/lookup.js +3 -27
- package/dist/rest/namespaces/lookup.js.map +1 -1
- package/dist/rest/namespaces/message.resources.generated.d.ts +6 -0
- package/dist/rest/namespaces/message.resources.generated.js +14 -0
- package/dist/rest/namespaces/message.resources.generated.js.map +1 -0
- package/dist/rest/namespaces/message.types.generated.d.ts +122 -0
- package/dist/rest/namespaces/message.types.generated.js +8 -0
- package/dist/rest/namespaces/message.types.generated.js.map +1 -0
- package/dist/rest/namespaces/messages.resources.generated.d.ts +18 -0
- package/dist/rest/namespaces/messages.resources.generated.js +44 -0
- package/dist/rest/namespaces/messages.resources.generated.js.map +1 -0
- package/dist/rest/namespaces/messages.types.generated.d.ts +99 -0
- package/dist/rest/namespaces/messages.types.generated.js +8 -0
- package/dist/rest/namespaces/messages.types.generated.js.map +1 -0
- package/dist/rest/namespaces/mfa.d.ts +3 -42
- package/dist/rest/namespaces/mfa.js +3 -49
- package/dist/rest/namespaces/mfa.js.map +1 -1
- package/dist/rest/namespaces/number-groups.d.ts +3 -45
- package/dist/rest/namespaces/number-groups.js +3 -53
- package/dist/rest/namespaces/number-groups.js.map +1 -1
- package/dist/rest/namespaces/phone-numbers.d.ts +9 -57
- package/dist/rest/namespaces/phone-numbers.js +9 -63
- package/dist/rest/namespaces/phone-numbers.js.map +1 -1
- package/dist/rest/namespaces/project.d.ts +6 -42
- package/dist/rest/namespaces/project.js +6 -51
- package/dist/rest/namespaces/project.js.map +1 -1
- package/dist/rest/namespaces/project.resources.generated.d.ts +17 -0
- package/dist/rest/namespaces/project.resources.generated.js +44 -0
- package/dist/rest/namespaces/project.resources.generated.js.map +1 -0
- package/dist/rest/namespaces/project.types.generated.d.ts +58 -0
- package/dist/rest/namespaces/project.types.generated.js +8 -0
- package/dist/rest/namespaces/project.types.generated.js.map +1 -0
- package/dist/rest/namespaces/projects.resources.generated.d.ts +12 -0
- package/dist/rest/namespaces/projects.resources.generated.js +25 -0
- package/dist/rest/namespaces/projects.resources.generated.js.map +1 -0
- package/dist/rest/namespaces/projects.types.generated.d.ts +77 -0
- package/dist/rest/namespaces/projects.types.generated.js +8 -0
- package/dist/rest/namespaces/projects.types.generated.js.map +1 -0
- package/dist/rest/namespaces/pubsub.d.ts +4 -18
- package/dist/rest/namespaces/pubsub.js +4 -21
- package/dist/rest/namespaces/pubsub.js.map +1 -1
- package/dist/rest/namespaces/pubsub.resources.generated.d.ts +12 -0
- package/dist/rest/namespaces/pubsub.resources.generated.js +29 -0
- package/dist/rest/namespaces/pubsub.resources.generated.js.map +1 -0
- package/dist/rest/namespaces/pubsub.types.generated.d.ts +60 -0
- package/dist/rest/namespaces/pubsub.types.generated.js +8 -0
- package/dist/rest/namespaces/pubsub.types.generated.js.map +1 -0
- package/dist/rest/namespaces/queues.d.ts +3 -38
- package/dist/rest/namespaces/queues.js +3 -44
- package/dist/rest/namespaces/queues.js.map +1 -1
- package/dist/rest/namespaces/recordings.d.ts +3 -34
- package/dist/rest/namespaces/recordings.js +3 -40
- package/dist/rest/namespaces/recordings.js.map +1 -1
- package/dist/rest/namespaces/registry.d.ts +6 -137
- package/dist/rest/namespaces/registry.js +6 -173
- package/dist/rest/namespaces/registry.js.map +1 -1
- package/dist/rest/namespaces/relay-rest.resources.generated.d.ts +168 -0
- package/dist/rest/namespaces/relay-rest.resources.generated.js +430 -0
- package/dist/rest/namespaces/relay-rest.resources.generated.js.map +1 -0
- package/dist/rest/namespaces/relay-rest.types.generated.d.ts +1906 -0
- package/dist/rest/namespaces/relay-rest.types.generated.js +8 -0
- package/dist/rest/namespaces/relay-rest.types.generated.js.map +1 -0
- package/dist/rest/namespaces/short-codes.d.ts +3 -35
- package/dist/rest/namespaces/short-codes.js +3 -41
- package/dist/rest/namespaces/short-codes.js.map +1 -1
- package/dist/rest/namespaces/sip-profile.d.ts +3 -24
- package/dist/rest/namespaces/sip-profile.js +3 -29
- package/dist/rest/namespaces/sip-profile.js.map +1 -1
- package/dist/rest/namespaces/verified-callers.d.ts +3 -29
- package/dist/rest/namespaces/verified-callers.js +3 -34
- package/dist/rest/namespaces/verified-callers.js.map +1 -1
- package/dist/rest/namespaces/video.d.ts +10 -227
- package/dist/rest/namespaces/video.js +10 -288
- package/dist/rest/namespaces/video.js.map +1 -1
- package/dist/rest/namespaces/video.resources.generated.d.ts +81 -0
- package/dist/rest/namespaces/video.resources.generated.js +171 -0
- package/dist/rest/namespaces/video.resources.generated.js.map +1 -0
- package/dist/rest/namespaces/video.types.generated.d.ts +771 -0
- package/dist/rest/namespaces/video.types.generated.js +8 -0
- package/dist/rest/namespaces/video.types.generated.js.map +1 -0
- package/dist/rest/namespaces/voice.resources.generated.d.ts +9 -0
- package/dist/rest/namespaces/voice.resources.generated.js +17 -0
- package/dist/rest/namespaces/voice.resources.generated.js.map +1 -0
- package/dist/rest/namespaces/voice.types.generated.d.ts +214 -0
- package/dist/rest/namespaces/voice.types.generated.js +8 -0
- package/dist/rest/namespaces/voice.types.generated.js.map +1 -0
- package/dist/rest/pagination.d.ts +5 -1
- package/dist/rest/pagination.js +40 -20
- package/dist/rest/pagination.js.map +1 -1
- package/dist/rest/types.d.ts +21 -3
- package/dist/schema.json +299 -98
- package/dist/skills/SkillBase.d.ts +97 -20
- package/dist/skills/SkillBase.js +100 -17
- package/dist/skills/SkillBase.js.map +1 -1
- package/dist/skills/SkillManager.d.ts +66 -13
- package/dist/skills/SkillManager.js +101 -20
- package/dist/skills/SkillManager.js.map +1 -1
- package/dist/skills/SkillName.d.ts +44 -0
- package/dist/skills/SkillName.js +2 -0
- package/dist/skills/SkillName.js.map +1 -0
- package/dist/skills/SkillRegistry.d.ts +47 -7
- package/dist/skills/SkillRegistry.js +85 -13
- package/dist/skills/SkillRegistry.js.map +1 -1
- package/dist/skills/builtin/api_ninjas_trivia.d.ts +3 -1
- package/dist/skills/builtin/api_ninjas_trivia.js +24 -8
- package/dist/skills/builtin/api_ninjas_trivia.js.map +1 -1
- package/dist/skills/builtin/ask_claude.d.ts +14 -4
- package/dist/skills/builtin/ask_claude.js +36 -14
- package/dist/skills/builtin/ask_claude.js.map +1 -1
- package/dist/skills/builtin/claude_skills.d.ts +3 -1
- package/dist/skills/builtin/claude_skills.js +19 -15
- package/dist/skills/builtin/claude_skills.js.map +1 -1
- package/dist/skills/builtin/custom_skills.d.ts +10 -3
- package/dist/skills/builtin/custom_skills.js +26 -9
- package/dist/skills/builtin/custom_skills.js.map +1 -1
- package/dist/skills/builtin/datasphere.d.ts +5 -3
- package/dist/skills/builtin/datasphere.js +34 -25
- package/dist/skills/builtin/datasphere.js.map +1 -1
- package/dist/skills/builtin/datasphere_serverless.d.ts +12 -1
- package/dist/skills/builtin/datasphere_serverless.js +17 -6
- package/dist/skills/builtin/datasphere_serverless.js.map +1 -1
- package/dist/skills/builtin/datetime.d.ts +3 -1
- package/dist/skills/builtin/datetime.js +11 -7
- package/dist/skills/builtin/datetime.js.map +1 -1
- package/dist/skills/builtin/google_maps.d.ts +29 -14
- package/dist/skills/builtin/google_maps.js +89 -269
- package/dist/skills/builtin/google_maps.js.map +1 -1
- package/dist/skills/builtin/index.d.ts +8 -6
- package/dist/skills/builtin/index.js +8 -6
- package/dist/skills/builtin/index.js.map +1 -1
- package/dist/skills/builtin/info_gatherer.d.ts +4 -2
- package/dist/skills/builtin/info_gatherer.js +20 -12
- package/dist/skills/builtin/info_gatherer.js.map +1 -1
- package/dist/skills/builtin/joke.d.ts +16 -6
- package/dist/skills/builtin/joke.js +54 -37
- package/dist/skills/builtin/joke.js.map +1 -1
- package/dist/skills/builtin/math.d.ts +3 -1
- package/dist/skills/builtin/math.js +14 -9
- package/dist/skills/builtin/math.js.map +1 -1
- package/dist/skills/builtin/mcp_gateway.d.ts +34 -5
- package/dist/skills/builtin/mcp_gateway.js +77 -46
- package/dist/skills/builtin/mcp_gateway.js.map +1 -1
- package/dist/skills/builtin/native_vector_search.d.ts +19 -5
- package/dist/skills/builtin/native_vector_search.js +179 -61
- package/dist/skills/builtin/native_vector_search.js.map +1 -1
- package/dist/skills/builtin/play_background_file.d.ts +21 -15
- package/dist/skills/builtin/play_background_file.js +43 -122
- package/dist/skills/builtin/play_background_file.js.map +1 -1
- package/dist/skills/builtin/spider.d.ts +46 -1
- package/dist/skills/builtin/spider.js +317 -101
- package/dist/skills/builtin/spider.js.map +1 -1
- package/dist/skills/builtin/swml_transfer.d.ts +14 -3
- package/dist/skills/builtin/swml_transfer.js +45 -24
- package/dist/skills/builtin/swml_transfer.js.map +1 -1
- package/dist/skills/builtin/weather_api.d.ts +24 -13
- package/dist/skills/builtin/weather_api.js +57 -31
- package/dist/skills/builtin/weather_api.js.map +1 -1
- package/dist/skills/builtin/web_search.d.ts +48 -10
- package/dist/skills/builtin/web_search.js +301 -84
- package/dist/skills/builtin/web_search.js.map +1 -1
- package/dist/skills/builtin/wikipedia_search.d.ts +4 -2
- package/dist/skills/builtin/wikipedia_search.js +32 -14
- package/dist/skills/builtin/wikipedia_search.js.map +1 -1
- package/dist/skills/index.d.ts +3 -2
- package/dist/skills/index.js +1 -1
- package/dist/skills/index.js.map +1 -1
- package/dist/swml_verbs_generated.d.ts +2824 -0
- package/dist/swml_verbs_generated.js +12 -0
- package/dist/swml_verbs_generated.js.map +1 -0
- package/dist/types.d.ts +65 -6
- package/dist/web.d.ts +27 -0
- package/dist/web.js +20 -0
- package/dist/web.js.map +1 -0
- package/docs/agent-guide.md +1034 -0
- package/docs/ai_chat.md +560 -0
- package/docs/api-reference.md +3534 -0
- package/docs/architecture.md +846 -0
- package/docs/bedrock_agent.md +411 -0
- package/docs/cli-guide.md +403 -0
- package/docs/cloud_functions_guide.md +399 -0
- package/docs/configuration.md +548 -0
- package/docs/contexts-guide.md +884 -0
- package/docs/datamap-guide.md +1160 -0
- package/docs/developer_pain_points.md +548 -0
- package/docs/llm_parameters.md +298 -0
- package/docs/mcp_gateway_reference.md +354 -0
- package/docs/mcp_integration.md +162 -0
- package/docs/pgi_agent_guide.md +1820 -0
- package/docs/prefabs-guide.md +815 -0
- package/docs/programmatically_governed_inference.md +301 -0
- package/docs/sdk_features.md +501 -0
- package/docs/security.md +559 -0
- package/docs/serverless-guide.md +520 -0
- package/docs/skills-guide.md +1223 -0
- package/docs/skills-system.md +405 -0
- package/docs/skills_parameter_schema.md +417 -0
- package/docs/swaig-reference.md +1938 -0
- package/docs/swml_service_guide.md +573 -0
- package/docs/third_party_skills.md +410 -0
- package/docs/web_service.md +666 -0
- package/examples/README.md +202 -0
- package/examples/advanced-datamap.ts +108 -0
- package/examples/advanced-dynamic-config.ts +70 -0
- package/examples/auto-vivified.ts +95 -0
- package/examples/call-flow.ts +65 -0
- package/examples/comprehensive-dynamic.ts +125 -0
- package/examples/contexts-steps.ts +65 -0
- package/examples/custom-path.ts +45 -0
- package/examples/datamap-tools.ts +51 -0
- package/examples/datasphere-multi-instance.ts +66 -0
- package/examples/datasphere-serverless-env.ts +87 -0
- package/examples/datasphere-webhook-env.ts +65 -0
- package/examples/datasphere.ts +56 -0
- package/examples/declarative.ts +100 -0
- package/examples/dynamic-config.ts +54 -0
- package/examples/dynamic-info-gatherer.ts +69 -0
- package/examples/dynamic-swml-service.ts +67 -0
- package/examples/gather-info.ts +95 -0
- package/examples/gather-per-question-functions-demo.ts +139 -0
- package/examples/joke-agent.ts +34 -0
- package/examples/kubernetes-agent.ts +45 -0
- package/examples/llm-params.ts +75 -0
- package/examples/mcp-agent.ts +89 -0
- package/examples/mcp-gateway.ts +81 -0
- package/examples/multi-agent.ts +80 -0
- package/examples/multi-endpoint.ts +79 -0
- package/examples/pgi/case-domain.ts +114 -0
- package/examples/pgi/serve.ts +16 -0
- package/examples/pgi/support-agent.ts +265 -0
- package/examples/pom-prompt.ts +70 -0
- package/examples/prefab-concierge.ts +42 -0
- package/examples/prefab-faq.ts +58 -0
- package/examples/prefab-info-gatherer.ts +33 -0
- package/examples/prefab-receptionist.ts +36 -0
- package/examples/prefab-survey.ts +69 -0
- package/examples/quickstart-agent.ts +29 -0
- package/examples/quickstart-relay.ts +25 -0
- package/examples/quickstart-rest.ts +25 -0
- package/examples/record-call.ts +65 -0
- package/examples/relay-demo.ts +33 -0
- package/examples/room-and-sip.ts +93 -0
- package/examples/serverless-lambda.ts +43 -0
- package/examples/session-state.ts +83 -0
- package/examples/simple-agent.ts +36 -0
- package/examples/simple-static.ts +29 -0
- package/examples/skills-demo.ts +41 -0
- package/examples/step-function-inheritance-demo.ts +124 -0
- package/examples/swaig-features.ts +193 -0
- package/examples/swml-service-routing.ts +66 -0
- package/examples/swml-service.ts +38 -0
- package/examples/swmlservice_ai_sidecar.ts +104 -0
- package/examples/swmlservice_swaig_standalone.ts +79 -0
- package/examples/tap.ts +67 -0
- package/examples/typed-tools.ts +68 -0
- package/examples/verb-methods.ts +45 -0
- package/examples/web-search-multi-instance.ts +75 -0
- package/examples/web-search.ts +38 -0
- package/examples/wikipedia.ts +36 -0
- package/livewire/README.md +164 -0
- package/livewire/docs/migration-guide.md +251 -0
- package/livewire/examples/livewire-basic-agent.ts +74 -0
- package/livewire/examples/livewire-handoff.ts +196 -0
- package/livewire/examples/livewire-multi-tool.ts +121 -0
- package/package.json +88 -13
- package/relay/README.md +101 -0
- package/relay/docs/call-methods.md +622 -0
- package/relay/docs/client-reference.md +281 -0
- package/relay/docs/events.md +193 -0
- package/relay/docs/getting-started.md +221 -0
- package/relay/docs/guide.md +386 -0
- package/relay/docs/messaging.md +246 -0
- package/relay/examples/relay-inbound.ts +66 -0
- package/relay/examples/relay-messaging.ts +74 -0
- package/relay/examples/relay-outbound.ts +76 -0
- package/rest/README.md +141 -0
- package/rest/docs/calling.md +313 -0
- package/rest/docs/client-reference.md +149 -0
- package/rest/docs/fabric.md +192 -0
- package/rest/docs/getting-started.md +138 -0
- package/rest/docs/guide.md +421 -0
- package/rest/docs/namespaces.md +367 -0
- package/rest/docs/phone-binding.md +116 -0
- package/rest/examples/rest-10dlc-registration.ts +177 -0
- package/rest/examples/rest-bind-phone-to-swml-webhook.ts +66 -0
- package/rest/examples/rest-calling-ivr-and-ai.ts +136 -0
- package/rest/examples/rest-calling-play-and-record.ts +98 -0
- package/rest/examples/rest-client.ts +59 -0
- package/rest/examples/rest-datasphere-search.ts +81 -0
- package/rest/examples/rest-fabric-conferences-and-routing.ts +147 -0
- package/rest/examples/rest-fabric-subscribers-and-sip.ts +106 -0
- package/rest/examples/rest-fabric-swml-and-callflows.ts +101 -0
- package/rest/examples/rest-manage-resources.ts +64 -0
- package/rest/examples/rest-phone-number-management.ts +200 -0
- package/rest/examples/rest-queues-mfa-and-recordings.ts +143 -0
- package/rest/examples/rest-video-rooms.ts +186 -0
- package/tutorial/fred/fred.ts +218 -0
- package/tutorial/fred/tutorial/01-introduction.md +141 -0
- package/tutorial/fred/tutorial/02-setup.md +304 -0
- package/tutorial/fred/tutorial/03-basic-agent.md +284 -0
- package/tutorial/fred/tutorial/04-wikipedia-skill.md +298 -0
- package/tutorial/fred/tutorial/05-custom-functions.md +347 -0
- package/tutorial/fred/tutorial/06-running-testing.md +642 -0
- package/tutorial/fred/tutorial/README.md +56 -0
- package/tutorial/fred/tutorial/appendix-complete-code.md +632 -0
- package/tutorial/fred/tutorial/appendix-docker-deployment.md +504 -0
- package/tutorial/full-guardrails-agent/handlers.ts +436 -0
- package/tutorial/full-guardrails-agent/penny.ts +305 -0
- package/tutorial/full-guardrails-agent/reservations.ts +1109 -0
- package/tutorial/full-guardrails-agent/tutorial/01-why-guardrails.md +149 -0
- package/tutorial/full-guardrails-agent/tutorial/02-design-first.md +139 -0
- package/tutorial/full-guardrails-agent/tutorial/03-rules-first.md +422 -0
- package/tutorial/full-guardrails-agent/tutorial/04-the-shell.md +238 -0
- package/tutorial/full-guardrails-agent/tutorial/05-steps-and-scoping.md +247 -0
- package/tutorial/full-guardrails-agent/tutorial/06-tools-that-decide.md +467 -0
- package/tutorial/full-guardrails-agent/tutorial/07-gather-and-projection.md +160 -0
- package/tutorial/full-guardrails-agent/tutorial/08-the-verification-gate.md +333 -0
- package/tutorial/full-guardrails-agent/tutorial/09-people-and-endings.md +313 -0
- package/tutorial/full-guardrails-agent/tutorial/10-testing-and-running.md +387 -0
- package/tutorial/full-guardrails-agent/tutorial/README.md +106 -0
- package/tutorial/full-guardrails-agent/tutorial/appendix-complete-code.md +2207 -0
- package/tutorial/full-guardrails-agent/tutorial/appendix-deployment.md +191 -0
- package/tutorial/full-guardrails-agent/tutorial/appendix-technique-map.md +117 -0
- package/tutorial/full-guardrails-agent/workflow.ts +219 -0
- package/tutorial/multi_agents/README.md +175 -0
- package/tutorial/multi_agents/advanced_agent.ts +395 -0
- package/tutorial/multi_agents/extending_agents.ts +641 -0
- package/tutorial/multi_agents/knowledge.ts +59 -0
- package/tutorial/multi_agents/lesson1_first_agent.md +368 -0
- package/tutorial/multi_agents/lesson2_knowledge_bases.md +404 -0
- package/tutorial/multi_agents/lesson3_multi_agent_systems.md +621 -0
- package/tutorial/multi_agents/lesson4_advanced_features.md +805 -0
- package/tutorial/multi_agents/lesson5_extending_agents.md +856 -0
- package/tutorial/multi_agents/pc_builder.ts +529 -0
- package/tutorial/multi_agents/sales_agent.ts +88 -0
- package/tutorial/multi_agents/sales_agent_with_search.ts +116 -0
- package/tutorial/multi_agents/sales_knowledge.md +139 -0
- package/tutorial/multi_agents/support_knowledge.md +256 -0
- package/dist/cli/mock-data.d.ts +0 -37
- package/dist/cli/mock-data.js +0 -80
- package/dist/cli/mock-data.js.map +0 -1
- package/dist/generateVerbTypes.d.ts +0 -11
- package/dist/generateVerbTypes.js +0 -265
- package/dist/generateVerbTypes.js.map +0 -1
- package/dist/rest/namespaces/compat.d.ts +0 -585
- package/dist/rest/namespaces/compat.js +0 -735
- package/dist/rest/namespaces/compat.js.map +0 -1
|
@@ -0,0 +1,518 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HandoffRouter - moving one conversation between voice and text.
|
|
3
|
+
*
|
|
4
|
+
* {@link ChatGateway} lets a browser hold a text conversation. This module
|
|
5
|
+
* provides the other routes a browser client needs: moving that conversation
|
|
6
|
+
* to a phone call and back, and typing into a live call.
|
|
7
|
+
*
|
|
8
|
+
* The browser side already exists. The SignalWire address widget calls
|
|
9
|
+
* `{gateway-url}/handoff`, `{gateway-url}/escalate` and `{gateway-url}/say`
|
|
10
|
+
* on the same URL that serves a `ChatGateway`, and sends `handoff_nonce` and
|
|
11
|
+
* `chat_handle` as user variables. Without these routes, a gateway answers
|
|
12
|
+
* the widget's JSON-RPC and returns 404 for the rest.
|
|
13
|
+
*
|
|
14
|
+
* ## Mechanism, not policy
|
|
15
|
+
*
|
|
16
|
+
* This class implements the wire contract: the routes, the nonce, the
|
|
17
|
+
* ordering guarantee and the spend limits. What a conversation is belongs to
|
|
18
|
+
* the application: where a leg's transcript is written, what a resumed
|
|
19
|
+
* greeting says, how much history to carry. Those are callbacks.
|
|
20
|
+
*
|
|
21
|
+
* ## The nonce
|
|
22
|
+
*
|
|
23
|
+
* A browser can't be trusted to name a call. `ai_message` takes a call id,
|
|
24
|
+
* and accepting one from a page would let anyone who learned or guessed an id
|
|
25
|
+
* inject speech into someone else's call. Instead, the application puts a
|
|
26
|
+
* random `handoff_nonce` in the user variables of one dial, registers it here
|
|
27
|
+
* against that call, and the browser presents it later. The nonce appears
|
|
28
|
+
* nowhere else, so presenting it shows the browser placed that call.
|
|
29
|
+
*
|
|
30
|
+
* Exchanging a nonce for a chat handle works once. Typing works repeatedly,
|
|
31
|
+
* up to `maxMessagesPerCall`, until `/handoff` uses the nonce or `nonceTtl`
|
|
32
|
+
* seconds pass from its registration, even if the call is still live. An
|
|
33
|
+
* unknown nonce gets the same answer as an expired one, so the routes can't
|
|
34
|
+
* be used to learn whether a call is live.
|
|
35
|
+
*
|
|
36
|
+
* ## The ordering guarantee
|
|
37
|
+
*
|
|
38
|
+
* A medium doesn't start until the one it replaces has ended and its record
|
|
39
|
+
* is written. `/handoff` ends the call and waits for the application to
|
|
40
|
+
* confirm the capture before issuing a handle; `/escalate` waits for the chat
|
|
41
|
+
* leg's capture before returning. Without the wait, the new medium's config
|
|
42
|
+
* fetch can run before the record exists, and the new leg starts with no
|
|
43
|
+
* history.
|
|
44
|
+
*
|
|
45
|
+
* ## Deployment
|
|
46
|
+
*
|
|
47
|
+
* The nonce registry lives in this process, like `ChatGateway`'s cap
|
|
48
|
+
* counters. A redemption must reach the replica that served the dial: run one
|
|
49
|
+
* replica, use sticky routing, or supply a shared `registry`.
|
|
50
|
+
*
|
|
51
|
+
* Registration, redemption and taking a typing slot each read the table and
|
|
52
|
+
* write it back without waiting on anything in between, so within one
|
|
53
|
+
* process overlapping requests can't redeem a nonce twice or pass the typing
|
|
54
|
+
* cap. Every change is written back with `set()`, so a `registry` that
|
|
55
|
+
* returns copies stores it. When replicas share a `registry`, each of those
|
|
56
|
+
* steps is a read followed by a write that another replica can interleave,
|
|
57
|
+
* so a nonce can be redeemed once by each, and the typing cap can be passed.
|
|
58
|
+
* The `registry` is a plain `Map`, so the SDK can't make those steps atomic
|
|
59
|
+
* across replicas; use one nonce table, or route each call's requests to one
|
|
60
|
+
* replica.
|
|
61
|
+
*
|
|
62
|
+
* Mirrors signalwire-python's `signalwire.ai_chat.handoff`.
|
|
63
|
+
*/
|
|
64
|
+
import { Hono } from 'hono';
|
|
65
|
+
import { getLogger } from '../Logger.js';
|
|
66
|
+
import { GatewayRejection, MAX_MESSAGE_BYTES, _readJsonBody, _utf8Length, } from './ChatGateway.js';
|
|
67
|
+
const logger = getLogger('ai_chat.handoff');
|
|
68
|
+
/** Seconds a nonce stays usable for `/handoff` and `/say`, from registration. */
|
|
69
|
+
export const DEFAULT_NONCE_TTL = 3600;
|
|
70
|
+
/** Typed messages allowed per call. */
|
|
71
|
+
export const DEFAULT_MAX_MESSAGES_PER_CALL = 200;
|
|
72
|
+
/** Seconds to wait for `captureLeg`. */
|
|
73
|
+
export const DEFAULT_CAPTURE_TIMEOUT = 8.0;
|
|
74
|
+
/** Seconds on a monotonic clock. */
|
|
75
|
+
function monotonic() {
|
|
76
|
+
return performance.now() / 1000;
|
|
77
|
+
}
|
|
78
|
+
/** What a registered nonce gives access to. */
|
|
79
|
+
export class NonceEntry {
|
|
80
|
+
/** The conversation the call belongs to. */
|
|
81
|
+
conversationId;
|
|
82
|
+
/** The platform call id, from the request the platform sent. */
|
|
83
|
+
callId;
|
|
84
|
+
/** When it was registered, in monotonic seconds. */
|
|
85
|
+
issuedAt;
|
|
86
|
+
/** Typed messages delivered so far. */
|
|
87
|
+
messages;
|
|
88
|
+
/**
|
|
89
|
+
* True once `/handoff` has used the nonce. The entry stays in the table
|
|
90
|
+
* until it would have expired, so registering the nonce again can't make
|
|
91
|
+
* it usable again.
|
|
92
|
+
*/
|
|
93
|
+
redeemed;
|
|
94
|
+
/**
|
|
95
|
+
* @param conversationId - The conversation the call belongs to.
|
|
96
|
+
* @param callId - The platform call id.
|
|
97
|
+
* @param issuedAt - When it was registered, in monotonic seconds; now by default.
|
|
98
|
+
* @param messages - Typed messages delivered so far.
|
|
99
|
+
* @param redeemed - Whether `/handoff` has used the nonce.
|
|
100
|
+
*/
|
|
101
|
+
constructor(conversationId, callId = null, issuedAt = monotonic(), messages = 0, redeemed = false) {
|
|
102
|
+
this.conversationId = conversationId;
|
|
103
|
+
this.callId = callId;
|
|
104
|
+
this.issuedAt = issuedAt;
|
|
105
|
+
this.messages = messages;
|
|
106
|
+
this.redeemed = redeemed;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/** The three routes a browser client needs beside a {@link ChatGateway}. */
|
|
110
|
+
export class HandoffRouter {
|
|
111
|
+
/** The gateway that issues and reads handles and checks origins. */
|
|
112
|
+
gateway;
|
|
113
|
+
/** Ends a leg and writes its record, or null. */
|
|
114
|
+
captureLeg;
|
|
115
|
+
/** Hangs a call up server-side, or null. */
|
|
116
|
+
endCall;
|
|
117
|
+
/** Delivers typed text into a call, or null (typing off). */
|
|
118
|
+
sendMessage;
|
|
119
|
+
/** Produces the id for a new leg. */
|
|
120
|
+
nextConversationId;
|
|
121
|
+
/** Seconds a nonce stays usable for `/handoff` and `/say`, from registration. */
|
|
122
|
+
nonceTtl;
|
|
123
|
+
/** Typed messages allowed per call. */
|
|
124
|
+
maxMessagesPerCall;
|
|
125
|
+
/** Seconds to wait for `captureLeg`. */
|
|
126
|
+
captureTimeout;
|
|
127
|
+
_nonces;
|
|
128
|
+
/**
|
|
129
|
+
* @param options - The gateway, the application's callbacks, and the limits.
|
|
130
|
+
*/
|
|
131
|
+
constructor(options) {
|
|
132
|
+
this.gateway = options.gateway;
|
|
133
|
+
this.captureLeg = options.captureLeg ?? null;
|
|
134
|
+
this.endCall = options.endCall ?? null;
|
|
135
|
+
this.sendMessage = options.sendMessage ?? null;
|
|
136
|
+
this.nextConversationId = options.nextConversationId ?? HandoffRouter._defaultNextId;
|
|
137
|
+
this.nonceTtl = options.nonceTtl ?? DEFAULT_NONCE_TTL;
|
|
138
|
+
this.maxMessagesPerCall = options.maxMessagesPerCall ?? DEFAULT_MAX_MESSAGES_PER_CALL;
|
|
139
|
+
this.captureTimeout = options.captureTimeout ?? DEFAULT_CAPTURE_TIMEOUT;
|
|
140
|
+
this._nonces = options.registry ?? new Map();
|
|
141
|
+
}
|
|
142
|
+
// ── Nonces ───────────────────────────────────────────────────────
|
|
143
|
+
/** `root` → `root.1`; `root.2` → `root.3`. */
|
|
144
|
+
static _defaultNextId(conversationId) {
|
|
145
|
+
const dot = conversationId.lastIndexOf('.');
|
|
146
|
+
const root = dot < 0 ? '' : conversationId.slice(0, dot);
|
|
147
|
+
const tail = dot < 0 ? '' : conversationId.slice(dot + 1);
|
|
148
|
+
if (root && /^\d+$/.test(tail))
|
|
149
|
+
return `${root}.${Number(tail) + 1}`;
|
|
150
|
+
return `${conversationId}.1`;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Record what a nonce gives access to.
|
|
154
|
+
*
|
|
155
|
+
* Call it from the per-call config callback of the dial that carried the
|
|
156
|
+
* nonce, with `callId` from the request the platform sent, never from
|
|
157
|
+
* anything the browser supplied.
|
|
158
|
+
*
|
|
159
|
+
* Registering a nonce that's already in the table changes nothing, since
|
|
160
|
+
* the callback runs on every config request for the call. The first
|
|
161
|
+
* registration's call, time and message count stand, and a nonce `/handoff`
|
|
162
|
+
* has used stays used until it would have expired.
|
|
163
|
+
*
|
|
164
|
+
* @param nonce - The nonce put in the dial's user variables.
|
|
165
|
+
* @param opts - `conversationId`: the conversation; `callId`: the call.
|
|
166
|
+
*/
|
|
167
|
+
register(nonce, opts) {
|
|
168
|
+
if (!nonce || typeof nonce !== 'string')
|
|
169
|
+
return;
|
|
170
|
+
this._prune();
|
|
171
|
+
const callId = opts.callId ?? null;
|
|
172
|
+
const existing = this._nonces.get(nonce);
|
|
173
|
+
if (existing) {
|
|
174
|
+
if (existing.redeemed ||
|
|
175
|
+
existing.conversationId !== opts.conversationId ||
|
|
176
|
+
existing.callId !== callId) {
|
|
177
|
+
logger.warn('handoff_nonce_reregister_ignored', {
|
|
178
|
+
conversation_id: opts.conversationId,
|
|
179
|
+
call_id: callId,
|
|
180
|
+
note: existing.redeemed ? 'nonce already redeemed' : 'nonce registered to another call',
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
this._nonces.set(nonce, new NonceEntry(opts.conversationId, callId));
|
|
186
|
+
logger.info('handoff_nonce_registered', {
|
|
187
|
+
conversation_id: opts.conversationId,
|
|
188
|
+
call_id: callId,
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
_prune() {
|
|
192
|
+
const cutoff = monotonic() - this.nonceTtl;
|
|
193
|
+
for (const [nonce, entry] of this._nonces) {
|
|
194
|
+
if (entry.issuedAt < cutoff)
|
|
195
|
+
this._nonces.delete(nonce);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
_lookup(nonce) {
|
|
199
|
+
if (!nonce || typeof nonce !== 'string')
|
|
200
|
+
return null;
|
|
201
|
+
this._prune();
|
|
202
|
+
const entry = this._nonces.get(nonce);
|
|
203
|
+
return entry && !entry.redeemed ? entry : null;
|
|
204
|
+
}
|
|
205
|
+
// ── Operations ───────────────────────────────────────────────────
|
|
206
|
+
/** Wait for the application's capture, up to `captureTimeout`. Never throws. */
|
|
207
|
+
async _capture(conversationId, medium) {
|
|
208
|
+
if (!this.captureLeg)
|
|
209
|
+
return false;
|
|
210
|
+
const capture = this.captureLeg;
|
|
211
|
+
let timer;
|
|
212
|
+
const timedOut = Symbol('timeout');
|
|
213
|
+
try {
|
|
214
|
+
const result = await Promise.race([
|
|
215
|
+
Promise.resolve().then(() => capture(conversationId, medium)),
|
|
216
|
+
new Promise((resolve) => {
|
|
217
|
+
timer = setTimeout(() => resolve(timedOut), this.captureTimeout * 1000);
|
|
218
|
+
}),
|
|
219
|
+
]);
|
|
220
|
+
if (result === timedOut) {
|
|
221
|
+
logger.warn('handoff_capture_timeout', {
|
|
222
|
+
conversation_id: conversationId,
|
|
223
|
+
medium,
|
|
224
|
+
note: "starting the next medium without this leg's record",
|
|
225
|
+
});
|
|
226
|
+
return false;
|
|
227
|
+
}
|
|
228
|
+
return Boolean(result);
|
|
229
|
+
}
|
|
230
|
+
catch (err) {
|
|
231
|
+
logger.error('handoff_capture_failed', {
|
|
232
|
+
conversation_id: conversationId,
|
|
233
|
+
error: err instanceof Error ? err.message : String(err),
|
|
234
|
+
});
|
|
235
|
+
return false;
|
|
236
|
+
}
|
|
237
|
+
finally {
|
|
238
|
+
clearTimeout(timer);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Exchange a nonce for a chat handle, once.
|
|
243
|
+
*
|
|
244
|
+
* Ends the call, waits for its record, and only then issues a handle for a
|
|
245
|
+
* new leg of the same conversation.
|
|
246
|
+
*
|
|
247
|
+
* @param nonce - The nonce the browser presented.
|
|
248
|
+
* @returns The handle, or null for a nonce that's unknown, expired or
|
|
249
|
+
* already used; the three can't be told apart.
|
|
250
|
+
*/
|
|
251
|
+
async redeem(nonce) {
|
|
252
|
+
const entry = this._lookup(nonce);
|
|
253
|
+
if (!entry)
|
|
254
|
+
return null;
|
|
255
|
+
// Used up even if what follows fails: a nonce is one attempt. Keep the
|
|
256
|
+
// entry as a tombstone until it would have expired, so registering the
|
|
257
|
+
// nonce again can't make it usable again.
|
|
258
|
+
entry.redeemed = true;
|
|
259
|
+
this._nonces.set(nonce, entry);
|
|
260
|
+
if (entry.callId && this.endCall) {
|
|
261
|
+
try {
|
|
262
|
+
await this.endCall(entry.callId);
|
|
263
|
+
}
|
|
264
|
+
catch (err) {
|
|
265
|
+
logger.warn('handoff_end_call_failed', {
|
|
266
|
+
error: err instanceof Error ? err.message : String(err),
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
await this._capture(entry.conversationId, 'voice');
|
|
271
|
+
let handle;
|
|
272
|
+
try {
|
|
273
|
+
handle = this.gateway.mintHandle(this.nextConversationId(entry.conversationId));
|
|
274
|
+
}
|
|
275
|
+
catch (err) {
|
|
276
|
+
logger.error('handoff_mint_failed', {
|
|
277
|
+
error: err instanceof Error ? err.message : String(err),
|
|
278
|
+
});
|
|
279
|
+
return null;
|
|
280
|
+
}
|
|
281
|
+
logger.info('handoff_redeemed', { conversation_id: entry.conversationId });
|
|
282
|
+
return handle;
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* End a chat leg and wait for its record, before a call is placed.
|
|
286
|
+
*
|
|
287
|
+
* The browser waits for this, so a voice leg started right after finds the
|
|
288
|
+
* text leg already recorded.
|
|
289
|
+
*
|
|
290
|
+
* @param handle - The chat leg's handle.
|
|
291
|
+
* @returns False when the handle doesn't verify.
|
|
292
|
+
*/
|
|
293
|
+
async escalate(handle) {
|
|
294
|
+
let conversationId;
|
|
295
|
+
try {
|
|
296
|
+
conversationId = this.gateway.readHandle(handle);
|
|
297
|
+
}
|
|
298
|
+
catch {
|
|
299
|
+
return false;
|
|
300
|
+
}
|
|
301
|
+
await this._capture(conversationId, 'chat');
|
|
302
|
+
logger.info('handoff_escalated', { conversation_id: conversationId });
|
|
303
|
+
return true;
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Deliver typed text into the call the nonce names.
|
|
307
|
+
*
|
|
308
|
+
* Doesn't use up the nonce: typing works until `/handoff` uses it or
|
|
309
|
+
* `nonceTtl` seconds pass from its registration, even if the call is
|
|
310
|
+
* still live. The call is found by nonce, never by a browser-supplied call
|
|
311
|
+
* id, and no other request field is forwarded. In particular, `global_data`
|
|
312
|
+
* is agent state that step logic trusts, and a page must not write it.
|
|
313
|
+
*
|
|
314
|
+
* Text over {@link MAX_MESSAGE_BYTES} (UTF-8), the gateway's limit for a
|
|
315
|
+
* chat message, is refused.
|
|
316
|
+
*
|
|
317
|
+
* @param nonce - The nonce the browser presented.
|
|
318
|
+
* @param text - The typed text; surrounding whitespace is removed.
|
|
319
|
+
* @returns True when the text was delivered: `sendMessage` neither threw
|
|
320
|
+
* nor returned false.
|
|
321
|
+
*/
|
|
322
|
+
async say(nonce, text) {
|
|
323
|
+
if (!this.sendMessage)
|
|
324
|
+
return false;
|
|
325
|
+
const cleaned = (text ?? '').trim();
|
|
326
|
+
if (!cleaned || _utf8Length(cleaned) > MAX_MESSAGE_BYTES)
|
|
327
|
+
return false;
|
|
328
|
+
const entry = this._lookup(nonce);
|
|
329
|
+
if (!entry || !entry.callId)
|
|
330
|
+
return false;
|
|
331
|
+
if (entry.messages >= this.maxMessagesPerCall) {
|
|
332
|
+
logger.warn('handoff_say_cap_reached', { call_id: entry.callId });
|
|
333
|
+
return false;
|
|
334
|
+
}
|
|
335
|
+
// Take the slot before waiting on delivery, so concurrent requests can't
|
|
336
|
+
// all pass the check. Written back, so a registry that returns copies
|
|
337
|
+
// stores the change.
|
|
338
|
+
entry.messages += 1;
|
|
339
|
+
this._nonces.set(nonce, entry);
|
|
340
|
+
let delivered;
|
|
341
|
+
try {
|
|
342
|
+
delivered = (await this.sendMessage(entry.callId, cleaned)) !== false;
|
|
343
|
+
}
|
|
344
|
+
catch (err) {
|
|
345
|
+
logger.error('handoff_say_failed', {
|
|
346
|
+
error: err instanceof Error ? err.message : String(err),
|
|
347
|
+
});
|
|
348
|
+
delivered = false;
|
|
349
|
+
}
|
|
350
|
+
if (!delivered)
|
|
351
|
+
this._refund(nonce, entry);
|
|
352
|
+
return delivered;
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Give back the slot a failed delivery took, if the table still holds the
|
|
356
|
+
* registration it came from. A registry may return copies, so the
|
|
357
|
+
* registration is matched by value (conversation, call and registration
|
|
358
|
+
* time), and the stored count is the one decremented, keeping the slots
|
|
359
|
+
* other requests took meanwhile.
|
|
360
|
+
*/
|
|
361
|
+
_refund(nonce, entry) {
|
|
362
|
+
const current = this._nonces.get(nonce);
|
|
363
|
+
if (current &&
|
|
364
|
+
current.messages > 0 &&
|
|
365
|
+
current.conversationId === entry.conversationId &&
|
|
366
|
+
current.callId === entry.callId &&
|
|
367
|
+
current.issuedAt === entry.issuedAt) {
|
|
368
|
+
current.messages -= 1;
|
|
369
|
+
this._nonces.set(nonce, current);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
// ── HTTP ─────────────────────────────────────────────────────────
|
|
373
|
+
/**
|
|
374
|
+
* A Hono app serving `POST /handoff`, `/escalate` and `/say`. Mount it at
|
|
375
|
+
* the same prefix as the gateway, since the browser derives all three
|
|
376
|
+
* paths from the gateway's URL:
|
|
377
|
+
*
|
|
378
|
+
* ```ts
|
|
379
|
+
* import { AgentBase, ChatGateway, HandoffRouter } from '@signalwire/sdk';
|
|
380
|
+
*
|
|
381
|
+
* const agent = new AgentBase({ name: 'shop', route: '/swml' });
|
|
382
|
+
* const gateway = new ChatGateway({
|
|
383
|
+
* configUrl: 'https://my-agent.example.com/swml',
|
|
384
|
+
* key: 'pk_live_...',
|
|
385
|
+
* allowedOrigins: ['https://shop.example.com'],
|
|
386
|
+
* });
|
|
387
|
+
* const handoff = new HandoffRouter({ gateway });
|
|
388
|
+
* agent.mount(gateway.router(), { prefix: '/chat' });
|
|
389
|
+
* agent.mount(handoff.router(), { prefix: '/chat' });
|
|
390
|
+
* ```
|
|
391
|
+
*
|
|
392
|
+
* - `/handoff` takes `{ nonce }` and returns `{ handle }`.
|
|
393
|
+
* - `/escalate` takes `{ handle }` and returns `{ ok: true }`.
|
|
394
|
+
* - `/say` takes `{ nonce, text }` and returns `{ ok: true }`.
|
|
395
|
+
*
|
|
396
|
+
* Each returns 403 for a refused origin, and 404 `{ error: 'not found' }`
|
|
397
|
+
* when the nonce or handle doesn't verify. Each returns 413
|
|
398
|
+
* `{ error: 'request too large' }` for a body over the gateway's
|
|
399
|
+
* `MAX_REQUEST_BODY_BYTES`, and `/say` returns 413
|
|
400
|
+
* `{ error: 'message too large' }` for text over its `MAX_MESSAGE_BYTES`.
|
|
401
|
+
* Both are checked before the nonce is looked up, so the answer says
|
|
402
|
+
* nothing about whether the nonce is live. Each answers its own CORS
|
|
403
|
+
* preflight, and sends CORS headers to an origin the gateway allows.
|
|
404
|
+
*
|
|
405
|
+
* @returns The Hono app.
|
|
406
|
+
*/
|
|
407
|
+
router() {
|
|
408
|
+
const router = new Hono();
|
|
409
|
+
// CORS for origins the gateway allows, so a widget on another origin can
|
|
410
|
+
// call these routes and read the answers; the agent's own CORS handling
|
|
411
|
+
// doesn't apply to a mounted app.
|
|
412
|
+
const cors = (c) => {
|
|
413
|
+
const origin = c.req.header('origin');
|
|
414
|
+
if (origin === undefined)
|
|
415
|
+
return {};
|
|
416
|
+
try {
|
|
417
|
+
this.gateway.checkOrigin(origin);
|
|
418
|
+
}
|
|
419
|
+
catch {
|
|
420
|
+
return {};
|
|
421
|
+
}
|
|
422
|
+
return { 'Access-Control-Allow-Origin': origin, Vary: 'Origin' };
|
|
423
|
+
};
|
|
424
|
+
const forbiddenOrigin = (c) => {
|
|
425
|
+
try {
|
|
426
|
+
this.gateway.checkOrigin(c.req.header('origin'));
|
|
427
|
+
}
|
|
428
|
+
catch {
|
|
429
|
+
return c.json({ error: 'origin not allowed' }, 403);
|
|
430
|
+
}
|
|
431
|
+
return null;
|
|
432
|
+
};
|
|
433
|
+
// Every answer carries the CORS headers, refusals included.
|
|
434
|
+
router.use('*', async (c, next) => {
|
|
435
|
+
await next();
|
|
436
|
+
for (const [name, value] of Object.entries(cors(c)))
|
|
437
|
+
c.res.headers.set(name, value);
|
|
438
|
+
});
|
|
439
|
+
for (const path of ['/handoff', '/escalate', '/say']) {
|
|
440
|
+
router.options(path, (c) => {
|
|
441
|
+
const headers = cors(c);
|
|
442
|
+
if (Object.keys(headers).length > 0) {
|
|
443
|
+
headers['Access-Control-Allow-Headers'] = 'Content-Type';
|
|
444
|
+
headers['Access-Control-Allow-Methods'] = 'POST, OPTIONS';
|
|
445
|
+
headers['Access-Control-Max-Age'] = '600';
|
|
446
|
+
}
|
|
447
|
+
return c.body(null, 204, headers);
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
// The JSON object sent, or {} for anything else. Throws a
|
|
451
|
+
// GatewayRejection (413) for a body over the size limit.
|
|
452
|
+
const readBody = async (c) => {
|
|
453
|
+
let data;
|
|
454
|
+
try {
|
|
455
|
+
data = await _readJsonBody(c.req);
|
|
456
|
+
}
|
|
457
|
+
catch (err) {
|
|
458
|
+
if (err instanceof GatewayRejection)
|
|
459
|
+
throw err;
|
|
460
|
+
return {};
|
|
461
|
+
}
|
|
462
|
+
return typeof data === 'object' && data !== null && !Array.isArray(data)
|
|
463
|
+
? data
|
|
464
|
+
: {};
|
|
465
|
+
};
|
|
466
|
+
const notFound = (c) => c.json({ error: 'not found' }, 404);
|
|
467
|
+
const tooLarge = (c, reason) => c.json({ error: reason }, 413);
|
|
468
|
+
// Every route reads its body this way, so an oversized one is refused
|
|
469
|
+
// before anything else looks at it.
|
|
470
|
+
const withBody = (handler) => async (c) => {
|
|
471
|
+
const denied = forbiddenOrigin(c);
|
|
472
|
+
if (denied)
|
|
473
|
+
return denied;
|
|
474
|
+
let body;
|
|
475
|
+
try {
|
|
476
|
+
body = await readBody(c);
|
|
477
|
+
}
|
|
478
|
+
catch (err) {
|
|
479
|
+
if (err instanceof GatewayRejection)
|
|
480
|
+
return tooLarge(c, err.reason);
|
|
481
|
+
throw err;
|
|
482
|
+
}
|
|
483
|
+
return handler(c, body);
|
|
484
|
+
};
|
|
485
|
+
router.post('/handoff', withBody(async (c, body) => {
|
|
486
|
+
const nonce = body['nonce'];
|
|
487
|
+
if (typeof nonce !== 'string')
|
|
488
|
+
return notFound(c);
|
|
489
|
+
const handle = await this.redeem(nonce);
|
|
490
|
+
// The same answer for unknown, expired and already used.
|
|
491
|
+
if (!handle)
|
|
492
|
+
return notFound(c);
|
|
493
|
+
return c.json({ handle });
|
|
494
|
+
}));
|
|
495
|
+
router.post('/escalate', withBody(async (c, body) => {
|
|
496
|
+
const handle = body['handle'];
|
|
497
|
+
if (!handle || typeof handle !== 'string')
|
|
498
|
+
return c.json({ error: 'bad request' }, 400);
|
|
499
|
+
if (!(await this.escalate(handle)))
|
|
500
|
+
return notFound(c);
|
|
501
|
+
return c.json({ ok: true });
|
|
502
|
+
}));
|
|
503
|
+
router.post('/say', withBody(async (c, body) => {
|
|
504
|
+
const nonce = body['nonce'];
|
|
505
|
+
const text = body['text'] ?? '';
|
|
506
|
+
if (typeof nonce !== 'string' || typeof text !== 'string')
|
|
507
|
+
return notFound(c);
|
|
508
|
+
// Before the lookup, so the answer doesn't depend on the nonce.
|
|
509
|
+
if (_utf8Length(text) > MAX_MESSAGE_BYTES)
|
|
510
|
+
return tooLarge(c, 'message too large');
|
|
511
|
+
if (!(await this.say(nonce, text)))
|
|
512
|
+
return notFound(c);
|
|
513
|
+
return c.json({ ok: true });
|
|
514
|
+
}));
|
|
515
|
+
return router;
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
//# sourceMappingURL=HandoffRouter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HandoffRouter.js","sourceRoot":"","sources":["../../src/ai-chat/HandoffRouter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8DG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,aAAa,EACb,WAAW,GAEZ,MAAM,kBAAkB,CAAC;AAE1B,MAAM,MAAM,GAAG,SAAS,CAAC,iBAAiB,CAAC,CAAC;AAE5C,iFAAiF;AACjF,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,CAAC;AACtC,uCAAuC;AACvC,MAAM,CAAC,MAAM,6BAA6B,GAAG,GAAG,CAAC;AACjD,wCAAwC;AACxC,MAAM,CAAC,MAAM,uBAAu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;gBAAE,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC;YACvD,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;QAC9B,CAAC,CAAC,CACH,CAAC;QAEF,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The SignalWire AI Chat service: {@link AIChatClient} to call it,
|
|
3
|
+
* {@link ChatGateway} to let a browser chat through your app without a token,
|
|
4
|
+
* and {@link HandoffRouter} to move a conversation between voice and text.
|
|
5
|
+
* Mirrors the python reference `signalwire.ai_chat` package surface.
|
|
6
|
+
*/
|
|
7
|
+
export { AIChatClient, AIChatError, AuthenticationError, ConversationNotFoundError, RateLimitError, ChatInProgressError, SummaryError, } from './AIChatClient.js';
|
|
8
|
+
export type { AIChatClientOptions, ConversationTurnOptions, CreateConversationOptions, ChatOptions, SummarizeOptions, ConversationInfo, ChatResponse, ChatLog, } from './AIChatClient.js';
|
|
9
|
+
export { ChatGateway, GatewayRejection, MAX_MESSAGE_BYTES, MAX_REQUEST_BODY_BYTES, MAX_USER_METADATA_BYTES, } from './ChatGateway.js';
|
|
10
|
+
export type { ChatGatewayOptions } from './ChatGateway.js';
|
|
11
|
+
export { HandoffRouter, NonceEntry } from './HandoffRouter.js';
|
|
12
|
+
export type { HandoffRouterOptions, CaptureLeg, EndCall, SendMessage } from './HandoffRouter.js';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The SignalWire AI Chat service: {@link AIChatClient} to call it,
|
|
3
|
+
* {@link ChatGateway} to let a browser chat through your app without a token,
|
|
4
|
+
* and {@link HandoffRouter} to move a conversation between voice and text.
|
|
5
|
+
* Mirrors the python reference `signalwire.ai_chat` package surface.
|
|
6
|
+
*/
|
|
7
|
+
export { AIChatClient, AIChatError, AuthenticationError, ConversationNotFoundError, RateLimitError, ChatInProgressError, SummaryError, } from './AIChatClient.js';
|
|
8
|
+
export { ChatGateway, GatewayRejection, MAX_MESSAGE_BYTES, MAX_REQUEST_BODY_BYTES, MAX_USER_METADATA_BYTES, } from './ChatGateway.js';
|
|
9
|
+
export { HandoffRouter, NonceEntry } from './HandoffRouter.js';
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ai-chat/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,YAAY,EACZ,WAAW,EACX,mBAAmB,EACnB,yBAAyB,EACzB,cAAc,EACd,mBAAmB,EACnB,YAAY,GACb,MAAM,mBAAmB,CAAC;AAa3B,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,iBAAiB,EACjB,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Capabilities - reading what a client says it can do.
|
|
3
|
+
*
|
|
4
|
+
* A browser client (the SignalWire address widget, or anything speaking the
|
|
5
|
+
* same convention) declares its rendering capabilities in the user variables
|
|
6
|
+
* it sends at dial time:
|
|
7
|
+
*
|
|
8
|
+
* ```json
|
|
9
|
+
* { "vars": { "userVariables": {
|
|
10
|
+
* "capabilities": { "display_content": true, "transcript": true, "chat_handoff": false },
|
|
11
|
+
* "metadata": { "page": {}, "client": {}, "widget": {} } } } }
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* These are declarations of what the client can RENDER, not grants of
|
|
15
|
+
* authority. Treat them as hints for deciding what to offer (whether to push
|
|
16
|
+
* content to a screen, whether to advertise a text-handoff tool), never as
|
|
17
|
+
* permission to do anything privileged: a caller controls its own user
|
|
18
|
+
* variables.
|
|
19
|
+
*
|
|
20
|
+
* Absence means no. Every function here resolves errors and missing data to
|
|
21
|
+
* "not declared", because offering a caller something they can't reach is
|
|
22
|
+
* worse than never mentioning it: a phone caller has no screen.
|
|
23
|
+
*
|
|
24
|
+
* There's deliberately no list of known capability names: a client can declare
|
|
25
|
+
* one this SDK has never heard of, and an application can act on it today.
|
|
26
|
+
* Mirrors signalwire-python's `signalwire.core.capabilities`.
|
|
27
|
+
*/
|
|
28
|
+
/**
|
|
29
|
+
* The user variables from a SWML request body (`vars.userVariables`), or `{}`.
|
|
30
|
+
*
|
|
31
|
+
* They're nested two levels down, which is easy to get wrong silently: a
|
|
32
|
+
* missing level yields an empty object, and every later check reports "not
|
|
33
|
+
* declared".
|
|
34
|
+
*
|
|
35
|
+
* @param bodyParams - The SWML request body.
|
|
36
|
+
* @returns The user variables, or an empty object.
|
|
37
|
+
*/
|
|
38
|
+
export declare function userVariables(bodyParams: unknown): Record<string, unknown>;
|
|
39
|
+
/**
|
|
40
|
+
* The capability names the client declared as truthy.
|
|
41
|
+
*
|
|
42
|
+
* Accepts either a whole SWML request body or already-extracted user
|
|
43
|
+
* variables, so it works from a dynamic config callback and from a tool
|
|
44
|
+
* handler alike.
|
|
45
|
+
*
|
|
46
|
+
* @param bodyParams - A SWML request body, or a user variables object.
|
|
47
|
+
* @returns The declared names; empty when nothing was declared, the payload
|
|
48
|
+
* was malformed, or the client isn't a browser at all.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```ts
|
|
52
|
+
* if (declaredCapabilities(body).has('display_content')) {
|
|
53
|
+
* agent.promptAddSection('Screen', { body: 'You can show the caller content.' });
|
|
54
|
+
* }
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export declare function declaredCapabilities(bodyParams: unknown): ReadonlySet<string>;
|
|
58
|
+
/**
|
|
59
|
+
* Whether the client declared `name` as truthy.
|
|
60
|
+
* @param bodyParams - A SWML request body, or a user variables object.
|
|
61
|
+
* @param name - Capability name, e.g. `display_content`.
|
|
62
|
+
* @returns True only when explicitly declared truthy.
|
|
63
|
+
*/
|
|
64
|
+
export declare function hasCapability(bodyParams: unknown, name: string): boolean;
|