@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,106 @@
|
|
|
1
|
+
import { exec } from "child_process";
|
|
2
|
+
import { promisify } from "util";
|
|
3
|
+
import { createLogger } from "../../logger.js";
|
|
4
|
+
function _define_property(obj, key, value) {
|
|
5
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
6
|
+
value: value,
|
|
7
|
+
enumerable: true,
|
|
8
|
+
configurable: true,
|
|
9
|
+
writable: true
|
|
10
|
+
});
|
|
11
|
+
else obj[key] = value;
|
|
12
|
+
return obj;
|
|
13
|
+
}
|
|
14
|
+
const execAsync = promisify(exec);
|
|
15
|
+
const logger = createLogger();
|
|
16
|
+
class TailscaleDiscoveryService {
|
|
17
|
+
async announce(config) {
|
|
18
|
+
this.isAnnouncing = true;
|
|
19
|
+
this.config = config;
|
|
20
|
+
}
|
|
21
|
+
async stopAnnouncing() {
|
|
22
|
+
this.isAnnouncing = false;
|
|
23
|
+
this.config = null;
|
|
24
|
+
}
|
|
25
|
+
async discover(timeout = 5000) {
|
|
26
|
+
try {
|
|
27
|
+
const devices = await this.getTailscaleDevices();
|
|
28
|
+
const gateways = [];
|
|
29
|
+
for (const device of devices){
|
|
30
|
+
if (!device.online) continue;
|
|
31
|
+
const isGateway = device.tags?.some((tag)=>tag.toLowerCase().includes("wingman-gateway")) || device.hostname.toLowerCase().includes("gateway");
|
|
32
|
+
if (!isGateway) continue;
|
|
33
|
+
const gatewayInfo = await this.probeGateway(device.ip, 3000);
|
|
34
|
+
if (gatewayInfo) gateways.push(gatewayInfo);
|
|
35
|
+
}
|
|
36
|
+
return gateways;
|
|
37
|
+
} catch (error) {
|
|
38
|
+
logger.error("Tailscale discovery failed", error);
|
|
39
|
+
return [];
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
async getTailscaleDevices() {
|
|
43
|
+
try {
|
|
44
|
+
const { stdout } = await execAsync("tailscale status --json");
|
|
45
|
+
const status = JSON.parse(stdout);
|
|
46
|
+
const devices = [];
|
|
47
|
+
if (status.Peer) for (const [id, peerData] of Object.entries(status.Peer)){
|
|
48
|
+
const peer = peerData;
|
|
49
|
+
devices.push({
|
|
50
|
+
id,
|
|
51
|
+
hostname: peer.HostName || peer.DNSName?.split(".")[0] || id,
|
|
52
|
+
ip: peer.TailscaleIPs?.[0] || peer.Addrs?.[0]?.split(":")[0] || "",
|
|
53
|
+
online: peer.Online ?? false,
|
|
54
|
+
tags: peer.Tags || []
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
return devices;
|
|
58
|
+
} catch (error) {
|
|
59
|
+
logger.error("Failed to get Tailscale devices", error);
|
|
60
|
+
return [];
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
async probeGateway(ip, port) {
|
|
64
|
+
try {
|
|
65
|
+
const response = await fetch(`http://${ip}:${port}/health`, {
|
|
66
|
+
signal: AbortSignal.timeout(2000)
|
|
67
|
+
});
|
|
68
|
+
if (!response.ok) return null;
|
|
69
|
+
const health = await response.json();
|
|
70
|
+
if ("wingman-gateway" !== health.service) return null;
|
|
71
|
+
let capabilities = [
|
|
72
|
+
"broadcast",
|
|
73
|
+
"direct",
|
|
74
|
+
"groups"
|
|
75
|
+
];
|
|
76
|
+
let version = "1.0.0";
|
|
77
|
+
try {
|
|
78
|
+
const statsResponse = await fetch(`http://${ip}:${port}/stats`, {
|
|
79
|
+
signal: AbortSignal.timeout(2000)
|
|
80
|
+
});
|
|
81
|
+
if (statsResponse.ok) {
|
|
82
|
+
const stats = await statsResponse.json();
|
|
83
|
+
if (stats.capabilities) capabilities = stats.capabilities;
|
|
84
|
+
if (stats.version) version = stats.version;
|
|
85
|
+
}
|
|
86
|
+
} catch {}
|
|
87
|
+
return {
|
|
88
|
+
name: health.name || `Gateway-${ip}`,
|
|
89
|
+
url: `ws://${ip}:${port}/ws`,
|
|
90
|
+
host: ip,
|
|
91
|
+
port,
|
|
92
|
+
requireAuth: health.requireAuth ?? false,
|
|
93
|
+
capabilities,
|
|
94
|
+
version,
|
|
95
|
+
transport: "ws"
|
|
96
|
+
};
|
|
97
|
+
} catch (error) {
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
constructor(){
|
|
102
|
+
_define_property(this, "isAnnouncing", false);
|
|
103
|
+
_define_property(this, "config", null);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
export { TailscaleDiscoveryService };
|
|
@@ -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,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Discovered gateway information
|
|
3
|
+
*/
|
|
4
|
+
export interface DiscoveredGateway {
|
|
5
|
+
name: string;
|
|
6
|
+
url: string;
|
|
7
|
+
host: string;
|
|
8
|
+
port: number;
|
|
9
|
+
requireAuth: boolean;
|
|
10
|
+
capabilities: string[];
|
|
11
|
+
version: string;
|
|
12
|
+
transport: "ws" | "wss";
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Discovery service interface
|
|
16
|
+
*/
|
|
17
|
+
export interface DiscoveryService {
|
|
18
|
+
/**
|
|
19
|
+
* Start announcing this gateway
|
|
20
|
+
*/
|
|
21
|
+
announce(config: DiscoveryConfig): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Stop announcing this gateway
|
|
24
|
+
*/
|
|
25
|
+
stopAnnouncing(): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* Discover available gateways
|
|
28
|
+
*/
|
|
29
|
+
discover(timeout?: number): Promise<DiscoveredGateway[]>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Discovery configuration
|
|
33
|
+
*/
|
|
34
|
+
export interface DiscoveryConfig {
|
|
35
|
+
name: string;
|
|
36
|
+
port: number;
|
|
37
|
+
requireAuth: boolean;
|
|
38
|
+
capabilities: string[];
|
|
39
|
+
version: string;
|
|
40
|
+
transport: "ws" | "wss";
|
|
41
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,45 @@
|
|
|
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
|
+
GATEWAY_TOKEN_ENV: ()=>GATEWAY_TOKEN_ENV,
|
|
28
|
+
getGatewayTokenFromEnv: ()=>getGatewayTokenFromEnv
|
|
29
|
+
});
|
|
30
|
+
const GATEWAY_TOKEN_ENV = "WINGMAN_GATEWAY_TOKEN";
|
|
31
|
+
function getGatewayTokenFromEnv() {
|
|
32
|
+
const raw = process.env[GATEWAY_TOKEN_ENV];
|
|
33
|
+
if (!raw) return;
|
|
34
|
+
const token = raw.trim();
|
|
35
|
+
return token.length > 0 ? token : void 0;
|
|
36
|
+
}
|
|
37
|
+
exports.GATEWAY_TOKEN_ENV = __webpack_exports__.GATEWAY_TOKEN_ENV;
|
|
38
|
+
exports.getGatewayTokenFromEnv = __webpack_exports__.getGatewayTokenFromEnv;
|
|
39
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
40
|
+
"GATEWAY_TOKEN_ENV",
|
|
41
|
+
"getGatewayTokenFromEnv"
|
|
42
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
43
|
+
Object.defineProperty(exports, '__esModule', {
|
|
44
|
+
value: true
|
|
45
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const GATEWAY_TOKEN_ENV = "WINGMAN_GATEWAY_TOKEN";
|
|
2
|
+
function getGatewayTokenFromEnv() {
|
|
3
|
+
const raw = process.env[GATEWAY_TOKEN_ENV];
|
|
4
|
+
if (!raw) return;
|
|
5
|
+
const token = raw.trim();
|
|
6
|
+
return token.length > 0 ? token : void 0;
|
|
7
|
+
}
|
|
8
|
+
export { GATEWAY_TOKEN_ENV, getGatewayTokenFromEnv };
|
|
@@ -0,0 +1,137 @@
|
|
|
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
|
+
InternalHookLoader: ()=>InternalHookLoader
|
|
28
|
+
});
|
|
29
|
+
const external_node_fs_namespaceObject = require("node:fs");
|
|
30
|
+
const external_node_path_namespaceObject = require("node:path");
|
|
31
|
+
const external_node_url_namespaceObject = require("node:url");
|
|
32
|
+
const external_js_yaml_namespaceObject = require("js-yaml");
|
|
33
|
+
function _define_property(obj, key, value) {
|
|
34
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
35
|
+
value: value,
|
|
36
|
+
enumerable: true,
|
|
37
|
+
configurable: true,
|
|
38
|
+
writable: true
|
|
39
|
+
});
|
|
40
|
+
else obj[key] = value;
|
|
41
|
+
return obj;
|
|
42
|
+
}
|
|
43
|
+
const parseFrontmatter = (content)=>{
|
|
44
|
+
const frontmatterRegex = /^---\s*\n([\s\S]*?)\n---\s*\n?([\s\S]*)$/;
|
|
45
|
+
const match = content.match(frontmatterRegex);
|
|
46
|
+
if (!match) throw new Error("Invalid HOOK.md format: missing frontmatter");
|
|
47
|
+
const [, frontmatter] = match;
|
|
48
|
+
const meta = external_js_yaml_namespaceObject.load(frontmatter) || {};
|
|
49
|
+
return {
|
|
50
|
+
meta
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
const resolveHandlerPath = (dir)=>{
|
|
54
|
+
const candidates = [
|
|
55
|
+
"handler.ts",
|
|
56
|
+
"handler.js",
|
|
57
|
+
"index.ts",
|
|
58
|
+
"index.js"
|
|
59
|
+
];
|
|
60
|
+
for (const candidate of candidates){
|
|
61
|
+
const path = (0, external_node_path_namespaceObject.join)(dir, candidate);
|
|
62
|
+
if ((0, external_node_fs_namespaceObject.existsSync)(path)) return path;
|
|
63
|
+
}
|
|
64
|
+
return null;
|
|
65
|
+
};
|
|
66
|
+
class InternalHookLoader {
|
|
67
|
+
async load() {
|
|
68
|
+
if (!this.config?.enabled) return [];
|
|
69
|
+
const entries = this.config.entries || {};
|
|
70
|
+
const enabledEntries = Object.entries(entries).filter(([, entry])=>entry?.enabled !== false);
|
|
71
|
+
const enabledNames = new Set(enabledEntries.map(([name])=>name));
|
|
72
|
+
const dirs = [
|
|
73
|
+
(0, external_node_path_namespaceObject.join)(this.baseDir, "hooks"),
|
|
74
|
+
...this.config.load?.extraDirs || []
|
|
75
|
+
];
|
|
76
|
+
const hooks = [];
|
|
77
|
+
for (const dir of dirs){
|
|
78
|
+
if (!(0, external_node_fs_namespaceObject.existsSync)(dir) || !(0, external_node_fs_namespaceObject.statSync)(dir).isDirectory()) continue;
|
|
79
|
+
const hookDirs = (0, external_node_fs_namespaceObject.readdirSync)(dir, {
|
|
80
|
+
withFileTypes: true
|
|
81
|
+
}).filter((entry)=>entry.isDirectory()).map((entry)=>entry.name);
|
|
82
|
+
for (const hookDirName of hookDirs){
|
|
83
|
+
const hookDir = (0, external_node_path_namespaceObject.join)(dir, hookDirName);
|
|
84
|
+
const hookDoc = (0, external_node_path_namespaceObject.join)(hookDir, "HOOK.md");
|
|
85
|
+
if ((0, external_node_fs_namespaceObject.existsSync)(hookDoc)) try {
|
|
86
|
+
const hookDocContent = await Bun.file(hookDoc).text();
|
|
87
|
+
const { meta } = parseFrontmatter(hookDocContent);
|
|
88
|
+
const name = meta.name || hookDirName;
|
|
89
|
+
if (!enabledNames.has(name)) continue;
|
|
90
|
+
const handlerPath = resolveHandlerPath(hookDir);
|
|
91
|
+
if (!handlerPath) {
|
|
92
|
+
this.logger.warn(`Hook ${name} missing handler file`);
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
const mod = await import((0, external_node_url_namespaceObject.pathToFileURL)(handlerPath).href);
|
|
96
|
+
const exportName = meta.export || "default";
|
|
97
|
+
const handler = mod[exportName];
|
|
98
|
+
if (!handler) {
|
|
99
|
+
this.logger.warn(`Hook ${name} missing export: ${exportName}`);
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
const events = Array.isArray(meta.events) ? meta.events : [];
|
|
103
|
+
if (0 === events.length) {
|
|
104
|
+
this.logger.warn(`Hook ${name} missing events`);
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
const entry = entries[name];
|
|
108
|
+
hooks.push({
|
|
109
|
+
name,
|
|
110
|
+
description: meta.description,
|
|
111
|
+
events,
|
|
112
|
+
handler,
|
|
113
|
+
entry
|
|
114
|
+
});
|
|
115
|
+
} catch (error) {
|
|
116
|
+
this.logger.error(`Failed to load hook from ${hookDir}: ${error}`);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return hooks;
|
|
121
|
+
}
|
|
122
|
+
constructor(baseDir, config, logger){
|
|
123
|
+
_define_property(this, "baseDir", void 0);
|
|
124
|
+
_define_property(this, "config", void 0);
|
|
125
|
+
_define_property(this, "logger", void 0);
|
|
126
|
+
this.baseDir = baseDir;
|
|
127
|
+
this.config = config;
|
|
128
|
+
this.logger = logger;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
exports.InternalHookLoader = __webpack_exports__.InternalHookLoader;
|
|
132
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
133
|
+
"InternalHookLoader"
|
|
134
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
135
|
+
Object.defineProperty(exports, '__esModule', {
|
|
136
|
+
value: true
|
|
137
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { HookDefinition } from "./types.js";
|
|
2
|
+
import type { InternalHooksConfig } from "./types.js";
|
|
3
|
+
import type { Logger } from "@/logger.js";
|
|
4
|
+
export declare class InternalHookLoader {
|
|
5
|
+
private baseDir;
|
|
6
|
+
private config;
|
|
7
|
+
private logger;
|
|
8
|
+
constructor(baseDir: string, config: InternalHooksConfig | undefined, logger: Logger);
|
|
9
|
+
load(): Promise<HookDefinition[]>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { existsSync, readdirSync, statSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { pathToFileURL } from "node:url";
|
|
4
|
+
import { load } from "js-yaml";
|
|
5
|
+
function _define_property(obj, key, value) {
|
|
6
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
7
|
+
value: value,
|
|
8
|
+
enumerable: true,
|
|
9
|
+
configurable: true,
|
|
10
|
+
writable: true
|
|
11
|
+
});
|
|
12
|
+
else obj[key] = value;
|
|
13
|
+
return obj;
|
|
14
|
+
}
|
|
15
|
+
const parseFrontmatter = (content)=>{
|
|
16
|
+
const frontmatterRegex = /^---\s*\n([\s\S]*?)\n---\s*\n?([\s\S]*)$/;
|
|
17
|
+
const match = content.match(frontmatterRegex);
|
|
18
|
+
if (!match) throw new Error("Invalid HOOK.md format: missing frontmatter");
|
|
19
|
+
const [, frontmatter] = match;
|
|
20
|
+
const meta = load(frontmatter) || {};
|
|
21
|
+
return {
|
|
22
|
+
meta
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
const resolveHandlerPath = (dir)=>{
|
|
26
|
+
const candidates = [
|
|
27
|
+
"handler.ts",
|
|
28
|
+
"handler.js",
|
|
29
|
+
"index.ts",
|
|
30
|
+
"index.js"
|
|
31
|
+
];
|
|
32
|
+
for (const candidate of candidates){
|
|
33
|
+
const path = join(dir, candidate);
|
|
34
|
+
if (existsSync(path)) return path;
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
};
|
|
38
|
+
class InternalHookLoader {
|
|
39
|
+
async load() {
|
|
40
|
+
if (!this.config?.enabled) return [];
|
|
41
|
+
const entries = this.config.entries || {};
|
|
42
|
+
const enabledEntries = Object.entries(entries).filter(([, entry])=>entry?.enabled !== false);
|
|
43
|
+
const enabledNames = new Set(enabledEntries.map(([name])=>name));
|
|
44
|
+
const dirs = [
|
|
45
|
+
join(this.baseDir, "hooks"),
|
|
46
|
+
...this.config.load?.extraDirs || []
|
|
47
|
+
];
|
|
48
|
+
const hooks = [];
|
|
49
|
+
for (const dir of dirs){
|
|
50
|
+
if (!existsSync(dir) || !statSync(dir).isDirectory()) continue;
|
|
51
|
+
const hookDirs = readdirSync(dir, {
|
|
52
|
+
withFileTypes: true
|
|
53
|
+
}).filter((entry)=>entry.isDirectory()).map((entry)=>entry.name);
|
|
54
|
+
for (const hookDirName of hookDirs){
|
|
55
|
+
const hookDir = join(dir, hookDirName);
|
|
56
|
+
const hookDoc = join(hookDir, "HOOK.md");
|
|
57
|
+
if (existsSync(hookDoc)) try {
|
|
58
|
+
const hookDocContent = await Bun.file(hookDoc).text();
|
|
59
|
+
const { meta } = parseFrontmatter(hookDocContent);
|
|
60
|
+
const name = meta.name || hookDirName;
|
|
61
|
+
if (!enabledNames.has(name)) continue;
|
|
62
|
+
const handlerPath = resolveHandlerPath(hookDir);
|
|
63
|
+
if (!handlerPath) {
|
|
64
|
+
this.logger.warn(`Hook ${name} missing handler file`);
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
const mod = await import(pathToFileURL(handlerPath).href);
|
|
68
|
+
const exportName = meta.export || "default";
|
|
69
|
+
const handler = mod[exportName];
|
|
70
|
+
if (!handler) {
|
|
71
|
+
this.logger.warn(`Hook ${name} missing export: ${exportName}`);
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
const events = Array.isArray(meta.events) ? meta.events : [];
|
|
75
|
+
if (0 === events.length) {
|
|
76
|
+
this.logger.warn(`Hook ${name} missing events`);
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
const entry = entries[name];
|
|
80
|
+
hooks.push({
|
|
81
|
+
name,
|
|
82
|
+
description: meta.description,
|
|
83
|
+
events,
|
|
84
|
+
handler,
|
|
85
|
+
entry
|
|
86
|
+
});
|
|
87
|
+
} catch (error) {
|
|
88
|
+
this.logger.error(`Failed to load hook from ${hookDir}: ${error}`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return hooks;
|
|
93
|
+
}
|
|
94
|
+
constructor(baseDir, config, logger){
|
|
95
|
+
_define_property(this, "baseDir", void 0);
|
|
96
|
+
_define_property(this, "config", void 0);
|
|
97
|
+
_define_property(this, "logger", void 0);
|
|
98
|
+
this.baseDir = baseDir;
|
|
99
|
+
this.config = config;
|
|
100
|
+
this.logger = logger;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
export { InternalHookLoader };
|
|
@@ -0,0 +1,128 @@
|
|
|
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
|
+
InternalHookRegistry: ()=>InternalHookRegistry
|
|
28
|
+
});
|
|
29
|
+
const external_loader_cjs_namespaceObject = require("./loader.cjs");
|
|
30
|
+
const agentInvoker_cjs_namespaceObject = require("../../cli/core/agentInvoker.cjs");
|
|
31
|
+
const outputManager_cjs_namespaceObject = require("../../cli/core/outputManager.cjs");
|
|
32
|
+
function _define_property(obj, key, value) {
|
|
33
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
34
|
+
value: value,
|
|
35
|
+
enumerable: true,
|
|
36
|
+
configurable: true,
|
|
37
|
+
writable: true
|
|
38
|
+
});
|
|
39
|
+
else obj[key] = value;
|
|
40
|
+
return obj;
|
|
41
|
+
}
|
|
42
|
+
class InternalHookRegistry {
|
|
43
|
+
async load() {
|
|
44
|
+
if (!this.config?.enabled) return;
|
|
45
|
+
const loader = new external_loader_cjs_namespaceObject.InternalHookLoader(this.ctx.resolveConfigDirPath(), this.config, this.ctx.logger);
|
|
46
|
+
this.hooks = await loader.load();
|
|
47
|
+
this.eventMap.clear();
|
|
48
|
+
for (const hook of this.hooks)for (const eventName of hook.events){
|
|
49
|
+
const list = this.eventMap.get(eventName) || [];
|
|
50
|
+
list.push(hook);
|
|
51
|
+
this.eventMap.set(eventName, list);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
emit(event) {
|
|
55
|
+
if (!this.config?.enabled) return;
|
|
56
|
+
const key = `${event.type}:${event.action}`;
|
|
57
|
+
const hooks = [
|
|
58
|
+
...this.eventMap.get(key) || [],
|
|
59
|
+
...this.eventMap.get("*") || []
|
|
60
|
+
];
|
|
61
|
+
if (0 === hooks.length) return;
|
|
62
|
+
for (const hook of hooks)this.runHook(hook, event);
|
|
63
|
+
}
|
|
64
|
+
async runHook(hook, baseEvent) {
|
|
65
|
+
const event = {
|
|
66
|
+
...baseEvent,
|
|
67
|
+
messages: []
|
|
68
|
+
};
|
|
69
|
+
try {
|
|
70
|
+
await hook.handler(event);
|
|
71
|
+
} catch (error) {
|
|
72
|
+
this.ctx.logger.error(`Hook ${hook.name} failed`, error);
|
|
73
|
+
}
|
|
74
|
+
if (hook.entry?.deliver) await this.deliverToAgent(hook, event, hook.entry.deliver);
|
|
75
|
+
}
|
|
76
|
+
async deliverToAgent(hook, event, deliver) {
|
|
77
|
+
const agentId = "last" === deliver.agentId ? event.agentId || this.ctx.router.selectAgent() : deliver.agentId;
|
|
78
|
+
if (!agentId) return void this.ctx.logger.warn(`Hook ${hook.name} has no target agent`);
|
|
79
|
+
const sessionKey = deliver.sessionKey || event.sessionKey || `agent:${agentId}:hook:${hook.name}`;
|
|
80
|
+
const message = deliver.message || (event.messages.length > 0 ? event.messages.join("\n") : event.payload ? JSON.stringify(event.payload, null, 2) : `Hook "${hook.name}" triggered (${event.type}:${event.action}).`);
|
|
81
|
+
try {
|
|
82
|
+
const manager = await this.ctx.getSessionManager(agentId);
|
|
83
|
+
manager.getOrCreateSession(sessionKey, agentId, `Hook: ${hook.name}`);
|
|
84
|
+
manager.updateSession(sessionKey, {
|
|
85
|
+
lastMessagePreview: message.substring(0, 200)
|
|
86
|
+
});
|
|
87
|
+
manager.updateSessionMetadata(sessionKey, {
|
|
88
|
+
source: "hook",
|
|
89
|
+
hookName: hook.name,
|
|
90
|
+
action: `${event.type}:${event.action}`
|
|
91
|
+
});
|
|
92
|
+
const outputManager = new outputManager_cjs_namespaceObject.OutputManager("interactive");
|
|
93
|
+
const workspace = this.ctx.resolveAgentWorkspace(agentId);
|
|
94
|
+
const session = manager.getSession(sessionKey);
|
|
95
|
+
const workdir = session?.metadata?.workdir ?? null;
|
|
96
|
+
const defaultOutputDir = this.ctx.resolveDefaultOutputDir(agentId);
|
|
97
|
+
const invoker = new agentInvoker_cjs_namespaceObject.AgentInvoker({
|
|
98
|
+
workspace,
|
|
99
|
+
configDir: this.ctx.configDir,
|
|
100
|
+
outputManager,
|
|
101
|
+
logger: this.ctx.logger,
|
|
102
|
+
sessionManager: manager,
|
|
103
|
+
workdir,
|
|
104
|
+
defaultOutputDir
|
|
105
|
+
});
|
|
106
|
+
invoker.invokeAgent(agentId, message, sessionKey);
|
|
107
|
+
} catch (error) {
|
|
108
|
+
this.ctx.logger.error(`Hook ${hook.name} delivery failed`, error);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
constructor(ctx, config){
|
|
112
|
+
_define_property(this, "ctx", void 0);
|
|
113
|
+
_define_property(this, "config", void 0);
|
|
114
|
+
_define_property(this, "hooks", void 0);
|
|
115
|
+
_define_property(this, "eventMap", void 0);
|
|
116
|
+
this.ctx = ctx;
|
|
117
|
+
this.config = config;
|
|
118
|
+
this.hooks = [];
|
|
119
|
+
this.eventMap = new Map();
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
exports.InternalHookRegistry = __webpack_exports__.InternalHookRegistry;
|
|
123
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
124
|
+
"InternalHookRegistry"
|
|
125
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
126
|
+
Object.defineProperty(exports, '__esModule', {
|
|
127
|
+
value: true
|
|
128
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { HookEvent, InternalHooksConfig } from "./types.js";
|
|
2
|
+
import type { GatewayHttpContext } from "../http/types.js";
|
|
3
|
+
export declare class InternalHookRegistry {
|
|
4
|
+
private ctx;
|
|
5
|
+
private config;
|
|
6
|
+
private hooks;
|
|
7
|
+
private eventMap;
|
|
8
|
+
constructor(ctx: GatewayHttpContext, config: InternalHooksConfig | undefined);
|
|
9
|
+
load(): Promise<void>;
|
|
10
|
+
emit(event: Omit<HookEvent, "messages">): void;
|
|
11
|
+
private runHook;
|
|
12
|
+
private deliverToAgent;
|
|
13
|
+
}
|