@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,71 @@
|
|
|
1
|
+
import { createInternetSearchTool } from "../tools/internet_search.js";
|
|
2
|
+
import { webCrawler } from "../tools/web_crawler.js";
|
|
3
|
+
import { createCommandExecuteTool } from "../tools/command_execute.js";
|
|
4
|
+
import { createThinkingTool } from "../tools/think.js";
|
|
5
|
+
import { createCodeSearchTool } from "../tools/code_search.js";
|
|
6
|
+
import { createGitStatusTool } from "../tools/git_status.js";
|
|
7
|
+
import { createLogger } from "../../logger.js";
|
|
8
|
+
import { MCPClientManager } from "./mcpClientManager.js";
|
|
9
|
+
const logger = createLogger();
|
|
10
|
+
function createTool(name, options = {}) {
|
|
11
|
+
const { workspace = process.cwd(), blockedCommands, allowScriptExecution = true, timeout = 300000, searchConfig = {
|
|
12
|
+
provider: "duckduckgo",
|
|
13
|
+
maxResults: 5
|
|
14
|
+
} } = options;
|
|
15
|
+
logger.debug(`Creating tool: ${name}`, {
|
|
16
|
+
workspace,
|
|
17
|
+
blockedCommands,
|
|
18
|
+
allowScriptExecution,
|
|
19
|
+
timeout,
|
|
20
|
+
searchConfig
|
|
21
|
+
});
|
|
22
|
+
switch(name){
|
|
23
|
+
case "internet_search":
|
|
24
|
+
return createInternetSearchTool(searchConfig);
|
|
25
|
+
case "web_crawler":
|
|
26
|
+
return webCrawler;
|
|
27
|
+
case "command_execute":
|
|
28
|
+
return createCommandExecuteTool(workspace, process.env, blockedCommands, allowScriptExecution, timeout);
|
|
29
|
+
case "think":
|
|
30
|
+
return createThinkingTool();
|
|
31
|
+
case "code_search":
|
|
32
|
+
return createCodeSearchTool(workspace);
|
|
33
|
+
case "git_status":
|
|
34
|
+
return createGitStatusTool(workspace);
|
|
35
|
+
default:
|
|
36
|
+
logger.warn(`Unknown tool name: ${name}`);
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
async function createTools(toolNames, options = {}) {
|
|
41
|
+
const tools = [];
|
|
42
|
+
for (const name of toolNames){
|
|
43
|
+
const tool = createTool(name, options);
|
|
44
|
+
if (tool) tools.push(tool);
|
|
45
|
+
else logger.warn(`Skipping unknown tool: ${name}`);
|
|
46
|
+
}
|
|
47
|
+
if (options.mcpConfigs && options.mcpConfigs.length > 0) try {
|
|
48
|
+
const mcpManager = new MCPClientManager(options.mcpConfigs, logger);
|
|
49
|
+
await mcpManager.initialize();
|
|
50
|
+
const mcpTools = await mcpManager.getTools();
|
|
51
|
+
if (mcpTools.length > 0) {
|
|
52
|
+
tools.push(...mcpTools);
|
|
53
|
+
logger.info(`Added ${mcpTools.length} MCP tool(s)`);
|
|
54
|
+
}
|
|
55
|
+
} catch (error) {
|
|
56
|
+
logger.error(`Failed to load MCP tools: ${error instanceof Error ? error.message : String(error)}`);
|
|
57
|
+
}
|
|
58
|
+
logger.info(`Created ${tools.length} total tools: ${toolNames.join(", ")}${options.mcpConfigs?.length ? " + MCP tools" : ""}`);
|
|
59
|
+
return tools;
|
|
60
|
+
}
|
|
61
|
+
function getAvailableTools() {
|
|
62
|
+
return [
|
|
63
|
+
"internet_search",
|
|
64
|
+
"web_crawler",
|
|
65
|
+
"command_execute",
|
|
66
|
+
"think",
|
|
67
|
+
"code_search",
|
|
68
|
+
"git_status"
|
|
69
|
+
];
|
|
70
|
+
}
|
|
71
|
+
export { createTool, createTools, getAvailableTools };
|
|
@@ -0,0 +1,60 @@
|
|
|
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
|
+
additionalMessageMiddleware: ()=>additionalMessageMiddleware
|
|
28
|
+
});
|
|
29
|
+
const external_langchain_namespaceObject = require("langchain");
|
|
30
|
+
const external_utils_cjs_namespaceObject = require("../utils.cjs");
|
|
31
|
+
const additionalMessageMiddleware = (context = {})=>({
|
|
32
|
+
name: "additional-message-middleware",
|
|
33
|
+
[external_langchain_namespaceObject.MIDDLEWARE_BRAND]: true,
|
|
34
|
+
beforeAgent: async (input)=>{
|
|
35
|
+
const alreadyInjected = input.messages.some((message)=>message?.additional_kwargs?.source === "additional-message-middleware");
|
|
36
|
+
if (alreadyInjected) return input;
|
|
37
|
+
const lines = [
|
|
38
|
+
(0, external_utils_cjs_namespaceObject.getMachineDetails)(),
|
|
39
|
+
`** Current Date Time (UTC): ${new Date().toISOString()} **`
|
|
40
|
+
];
|
|
41
|
+
if (context.workdir) lines.push(`** Working directory for outputs: ${context.workdir} **`);
|
|
42
|
+
else if (context.defaultOutputDir) lines.push(`** No session working directory set. Default output directory: ${context.defaultOutputDir} **`);
|
|
43
|
+
lines.push("** Long-term memory **\n- Use /memories/ for durable notes across threads.\n- Store stable preferences, project context, decisions, and research notes.\n- Avoid transient logs; keep entries concise and organized.\n- Suggested paths: /memories/preferences.md, /memories/projects/<name>/context.md, /memories/projects/<name>/decisions.md");
|
|
44
|
+
input.messages.unshift(new external_langchain_namespaceObject.HumanMessage({
|
|
45
|
+
content: lines.join("\n\n"),
|
|
46
|
+
additional_kwargs: {
|
|
47
|
+
ui_hidden: true,
|
|
48
|
+
source: "additional-message-middleware"
|
|
49
|
+
}
|
|
50
|
+
}));
|
|
51
|
+
return input;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
exports.additionalMessageMiddleware = __webpack_exports__.additionalMessageMiddleware;
|
|
55
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
56
|
+
"additionalMessageMiddleware"
|
|
57
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
58
|
+
Object.defineProperty(exports, '__esModule', {
|
|
59
|
+
value: true
|
|
60
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type AgentMiddleware } from "langchain";
|
|
2
|
+
type AdditionalMessageContext = {
|
|
3
|
+
workdir?: string | null;
|
|
4
|
+
defaultOutputDir?: string | null;
|
|
5
|
+
};
|
|
6
|
+
export declare const additionalMessageMiddleware: (context?: AdditionalMessageContext) => AgentMiddleware;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { HumanMessage, MIDDLEWARE_BRAND } from "langchain";
|
|
2
|
+
import { getMachineDetails } from "../utils.js";
|
|
3
|
+
const additionalMessageMiddleware = (context = {})=>({
|
|
4
|
+
name: "additional-message-middleware",
|
|
5
|
+
[MIDDLEWARE_BRAND]: true,
|
|
6
|
+
beforeAgent: async (input)=>{
|
|
7
|
+
const alreadyInjected = input.messages.some((message)=>message?.additional_kwargs?.source === "additional-message-middleware");
|
|
8
|
+
if (alreadyInjected) return input;
|
|
9
|
+
const lines = [
|
|
10
|
+
getMachineDetails(),
|
|
11
|
+
`** Current Date Time (UTC): ${new Date().toISOString()} **`
|
|
12
|
+
];
|
|
13
|
+
if (context.workdir) lines.push(`** Working directory for outputs: ${context.workdir} **`);
|
|
14
|
+
else if (context.defaultOutputDir) lines.push(`** No session working directory set. Default output directory: ${context.defaultOutputDir} **`);
|
|
15
|
+
lines.push("** Long-term memory **\n- Use /memories/ for durable notes across threads.\n- Store stable preferences, project context, decisions, and research notes.\n- Avoid transient logs; keep entries concise and organized.\n- Suggested paths: /memories/preferences.md, /memories/projects/<name>/context.md, /memories/projects/<name>/decisions.md");
|
|
16
|
+
input.messages.unshift(new HumanMessage({
|
|
17
|
+
content: lines.join("\n\n"),
|
|
18
|
+
additional_kwargs: {
|
|
19
|
+
ui_hidden: true,
|
|
20
|
+
source: "additional-message-middleware"
|
|
21
|
+
}
|
|
22
|
+
}));
|
|
23
|
+
return input;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
export { additionalMessageMiddleware };
|
|
@@ -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
|
+
HookExecutor: ()=>HookExecutor
|
|
28
|
+
});
|
|
29
|
+
const external_node_child_process_namespaceObject = require("node:child_process");
|
|
30
|
+
const external_input_builder_cjs_namespaceObject = require("./input-builder.cjs");
|
|
31
|
+
const external_matcher_cjs_namespaceObject = require("./matcher.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 HookExecutor {
|
|
43
|
+
async executeHooksForEvent(eventName, matchers, context, blocking = false) {
|
|
44
|
+
if (!matchers || 0 === matchers.length) return;
|
|
45
|
+
const toolName = context.toolCallRequest?.tool?.name;
|
|
46
|
+
if (!toolName || "string" != typeof toolName) return void this.logger.debug("No tool name in context, skipping hook execution");
|
|
47
|
+
const hooks = (0, external_matcher_cjs_namespaceObject.findMatchingHooks)(matchers, toolName);
|
|
48
|
+
if (0 === hooks.length) return void this.logger.debug(`No hooks matched tool: ${toolName}`);
|
|
49
|
+
this.logger.debug(`Executing ${hooks.length} ${eventName} hooks for tool: ${toolName}`);
|
|
50
|
+
const hookInput = (0, external_input_builder_cjs_namespaceObject.buildHookInput)(eventName, context);
|
|
51
|
+
for (const hook of hooks)await this.executeHook(hook, hookInput, eventName, blocking);
|
|
52
|
+
}
|
|
53
|
+
async executeStopHooks(stopHooks, context) {
|
|
54
|
+
if (!stopHooks || 0 === stopHooks.length) return;
|
|
55
|
+
this.logger.debug(`Executing ${stopHooks.length} Stop hook groups`);
|
|
56
|
+
const hookInput = (0, external_input_builder_cjs_namespaceObject.buildHookInput)("Stop", context);
|
|
57
|
+
for (const stopHook of stopHooks)for (const hook of stopHook.hooks)await this.executeHook(hook, hookInput, "Stop", false);
|
|
58
|
+
}
|
|
59
|
+
async executeHook(hook, hookInput, eventName, blocking) {
|
|
60
|
+
const startTime = Date.now();
|
|
61
|
+
const timeoutMs = 1000 * (hook.timeout || 60);
|
|
62
|
+
this.logger.debug(`Executing ${eventName} hook: ${hook.command} (timeout: ${hook.timeout || 60}s)`);
|
|
63
|
+
try {
|
|
64
|
+
const result = await this.runCommand(hook.command, hookInput, timeoutMs);
|
|
65
|
+
const duration = Date.now() - startTime;
|
|
66
|
+
if (result.timedOut) {
|
|
67
|
+
this.logger.warn(`Hook timed out after ${timeoutMs}ms: ${hook.command}`);
|
|
68
|
+
if (blocking) throw new Error(`Hook timed out: ${hook.command}`);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
if (0 === result.exitCode) {
|
|
72
|
+
this.logger.info(`Hook completed successfully in ${duration}ms: ${hook.command}`);
|
|
73
|
+
if (result.stdout) this.logger.debug(`Hook stdout: ${result.stdout}`);
|
|
74
|
+
} else if (2 === result.exitCode) {
|
|
75
|
+
const errorMsg = result.stderr || `Hook failed with exit code 2: ${hook.command}`;
|
|
76
|
+
this.logger.error(`Blocking hook error: ${errorMsg}`);
|
|
77
|
+
throw new Error(errorMsg);
|
|
78
|
+
} else {
|
|
79
|
+
const errorMsg = result.stderr || `Hook failed with exit code ${result.exitCode}: ${hook.command}`;
|
|
80
|
+
this.logger.warn(`Hook failed (non-blocking): ${errorMsg}`);
|
|
81
|
+
if (blocking) throw new Error(errorMsg);
|
|
82
|
+
}
|
|
83
|
+
} catch (error) {
|
|
84
|
+
const duration = Date.now() - startTime;
|
|
85
|
+
this.logger.error(`Hook execution error after ${duration}ms: ${error instanceof Error ? error.message : String(error)}`);
|
|
86
|
+
if (blocking) throw error;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
runCommand(command, input, timeoutMs) {
|
|
90
|
+
return new Promise((resolve)=>{
|
|
91
|
+
const inputJson = JSON.stringify(input);
|
|
92
|
+
const child = (0, external_node_child_process_namespaceObject.spawn)(command, {
|
|
93
|
+
cwd: this.workspace,
|
|
94
|
+
shell: true,
|
|
95
|
+
timeout: timeoutMs
|
|
96
|
+
});
|
|
97
|
+
let stdout = "";
|
|
98
|
+
let stderr = "";
|
|
99
|
+
let timedOut = false;
|
|
100
|
+
child.stdout?.on("data", (data)=>{
|
|
101
|
+
stdout += data.toString();
|
|
102
|
+
});
|
|
103
|
+
child.stderr?.on("data", (data)=>{
|
|
104
|
+
stderr += data.toString();
|
|
105
|
+
});
|
|
106
|
+
child.on("error", (error)=>{
|
|
107
|
+
if (error.message.includes("ETIMEDOUT")) timedOut = true;
|
|
108
|
+
});
|
|
109
|
+
child.on("exit", (code)=>{
|
|
110
|
+
resolve({
|
|
111
|
+
success: 0 === code,
|
|
112
|
+
stdout: stdout.trim(),
|
|
113
|
+
stderr: stderr.trim(),
|
|
114
|
+
exitCode: code || void 0,
|
|
115
|
+
timedOut
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
if (child.stdin) {
|
|
119
|
+
child.stdin.write(inputJson);
|
|
120
|
+
child.stdin.end();
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
constructor(workspace, logger){
|
|
125
|
+
_define_property(this, "workspace", void 0);
|
|
126
|
+
_define_property(this, "logger", void 0);
|
|
127
|
+
this.workspace = workspace;
|
|
128
|
+
this.logger = logger;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
exports.HookExecutor = __webpack_exports__.HookExecutor;
|
|
132
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
133
|
+
"HookExecutor"
|
|
134
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
135
|
+
Object.defineProperty(exports, '__esModule', {
|
|
136
|
+
value: true
|
|
137
|
+
});
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook Executor
|
|
3
|
+
*
|
|
4
|
+
* Core execution engine for running hooks at lifecycle points
|
|
5
|
+
* Handles command execution, timeout enforcement, and exit code handling
|
|
6
|
+
*/
|
|
7
|
+
import type { HookMatcher, StopHook } from "@/types/hooks.js";
|
|
8
|
+
import type { HookExecutionContext } from "./types.js";
|
|
9
|
+
import type { Logger } from "@/logger.js";
|
|
10
|
+
/**
|
|
11
|
+
* Hook executor class
|
|
12
|
+
* Manages hook execution with proper error handling and timeout enforcement
|
|
13
|
+
*/
|
|
14
|
+
export declare class HookExecutor {
|
|
15
|
+
private workspace;
|
|
16
|
+
private logger;
|
|
17
|
+
constructor(workspace: string, logger: Logger);
|
|
18
|
+
/**
|
|
19
|
+
* Execute hooks for a specific event with tool filtering
|
|
20
|
+
*
|
|
21
|
+
* @param eventName - The hook event name
|
|
22
|
+
* @param matchers - Array of hook matchers (for PreToolUse/PostToolUse)
|
|
23
|
+
* @param context - Execution context
|
|
24
|
+
* @param blocking - Whether hook failures should block execution (PreToolUse only)
|
|
25
|
+
*/
|
|
26
|
+
executeHooksForEvent(eventName: "PreToolUse" | "PostToolUse", matchers: HookMatcher[] | undefined, context: HookExecutionContext, blocking?: boolean): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Execute Stop hooks (no filtering needed)
|
|
29
|
+
*
|
|
30
|
+
* @param stopHooks - Array of Stop hook configurations
|
|
31
|
+
* @param context - Execution context
|
|
32
|
+
*/
|
|
33
|
+
executeStopHooks(stopHooks: StopHook[] | undefined, context: HookExecutionContext): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Execute a single hook command
|
|
36
|
+
*
|
|
37
|
+
* @param hook - The hook configuration
|
|
38
|
+
* @param hookInput - Input data to pass via stdin
|
|
39
|
+
* @param eventName - The event name (for logging)
|
|
40
|
+
* @param blocking - Whether failures should throw errors
|
|
41
|
+
*/
|
|
42
|
+
private executeHook;
|
|
43
|
+
/**
|
|
44
|
+
* Run a shell command with JSON input via stdin
|
|
45
|
+
*
|
|
46
|
+
* @param command - The command to execute
|
|
47
|
+
* @param input - JSON input to pass via stdin
|
|
48
|
+
* @param timeoutMs - Timeout in milliseconds
|
|
49
|
+
* @returns Execution result with stdout/stderr/exitCode
|
|
50
|
+
*/
|
|
51
|
+
private runCommand;
|
|
52
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { buildHookInput } from "./input-builder.js";
|
|
3
|
+
import { findMatchingHooks } from "./matcher.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
|
+
class HookExecutor {
|
|
15
|
+
async executeHooksForEvent(eventName, matchers, context, blocking = false) {
|
|
16
|
+
if (!matchers || 0 === matchers.length) return;
|
|
17
|
+
const toolName = context.toolCallRequest?.tool?.name;
|
|
18
|
+
if (!toolName || "string" != typeof toolName) return void this.logger.debug("No tool name in context, skipping hook execution");
|
|
19
|
+
const hooks = findMatchingHooks(matchers, toolName);
|
|
20
|
+
if (0 === hooks.length) return void this.logger.debug(`No hooks matched tool: ${toolName}`);
|
|
21
|
+
this.logger.debug(`Executing ${hooks.length} ${eventName} hooks for tool: ${toolName}`);
|
|
22
|
+
const hookInput = buildHookInput(eventName, context);
|
|
23
|
+
for (const hook of hooks)await this.executeHook(hook, hookInput, eventName, blocking);
|
|
24
|
+
}
|
|
25
|
+
async executeStopHooks(stopHooks, context) {
|
|
26
|
+
if (!stopHooks || 0 === stopHooks.length) return;
|
|
27
|
+
this.logger.debug(`Executing ${stopHooks.length} Stop hook groups`);
|
|
28
|
+
const hookInput = buildHookInput("Stop", context);
|
|
29
|
+
for (const stopHook of stopHooks)for (const hook of stopHook.hooks)await this.executeHook(hook, hookInput, "Stop", false);
|
|
30
|
+
}
|
|
31
|
+
async executeHook(hook, hookInput, eventName, blocking) {
|
|
32
|
+
const startTime = Date.now();
|
|
33
|
+
const timeoutMs = 1000 * (hook.timeout || 60);
|
|
34
|
+
this.logger.debug(`Executing ${eventName} hook: ${hook.command} (timeout: ${hook.timeout || 60}s)`);
|
|
35
|
+
try {
|
|
36
|
+
const result = await this.runCommand(hook.command, hookInput, timeoutMs);
|
|
37
|
+
const duration = Date.now() - startTime;
|
|
38
|
+
if (result.timedOut) {
|
|
39
|
+
this.logger.warn(`Hook timed out after ${timeoutMs}ms: ${hook.command}`);
|
|
40
|
+
if (blocking) throw new Error(`Hook timed out: ${hook.command}`);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (0 === result.exitCode) {
|
|
44
|
+
this.logger.info(`Hook completed successfully in ${duration}ms: ${hook.command}`);
|
|
45
|
+
if (result.stdout) this.logger.debug(`Hook stdout: ${result.stdout}`);
|
|
46
|
+
} else if (2 === result.exitCode) {
|
|
47
|
+
const errorMsg = result.stderr || `Hook failed with exit code 2: ${hook.command}`;
|
|
48
|
+
this.logger.error(`Blocking hook error: ${errorMsg}`);
|
|
49
|
+
throw new Error(errorMsg);
|
|
50
|
+
} else {
|
|
51
|
+
const errorMsg = result.stderr || `Hook failed with exit code ${result.exitCode}: ${hook.command}`;
|
|
52
|
+
this.logger.warn(`Hook failed (non-blocking): ${errorMsg}`);
|
|
53
|
+
if (blocking) throw new Error(errorMsg);
|
|
54
|
+
}
|
|
55
|
+
} catch (error) {
|
|
56
|
+
const duration = Date.now() - startTime;
|
|
57
|
+
this.logger.error(`Hook execution error after ${duration}ms: ${error instanceof Error ? error.message : String(error)}`);
|
|
58
|
+
if (blocking) throw error;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
runCommand(command, input, timeoutMs) {
|
|
62
|
+
return new Promise((resolve)=>{
|
|
63
|
+
const inputJson = JSON.stringify(input);
|
|
64
|
+
const child = spawn(command, {
|
|
65
|
+
cwd: this.workspace,
|
|
66
|
+
shell: true,
|
|
67
|
+
timeout: timeoutMs
|
|
68
|
+
});
|
|
69
|
+
let stdout = "";
|
|
70
|
+
let stderr = "";
|
|
71
|
+
let timedOut = false;
|
|
72
|
+
child.stdout?.on("data", (data)=>{
|
|
73
|
+
stdout += data.toString();
|
|
74
|
+
});
|
|
75
|
+
child.stderr?.on("data", (data)=>{
|
|
76
|
+
stderr += data.toString();
|
|
77
|
+
});
|
|
78
|
+
child.on("error", (error)=>{
|
|
79
|
+
if (error.message.includes("ETIMEDOUT")) timedOut = true;
|
|
80
|
+
});
|
|
81
|
+
child.on("exit", (code)=>{
|
|
82
|
+
resolve({
|
|
83
|
+
success: 0 === code,
|
|
84
|
+
stdout: stdout.trim(),
|
|
85
|
+
stderr: stderr.trim(),
|
|
86
|
+
exitCode: code || void 0,
|
|
87
|
+
timedOut
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
if (child.stdin) {
|
|
91
|
+
child.stdin.write(inputJson);
|
|
92
|
+
child.stdin.end();
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
constructor(workspace, logger){
|
|
97
|
+
_define_property(this, "workspace", void 0);
|
|
98
|
+
_define_property(this, "logger", void 0);
|
|
99
|
+
this.workspace = workspace;
|
|
100
|
+
this.logger = logger;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
export { HookExecutor };
|
|
@@ -0,0 +1,55 @@
|
|
|
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
|
+
buildHookInput: ()=>buildHookInput
|
|
28
|
+
});
|
|
29
|
+
function buildHookInput(eventName, context) {
|
|
30
|
+
const input = {
|
|
31
|
+
session_id: context.sessionId,
|
|
32
|
+
cwd: context.cwd,
|
|
33
|
+
hook_event_name: eventName
|
|
34
|
+
};
|
|
35
|
+
if ("PreToolUse" === eventName || "PostToolUse" === eventName) {
|
|
36
|
+
if (context.toolCallRequest?.tool) {
|
|
37
|
+
const { tool, toolCall } = context.toolCallRequest;
|
|
38
|
+
input.tool_name = String(tool.name);
|
|
39
|
+
input.tool_use_id = toolCall.id;
|
|
40
|
+
if (toolCall.args) input.tool_input = toolCall.args;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if ("PostToolUse" === eventName && context.toolResult) {
|
|
44
|
+
const content = context.toolResult.content;
|
|
45
|
+
input.tool_output = "string" == typeof content ? content : content;
|
|
46
|
+
}
|
|
47
|
+
return input;
|
|
48
|
+
}
|
|
49
|
+
exports.buildHookInput = __webpack_exports__.buildHookInput;
|
|
50
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
51
|
+
"buildHookInput"
|
|
52
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
53
|
+
Object.defineProperty(exports, '__esModule', {
|
|
54
|
+
value: true
|
|
55
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook Input Builder
|
|
3
|
+
*
|
|
4
|
+
* Constructs JSON input data for hooks following Claude Code's HookInput format
|
|
5
|
+
*/
|
|
6
|
+
import type { HookInput, HookEventName } from "@/types/hooks.js";
|
|
7
|
+
import type { HookExecutionContext } from "./types.js";
|
|
8
|
+
/**
|
|
9
|
+
* Build hook input JSON from execution context
|
|
10
|
+
*
|
|
11
|
+
* @param eventName - The hook event name
|
|
12
|
+
* @param context - The execution context containing all runtime data
|
|
13
|
+
* @returns HookInput object to be serialized and passed to hook via stdin
|
|
14
|
+
*/
|
|
15
|
+
export declare function buildHookInput(eventName: HookEventName, context: HookExecutionContext): HookInput;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
function buildHookInput(eventName, context) {
|
|
2
|
+
const input = {
|
|
3
|
+
session_id: context.sessionId,
|
|
4
|
+
cwd: context.cwd,
|
|
5
|
+
hook_event_name: eventName
|
|
6
|
+
};
|
|
7
|
+
if ("PreToolUse" === eventName || "PostToolUse" === eventName) {
|
|
8
|
+
if (context.toolCallRequest?.tool) {
|
|
9
|
+
const { tool, toolCall } = context.toolCallRequest;
|
|
10
|
+
input.tool_name = String(tool.name);
|
|
11
|
+
input.tool_use_id = toolCall.id;
|
|
12
|
+
if (toolCall.args) input.tool_input = toolCall.args;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
if ("PostToolUse" === eventName && context.toolResult) {
|
|
16
|
+
const content = context.toolResult.content;
|
|
17
|
+
input.tool_output = "string" == typeof content ? content : content;
|
|
18
|
+
}
|
|
19
|
+
return input;
|
|
20
|
+
}
|
|
21
|
+
export { buildHookInput };
|
|
@@ -0,0 +1,59 @@
|
|
|
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
|
+
findMatchingHooks: ()=>findMatchingHooks,
|
|
28
|
+
matchesToolPattern: ()=>matchesToolPattern
|
|
29
|
+
});
|
|
30
|
+
function matchesToolPattern(toolName, pattern) {
|
|
31
|
+
if (!pattern || "" === pattern) return true;
|
|
32
|
+
if ("*" === pattern) return true;
|
|
33
|
+
if (pattern.includes("|")) {
|
|
34
|
+
const toolNames = pattern.split("|").map((t)=>t.trim());
|
|
35
|
+
return toolNames.includes(toolName);
|
|
36
|
+
}
|
|
37
|
+
if (pattern === toolName) return true;
|
|
38
|
+
try {
|
|
39
|
+
const regex = new RegExp(pattern);
|
|
40
|
+
return regex.test(toolName);
|
|
41
|
+
} catch (error) {
|
|
42
|
+
return pattern === toolName;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function findMatchingHooks(matchers, toolName) {
|
|
46
|
+
if (!matchers || 0 === matchers.length) return [];
|
|
47
|
+
const matchingHooks = [];
|
|
48
|
+
for (const matcher of matchers)if (matchesToolPattern(toolName, matcher.matcher)) matchingHooks.push(...matcher.hooks);
|
|
49
|
+
return matchingHooks;
|
|
50
|
+
}
|
|
51
|
+
exports.findMatchingHooks = __webpack_exports__.findMatchingHooks;
|
|
52
|
+
exports.matchesToolPattern = __webpack_exports__.matchesToolPattern;
|
|
53
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
54
|
+
"findMatchingHooks",
|
|
55
|
+
"matchesToolPattern"
|
|
56
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
57
|
+
Object.defineProperty(exports, '__esModule', {
|
|
58
|
+
value: true
|
|
59
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pattern Matching Utilities for Hooks
|
|
3
|
+
*
|
|
4
|
+
* Implements tool name pattern matching following Claude Code's behavior:
|
|
5
|
+
* - Pipe-separated tool names: "write_file|edit_file"
|
|
6
|
+
* - Wildcard: "*" or empty string
|
|
7
|
+
* - Regex patterns: ".*_file"
|
|
8
|
+
* - Case-sensitive matching
|
|
9
|
+
*/
|
|
10
|
+
import type { HookMatcher } from "@/types/hooks.js";
|
|
11
|
+
import type { Hook } from "@/types/hooks.js";
|
|
12
|
+
/**
|
|
13
|
+
* Check if a tool name matches a pattern
|
|
14
|
+
*
|
|
15
|
+
* @param toolName - The tool name to match (e.g., "write_file")
|
|
16
|
+
* @param pattern - The pattern to match against
|
|
17
|
+
* @returns true if the tool name matches the pattern
|
|
18
|
+
*/
|
|
19
|
+
export declare function matchesToolPattern(toolName: string, pattern?: string): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Find all hooks that match a given tool name
|
|
22
|
+
*
|
|
23
|
+
* @param matchers - Array of hook matchers to search
|
|
24
|
+
* @param toolName - The tool name to match
|
|
25
|
+
* @returns Array of all matching hooks (flattened)
|
|
26
|
+
*/
|
|
27
|
+
export declare function findMatchingHooks(matchers: HookMatcher[] | undefined, toolName: string): Hook[];
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
function matchesToolPattern(toolName, pattern) {
|
|
2
|
+
if (!pattern || "" === pattern) return true;
|
|
3
|
+
if ("*" === pattern) return true;
|
|
4
|
+
if (pattern.includes("|")) {
|
|
5
|
+
const toolNames = pattern.split("|").map((t)=>t.trim());
|
|
6
|
+
return toolNames.includes(toolName);
|
|
7
|
+
}
|
|
8
|
+
if (pattern === toolName) return true;
|
|
9
|
+
try {
|
|
10
|
+
const regex = new RegExp(pattern);
|
|
11
|
+
return regex.test(toolName);
|
|
12
|
+
} catch (error) {
|
|
13
|
+
return pattern === toolName;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function findMatchingHooks(matchers, toolName) {
|
|
17
|
+
if (!matchers || 0 === matchers.length) return [];
|
|
18
|
+
const matchingHooks = [];
|
|
19
|
+
for (const matcher of matchers)if (matchesToolPattern(toolName, matcher.matcher)) matchingHooks.push(...matcher.hooks);
|
|
20
|
+
return matchingHooks;
|
|
21
|
+
}
|
|
22
|
+
export { findMatchingHooks, matchesToolPattern };
|