@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,309 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_exports__ = {};
|
|
3
|
+
const external_vitest_namespaceObject = require("vitest");
|
|
4
|
+
const matcher_cjs_namespaceObject = require("../agent/middleware/hooks/matcher.cjs");
|
|
5
|
+
(0, external_vitest_namespaceObject.describe)("Hooks Pattern Matching", ()=>{
|
|
6
|
+
(0, external_vitest_namespaceObject.describe)("matchesToolPattern", ()=>{
|
|
7
|
+
(0, external_vitest_namespaceObject.describe)("Wildcard patterns", ()=>{
|
|
8
|
+
(0, external_vitest_namespaceObject.it)("should match all tools with wildcard *", ()=>{
|
|
9
|
+
(0, external_vitest_namespaceObject.expect)((0, matcher_cjs_namespaceObject.matchesToolPattern)("write_file", "*")).toBe(true);
|
|
10
|
+
(0, external_vitest_namespaceObject.expect)((0, matcher_cjs_namespaceObject.matchesToolPattern)("read_file", "*")).toBe(true);
|
|
11
|
+
(0, external_vitest_namespaceObject.expect)((0, matcher_cjs_namespaceObject.matchesToolPattern)("any_tool", "*")).toBe(true);
|
|
12
|
+
});
|
|
13
|
+
(0, external_vitest_namespaceObject.it)("should match all tools with empty string", ()=>{
|
|
14
|
+
(0, external_vitest_namespaceObject.expect)((0, matcher_cjs_namespaceObject.matchesToolPattern)("write_file", "")).toBe(true);
|
|
15
|
+
(0, external_vitest_namespaceObject.expect)((0, matcher_cjs_namespaceObject.matchesToolPattern)("read_file", "")).toBe(true);
|
|
16
|
+
});
|
|
17
|
+
(0, external_vitest_namespaceObject.it)("should match all tools with undefined pattern", ()=>{
|
|
18
|
+
(0, external_vitest_namespaceObject.expect)((0, matcher_cjs_namespaceObject.matchesToolPattern)("write_file", void 0)).toBe(true);
|
|
19
|
+
(0, external_vitest_namespaceObject.expect)((0, matcher_cjs_namespaceObject.matchesToolPattern)("read_file", void 0)).toBe(true);
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
(0, external_vitest_namespaceObject.describe)("Exact match", ()=>{
|
|
23
|
+
(0, external_vitest_namespaceObject.it)("should match exact tool name", ()=>{
|
|
24
|
+
(0, external_vitest_namespaceObject.expect)((0, matcher_cjs_namespaceObject.matchesToolPattern)("write_file", "write_file")).toBe(true);
|
|
25
|
+
(0, external_vitest_namespaceObject.expect)((0, matcher_cjs_namespaceObject.matchesToolPattern)("read_file", "read_file")).toBe(true);
|
|
26
|
+
});
|
|
27
|
+
(0, external_vitest_namespaceObject.it)("should not match different tool names", ()=>{
|
|
28
|
+
(0, external_vitest_namespaceObject.expect)((0, matcher_cjs_namespaceObject.matchesToolPattern)("write_file", "read_file")).toBe(false);
|
|
29
|
+
(0, external_vitest_namespaceObject.expect)((0, matcher_cjs_namespaceObject.matchesToolPattern)("read_file", "write_file")).toBe(false);
|
|
30
|
+
});
|
|
31
|
+
(0, external_vitest_namespaceObject.it)("should be case-sensitive", ()=>{
|
|
32
|
+
(0, external_vitest_namespaceObject.expect)((0, matcher_cjs_namespaceObject.matchesToolPattern)("write_file", "WRITE_FILE")).toBe(false);
|
|
33
|
+
(0, external_vitest_namespaceObject.expect)((0, matcher_cjs_namespaceObject.matchesToolPattern)("Write_File", "write_file")).toBe(false);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
(0, external_vitest_namespaceObject.describe)("Pipe-separated lists", ()=>{
|
|
37
|
+
(0, external_vitest_namespaceObject.it)("should match any tool in pipe-separated list", ()=>{
|
|
38
|
+
const pattern = "write_file|read_file|edit_file";
|
|
39
|
+
(0, external_vitest_namespaceObject.expect)((0, matcher_cjs_namespaceObject.matchesToolPattern)("write_file", pattern)).toBe(true);
|
|
40
|
+
(0, external_vitest_namespaceObject.expect)((0, matcher_cjs_namespaceObject.matchesToolPattern)("read_file", pattern)).toBe(true);
|
|
41
|
+
(0, external_vitest_namespaceObject.expect)((0, matcher_cjs_namespaceObject.matchesToolPattern)("edit_file", pattern)).toBe(true);
|
|
42
|
+
});
|
|
43
|
+
(0, external_vitest_namespaceObject.it)("should not match tools not in the list", ()=>{
|
|
44
|
+
const pattern = "write_file|read_file";
|
|
45
|
+
(0, external_vitest_namespaceObject.expect)((0, matcher_cjs_namespaceObject.matchesToolPattern)("delete_file", pattern)).toBe(false);
|
|
46
|
+
(0, external_vitest_namespaceObject.expect)((0, matcher_cjs_namespaceObject.matchesToolPattern)("search", pattern)).toBe(false);
|
|
47
|
+
});
|
|
48
|
+
(0, external_vitest_namespaceObject.it)("should handle whitespace around pipe separators", ()=>{
|
|
49
|
+
const pattern = "write_file | read_file | edit_file";
|
|
50
|
+
(0, external_vitest_namespaceObject.expect)((0, matcher_cjs_namespaceObject.matchesToolPattern)("write_file", pattern)).toBe(true);
|
|
51
|
+
(0, external_vitest_namespaceObject.expect)((0, matcher_cjs_namespaceObject.matchesToolPattern)("read_file", pattern)).toBe(true);
|
|
52
|
+
(0, external_vitest_namespaceObject.expect)((0, matcher_cjs_namespaceObject.matchesToolPattern)("edit_file", pattern)).toBe(true);
|
|
53
|
+
});
|
|
54
|
+
(0, external_vitest_namespaceObject.it)("should handle single item in pipe-separated list", ()=>{
|
|
55
|
+
(0, external_vitest_namespaceObject.expect)((0, matcher_cjs_namespaceObject.matchesToolPattern)("write_file", "write_file|")).toBe(true);
|
|
56
|
+
(0, external_vitest_namespaceObject.expect)((0, matcher_cjs_namespaceObject.matchesToolPattern)("write_file", "|write_file")).toBe(true);
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
(0, external_vitest_namespaceObject.describe)("Regex patterns", ()=>{
|
|
60
|
+
(0, external_vitest_namespaceObject.it)("should match regex patterns", ()=>{
|
|
61
|
+
(0, external_vitest_namespaceObject.expect)((0, matcher_cjs_namespaceObject.matchesToolPattern)("write_file", ".*_file")).toBe(true);
|
|
62
|
+
(0, external_vitest_namespaceObject.expect)((0, matcher_cjs_namespaceObject.matchesToolPattern)("read_file", ".*_file")).toBe(true);
|
|
63
|
+
(0, external_vitest_namespaceObject.expect)((0, matcher_cjs_namespaceObject.matchesToolPattern)("delete_file", ".*_file")).toBe(true);
|
|
64
|
+
});
|
|
65
|
+
(0, external_vitest_namespaceObject.it)("should not match when regex doesn't match", ()=>{
|
|
66
|
+
(0, external_vitest_namespaceObject.expect)((0, matcher_cjs_namespaceObject.matchesToolPattern)("search", ".*_file")).toBe(false);
|
|
67
|
+
(0, external_vitest_namespaceObject.expect)((0, matcher_cjs_namespaceObject.matchesToolPattern)("internet_search", ".*_file")).toBe(false);
|
|
68
|
+
});
|
|
69
|
+
(0, external_vitest_namespaceObject.it)("should handle complex regex patterns", ()=>{
|
|
70
|
+
(0, external_vitest_namespaceObject.expect)((0, matcher_cjs_namespaceObject.matchesToolPattern)("write_file", "^write_.*")).toBe(true);
|
|
71
|
+
(0, external_vitest_namespaceObject.expect)((0, matcher_cjs_namespaceObject.matchesToolPattern)("write_code", "^write_.*")).toBe(true);
|
|
72
|
+
(0, external_vitest_namespaceObject.expect)((0, matcher_cjs_namespaceObject.matchesToolPattern)("read_file", "^write_.*")).toBe(false);
|
|
73
|
+
});
|
|
74
|
+
(0, external_vitest_namespaceObject.it)("should handle character classes in regex", ()=>{
|
|
75
|
+
(0, external_vitest_namespaceObject.expect)((0, matcher_cjs_namespaceObject.matchesToolPattern)("write1_file", "write[0-9]_file")).toBe(true);
|
|
76
|
+
(0, external_vitest_namespaceObject.expect)((0, matcher_cjs_namespaceObject.matchesToolPattern)("write2_file", "write[0-9]_file")).toBe(true);
|
|
77
|
+
(0, external_vitest_namespaceObject.expect)((0, matcher_cjs_namespaceObject.matchesToolPattern)("writeA_file", "write[0-9]_file")).toBe(false);
|
|
78
|
+
});
|
|
79
|
+
(0, external_vitest_namespaceObject.it)("should fallback to exact match for invalid regex", ()=>{
|
|
80
|
+
const invalidPattern = "[invalid(regex";
|
|
81
|
+
(0, external_vitest_namespaceObject.expect)((0, matcher_cjs_namespaceObject.matchesToolPattern)(invalidPattern, invalidPattern)).toBe(true);
|
|
82
|
+
(0, external_vitest_namespaceObject.expect)((0, matcher_cjs_namespaceObject.matchesToolPattern)("other_tool", invalidPattern)).toBe(false);
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
(0, external_vitest_namespaceObject.describe)("Edge cases", ()=>{
|
|
86
|
+
(0, external_vitest_namespaceObject.it)("should handle empty tool name", ()=>{
|
|
87
|
+
(0, external_vitest_namespaceObject.expect)((0, matcher_cjs_namespaceObject.matchesToolPattern)("", "*")).toBe(true);
|
|
88
|
+
(0, external_vitest_namespaceObject.expect)((0, matcher_cjs_namespaceObject.matchesToolPattern)("", "")).toBe(true);
|
|
89
|
+
(0, external_vitest_namespaceObject.expect)((0, matcher_cjs_namespaceObject.matchesToolPattern)("", "write_file")).toBe(false);
|
|
90
|
+
});
|
|
91
|
+
(0, external_vitest_namespaceObject.it)("should handle special characters in tool names", ()=>{
|
|
92
|
+
(0, external_vitest_namespaceObject.expect)((0, matcher_cjs_namespaceObject.matchesToolPattern)("write_file-v2", "write_file-v2")).toBe(true);
|
|
93
|
+
(0, external_vitest_namespaceObject.expect)((0, matcher_cjs_namespaceObject.matchesToolPattern)("write.file", "write.file")).toBe(true);
|
|
94
|
+
(0, external_vitest_namespaceObject.expect)((0, matcher_cjs_namespaceObject.matchesToolPattern)("write$file", "write$file")).toBe(true);
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
(0, external_vitest_namespaceObject.describe)("findMatchingHooks", ()=>{
|
|
99
|
+
const mockHook1 = {
|
|
100
|
+
type: "command",
|
|
101
|
+
command: "echo 'hook1'",
|
|
102
|
+
timeout: 30
|
|
103
|
+
};
|
|
104
|
+
const mockHook2 = {
|
|
105
|
+
type: "command",
|
|
106
|
+
command: "echo 'hook2'",
|
|
107
|
+
timeout: 60
|
|
108
|
+
};
|
|
109
|
+
const mockHook3 = {
|
|
110
|
+
type: "command",
|
|
111
|
+
command: "echo 'hook3'"
|
|
112
|
+
};
|
|
113
|
+
(0, external_vitest_namespaceObject.describe)("Basic matching", ()=>{
|
|
114
|
+
(0, external_vitest_namespaceObject.it)("should return empty array when no matchers provided", ()=>{
|
|
115
|
+
const result = (0, matcher_cjs_namespaceObject.findMatchingHooks)(void 0, "write_file");
|
|
116
|
+
(0, external_vitest_namespaceObject.expect)(result).toEqual([]);
|
|
117
|
+
});
|
|
118
|
+
(0, external_vitest_namespaceObject.it)("should return empty array when matchers array is empty", ()=>{
|
|
119
|
+
const result = (0, matcher_cjs_namespaceObject.findMatchingHooks)([], "write_file");
|
|
120
|
+
(0, external_vitest_namespaceObject.expect)(result).toEqual([]);
|
|
121
|
+
});
|
|
122
|
+
(0, external_vitest_namespaceObject.it)("should return hooks that match the tool name", ()=>{
|
|
123
|
+
const matchers = [
|
|
124
|
+
{
|
|
125
|
+
matcher: "write_file",
|
|
126
|
+
hooks: [
|
|
127
|
+
mockHook1
|
|
128
|
+
]
|
|
129
|
+
}
|
|
130
|
+
];
|
|
131
|
+
const result = (0, matcher_cjs_namespaceObject.findMatchingHooks)(matchers, "write_file");
|
|
132
|
+
(0, external_vitest_namespaceObject.expect)(result).toHaveLength(1);
|
|
133
|
+
(0, external_vitest_namespaceObject.expect)(result[0]).toBe(mockHook1);
|
|
134
|
+
});
|
|
135
|
+
(0, external_vitest_namespaceObject.it)("should return empty array when no matchers match", ()=>{
|
|
136
|
+
const matchers = [
|
|
137
|
+
{
|
|
138
|
+
matcher: "write_file",
|
|
139
|
+
hooks: [
|
|
140
|
+
mockHook1
|
|
141
|
+
]
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
matcher: "edit_file",
|
|
145
|
+
hooks: [
|
|
146
|
+
mockHook2
|
|
147
|
+
]
|
|
148
|
+
}
|
|
149
|
+
];
|
|
150
|
+
const result = (0, matcher_cjs_namespaceObject.findMatchingHooks)(matchers, "read_file");
|
|
151
|
+
(0, external_vitest_namespaceObject.expect)(result).toEqual([]);
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
(0, external_vitest_namespaceObject.describe)("Multiple matches", ()=>{
|
|
155
|
+
(0, external_vitest_namespaceObject.it)("should return hooks from multiple matchers", ()=>{
|
|
156
|
+
const matchers = [
|
|
157
|
+
{
|
|
158
|
+
matcher: "write_file",
|
|
159
|
+
hooks: [
|
|
160
|
+
mockHook1
|
|
161
|
+
]
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
matcher: "write_file",
|
|
165
|
+
hooks: [
|
|
166
|
+
mockHook2
|
|
167
|
+
]
|
|
168
|
+
}
|
|
169
|
+
];
|
|
170
|
+
const result = (0, matcher_cjs_namespaceObject.findMatchingHooks)(matchers, "write_file");
|
|
171
|
+
(0, external_vitest_namespaceObject.expect)(result).toHaveLength(2);
|
|
172
|
+
(0, external_vitest_namespaceObject.expect)(result).toContain(mockHook1);
|
|
173
|
+
(0, external_vitest_namespaceObject.expect)(result).toContain(mockHook2);
|
|
174
|
+
});
|
|
175
|
+
(0, external_vitest_namespaceObject.it)("should return all hooks from a matcher with multiple hooks", ()=>{
|
|
176
|
+
const matchers = [
|
|
177
|
+
{
|
|
178
|
+
matcher: "write_file",
|
|
179
|
+
hooks: [
|
|
180
|
+
mockHook1,
|
|
181
|
+
mockHook2,
|
|
182
|
+
mockHook3
|
|
183
|
+
]
|
|
184
|
+
}
|
|
185
|
+
];
|
|
186
|
+
const result = (0, matcher_cjs_namespaceObject.findMatchingHooks)(matchers, "write_file");
|
|
187
|
+
(0, external_vitest_namespaceObject.expect)(result).toHaveLength(3);
|
|
188
|
+
(0, external_vitest_namespaceObject.expect)(result).toContain(mockHook1);
|
|
189
|
+
(0, external_vitest_namespaceObject.expect)(result).toContain(mockHook2);
|
|
190
|
+
(0, external_vitest_namespaceObject.expect)(result).toContain(mockHook3);
|
|
191
|
+
});
|
|
192
|
+
(0, external_vitest_namespaceObject.it)("should flatten hooks from multiple matching matchers", ()=>{
|
|
193
|
+
const matchers = [
|
|
194
|
+
{
|
|
195
|
+
matcher: ".*_file",
|
|
196
|
+
hooks: [
|
|
197
|
+
mockHook1
|
|
198
|
+
]
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
matcher: "write_file|read_file",
|
|
202
|
+
hooks: [
|
|
203
|
+
mockHook2
|
|
204
|
+
]
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
matcher: "*",
|
|
208
|
+
hooks: [
|
|
209
|
+
mockHook3
|
|
210
|
+
]
|
|
211
|
+
}
|
|
212
|
+
];
|
|
213
|
+
const result = (0, matcher_cjs_namespaceObject.findMatchingHooks)(matchers, "write_file");
|
|
214
|
+
(0, external_vitest_namespaceObject.expect)(result).toHaveLength(3);
|
|
215
|
+
(0, external_vitest_namespaceObject.expect)(result[0]).toBe(mockHook1);
|
|
216
|
+
(0, external_vitest_namespaceObject.expect)(result[1]).toBe(mockHook2);
|
|
217
|
+
(0, external_vitest_namespaceObject.expect)(result[2]).toBe(mockHook3);
|
|
218
|
+
});
|
|
219
|
+
});
|
|
220
|
+
(0, external_vitest_namespaceObject.describe)("Pattern types", ()=>{
|
|
221
|
+
(0, external_vitest_namespaceObject.it)("should match with wildcard pattern", ()=>{
|
|
222
|
+
const matchers = [
|
|
223
|
+
{
|
|
224
|
+
matcher: "*",
|
|
225
|
+
hooks: [
|
|
226
|
+
mockHook1
|
|
227
|
+
]
|
|
228
|
+
}
|
|
229
|
+
];
|
|
230
|
+
(0, external_vitest_namespaceObject.expect)((0, matcher_cjs_namespaceObject.findMatchingHooks)(matchers, "write_file")).toHaveLength(1);
|
|
231
|
+
(0, external_vitest_namespaceObject.expect)((0, matcher_cjs_namespaceObject.findMatchingHooks)(matchers, "read_file")).toHaveLength(1);
|
|
232
|
+
(0, external_vitest_namespaceObject.expect)((0, matcher_cjs_namespaceObject.findMatchingHooks)(matchers, "any_tool")).toHaveLength(1);
|
|
233
|
+
});
|
|
234
|
+
(0, external_vitest_namespaceObject.it)("should match with pipe-separated list", ()=>{
|
|
235
|
+
const matchers = [
|
|
236
|
+
{
|
|
237
|
+
matcher: "write_file|read_file|edit_file",
|
|
238
|
+
hooks: [
|
|
239
|
+
mockHook1
|
|
240
|
+
]
|
|
241
|
+
}
|
|
242
|
+
];
|
|
243
|
+
(0, external_vitest_namespaceObject.expect)((0, matcher_cjs_namespaceObject.findMatchingHooks)(matchers, "write_file")).toHaveLength(1);
|
|
244
|
+
(0, external_vitest_namespaceObject.expect)((0, matcher_cjs_namespaceObject.findMatchingHooks)(matchers, "read_file")).toHaveLength(1);
|
|
245
|
+
(0, external_vitest_namespaceObject.expect)((0, matcher_cjs_namespaceObject.findMatchingHooks)(matchers, "delete_file")).toHaveLength(0);
|
|
246
|
+
});
|
|
247
|
+
(0, external_vitest_namespaceObject.it)("should match with regex pattern", ()=>{
|
|
248
|
+
const matchers = [
|
|
249
|
+
{
|
|
250
|
+
matcher: ".*_file",
|
|
251
|
+
hooks: [
|
|
252
|
+
mockHook1
|
|
253
|
+
]
|
|
254
|
+
}
|
|
255
|
+
];
|
|
256
|
+
(0, external_vitest_namespaceObject.expect)((0, matcher_cjs_namespaceObject.findMatchingHooks)(matchers, "write_file")).toHaveLength(1);
|
|
257
|
+
(0, external_vitest_namespaceObject.expect)((0, matcher_cjs_namespaceObject.findMatchingHooks)(matchers, "read_file")).toHaveLength(1);
|
|
258
|
+
(0, external_vitest_namespaceObject.expect)((0, matcher_cjs_namespaceObject.findMatchingHooks)(matchers, "search")).toHaveLength(0);
|
|
259
|
+
});
|
|
260
|
+
});
|
|
261
|
+
(0, external_vitest_namespaceObject.describe)("Order preservation", ()=>{
|
|
262
|
+
(0, external_vitest_namespaceObject.it)("should preserve order of hooks from matchers", ()=>{
|
|
263
|
+
const matchers = [
|
|
264
|
+
{
|
|
265
|
+
matcher: "*",
|
|
266
|
+
hooks: [
|
|
267
|
+
mockHook1,
|
|
268
|
+
mockHook2
|
|
269
|
+
]
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
matcher: "write_file",
|
|
273
|
+
hooks: [
|
|
274
|
+
mockHook3
|
|
275
|
+
]
|
|
276
|
+
}
|
|
277
|
+
];
|
|
278
|
+
const result = (0, matcher_cjs_namespaceObject.findMatchingHooks)(matchers, "write_file");
|
|
279
|
+
(0, external_vitest_namespaceObject.expect)(result).toHaveLength(3);
|
|
280
|
+
(0, external_vitest_namespaceObject.expect)(result[0]).toBe(mockHook1);
|
|
281
|
+
(0, external_vitest_namespaceObject.expect)(result[1]).toBe(mockHook2);
|
|
282
|
+
(0, external_vitest_namespaceObject.expect)(result[2]).toBe(mockHook3);
|
|
283
|
+
});
|
|
284
|
+
});
|
|
285
|
+
(0, external_vitest_namespaceObject.describe)("Empty hook arrays", ()=>{
|
|
286
|
+
(0, external_vitest_namespaceObject.it)("should handle matchers with empty hook arrays", ()=>{
|
|
287
|
+
const matchers = [
|
|
288
|
+
{
|
|
289
|
+
matcher: "write_file",
|
|
290
|
+
hooks: []
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
matcher: "write_file",
|
|
294
|
+
hooks: [
|
|
295
|
+
mockHook1
|
|
296
|
+
]
|
|
297
|
+
}
|
|
298
|
+
];
|
|
299
|
+
const result = (0, matcher_cjs_namespaceObject.findMatchingHooks)(matchers, "write_file");
|
|
300
|
+
(0, external_vitest_namespaceObject.expect)(result).toHaveLength(1);
|
|
301
|
+
(0, external_vitest_namespaceObject.expect)(result[0]).toBe(mockHook1);
|
|
302
|
+
});
|
|
303
|
+
});
|
|
304
|
+
});
|
|
305
|
+
});
|
|
306
|
+
for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
307
|
+
Object.defineProperty(exports, '__esModule', {
|
|
308
|
+
value: true
|
|
309
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { findMatchingHooks, matchesToolPattern } from "../agent/middleware/hooks/matcher.js";
|
|
3
|
+
describe("Hooks Pattern Matching", ()=>{
|
|
4
|
+
describe("matchesToolPattern", ()=>{
|
|
5
|
+
describe("Wildcard patterns", ()=>{
|
|
6
|
+
it("should match all tools with wildcard *", ()=>{
|
|
7
|
+
expect(matchesToolPattern("write_file", "*")).toBe(true);
|
|
8
|
+
expect(matchesToolPattern("read_file", "*")).toBe(true);
|
|
9
|
+
expect(matchesToolPattern("any_tool", "*")).toBe(true);
|
|
10
|
+
});
|
|
11
|
+
it("should match all tools with empty string", ()=>{
|
|
12
|
+
expect(matchesToolPattern("write_file", "")).toBe(true);
|
|
13
|
+
expect(matchesToolPattern("read_file", "")).toBe(true);
|
|
14
|
+
});
|
|
15
|
+
it("should match all tools with undefined pattern", ()=>{
|
|
16
|
+
expect(matchesToolPattern("write_file", void 0)).toBe(true);
|
|
17
|
+
expect(matchesToolPattern("read_file", void 0)).toBe(true);
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
describe("Exact match", ()=>{
|
|
21
|
+
it("should match exact tool name", ()=>{
|
|
22
|
+
expect(matchesToolPattern("write_file", "write_file")).toBe(true);
|
|
23
|
+
expect(matchesToolPattern("read_file", "read_file")).toBe(true);
|
|
24
|
+
});
|
|
25
|
+
it("should not match different tool names", ()=>{
|
|
26
|
+
expect(matchesToolPattern("write_file", "read_file")).toBe(false);
|
|
27
|
+
expect(matchesToolPattern("read_file", "write_file")).toBe(false);
|
|
28
|
+
});
|
|
29
|
+
it("should be case-sensitive", ()=>{
|
|
30
|
+
expect(matchesToolPattern("write_file", "WRITE_FILE")).toBe(false);
|
|
31
|
+
expect(matchesToolPattern("Write_File", "write_file")).toBe(false);
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
describe("Pipe-separated lists", ()=>{
|
|
35
|
+
it("should match any tool in pipe-separated list", ()=>{
|
|
36
|
+
const pattern = "write_file|read_file|edit_file";
|
|
37
|
+
expect(matchesToolPattern("write_file", pattern)).toBe(true);
|
|
38
|
+
expect(matchesToolPattern("read_file", pattern)).toBe(true);
|
|
39
|
+
expect(matchesToolPattern("edit_file", pattern)).toBe(true);
|
|
40
|
+
});
|
|
41
|
+
it("should not match tools not in the list", ()=>{
|
|
42
|
+
const pattern = "write_file|read_file";
|
|
43
|
+
expect(matchesToolPattern("delete_file", pattern)).toBe(false);
|
|
44
|
+
expect(matchesToolPattern("search", pattern)).toBe(false);
|
|
45
|
+
});
|
|
46
|
+
it("should handle whitespace around pipe separators", ()=>{
|
|
47
|
+
const pattern = "write_file | read_file | edit_file";
|
|
48
|
+
expect(matchesToolPattern("write_file", pattern)).toBe(true);
|
|
49
|
+
expect(matchesToolPattern("read_file", pattern)).toBe(true);
|
|
50
|
+
expect(matchesToolPattern("edit_file", pattern)).toBe(true);
|
|
51
|
+
});
|
|
52
|
+
it("should handle single item in pipe-separated list", ()=>{
|
|
53
|
+
expect(matchesToolPattern("write_file", "write_file|")).toBe(true);
|
|
54
|
+
expect(matchesToolPattern("write_file", "|write_file")).toBe(true);
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
describe("Regex patterns", ()=>{
|
|
58
|
+
it("should match regex patterns", ()=>{
|
|
59
|
+
expect(matchesToolPattern("write_file", ".*_file")).toBe(true);
|
|
60
|
+
expect(matchesToolPattern("read_file", ".*_file")).toBe(true);
|
|
61
|
+
expect(matchesToolPattern("delete_file", ".*_file")).toBe(true);
|
|
62
|
+
});
|
|
63
|
+
it("should not match when regex doesn't match", ()=>{
|
|
64
|
+
expect(matchesToolPattern("search", ".*_file")).toBe(false);
|
|
65
|
+
expect(matchesToolPattern("internet_search", ".*_file")).toBe(false);
|
|
66
|
+
});
|
|
67
|
+
it("should handle complex regex patterns", ()=>{
|
|
68
|
+
expect(matchesToolPattern("write_file", "^write_.*")).toBe(true);
|
|
69
|
+
expect(matchesToolPattern("write_code", "^write_.*")).toBe(true);
|
|
70
|
+
expect(matchesToolPattern("read_file", "^write_.*")).toBe(false);
|
|
71
|
+
});
|
|
72
|
+
it("should handle character classes in regex", ()=>{
|
|
73
|
+
expect(matchesToolPattern("write1_file", "write[0-9]_file")).toBe(true);
|
|
74
|
+
expect(matchesToolPattern("write2_file", "write[0-9]_file")).toBe(true);
|
|
75
|
+
expect(matchesToolPattern("writeA_file", "write[0-9]_file")).toBe(false);
|
|
76
|
+
});
|
|
77
|
+
it("should fallback to exact match for invalid regex", ()=>{
|
|
78
|
+
const invalidPattern = "[invalid(regex";
|
|
79
|
+
expect(matchesToolPattern(invalidPattern, invalidPattern)).toBe(true);
|
|
80
|
+
expect(matchesToolPattern("other_tool", invalidPattern)).toBe(false);
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
describe("Edge cases", ()=>{
|
|
84
|
+
it("should handle empty tool name", ()=>{
|
|
85
|
+
expect(matchesToolPattern("", "*")).toBe(true);
|
|
86
|
+
expect(matchesToolPattern("", "")).toBe(true);
|
|
87
|
+
expect(matchesToolPattern("", "write_file")).toBe(false);
|
|
88
|
+
});
|
|
89
|
+
it("should handle special characters in tool names", ()=>{
|
|
90
|
+
expect(matchesToolPattern("write_file-v2", "write_file-v2")).toBe(true);
|
|
91
|
+
expect(matchesToolPattern("write.file", "write.file")).toBe(true);
|
|
92
|
+
expect(matchesToolPattern("write$file", "write$file")).toBe(true);
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
describe("findMatchingHooks", ()=>{
|
|
97
|
+
const mockHook1 = {
|
|
98
|
+
type: "command",
|
|
99
|
+
command: "echo 'hook1'",
|
|
100
|
+
timeout: 30
|
|
101
|
+
};
|
|
102
|
+
const mockHook2 = {
|
|
103
|
+
type: "command",
|
|
104
|
+
command: "echo 'hook2'",
|
|
105
|
+
timeout: 60
|
|
106
|
+
};
|
|
107
|
+
const mockHook3 = {
|
|
108
|
+
type: "command",
|
|
109
|
+
command: "echo 'hook3'"
|
|
110
|
+
};
|
|
111
|
+
describe("Basic matching", ()=>{
|
|
112
|
+
it("should return empty array when no matchers provided", ()=>{
|
|
113
|
+
const result = findMatchingHooks(void 0, "write_file");
|
|
114
|
+
expect(result).toEqual([]);
|
|
115
|
+
});
|
|
116
|
+
it("should return empty array when matchers array is empty", ()=>{
|
|
117
|
+
const result = findMatchingHooks([], "write_file");
|
|
118
|
+
expect(result).toEqual([]);
|
|
119
|
+
});
|
|
120
|
+
it("should return hooks that match the tool name", ()=>{
|
|
121
|
+
const matchers = [
|
|
122
|
+
{
|
|
123
|
+
matcher: "write_file",
|
|
124
|
+
hooks: [
|
|
125
|
+
mockHook1
|
|
126
|
+
]
|
|
127
|
+
}
|
|
128
|
+
];
|
|
129
|
+
const result = findMatchingHooks(matchers, "write_file");
|
|
130
|
+
expect(result).toHaveLength(1);
|
|
131
|
+
expect(result[0]).toBe(mockHook1);
|
|
132
|
+
});
|
|
133
|
+
it("should return empty array when no matchers match", ()=>{
|
|
134
|
+
const matchers = [
|
|
135
|
+
{
|
|
136
|
+
matcher: "write_file",
|
|
137
|
+
hooks: [
|
|
138
|
+
mockHook1
|
|
139
|
+
]
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
matcher: "edit_file",
|
|
143
|
+
hooks: [
|
|
144
|
+
mockHook2
|
|
145
|
+
]
|
|
146
|
+
}
|
|
147
|
+
];
|
|
148
|
+
const result = findMatchingHooks(matchers, "read_file");
|
|
149
|
+
expect(result).toEqual([]);
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
describe("Multiple matches", ()=>{
|
|
153
|
+
it("should return hooks from multiple matchers", ()=>{
|
|
154
|
+
const matchers = [
|
|
155
|
+
{
|
|
156
|
+
matcher: "write_file",
|
|
157
|
+
hooks: [
|
|
158
|
+
mockHook1
|
|
159
|
+
]
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
matcher: "write_file",
|
|
163
|
+
hooks: [
|
|
164
|
+
mockHook2
|
|
165
|
+
]
|
|
166
|
+
}
|
|
167
|
+
];
|
|
168
|
+
const result = findMatchingHooks(matchers, "write_file");
|
|
169
|
+
expect(result).toHaveLength(2);
|
|
170
|
+
expect(result).toContain(mockHook1);
|
|
171
|
+
expect(result).toContain(mockHook2);
|
|
172
|
+
});
|
|
173
|
+
it("should return all hooks from a matcher with multiple hooks", ()=>{
|
|
174
|
+
const matchers = [
|
|
175
|
+
{
|
|
176
|
+
matcher: "write_file",
|
|
177
|
+
hooks: [
|
|
178
|
+
mockHook1,
|
|
179
|
+
mockHook2,
|
|
180
|
+
mockHook3
|
|
181
|
+
]
|
|
182
|
+
}
|
|
183
|
+
];
|
|
184
|
+
const result = findMatchingHooks(matchers, "write_file");
|
|
185
|
+
expect(result).toHaveLength(3);
|
|
186
|
+
expect(result).toContain(mockHook1);
|
|
187
|
+
expect(result).toContain(mockHook2);
|
|
188
|
+
expect(result).toContain(mockHook3);
|
|
189
|
+
});
|
|
190
|
+
it("should flatten hooks from multiple matching matchers", ()=>{
|
|
191
|
+
const matchers = [
|
|
192
|
+
{
|
|
193
|
+
matcher: ".*_file",
|
|
194
|
+
hooks: [
|
|
195
|
+
mockHook1
|
|
196
|
+
]
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
matcher: "write_file|read_file",
|
|
200
|
+
hooks: [
|
|
201
|
+
mockHook2
|
|
202
|
+
]
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
matcher: "*",
|
|
206
|
+
hooks: [
|
|
207
|
+
mockHook3
|
|
208
|
+
]
|
|
209
|
+
}
|
|
210
|
+
];
|
|
211
|
+
const result = findMatchingHooks(matchers, "write_file");
|
|
212
|
+
expect(result).toHaveLength(3);
|
|
213
|
+
expect(result[0]).toBe(mockHook1);
|
|
214
|
+
expect(result[1]).toBe(mockHook2);
|
|
215
|
+
expect(result[2]).toBe(mockHook3);
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
describe("Pattern types", ()=>{
|
|
219
|
+
it("should match with wildcard pattern", ()=>{
|
|
220
|
+
const matchers = [
|
|
221
|
+
{
|
|
222
|
+
matcher: "*",
|
|
223
|
+
hooks: [
|
|
224
|
+
mockHook1
|
|
225
|
+
]
|
|
226
|
+
}
|
|
227
|
+
];
|
|
228
|
+
expect(findMatchingHooks(matchers, "write_file")).toHaveLength(1);
|
|
229
|
+
expect(findMatchingHooks(matchers, "read_file")).toHaveLength(1);
|
|
230
|
+
expect(findMatchingHooks(matchers, "any_tool")).toHaveLength(1);
|
|
231
|
+
});
|
|
232
|
+
it("should match with pipe-separated list", ()=>{
|
|
233
|
+
const matchers = [
|
|
234
|
+
{
|
|
235
|
+
matcher: "write_file|read_file|edit_file",
|
|
236
|
+
hooks: [
|
|
237
|
+
mockHook1
|
|
238
|
+
]
|
|
239
|
+
}
|
|
240
|
+
];
|
|
241
|
+
expect(findMatchingHooks(matchers, "write_file")).toHaveLength(1);
|
|
242
|
+
expect(findMatchingHooks(matchers, "read_file")).toHaveLength(1);
|
|
243
|
+
expect(findMatchingHooks(matchers, "delete_file")).toHaveLength(0);
|
|
244
|
+
});
|
|
245
|
+
it("should match with regex pattern", ()=>{
|
|
246
|
+
const matchers = [
|
|
247
|
+
{
|
|
248
|
+
matcher: ".*_file",
|
|
249
|
+
hooks: [
|
|
250
|
+
mockHook1
|
|
251
|
+
]
|
|
252
|
+
}
|
|
253
|
+
];
|
|
254
|
+
expect(findMatchingHooks(matchers, "write_file")).toHaveLength(1);
|
|
255
|
+
expect(findMatchingHooks(matchers, "read_file")).toHaveLength(1);
|
|
256
|
+
expect(findMatchingHooks(matchers, "search")).toHaveLength(0);
|
|
257
|
+
});
|
|
258
|
+
});
|
|
259
|
+
describe("Order preservation", ()=>{
|
|
260
|
+
it("should preserve order of hooks from matchers", ()=>{
|
|
261
|
+
const matchers = [
|
|
262
|
+
{
|
|
263
|
+
matcher: "*",
|
|
264
|
+
hooks: [
|
|
265
|
+
mockHook1,
|
|
266
|
+
mockHook2
|
|
267
|
+
]
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
matcher: "write_file",
|
|
271
|
+
hooks: [
|
|
272
|
+
mockHook3
|
|
273
|
+
]
|
|
274
|
+
}
|
|
275
|
+
];
|
|
276
|
+
const result = findMatchingHooks(matchers, "write_file");
|
|
277
|
+
expect(result).toHaveLength(3);
|
|
278
|
+
expect(result[0]).toBe(mockHook1);
|
|
279
|
+
expect(result[1]).toBe(mockHook2);
|
|
280
|
+
expect(result[2]).toBe(mockHook3);
|
|
281
|
+
});
|
|
282
|
+
});
|
|
283
|
+
describe("Empty hook arrays", ()=>{
|
|
284
|
+
it("should handle matchers with empty hook arrays", ()=>{
|
|
285
|
+
const matchers = [
|
|
286
|
+
{
|
|
287
|
+
matcher: "write_file",
|
|
288
|
+
hooks: []
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
matcher: "write_file",
|
|
292
|
+
hooks: [
|
|
293
|
+
mockHook1
|
|
294
|
+
]
|
|
295
|
+
}
|
|
296
|
+
];
|
|
297
|
+
const result = findMatchingHooks(matchers, "write_file");
|
|
298
|
+
expect(result).toHaveLength(1);
|
|
299
|
+
expect(result[0]).toBe(mockHook1);
|
|
300
|
+
});
|
|
301
|
+
});
|
|
302
|
+
});
|
|
303
|
+
});
|