@signalwire/sdk 2.0.5 → 3.6.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 +821 -0
- package/LICENSE +21 -0
- package/README.md +163 -68
- package/dist/AGENTS.md +13 -0
- package/dist/AgentBase.d.ts +510 -126
- package/dist/AgentBase.js +1581 -455
- 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 +186 -45
- package/dist/DataMap.js +210 -52
- package/dist/DataMap.js.map +1 -1
- package/dist/FunctionResult.d.ts +309 -83
- package/dist/FunctionResult.js +483 -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 +12 -1
- package/dist/POM/PromptObjectModel.js +25 -9
- package/dist/POM/PromptObjectModel.js.map +1 -1
- 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 +18 -0
- package/dist/PomBuilder.js +53 -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 +22 -1
- package/dist/PromptManager.js +28 -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 +169 -59
- package/dist/SWMLService.js +456 -129
- 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 +49 -9
- package/dist/SecurityUtils.js +153 -51
- package/dist/SecurityUtils.js.map +1 -1
- package/dist/SemanticGate.d.ts +183 -0
- package/dist/SemanticGate.js +533 -0
- package/dist/SemanticGate.js.map +1 -0
- 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 +139 -7
- package/dist/SwaigFunction.js +170 -22
- 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 +92 -33
- 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 -371
- 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 +920 -0
- package/dist/cli/tsdocs/topics.js.map +1 -0
- package/dist/index.d.ts +49 -68
- package/dist/index.js +45 -73
- 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 +44 -17
- package/dist/relay/RelayClient.js +175 -65
- 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 +73 -42
- 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 +5 -2
- package/dist/rest/callHandler.js +4 -1
- package/dist/rest/callHandler.js.map +1 -1
- package/dist/rest/index.d.ts +18 -77
- package/dist/rest/index.js +47 -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 -327
- package/dist/rest/namespaces/fabric.js +14 -439
- 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 +8 -196
- package/dist/rest/namespaces/phone-numbers.js +8 -230
- 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 +111 -21
- 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 +22 -11
- package/dist/skills/SkillRegistry.js +47 -17
- 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 +18 -6
- 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 +21 -22
- 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 +42 -4
- package/dist/skills/builtin/spider.js +277 -104
- 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 +38 -30
- 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 +294 -100
- 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 +14 -13
- 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 +59 -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 +3641 -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 +1207 -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 +1986 -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 +85 -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
package/dist/AgentBase.d.ts
CHANGED
|
@@ -5,24 +5,34 @@
|
|
|
5
5
|
* into a single HTTP-servable agent.
|
|
6
6
|
*/
|
|
7
7
|
import { Hono } from 'hono';
|
|
8
|
+
import type { Context } from 'hono';
|
|
9
|
+
import type { HostAppRouter } from './web.js';
|
|
8
10
|
import { PromptManager } from './PromptManager.js';
|
|
9
11
|
import { PromptObjectModel } from './POM/PromptObjectModel.js';
|
|
10
12
|
import { SWMLService } from './SWMLService.js';
|
|
11
|
-
import { SwaigFunction, type
|
|
13
|
+
import { SwaigFunction, type SwaigErrorHandler } from './SwaigFunction.js';
|
|
14
|
+
import { type FillerPhrases, type SemanticGate } from './SemanticGate.js';
|
|
15
|
+
import { type TypedToolHandler } from './TypeInference.js';
|
|
12
16
|
import { ContextBuilder } from './ContextBuilder.js';
|
|
17
|
+
import { type Logger } from './Logger.js';
|
|
13
18
|
import { SkillManager } from './skills/SkillManager.js';
|
|
14
19
|
import type { SkillBase, SkillConfig } from './skills/SkillBase.js';
|
|
20
|
+
import type { SkillNameOrString } from './skills/SkillName.js';
|
|
15
21
|
import { type ServerlessEvent, type ServerlessResponse } from './ServerlessAdapter.js';
|
|
16
22
|
import type { AgentOptions, LanguageConfig, PronunciationRule, FunctionInclude, DynamicConfigCallback } from './types.js';
|
|
23
|
+
import type { SwmlRequestData } from './PlatformContracts.js';
|
|
24
|
+
import type { SwaigRequest, PostPrompt, PostPromptData } from './SwaigContracts.js';
|
|
17
25
|
/**
|
|
18
26
|
* Callback invoked at a registered routing endpoint to determine how to handle an
|
|
19
27
|
* incoming request. Return a route string to redirect to that agent route, or
|
|
20
28
|
* null / undefined to let normal SWML processing continue.
|
|
21
29
|
*
|
|
22
|
-
* Mirrors Python `web_mixin.register_routing_callback` callback signature
|
|
23
|
-
*
|
|
30
|
+
* Mirrors Python `web_mixin.register_routing_callback` callback signature. Python
|
|
31
|
+
* decomposed the routing callback to `callback_fn(body, headers)` — the parsed body
|
|
32
|
+
* plus the request headers (the raw Hono request object is not forwarded). `headers`
|
|
33
|
+
* is optional so existing body-only callbacks keep working.
|
|
24
34
|
*/
|
|
25
|
-
export type RoutingCallback = (body: Record<string,
|
|
35
|
+
export type RoutingCallback = (body: SwmlRequestData, headers?: Record<string, string>) => string | null | undefined | Promise<string | null | undefined>;
|
|
26
36
|
/**
|
|
27
37
|
* Core agent class that composes an HTTP server, prompt management, session handling,
|
|
28
38
|
* SWAIG tool registry, and 5-phase SWML rendering into a single deployable unit.
|
|
@@ -99,6 +109,7 @@ export declare class AgentBase extends SWMLService {
|
|
|
99
109
|
private _nativeFunctions;
|
|
100
110
|
private hints;
|
|
101
111
|
private languages;
|
|
112
|
+
private multilingual;
|
|
102
113
|
private pronounce;
|
|
103
114
|
private params;
|
|
104
115
|
private globalData;
|
|
@@ -110,11 +121,20 @@ export declare class AgentBase extends SWMLService {
|
|
|
110
121
|
private answerConfig;
|
|
111
122
|
private postAnswerVerbs;
|
|
112
123
|
private postAiVerbs;
|
|
113
|
-
|
|
124
|
+
/** Per-request configuration callbacks, run in order on each request's copy. */
|
|
125
|
+
private perCallConfigs;
|
|
126
|
+
/** Set once serve() runs an HTTP server; getFullUrl then ignores serverless environments. */
|
|
127
|
+
private _serving;
|
|
128
|
+
/** Handlers registered with {@link onCallEnd}. */
|
|
129
|
+
private callEndHandlers;
|
|
130
|
+
/** Apps and routers added with {@link mount}, replayed on every app build. */
|
|
131
|
+
private mounts;
|
|
114
132
|
private swaigQueryParams;
|
|
115
133
|
private webHookUrlOverride;
|
|
116
134
|
private postPromptUrlOverride;
|
|
117
135
|
private contextsBuilder;
|
|
136
|
+
/** Contexts given as a plain object, rendered as they are. */
|
|
137
|
+
private _rawContexts;
|
|
118
138
|
private _mcpServers;
|
|
119
139
|
private _mcpServerEnabled;
|
|
120
140
|
private _sipRoutingEnabled;
|
|
@@ -128,13 +148,43 @@ export declare class AgentBase extends SWMLService {
|
|
|
128
148
|
private _enforceHttps;
|
|
129
149
|
/** Structured logger instance for this agent. Override the inherited
|
|
130
150
|
* SWMLService logger with an AgentBase-tagged one. */
|
|
131
|
-
log:
|
|
151
|
+
log: Logger;
|
|
132
152
|
private _skillManager;
|
|
133
153
|
private _enablePostPromptOverride;
|
|
134
154
|
private _checkForInputOverride;
|
|
135
155
|
private _schemaValidation;
|
|
136
156
|
private _configFile;
|
|
137
157
|
private _schemaPath;
|
|
158
|
+
/**
|
|
159
|
+
* Resolved SignalWire Signing Key. Source of truth for the
|
|
160
|
+
* webhook-validation middleware mounted on POST /, /swaig, /post_prompt.
|
|
161
|
+
* Resolved from constructor opts, falling back to
|
|
162
|
+
* ``SIGNALWIRE_SIGNING_KEY``. When ``null``, signature validation is
|
|
163
|
+
* disabled.
|
|
164
|
+
*
|
|
165
|
+
* NEVER logged. NEVER serialized. Not included in any SWML/SWAIG render or
|
|
166
|
+
* state dump.
|
|
167
|
+
*
|
|
168
|
+
* READABLE, matching the reference's public `self.signing_key`
|
|
169
|
+
* (`core/agent_base.py:253`) and java's `getSigningKey()`. The value came FROM the
|
|
170
|
+
* caller (an explicit `signingKey` option or `SIGNALWIRE_SIGNING_KEY`), so a
|
|
171
|
+
* caller who supplied it must be able to read back which key the agent resolved —
|
|
172
|
+
* the same posture as `getBasicAuthCredentials()`, which already returns the auth
|
|
173
|
+
* secret. Withholding it hides configuration from its own owner without hiding it
|
|
174
|
+
* from anything else (the process already holds it).
|
|
175
|
+
*/
|
|
176
|
+
private _signingKey;
|
|
177
|
+
/**
|
|
178
|
+
* The resolved SignalWire Signing Key, or `null` when signature validation is
|
|
179
|
+
* disabled — the reference's public `self.signing_key`.
|
|
180
|
+
*
|
|
181
|
+
* Read-only: the resolution order (explicit option → `SIGNALWIRE_SIGNING_KEY` →
|
|
182
|
+
* `null`) runs once at construction and the middleware is mounted against it, so a
|
|
183
|
+
* post-construction write would not take effect.
|
|
184
|
+
*/
|
|
185
|
+
get signingKey(): string | null;
|
|
186
|
+
/** Whether to honor X-Forwarded-* headers when reconstructing the URL. */
|
|
187
|
+
private _webhookTrustProxy;
|
|
138
188
|
private _appBuiltByAgent;
|
|
139
189
|
/**
|
|
140
190
|
* Create a new AgentBase instance.
|
|
@@ -151,12 +201,45 @@ export declare class AgentBase extends SWMLService {
|
|
|
151
201
|
bullets?: string[];
|
|
152
202
|
numbered?: boolean;
|
|
153
203
|
}[];
|
|
204
|
+
/** Guards {@link ensureToolsDefined} so `defineTools()` runs at most once. */
|
|
205
|
+
private _toolsDefined;
|
|
154
206
|
/**
|
|
155
|
-
* Lifecycle
|
|
156
|
-
*
|
|
157
|
-
*
|
|
207
|
+
* Lifecycle hook for subclasses to register their SWAIG tools. Override it
|
|
208
|
+
* and call `this.defineTool(...)` inside.
|
|
209
|
+
*
|
|
210
|
+
* You do **not** need to call this yourself — the base class invokes it
|
|
211
|
+
* automatically (exactly once) the first time tools are needed: on
|
|
212
|
+
* {@link renderSwml}, {@link getTools}, {@link serve}/{@link run}, or SWAIG
|
|
213
|
+
* dispatch. It runs lazily rather than from the base constructor because in
|
|
214
|
+
* JS/TS `super()` runs *before* a subclass's field initializers, so a
|
|
215
|
+
* base-constructor call would see `undefined` fields. Deferring to first use
|
|
216
|
+
* guarantees all subclass fields are initialized.
|
|
217
|
+
*
|
|
218
|
+
* Calling `this.defineTools()` manually (the old convention) still works and
|
|
219
|
+
* is safe — the call is idempotent, so it will not double-register tools.
|
|
158
220
|
*/
|
|
159
221
|
protected defineTools(): void;
|
|
222
|
+
/**
|
|
223
|
+
* Run {@link defineTools} exactly once. Idempotent: safe to call from any
|
|
224
|
+
* tool-consumption entry point and from a subclass constructor. This is how
|
|
225
|
+
* `defineTools()` gets auto-invoked without falling into the JS field-init
|
|
226
|
+
* ordering trap (see {@link defineTools}).
|
|
227
|
+
*/
|
|
228
|
+
protected ensureToolsDefined(): void;
|
|
229
|
+
/** Agent-level SWAIG error hook; see {@link onError}. */
|
|
230
|
+
private _onError?;
|
|
231
|
+
/**
|
|
232
|
+
* Register an agent-level error hook invoked when any SWAIG tool handler
|
|
233
|
+
* throws. It runs after a tool's own `onError` (if any) and lets you report
|
|
234
|
+
* failures (Sentry/Datadog/logging) and optionally control the user-facing
|
|
235
|
+
* response — return a {@link FunctionResult} to override it, or nothing to
|
|
236
|
+
* fall back to the default message. The error is always contained, so a
|
|
237
|
+
* thrown handler never breaks the live call.
|
|
238
|
+
*
|
|
239
|
+
* @param handler - The error hook, or `undefined` to clear it.
|
|
240
|
+
* @returns `this`, for chaining.
|
|
241
|
+
*/
|
|
242
|
+
onError(handler: SwaigErrorHandler | undefined): this;
|
|
160
243
|
/**
|
|
161
244
|
* Public access to the list of registered tools.
|
|
162
245
|
*
|
|
@@ -176,7 +259,7 @@ export declare class AgentBase extends SWMLService {
|
|
|
176
259
|
/**
|
|
177
260
|
* Public accessor for the agent's POM as a {@link PromptObjectModel} instance.
|
|
178
261
|
*
|
|
179
|
-
* Python
|
|
262
|
+
* Python equivalent: ``agent.pom`` instance attribute (agent_base.py line 209)
|
|
180
263
|
* is a ``signalwire.pom.pom.PromptObjectModel`` when ``use_pom=True``,
|
|
181
264
|
* or ``None`` otherwise. This getter returns the equivalent TypeScript
|
|
182
265
|
* ``PromptObjectModel`` instance — callers can use ``addSection``,
|
|
@@ -311,11 +394,20 @@ export declare class AgentBase extends SWMLService {
|
|
|
311
394
|
*/
|
|
312
395
|
setPromptPom(pom: Record<string, unknown>[]): this;
|
|
313
396
|
/**
|
|
314
|
-
*
|
|
315
|
-
*
|
|
316
|
-
*
|
|
397
|
+
* Get the agent's contexts builder, creating it on first use, or replace it.
|
|
398
|
+
*
|
|
399
|
+
* Called with no argument, it returns the builder the agent already has, so
|
|
400
|
+
* calling it again adds to the same workflow, as in the Python SDK.
|
|
401
|
+
*
|
|
402
|
+
* Given a plain object, it uses that object as the contexts, rendered as it
|
|
403
|
+
* is, and returns the agent, as the Python SDK does with a dict.
|
|
404
|
+
*
|
|
405
|
+
* @param contexts - A ContextBuilder to use in place of the current one, or
|
|
406
|
+
* the contexts as a plain object.
|
|
407
|
+
* @returns The active ContextBuilder, or the agent when given an object.
|
|
317
408
|
*/
|
|
318
|
-
defineContexts(contexts?: ContextBuilder
|
|
409
|
+
defineContexts(contexts?: ContextBuilder): ContextBuilder;
|
|
410
|
+
defineContexts(contexts: Record<string, unknown>): this;
|
|
319
411
|
/**
|
|
320
412
|
* Remove all contexts, returning the agent to a no-contexts state.
|
|
321
413
|
*
|
|
@@ -363,6 +455,10 @@ export declare class AgentBase extends SWMLService {
|
|
|
363
455
|
/**
|
|
364
456
|
* Add a supported language to the AI configuration.
|
|
365
457
|
* @param config - Language configuration including name, code, voice, and optional fillers.
|
|
458
|
+
* `params` may be set to attach engine-specific tuning (voice stability,
|
|
459
|
+
* similarity boost, model knobs, etc.); only emitted into SWML when
|
|
460
|
+
* non-empty so existing entries stay byte-identical when no params are
|
|
461
|
+
* passed (Python ai_config_mixin.py `add_language`).
|
|
366
462
|
* @returns This agent instance for chaining.
|
|
367
463
|
*/
|
|
368
464
|
addLanguage(config: LanguageConfig): this;
|
|
@@ -372,6 +468,44 @@ export declare class AgentBase extends SWMLService {
|
|
|
372
468
|
* @returns This agent instance for chaining.
|
|
373
469
|
*/
|
|
374
470
|
setLanguages(languages: LanguageConfig[]): this;
|
|
471
|
+
/**
|
|
472
|
+
* Configure ASR-driven multilingual mode (Mode B).
|
|
473
|
+
*
|
|
474
|
+
* Emits a top-level `multilingual` object on the AI verb. The recognizer runs
|
|
475
|
+
* in code-switching mode and the agent answers in whatever language the caller
|
|
476
|
+
* actually spoke — the model does not pick the language. Mutually exclusive
|
|
477
|
+
* with {@link setLanguages}; if both are set the server uses `multilingual` and
|
|
478
|
+
* ignores `languages`.
|
|
479
|
+
*
|
|
480
|
+
* @param config - The multilingual config object (languages, allowed,
|
|
481
|
+
* start_language, min_switch_words, fillers, etc.).
|
|
482
|
+
* @returns This agent instance for chaining.
|
|
483
|
+
*/
|
|
484
|
+
setMultilingual(config: Record<string, unknown>): this;
|
|
485
|
+
/**
|
|
486
|
+
* Set (or replace) the per-language `params` dict on an already-added
|
|
487
|
+
* language. Useful when language entries are built up via {@link addLanguage}
|
|
488
|
+
* first and engine-specific tuning is added later (e.g., from a config
|
|
489
|
+
* loader).
|
|
490
|
+
*
|
|
491
|
+
* Python equivalent: `set_language_params(code, params)`. Passing an empty
|
|
492
|
+
* object removes the `params` key entirely. Unknown codes are a no-op.
|
|
493
|
+
*
|
|
494
|
+
* @param code - Language code as previously passed to {@link addLanguage} (e.g. `"en-US"`).
|
|
495
|
+
* @param params - Engine-specific params dict to attach. Empty object removes the key.
|
|
496
|
+
* @returns This agent instance for chaining.
|
|
497
|
+
*/
|
|
498
|
+
setLanguageParams(code: string, params: Record<string, unknown>): this;
|
|
499
|
+
/**
|
|
500
|
+
* Read the per-language `params` dict for a previously-added language.
|
|
501
|
+
*
|
|
502
|
+
* Python equivalent: `get_language_params(code)`. Returns `undefined` if the
|
|
503
|
+
* code is unknown or the language has no params set — no exception path.
|
|
504
|
+
*
|
|
505
|
+
* @param code - Language code as previously passed to {@link addLanguage}.
|
|
506
|
+
* @returns The params dict if set, `undefined` otherwise (including when the code is unknown).
|
|
507
|
+
*/
|
|
508
|
+
getLanguageParams(code: string): Record<string, unknown> | undefined;
|
|
375
509
|
/**
|
|
376
510
|
* Add a pronunciation override rule for the TTS engine.
|
|
377
511
|
* @param rule - Pronunciation rule specifying the text to replace and its substitute.
|
|
@@ -398,25 +532,78 @@ export declare class AgentBase extends SWMLService {
|
|
|
398
532
|
*/
|
|
399
533
|
setParams(params: Record<string, unknown>): this;
|
|
400
534
|
/**
|
|
401
|
-
*
|
|
402
|
-
*
|
|
403
|
-
*
|
|
404
|
-
*
|
|
405
|
-
*
|
|
535
|
+
* Set how the call checks its functions' semantic gates (see
|
|
536
|
+
* {@link SemanticGate}).
|
|
537
|
+
*
|
|
538
|
+
* Each option left out leaves its current setting as it is; the platform's
|
|
539
|
+
* default applies to a setting that was never set.
|
|
540
|
+
* @param opts - The gate settings.
|
|
541
|
+
* @param opts.enabled - `false` dispatches gated functions without checking
|
|
542
|
+
* their gates. Default `true`. Sent as `semantic_gates_enabled`.
|
|
543
|
+
* @param opts.timeoutMs - The time one check may take, 500 to 10000
|
|
544
|
+
* milliseconds, preparing the request and any retry included. A check that
|
|
545
|
+
* runs out blocks the call. Default 2500. Sent as
|
|
546
|
+
* `semantic_gate_timeout_ms`.
|
|
547
|
+
* @param opts.history - How many recent dialogue entries the decision model
|
|
548
|
+
* sees, 0 to 100. Default 20. Sent as `semantic_gate_history`.
|
|
549
|
+
* @returns This agent instance for chaining.
|
|
550
|
+
* @throws {Error} When a value has the wrong type or is out of range.
|
|
551
|
+
*/
|
|
552
|
+
setSemanticGates(opts?: {
|
|
553
|
+
enabled?: boolean;
|
|
554
|
+
timeoutMs?: number;
|
|
555
|
+
history?: number;
|
|
556
|
+
}): this;
|
|
557
|
+
/**
|
|
558
|
+
* **MERGES** `data` into the global_data object passed into the AI
|
|
559
|
+
* configuration. **Despite the name, this does NOT replace** the existing
|
|
560
|
+
* object — existing keys are preserved and incoming keys overwrite only on
|
|
561
|
+
* collision (it calls `.update()`-style merge, matching Python
|
|
562
|
+
* `set_global_data`). This is intentional: skills and other callers each
|
|
563
|
+
* contribute keys via {@link updateGlobalData}, and a replacing
|
|
564
|
+
* `setGlobalData` would silently clobber their contributions.
|
|
406
565
|
*
|
|
407
|
-
*
|
|
408
|
-
*
|
|
566
|
+
* - To **add/override** keys while keeping the rest: this method or the
|
|
567
|
+
* identical {@link updateGlobalData}.
|
|
568
|
+
* - To **fully replace** global_data (clearing every prior key, including
|
|
569
|
+
* skill-contributed ones): use {@link replaceGlobalData}.
|
|
409
570
|
*
|
|
410
571
|
* @param data - Key-value pairs to merge into global data.
|
|
411
572
|
* @returns This agent instance for chaining.
|
|
573
|
+
* @see updateGlobalData - explicit merge alias.
|
|
574
|
+
* @see replaceGlobalData - true replace semantics.
|
|
412
575
|
*/
|
|
413
576
|
setGlobalData(data: Record<string, unknown>): this;
|
|
414
577
|
/**
|
|
415
|
-
* Merge additional entries into the existing global_data object.
|
|
578
|
+
* Merge additional entries into the existing global_data object. Identical in
|
|
579
|
+
* behavior to {@link setGlobalData} (both merge); use this name when the
|
|
580
|
+
* intent is explicitly "add to" rather than "set". Skills register their
|
|
581
|
+
* global data through this path.
|
|
582
|
+
*
|
|
416
583
|
* @param data - Key-value pairs to merge into global data.
|
|
417
584
|
* @returns This agent instance for chaining.
|
|
585
|
+
* @see replaceGlobalData - to clear prior keys instead of merging.
|
|
418
586
|
*/
|
|
419
587
|
updateGlobalData(data: Record<string, unknown>): this;
|
|
588
|
+
/**
|
|
589
|
+
* **REPLACES** the entire global_data object: every previously-set key
|
|
590
|
+
* (including skill-contributed keys) is cleared, and `data` becomes the new
|
|
591
|
+
* global_data. Use this when you genuinely want a fresh object — the
|
|
592
|
+
* unambiguous counterpart to the merging {@link setGlobalData} /
|
|
593
|
+
* {@link updateGlobalData}.
|
|
594
|
+
*
|
|
595
|
+
* A shallow copy of `data` is stored, so later mutations of the caller's
|
|
596
|
+
* object do not leak into the agent.
|
|
597
|
+
*
|
|
598
|
+
* TS-native addition: Python's reference SDK has no replace path (its
|
|
599
|
+
* `set_global_data` only merges), so this has no Python counterpart — see
|
|
600
|
+
* `PORT_ADDITIONS.md`.
|
|
601
|
+
*
|
|
602
|
+
* @param data - The new global_data object (replaces all prior keys).
|
|
603
|
+
* @returns This agent instance for chaining.
|
|
604
|
+
* @see setGlobalData - the merging counterpart (does NOT clear prior keys).
|
|
605
|
+
*/
|
|
606
|
+
replaceGlobalData(data: Record<string, unknown>): this;
|
|
420
607
|
/**
|
|
421
608
|
* Set the list of native SWAIG function names (built-in platform functions).
|
|
422
609
|
* @param funcs - Array of native function names.
|
|
@@ -549,8 +736,8 @@ export declare class AgentBase extends SWMLService {
|
|
|
549
736
|
*
|
|
550
737
|
* When called, the endpoint at `path` will invoke `callback` with the parsed
|
|
551
738
|
* request body. If `callback` returns a non-empty route string the server
|
|
552
|
-
* responds with `
|
|
553
|
-
* request to the right agent. If `callback` returns `null` / `undefined` the
|
|
739
|
+
* responds with a `307` redirect to it (`Location: <route>`), so the
|
|
740
|
+
* request goes to the right agent. If `callback` returns `null` / `undefined` the
|
|
554
741
|
* agent's own SWML is returned instead (normal processing).
|
|
555
742
|
*
|
|
556
743
|
* Mirrors Python `swml_service.register_routing_callback` /
|
|
@@ -568,7 +755,7 @@ export declare class AgentBase extends SWMLService {
|
|
|
568
755
|
* @param requestBody - The parsed request body containing call information.
|
|
569
756
|
* @returns The extracted SIP username, or null if not found.
|
|
570
757
|
*/
|
|
571
|
-
static extractSipUsername(requestBody:
|
|
758
|
+
static extractSipUsername(requestBody: SwmlRequestData): string | null;
|
|
572
759
|
/**
|
|
573
760
|
* Add an external MCP server for tool discovery and invocation.
|
|
574
761
|
* Tools are discovered via MCP protocol at session start and added to the AI's tool list.
|
|
@@ -584,6 +771,8 @@ export declare class AgentBase extends SWMLService {
|
|
|
584
771
|
/**
|
|
585
772
|
* Expose this agent's tools as an MCP server endpoint at /mcp.
|
|
586
773
|
* Adds a JSON-RPC 2.0 endpoint that MCP clients (Claude Desktop, other agents) can connect to.
|
|
774
|
+
* The endpoint requires the agent's basic auth credentials, and lists and
|
|
775
|
+
* calls only the tools the agent runs itself (not DataMap or external webhook tools).
|
|
587
776
|
* @returns This agent instance for chaining
|
|
588
777
|
*/
|
|
589
778
|
enableMcpServer(): this;
|
|
@@ -591,82 +780,16 @@ export declare class AgentBase extends SWMLService {
|
|
|
591
780
|
isMcpServerEnabled(): boolean;
|
|
592
781
|
/** Get configured MCP servers (read-only copy). */
|
|
593
782
|
getMcpServers(): Record<string, unknown>[];
|
|
783
|
+
/**
|
|
784
|
+
* Whether the /mcp endpoint may list and call this tool: only tools this
|
|
785
|
+
* agent runs itself. DataMap tools run on SignalWire and external webhook
|
|
786
|
+
* tools run on another server, so neither has a handler here.
|
|
787
|
+
*/
|
|
788
|
+
private isMcpCallable;
|
|
594
789
|
/** Build MCP tool list from registered tools. */
|
|
595
790
|
private buildMcpToolList;
|
|
596
791
|
/** Handle an MCP JSON-RPC 2.0 request. Returns the response object. */
|
|
597
792
|
handleMcpRequest(body: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
598
|
-
/**
|
|
599
|
-
* Register a SWAIG tool (function) that the AI can invoke during a call.
|
|
600
|
-
*
|
|
601
|
-
* ## How this becomes a tool the model sees
|
|
602
|
-
*
|
|
603
|
-
* A SWAIG function is **exactly the same concept** as a "tool" in
|
|
604
|
-
* native OpenAI / Anthropic tool calling. On every LLM turn, the SDK
|
|
605
|
-
* renders each registered SWAIG function into the OpenAI tool schema:
|
|
606
|
-
*
|
|
607
|
-
* ```json
|
|
608
|
-
* {
|
|
609
|
-
* "type": "function",
|
|
610
|
-
* "function": {
|
|
611
|
-
* "name": "your_name_here",
|
|
612
|
-
* "description": "your description text",
|
|
613
|
-
* "parameters": { /* your JSON schema *\/ }
|
|
614
|
-
* }
|
|
615
|
-
* }
|
|
616
|
-
* ```
|
|
617
|
-
*
|
|
618
|
-
* That schema goes to the model in the same API call that produces
|
|
619
|
-
* the next assistant message. The model reads:
|
|
620
|
-
*
|
|
621
|
-
* - the **function `description`** to decide WHEN to call this tool
|
|
622
|
-
* - each **parameter `description`** (inside the JSON schema) to
|
|
623
|
-
* decide HOW to fill in each argument
|
|
624
|
-
*
|
|
625
|
-
* This means **descriptions are prompt engineering**, not developer
|
|
626
|
-
* comments. A vague description is the #1 cause of "the model has the
|
|
627
|
-
* right tool but doesn't call it" failures.
|
|
628
|
-
*
|
|
629
|
-
* ### Bad vs good descriptions
|
|
630
|
-
*
|
|
631
|
-
* ```text
|
|
632
|
-
* BAD : description: 'Lookup function'
|
|
633
|
-
* GOOD: description: 'Look up a customer's account details by account
|
|
634
|
-
* number. Use this BEFORE quoting any account-specific info
|
|
635
|
-
* (balance, plan, status). Do not use for general product
|
|
636
|
-
* questions.'
|
|
637
|
-
*
|
|
638
|
-
* BAD : parameters: { id: { type: 'string', description: 'the id' } }
|
|
639
|
-
* GOOD: parameters: { account_number: { type: 'string', description:
|
|
640
|
-
* 'The customer's 8-digit account number, no dashes or spaces.
|
|
641
|
-
* Ask the user if they don't provide it.' } }
|
|
642
|
-
* ```
|
|
643
|
-
*
|
|
644
|
-
* ### Tool count matters
|
|
645
|
-
*
|
|
646
|
-
* LLM tool selection accuracy degrades past ~7-8 simultaneously-active
|
|
647
|
-
* tools per call. Use Step.setFunctions() to partition tools across
|
|
648
|
-
* steps so only the relevant subset is active at any moment.
|
|
649
|
-
*
|
|
650
|
-
* @param opts - Tool definition including name, description, parameter
|
|
651
|
-
* schema, and handler callback. `description` and per-parameter
|
|
652
|
-
* `description` strings are LLM-facing prompt engineering.
|
|
653
|
-
* @returns This agent instance for chaining.
|
|
654
|
-
*/
|
|
655
|
-
defineTool(opts: {
|
|
656
|
-
name: string;
|
|
657
|
-
description: string;
|
|
658
|
-
parameters?: Record<string, unknown>;
|
|
659
|
-
handler: SwaigHandler;
|
|
660
|
-
secure?: boolean;
|
|
661
|
-
fillers?: Record<string, string[]>;
|
|
662
|
-
waitFile?: string;
|
|
663
|
-
waitFileLoops?: number;
|
|
664
|
-
required?: string[];
|
|
665
|
-
/** External webhook URL; makes this an externally-hosted tool. */
|
|
666
|
-
webhookUrl?: string;
|
|
667
|
-
/** Additional fields to pass through to the SWAIG function definition (Python `**swaig_fields` equivalent). */
|
|
668
|
-
extraFields?: Record<string, unknown>;
|
|
669
|
-
}): this;
|
|
670
793
|
/**
|
|
671
794
|
* Register a SWAIG tool with a typed handler that receives named parameters
|
|
672
795
|
* instead of the standard `(args, rawData)` convention.
|
|
@@ -682,12 +805,24 @@ export declare class AgentBase extends SWMLService {
|
|
|
682
805
|
name: string;
|
|
683
806
|
description: string;
|
|
684
807
|
parameters?: Record<string, unknown>;
|
|
685
|
-
|
|
808
|
+
/**
|
|
809
|
+
* The typed handler. Receives the AI-extracted arguments as named
|
|
810
|
+
* positional parameters (in declaration order), optionally with a trailing
|
|
811
|
+
* `rawData` record, and returns a SWAIG result. Precisely typed as
|
|
812
|
+
* {@link TypedToolHandler} rather than the bare `Function` so a non-callable
|
|
813
|
+
* — or a callable that returns nothing usable — is a compile-time error.
|
|
814
|
+
*/
|
|
815
|
+
handler: TypedToolHandler;
|
|
686
816
|
secure?: boolean;
|
|
817
|
+
/** Phrases the AI says while the function runs (see `SwaigFunctionOptions.fillers`). */
|
|
687
818
|
fillers?: Record<string, string[]>;
|
|
688
819
|
waitFile?: string;
|
|
689
820
|
waitFileLoops?: number;
|
|
690
821
|
required?: string[];
|
|
822
|
+
/** Semantic gates (see `SwaigFunctionOptions.gates`). */
|
|
823
|
+
gates?: ReadonlyArray<SemanticGate | Record<string, unknown>>;
|
|
824
|
+
/** Phrases said while the gates are checked (see `SwaigFunctionOptions.gateFillers`). */
|
|
825
|
+
gateFillers?: FillerPhrases;
|
|
691
826
|
}): this;
|
|
692
827
|
/**
|
|
693
828
|
* Validate a tool-call token for the given function.
|
|
@@ -780,12 +915,19 @@ export declare class AgentBase extends SWMLService {
|
|
|
780
915
|
* name via the SkillManager registry. Throws a `ValueError`-equivalent if the
|
|
781
916
|
* skill name is not found in the registry.
|
|
782
917
|
*
|
|
918
|
+
* Accepts a typed {@link SkillNameOrString}: one of the built-in
|
|
919
|
+
* {@link SkillName} values (autocompleted) or any other string for custom
|
|
920
|
+
* and third-party skills. Because any string is accepted, a misspelled name
|
|
921
|
+
* compiles, and this rejects at runtime because it isn't registered. The value is
|
|
922
|
+
* forwarded to the registry unchanged — the typing is erased at runtime, so
|
|
923
|
+
* this matches Python's bare-`str` `add_skill(skill_name, params)`.
|
|
924
|
+
*
|
|
783
925
|
* @param skillName - The name the skill was registered under in the SkillRegistry.
|
|
784
926
|
* @param params - Optional configuration parameters forwarded to the skill factory.
|
|
785
927
|
* @returns This agent instance for chaining.
|
|
786
928
|
* @throws Error if no skill with the given name is registered.
|
|
787
929
|
*/
|
|
788
|
-
addSkillByName(skillName:
|
|
930
|
+
addSkillByName(skillName: SkillNameOrString, params?: SkillConfig): Promise<this>;
|
|
789
931
|
/**
|
|
790
932
|
* Remove a previously added skill by its instance ID.
|
|
791
933
|
* @param instanceId - The unique instance ID of the skill to remove.
|
|
@@ -803,27 +945,59 @@ export declare class AgentBase extends SWMLService {
|
|
|
803
945
|
}[];
|
|
804
946
|
/**
|
|
805
947
|
* Check whether a skill with the given name is registered.
|
|
948
|
+
*
|
|
949
|
+
* Accepts a typed {@link SkillNameOrString} so built-in names autocomplete;
|
|
950
|
+
* any other string is accepted too (custom skills, matching Python's
|
|
951
|
+
* bare-`str` `has_skill`), so a misspelled name compiles and returns false.
|
|
952
|
+
*
|
|
806
953
|
* @param skillName - The skill name to check.
|
|
807
954
|
* @returns True if a skill with that name exists.
|
|
808
955
|
*/
|
|
809
|
-
hasSkill(skillName:
|
|
956
|
+
hasSkill(skillName: SkillNameOrString): boolean;
|
|
810
957
|
/**
|
|
811
|
-
* Remove a skill by its name (Python
|
|
958
|
+
* Remove a skill by its name (matches the Python SDK).
|
|
812
959
|
*
|
|
813
960
|
* Python's `remove_skill(skill_name)` removes by skill name.
|
|
814
961
|
* The existing `removeSkill(instanceId)` removes by instance ID.
|
|
815
|
-
* This method provides name-based removal
|
|
962
|
+
* This method provides name-based removal to match the Python SDK.
|
|
816
963
|
*
|
|
817
964
|
* @param skillName - The skill name to remove.
|
|
818
965
|
* @returns True if a skill with that name was found and removed.
|
|
819
966
|
*/
|
|
820
967
|
removeSkillByName(skillName: string): Promise<boolean>;
|
|
821
968
|
/**
|
|
822
|
-
*
|
|
823
|
-
*
|
|
824
|
-
*
|
|
825
|
-
*
|
|
826
|
-
*
|
|
969
|
+
* A tool handler that calls `fn` with the agent running the call: with a
|
|
970
|
+
* dynamic config callback, the request's configured copy (so the handler
|
|
971
|
+
* sees what the callback configured), otherwise this agent. For handlers
|
|
972
|
+
* that read the agent's own state; the SDK's prefabs register theirs this
|
|
973
|
+
* way. A plain handler gets the same agent as its third argument.
|
|
974
|
+
* @internal
|
|
975
|
+
*/
|
|
976
|
+
protected _onCallAgent<A, R>(fn: (self: this, args: A, rawData: SwaigRequest) => R): (args: A, rawData: SwaigRequest, agent?: AgentBase) => R;
|
|
977
|
+
/**
|
|
978
|
+
* Set a callback that configures a per-request copy of this agent.
|
|
979
|
+
*
|
|
980
|
+
* On each request that renders SWML, runs a SWAIG function or delivers a
|
|
981
|
+
* summary, the SDK makes a copy of this agent, calls the callback with the
|
|
982
|
+
* request's query parameters, body and headers (credential-bearing headers
|
|
983
|
+
* removed) and the copy, and handles the request with the copy. Tool
|
|
984
|
+
* handlers get the copy as their third argument, and `onSummary` runs on it.
|
|
985
|
+
*
|
|
986
|
+
* The copy has its own prompt, tools, skills list, hints, languages,
|
|
987
|
+
* pronunciations, params, global data, function includes, LLM params,
|
|
988
|
+
* fillers, call-flow verbs, SWAIG query params, native functions, MCP
|
|
989
|
+
* servers, SIP usernames, routing callbacks and contexts, so changing any of
|
|
990
|
+
* them with the agent's methods affects only this request. Anything else is
|
|
991
|
+
* shared with this agent and every request in flight: a field a subclass
|
|
992
|
+
* adds, a skill instance, or an object inside the configuration that isn't
|
|
993
|
+
* plain data (a `URL`, a class instance). Assigning a new value to such a
|
|
994
|
+
* field on the copy is safe; mutating a shared object in place is not.
|
|
995
|
+
*
|
|
996
|
+
* A handler that captured this agent (an arrow function, or a method passed
|
|
997
|
+
* with `.bind(this)`) still sees this agent, not the copy: read per-call
|
|
998
|
+
* configuration from the handler's third argument. A subclass's JavaScript
|
|
999
|
+
* `#private` fields aren't on the copy, so its methods that read them
|
|
1000
|
+
* throw there; use TypeScript `private` fields.
|
|
827
1001
|
*
|
|
828
1002
|
* @param cb - Callback receiving `(queryParams, bodyParams, headers, agent)` where
|
|
829
1003
|
* `agent` is the ephemeral `AgentBase` copy to mutate. May be async.
|
|
@@ -840,6 +1014,80 @@ export declare class AgentBase extends SWMLService {
|
|
|
840
1014
|
* ```
|
|
841
1015
|
*/
|
|
842
1016
|
setDynamicConfigCallback(cb: DynamicConfigCallback): this;
|
|
1017
|
+
/**
|
|
1018
|
+
* Register a per-request configuration callback, keeping any already set.
|
|
1019
|
+
*
|
|
1020
|
+
* Same signature and contract as {@link setDynamicConfigCallback}, except
|
|
1021
|
+
* that callbacks accumulate instead of replacing each other. They run in
|
|
1022
|
+
* registration order on the same per-request copy, so a later one sees what
|
|
1023
|
+
* an earlier one configured. This is the composable form: a base class and a
|
|
1024
|
+
* subclass, or an agent and a helper, can each register what they own
|
|
1025
|
+
* without knowing about each other. `setDynamicConfigCallback` replaces
|
|
1026
|
+
* every callback registered so far.
|
|
1027
|
+
*
|
|
1028
|
+
* @param cb - Callback receiving `(queryParams, bodyParams, headers, agent)`,
|
|
1029
|
+
* where `agent` is the per-request copy. Configure that, never the agent
|
|
1030
|
+
* itself, or the configuration leaks across callers. May be async.
|
|
1031
|
+
* @returns This agent instance for chaining.
|
|
1032
|
+
*/
|
|
1033
|
+
addPerCallConfig(cb: DynamicConfigCallback): this;
|
|
1034
|
+
/**
|
|
1035
|
+
* Register a handler that runs when the call ends, with the transcript.
|
|
1036
|
+
*
|
|
1037
|
+
* Handlers run in registration order with `(callLog, rawData)`: the
|
|
1038
|
+
* conversation as the platform recorded it, and the whole SWAIG request
|
|
1039
|
+
* (with `global_data` and `call_id`). This wraps the platform's reserved
|
|
1040
|
+
* `hangup_hook` function, which fires on hangup and is never offered to the
|
|
1041
|
+
* model, so it can't be called early or skipped.
|
|
1042
|
+
*
|
|
1043
|
+
* Registering a handler also turns on the `swaig_post_conversation`
|
|
1044
|
+
* parameter: without it the hook still fires, but carries no transcript,
|
|
1045
|
+
* and the handler gets an empty list with nothing to say why. If that
|
|
1046
|
+
* parameter is explicitly `false`, it's left alone and a warning is logged.
|
|
1047
|
+
*
|
|
1048
|
+
* A handler's return value is ignored (the call is over), and an exception
|
|
1049
|
+
* is logged, not raised, so a failing handler doesn't stop the others.
|
|
1050
|
+
*
|
|
1051
|
+
* @param handler - Called with `(callLog, rawData)`; may be async.
|
|
1052
|
+
* @returns The handler.
|
|
1053
|
+
*
|
|
1054
|
+
* @example
|
|
1055
|
+
* ```ts
|
|
1056
|
+
* agent.onCallEnd((callLog, rawData) => {
|
|
1057
|
+
* archive(rawData.global_data?.['conversation_id'], callLog);
|
|
1058
|
+
* });
|
|
1059
|
+
* ```
|
|
1060
|
+
*/
|
|
1061
|
+
onCallEnd(handler: (callLog: Record<string, unknown>[], rawData: SwaigRequest) => void | Promise<void>): (callLog: Record<string, unknown>[], rawData: SwaigRequest) => void | Promise<void>;
|
|
1062
|
+
/** Register the reserved hangup_hook tool once, and turn on its transcript. */
|
|
1063
|
+
private ensureCallEndHook;
|
|
1064
|
+
/**
|
|
1065
|
+
* Mount an extra Hono app, or a fetch handler, alongside this agent's routes.
|
|
1066
|
+
*
|
|
1067
|
+
* Use this instead of adding routes to {@link getApp}'s app by hand: the
|
|
1068
|
+
* agent rebuilds its app when its routes change (a routing callback, say),
|
|
1069
|
+
* and a mount is replayed on every build. A mounted app answers its own
|
|
1070
|
+
* CORS preflights (the agent's CORS and CSRF middleware don't apply to it),
|
|
1071
|
+
* sets its own security headers, and isn't behind the agent's basic auth.
|
|
1072
|
+
* Mount before calling `serve()`.
|
|
1073
|
+
*
|
|
1074
|
+
* @param appOrRouter - A Hono app (its routes are added under `prefix`) or a
|
|
1075
|
+
* fetch handler `(request) => Response` (mounted at `prefix`, which it
|
|
1076
|
+
* doesn't see).
|
|
1077
|
+
* @param opts - `prefix`: the path to mount at, from the host root (a
|
|
1078
|
+
* trailing slash is dropped; default the root). `name`: accepted so
|
|
1079
|
+
* code written for the Python SDK works; it has no effect here.
|
|
1080
|
+
* @returns This agent instance for chaining.
|
|
1081
|
+
*
|
|
1082
|
+
* @example
|
|
1083
|
+
* ```ts
|
|
1084
|
+
* agent.mount(gateway.router(), { prefix: '/chat' });
|
|
1085
|
+
* ```
|
|
1086
|
+
*/
|
|
1087
|
+
mount(appOrRouter: Hono | ((req: Request) => Response | Promise<Response>), opts?: {
|
|
1088
|
+
prefix?: string;
|
|
1089
|
+
name?: string;
|
|
1090
|
+
}): this;
|
|
843
1091
|
/**
|
|
844
1092
|
* Add extra query parameters appended to all SWAIG webhook URLs.
|
|
845
1093
|
* @param params - Key-value pairs to append as query parameters.
|
|
@@ -890,13 +1138,18 @@ export declare class AgentBase extends SWMLService {
|
|
|
890
1138
|
* @returns The fully-qualified URL string.
|
|
891
1139
|
*/
|
|
892
1140
|
getFullUrl(includeAuth?: boolean): string;
|
|
1141
|
+
/**
|
|
1142
|
+
* Whether serve() serves HTTPS: SSL enabled with a certificate and key that
|
|
1143
|
+
* exist. getFullUrl() uses the same check, so the webhook URLs match.
|
|
1144
|
+
*/
|
|
1145
|
+
private _servesTls;
|
|
893
1146
|
private insertAuth;
|
|
894
1147
|
private buildWebhookUrl;
|
|
895
1148
|
/**
|
|
896
1149
|
* Lifecycle hook called when a post-prompt summary is received. Override in subclasses.
|
|
897
1150
|
*
|
|
898
1151
|
* Invoked once at the end of a call when the AI has produced a structured summary
|
|
899
|
-
* (configured via `setPostPrompt()`
|
|
1152
|
+
* (configured via `setPostPrompt()`). Use this hook to persist
|
|
900
1153
|
* call data, notify other systems, or trigger follow-up workflows.
|
|
901
1154
|
*
|
|
902
1155
|
* @param _summary - Parsed summary object (JSON when the post-prompt requests
|
|
@@ -904,6 +1157,12 @@ export declare class AgentBase extends SWMLService {
|
|
|
904
1157
|
* @param _rawData - Full raw post-prompt payload received from the platform,
|
|
905
1158
|
* including call metadata, conversation history, and the summary text.
|
|
906
1159
|
*
|
|
1160
|
+
* With a dynamic config callback set, this runs on the request's configured
|
|
1161
|
+
* copy of the agent. For a request whose `action` is `fetch_conversation`,
|
|
1162
|
+
* an override may return the conversation (for example
|
|
1163
|
+
* `{ conversation_summary: '...' }`); the post-prompt endpoint sends that
|
|
1164
|
+
* back instead of `{ success: true }`.
|
|
1165
|
+
*
|
|
907
1166
|
* @example
|
|
908
1167
|
* ```ts
|
|
909
1168
|
* class MyAgent extends AgentBase {
|
|
@@ -918,7 +1177,7 @@ export declare class AgentBase extends SWMLService {
|
|
|
918
1177
|
* }
|
|
919
1178
|
* ```
|
|
920
1179
|
*/
|
|
921
|
-
onSummary(_summary:
|
|
1180
|
+
onSummary(_summary: PostPromptData | null, _rawData: PostPrompt): void | Record<string, unknown> | Promise<void | Record<string, unknown>>;
|
|
922
1181
|
/**
|
|
923
1182
|
* Lifecycle hook called when SWML is requested. Default delegates to
|
|
924
1183
|
* {@link onSwmlRequest} and returns its result. Subclasses typically
|
|
@@ -934,7 +1193,7 @@ export declare class AgentBase extends SWMLService {
|
|
|
934
1193
|
* @returns Optionally a dict of SWML modifications, or undefined for
|
|
935
1194
|
* default rendering.
|
|
936
1195
|
*/
|
|
937
|
-
onRequest(requestData?:
|
|
1196
|
+
onRequest(requestData?: SwmlRequestData | null, callbackPath?: string | null): Record<string, unknown> | void | Promise<Record<string, unknown> | void>;
|
|
938
1197
|
/**
|
|
939
1198
|
* Lifecycle hook called on every SWML request before rendering. Override in subclasses.
|
|
940
1199
|
*
|
|
@@ -951,19 +1210,54 @@ export declare class AgentBase extends SWMLService {
|
|
|
951
1210
|
* @param _context - The raw Hono context object (c), providing access to headers and query params.
|
|
952
1211
|
* @returns Optionally a dict of SWML modifications, or void.
|
|
953
1212
|
*/
|
|
954
|
-
onSwmlRequest(_rawData:
|
|
1213
|
+
onSwmlRequest(_rawData: SwmlRequestData, _callbackPath?: string, _context?: Context): Record<string, unknown> | void | Promise<Record<string, unknown> | void>;
|
|
1214
|
+
/**
|
|
1215
|
+
* Framework-free request-dispatch core for AgentBase.
|
|
1216
|
+
*
|
|
1217
|
+
* Overrides {@link SWMLService.handleRequest} so the primitive dispatch surface
|
|
1218
|
+
* renders SWML via AgentBase's {@link renderSwml} (mirroring the Hono root path)
|
|
1219
|
+
* instead of the base `renderDocument`. Performs basic-auth, the routing-callback
|
|
1220
|
+
* check `(body, headers)`, and `onSwmlRequest` modification over plain
|
|
1221
|
+
* primitives, returning a `[status, headers, bodyString]` triple with the
|
|
1222
|
+
* 401-auth and 307-redirect behavior preserved. Mirrors Python's
|
|
1223
|
+
* `AgentBase.handle_request(method, url, headers, body)`.
|
|
1224
|
+
*
|
|
1225
|
+
* @param method HTTP method, e.g. `"GET"` or `"POST"`.
|
|
1226
|
+
* @param url The full request URL.
|
|
1227
|
+
* @param headers Request headers as a plain dict.
|
|
1228
|
+
* @param body The already-parsed JSON body for POST requests, or `undefined`.
|
|
1229
|
+
* @returns A `[statusCode, responseHeaders, bodyString]` triple.
|
|
1230
|
+
*/
|
|
1231
|
+
handleRequest(method: string, url: string, headers: Record<string, string>, body?: Record<string, unknown> | null): Promise<[number, Record<string, string>, string]>;
|
|
1232
|
+
/**
|
|
1233
|
+
* The agent a request runs on: this agent, or, when a dynamic config
|
|
1234
|
+
* callback is set, a per-request copy that the callback configured from the
|
|
1235
|
+
* request's query parameters, body and headers (credential-bearing headers
|
|
1236
|
+
* removed). Rendering SWML, running a SWAIG function and delivering a
|
|
1237
|
+
* summary all use it, so a tool the callback registers or secures is the one
|
|
1238
|
+
* that runs, and is checked, when the call invokes it. Mirrors the
|
|
1239
|
+
* reference's `_per_call_agent`.
|
|
1240
|
+
*/
|
|
1241
|
+
private perCallAgent;
|
|
1242
|
+
/** Validate basic-auth from a plain headers dict (the primitive analog of
|
|
1243
|
+
* the Hono `basicAuth` middleware), through {@link validateBasicAuth}. */
|
|
1244
|
+
private checkAgentBasicAuth;
|
|
955
1245
|
/**
|
|
956
1246
|
* Lifecycle hook called when a debug event webhook is received. Override in subclasses.
|
|
957
1247
|
* @param _event - The debug event payload.
|
|
958
1248
|
*/
|
|
959
1249
|
onDebugEvent(_event: Record<string, unknown>): void | Promise<void>;
|
|
960
1250
|
/**
|
|
961
|
-
*
|
|
962
|
-
*
|
|
963
|
-
*
|
|
1251
|
+
* Check a request's basic-auth credentials. Every route that requires
|
|
1252
|
+
* basic auth calls it. The default compares them with the agent's
|
|
1253
|
+
* credentials in constant time; override it to check credentials another
|
|
1254
|
+
* way, as the Python SDK's `validate_basic_auth` allows. An override
|
|
1255
|
+
* replaces the comparison, so call `super.validateBasicAuth()` to keep it.
|
|
1256
|
+
* @param username - The username from the request.
|
|
1257
|
+
* @param password - The password from the request.
|
|
964
1258
|
* @returns True if the credentials are valid; false to reject the request.
|
|
965
1259
|
*/
|
|
966
|
-
validateBasicAuth(
|
|
1260
|
+
validateBasicAuth(username: string, password: string): boolean | Promise<boolean>;
|
|
967
1261
|
/**
|
|
968
1262
|
* Hook called before each SWAIG function execution. Override in subclasses.
|
|
969
1263
|
*
|
|
@@ -971,7 +1265,7 @@ export declare class AgentBase extends SWMLService {
|
|
|
971
1265
|
* — it retrieves and executes the function, returning the result. In TypeScript,
|
|
972
1266
|
* `fn.execute()` is called separately after this hook. However, if this method
|
|
973
1267
|
* returns a non-void value, it is used as the result and the default execution
|
|
974
|
-
* is skipped, enabling dispatch interception
|
|
1268
|
+
* is skipped, enabling dispatch interception matching the Python SDK.
|
|
975
1269
|
*
|
|
976
1270
|
* @param _name - Name of the function about to execute.
|
|
977
1271
|
* @param _args - Parsed arguments for the function.
|
|
@@ -980,6 +1274,36 @@ export declare class AgentBase extends SWMLService {
|
|
|
980
1274
|
* or void/undefined to proceed normally.
|
|
981
1275
|
*/
|
|
982
1276
|
onFunctionCall(_name: string, _args: Record<string, unknown>, _rawData: Record<string, unknown>): Record<string, unknown> | void | Promise<Record<string, unknown> | void>;
|
|
1277
|
+
/**
|
|
1278
|
+
* Extract the tool-call arguments from a SWAIG request body.
|
|
1279
|
+
*
|
|
1280
|
+
* The real platform (mod_openai) POSTs a tool call with the args nested under
|
|
1281
|
+
* the platform envelope `{"argument": {"parsed": [{...args...}], "raw": "..."}}`
|
|
1282
|
+
* — NOT flat. Reading `body.argument` directly hands the handler the WHOLE
|
|
1283
|
+
* envelope (`{parsed, raw}`) instead of the args, so a real platform call
|
|
1284
|
+
* arrives with EMPTY args. This unwraps `argument.parsed[0]` first, falls back
|
|
1285
|
+
* to parsing `argument.raw` JSON, and finally accepts the flat
|
|
1286
|
+
* `{"arguments": {...}}` shape some external integrations send — matching the
|
|
1287
|
+
* Python reference (`core/swml_service.py:836-851`).
|
|
1288
|
+
*
|
|
1289
|
+
* @param body - The parsed SWAIG request body.
|
|
1290
|
+
* @param reqLog - Request-scoped logger for the raw-parse-error path.
|
|
1291
|
+
* @returns The extracted argument object (empty object when none present).
|
|
1292
|
+
*/
|
|
1293
|
+
/**
|
|
1294
|
+
* Check a SWAIG request's token before a function runs.
|
|
1295
|
+
*
|
|
1296
|
+
* A secure function runs only with a valid token minted for that function
|
|
1297
|
+
* and call. The token is in the `web_hook_url` the agent rendered, so a
|
|
1298
|
+
* request without one didn't come from that SWML: a missing token, or a
|
|
1299
|
+
* missing `call_id`, is refused like a wrong token. A non-secure function
|
|
1300
|
+
* runs without a token.
|
|
1301
|
+
*
|
|
1302
|
+
* @returns The SWAIG response to send instead of running the function, or
|
|
1303
|
+
* `null` when the function may run.
|
|
1304
|
+
*/
|
|
1305
|
+
private swaigTokenRefusal;
|
|
1306
|
+
private extractSwaigArgs;
|
|
983
1307
|
/**
|
|
984
1308
|
* Render the complete SWML document by assembling all 5 phases: pre-answer, answer,
|
|
985
1309
|
* post-answer, AI, and post-AI verbs.
|
|
@@ -992,16 +1316,62 @@ export declare class AgentBase extends SWMLService {
|
|
|
992
1316
|
*/
|
|
993
1317
|
renderSwml(callId?: string, modifications?: Record<string, unknown>): string;
|
|
994
1318
|
private createEphemeralCopy;
|
|
1319
|
+
/**
|
|
1320
|
+
* Thin Hono adapter over the decomposed {@link handleRequest} core. Extracts
|
|
1321
|
+
* `(method, url, headers, body)` primitives from the Hono `Context`, delegates
|
|
1322
|
+
* the auth / routing-callback / render DECISION to `handleRequest`, and
|
|
1323
|
+
* marshals the returned `[status, headers, body]` triple back into a Hono
|
|
1324
|
+
* `Response` — including the routing-callback **307** (`Location`) and the
|
|
1325
|
+
* **401** (`WWW-Authenticate`). This is what routes serve()/asRouter() through
|
|
1326
|
+
* the same core the primitive path uses, instead of a parallel inline
|
|
1327
|
+
* auth/render/redirect path (mirrors the rust/dotnet/php served path).
|
|
1328
|
+
*
|
|
1329
|
+
* Proxy detection stays here as framework plumbing (it needs the raw request);
|
|
1330
|
+
* everything else comes from `handleRequest`.
|
|
1331
|
+
*/
|
|
1332
|
+
private serveViaHandleRequest;
|
|
995
1333
|
/**
|
|
996
1334
|
* Get or lazily create the Hono HTTP application with all routes, middleware, auth, and CORS.
|
|
997
1335
|
* @returns The configured Hono application instance.
|
|
998
1336
|
*/
|
|
999
1337
|
getApp(): Hono;
|
|
1000
1338
|
/**
|
|
1001
|
-
*
|
|
1002
|
-
* @
|
|
1339
|
+
* Build the Hono app serving this agent's routes under `basePath` ('' for
|
|
1340
|
+
* route-relative routes, as {@link asRouter} returns them).
|
|
1341
|
+
*
|
|
1342
|
+
* Paths are matched without regard to a trailing slash or repeated slashes
|
|
1343
|
+
* (`/agent/swaig/`, `/agent//swaig`), as the reference's router and
|
|
1344
|
+
* catch-all routes accept them; the signature check still covers the URL
|
|
1345
|
+
* as the request spelled it.
|
|
1346
|
+
*/
|
|
1347
|
+
private buildApp;
|
|
1348
|
+
/** The route-relative app {@link asRouter} returns, built on first use. */
|
|
1349
|
+
private _routerApp;
|
|
1350
|
+
/**
|
|
1351
|
+
* Get a router to embed this agent's routes in a host web app.
|
|
1352
|
+
*
|
|
1353
|
+
* Returns a Hono sub-app with this agent's routes relative to its root
|
|
1354
|
+
* (`/`, `/swaig`, `/post_prompt`, plus any routing callbacks), for the host
|
|
1355
|
+
* to mount under the agent's route: `hostApp.route(agent.route,
|
|
1356
|
+
* agent.asRouter())`. This is the TypeScript realization of Python's
|
|
1357
|
+
* `as_router()`, which is route-relative the same way; the named
|
|
1358
|
+
* {@link HostAppRouter} type is the cross-port "embed my routes in a host
|
|
1359
|
+
* app" contract. {@link getApp} serves the same routes under the agent's
|
|
1360
|
+
* route.
|
|
1361
|
+
*
|
|
1362
|
+
* @returns A mountable Hono sub-app carrying this agent's routes.
|
|
1363
|
+
*/
|
|
1364
|
+
asRouter(): HostAppRouter;
|
|
1365
|
+
/**
|
|
1366
|
+
* Whether a request path is served by an app added with {@link mount}
|
|
1367
|
+
* rather than by the agent's own routes, so the agent's security headers,
|
|
1368
|
+
* CORS and CSRF handling should leave it alone. Internal; AgentServer uses
|
|
1369
|
+
* it for the agents it serves.
|
|
1370
|
+
*
|
|
1371
|
+
* @param path - The path relative to the agent's route-relative router.
|
|
1372
|
+
* @param method - The request's method.
|
|
1003
1373
|
*/
|
|
1004
|
-
|
|
1374
|
+
_servedByMount(path: string, method?: string): boolean;
|
|
1005
1375
|
/**
|
|
1006
1376
|
* Start the HTTP server and begin listening for requests.
|
|
1007
1377
|
*
|
|
@@ -1026,21 +1396,35 @@ export declare class AgentBase extends SWMLService {
|
|
|
1026
1396
|
port?: number;
|
|
1027
1397
|
}): Promise<void>;
|
|
1028
1398
|
/**
|
|
1029
|
-
*
|
|
1030
|
-
*
|
|
1031
|
-
*
|
|
1399
|
+
* Smart entry point matching Python's `WebMixin.run()`: auto-detects the
|
|
1400
|
+
* execution environment and dispatches accordingly. When a serverless event
|
|
1401
|
+
* is supplied, or a serverless platform is detected from the environment
|
|
1402
|
+
* (`AWS_LAMBDA_FUNCTION_NAME`/`_HANDLER`, `FUNCTION_TARGET`,
|
|
1403
|
+
* `FUNCTIONS_WORKER_RUNTIME`, `GATEWAY_INTERFACE`), it dispatches to
|
|
1404
|
+
* {@link runServerless}; otherwise it starts the HTTP server via {@link serve}.
|
|
1405
|
+
* Cloud Run sets `K_SERVICE` but not `FUNCTION_TARGET`, so there it serves.
|
|
1406
|
+
*
|
|
1407
|
+
* For deterministic behavior, call {@link serve} (server) or
|
|
1408
|
+
* {@link runServerless} (serverless) directly.
|
|
1409
|
+
*
|
|
1410
|
+
* @param opts - Either server host/port overrides, or a serverless
|
|
1411
|
+
* `{ event, context, platform }` payload.
|
|
1412
|
+
* @returns `void` for server mode, or the serverless response object.
|
|
1032
1413
|
*/
|
|
1033
1414
|
run(opts?: {
|
|
1034
1415
|
host?: string;
|
|
1035
1416
|
port?: number;
|
|
1036
|
-
|
|
1417
|
+
event?: ServerlessEvent;
|
|
1418
|
+
context?: unknown;
|
|
1419
|
+
platform?: 'lambda' | 'gcf' | 'azure' | 'cgi' | 'auto';
|
|
1420
|
+
}): Promise<void | ServerlessResponse>;
|
|
1037
1421
|
/**
|
|
1038
1422
|
* Handle a single serverless invocation (AWS Lambda, Google Cloud Functions, Azure Functions, or CGI).
|
|
1039
1423
|
*
|
|
1040
1424
|
* Matches Python `run(event, context)` when executed in a serverless environment. Python's
|
|
1041
1425
|
* `run()` auto-detects the platform via `get_execution_mode()` and dispatches accordingly;
|
|
1042
|
-
*
|
|
1043
|
-
*
|
|
1426
|
+
* `runServerless` is the **explicit** serverless path so callers can opt in deliberately
|
|
1427
|
+
* (the polymorphic {@link run} dispatches here when a serverless env/event is detected).
|
|
1044
1428
|
*
|
|
1045
1429
|
* Platform detection follows the same environment-variable heuristics as Python's
|
|
1046
1430
|
* `ServerlessMixin`: `AWS_LAMBDA_FUNCTION_NAME` → Lambda, `K_SERVICE` → GCF,
|
|
@@ -1073,5 +1457,5 @@ export declare class AgentBase extends SWMLService {
|
|
|
1073
1457
|
* @returns A tuple of [username, password] or [username, password, source].
|
|
1074
1458
|
*/
|
|
1075
1459
|
getBasicAuthCredentials(includeSource?: false): [string, string];
|
|
1076
|
-
getBasicAuthCredentials(includeSource: true): [string, string, 'provided' | 'environment' | 'generated'];
|
|
1460
|
+
getBasicAuthCredentials(includeSource: true): [string, string, 'provided' | 'environment' | 'config file' | 'generated'];
|
|
1077
1461
|
}
|