@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,634 @@
|
|
|
1
|
+
import { copyFileSync, existsSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import chalk from "chalk";
|
|
5
|
+
import { cancel, confirm as prompts_confirm, intro, isCancel, multiselect, note, outro, select as prompts_select, spinner, text as prompts_text } from "@clack/prompts";
|
|
6
|
+
import { OutputManager } from "../core/outputManager.js";
|
|
7
|
+
import { WingmanConfigSchema } from "../config/schema.js";
|
|
8
|
+
import { createLogger, getLogFilePath } from "../../logger.js";
|
|
9
|
+
import { listProviderSpecs, normalizeProviderName } from "../../providers/registry.js";
|
|
10
|
+
import { getCredentialsPath, resolveProviderToken, saveProviderToken } from "../../providers/credentials.js";
|
|
11
|
+
import { ModelFactory } from "../../agent/config/modelFactory.js";
|
|
12
|
+
const DEFAULT_AGENT_ID = "wingman";
|
|
13
|
+
const DEFAULT_AGENT_DESCRIPTION = "General-purpose coding assistant for this workspace.";
|
|
14
|
+
const DEFAULT_AGENT_PROMPT = "You are Wingman, a coding assistant for this repository.\nBe direct and concise. Ask clarifying questions when requirements are unclear.\nPrefer minimal diffs and safe changes. Avoid destructive actions unless asked.\nUse tools to inspect the codebase before editing.";
|
|
15
|
+
const DEFAULT_TOOLS = [
|
|
16
|
+
"code_search",
|
|
17
|
+
"git_status",
|
|
18
|
+
"command_execute",
|
|
19
|
+
"internet_search",
|
|
20
|
+
"think"
|
|
21
|
+
];
|
|
22
|
+
const DEFAULT_FS_ROOT = ".";
|
|
23
|
+
const DEFAULT_MODELS = {
|
|
24
|
+
anthropic: "anthropic:claude-sonnet-4-5",
|
|
25
|
+
openai: "openai:gpt-4o",
|
|
26
|
+
openrouter: "openrouter:openai/gpt-4o",
|
|
27
|
+
copilot: "copilot:gpt-4o",
|
|
28
|
+
xai: "xai:grok-beta"
|
|
29
|
+
};
|
|
30
|
+
async function executeInitCommand(args, options = {}) {
|
|
31
|
+
const outputManager = new OutputManager(args.outputMode);
|
|
32
|
+
const logger = createLogger(args.verbosity);
|
|
33
|
+
const workspace = options.workspace || process.cwd();
|
|
34
|
+
const configDir = options.configDir || ".wingman";
|
|
35
|
+
const configRoot = join(workspace, configDir);
|
|
36
|
+
const configPath = join(configRoot, "wingman.config.json");
|
|
37
|
+
try {
|
|
38
|
+
if (isHelpCommand(args.subcommand)) return void showInitHelp(outputManager, args.outputMode);
|
|
39
|
+
const optionMap = args.options || {};
|
|
40
|
+
const nonInteractive = "interactive" !== outputManager.getMode() || getBooleanOption(optionMap, [
|
|
41
|
+
"yes",
|
|
42
|
+
"non-interactive"
|
|
43
|
+
], false);
|
|
44
|
+
const skipConfig = getBooleanOption(optionMap, [
|
|
45
|
+
"skip-config"
|
|
46
|
+
], false);
|
|
47
|
+
const skipAgent = getBooleanOption(optionMap, [
|
|
48
|
+
"skip-agent"
|
|
49
|
+
], false);
|
|
50
|
+
const skipProvider = getBooleanOption(optionMap, [
|
|
51
|
+
"skip-provider"
|
|
52
|
+
], false);
|
|
53
|
+
const force = getBooleanOption(optionMap, [
|
|
54
|
+
"force"
|
|
55
|
+
], false);
|
|
56
|
+
const merge = getBooleanOption(optionMap, [
|
|
57
|
+
"merge"
|
|
58
|
+
], false);
|
|
59
|
+
const fsRoot = getStringOption(optionMap, [
|
|
60
|
+
"fs-root"
|
|
61
|
+
]) || DEFAULT_FS_ROOT;
|
|
62
|
+
const useClack = shouldUseClack(outputManager, nonInteractive);
|
|
63
|
+
renderInitBanner(outputManager, nonInteractive);
|
|
64
|
+
const bundledAgentsPath = resolveBundledAgentsPath();
|
|
65
|
+
const bundledAgents = bundledAgentsPath ? listBundledAgents(bundledAgentsPath) : [];
|
|
66
|
+
const explicitAgent = Boolean(args.agent?.trim()) || Boolean(args.subcommand) && !isHelpCommand(args.subcommand) && !args.subcommand.startsWith("-");
|
|
67
|
+
const agentPlan = await resolveAgentPlan({
|
|
68
|
+
explicitAgent,
|
|
69
|
+
defaultAgentId: resolveAgentId(args),
|
|
70
|
+
bundledAgents,
|
|
71
|
+
nonInteractive,
|
|
72
|
+
optionMap,
|
|
73
|
+
outputManager
|
|
74
|
+
});
|
|
75
|
+
const providerName = await resolveProviderSelection({
|
|
76
|
+
nonInteractive,
|
|
77
|
+
skipProvider,
|
|
78
|
+
optionMap,
|
|
79
|
+
outputManager
|
|
80
|
+
});
|
|
81
|
+
const model = await resolveModelSelection({
|
|
82
|
+
nonInteractive,
|
|
83
|
+
optionMap,
|
|
84
|
+
providerName,
|
|
85
|
+
outputManager
|
|
86
|
+
});
|
|
87
|
+
if (skipConfig) writeLine(outputManager, "Skipping config setup (--skip-config).");
|
|
88
|
+
else await runStep(useClack, "Writing workspace config", async ()=>handleConfigSetup({
|
|
89
|
+
configPath,
|
|
90
|
+
configRoot,
|
|
91
|
+
agentId: agentPlan.defaultAgentId,
|
|
92
|
+
fsRoot,
|
|
93
|
+
force,
|
|
94
|
+
merge,
|
|
95
|
+
nonInteractive,
|
|
96
|
+
outputManager
|
|
97
|
+
}));
|
|
98
|
+
if (skipAgent) writeLine(outputManager, "Skipping starter agent (--skip-agent).");
|
|
99
|
+
else await runStep(useClack, "Installing bundled agents", async ()=>handleAgentSetup({
|
|
100
|
+
configRoot,
|
|
101
|
+
agentId: agentPlan.defaultAgentId,
|
|
102
|
+
model,
|
|
103
|
+
force,
|
|
104
|
+
nonInteractive,
|
|
105
|
+
outputManager,
|
|
106
|
+
bundledAgentsPath,
|
|
107
|
+
copyAgents: agentPlan.copyAgents
|
|
108
|
+
}));
|
|
109
|
+
if (skipProvider) writeLine(outputManager, "Skipping provider setup (--skip-provider).");
|
|
110
|
+
else await runStep(useClack, "Connecting providers", async ()=>handleProviderSetup({
|
|
111
|
+
providerName,
|
|
112
|
+
optionMap,
|
|
113
|
+
nonInteractive,
|
|
114
|
+
outputManager
|
|
115
|
+
}));
|
|
116
|
+
if (useClack) outro(chalk.green("Wingman init complete."));
|
|
117
|
+
else {
|
|
118
|
+
writeLine(outputManager, "");
|
|
119
|
+
writeLine(outputManager, "Wingman init complete.");
|
|
120
|
+
}
|
|
121
|
+
writeLine(outputManager, `Workspace: ${workspace}`);
|
|
122
|
+
writeLine(outputManager, `Config: ${configPath}`);
|
|
123
|
+
writeLine(outputManager, `Agent: ${skipAgent ? "skipped" : agentPlan.defaultAgentId}`);
|
|
124
|
+
if (!model) writeLine(outputManager, "Note: No model set yet. Update your agent config with a model string.");
|
|
125
|
+
writeLine(outputManager, "");
|
|
126
|
+
writeLine(outputManager, "Next steps:");
|
|
127
|
+
writeLine(outputManager, ` 1) wingman agent --local --agent ${agentPlan.defaultAgentId} "hello"`);
|
|
128
|
+
writeLine(outputManager, " 2) wingman gateway start");
|
|
129
|
+
} catch (error) {
|
|
130
|
+
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
131
|
+
const logFile = getLogFilePath();
|
|
132
|
+
logger.error("Init command failed", {
|
|
133
|
+
error: errorMsg
|
|
134
|
+
});
|
|
135
|
+
if ("interactive" === outputManager.getMode()) {
|
|
136
|
+
console.error(`\nError: ${errorMsg}`);
|
|
137
|
+
console.error(`Logs: ${logFile}`);
|
|
138
|
+
process.exit(1);
|
|
139
|
+
} else {
|
|
140
|
+
outputManager.emitAgentError(error);
|
|
141
|
+
process.exit(1);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
function renderInitBanner(outputManager, nonInteractive) {
|
|
146
|
+
if ("interactive" !== outputManager.getMode() || nonInteractive) return;
|
|
147
|
+
const title = "__ ___ _ _ ____ __ __ _ _ _\n\\ \\ / / | \\ | |/ ___| \\/ | / \\ | \\ | |\n \\ \\ /\\ / /| | \\| | | _| |\\/| | / _ \\ | \\| |\n \\ V V / | | |\\ | |_| | | | |/ ___ \\| |\\ |\n \\_/\\_/ |_|_| \\_|\\____|_| |_/_/ \\_\\_| \\_|";
|
|
148
|
+
const accent = process.stdout.isTTY ? chalk.cyanBright : (text)=>text;
|
|
149
|
+
const muted = process.stdout.isTTY ? chalk.gray : (text)=>text;
|
|
150
|
+
const emphasis = process.stdout.isTTY ? chalk.whiteBright : (text)=>text;
|
|
151
|
+
intro(accent(title));
|
|
152
|
+
note(muted("We will set up config, install bundled agents, and connect providers."), emphasis("Wingman Init Wizard"));
|
|
153
|
+
note(muted("Press Enter to accept defaults."), emphasis("Tip"));
|
|
154
|
+
}
|
|
155
|
+
function isHelpCommand(subcommand) {
|
|
156
|
+
return [
|
|
157
|
+
"help",
|
|
158
|
+
"--help",
|
|
159
|
+
"-h"
|
|
160
|
+
].includes(subcommand);
|
|
161
|
+
}
|
|
162
|
+
function resolveAgentId(args) {
|
|
163
|
+
if (args.agent && args.agent.trim()) return args.agent.trim();
|
|
164
|
+
if (args.subcommand && !isHelpCommand(args.subcommand) && !args.subcommand.startsWith("-")) return args.subcommand.trim();
|
|
165
|
+
return DEFAULT_AGENT_ID;
|
|
166
|
+
}
|
|
167
|
+
async function resolveAgentPlan(input) {
|
|
168
|
+
const { explicitAgent, defaultAgentId, bundledAgents, nonInteractive, optionMap, outputManager } = input;
|
|
169
|
+
let nextDefaultAgent = sanitizeAgentId(defaultAgentId);
|
|
170
|
+
const availableAgents = bundledAgents.slice();
|
|
171
|
+
if (!explicitAgent && !nonInteractive && availableAgents.length > 0) nextDefaultAgent = await promptForDefaultAgent(availableAgents, nextDefaultAgent);
|
|
172
|
+
const rawAgentsList = getStringOption(optionMap, [
|
|
173
|
+
"agents"
|
|
174
|
+
]);
|
|
175
|
+
if (rawAgentsList) {
|
|
176
|
+
const selected = parseAgentList(rawAgentsList, availableAgents);
|
|
177
|
+
const unique = ensureIncludesDefault(selected, nextDefaultAgent, availableAgents);
|
|
178
|
+
return {
|
|
179
|
+
defaultAgentId: nextDefaultAgent,
|
|
180
|
+
copyAgents: unique
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
if (nonInteractive || 0 === availableAgents.length) return {
|
|
184
|
+
defaultAgentId: nextDefaultAgent
|
|
185
|
+
};
|
|
186
|
+
const copyAll = await promptConfirm("Copy all bundled agents?", true);
|
|
187
|
+
if (copyAll) return {
|
|
188
|
+
defaultAgentId: nextDefaultAgent
|
|
189
|
+
};
|
|
190
|
+
const selectedAgents = await promptForAgentSelection(availableAgents, nextDefaultAgent);
|
|
191
|
+
const finalAgents = ensureIncludesDefault(selectedAgents, nextDefaultAgent, availableAgents);
|
|
192
|
+
if (0 === finalAgents.length) {
|
|
193
|
+
writeLine(outputManager, "No bundled agents selected.");
|
|
194
|
+
return {
|
|
195
|
+
defaultAgentId: nextDefaultAgent,
|
|
196
|
+
copyAgents: []
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
return {
|
|
200
|
+
defaultAgentId: nextDefaultAgent,
|
|
201
|
+
copyAgents: finalAgents
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
function sanitizeAgentId(value) {
|
|
205
|
+
const trimmed = value.trim();
|
|
206
|
+
if (!trimmed) throw new Error("Agent name is required.");
|
|
207
|
+
if (trimmed.includes("/") || trimmed.includes("\\")) throw new Error("Agent name cannot include path separators.");
|
|
208
|
+
if (trimmed.includes("..")) throw new Error("Agent name cannot include '..'.");
|
|
209
|
+
return trimmed;
|
|
210
|
+
}
|
|
211
|
+
async function handleConfigSetup(input) {
|
|
212
|
+
const { configPath, configRoot, agentId, fsRoot, force, merge, nonInteractive, outputManager } = input;
|
|
213
|
+
const configExists = existsSync(configPath);
|
|
214
|
+
if (configExists && !force && !merge) {
|
|
215
|
+
if (nonInteractive) return void writeLine(outputManager, "Config already exists. Use --merge or --force to update it.");
|
|
216
|
+
const shouldMerge = await promptConfirm("Config exists. Update with recommended settings? (y/N): ", false);
|
|
217
|
+
if (!shouldMerge) return void writeLine(outputManager, "Leaving existing config unchanged.");
|
|
218
|
+
}
|
|
219
|
+
const nextConfig = configExists && !force ? mergeConfigFile(configPath, agentId, fsRoot) : buildDefaultConfig(agentId, fsRoot);
|
|
220
|
+
if (!nextConfig) return void writeLine(outputManager, "Config already has recommended settings.");
|
|
221
|
+
mkdirSync(configRoot, {
|
|
222
|
+
recursive: true
|
|
223
|
+
});
|
|
224
|
+
writeFileSync(configPath, JSON.stringify(nextConfig, null, 2));
|
|
225
|
+
writeLine(outputManager, `Saved config to ${configPath}`);
|
|
226
|
+
}
|
|
227
|
+
function mergeConfigFile(configPath, agentId, fsRoot) {
|
|
228
|
+
const raw = readFileSync(configPath, "utf-8");
|
|
229
|
+
let parsed;
|
|
230
|
+
try {
|
|
231
|
+
parsed = JSON.parse(raw);
|
|
232
|
+
} catch {
|
|
233
|
+
throw new Error("Existing wingman.config.json is invalid JSON. Use --force to overwrite.");
|
|
234
|
+
}
|
|
235
|
+
if (!parsed || "object" != typeof parsed || Array.isArray(parsed)) throw new Error("Existing wingman.config.json is not a JSON object. Use --force to overwrite.");
|
|
236
|
+
const { config, changed } = mergeConfigValues(parsed, agentId, fsRoot);
|
|
237
|
+
return changed ? config : null;
|
|
238
|
+
}
|
|
239
|
+
function mergeConfigValues(config, agentId, fsRoot) {
|
|
240
|
+
let changed = false;
|
|
241
|
+
const nextConfig = {
|
|
242
|
+
...config
|
|
243
|
+
};
|
|
244
|
+
if (!nextConfig.defaultAgent) {
|
|
245
|
+
nextConfig.defaultAgent = agentId;
|
|
246
|
+
changed = true;
|
|
247
|
+
}
|
|
248
|
+
const gatewayRaw = nextConfig.gateway;
|
|
249
|
+
const gateway = gatewayRaw && "object" == typeof gatewayRaw && !Array.isArray(gatewayRaw) ? {
|
|
250
|
+
...gatewayRaw
|
|
251
|
+
} : {};
|
|
252
|
+
const fsRootsRaw = gateway.fsRoots;
|
|
253
|
+
const fsRoots = Array.isArray(fsRootsRaw) ? [
|
|
254
|
+
...fsRootsRaw
|
|
255
|
+
] : [];
|
|
256
|
+
if (fsRoot && !fsRoots.includes(fsRoot)) {
|
|
257
|
+
fsRoots.push(fsRoot);
|
|
258
|
+
changed = true;
|
|
259
|
+
}
|
|
260
|
+
if (changed) nextConfig.gateway = {
|
|
261
|
+
...gateway,
|
|
262
|
+
fsRoots
|
|
263
|
+
};
|
|
264
|
+
return {
|
|
265
|
+
config: nextConfig,
|
|
266
|
+
changed
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
function buildDefaultConfig(agentId, fsRoot) {
|
|
270
|
+
const config = WingmanConfigSchema.parse({});
|
|
271
|
+
config.defaultAgent = agentId;
|
|
272
|
+
config.gateway = {
|
|
273
|
+
...config.gateway,
|
|
274
|
+
fsRoots: [
|
|
275
|
+
fsRoot
|
|
276
|
+
]
|
|
277
|
+
};
|
|
278
|
+
return config;
|
|
279
|
+
}
|
|
280
|
+
async function handleAgentSetup(input) {
|
|
281
|
+
const { configRoot, agentId, model, force, nonInteractive, outputManager, bundledAgentsPath, copyAgents } = input;
|
|
282
|
+
const copiedAgents = bundledAgentsPath ? copyBundledAgents({
|
|
283
|
+
bundledAgentsPath,
|
|
284
|
+
configRoot,
|
|
285
|
+
force,
|
|
286
|
+
outputManager,
|
|
287
|
+
agentNames: copyAgents
|
|
288
|
+
}) : new Set();
|
|
289
|
+
if (copiedAgents.size > 0) writeLine(outputManager, `Copied ${copiedAgents.size} bundled agent(s) to ${join(configRoot, "agents")}`);
|
|
290
|
+
const expectedAgentDir = join(configRoot, "agents", agentId);
|
|
291
|
+
const expectedAgentPath = join(expectedAgentDir, "agent.json");
|
|
292
|
+
const expectedAgentExists = existsSync(expectedAgentPath);
|
|
293
|
+
if (!expectedAgentExists) return void await createFallbackAgent({
|
|
294
|
+
configRoot,
|
|
295
|
+
agentId,
|
|
296
|
+
model,
|
|
297
|
+
force,
|
|
298
|
+
nonInteractive,
|
|
299
|
+
outputManager
|
|
300
|
+
});
|
|
301
|
+
if (model) applyModelToAgent(expectedAgentPath, model, outputManager);
|
|
302
|
+
}
|
|
303
|
+
function resolveBundledAgentsPath() {
|
|
304
|
+
const candidates = [
|
|
305
|
+
new URL("../../../../.wingman/agents", import.meta.url),
|
|
306
|
+
new URL("../../../.wingman/agents", import.meta.url)
|
|
307
|
+
];
|
|
308
|
+
for (const candidate of candidates){
|
|
309
|
+
const resolved = fileURLToPath(candidate);
|
|
310
|
+
if (existsSync(resolved) && statSync(resolved).isDirectory()) return resolved;
|
|
311
|
+
}
|
|
312
|
+
const cwdFallback = join(process.cwd(), ".wingman", "agents");
|
|
313
|
+
if (existsSync(cwdFallback) && statSync(cwdFallback).isDirectory()) return cwdFallback;
|
|
314
|
+
return null;
|
|
315
|
+
}
|
|
316
|
+
function listBundledAgents(bundledAgentsPath) {
|
|
317
|
+
return readdirSync(bundledAgentsPath, {
|
|
318
|
+
withFileTypes: true
|
|
319
|
+
}).filter((dirent)=>dirent.isDirectory()).map((dirent)=>dirent.name).sort((a, b)=>a.localeCompare(b));
|
|
320
|
+
}
|
|
321
|
+
function copyBundledAgents(input) {
|
|
322
|
+
const { bundledAgentsPath, configRoot, force, outputManager, agentNames } = input;
|
|
323
|
+
const available = listBundledAgents(bundledAgentsPath);
|
|
324
|
+
const entries = agentNames ? agentNames : available;
|
|
325
|
+
const copied = new Set();
|
|
326
|
+
const targetRoot = join(configRoot, "agents");
|
|
327
|
+
for (const entry of entries){
|
|
328
|
+
const sourceDir = join(bundledAgentsPath, entry);
|
|
329
|
+
const targetDir = join(targetRoot, entry);
|
|
330
|
+
if (existsSync(targetDir) && !force) {
|
|
331
|
+
writeLine(outputManager, `Agent "${entry}" already exists. Skipping (use --force to overwrite).`);
|
|
332
|
+
continue;
|
|
333
|
+
}
|
|
334
|
+
if (existsSync(targetDir) && force) rmSync(targetDir, {
|
|
335
|
+
recursive: true,
|
|
336
|
+
force: true
|
|
337
|
+
});
|
|
338
|
+
copyDirectory(sourceDir, targetDir);
|
|
339
|
+
copied.add(entry);
|
|
340
|
+
}
|
|
341
|
+
return copied;
|
|
342
|
+
}
|
|
343
|
+
function copyDirectory(source, target) {
|
|
344
|
+
mkdirSync(target, {
|
|
345
|
+
recursive: true
|
|
346
|
+
});
|
|
347
|
+
const entries = readdirSync(source, {
|
|
348
|
+
withFileTypes: true
|
|
349
|
+
});
|
|
350
|
+
for (const entry of entries){
|
|
351
|
+
const sourcePath = join(source, entry.name);
|
|
352
|
+
const targetPath = join(target, entry.name);
|
|
353
|
+
if (entry.isDirectory()) copyDirectory(sourcePath, targetPath);
|
|
354
|
+
else copyFileSync(sourcePath, targetPath);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
async function createFallbackAgent(input) {
|
|
358
|
+
const { configRoot, agentId, model, force, nonInteractive, outputManager } = input;
|
|
359
|
+
const agentDir = join(configRoot, "agents", agentId);
|
|
360
|
+
const agentPath = join(agentDir, "agent.json");
|
|
361
|
+
const agentExists = existsSync(agentPath);
|
|
362
|
+
if (agentExists && !force) {
|
|
363
|
+
if (nonInteractive) return void writeLine(outputManager, `Agent "${agentId}" already exists. Use --force to overwrite.`);
|
|
364
|
+
const shouldOverwrite = await promptConfirm(`Agent "${agentId}" exists. Overwrite? (y/N): `, false);
|
|
365
|
+
if (!shouldOverwrite) return void writeLine(outputManager, `Keeping existing agent "${agentId}".`);
|
|
366
|
+
}
|
|
367
|
+
mkdirSync(agentDir, {
|
|
368
|
+
recursive: true
|
|
369
|
+
});
|
|
370
|
+
const agentConfig = {
|
|
371
|
+
name: agentId,
|
|
372
|
+
description: DEFAULT_AGENT_DESCRIPTION,
|
|
373
|
+
systemPrompt: DEFAULT_AGENT_PROMPT,
|
|
374
|
+
tools: DEFAULT_TOOLS
|
|
375
|
+
};
|
|
376
|
+
if (model) agentConfig.model = model;
|
|
377
|
+
writeFileSync(agentPath, JSON.stringify(agentConfig, null, 2));
|
|
378
|
+
writeLine(outputManager, `Created starter agent at ${agentPath}`);
|
|
379
|
+
}
|
|
380
|
+
function applyModelToAgent(agentPath, model, outputManager) {
|
|
381
|
+
try {
|
|
382
|
+
const raw = readFileSync(agentPath, "utf-8");
|
|
383
|
+
const parsed = JSON.parse(raw);
|
|
384
|
+
parsed.model = model;
|
|
385
|
+
writeFileSync(agentPath, JSON.stringify(parsed, null, 2));
|
|
386
|
+
writeLine(outputManager, `Updated ${agentPath} with model ${model}`);
|
|
387
|
+
} catch {
|
|
388
|
+
writeLine(outputManager, `Unable to update model for ${agentPath}. Update manually.`);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
async function resolveProviderSelection(input) {
|
|
392
|
+
const { nonInteractive, skipProvider, optionMap, outputManager } = input;
|
|
393
|
+
if (skipProvider) return;
|
|
394
|
+
const providerOption = getStringOption(optionMap, [
|
|
395
|
+
"provider"
|
|
396
|
+
]);
|
|
397
|
+
if (providerOption) {
|
|
398
|
+
const normalized = normalizeProviderName(providerOption);
|
|
399
|
+
if (!normalized) throw new Error(`Unknown provider: ${providerOption}`);
|
|
400
|
+
return normalized;
|
|
401
|
+
}
|
|
402
|
+
if (nonInteractive) return;
|
|
403
|
+
const providers = listProviderSpecs("model");
|
|
404
|
+
const options = [
|
|
405
|
+
{
|
|
406
|
+
value: "__skip__",
|
|
407
|
+
label: "Skip for now"
|
|
408
|
+
},
|
|
409
|
+
...providers.map((provider)=>({
|
|
410
|
+
value: provider.name,
|
|
411
|
+
label: provider.label,
|
|
412
|
+
hint: provider.name
|
|
413
|
+
}))
|
|
414
|
+
];
|
|
415
|
+
const selection = await prompts_select({
|
|
416
|
+
message: "Choose a provider to configure",
|
|
417
|
+
options
|
|
418
|
+
});
|
|
419
|
+
if (isCancel(selection)) abortSetup();
|
|
420
|
+
if ("__skip__" === selection) return void writeLine(outputManager, "Skipping provider configuration.");
|
|
421
|
+
const normalized = normalizeProviderName(String(selection));
|
|
422
|
+
if (!normalized) throw new Error(`Unknown provider: ${String(selection)}`);
|
|
423
|
+
return normalized;
|
|
424
|
+
}
|
|
425
|
+
async function resolveModelSelection(input) {
|
|
426
|
+
const { nonInteractive, optionMap, providerName, outputManager } = input;
|
|
427
|
+
const explicitModel = getStringOption(optionMap, [
|
|
428
|
+
"model"
|
|
429
|
+
]);
|
|
430
|
+
if (explicitModel) {
|
|
431
|
+
validateModel(explicitModel);
|
|
432
|
+
return explicitModel;
|
|
433
|
+
}
|
|
434
|
+
const providers = listProviderSpecs("model");
|
|
435
|
+
const configuredProvider = providers.find((provider)=>"missing" !== resolveProviderToken(provider.name).source);
|
|
436
|
+
const suggestedProvider = providerName || configuredProvider?.name;
|
|
437
|
+
const suggestedModel = suggestedProvider ? DEFAULT_MODELS[suggestedProvider] : void 0;
|
|
438
|
+
if (nonInteractive) {
|
|
439
|
+
if (suggestedModel) return suggestedModel;
|
|
440
|
+
return;
|
|
441
|
+
}
|
|
442
|
+
const inputValue = await prompts_text({
|
|
443
|
+
message: "Model string (provider:model)",
|
|
444
|
+
placeholder: suggestedModel ? void 0 : "anthropic:claude-sonnet-4-5",
|
|
445
|
+
defaultValue: suggestedModel
|
|
446
|
+
});
|
|
447
|
+
if (isCancel(inputValue)) abortSetup();
|
|
448
|
+
const trimmed = String(inputValue ?? "").trim();
|
|
449
|
+
if (!trimmed && suggestedModel) return suggestedModel;
|
|
450
|
+
if (!trimmed) return void writeLine(outputManager, "Skipping model selection.");
|
|
451
|
+
validateModel(trimmed);
|
|
452
|
+
return trimmed;
|
|
453
|
+
}
|
|
454
|
+
function validateModel(model) {
|
|
455
|
+
const result = ModelFactory.validateModelString(model);
|
|
456
|
+
if (!result.valid) throw new Error(result.error || "Invalid model string.");
|
|
457
|
+
}
|
|
458
|
+
async function handleProviderSetup(input) {
|
|
459
|
+
const { providerName, optionMap, nonInteractive, outputManager } = input;
|
|
460
|
+
if (!providerName) return void writeLine(outputManager, "No provider selected.");
|
|
461
|
+
const status = resolveProviderToken(providerName);
|
|
462
|
+
if ("missing" !== status.source) return void writeLine(outputManager, `Provider "${providerName}" already configured (${status.source}).`);
|
|
463
|
+
const tokenOption = getTokenOption(optionMap);
|
|
464
|
+
if (tokenOption) {
|
|
465
|
+
saveProviderToken(providerName, tokenOption);
|
|
466
|
+
writeLine(outputManager, `Saved ${providerName} credentials to ${getCredentialsPath()}`);
|
|
467
|
+
return;
|
|
468
|
+
}
|
|
469
|
+
if (nonInteractive) return void writeLine(outputManager, `Missing credentials for "${providerName}". Run "wingman provider login ${providerName}" to add them.`);
|
|
470
|
+
const tokenInput = await prompts_text({
|
|
471
|
+
message: `Enter ${providerName} API key`,
|
|
472
|
+
placeholder: "sk-..."
|
|
473
|
+
});
|
|
474
|
+
if (isCancel(tokenInput)) abortSetup();
|
|
475
|
+
const token = String(tokenInput ?? "").trim();
|
|
476
|
+
if (!token) throw new Error("API key is required.");
|
|
477
|
+
saveProviderToken(providerName, token);
|
|
478
|
+
writeLine(outputManager, `Saved ${providerName} credentials to ${getCredentialsPath()}`);
|
|
479
|
+
}
|
|
480
|
+
function getTokenOption(options) {
|
|
481
|
+
const raw = getStringOption(options, [
|
|
482
|
+
"token"
|
|
483
|
+
]) ?? getStringOption(options, [
|
|
484
|
+
"api-key"
|
|
485
|
+
]) ?? getStringOption(options, [
|
|
486
|
+
"apiKey"
|
|
487
|
+
]);
|
|
488
|
+
if ("string" == typeof raw && raw.trim()) return raw.trim();
|
|
489
|
+
}
|
|
490
|
+
function getStringOption(options, keys) {
|
|
491
|
+
for (const key of keys){
|
|
492
|
+
const raw = options[key];
|
|
493
|
+
if ("string" == typeof raw && raw.trim()) return raw.trim();
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
function parseAgentList(raw, bundledAgents) {
|
|
497
|
+
const normalized = raw.split(/[,\s]+/).map((value)=>value.trim()).filter(Boolean);
|
|
498
|
+
if (0 === normalized.length) return [];
|
|
499
|
+
const unknown = normalized.filter((value)=>!bundledAgents.includes(value));
|
|
500
|
+
if (unknown.length > 0) throw new Error(`Unknown bundled agents: ${unknown.join(", ")}.`);
|
|
501
|
+
return Array.from(new Set(normalized));
|
|
502
|
+
}
|
|
503
|
+
function ensureIncludesDefault(agents, defaultAgent, bundledAgents) {
|
|
504
|
+
if (!bundledAgents.includes(defaultAgent)) return agents;
|
|
505
|
+
if (agents.includes(defaultAgent)) return agents;
|
|
506
|
+
return [
|
|
507
|
+
...agents,
|
|
508
|
+
defaultAgent
|
|
509
|
+
];
|
|
510
|
+
}
|
|
511
|
+
async function promptForDefaultAgent(agents, currentDefault) {
|
|
512
|
+
const choices = agents.length > 0 ? agents : [
|
|
513
|
+
currentDefault
|
|
514
|
+
];
|
|
515
|
+
const defaultValue = choices.includes(currentDefault) ? currentDefault : choices[0];
|
|
516
|
+
const selection = await prompts_select({
|
|
517
|
+
message: "Pick a default agent",
|
|
518
|
+
options: [
|
|
519
|
+
...choices.map((agent)=>({
|
|
520
|
+
value: agent,
|
|
521
|
+
label: agent
|
|
522
|
+
})),
|
|
523
|
+
{
|
|
524
|
+
value: "__custom__",
|
|
525
|
+
label: "Custom agent name"
|
|
526
|
+
}
|
|
527
|
+
],
|
|
528
|
+
initialValue: defaultValue
|
|
529
|
+
});
|
|
530
|
+
if (isCancel(selection)) abortSetup();
|
|
531
|
+
if ("__custom__" === selection) {
|
|
532
|
+
const input = await prompts_text({
|
|
533
|
+
message: "Default agent name",
|
|
534
|
+
placeholder: defaultValue
|
|
535
|
+
});
|
|
536
|
+
if (isCancel(input)) abortSetup();
|
|
537
|
+
const trimmed = String(input ?? "").trim();
|
|
538
|
+
if (!trimmed) return defaultValue;
|
|
539
|
+
return sanitizeAgentId(trimmed);
|
|
540
|
+
}
|
|
541
|
+
return sanitizeAgentId(String(selection));
|
|
542
|
+
}
|
|
543
|
+
async function promptForAgentSelection(agents, defaultAgent) {
|
|
544
|
+
const selection = await multiselect({
|
|
545
|
+
message: "Choose bundled agents to copy",
|
|
546
|
+
options: agents.map((agent)=>({
|
|
547
|
+
value: agent,
|
|
548
|
+
label: agent
|
|
549
|
+
})),
|
|
550
|
+
required: false,
|
|
551
|
+
initialValues: agents.includes(defaultAgent) ? [
|
|
552
|
+
defaultAgent
|
|
553
|
+
] : []
|
|
554
|
+
});
|
|
555
|
+
if (isCancel(selection)) abortSetup();
|
|
556
|
+
const values = Array.isArray(selection) ? selection.map((value)=>String(value)) : [];
|
|
557
|
+
return Array.from(new Set(values));
|
|
558
|
+
}
|
|
559
|
+
function getBooleanOption(options, keys, defaultValue) {
|
|
560
|
+
for (const key of keys){
|
|
561
|
+
const raw = options[key];
|
|
562
|
+
if ("boolean" == typeof raw) return raw;
|
|
563
|
+
if ("string" == typeof raw) {
|
|
564
|
+
if ("true" === raw.toLowerCase()) return true;
|
|
565
|
+
if ("false" === raw.toLowerCase()) return false;
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
return defaultValue;
|
|
569
|
+
}
|
|
570
|
+
function shouldUseClack(outputManager, nonInteractive) {
|
|
571
|
+
return "interactive" === outputManager.getMode() && !nonInteractive;
|
|
572
|
+
}
|
|
573
|
+
function abortSetup() {
|
|
574
|
+
cancel("Setup cancelled.");
|
|
575
|
+
process.exit(0);
|
|
576
|
+
}
|
|
577
|
+
async function runStep(useClack, label, handler) {
|
|
578
|
+
if (!useClack) return handler();
|
|
579
|
+
const active = spinner();
|
|
580
|
+
active.start(label);
|
|
581
|
+
try {
|
|
582
|
+
const result = await handler();
|
|
583
|
+
active.stop(chalk.green("done"));
|
|
584
|
+
return result;
|
|
585
|
+
} catch (error) {
|
|
586
|
+
active.stop(chalk.red("failed"));
|
|
587
|
+
throw error;
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
async function promptConfirm(message, defaultValue) {
|
|
591
|
+
const response = await prompts_confirm({
|
|
592
|
+
message,
|
|
593
|
+
initialValue: defaultValue
|
|
594
|
+
});
|
|
595
|
+
if (isCancel(response)) abortSetup();
|
|
596
|
+
return Boolean(response);
|
|
597
|
+
}
|
|
598
|
+
function showInitHelp(outputManager, outputMode) {
|
|
599
|
+
if ("interactive" === outputMode) console.log(`
|
|
600
|
+
Wingman Init - Quickstart onboarding
|
|
601
|
+
|
|
602
|
+
Usage:
|
|
603
|
+
wingman init [options]
|
|
604
|
+
wingman init <agent-name>
|
|
605
|
+
|
|
606
|
+
Options:
|
|
607
|
+
--agent <name> Agent name (default: wingman)
|
|
608
|
+
--agents <list> Copy only these bundled agents (comma-separated)
|
|
609
|
+
--model <provider:model>
|
|
610
|
+
Set model for the starter agent
|
|
611
|
+
--provider <name> Provider to configure (anthropic|openai|openrouter|copilot|xai)
|
|
612
|
+
--token <token> Save provider token (non-interactive)
|
|
613
|
+
--api-key <key> Alias for --token
|
|
614
|
+
--fs-root <path> Add fs root (default: ".")
|
|
615
|
+
--skip-config Skip wingman.config.json setup
|
|
616
|
+
--skip-agent Skip starter agent creation
|
|
617
|
+
--skip-provider Skip provider credential setup
|
|
618
|
+
--merge Merge recommended settings into existing config
|
|
619
|
+
--force Overwrite existing config or agent files
|
|
620
|
+
--yes Accept defaults without prompts
|
|
621
|
+
|
|
622
|
+
Examples:
|
|
623
|
+
wingman init
|
|
624
|
+
wingman init coder --model openai:gpt-4o
|
|
625
|
+
wingman init --provider anthropic
|
|
626
|
+
wingman init --provider openai --api-key="sk-..."
|
|
627
|
+
`);
|
|
628
|
+
else outputManager.emitLog("info", "Init help requested");
|
|
629
|
+
}
|
|
630
|
+
function writeLine(outputManager, message) {
|
|
631
|
+
if ("interactive" === outputManager.getMode()) console.log(message);
|
|
632
|
+
else outputManager.emitLog("info", message);
|
|
633
|
+
}
|
|
634
|
+
export { executeInitCommand };
|