@wingman-ai/gateway 0.1.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/.wingman/agents/README.md +161 -0
- package/.wingman/agents/coding/agent.md +147 -0
- package/.wingman/agents/coding/implementor.md +56 -0
- package/.wingman/agents/main/agent.md +19 -0
- package/.wingman/agents/researcher/agent.md +62 -0
- package/.wingman/agents/stock-trader/agent.md +223 -0
- package/.wingman/agents/stock-trader/chain-curator.md +24 -0
- package/.wingman/agents/stock-trader/goal-translator.md +42 -0
- package/.wingman/agents/stock-trader/guardrails-veto.md +11 -0
- package/.wingman/agents/stock-trader/path-planner.md +23 -0
- package/.wingman/agents/stock-trader/regime-analyst.md +15 -0
- package/.wingman/agents/stock-trader/risk.md +20 -0
- package/.wingman/agents/stock-trader/selection.md +22 -0
- package/.wingman/agents/stock-trader/strategy-composer.md +38 -0
- package/.wingman/agents/wingman/agent.json +12 -0
- package/bin/wingman +7 -0
- package/dist/agent/config/agentConfig.cjs +95 -0
- package/dist/agent/config/agentConfig.d.ts +187 -0
- package/dist/agent/config/agentConfig.js +52 -0
- package/dist/agent/config/agentLoader.cjs +242 -0
- package/dist/agent/config/agentLoader.d.ts +42 -0
- package/dist/agent/config/agentLoader.js +208 -0
- package/dist/agent/config/mcpClientManager.cjs +168 -0
- package/dist/agent/config/mcpClientManager.d.ts +41 -0
- package/dist/agent/config/mcpClientManager.js +134 -0
- package/dist/agent/config/modelFactory.cjs +175 -0
- package/dist/agent/config/modelFactory.d.ts +33 -0
- package/dist/agent/config/modelFactory.js +141 -0
- package/dist/agent/config/toolRegistry.cjs +111 -0
- package/dist/agent/config/toolRegistry.d.ts +25 -0
- package/dist/agent/config/toolRegistry.js +71 -0
- package/dist/agent/middleware/additional-messages.cjs +60 -0
- package/dist/agent/middleware/additional-messages.d.ts +7 -0
- package/dist/agent/middleware/additional-messages.js +26 -0
- package/dist/agent/middleware/hooks/executor.cjs +137 -0
- package/dist/agent/middleware/hooks/executor.d.ts +52 -0
- package/dist/agent/middleware/hooks/executor.js +103 -0
- package/dist/agent/middleware/hooks/input-builder.cjs +55 -0
- package/dist/agent/middleware/hooks/input-builder.d.ts +15 -0
- package/dist/agent/middleware/hooks/input-builder.js +21 -0
- package/dist/agent/middleware/hooks/matcher.cjs +59 -0
- package/dist/agent/middleware/hooks/matcher.d.ts +27 -0
- package/dist/agent/middleware/hooks/matcher.js +22 -0
- package/dist/agent/middleware/hooks/merger.cjs +54 -0
- package/dist/agent/middleware/hooks/merger.d.ts +18 -0
- package/dist/agent/middleware/hooks/merger.js +20 -0
- package/dist/agent/middleware/hooks/types.cjs +62 -0
- package/dist/agent/middleware/hooks/types.d.ts +82 -0
- package/dist/agent/middleware/hooks/types.js +19 -0
- package/dist/agent/middleware/hooks.cjs +79 -0
- package/dist/agent/middleware/hooks.d.ts +19 -0
- package/dist/agent/middleware/hooks.js +45 -0
- package/dist/agent/middleware/media-compat.cjs +80 -0
- package/dist/agent/middleware/media-compat.d.ts +7 -0
- package/dist/agent/middleware/media-compat.js +46 -0
- package/dist/agent/tests/agentConfig.test.cjs +132 -0
- package/dist/agent/tests/agentConfig.test.d.ts +1 -0
- package/dist/agent/tests/agentConfig.test.js +126 -0
- package/dist/agent/tests/agentLoader.test.cjs +235 -0
- package/dist/agent/tests/agentLoader.test.d.ts +1 -0
- package/dist/agent/tests/agentLoader.test.js +229 -0
- package/dist/agent/tests/modelFactory.test.cjs +114 -0
- package/dist/agent/tests/modelFactory.test.d.ts +1 -0
- package/dist/agent/tests/modelFactory.test.js +108 -0
- package/dist/agent/tests/test-agent-loader.cjs +33 -0
- package/dist/agent/tests/test-agent-loader.d.ts +1 -0
- package/dist/agent/tests/test-agent-loader.js +27 -0
- package/dist/agent/tests/test-subagent-loading.cjs +99 -0
- package/dist/agent/tests/test-subagent-loading.d.ts +1 -0
- package/dist/agent/tests/test-subagent-loading.js +93 -0
- package/dist/agent/tests/toolRegistry.test.cjs +109 -0
- package/dist/agent/tests/toolRegistry.test.d.ts +1 -0
- package/dist/agent/tests/toolRegistry.test.js +103 -0
- package/dist/agent/tools/code_search.cjs +108 -0
- package/dist/agent/tools/code_search.d.ts +24 -0
- package/dist/agent/tools/code_search.js +74 -0
- package/dist/agent/tools/command_execute.cjs +136 -0
- package/dist/agent/tools/command_execute.d.ts +12 -0
- package/dist/agent/tools/command_execute.js +99 -0
- package/dist/agent/tools/git_status.cjs +126 -0
- package/dist/agent/tools/git_status.d.ts +15 -0
- package/dist/agent/tools/git_status.js +92 -0
- package/dist/agent/tools/internet_search.cjs +93 -0
- package/dist/agent/tools/internet_search.d.ts +25 -0
- package/dist/agent/tools/internet_search.js +56 -0
- package/dist/agent/tools/think.cjs +53 -0
- package/dist/agent/tools/think.d.ts +26 -0
- package/dist/agent/tools/think.js +16 -0
- package/dist/agent/tools/web_crawler.cjs +180 -0
- package/dist/agent/tools/web_crawler.d.ts +31 -0
- package/dist/agent/tools/web_crawler.js +143 -0
- package/dist/agent/utils.cjs +54 -0
- package/dist/agent/utils.d.ts +1 -0
- package/dist/agent/utils.js +10 -0
- package/dist/cli/commands/agent.cjs +169 -0
- package/dist/cli/commands/agent.d.ts +15 -0
- package/dist/cli/commands/agent.js +125 -0
- package/dist/cli/commands/gateway.cjs +601 -0
- package/dist/cli/commands/gateway.d.ts +12 -0
- package/dist/cli/commands/gateway.js +567 -0
- package/dist/cli/commands/init.cjs +681 -0
- package/dist/cli/commands/init.d.ts +10 -0
- package/dist/cli/commands/init.js +634 -0
- package/dist/cli/commands/provider.cjs +208 -0
- package/dist/cli/commands/provider.d.ts +5 -0
- package/dist/cli/commands/provider.js +174 -0
- package/dist/cli/commands/skill.cjs +145 -0
- package/dist/cli/commands/skill.d.ts +10 -0
- package/dist/cli/commands/skill.js +111 -0
- package/dist/cli/config/loader.cjs +143 -0
- package/dist/cli/config/loader.d.ts +14 -0
- package/dist/cli/config/loader.js +109 -0
- package/dist/cli/config/schema.cjs +262 -0
- package/dist/cli/config/schema.d.ts +268 -0
- package/dist/cli/config/schema.js +213 -0
- package/dist/cli/core/agentInvoker.cjs +284 -0
- package/dist/cli/core/agentInvoker.d.ts +77 -0
- package/dist/cli/core/agentInvoker.js +247 -0
- package/dist/cli/core/commandHandler.cjs +257 -0
- package/dist/cli/core/commandHandler.d.ts +62 -0
- package/dist/cli/core/commandHandler.js +223 -0
- package/dist/cli/core/database/bunSqliteAdapter.cjs +87 -0
- package/dist/cli/core/database/bunSqliteAdapter.d.ts +34 -0
- package/dist/cli/core/database/bunSqliteAdapter.js +53 -0
- package/dist/cli/core/loggerBridge.cjs +42 -0
- package/dist/cli/core/loggerBridge.d.ts +8 -0
- package/dist/cli/core/loggerBridge.js +8 -0
- package/dist/cli/core/outputManager.cjs +106 -0
- package/dist/cli/core/outputManager.d.ts +43 -0
- package/dist/cli/core/outputManager.js +72 -0
- package/dist/cli/core/sessionManager.cjs +535 -0
- package/dist/cli/core/sessionManager.d.ts +111 -0
- package/dist/cli/core/sessionManager.js +486 -0
- package/dist/cli/core/streamParser.cjs +328 -0
- package/dist/cli/core/streamParser.d.ts +42 -0
- package/dist/cli/core/streamParser.js +288 -0
- package/dist/cli/index.cjs +211 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +205 -0
- package/dist/cli/services/skillRepository.cjs +178 -0
- package/dist/cli/services/skillRepository.d.ts +35 -0
- package/dist/cli/services/skillRepository.js +144 -0
- package/dist/cli/services/skillService.cjs +336 -0
- package/dist/cli/services/skillService.d.ts +48 -0
- package/dist/cli/services/skillService.js +302 -0
- package/dist/cli/types/gateway.cjs +18 -0
- package/dist/cli/types/gateway.d.ts +18 -0
- package/dist/cli/types/gateway.js +0 -0
- package/dist/cli/types/init.cjs +18 -0
- package/dist/cli/types/init.d.ts +13 -0
- package/dist/cli/types/init.js +0 -0
- package/dist/cli/types/provider.cjs +18 -0
- package/dist/cli/types/provider.d.ts +9 -0
- package/dist/cli/types/provider.js +0 -0
- package/dist/cli/types/skill.cjs +18 -0
- package/dist/cli/types/skill.d.ts +71 -0
- package/dist/cli/types/skill.js +0 -0
- package/dist/cli/types.cjs +18 -0
- package/dist/cli/types.d.ts +175 -0
- package/dist/cli/types.js +0 -0
- package/dist/cli/ui/AgentOutput.cjs +82 -0
- package/dist/cli/ui/AgentOutput.d.ts +8 -0
- package/dist/cli/ui/AgentOutput.js +38 -0
- package/dist/cli/ui/App.cjs +285 -0
- package/dist/cli/ui/App.d.ts +6 -0
- package/dist/cli/ui/App.js +241 -0
- package/dist/cli/ui/ErrorDisplay.cjs +65 -0
- package/dist/cli/ui/ErrorDisplay.d.ts +8 -0
- package/dist/cli/ui/ErrorDisplay.js +21 -0
- package/dist/cli/ui/LogDisplay.cjs +74 -0
- package/dist/cli/ui/LogDisplay.d.ts +13 -0
- package/dist/cli/ui/LogDisplay.js +30 -0
- package/dist/cli/ui/SessionListDisplay.cjs +135 -0
- package/dist/cli/ui/SessionListDisplay.d.ts +9 -0
- package/dist/cli/ui/SessionListDisplay.js +91 -0
- package/dist/cli/ui/blockHelpers.cjs +80 -0
- package/dist/cli/ui/blockHelpers.d.ts +21 -0
- package/dist/cli/ui/blockHelpers.js +40 -0
- package/dist/cli/ui/components/ToolCallDisplay.cjs +207 -0
- package/dist/cli/ui/components/ToolCallDisplay.d.ts +7 -0
- package/dist/cli/ui/components/ToolCallDisplay.js +162 -0
- package/dist/cli/ui/components/ToolResultDisplay.cjs +86 -0
- package/dist/cli/ui/components/ToolResultDisplay.d.ts +8 -0
- package/dist/cli/ui/components/ToolResultDisplay.js +42 -0
- package/dist/cli/ui/toolDisplayHelpers.cjs +112 -0
- package/dist/cli/ui/toolDisplayHelpers.d.ts +3 -0
- package/dist/cli/ui/toolDisplayHelpers.js +72 -0
- package/dist/gateway/adapters/discord.cjs +298 -0
- package/dist/gateway/adapters/discord.d.ts +42 -0
- package/dist/gateway/adapters/discord.js +246 -0
- package/dist/gateway/auth.cjs +94 -0
- package/dist/gateway/auth.d.ts +36 -0
- package/dist/gateway/auth.js +60 -0
- package/dist/gateway/broadcast.cjs +131 -0
- package/dist/gateway/broadcast.d.ts +76 -0
- package/dist/gateway/broadcast.js +97 -0
- package/dist/gateway/client.cjs +282 -0
- package/dist/gateway/client.d.ts +141 -0
- package/dist/gateway/client.js +248 -0
- package/dist/gateway/daemon.cjs +195 -0
- package/dist/gateway/daemon.d.ts +67 -0
- package/dist/gateway/daemon.js +161 -0
- package/dist/gateway/discovery/index.cjs +72 -0
- package/dist/gateway/discovery/index.d.ts +3 -0
- package/dist/gateway/discovery/index.js +3 -0
- package/dist/gateway/discovery/mdns.cjs +221 -0
- package/dist/gateway/discovery/mdns.d.ts +37 -0
- package/dist/gateway/discovery/mdns.js +177 -0
- package/dist/gateway/discovery/tailscale.cjs +140 -0
- package/dist/gateway/discovery/tailscale.d.ts +31 -0
- package/dist/gateway/discovery/tailscale.js +106 -0
- package/dist/gateway/discovery/types.cjs +18 -0
- package/dist/gateway/discovery/types.d.ts +41 -0
- package/dist/gateway/discovery/types.js +0 -0
- package/dist/gateway/env.cjs +45 -0
- package/dist/gateway/env.d.ts +2 -0
- package/dist/gateway/env.js +8 -0
- package/dist/gateway/hooks/loader.cjs +137 -0
- package/dist/gateway/hooks/loader.d.ts +10 -0
- package/dist/gateway/hooks/loader.js +103 -0
- package/dist/gateway/hooks/registry.cjs +128 -0
- package/dist/gateway/hooks/registry.d.ts +13 -0
- package/dist/gateway/hooks/registry.js +94 -0
- package/dist/gateway/hooks/types.cjs +58 -0
- package/dist/gateway/hooks/types.d.ts +50 -0
- package/dist/gateway/hooks/types.js +18 -0
- package/dist/gateway/http/agents.cjs +280 -0
- package/dist/gateway/http/agents.d.ts +2 -0
- package/dist/gateway/http/agents.js +246 -0
- package/dist/gateway/http/fs.cjs +81 -0
- package/dist/gateway/http/fs.d.ts +2 -0
- package/dist/gateway/http/fs.js +47 -0
- package/dist/gateway/http/providers.cjs +120 -0
- package/dist/gateway/http/providers.d.ts +2 -0
- package/dist/gateway/http/providers.js +86 -0
- package/dist/gateway/http/routines.cjs +196 -0
- package/dist/gateway/http/routines.d.ts +20 -0
- package/dist/gateway/http/routines.js +159 -0
- package/dist/gateway/http/sessions.cjs +241 -0
- package/dist/gateway/http/sessions.d.ts +2 -0
- package/dist/gateway/http/sessions.js +207 -0
- package/dist/gateway/http/types.cjs +18 -0
- package/dist/gateway/http/types.d.ts +25 -0
- package/dist/gateway/http/types.js +0 -0
- package/dist/gateway/http/voice.cjs +167 -0
- package/dist/gateway/http/voice.d.ts +2 -0
- package/dist/gateway/http/voice.js +133 -0
- package/dist/gateway/http/webhooks.cjs +353 -0
- package/dist/gateway/http/webhooks.d.ts +22 -0
- package/dist/gateway/http/webhooks.js +313 -0
- package/dist/gateway/index.cjs +119 -0
- package/dist/gateway/index.d.ts +8 -0
- package/dist/gateway/index.js +9 -0
- package/dist/gateway/node.cjs +218 -0
- package/dist/gateway/node.d.ts +112 -0
- package/dist/gateway/node.js +184 -0
- package/dist/gateway/router.cjs +85 -0
- package/dist/gateway/router.d.ts +9 -0
- package/dist/gateway/router.js +51 -0
- package/dist/gateway/rpcClient.cjs +152 -0
- package/dist/gateway/rpcClient.d.ts +24 -0
- package/dist/gateway/rpcClient.js +118 -0
- package/dist/gateway/server.cjs +1175 -0
- package/dist/gateway/server.d.ts +185 -0
- package/dist/gateway/server.js +1138 -0
- package/dist/gateway/transport/http.cjs +153 -0
- package/dist/gateway/transport/http.d.ts +25 -0
- package/dist/gateway/transport/http.js +119 -0
- package/dist/gateway/transport/index.cjs +40 -0
- package/dist/gateway/transport/index.d.ts +3 -0
- package/dist/gateway/transport/index.js +3 -0
- package/dist/gateway/transport/types.cjs +18 -0
- package/dist/gateway/transport/types.d.ts +59 -0
- package/dist/gateway/transport/types.js +0 -0
- package/dist/gateway/transport/websocket.cjs +132 -0
- package/dist/gateway/transport/websocket.d.ts +21 -0
- package/dist/gateway/transport/websocket.js +98 -0
- package/dist/gateway/types.cjs +18 -0
- package/dist/gateway/types.d.ts +215 -0
- package/dist/gateway/types.js +0 -0
- package/dist/gateway/validation.cjs +225 -0
- package/dist/gateway/validation.d.ts +157 -0
- package/dist/gateway/validation.js +158 -0
- package/dist/index.cjs +95 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +6 -0
- package/dist/logger.cjs +270 -0
- package/dist/logger.d.ts +54 -0
- package/dist/logger.js +215 -0
- package/dist/providers/copilot.cjs +148 -0
- package/dist/providers/copilot.d.ts +3 -0
- package/dist/providers/copilot.js +114 -0
- package/dist/providers/credentials.cjs +154 -0
- package/dist/providers/credentials.d.ts +26 -0
- package/dist/providers/credentials.js +99 -0
- package/dist/providers/oauth.cjs +279 -0
- package/dist/providers/oauth.d.ts +13 -0
- package/dist/providers/oauth.js +245 -0
- package/dist/providers/registry.cjs +138 -0
- package/dist/providers/registry.d.ts +32 -0
- package/dist/providers/registry.js +98 -0
- package/dist/tests/additionalMessageMiddleware.test.cjs +45 -0
- package/dist/tests/additionalMessageMiddleware.test.d.ts +1 -0
- package/dist/tests/additionalMessageMiddleware.test.js +39 -0
- package/dist/tests/agent-config-voice.test.cjs +25 -0
- package/dist/tests/agent-config-voice.test.d.ts +1 -0
- package/dist/tests/agent-config-voice.test.js +19 -0
- package/dist/tests/agentInvokerAttachments.test.cjs +67 -0
- package/dist/tests/agentInvokerAttachments.test.d.ts +1 -0
- package/dist/tests/agentInvokerAttachments.test.js +61 -0
- package/dist/tests/attachments-utils.test.cjs +46 -0
- package/dist/tests/attachments-utils.test.d.ts +1 -0
- package/dist/tests/attachments-utils.test.js +40 -0
- package/dist/tests/bunSqliteAdapter.test.cjs +265 -0
- package/dist/tests/bunSqliteAdapter.test.d.ts +1 -0
- package/dist/tests/bunSqliteAdapter.test.js +259 -0
- package/dist/tests/candleRange.test.cjs +48 -0
- package/dist/tests/candleRange.test.d.ts +1 -0
- package/dist/tests/candleRange.test.js +42 -0
- package/dist/tests/cli-config-loader.test.cjs +364 -0
- package/dist/tests/cli-config-loader.test.d.ts +1 -0
- package/dist/tests/cli-config-loader.test.js +358 -0
- package/dist/tests/cli-init.test.cjs +82 -0
- package/dist/tests/cli-init.test.d.ts +1 -0
- package/dist/tests/cli-init.test.js +76 -0
- package/dist/tests/discord-adapter.test.cjs +55 -0
- package/dist/tests/discord-adapter.test.d.ts +1 -0
- package/dist/tests/discord-adapter.test.js +49 -0
- package/dist/tests/gateway.test.cjs +319 -0
- package/dist/tests/gateway.test.d.ts +1 -0
- package/dist/tests/gateway.test.js +313 -0
- package/dist/tests/hooks-matcher.test.cjs +309 -0
- package/dist/tests/hooks-matcher.test.d.ts +1 -0
- package/dist/tests/hooks-matcher.test.js +303 -0
- package/dist/tests/hooks-merger.test.cjs +528 -0
- package/dist/tests/hooks-merger.test.d.ts +1 -0
- package/dist/tests/hooks-merger.test.js +522 -0
- package/dist/tests/integration/agent-invocation.integration.test.cjs +264 -0
- package/dist/tests/integration/agent-invocation.integration.test.d.ts +1 -0
- package/dist/tests/integration/agent-invocation.integration.test.js +258 -0
- package/dist/tests/integration/finnhub-candles.integration.test.cjs +98 -0
- package/dist/tests/integration/finnhub-candles.integration.test.d.ts +1 -0
- package/dist/tests/integration/finnhub-candles.integration.test.js +92 -0
- package/dist/tests/logger.test.cjs +353 -0
- package/dist/tests/logger.test.d.ts +1 -0
- package/dist/tests/logger.test.js +347 -0
- package/dist/tests/mediaCompatibilityMiddleware.test.cjs +106 -0
- package/dist/tests/mediaCompatibilityMiddleware.test.d.ts +1 -0
- package/dist/tests/mediaCompatibilityMiddleware.test.js +100 -0
- package/dist/tests/routines-api.test.cjs +107 -0
- package/dist/tests/routines-api.test.d.ts +1 -0
- package/dist/tests/routines-api.test.js +101 -0
- package/dist/tests/sessionMessageAttachments.test.cjs +108 -0
- package/dist/tests/sessionMessageAttachments.test.d.ts +1 -0
- package/dist/tests/sessionMessageAttachments.test.js +102 -0
- package/dist/tests/sessionMessageRole.test.cjs +44 -0
- package/dist/tests/sessionMessageRole.test.d.ts +1 -0
- package/dist/tests/sessionMessageRole.test.js +38 -0
- package/dist/tests/sessionStateMessages.test.cjs +72 -0
- package/dist/tests/sessionStateMessages.test.d.ts +1 -0
- package/dist/tests/sessionStateMessages.test.js +66 -0
- package/dist/tests/sessions-api.test.cjs +68 -0
- package/dist/tests/sessions-api.test.d.ts +1 -0
- package/dist/tests/sessions-api.test.js +62 -0
- package/dist/tests/technicalIndicators.test.cjs +82 -0
- package/dist/tests/technicalIndicators.test.d.ts +1 -0
- package/dist/tests/technicalIndicators.test.js +76 -0
- package/dist/tests/toolDisplayHelpers.test.cjs +43 -0
- package/dist/tests/toolDisplayHelpers.test.d.ts +1 -0
- package/dist/tests/toolDisplayHelpers.test.js +37 -0
- package/dist/tests/voice-config.test.cjs +35 -0
- package/dist/tests/voice-config.test.d.ts +1 -0
- package/dist/tests/voice-config.test.js +29 -0
- package/dist/tests/yahooCandles.test.cjs +111 -0
- package/dist/tests/yahooCandles.test.d.ts +1 -0
- package/dist/tests/yahooCandles.test.js +105 -0
- package/dist/tools/finance/candleRange.cjs +71 -0
- package/dist/tools/finance/candleRange.d.ts +21 -0
- package/dist/tools/finance/candleRange.js +28 -0
- package/dist/tools/finance/optionsAnalytics.cjs +222 -0
- package/dist/tools/finance/optionsAnalytics.d.ts +44 -0
- package/dist/tools/finance/optionsAnalytics.js +188 -0
- package/dist/tools/finance/optionsAnalytics.test.cjs +128 -0
- package/dist/tools/finance/optionsAnalytics.test.d.ts +1 -0
- package/dist/tools/finance/optionsAnalytics.test.js +122 -0
- package/dist/tools/finance/technicalIndicators.cjs +111 -0
- package/dist/tools/finance/technicalIndicators.d.ts +15 -0
- package/dist/tools/finance/technicalIndicators.js +68 -0
- package/dist/tools/finance/yahooCandles.cjs +125 -0
- package/dist/tools/finance/yahooCandles.d.ts +41 -0
- package/dist/tools/finance/yahooCandles.js +85 -0
- package/dist/tools/mcp-finance.cjs +649 -0
- package/dist/tools/mcp-finance.d.ts +1 -0
- package/dist/tools/mcp-finance.js +631 -0
- package/dist/types/agents.cjs +18 -0
- package/dist/types/agents.d.ts +11 -0
- package/dist/types/agents.js +0 -0
- package/dist/types/hooks.cjs +18 -0
- package/dist/types/hooks.d.ts +82 -0
- package/dist/types/hooks.js +0 -0
- package/dist/types/mcp.cjs +86 -0
- package/dist/types/mcp.d.ts +107 -0
- package/dist/types/mcp.js +40 -0
- package/dist/types/voice.cjs +103 -0
- package/dist/types/voice.d.ts +117 -0
- package/dist/types/voice.js +51 -0
- package/dist/utils/attachments.cjs +46 -0
- package/dist/utils/attachments.d.ts +7 -0
- package/dist/utils/attachments.js +12 -0
- package/dist/voice/config.cjs +52 -0
- package/dist/voice/config.d.ts +8 -0
- package/dist/voice/config.js +18 -0
- package/dist/webui/assets/index-BA0HaStz.css +1 -0
- package/dist/webui/assets/index-NHgTZsWN.js +112 -0
- package/dist/webui/assets/wingman_icon-DOy91UEF.webp +0 -0
- package/dist/webui/assets/wingman_logo-Cogyt3qm.webp +0 -0
- package/dist/webui/index.html +19 -0
- package/package.json +130 -0
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
HTTPBridgeTransport: ()=>HTTPBridgeTransport
|
|
28
|
+
});
|
|
29
|
+
const external_logger_cjs_namespaceObject = require("../../logger.cjs");
|
|
30
|
+
function _define_property(obj, key, value) {
|
|
31
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
32
|
+
value: value,
|
|
33
|
+
enumerable: true,
|
|
34
|
+
configurable: true,
|
|
35
|
+
writable: true
|
|
36
|
+
});
|
|
37
|
+
else obj[key] = value;
|
|
38
|
+
return obj;
|
|
39
|
+
}
|
|
40
|
+
const logger = (0, external_logger_cjs_namespaceObject.createLogger)();
|
|
41
|
+
class HTTPBridgeTransport {
|
|
42
|
+
async connect() {
|
|
43
|
+
if (this.connected) throw new Error("Already connected");
|
|
44
|
+
this.connected = true;
|
|
45
|
+
this.startPolling();
|
|
46
|
+
}
|
|
47
|
+
disconnect() {
|
|
48
|
+
this.connected = false;
|
|
49
|
+
this.stopPolling();
|
|
50
|
+
if (this.nodeId) this.send({
|
|
51
|
+
type: "unregister",
|
|
52
|
+
nodeId: this.nodeId,
|
|
53
|
+
timestamp: Date.now()
|
|
54
|
+
}).catch(()=>{});
|
|
55
|
+
this.nodeId = null;
|
|
56
|
+
}
|
|
57
|
+
async send(message) {
|
|
58
|
+
if (!this.connected) throw new Error("Not connected");
|
|
59
|
+
const response = await fetch(`${this.baseUrl}/bridge/send`, {
|
|
60
|
+
method: "POST",
|
|
61
|
+
headers: {
|
|
62
|
+
"Content-Type": "application/json",
|
|
63
|
+
...this.options.token && {
|
|
64
|
+
Authorization: `Bearer ${this.options.token}`
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
body: JSON.stringify(message),
|
|
68
|
+
signal: AbortSignal.timeout(this.options.connectionTimeout || 10000)
|
|
69
|
+
});
|
|
70
|
+
if (!response.ok) throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
71
|
+
if ("register" === message.type) {
|
|
72
|
+
const data = await response.json();
|
|
73
|
+
if ("registered" === data.type && "nodeId" in data) {
|
|
74
|
+
this.nodeId = data.nodeId;
|
|
75
|
+
if (this.messageHandler) this.messageHandler(data);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
onMessage(handler) {
|
|
80
|
+
this.messageHandler = handler;
|
|
81
|
+
}
|
|
82
|
+
isConnected() {
|
|
83
|
+
return this.connected;
|
|
84
|
+
}
|
|
85
|
+
getType() {
|
|
86
|
+
return "http";
|
|
87
|
+
}
|
|
88
|
+
startPolling() {
|
|
89
|
+
if (this.polling) return;
|
|
90
|
+
this.polling = true;
|
|
91
|
+
this.poll();
|
|
92
|
+
}
|
|
93
|
+
stopPolling() {
|
|
94
|
+
this.polling = false;
|
|
95
|
+
if (this.pollAbortController) {
|
|
96
|
+
this.pollAbortController.abort();
|
|
97
|
+
this.pollAbortController = null;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
async poll() {
|
|
101
|
+
while(this.polling && this.connected)try {
|
|
102
|
+
this.pollAbortController = new AbortController();
|
|
103
|
+
const response = await fetch(`${this.baseUrl}/bridge/poll`, {
|
|
104
|
+
method: "GET",
|
|
105
|
+
headers: {
|
|
106
|
+
...this.options.token && {
|
|
107
|
+
Authorization: `Bearer ${this.options.token}`
|
|
108
|
+
},
|
|
109
|
+
...this.nodeId && {
|
|
110
|
+
"X-Node-ID": this.nodeId
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
signal: this.pollAbortController.signal
|
|
114
|
+
});
|
|
115
|
+
if (!response.ok) {
|
|
116
|
+
if (401 === response.status) throw new Error("Authentication failed");
|
|
117
|
+
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
118
|
+
}
|
|
119
|
+
const messages = await response.json();
|
|
120
|
+
if (this.messageHandler && messages.length > 0) for (const message of messages)this.messageHandler(message);
|
|
121
|
+
} catch (error) {
|
|
122
|
+
if (error instanceof Error && "AbortError" === error.name) break;
|
|
123
|
+
logger.error("Polling error", error);
|
|
124
|
+
if (this.polling && this.connected) await new Promise((resolve)=>setTimeout(resolve, this.options.reconnectDelay || 5000));
|
|
125
|
+
}
|
|
126
|
+
this.pollAbortController = null;
|
|
127
|
+
}
|
|
128
|
+
constructor(url, options = {}){
|
|
129
|
+
_define_property(this, "baseUrl", void 0);
|
|
130
|
+
_define_property(this, "options", void 0);
|
|
131
|
+
_define_property(this, "messageHandler", null);
|
|
132
|
+
_define_property(this, "nodeId", null);
|
|
133
|
+
_define_property(this, "connected", false);
|
|
134
|
+
_define_property(this, "polling", false);
|
|
135
|
+
_define_property(this, "pollAbortController", null);
|
|
136
|
+
this.baseUrl = url.replace(/^ws:/, "http:").replace(/^wss:/, "https:");
|
|
137
|
+
this.baseUrl = this.baseUrl.replace(/\/ws$/, "");
|
|
138
|
+
this.options = {
|
|
139
|
+
autoReconnect: true,
|
|
140
|
+
maxReconnectAttempts: 5,
|
|
141
|
+
reconnectDelay: 5000,
|
|
142
|
+
connectionTimeout: 10000,
|
|
143
|
+
...options
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
exports.HTTPBridgeTransport = __webpack_exports__.HTTPBridgeTransport;
|
|
148
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
149
|
+
"HTTPBridgeTransport"
|
|
150
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
151
|
+
Object.defineProperty(exports, '__esModule', {
|
|
152
|
+
value: true
|
|
153
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { GatewayMessage } from "../types.js";
|
|
2
|
+
import type { TransportClient, TransportOptions } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* HTTP bridge transport client
|
|
5
|
+
* Uses long-polling for receiving messages and POST for sending
|
|
6
|
+
*/
|
|
7
|
+
export declare class HTTPBridgeTransport implements TransportClient {
|
|
8
|
+
private baseUrl;
|
|
9
|
+
private options;
|
|
10
|
+
private messageHandler;
|
|
11
|
+
private nodeId;
|
|
12
|
+
private connected;
|
|
13
|
+
private polling;
|
|
14
|
+
private pollAbortController;
|
|
15
|
+
constructor(url: string, options?: TransportOptions);
|
|
16
|
+
connect(): Promise<void>;
|
|
17
|
+
disconnect(): void;
|
|
18
|
+
send(message: GatewayMessage): Promise<void>;
|
|
19
|
+
onMessage(handler: (message: GatewayMessage) => void): void;
|
|
20
|
+
isConnected(): boolean;
|
|
21
|
+
getType(): "http";
|
|
22
|
+
private startPolling;
|
|
23
|
+
private stopPolling;
|
|
24
|
+
private poll;
|
|
25
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { createLogger } from "../../logger.js";
|
|
2
|
+
function _define_property(obj, key, value) {
|
|
3
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
4
|
+
value: value,
|
|
5
|
+
enumerable: true,
|
|
6
|
+
configurable: true,
|
|
7
|
+
writable: true
|
|
8
|
+
});
|
|
9
|
+
else obj[key] = value;
|
|
10
|
+
return obj;
|
|
11
|
+
}
|
|
12
|
+
const logger = createLogger();
|
|
13
|
+
class HTTPBridgeTransport {
|
|
14
|
+
async connect() {
|
|
15
|
+
if (this.connected) throw new Error("Already connected");
|
|
16
|
+
this.connected = true;
|
|
17
|
+
this.startPolling();
|
|
18
|
+
}
|
|
19
|
+
disconnect() {
|
|
20
|
+
this.connected = false;
|
|
21
|
+
this.stopPolling();
|
|
22
|
+
if (this.nodeId) this.send({
|
|
23
|
+
type: "unregister",
|
|
24
|
+
nodeId: this.nodeId,
|
|
25
|
+
timestamp: Date.now()
|
|
26
|
+
}).catch(()=>{});
|
|
27
|
+
this.nodeId = null;
|
|
28
|
+
}
|
|
29
|
+
async send(message) {
|
|
30
|
+
if (!this.connected) throw new Error("Not connected");
|
|
31
|
+
const response = await fetch(`${this.baseUrl}/bridge/send`, {
|
|
32
|
+
method: "POST",
|
|
33
|
+
headers: {
|
|
34
|
+
"Content-Type": "application/json",
|
|
35
|
+
...this.options.token && {
|
|
36
|
+
Authorization: `Bearer ${this.options.token}`
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
body: JSON.stringify(message),
|
|
40
|
+
signal: AbortSignal.timeout(this.options.connectionTimeout || 10000)
|
|
41
|
+
});
|
|
42
|
+
if (!response.ok) throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
43
|
+
if ("register" === message.type) {
|
|
44
|
+
const data = await response.json();
|
|
45
|
+
if ("registered" === data.type && "nodeId" in data) {
|
|
46
|
+
this.nodeId = data.nodeId;
|
|
47
|
+
if (this.messageHandler) this.messageHandler(data);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
onMessage(handler) {
|
|
52
|
+
this.messageHandler = handler;
|
|
53
|
+
}
|
|
54
|
+
isConnected() {
|
|
55
|
+
return this.connected;
|
|
56
|
+
}
|
|
57
|
+
getType() {
|
|
58
|
+
return "http";
|
|
59
|
+
}
|
|
60
|
+
startPolling() {
|
|
61
|
+
if (this.polling) return;
|
|
62
|
+
this.polling = true;
|
|
63
|
+
this.poll();
|
|
64
|
+
}
|
|
65
|
+
stopPolling() {
|
|
66
|
+
this.polling = false;
|
|
67
|
+
if (this.pollAbortController) {
|
|
68
|
+
this.pollAbortController.abort();
|
|
69
|
+
this.pollAbortController = null;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
async poll() {
|
|
73
|
+
while(this.polling && this.connected)try {
|
|
74
|
+
this.pollAbortController = new AbortController();
|
|
75
|
+
const response = await fetch(`${this.baseUrl}/bridge/poll`, {
|
|
76
|
+
method: "GET",
|
|
77
|
+
headers: {
|
|
78
|
+
...this.options.token && {
|
|
79
|
+
Authorization: `Bearer ${this.options.token}`
|
|
80
|
+
},
|
|
81
|
+
...this.nodeId && {
|
|
82
|
+
"X-Node-ID": this.nodeId
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
signal: this.pollAbortController.signal
|
|
86
|
+
});
|
|
87
|
+
if (!response.ok) {
|
|
88
|
+
if (401 === response.status) throw new Error("Authentication failed");
|
|
89
|
+
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
90
|
+
}
|
|
91
|
+
const messages = await response.json();
|
|
92
|
+
if (this.messageHandler && messages.length > 0) for (const message of messages)this.messageHandler(message);
|
|
93
|
+
} catch (error) {
|
|
94
|
+
if (error instanceof Error && "AbortError" === error.name) break;
|
|
95
|
+
logger.error("Polling error", error);
|
|
96
|
+
if (this.polling && this.connected) await new Promise((resolve)=>setTimeout(resolve, this.options.reconnectDelay || 5000));
|
|
97
|
+
}
|
|
98
|
+
this.pollAbortController = null;
|
|
99
|
+
}
|
|
100
|
+
constructor(url, options = {}){
|
|
101
|
+
_define_property(this, "baseUrl", void 0);
|
|
102
|
+
_define_property(this, "options", void 0);
|
|
103
|
+
_define_property(this, "messageHandler", null);
|
|
104
|
+
_define_property(this, "nodeId", null);
|
|
105
|
+
_define_property(this, "connected", false);
|
|
106
|
+
_define_property(this, "polling", false);
|
|
107
|
+
_define_property(this, "pollAbortController", null);
|
|
108
|
+
this.baseUrl = url.replace(/^ws:/, "http:").replace(/^wss:/, "https:");
|
|
109
|
+
this.baseUrl = this.baseUrl.replace(/\/ws$/, "");
|
|
110
|
+
this.options = {
|
|
111
|
+
autoReconnect: true,
|
|
112
|
+
maxReconnectAttempts: 5,
|
|
113
|
+
reconnectDelay: 5000,
|
|
114
|
+
connectionTimeout: 10000,
|
|
115
|
+
...options
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
export { HTTPBridgeTransport };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
WebSocketTransport: ()=>external_websocket_cjs_namespaceObject.WebSocketTransport,
|
|
28
|
+
HTTPBridgeTransport: ()=>external_http_cjs_namespaceObject.HTTPBridgeTransport
|
|
29
|
+
});
|
|
30
|
+
const external_websocket_cjs_namespaceObject = require("./websocket.cjs");
|
|
31
|
+
const external_http_cjs_namespaceObject = require("./http.cjs");
|
|
32
|
+
exports.HTTPBridgeTransport = __webpack_exports__.HTTPBridgeTransport;
|
|
33
|
+
exports.WebSocketTransport = __webpack_exports__.WebSocketTransport;
|
|
34
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
35
|
+
"HTTPBridgeTransport",
|
|
36
|
+
"WebSocketTransport"
|
|
37
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
38
|
+
Object.defineProperty(exports, '__esModule', {
|
|
39
|
+
value: true
|
|
40
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.r = (exports1)=>{
|
|
5
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
6
|
+
value: 'Module'
|
|
7
|
+
});
|
|
8
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
9
|
+
value: true
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
})();
|
|
13
|
+
var __webpack_exports__ = {};
|
|
14
|
+
__webpack_require__.r(__webpack_exports__);
|
|
15
|
+
for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
16
|
+
Object.defineProperty(exports, '__esModule', {
|
|
17
|
+
value: true
|
|
18
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { GatewayMessage } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Transport types
|
|
4
|
+
*/
|
|
5
|
+
export type TransportType = "websocket" | "http";
|
|
6
|
+
/**
|
|
7
|
+
* Transport client interface
|
|
8
|
+
*/
|
|
9
|
+
export interface TransportClient {
|
|
10
|
+
/**
|
|
11
|
+
* Connect to the gateway
|
|
12
|
+
*/
|
|
13
|
+
connect(): Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* Disconnect from the gateway
|
|
16
|
+
*/
|
|
17
|
+
disconnect(): void;
|
|
18
|
+
/**
|
|
19
|
+
* Send a message to the gateway
|
|
20
|
+
*/
|
|
21
|
+
send(message: GatewayMessage): void;
|
|
22
|
+
/**
|
|
23
|
+
* Register message handler
|
|
24
|
+
*/
|
|
25
|
+
onMessage(handler: (message: GatewayMessage) => void): void;
|
|
26
|
+
/**
|
|
27
|
+
* Check if connected
|
|
28
|
+
*/
|
|
29
|
+
isConnected(): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Get transport type
|
|
32
|
+
*/
|
|
33
|
+
getType(): TransportType;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Transport client options
|
|
37
|
+
*/
|
|
38
|
+
export interface TransportOptions {
|
|
39
|
+
/**
|
|
40
|
+
* Authentication token
|
|
41
|
+
*/
|
|
42
|
+
token?: string;
|
|
43
|
+
/**
|
|
44
|
+
* Reconnect automatically on disconnect
|
|
45
|
+
*/
|
|
46
|
+
autoReconnect?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Maximum reconnection attempts
|
|
49
|
+
*/
|
|
50
|
+
maxReconnectAttempts?: number;
|
|
51
|
+
/**
|
|
52
|
+
* Reconnect delay in ms
|
|
53
|
+
*/
|
|
54
|
+
reconnectDelay?: number;
|
|
55
|
+
/**
|
|
56
|
+
* Connection timeout in ms
|
|
57
|
+
*/
|
|
58
|
+
connectionTimeout?: number;
|
|
59
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
WebSocketTransport: ()=>WebSocketTransport
|
|
28
|
+
});
|
|
29
|
+
const external_logger_cjs_namespaceObject = require("../../logger.cjs");
|
|
30
|
+
function _define_property(obj, key, value) {
|
|
31
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
32
|
+
value: value,
|
|
33
|
+
enumerable: true,
|
|
34
|
+
configurable: true,
|
|
35
|
+
writable: true
|
|
36
|
+
});
|
|
37
|
+
else obj[key] = value;
|
|
38
|
+
return obj;
|
|
39
|
+
}
|
|
40
|
+
const logger = (0, external_logger_cjs_namespaceObject.createLogger)();
|
|
41
|
+
class WebSocketTransport {
|
|
42
|
+
async connect() {
|
|
43
|
+
return new Promise((resolve, reject)=>{
|
|
44
|
+
const timeout = setTimeout(()=>{
|
|
45
|
+
if (this.ws) this.ws.close();
|
|
46
|
+
reject(new Error("Connection timeout"));
|
|
47
|
+
}, this.options.connectionTimeout);
|
|
48
|
+
try {
|
|
49
|
+
this.ws = new WebSocket(this.url);
|
|
50
|
+
this.ws.onopen = ()=>{
|
|
51
|
+
clearTimeout(timeout);
|
|
52
|
+
this.reconnectAttempts = 0;
|
|
53
|
+
resolve();
|
|
54
|
+
};
|
|
55
|
+
this.ws.onmessage = (event)=>{
|
|
56
|
+
try {
|
|
57
|
+
const message = JSON.parse(event.data);
|
|
58
|
+
if (this.messageHandler) this.messageHandler(message);
|
|
59
|
+
} catch (error) {
|
|
60
|
+
logger.error("Failed to parse message", error);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
this.ws.onerror = (error)=>{
|
|
64
|
+
clearTimeout(timeout);
|
|
65
|
+
reject(error);
|
|
66
|
+
};
|
|
67
|
+
this.ws.onclose = ()=>{
|
|
68
|
+
this.ws = null;
|
|
69
|
+
if (this.options.autoReconnect && this.reconnectAttempts < (this.options.maxReconnectAttempts || 5)) this.scheduleReconnect();
|
|
70
|
+
};
|
|
71
|
+
} catch (error) {
|
|
72
|
+
clearTimeout(timeout);
|
|
73
|
+
reject(error);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
disconnect() {
|
|
78
|
+
this.options.autoReconnect = false;
|
|
79
|
+
if (this.reconnectTimer) {
|
|
80
|
+
clearTimeout(this.reconnectTimer);
|
|
81
|
+
this.reconnectTimer = null;
|
|
82
|
+
}
|
|
83
|
+
if (this.ws) {
|
|
84
|
+
this.ws.close();
|
|
85
|
+
this.ws = null;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
send(message) {
|
|
89
|
+
if (!this.ws || this.ws.readyState !== WebSocket.OPEN) throw new Error("WebSocket not connected");
|
|
90
|
+
this.ws.send(JSON.stringify(message));
|
|
91
|
+
}
|
|
92
|
+
onMessage(handler) {
|
|
93
|
+
this.messageHandler = handler;
|
|
94
|
+
}
|
|
95
|
+
isConnected() {
|
|
96
|
+
return null !== this.ws && this.ws.readyState === WebSocket.OPEN;
|
|
97
|
+
}
|
|
98
|
+
getType() {
|
|
99
|
+
return "websocket";
|
|
100
|
+
}
|
|
101
|
+
scheduleReconnect() {
|
|
102
|
+
this.reconnectAttempts++;
|
|
103
|
+
this.reconnectTimer = setTimeout(()=>{
|
|
104
|
+
this.connect().catch((error)=>{
|
|
105
|
+
logger.error("Reconnect failed", error);
|
|
106
|
+
});
|
|
107
|
+
}, this.options.reconnectDelay);
|
|
108
|
+
}
|
|
109
|
+
constructor(url, options = {}){
|
|
110
|
+
_define_property(this, "ws", null);
|
|
111
|
+
_define_property(this, "url", void 0);
|
|
112
|
+
_define_property(this, "options", void 0);
|
|
113
|
+
_define_property(this, "messageHandler", null);
|
|
114
|
+
_define_property(this, "reconnectAttempts", 0);
|
|
115
|
+
_define_property(this, "reconnectTimer", null);
|
|
116
|
+
this.url = url;
|
|
117
|
+
this.options = {
|
|
118
|
+
autoReconnect: true,
|
|
119
|
+
maxReconnectAttempts: 5,
|
|
120
|
+
reconnectDelay: 5000,
|
|
121
|
+
connectionTimeout: 10000,
|
|
122
|
+
...options
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
exports.WebSocketTransport = __webpack_exports__.WebSocketTransport;
|
|
127
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
128
|
+
"WebSocketTransport"
|
|
129
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
130
|
+
Object.defineProperty(exports, '__esModule', {
|
|
131
|
+
value: true
|
|
132
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { GatewayMessage } from "../types.js";
|
|
2
|
+
import type { TransportClient, TransportOptions } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* WebSocket transport client
|
|
5
|
+
*/
|
|
6
|
+
export declare class WebSocketTransport implements TransportClient {
|
|
7
|
+
private ws;
|
|
8
|
+
private url;
|
|
9
|
+
private options;
|
|
10
|
+
private messageHandler;
|
|
11
|
+
private reconnectAttempts;
|
|
12
|
+
private reconnectTimer;
|
|
13
|
+
constructor(url: string, options?: TransportOptions);
|
|
14
|
+
connect(): Promise<void>;
|
|
15
|
+
disconnect(): void;
|
|
16
|
+
send(message: GatewayMessage): void;
|
|
17
|
+
onMessage(handler: (message: GatewayMessage) => void): void;
|
|
18
|
+
isConnected(): boolean;
|
|
19
|
+
getType(): "websocket";
|
|
20
|
+
private scheduleReconnect;
|
|
21
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { createLogger } from "../../logger.js";
|
|
2
|
+
function _define_property(obj, key, value) {
|
|
3
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
4
|
+
value: value,
|
|
5
|
+
enumerable: true,
|
|
6
|
+
configurable: true,
|
|
7
|
+
writable: true
|
|
8
|
+
});
|
|
9
|
+
else obj[key] = value;
|
|
10
|
+
return obj;
|
|
11
|
+
}
|
|
12
|
+
const logger = createLogger();
|
|
13
|
+
class WebSocketTransport {
|
|
14
|
+
async connect() {
|
|
15
|
+
return new Promise((resolve, reject)=>{
|
|
16
|
+
const timeout = setTimeout(()=>{
|
|
17
|
+
if (this.ws) this.ws.close();
|
|
18
|
+
reject(new Error("Connection timeout"));
|
|
19
|
+
}, this.options.connectionTimeout);
|
|
20
|
+
try {
|
|
21
|
+
this.ws = new WebSocket(this.url);
|
|
22
|
+
this.ws.onopen = ()=>{
|
|
23
|
+
clearTimeout(timeout);
|
|
24
|
+
this.reconnectAttempts = 0;
|
|
25
|
+
resolve();
|
|
26
|
+
};
|
|
27
|
+
this.ws.onmessage = (event)=>{
|
|
28
|
+
try {
|
|
29
|
+
const message = JSON.parse(event.data);
|
|
30
|
+
if (this.messageHandler) this.messageHandler(message);
|
|
31
|
+
} catch (error) {
|
|
32
|
+
logger.error("Failed to parse message", error);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
this.ws.onerror = (error)=>{
|
|
36
|
+
clearTimeout(timeout);
|
|
37
|
+
reject(error);
|
|
38
|
+
};
|
|
39
|
+
this.ws.onclose = ()=>{
|
|
40
|
+
this.ws = null;
|
|
41
|
+
if (this.options.autoReconnect && this.reconnectAttempts < (this.options.maxReconnectAttempts || 5)) this.scheduleReconnect();
|
|
42
|
+
};
|
|
43
|
+
} catch (error) {
|
|
44
|
+
clearTimeout(timeout);
|
|
45
|
+
reject(error);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
disconnect() {
|
|
50
|
+
this.options.autoReconnect = false;
|
|
51
|
+
if (this.reconnectTimer) {
|
|
52
|
+
clearTimeout(this.reconnectTimer);
|
|
53
|
+
this.reconnectTimer = null;
|
|
54
|
+
}
|
|
55
|
+
if (this.ws) {
|
|
56
|
+
this.ws.close();
|
|
57
|
+
this.ws = null;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
send(message) {
|
|
61
|
+
if (!this.ws || this.ws.readyState !== WebSocket.OPEN) throw new Error("WebSocket not connected");
|
|
62
|
+
this.ws.send(JSON.stringify(message));
|
|
63
|
+
}
|
|
64
|
+
onMessage(handler) {
|
|
65
|
+
this.messageHandler = handler;
|
|
66
|
+
}
|
|
67
|
+
isConnected() {
|
|
68
|
+
return null !== this.ws && this.ws.readyState === WebSocket.OPEN;
|
|
69
|
+
}
|
|
70
|
+
getType() {
|
|
71
|
+
return "websocket";
|
|
72
|
+
}
|
|
73
|
+
scheduleReconnect() {
|
|
74
|
+
this.reconnectAttempts++;
|
|
75
|
+
this.reconnectTimer = setTimeout(()=>{
|
|
76
|
+
this.connect().catch((error)=>{
|
|
77
|
+
logger.error("Reconnect failed", error);
|
|
78
|
+
});
|
|
79
|
+
}, this.options.reconnectDelay);
|
|
80
|
+
}
|
|
81
|
+
constructor(url, options = {}){
|
|
82
|
+
_define_property(this, "ws", null);
|
|
83
|
+
_define_property(this, "url", void 0);
|
|
84
|
+
_define_property(this, "options", void 0);
|
|
85
|
+
_define_property(this, "messageHandler", null);
|
|
86
|
+
_define_property(this, "reconnectAttempts", 0);
|
|
87
|
+
_define_property(this, "reconnectTimer", null);
|
|
88
|
+
this.url = url;
|
|
89
|
+
this.options = {
|
|
90
|
+
autoReconnect: true,
|
|
91
|
+
maxReconnectAttempts: 5,
|
|
92
|
+
reconnectDelay: 5000,
|
|
93
|
+
connectionTimeout: 10000,
|
|
94
|
+
...options
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
export { WebSocketTransport };
|