@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
|
@@ -5,9 +5,12 @@
|
|
|
5
5
|
* They define tools, prompt sections, hints, and global data.
|
|
6
6
|
*/
|
|
7
7
|
import type { SwaigHandler } from '../SwaigFunction.js';
|
|
8
|
+
import type { FillerPhrases, SemanticGate } from '../SemanticGate.js';
|
|
9
|
+
import type { SwaigRequest } from '../SwaigContracts.js';
|
|
8
10
|
import type { FunctionResult } from '../FunctionResult.js';
|
|
9
11
|
import type { AgentBase } from '../AgentBase.js';
|
|
10
12
|
import { type Logger } from '../Logger.js';
|
|
13
|
+
import type { ToolParameters, ToolArgs } from '../ParameterSchema.js';
|
|
11
14
|
/** Configuration key-value pairs passed to a skill at construction time. */
|
|
12
15
|
export interface SkillConfig {
|
|
13
16
|
[key: string]: unknown;
|
|
@@ -24,7 +27,11 @@ export interface SkillToolDefinition {
|
|
|
24
27
|
handler: SwaigHandler;
|
|
25
28
|
/** Whether the tool requires secure (authenticated) invocation. */
|
|
26
29
|
secure?: boolean;
|
|
27
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* Phrases the AI says while the tool runs, keyed by language code, `"auto"`
|
|
32
|
+
* or `"default"`; an entry may also be a list of phrases, a wait script
|
|
33
|
+
* (the type predates wait scripts, so one needs a cast).
|
|
34
|
+
*/
|
|
28
35
|
fillers?: Record<string, string[]>;
|
|
29
36
|
/** List of parameter names that are required. */
|
|
30
37
|
required?: string[];
|
|
@@ -39,7 +46,74 @@ export interface SkillToolDefinition {
|
|
|
39
46
|
* The flag is serialised as `"is_hangup_hook": true` in the SWAIG JSON.
|
|
40
47
|
*/
|
|
41
48
|
isHangupHook?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Semantic gates on the tool: yes/no preconditions a decision model checks
|
|
51
|
+
* right before the platform runs it (see {@link SemanticGate}). They win
|
|
52
|
+
* over gates in the skill's `swaig_fields`.
|
|
53
|
+
*/
|
|
54
|
+
gates?: ReadonlyArray<SemanticGate | Record<string, unknown>>;
|
|
55
|
+
/** Phrases the AI says while the gates are checked, shaped like `fillers`. */
|
|
56
|
+
gate_fillers?: FillerPhrases;
|
|
42
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* Build a {@link SkillToolDefinition} whose `handler` args are *inferred* from
|
|
60
|
+
* its `parameters` schema + `required` list — the `getTools()`-level counterpart
|
|
61
|
+
* to {@link ../SWMLService.SWMLService.defineTool}'s typed-tool inference.
|
|
62
|
+
*
|
|
63
|
+
* A skill returns its tools as a plain `SkillToolDefinition[]`, and that
|
|
64
|
+
* interface types `handler` as the loose {@link SwaigHandler} (`args:
|
|
65
|
+
* Record<string, unknown>`) — so a hand-written entry's handler sees untyped
|
|
66
|
+
* args and must reach for `args['query'] as string`. Wrapping the entry in
|
|
67
|
+
* `defineSkillTool` captures `parameters` (`P`) and `required` (`R`) via `const`
|
|
68
|
+
* type parameters and feeds them through {@link ToolArgs}, so the handler's
|
|
69
|
+
* `args` is precise: a `required` string prop is `args.query: string`, an `enum`
|
|
70
|
+
* prop narrows to its literal union, optional props are `?`. It then erases the
|
|
71
|
+
* typed handler back to {@link SwaigHandler} at a single boundary and returns an
|
|
72
|
+
* ordinary `SkillToolDefinition`, so the result drops straight into a
|
|
73
|
+
* `getTools()` array with no other change.
|
|
74
|
+
*
|
|
75
|
+
* The inferred `args` is a **compile-time authoring convenience only** — at
|
|
76
|
+
* runtime `args` is still whatever JSON the model extracted, so a handler that
|
|
77
|
+
* cares (most do, since the model can emit an empty/typeless value even for a
|
|
78
|
+
* `required` param) keeps its defensive `typeof`/`.trim()` narrowing. The wire
|
|
79
|
+
* output is byte-identical to the equivalent hand-written entry (drift/emission
|
|
80
|
+
* unaffected); this is purely an author-side type gain.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```ts
|
|
84
|
+
* import { SkillBase, defineSkillTool, FunctionResult, type SkillToolDefinition } from '@signalwire/sdk';
|
|
85
|
+
*
|
|
86
|
+
* class WikiSkill extends SkillBase {
|
|
87
|
+
* static override SKILL_NAME = 'wiki';
|
|
88
|
+
* static override SKILL_DESCRIPTION = 'Search Wikipedia.';
|
|
89
|
+
*
|
|
90
|
+
* override getTools(): SkillToolDefinition[] {
|
|
91
|
+
* return [
|
|
92
|
+
* defineSkillTool({
|
|
93
|
+
* name: 'search_wiki',
|
|
94
|
+
* description: 'Search Wikipedia for a topic',
|
|
95
|
+
* parameters: { query: { type: 'string', description: 'The search term' } },
|
|
96
|
+
* required: ['query'],
|
|
97
|
+
* handler: async (args) => {
|
|
98
|
+
* // args.query is `string` (required) — no cast needed
|
|
99
|
+
* if (!args.query.trim()) return new FunctionResult('Provide a query.');
|
|
100
|
+
* return new FunctionResult(await this.searchWiki(args.query.trim()));
|
|
101
|
+
* },
|
|
102
|
+
* }),
|
|
103
|
+
* ];
|
|
104
|
+
* }
|
|
105
|
+
*
|
|
106
|
+
* private async searchWiki(query: string): Promise<string> {
|
|
107
|
+
* return `results for ${query}`;
|
|
108
|
+
* }
|
|
109
|
+
* }
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
export declare function defineSkillTool<const P extends ToolParameters = ToolParameters, const R extends readonly PropertyKey[] = []>(toolDef: Omit<SkillToolDefinition, 'parameters' | 'required' | 'handler'> & {
|
|
113
|
+
parameters?: P;
|
|
114
|
+
required?: R;
|
|
115
|
+
handler: (args: ToolArgs<P, R>, rawData: SwaigRequest, agent?: AgentBase) => FunctionResult | Record<string, unknown> | string | Promise<FunctionResult | Record<string, unknown> | string>;
|
|
116
|
+
}): SkillToolDefinition;
|
|
43
117
|
/** A section of prompt content injected into the agent's system prompt by a skill. */
|
|
44
118
|
export interface SkillPromptSection {
|
|
45
119
|
/** Section heading displayed in the prompt. */
|
|
@@ -63,7 +137,7 @@ export interface ParameterSchemaEntry {
|
|
|
63
137
|
required?: boolean;
|
|
64
138
|
/** Whether the parameter should be hidden from user-facing output (e.g., API keys). */
|
|
65
139
|
hidden?: boolean;
|
|
66
|
-
/** Environment variable
|
|
140
|
+
/** Environment variable a configuration tool can read this value from. A hint only: the SDK doesn't read it, so the skill gets the value from its params. */
|
|
67
141
|
env_var?: string;
|
|
68
142
|
/** Allowed values for the parameter. */
|
|
69
143
|
enum?: unknown[];
|
|
@@ -85,13 +159,14 @@ export interface ParameterSchemaEntry {
|
|
|
85
159
|
* - **Speech hints** via `getHints()`
|
|
86
160
|
* - **Global data** seeded into each call via `getGlobalData()`
|
|
87
161
|
*
|
|
88
|
-
* Skills are added to an agent with `agent.addSkill(
|
|
89
|
-
*
|
|
90
|
-
*
|
|
162
|
+
* Skills are added to an agent with `agent.addSkill(new MySkill(config))`, or
|
|
163
|
+
* by registered name with `agent.addSkillByName('name', config)`. The agent
|
|
164
|
+
* calls `setAgent()`, and the {@link SkillManager} then calls `setup()`,
|
|
165
|
+
* before the skill's tools are registered.
|
|
91
166
|
*
|
|
92
167
|
* @example Custom skill
|
|
93
168
|
* ```ts
|
|
94
|
-
* import { SkillBase, FunctionResult, type SkillToolDefinition } from '@signalwire/sdk';
|
|
169
|
+
* import { AgentBase, SkillBase, FunctionResult, type SkillToolDefinition } from '@signalwire/sdk';
|
|
95
170
|
*
|
|
96
171
|
* export class GreetingSkill extends SkillBase {
|
|
97
172
|
* static override SKILL_NAME = 'greeting';
|
|
@@ -108,7 +183,8 @@ export interface ParameterSchemaEntry {
|
|
|
108
183
|
* }
|
|
109
184
|
*
|
|
110
185
|
* // In your agent:
|
|
111
|
-
* agent
|
|
186
|
+
* const agent = new AgentBase({ name: 'demo', route: '/' });
|
|
187
|
+
* await agent.addSkill(new GreetingSkill({ message: 'Howdy!' }));
|
|
112
188
|
* ```
|
|
113
189
|
*
|
|
114
190
|
* @see {@link SkillManager}
|
|
@@ -119,7 +195,7 @@ export declare abstract class SkillBase {
|
|
|
119
195
|
/**
|
|
120
196
|
* Unique skill name. Subclasses MUST override with a non-empty string.
|
|
121
197
|
*
|
|
122
|
-
* Python
|
|
198
|
+
* Python equivalent:`SKILL_NAME: str = None` at `core/skill_base.py:23`.
|
|
123
199
|
* Python raises `ValueError` in `__init__` when this is left as `None`;
|
|
124
200
|
* TS throws at construction when this is left as the empty default.
|
|
125
201
|
*/
|
|
@@ -127,19 +203,19 @@ export declare abstract class SkillBase {
|
|
|
127
203
|
/**
|
|
128
204
|
* Human-readable description of the skill. Subclasses MUST override.
|
|
129
205
|
*
|
|
130
|
-
* Python
|
|
206
|
+
* Python equivalent:`SKILL_DESCRIPTION: str = None` at `core/skill_base.py:24`.
|
|
131
207
|
*/
|
|
132
208
|
static SKILL_DESCRIPTION: string;
|
|
133
209
|
/**
|
|
134
210
|
* Semantic version string. Subclasses may override; defaults to `"1.0.0"`.
|
|
135
211
|
*
|
|
136
|
-
* Python
|
|
212
|
+
* Python equivalent:`SKILL_VERSION: str = "1.0.0"` at `core/skill_base.py:25`.
|
|
137
213
|
*/
|
|
138
214
|
static SKILL_VERSION: string;
|
|
139
215
|
/**
|
|
140
216
|
* Packages required by the skill, checked at load time by `validatePackages()`.
|
|
141
217
|
*
|
|
142
|
-
* Python
|
|
218
|
+
* Python equivalent:`REQUIRED_PACKAGES: List[str] = []` at `core/skill_base.py:26`.
|
|
143
219
|
* In TS these are npm package names importable via dynamic `import()`.
|
|
144
220
|
*/
|
|
145
221
|
static REQUIRED_PACKAGES: readonly string[];
|
|
@@ -147,13 +223,13 @@ export declare abstract class SkillBase {
|
|
|
147
223
|
* Environment variables required for the skill to function, checked at load
|
|
148
224
|
* time by `validateEnvVars()`.
|
|
149
225
|
*
|
|
150
|
-
* Python
|
|
226
|
+
* Python equivalent:`REQUIRED_ENV_VARS: List[str] = []` at `core/skill_base.py:27`.
|
|
151
227
|
*/
|
|
152
228
|
static REQUIRED_ENV_VARS: readonly string[];
|
|
153
229
|
/**
|
|
154
230
|
* Whether this skill type supports multiple simultaneous instances (e.g., with different tool_name).
|
|
155
231
|
*
|
|
156
|
-
* Python
|
|
232
|
+
* Python equivalent:`SUPPORTS_MULTIPLE_INSTANCES: bool = False` at `core/skill_base.py:30`.
|
|
157
233
|
*/
|
|
158
234
|
static SUPPORTS_MULTIPLE_INSTANCES: boolean;
|
|
159
235
|
/**
|
|
@@ -185,8 +261,12 @@ export declare abstract class SkillBase {
|
|
|
185
261
|
* constructor. In the TypeScript SDK the SkillManager always calls
|
|
186
262
|
* `setAgent()` before `setup()`, so subclasses can rely on `getAgent()` being
|
|
187
263
|
* safe to call inside `setup()` and any method invoked after it.
|
|
264
|
+
*
|
|
265
|
+
* Readable by anyone holding the skill, so a test or an introspection tool can
|
|
266
|
+
* check which agent a skill was bound to. Subclasses that need a guaranteed
|
|
267
|
+
* non-null agent should still prefer the asserting {@link getAgent}.
|
|
188
268
|
*/
|
|
189
|
-
|
|
269
|
+
agent?: AgentBase;
|
|
190
270
|
/**
|
|
191
271
|
* Logger scoped to this skill. Python equivalent: `self.logger = get_logger(...)`
|
|
192
272
|
* set in `SkillBase.__init__` so every subclass can call `self.logger.info(...)`.
|
|
@@ -196,7 +276,7 @@ export declare abstract class SkillBase {
|
|
|
196
276
|
/**
|
|
197
277
|
* Tools registered imperatively via `defineTool()`.
|
|
198
278
|
*
|
|
199
|
-
* Python
|
|
279
|
+
* Python equivalent:Python's `SkillBase.register_tools()` is a `@abstractmethod` that
|
|
200
280
|
* calls `self.agent.define_tool(...)` (or `self.define_tool(...)`) once per tool.
|
|
201
281
|
* In TypeScript the tool pipeline is declarative (pull model): `SkillManager`
|
|
202
282
|
* calls `getTools()` at SWML render time. Skills that want to build their tool
|
|
@@ -218,10 +298,20 @@ export declare abstract class SkillBase {
|
|
|
218
298
|
* attached to an agent by the SkillManager).
|
|
219
299
|
*/
|
|
220
300
|
protected getAgent(): AgentBase;
|
|
301
|
+
/**
|
|
302
|
+
* The configuration this skill was constructed with — the reference's public
|
|
303
|
+
* `self.params` (`core/skill_base.py:40`), read-only.
|
|
304
|
+
*
|
|
305
|
+
* `swaig_fields` is absent: the constructor pops it into {@link swaigFields},
|
|
306
|
+
* mirroring the reference's `self.swaig_fields = self.params.pop(...)`
|
|
307
|
+
* (`core/skill_base.py:44`). Use {@link getConfig} for a single typed key; this
|
|
308
|
+
* returns the whole map, which is what the reference attribute exposes.
|
|
309
|
+
*/
|
|
310
|
+
get params(): Readonly<SkillConfig>;
|
|
221
311
|
/**
|
|
222
312
|
* Create a new skill instance.
|
|
223
313
|
*
|
|
224
|
-
* Python
|
|
314
|
+
* Python equivalent:`core/skill_base.py:32-43`.
|
|
225
315
|
* Python `__init__` raises `ValueError` if `SKILL_NAME` or `SKILL_DESCRIPTION`
|
|
226
316
|
* is left as `None` on the subclass. TS throws the equivalent when the static
|
|
227
317
|
* defaults haven't been overridden.
|
|
@@ -243,7 +333,7 @@ export declare abstract class SkillBase {
|
|
|
243
333
|
* `defineTool()`. Skills using the declarative pattern override this
|
|
244
334
|
* method to return a static array built from their config.
|
|
245
335
|
*
|
|
246
|
-
* Python
|
|
336
|
+
* Python equivalent:replaces the `@abstractmethod register_tools()` contract
|
|
247
337
|
* — Python skills call `self.define_tool(...)` inside `register_tools()`;
|
|
248
338
|
* TypeScript skills either call `this.defineTool(...)` in `setup()` (and
|
|
249
339
|
* let the default `getTools()` return them) or override `getTools()`
|
|
@@ -255,7 +345,7 @@ export declare abstract class SkillBase {
|
|
|
255
345
|
/**
|
|
256
346
|
* Imperatively register a tool with this skill.
|
|
257
347
|
*
|
|
258
|
-
* Python
|
|
348
|
+
* Python equivalent:`core/skill_base.py:58` `def define_tool(self, **kwargs)`.
|
|
259
349
|
* Merges `this.swaigFields` into the tool definition (explicit fields on
|
|
260
350
|
* `toolDef` take precedence), then pushes the result into `_dynamicTools`
|
|
261
351
|
* so the default `getTools()` returns it at SWML render time.
|
|
@@ -328,7 +418,7 @@ export declare abstract class SkillBase {
|
|
|
328
418
|
* @param rawData - The raw request data containing global_data.
|
|
329
419
|
* @returns The skill's stored data, or an empty object if not found.
|
|
330
420
|
*/
|
|
331
|
-
getSkillData(rawData:
|
|
421
|
+
getSkillData(rawData: SwaigRequest): Record<string, unknown>;
|
|
332
422
|
/**
|
|
333
423
|
* Update this skill's namespaced data on a FunctionResult via updateGlobalData.
|
|
334
424
|
* @param result - The FunctionResult to update.
|
|
@@ -344,7 +434,7 @@ export declare abstract class SkillBase {
|
|
|
344
434
|
* Validate that all required environment variables declared on the skill class
|
|
345
435
|
* are set in the current process environment.
|
|
346
436
|
*
|
|
347
|
-
* Python
|
|
437
|
+
* Python equivalent:`core/skill_base.py:103-110` reads `self.REQUIRED_ENV_VARS`
|
|
348
438
|
* directly. TS reads the same static from the class.
|
|
349
439
|
*
|
|
350
440
|
* Returns the list of missing variable names so callers can produce actionable
|
|
@@ -387,7 +477,7 @@ export declare abstract class SkillBase {
|
|
|
387
477
|
/**
|
|
388
478
|
* Validate that all required packages declared on the skill class can be imported.
|
|
389
479
|
*
|
|
390
|
-
* Python
|
|
480
|
+
* Python equivalent:`core/skill_base.py:112-124` reads `self.REQUIRED_PACKAGES`
|
|
391
481
|
* directly and tries `importlib.import_module(pkg)` for each; TS does the
|
|
392
482
|
* equivalent with a dynamic `import()`.
|
|
393
483
|
*
|
package/dist/skills/SkillBase.js
CHANGED
|
@@ -6,6 +6,71 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { randomBytes } from 'node:crypto';
|
|
8
8
|
import { getLogger } from '../Logger.js';
|
|
9
|
+
/**
|
|
10
|
+
* Build a {@link SkillToolDefinition} whose `handler` args are *inferred* from
|
|
11
|
+
* its `parameters` schema + `required` list — the `getTools()`-level counterpart
|
|
12
|
+
* to {@link ../SWMLService.SWMLService.defineTool}'s typed-tool inference.
|
|
13
|
+
*
|
|
14
|
+
* A skill returns its tools as a plain `SkillToolDefinition[]`, and that
|
|
15
|
+
* interface types `handler` as the loose {@link SwaigHandler} (`args:
|
|
16
|
+
* Record<string, unknown>`) — so a hand-written entry's handler sees untyped
|
|
17
|
+
* args and must reach for `args['query'] as string`. Wrapping the entry in
|
|
18
|
+
* `defineSkillTool` captures `parameters` (`P`) and `required` (`R`) via `const`
|
|
19
|
+
* type parameters and feeds them through {@link ToolArgs}, so the handler's
|
|
20
|
+
* `args` is precise: a `required` string prop is `args.query: string`, an `enum`
|
|
21
|
+
* prop narrows to its literal union, optional props are `?`. It then erases the
|
|
22
|
+
* typed handler back to {@link SwaigHandler} at a single boundary and returns an
|
|
23
|
+
* ordinary `SkillToolDefinition`, so the result drops straight into a
|
|
24
|
+
* `getTools()` array with no other change.
|
|
25
|
+
*
|
|
26
|
+
* The inferred `args` is a **compile-time authoring convenience only** — at
|
|
27
|
+
* runtime `args` is still whatever JSON the model extracted, so a handler that
|
|
28
|
+
* cares (most do, since the model can emit an empty/typeless value even for a
|
|
29
|
+
* `required` param) keeps its defensive `typeof`/`.trim()` narrowing. The wire
|
|
30
|
+
* output is byte-identical to the equivalent hand-written entry (drift/emission
|
|
31
|
+
* unaffected); this is purely an author-side type gain.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts
|
|
35
|
+
* import { SkillBase, defineSkillTool, FunctionResult, type SkillToolDefinition } from '@signalwire/sdk';
|
|
36
|
+
*
|
|
37
|
+
* class WikiSkill extends SkillBase {
|
|
38
|
+
* static override SKILL_NAME = 'wiki';
|
|
39
|
+
* static override SKILL_DESCRIPTION = 'Search Wikipedia.';
|
|
40
|
+
*
|
|
41
|
+
* override getTools(): SkillToolDefinition[] {
|
|
42
|
+
* return [
|
|
43
|
+
* defineSkillTool({
|
|
44
|
+
* name: 'search_wiki',
|
|
45
|
+
* description: 'Search Wikipedia for a topic',
|
|
46
|
+
* parameters: { query: { type: 'string', description: 'The search term' } },
|
|
47
|
+
* required: ['query'],
|
|
48
|
+
* handler: async (args) => {
|
|
49
|
+
* // args.query is `string` (required) — no cast needed
|
|
50
|
+
* if (!args.query.trim()) return new FunctionResult('Provide a query.');
|
|
51
|
+
* return new FunctionResult(await this.searchWiki(args.query.trim()));
|
|
52
|
+
* },
|
|
53
|
+
* }),
|
|
54
|
+
* ];
|
|
55
|
+
* }
|
|
56
|
+
*
|
|
57
|
+
* private async searchWiki(query: string): Promise<string> {
|
|
58
|
+
* return `results for ${query}`;
|
|
59
|
+
* }
|
|
60
|
+
* }
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
export function defineSkillTool(toolDef) {
|
|
64
|
+
return {
|
|
65
|
+
...toolDef,
|
|
66
|
+
parameters: toolDef.parameters,
|
|
67
|
+
required: toolDef.required,
|
|
68
|
+
// Single type-erasure boundary: at runtime the handler is the ordinary
|
|
69
|
+
// (args: Record<string,unknown>, rawData) SwaigHandler; the inferred-args
|
|
70
|
+
// view is compile-time only (mirrors SWMLService.defineTool).
|
|
71
|
+
handler: toolDef.handler,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
9
74
|
/**
|
|
10
75
|
* Abstract base class for agent skills.
|
|
11
76
|
*
|
|
@@ -17,13 +82,14 @@ import { getLogger } from '../Logger.js';
|
|
|
17
82
|
* - **Speech hints** via `getHints()`
|
|
18
83
|
* - **Global data** seeded into each call via `getGlobalData()`
|
|
19
84
|
*
|
|
20
|
-
* Skills are added to an agent with `agent.addSkill(
|
|
21
|
-
*
|
|
22
|
-
*
|
|
85
|
+
* Skills are added to an agent with `agent.addSkill(new MySkill(config))`, or
|
|
86
|
+
* by registered name with `agent.addSkillByName('name', config)`. The agent
|
|
87
|
+
* calls `setAgent()`, and the {@link SkillManager} then calls `setup()`,
|
|
88
|
+
* before the skill's tools are registered.
|
|
23
89
|
*
|
|
24
90
|
* @example Custom skill
|
|
25
91
|
* ```ts
|
|
26
|
-
* import { SkillBase, FunctionResult, type SkillToolDefinition } from '@signalwire/sdk';
|
|
92
|
+
* import { AgentBase, SkillBase, FunctionResult, type SkillToolDefinition } from '@signalwire/sdk';
|
|
27
93
|
*
|
|
28
94
|
* export class GreetingSkill extends SkillBase {
|
|
29
95
|
* static override SKILL_NAME = 'greeting';
|
|
@@ -40,7 +106,8 @@ import { getLogger } from '../Logger.js';
|
|
|
40
106
|
* }
|
|
41
107
|
*
|
|
42
108
|
* // In your agent:
|
|
43
|
-
* agent
|
|
109
|
+
* const agent = new AgentBase({ name: 'demo', route: '/' });
|
|
110
|
+
* await agent.addSkill(new GreetingSkill({ message: 'Howdy!' }));
|
|
44
111
|
* ```
|
|
45
112
|
*
|
|
46
113
|
* @see {@link SkillManager}
|
|
@@ -51,7 +118,7 @@ export class SkillBase {
|
|
|
51
118
|
/**
|
|
52
119
|
* Unique skill name. Subclasses MUST override with a non-empty string.
|
|
53
120
|
*
|
|
54
|
-
* Python
|
|
121
|
+
* Python equivalent:`SKILL_NAME: str = None` at `core/skill_base.py:23`.
|
|
55
122
|
* Python raises `ValueError` in `__init__` when this is left as `None`;
|
|
56
123
|
* TS throws at construction when this is left as the empty default.
|
|
57
124
|
*/
|
|
@@ -59,19 +126,19 @@ export class SkillBase {
|
|
|
59
126
|
/**
|
|
60
127
|
* Human-readable description of the skill. Subclasses MUST override.
|
|
61
128
|
*
|
|
62
|
-
* Python
|
|
129
|
+
* Python equivalent:`SKILL_DESCRIPTION: str = None` at `core/skill_base.py:24`.
|
|
63
130
|
*/
|
|
64
131
|
static SKILL_DESCRIPTION = '';
|
|
65
132
|
/**
|
|
66
133
|
* Semantic version string. Subclasses may override; defaults to `"1.0.0"`.
|
|
67
134
|
*
|
|
68
|
-
* Python
|
|
135
|
+
* Python equivalent:`SKILL_VERSION: str = "1.0.0"` at `core/skill_base.py:25`.
|
|
69
136
|
*/
|
|
70
137
|
static SKILL_VERSION = '1.0.0';
|
|
71
138
|
/**
|
|
72
139
|
* Packages required by the skill, checked at load time by `validatePackages()`.
|
|
73
140
|
*
|
|
74
|
-
* Python
|
|
141
|
+
* Python equivalent:`REQUIRED_PACKAGES: List[str] = []` at `core/skill_base.py:26`.
|
|
75
142
|
* In TS these are npm package names importable via dynamic `import()`.
|
|
76
143
|
*/
|
|
77
144
|
static REQUIRED_PACKAGES = [];
|
|
@@ -79,13 +146,13 @@ export class SkillBase {
|
|
|
79
146
|
* Environment variables required for the skill to function, checked at load
|
|
80
147
|
* time by `validateEnvVars()`.
|
|
81
148
|
*
|
|
82
|
-
* Python
|
|
149
|
+
* Python equivalent:`REQUIRED_ENV_VARS: List[str] = []` at `core/skill_base.py:27`.
|
|
83
150
|
*/
|
|
84
151
|
static REQUIRED_ENV_VARS = [];
|
|
85
152
|
/**
|
|
86
153
|
* Whether this skill type supports multiple simultaneous instances (e.g., with different tool_name).
|
|
87
154
|
*
|
|
88
|
-
* Python
|
|
155
|
+
* Python equivalent:`SUPPORTS_MULTIPLE_INSTANCES: bool = False` at `core/skill_base.py:30`.
|
|
89
156
|
*/
|
|
90
157
|
static SUPPORTS_MULTIPLE_INSTANCES = false;
|
|
91
158
|
/**
|
|
@@ -142,6 +209,10 @@ export class SkillBase {
|
|
|
142
209
|
* constructor. In the TypeScript SDK the SkillManager always calls
|
|
143
210
|
* `setAgent()` before `setup()`, so subclasses can rely on `getAgent()` being
|
|
144
211
|
* safe to call inside `setup()` and any method invoked after it.
|
|
212
|
+
*
|
|
213
|
+
* Readable by anyone holding the skill, so a test or an introspection tool can
|
|
214
|
+
* check which agent a skill was bound to. Subclasses that need a guaranteed
|
|
215
|
+
* non-null agent should still prefer the asserting {@link getAgent}.
|
|
145
216
|
*/
|
|
146
217
|
agent;
|
|
147
218
|
/**
|
|
@@ -153,7 +224,7 @@ export class SkillBase {
|
|
|
153
224
|
/**
|
|
154
225
|
* Tools registered imperatively via `defineTool()`.
|
|
155
226
|
*
|
|
156
|
-
* Python
|
|
227
|
+
* Python equivalent:Python's `SkillBase.register_tools()` is a `@abstractmethod` that
|
|
157
228
|
* calls `self.agent.define_tool(...)` (or `self.define_tool(...)`) once per tool.
|
|
158
229
|
* In TypeScript the tool pipeline is declarative (pull model): `SkillManager`
|
|
159
230
|
* calls `getTools()` at SWML render time. Skills that want to build their tool
|
|
@@ -182,10 +253,22 @@ export class SkillBase {
|
|
|
182
253
|
}
|
|
183
254
|
return this.agent;
|
|
184
255
|
}
|
|
256
|
+
/**
|
|
257
|
+
* The configuration this skill was constructed with — the reference's public
|
|
258
|
+
* `self.params` (`core/skill_base.py:40`), read-only.
|
|
259
|
+
*
|
|
260
|
+
* `swaig_fields` is absent: the constructor pops it into {@link swaigFields},
|
|
261
|
+
* mirroring the reference's `self.swaig_fields = self.params.pop(...)`
|
|
262
|
+
* (`core/skill_base.py:44`). Use {@link getConfig} for a single typed key; this
|
|
263
|
+
* returns the whole map, which is what the reference attribute exposes.
|
|
264
|
+
*/
|
|
265
|
+
get params() {
|
|
266
|
+
return this.config;
|
|
267
|
+
}
|
|
185
268
|
/**
|
|
186
269
|
* Create a new skill instance.
|
|
187
270
|
*
|
|
188
|
-
* Python
|
|
271
|
+
* Python equivalent:`core/skill_base.py:32-43`.
|
|
189
272
|
* Python `__init__` raises `ValueError` if `SKILL_NAME` or `SKILL_DESCRIPTION`
|
|
190
273
|
* is left as `None` on the subclass. TS throws the equivalent when the static
|
|
191
274
|
* defaults haven't been overridden.
|
|
@@ -226,7 +309,7 @@ export class SkillBase {
|
|
|
226
309
|
* `defineTool()`. Skills using the declarative pattern override this
|
|
227
310
|
* method to return a static array built from their config.
|
|
228
311
|
*
|
|
229
|
-
* Python
|
|
312
|
+
* Python equivalent:replaces the `@abstractmethod register_tools()` contract
|
|
230
313
|
* — Python skills call `self.define_tool(...)` inside `register_tools()`;
|
|
231
314
|
* TypeScript skills either call `this.defineTool(...)` in `setup()` (and
|
|
232
315
|
* let the default `getTools()` return them) or override `getTools()`
|
|
@@ -240,7 +323,7 @@ export class SkillBase {
|
|
|
240
323
|
/**
|
|
241
324
|
* Imperatively register a tool with this skill.
|
|
242
325
|
*
|
|
243
|
-
* Python
|
|
326
|
+
* Python equivalent:`core/skill_base.py:58` `def define_tool(self, **kwargs)`.
|
|
244
327
|
* Merges `this.swaigFields` into the tool definition (explicit fields on
|
|
245
328
|
* `toolDef` take precedence), then pushes the result into `_dynamicTools`
|
|
246
329
|
* so the default `getTools()` returns it at SWML render time.
|
|
@@ -368,7 +451,7 @@ export class SkillBase {
|
|
|
368
451
|
* Validate that all required environment variables declared on the skill class
|
|
369
452
|
* are set in the current process environment.
|
|
370
453
|
*
|
|
371
|
-
* Python
|
|
454
|
+
* Python equivalent:`core/skill_base.py:103-110` reads `self.REQUIRED_ENV_VARS`
|
|
372
455
|
* directly. TS reads the same static from the class.
|
|
373
456
|
*
|
|
374
457
|
* Returns the list of missing variable names so callers can produce actionable
|
|
@@ -436,7 +519,7 @@ export class SkillBase {
|
|
|
436
519
|
/**
|
|
437
520
|
* Validate that all required packages declared on the skill class can be imported.
|
|
438
521
|
*
|
|
439
|
-
* Python
|
|
522
|
+
* Python equivalent:`core/skill_base.py:112-124` reads `self.REQUIRED_PACKAGES`
|
|
440
523
|
* directly and tries `importlib.import_module(pkg)` for each; TS does the
|
|
441
524
|
* equivalent with a dynamic `import()`.
|
|
442
525
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SkillBase.js","sourceRoot":"","sources":["../../src/skills/SkillBase.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,WAA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AC,eAAe,EAAE,CAAC,MAAM,KAAK,CAAC,CAAC;IAC7C,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,gBAAgB;QACpB,MAAM,KAAK,GAAG,IAAI,CAAC,WAA+B,CAAC;QACnD,MAAM,OAAO,GAAa,EAAE,CAAC;QAC7B,KAAK,MAAM,GAAG,IAAI,KAAK,CAAC,iBAAiB,EAAE,CAAC;YAC1C,IAAI,CAAC;gBACH,MAAM,MAAM,CAAC,GAAG,CAAC,CAAC;YACpB,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACpB,CAAC;QACH,CAAC;QACD,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACvB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,8BAA8B,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACxE,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,cAAc;QAClB,OAAO,CAAC,MAAM,IAAI,CAAC,gBAAgB,EAAE,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC;IACtD,CAAC"}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* skill tools, hints, global data, and prompt sections.
|
|
6
6
|
*/
|
|
7
7
|
import { SkillBase, type SkillConfig } from './SkillBase.js';
|
|
8
|
+
import type { AgentBase } from '../AgentBase.js';
|
|
8
9
|
/**
|
|
9
10
|
* Manages the lifecycle of skills attached to an agent.
|
|
10
11
|
*
|
|
@@ -12,23 +13,49 @@ import { SkillBase, type SkillConfig } from './SkillBase.js';
|
|
|
12
13
|
* hints, global data, and prompt sections.
|
|
13
14
|
*
|
|
14
15
|
* @remarks
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* `
|
|
16
|
+
* `AgentBase` owns a manager (`agent.skillManager`). {@link addSkill} only
|
|
17
|
+
* checks, sets up and records a skill: `AgentBase.addSkill()` calls it, then
|
|
18
|
+
* registers the skill's tools, prompt sections, hints and global data on the
|
|
19
|
+
* agent. {@link loadSkill} and {@link loadSkillByName} on a manager that
|
|
20
|
+
* belongs to an agent go through `AgentBase.addSkill()`, so the skill is
|
|
21
|
+
* registered on the agent as well, as Python's `SkillManager.load_skill()`
|
|
22
|
+
* does (`core/skill_manager.py`). On a standalone manager they only record
|
|
23
|
+
* the skill.
|
|
20
24
|
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* calls `getAllHints()`, `getMergedGlobalData()`, and `getAllPromptSections()`
|
|
24
|
-
* at render time. Both approaches produce the same observable behavior at the
|
|
25
|
-
* SWML / SWAIG level. The pull model avoids circular-reference issues between
|
|
26
|
-
* `AgentBase` and `SkillManager` and is better suited to TypeScript's
|
|
27
|
-
* import-graph constraints.
|
|
25
|
+
* The owning agent is kept as a public back-reference ({@link agent}), the
|
|
26
|
+
* reference's readable `self.agent` (`core/skill_manager.py:22`).
|
|
28
27
|
*/
|
|
29
28
|
export declare class SkillManager {
|
|
30
29
|
private skills;
|
|
31
30
|
private skillMeta;
|
|
31
|
+
/** Instance keys taken over from another manager by {@link _inheritFrom}. */
|
|
32
|
+
private inherited;
|
|
33
|
+
/**
|
|
34
|
+
* The agent this manager belongs to (the reference's public `self.agent`), or
|
|
35
|
+
* `undefined` when the manager is used standalone (a bare `new SkillManager()`,
|
|
36
|
+
* as in tests and the doc examples).
|
|
37
|
+
*/
|
|
38
|
+
readonly agent?: AgentBase;
|
|
39
|
+
/**
|
|
40
|
+
* @param agent - Optional owning agent, kept as a public back-reference
|
|
41
|
+
* (the reference's `SkillManager(agent)`). Omit for standalone use.
|
|
42
|
+
*/
|
|
43
|
+
constructor(agent?: AgentBase);
|
|
44
|
+
/**
|
|
45
|
+
* Start with the skills another manager has loaded, for a per-request copy
|
|
46
|
+
* of its agent. The skill instances are shared and not set up again: their
|
|
47
|
+
* tools, hints, prompt sections and global data are already in the agent
|
|
48
|
+
* the copy was made from. Removing an inherited skill from this manager
|
|
49
|
+
* drops it here without cleaning up the shared instance.
|
|
50
|
+
* @internal
|
|
51
|
+
*/
|
|
52
|
+
_inheritFrom(other: SkillManager): void;
|
|
53
|
+
/**
|
|
54
|
+
* Whether `skill`'s instance is one {@link _inheritFrom} took over, so
|
|
55
|
+
* adding it again is a no-op.
|
|
56
|
+
* @internal
|
|
57
|
+
*/
|
|
58
|
+
_inherits(skill: SkillBase): boolean;
|
|
32
59
|
/**
|
|
33
60
|
* Public read-only view of all loaded skill instances, keyed by instance key.
|
|
34
61
|
* Python equivalent: `self.loaded_skills` (public `Dict[str, SkillBase]`).
|
|
@@ -38,7 +65,9 @@ export declare class SkillManager {
|
|
|
38
65
|
get loadedSkills(): ReadonlyMap<string, SkillBase>;
|
|
39
66
|
/**
|
|
40
67
|
* Add a skill to the manager, validating env vars and calling setup().
|
|
41
|
-
* Uses the skill's instance key for deduplication.
|
|
68
|
+
* Uses the skill's instance key for deduplication. This records the skill
|
|
69
|
+
* only; it doesn't register the skill's tools on the agent. Use
|
|
70
|
+
* {@link loadSkill}, or `AgentBase.addSkill()`, for that.
|
|
42
71
|
*
|
|
43
72
|
* {@link loadSkill} / {@link loadSkillByName} wrap this and catch to return
|
|
44
73
|
* `[false, msg]`, matching Python `load_skill`'s return contract
|
|
@@ -90,11 +119,21 @@ export declare class SkillManager {
|
|
|
90
119
|
* `skillManager.hasSkillByKey(key)`.
|
|
91
120
|
*/
|
|
92
121
|
hasSkillByKey(instanceKey: string): boolean;
|
|
122
|
+
/**
|
|
123
|
+
* Add a skill and, when this manager belongs to an agent, register its
|
|
124
|
+
* tools, prompt sections, hints and global data there, through
|
|
125
|
+
* `AgentBase.addSkill()` (which calls {@link addSkill}).
|
|
126
|
+
*/
|
|
127
|
+
private addAndRegister;
|
|
93
128
|
/**
|
|
94
129
|
* Load a skill by providing the class constructor directly, bypassing the registry.
|
|
95
130
|
* This is the TypeScript equivalent of Python's `load_skill(skill_name, skill_class, params)`
|
|
96
131
|
* path where a caller-provided `skill_class` is used instead of a registry lookup.
|
|
97
132
|
*
|
|
133
|
+
* On a manager that belongs to an agent, the skill's tools, prompt sections,
|
|
134
|
+
* hints and global data are registered on that agent, as with
|
|
135
|
+
* `agent.addSkill()`.
|
|
136
|
+
*
|
|
98
137
|
* @param skillClass - The skill class constructor (a subclass of `SkillBase`).
|
|
99
138
|
* @param config - Optional configuration to pass to the skill constructor.
|
|
100
139
|
* @returns A tuple `[success, errorMessage]` matching Python's `load_skill` return
|
|
@@ -104,6 +143,17 @@ export declare class SkillManager {
|
|
|
104
143
|
*
|
|
105
144
|
* @example
|
|
106
145
|
* ```ts
|
|
146
|
+
* import { SkillManager, SkillBase, type SkillToolDefinition } from '@signalwire/sdk';
|
|
147
|
+
*
|
|
148
|
+
* class MyCustomSkill extends SkillBase {
|
|
149
|
+
* static override SKILL_NAME = 'my_custom';
|
|
150
|
+
* static override SKILL_DESCRIPTION = 'Example custom skill.';
|
|
151
|
+
* override getTools(): SkillToolDefinition[] {
|
|
152
|
+
* return [];
|
|
153
|
+
* }
|
|
154
|
+
* }
|
|
155
|
+
*
|
|
156
|
+
* const manager = new SkillManager();
|
|
107
157
|
* const [ok, err] = await manager.loadSkill(MyCustomSkill, { api_key: 'secret' });
|
|
108
158
|
* if (!ok) console.error(err);
|
|
109
159
|
* ```
|
|
@@ -114,6 +164,9 @@ export declare class SkillManager {
|
|
|
114
164
|
* This is the TypeScript equivalent of Python's `load_skill(skill_name)` path
|
|
115
165
|
* where `skill_class=None` triggers a registry lookup.
|
|
116
166
|
*
|
|
167
|
+
* On a manager that belongs to an agent, the skill is registered on that
|
|
168
|
+
* agent, as with {@link loadSkill}.
|
|
169
|
+
*
|
|
117
170
|
* @param skillName - The registered skill name to look up in the SkillRegistry.
|
|
118
171
|
* @param config - Optional configuration to pass to the skill factory.
|
|
119
172
|
* @returns A tuple `[success, errorMessage]` matching Python's `load_skill` return
|