@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,242 @@
|
|
|
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
|
+
AgentLoader: ()=>AgentLoader
|
|
28
|
+
});
|
|
29
|
+
const external_node_fs_namespaceObject = require("node:fs");
|
|
30
|
+
const external_node_path_namespaceObject = require("node:path");
|
|
31
|
+
const external_js_yaml_namespaceObject = require("js-yaml");
|
|
32
|
+
const external_agentConfig_cjs_namespaceObject = require("./agentConfig.cjs");
|
|
33
|
+
const external_toolRegistry_cjs_namespaceObject = require("./toolRegistry.cjs");
|
|
34
|
+
const external_modelFactory_cjs_namespaceObject = require("./modelFactory.cjs");
|
|
35
|
+
const external_logger_cjs_namespaceObject = require("../../logger.cjs");
|
|
36
|
+
function _define_property(obj, key, value) {
|
|
37
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
38
|
+
value: value,
|
|
39
|
+
enumerable: true,
|
|
40
|
+
configurable: true,
|
|
41
|
+
writable: true
|
|
42
|
+
});
|
|
43
|
+
else obj[key] = value;
|
|
44
|
+
return obj;
|
|
45
|
+
}
|
|
46
|
+
const logger = (0, external_logger_cjs_namespaceObject.createLogger)();
|
|
47
|
+
class AgentLoader {
|
|
48
|
+
resolveConfigPath(...segments) {
|
|
49
|
+
const baseDir = (0, external_node_path_namespaceObject.isAbsolute)(this.configDir) ? this.configDir : (0, external_node_path_namespaceObject.join)(this.workspace, this.configDir);
|
|
50
|
+
return (0, external_node_path_namespaceObject.join)(baseDir, ...segments);
|
|
51
|
+
}
|
|
52
|
+
loadAllAgentConfigs() {
|
|
53
|
+
const agents = [];
|
|
54
|
+
const agentsDir = this.resolveConfigPath("agents");
|
|
55
|
+
if ((0, external_node_fs_namespaceObject.existsSync)(agentsDir) && (0, external_node_fs_namespaceObject.statSync)(agentsDir).isDirectory()) {
|
|
56
|
+
logger.info(`Loading agents from directory: ${agentsDir}`);
|
|
57
|
+
const agentDirs = (0, external_node_fs_namespaceObject.readdirSync)(agentsDir, {
|
|
58
|
+
withFileTypes: true
|
|
59
|
+
}).filter((dirent)=>dirent.isDirectory()).map((dirent)=>dirent.name);
|
|
60
|
+
for (const agentDir of agentDirs){
|
|
61
|
+
const agentDirPath = (0, external_node_path_namespaceObject.join)(agentsDir, agentDir);
|
|
62
|
+
const agentJsonPath = (0, external_node_path_namespaceObject.join)(agentDirPath, "agent.json");
|
|
63
|
+
const agentMarkdownPath = (0, external_node_path_namespaceObject.join)(agentDirPath, "agent.md");
|
|
64
|
+
const hasJson = (0, external_node_fs_namespaceObject.existsSync)(agentJsonPath);
|
|
65
|
+
const hasMarkdown = (0, external_node_fs_namespaceObject.existsSync)(agentMarkdownPath);
|
|
66
|
+
if (!hasJson && !hasMarkdown) {
|
|
67
|
+
logger.warn(`Skipping ${agentDir}: agent.json or agent.md not found`);
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
try {
|
|
71
|
+
const agentFilePath = hasJson ? agentJsonPath : agentMarkdownPath;
|
|
72
|
+
const json = hasJson ? this.loadFromJson(agentJsonPath) : this.loadFromMarkdown(agentMarkdownPath, agentDirPath);
|
|
73
|
+
const validation = (0, external_agentConfig_cjs_namespaceObject.validateAgentConfig)(json);
|
|
74
|
+
if (!validation.success) {
|
|
75
|
+
logger.error(`Failed to validate ${agentFilePath}:\n${validation.error}`);
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
agents.push(validation.data);
|
|
79
|
+
logger.info(`Loaded agent config: ${validation.data.name}`);
|
|
80
|
+
} catch (error) {
|
|
81
|
+
logger.error(`Failed to load agent from ${agentDirPath}: ${error}`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
} else logger.info(`No agents directory found at: ${agentsDir}`);
|
|
85
|
+
return agents;
|
|
86
|
+
}
|
|
87
|
+
parseFrontmatter(content) {
|
|
88
|
+
const frontmatterRegex = /^---\s*\n([\s\S]*?)\n---\s*\n([\s\S]*)$/;
|
|
89
|
+
const match = content.match(frontmatterRegex);
|
|
90
|
+
if (!match) throw new Error("Invalid agent.md format: missing frontmatter");
|
|
91
|
+
const [, frontmatter, prompt] = match;
|
|
92
|
+
try {
|
|
93
|
+
const metadata = external_js_yaml_namespaceObject.load(frontmatter);
|
|
94
|
+
if (!metadata || "object" != typeof metadata) throw new Error("Frontmatter must be a valid YAML object");
|
|
95
|
+
return {
|
|
96
|
+
metadata,
|
|
97
|
+
prompt: prompt.trim()
|
|
98
|
+
};
|
|
99
|
+
} catch (error) {
|
|
100
|
+
throw new Error(`Failed to parse frontmatter: ${error}`);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
normalizeAgentConfig(config) {
|
|
104
|
+
if (config.subagents && !config.subAgents) {
|
|
105
|
+
config.subAgents = config.subagents;
|
|
106
|
+
delete config.subagents;
|
|
107
|
+
}
|
|
108
|
+
if (Array.isArray(config.subAgents)) {
|
|
109
|
+
for (const subagent of config.subAgents)if (subagent?.subagents && !subagent.subAgents) {
|
|
110
|
+
subagent.subAgents = subagent.subagents;
|
|
111
|
+
delete subagent.subagents;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return config;
|
|
115
|
+
}
|
|
116
|
+
loadFromJson(filePath) {
|
|
117
|
+
const content = (0, external_node_fs_namespaceObject.readFileSync)(filePath, "utf-8");
|
|
118
|
+
const json = JSON.parse(content);
|
|
119
|
+
return this.normalizeAgentConfig(json);
|
|
120
|
+
}
|
|
121
|
+
loadFromMarkdown(filePath, agentDir) {
|
|
122
|
+
const content = (0, external_node_fs_namespaceObject.readFileSync)(filePath, "utf-8");
|
|
123
|
+
const { metadata, prompt } = this.parseFrontmatter(content);
|
|
124
|
+
const config = this.normalizeAgentConfig({
|
|
125
|
+
...metadata,
|
|
126
|
+
systemPrompt: prompt
|
|
127
|
+
});
|
|
128
|
+
if (config.subAgents && Array.isArray(config.subAgents)) {
|
|
129
|
+
for (const subagent of config.subAgents)if (subagent.promptFile) {
|
|
130
|
+
const promptPath = (0, external_node_path_namespaceObject.join)(agentDir, subagent.promptFile);
|
|
131
|
+
if (!(0, external_node_fs_namespaceObject.existsSync)(promptPath)) throw new Error(`Subagent prompt file not found: ${promptPath}`);
|
|
132
|
+
const subagentContent = (0, external_node_fs_namespaceObject.readFileSync)(promptPath, "utf-8");
|
|
133
|
+
if (subagentContent.startsWith("---")) {
|
|
134
|
+
const parsed = this.parseFrontmatter(subagentContent);
|
|
135
|
+
Object.assign(subagent, parsed.metadata);
|
|
136
|
+
subagent.systemPrompt = parsed.prompt;
|
|
137
|
+
} else subagent.systemPrompt = subagentContent.trim();
|
|
138
|
+
delete subagent.promptFile;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return config;
|
|
142
|
+
}
|
|
143
|
+
async loadAgent(agentName) {
|
|
144
|
+
let agent;
|
|
145
|
+
const customAgentsDir = this.resolveConfigPath("agents", agentName);
|
|
146
|
+
if ((0, external_node_fs_namespaceObject.existsSync)(customAgentsDir) && (0, external_node_fs_namespaceObject.statSync)(customAgentsDir).isDirectory()) {
|
|
147
|
+
logger.info(`Loading agent from directory: ${customAgentsDir}`);
|
|
148
|
+
agent = await this.loadFromDirectory(customAgentsDir);
|
|
149
|
+
}
|
|
150
|
+
return agent;
|
|
151
|
+
}
|
|
152
|
+
async loadFromDirectory(dirPath) {
|
|
153
|
+
const agentJsonPath = (0, external_node_path_namespaceObject.join)(dirPath, "agent.json");
|
|
154
|
+
const agentMarkdownPath = (0, external_node_path_namespaceObject.join)(dirPath, "agent.md");
|
|
155
|
+
const hasJson = (0, external_node_fs_namespaceObject.existsSync)(agentJsonPath);
|
|
156
|
+
const hasMarkdown = (0, external_node_fs_namespaceObject.existsSync)(agentMarkdownPath);
|
|
157
|
+
try {
|
|
158
|
+
if (!hasJson && !hasMarkdown) throw new Error(`Agent config file not found: ${agentJsonPath} or ${agentMarkdownPath}`);
|
|
159
|
+
const json = hasJson ? this.loadFromJson(agentJsonPath) : this.loadFromMarkdown(agentMarkdownPath, dirPath);
|
|
160
|
+
logger.info(`Loading agent from ${hasJson ? "JSON" : "markdown"}: ${hasJson ? agentJsonPath : agentMarkdownPath}`);
|
|
161
|
+
const validation = (0, external_agentConfig_cjs_namespaceObject.validateAgentConfig)(json);
|
|
162
|
+
if (!validation.success) throw new Error(`Failed to validate ${hasJson ? agentJsonPath : agentMarkdownPath}:\n${validation.error}`);
|
|
163
|
+
const agent = await this.createAgent(validation.data);
|
|
164
|
+
if (agent.subagents && agent.subagents.length > 0) {
|
|
165
|
+
logger.info(`Agent "${agent.name}" has ${agent.subagents.length} subagent(s)`);
|
|
166
|
+
for (const subagent of agent.subagents)if ("subagents" in subagent && subagent.subagents) {
|
|
167
|
+
logger.warn(`Subagent "${subagent.name}" has its own subagents, which is not currently supported. Ignoring nested subagents.`);
|
|
168
|
+
subagent.subagents = [];
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
logger.info(`Loaded custom agent: ${agent.name} from ${dirPath}`);
|
|
172
|
+
return agent;
|
|
173
|
+
} catch (error) {
|
|
174
|
+
throw new Error(`Failed to load agent from ${dirPath}: ${error}`);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
async createAgent(config) {
|
|
178
|
+
const agent = {
|
|
179
|
+
name: config.name,
|
|
180
|
+
description: config.description,
|
|
181
|
+
systemPrompt: config.systemPrompt
|
|
182
|
+
};
|
|
183
|
+
const buildToolOptions = (source)=>{
|
|
184
|
+
const mcpConfigs = [];
|
|
185
|
+
if (source.mcp) mcpConfigs.push(source.mcp);
|
|
186
|
+
if (source.mcpUseGlobal && this.wingmanConfig?.mcp) mcpConfigs.push(this.wingmanConfig.mcp);
|
|
187
|
+
return {
|
|
188
|
+
workspace: this.workspace,
|
|
189
|
+
blockedCommands: source.blockedCommands,
|
|
190
|
+
allowScriptExecution: source.allowScriptExecution,
|
|
191
|
+
timeout: source.commandTimeout,
|
|
192
|
+
searchConfig: this.wingmanConfig?.search,
|
|
193
|
+
mcpConfigs
|
|
194
|
+
};
|
|
195
|
+
};
|
|
196
|
+
if (config.tools && config.tools.length > 0) agent.tools = await (0, external_toolRegistry_cjs_namespaceObject.createTools)(config.tools, buildToolOptions(config));
|
|
197
|
+
if (config.mcp) agent.mcpConfig = config.mcp;
|
|
198
|
+
if (config.mcpUseGlobal) agent.mcpUseGlobal = true;
|
|
199
|
+
if (config.model) try {
|
|
200
|
+
agent.model = external_modelFactory_cjs_namespaceObject.ModelFactory.createModel(config.model);
|
|
201
|
+
logger.info(`Agent "${config.name}" using model: ${config.model}`);
|
|
202
|
+
} catch (error) {
|
|
203
|
+
logger.error(`Failed to create model for agent "${config.name}": ${error}`);
|
|
204
|
+
logger.info(`Agent "${config.name}" will use default model`);
|
|
205
|
+
}
|
|
206
|
+
if (config.subAgents) {
|
|
207
|
+
const subagents = [];
|
|
208
|
+
for (const subagent of config.subAgents){
|
|
209
|
+
const sub = {
|
|
210
|
+
name: subagent.name,
|
|
211
|
+
description: subagent.description,
|
|
212
|
+
systemPrompt: subagent.systemPrompt
|
|
213
|
+
};
|
|
214
|
+
if (subagent.tools && subagent.tools.length > 0) sub.tools = await (0, external_toolRegistry_cjs_namespaceObject.createTools)(subagent.tools, buildToolOptions(subagent));
|
|
215
|
+
if (subagent.model) try {
|
|
216
|
+
sub.model = external_modelFactory_cjs_namespaceObject.ModelFactory.createModel(subagent.model);
|
|
217
|
+
logger.info(`Subagent "${subagent.name}" using model: ${subagent.model}`);
|
|
218
|
+
} catch (error) {
|
|
219
|
+
logger.error(`Failed to create model for subagent "${subagent.name}": ${error}`);
|
|
220
|
+
}
|
|
221
|
+
subagents.push(sub);
|
|
222
|
+
}
|
|
223
|
+
agent.subagents = subagents;
|
|
224
|
+
}
|
|
225
|
+
return agent;
|
|
226
|
+
}
|
|
227
|
+
constructor(configDir = external_agentConfig_cjs_namespaceObject.WingmanDirectory, workspace = process.cwd(), wingmanConfig){
|
|
228
|
+
_define_property(this, "configDir", void 0);
|
|
229
|
+
_define_property(this, "workspace", void 0);
|
|
230
|
+
_define_property(this, "wingmanConfig", void 0);
|
|
231
|
+
this.configDir = configDir;
|
|
232
|
+
this.workspace = workspace;
|
|
233
|
+
this.wingmanConfig = wingmanConfig;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
exports.AgentLoader = __webpack_exports__.AgentLoader;
|
|
237
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
238
|
+
"AgentLoader"
|
|
239
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
240
|
+
Object.defineProperty(exports, '__esModule', {
|
|
241
|
+
value: true
|
|
242
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { type WingmanAgentConfig } from "./agentConfig.js";
|
|
2
|
+
import type { WingmanAgent } from "@/types/agents.js";
|
|
3
|
+
import type { WingmanConfigType } from "../../cli/config/schema.js";
|
|
4
|
+
/**
|
|
5
|
+
* Load and validate agent configurations from multiple sources
|
|
6
|
+
*/
|
|
7
|
+
export declare class AgentLoader {
|
|
8
|
+
private configDir;
|
|
9
|
+
private workspace;
|
|
10
|
+
private wingmanConfig?;
|
|
11
|
+
constructor(configDir?: string, workspace?: string, wingmanConfig?: WingmanConfigType | undefined);
|
|
12
|
+
private resolveConfigPath;
|
|
13
|
+
loadAllAgentConfigs(): WingmanAgentConfig[];
|
|
14
|
+
/**
|
|
15
|
+
* Parse frontmatter from markdown content
|
|
16
|
+
*/
|
|
17
|
+
private parseFrontmatter;
|
|
18
|
+
/**
|
|
19
|
+
* Normalize legacy config fields
|
|
20
|
+
*/
|
|
21
|
+
private normalizeAgentConfig;
|
|
22
|
+
/**
|
|
23
|
+
* Load agent configuration from JSON file
|
|
24
|
+
*/
|
|
25
|
+
private loadFromJson;
|
|
26
|
+
/**
|
|
27
|
+
* Load agent configuration from markdown file
|
|
28
|
+
*/
|
|
29
|
+
private loadFromMarkdown;
|
|
30
|
+
/**
|
|
31
|
+
* Load a specific agent configuration by name
|
|
32
|
+
*/
|
|
33
|
+
loadAgent(agentName: string): Promise<WingmanAgent | undefined>;
|
|
34
|
+
/**
|
|
35
|
+
* Load agents from markdown files in a directory
|
|
36
|
+
*/
|
|
37
|
+
private loadFromDirectory;
|
|
38
|
+
/**
|
|
39
|
+
* Create a WingmanAgent instance from a user config
|
|
40
|
+
*/
|
|
41
|
+
private createAgent;
|
|
42
|
+
}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
|
|
2
|
+
import { isAbsolute, join } from "node:path";
|
|
3
|
+
import { load } from "js-yaml";
|
|
4
|
+
import { WingmanDirectory, validateAgentConfig } from "./agentConfig.js";
|
|
5
|
+
import { createTools } from "./toolRegistry.js";
|
|
6
|
+
import { ModelFactory } from "./modelFactory.js";
|
|
7
|
+
import { createLogger } from "../../logger.js";
|
|
8
|
+
function _define_property(obj, key, value) {
|
|
9
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
10
|
+
value: value,
|
|
11
|
+
enumerable: true,
|
|
12
|
+
configurable: true,
|
|
13
|
+
writable: true
|
|
14
|
+
});
|
|
15
|
+
else obj[key] = value;
|
|
16
|
+
return obj;
|
|
17
|
+
}
|
|
18
|
+
const logger = createLogger();
|
|
19
|
+
class AgentLoader {
|
|
20
|
+
resolveConfigPath(...segments) {
|
|
21
|
+
const baseDir = isAbsolute(this.configDir) ? this.configDir : join(this.workspace, this.configDir);
|
|
22
|
+
return join(baseDir, ...segments);
|
|
23
|
+
}
|
|
24
|
+
loadAllAgentConfigs() {
|
|
25
|
+
const agents = [];
|
|
26
|
+
const agentsDir = this.resolveConfigPath("agents");
|
|
27
|
+
if (existsSync(agentsDir) && statSync(agentsDir).isDirectory()) {
|
|
28
|
+
logger.info(`Loading agents from directory: ${agentsDir}`);
|
|
29
|
+
const agentDirs = readdirSync(agentsDir, {
|
|
30
|
+
withFileTypes: true
|
|
31
|
+
}).filter((dirent)=>dirent.isDirectory()).map((dirent)=>dirent.name);
|
|
32
|
+
for (const agentDir of agentDirs){
|
|
33
|
+
const agentDirPath = join(agentsDir, agentDir);
|
|
34
|
+
const agentJsonPath = join(agentDirPath, "agent.json");
|
|
35
|
+
const agentMarkdownPath = join(agentDirPath, "agent.md");
|
|
36
|
+
const hasJson = existsSync(agentJsonPath);
|
|
37
|
+
const hasMarkdown = existsSync(agentMarkdownPath);
|
|
38
|
+
if (!hasJson && !hasMarkdown) {
|
|
39
|
+
logger.warn(`Skipping ${agentDir}: agent.json or agent.md not found`);
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
try {
|
|
43
|
+
const agentFilePath = hasJson ? agentJsonPath : agentMarkdownPath;
|
|
44
|
+
const json = hasJson ? this.loadFromJson(agentJsonPath) : this.loadFromMarkdown(agentMarkdownPath, agentDirPath);
|
|
45
|
+
const validation = validateAgentConfig(json);
|
|
46
|
+
if (!validation.success) {
|
|
47
|
+
logger.error(`Failed to validate ${agentFilePath}:\n${validation.error}`);
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
agents.push(validation.data);
|
|
51
|
+
logger.info(`Loaded agent config: ${validation.data.name}`);
|
|
52
|
+
} catch (error) {
|
|
53
|
+
logger.error(`Failed to load agent from ${agentDirPath}: ${error}`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
} else logger.info(`No agents directory found at: ${agentsDir}`);
|
|
57
|
+
return agents;
|
|
58
|
+
}
|
|
59
|
+
parseFrontmatter(content) {
|
|
60
|
+
const frontmatterRegex = /^---\s*\n([\s\S]*?)\n---\s*\n([\s\S]*)$/;
|
|
61
|
+
const match = content.match(frontmatterRegex);
|
|
62
|
+
if (!match) throw new Error("Invalid agent.md format: missing frontmatter");
|
|
63
|
+
const [, frontmatter, prompt] = match;
|
|
64
|
+
try {
|
|
65
|
+
const metadata = load(frontmatter);
|
|
66
|
+
if (!metadata || "object" != typeof metadata) throw new Error("Frontmatter must be a valid YAML object");
|
|
67
|
+
return {
|
|
68
|
+
metadata,
|
|
69
|
+
prompt: prompt.trim()
|
|
70
|
+
};
|
|
71
|
+
} catch (error) {
|
|
72
|
+
throw new Error(`Failed to parse frontmatter: ${error}`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
normalizeAgentConfig(config) {
|
|
76
|
+
if (config.subagents && !config.subAgents) {
|
|
77
|
+
config.subAgents = config.subagents;
|
|
78
|
+
delete config.subagents;
|
|
79
|
+
}
|
|
80
|
+
if (Array.isArray(config.subAgents)) {
|
|
81
|
+
for (const subagent of config.subAgents)if (subagent?.subagents && !subagent.subAgents) {
|
|
82
|
+
subagent.subAgents = subagent.subagents;
|
|
83
|
+
delete subagent.subagents;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return config;
|
|
87
|
+
}
|
|
88
|
+
loadFromJson(filePath) {
|
|
89
|
+
const content = readFileSync(filePath, "utf-8");
|
|
90
|
+
const json = JSON.parse(content);
|
|
91
|
+
return this.normalizeAgentConfig(json);
|
|
92
|
+
}
|
|
93
|
+
loadFromMarkdown(filePath, agentDir) {
|
|
94
|
+
const content = readFileSync(filePath, "utf-8");
|
|
95
|
+
const { metadata, prompt } = this.parseFrontmatter(content);
|
|
96
|
+
const config = this.normalizeAgentConfig({
|
|
97
|
+
...metadata,
|
|
98
|
+
systemPrompt: prompt
|
|
99
|
+
});
|
|
100
|
+
if (config.subAgents && Array.isArray(config.subAgents)) {
|
|
101
|
+
for (const subagent of config.subAgents)if (subagent.promptFile) {
|
|
102
|
+
const promptPath = join(agentDir, subagent.promptFile);
|
|
103
|
+
if (!existsSync(promptPath)) throw new Error(`Subagent prompt file not found: ${promptPath}`);
|
|
104
|
+
const subagentContent = readFileSync(promptPath, "utf-8");
|
|
105
|
+
if (subagentContent.startsWith("---")) {
|
|
106
|
+
const parsed = this.parseFrontmatter(subagentContent);
|
|
107
|
+
Object.assign(subagent, parsed.metadata);
|
|
108
|
+
subagent.systemPrompt = parsed.prompt;
|
|
109
|
+
} else subagent.systemPrompt = subagentContent.trim();
|
|
110
|
+
delete subagent.promptFile;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return config;
|
|
114
|
+
}
|
|
115
|
+
async loadAgent(agentName) {
|
|
116
|
+
let agent;
|
|
117
|
+
const customAgentsDir = this.resolveConfigPath("agents", agentName);
|
|
118
|
+
if (existsSync(customAgentsDir) && statSync(customAgentsDir).isDirectory()) {
|
|
119
|
+
logger.info(`Loading agent from directory: ${customAgentsDir}`);
|
|
120
|
+
agent = await this.loadFromDirectory(customAgentsDir);
|
|
121
|
+
}
|
|
122
|
+
return agent;
|
|
123
|
+
}
|
|
124
|
+
async loadFromDirectory(dirPath) {
|
|
125
|
+
const agentJsonPath = join(dirPath, "agent.json");
|
|
126
|
+
const agentMarkdownPath = join(dirPath, "agent.md");
|
|
127
|
+
const hasJson = existsSync(agentJsonPath);
|
|
128
|
+
const hasMarkdown = existsSync(agentMarkdownPath);
|
|
129
|
+
try {
|
|
130
|
+
if (!hasJson && !hasMarkdown) throw new Error(`Agent config file not found: ${agentJsonPath} or ${agentMarkdownPath}`);
|
|
131
|
+
const json = hasJson ? this.loadFromJson(agentJsonPath) : this.loadFromMarkdown(agentMarkdownPath, dirPath);
|
|
132
|
+
logger.info(`Loading agent from ${hasJson ? "JSON" : "markdown"}: ${hasJson ? agentJsonPath : agentMarkdownPath}`);
|
|
133
|
+
const validation = validateAgentConfig(json);
|
|
134
|
+
if (!validation.success) throw new Error(`Failed to validate ${hasJson ? agentJsonPath : agentMarkdownPath}:\n${validation.error}`);
|
|
135
|
+
const agent = await this.createAgent(validation.data);
|
|
136
|
+
if (agent.subagents && agent.subagents.length > 0) {
|
|
137
|
+
logger.info(`Agent "${agent.name}" has ${agent.subagents.length} subagent(s)`);
|
|
138
|
+
for (const subagent of agent.subagents)if ("subagents" in subagent && subagent.subagents) {
|
|
139
|
+
logger.warn(`Subagent "${subagent.name}" has its own subagents, which is not currently supported. Ignoring nested subagents.`);
|
|
140
|
+
subagent.subagents = [];
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
logger.info(`Loaded custom agent: ${agent.name} from ${dirPath}`);
|
|
144
|
+
return agent;
|
|
145
|
+
} catch (error) {
|
|
146
|
+
throw new Error(`Failed to load agent from ${dirPath}: ${error}`);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
async createAgent(config) {
|
|
150
|
+
const agent = {
|
|
151
|
+
name: config.name,
|
|
152
|
+
description: config.description,
|
|
153
|
+
systemPrompt: config.systemPrompt
|
|
154
|
+
};
|
|
155
|
+
const buildToolOptions = (source)=>{
|
|
156
|
+
const mcpConfigs = [];
|
|
157
|
+
if (source.mcp) mcpConfigs.push(source.mcp);
|
|
158
|
+
if (source.mcpUseGlobal && this.wingmanConfig?.mcp) mcpConfigs.push(this.wingmanConfig.mcp);
|
|
159
|
+
return {
|
|
160
|
+
workspace: this.workspace,
|
|
161
|
+
blockedCommands: source.blockedCommands,
|
|
162
|
+
allowScriptExecution: source.allowScriptExecution,
|
|
163
|
+
timeout: source.commandTimeout,
|
|
164
|
+
searchConfig: this.wingmanConfig?.search,
|
|
165
|
+
mcpConfigs
|
|
166
|
+
};
|
|
167
|
+
};
|
|
168
|
+
if (config.tools && config.tools.length > 0) agent.tools = await createTools(config.tools, buildToolOptions(config));
|
|
169
|
+
if (config.mcp) agent.mcpConfig = config.mcp;
|
|
170
|
+
if (config.mcpUseGlobal) agent.mcpUseGlobal = true;
|
|
171
|
+
if (config.model) try {
|
|
172
|
+
agent.model = ModelFactory.createModel(config.model);
|
|
173
|
+
logger.info(`Agent "${config.name}" using model: ${config.model}`);
|
|
174
|
+
} catch (error) {
|
|
175
|
+
logger.error(`Failed to create model for agent "${config.name}": ${error}`);
|
|
176
|
+
logger.info(`Agent "${config.name}" will use default model`);
|
|
177
|
+
}
|
|
178
|
+
if (config.subAgents) {
|
|
179
|
+
const subagents = [];
|
|
180
|
+
for (const subagent of config.subAgents){
|
|
181
|
+
const sub = {
|
|
182
|
+
name: subagent.name,
|
|
183
|
+
description: subagent.description,
|
|
184
|
+
systemPrompt: subagent.systemPrompt
|
|
185
|
+
};
|
|
186
|
+
if (subagent.tools && subagent.tools.length > 0) sub.tools = await createTools(subagent.tools, buildToolOptions(subagent));
|
|
187
|
+
if (subagent.model) try {
|
|
188
|
+
sub.model = ModelFactory.createModel(subagent.model);
|
|
189
|
+
logger.info(`Subagent "${subagent.name}" using model: ${subagent.model}`);
|
|
190
|
+
} catch (error) {
|
|
191
|
+
logger.error(`Failed to create model for subagent "${subagent.name}": ${error}`);
|
|
192
|
+
}
|
|
193
|
+
subagents.push(sub);
|
|
194
|
+
}
|
|
195
|
+
agent.subagents = subagents;
|
|
196
|
+
}
|
|
197
|
+
return agent;
|
|
198
|
+
}
|
|
199
|
+
constructor(configDir = WingmanDirectory, workspace = process.cwd(), wingmanConfig){
|
|
200
|
+
_define_property(this, "configDir", void 0);
|
|
201
|
+
_define_property(this, "workspace", void 0);
|
|
202
|
+
_define_property(this, "wingmanConfig", void 0);
|
|
203
|
+
this.configDir = configDir;
|
|
204
|
+
this.workspace = workspace;
|
|
205
|
+
this.wingmanConfig = wingmanConfig;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
export { AgentLoader };
|
|
@@ -0,0 +1,168 @@
|
|
|
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
|
+
MCPClientManager: ()=>MCPClientManager
|
|
28
|
+
});
|
|
29
|
+
const mcp_adapters_namespaceObject = require("@langchain/mcp-adapters");
|
|
30
|
+
const tools_namespaceObject = require("@langchain/core/tools");
|
|
31
|
+
function _define_property(obj, key, value) {
|
|
32
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
33
|
+
value: value,
|
|
34
|
+
enumerable: true,
|
|
35
|
+
configurable: true,
|
|
36
|
+
writable: true
|
|
37
|
+
});
|
|
38
|
+
else obj[key] = value;
|
|
39
|
+
return obj;
|
|
40
|
+
}
|
|
41
|
+
class MCPClientManager {
|
|
42
|
+
mergeConfigs(configs) {
|
|
43
|
+
const serverMap = new Map();
|
|
44
|
+
for (const config of configs)if (config.servers) for (const server of config.servers)serverMap.set(server.name, server);
|
|
45
|
+
return Array.from(serverMap.values());
|
|
46
|
+
}
|
|
47
|
+
buildClientConfig() {
|
|
48
|
+
const clientConfig = {};
|
|
49
|
+
for (const server of this.serverConfigs)if ("stdio" === server.transport) {
|
|
50
|
+
const stdioServer = server;
|
|
51
|
+
const resolvedEnv = {};
|
|
52
|
+
for (const [key, value] of Object.entries(stdioServer.env || {}))resolvedEnv[key] = resolveEnvValue(value);
|
|
53
|
+
clientConfig[server.name] = {
|
|
54
|
+
transport: "stdio",
|
|
55
|
+
command: stdioServer.command,
|
|
56
|
+
args: stdioServer.args || [],
|
|
57
|
+
env: resolvedEnv
|
|
58
|
+
};
|
|
59
|
+
} else if ("sse" === server.transport) {
|
|
60
|
+
const sseServer = server;
|
|
61
|
+
clientConfig[server.name] = {
|
|
62
|
+
transport: "sse",
|
|
63
|
+
url: sseServer.url,
|
|
64
|
+
headers: sseServer.headers || {}
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
return clientConfig;
|
|
68
|
+
}
|
|
69
|
+
async initialize() {
|
|
70
|
+
if (0 === this.serverConfigs.length) return void this.logger.debug("No MCP servers configured");
|
|
71
|
+
try {
|
|
72
|
+
const clientConfig = this.buildClientConfig();
|
|
73
|
+
this.logger.info(`Initializing MCP client with ${this.serverConfigs.length} server(s)`);
|
|
74
|
+
this.client = new mcp_adapters_namespaceObject.MultiServerMCPClient(clientConfig);
|
|
75
|
+
this.logger.info("MCP client initialized successfully");
|
|
76
|
+
} catch (error) {
|
|
77
|
+
this.logger.error(`Failed to initialize MCP client: ${error instanceof Error ? error.message : String(error)}`);
|
|
78
|
+
throw new Error(`MCP client initialization failed: ${error}`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
async getTools() {
|
|
82
|
+
if (!this.client) {
|
|
83
|
+
this.logger.debug("No MCP client initialized, returning empty tools array");
|
|
84
|
+
return [];
|
|
85
|
+
}
|
|
86
|
+
try {
|
|
87
|
+
this.logger.debug("Retrieving tools from MCP servers");
|
|
88
|
+
const tools = await this.client.getTools();
|
|
89
|
+
const sanitized = this.sanitizeToolNames(tools);
|
|
90
|
+
this.logger.info(`Retrieved ${sanitized.length} tool(s) from MCP servers`);
|
|
91
|
+
return sanitized;
|
|
92
|
+
} catch (error) {
|
|
93
|
+
this.logger.error(`Failed to retrieve MCP tools: ${error instanceof Error ? error.message : String(error)}`);
|
|
94
|
+
return [];
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
sanitizeToolNames(tools) {
|
|
98
|
+
const used = new Map();
|
|
99
|
+
const sanitize = (name)=>{
|
|
100
|
+
const base = name.replace(/[^a-zA-Z0-9_-]/g, "_").slice(0, 128);
|
|
101
|
+
return base.length > 0 ? base : "tool";
|
|
102
|
+
};
|
|
103
|
+
const uniqueName = (name)=>{
|
|
104
|
+
let candidate = sanitize(name);
|
|
105
|
+
let counter = used.get(candidate) || 0;
|
|
106
|
+
while(used.has(candidate)){
|
|
107
|
+
counter += 1;
|
|
108
|
+
const suffix = `_${counter}`;
|
|
109
|
+
candidate = `${sanitize(name).slice(0, 128 - suffix.length)}${suffix}`;
|
|
110
|
+
}
|
|
111
|
+
used.set(candidate, counter);
|
|
112
|
+
return candidate;
|
|
113
|
+
};
|
|
114
|
+
return tools.map((tool)=>{
|
|
115
|
+
const original = tool.name;
|
|
116
|
+
const sanitized = uniqueName(original);
|
|
117
|
+
if (sanitized === original) return tool;
|
|
118
|
+
const originalLabel = `Original tool name: ${original}`;
|
|
119
|
+
const description = tool.description ? `${tool.description}\n\n${originalLabel}` : originalLabel;
|
|
120
|
+
const schema = tool.schema ?? tool.inputSchema;
|
|
121
|
+
if (!schema) try {
|
|
122
|
+
tool.name = sanitized;
|
|
123
|
+
tool.description = description;
|
|
124
|
+
return tool;
|
|
125
|
+
} catch {
|
|
126
|
+
return tool;
|
|
127
|
+
}
|
|
128
|
+
return (0, tools_namespaceObject.tool)(async (input)=>tool.invoke(input), {
|
|
129
|
+
name: sanitized,
|
|
130
|
+
description,
|
|
131
|
+
schema
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
async cleanup() {
|
|
136
|
+
if (!this.client) return;
|
|
137
|
+
try {
|
|
138
|
+
this.logger.debug("Cleaning up MCP client");
|
|
139
|
+
this.client = null;
|
|
140
|
+
this.logger.debug("MCP client cleanup complete");
|
|
141
|
+
} catch (error) {
|
|
142
|
+
this.logger.warn(`Error during MCP cleanup: ${error instanceof Error ? error.message : String(error)}`);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
hasServers() {
|
|
146
|
+
return this.serverConfigs.length > 0;
|
|
147
|
+
}
|
|
148
|
+
constructor(configs, logger){
|
|
149
|
+
_define_property(this, "client", null);
|
|
150
|
+
_define_property(this, "logger", void 0);
|
|
151
|
+
_define_property(this, "serverConfigs", void 0);
|
|
152
|
+
this.logger = logger;
|
|
153
|
+
this.serverConfigs = this.mergeConfigs(configs);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
function resolveEnvValue(value) {
|
|
157
|
+
const match = value.match(/^\$\{([A-Z0-9_]+)\}$/);
|
|
158
|
+
if (!match) return value;
|
|
159
|
+
const envValue = process.env[match[1]];
|
|
160
|
+
return envValue ?? "";
|
|
161
|
+
}
|
|
162
|
+
exports.MCPClientManager = __webpack_exports__.MCPClientManager;
|
|
163
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
164
|
+
"MCPClientManager"
|
|
165
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
166
|
+
Object.defineProperty(exports, '__esModule', {
|
|
167
|
+
value: true
|
|
168
|
+
});
|