@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,246 @@
|
|
|
1
|
+
import { AgentLoader } from "../../agent/config/agentLoader.js";
|
|
2
|
+
import { getAvailableTools } from "../../agent/config/toolRegistry.js";
|
|
3
|
+
import { GatewayRouter } from "../router.js";
|
|
4
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
5
|
+
import { join } from "node:path";
|
|
6
|
+
import { dump, load } from "js-yaml";
|
|
7
|
+
import { AgentVoiceConfigSchema } from "../../types/voice.js";
|
|
8
|
+
const buildAgentMarkdown = (params)=>{
|
|
9
|
+
const { id, description, tools, model, prompt, voice } = params;
|
|
10
|
+
const metadata = {
|
|
11
|
+
name: id,
|
|
12
|
+
description: description || "New Wingman agent",
|
|
13
|
+
tools: tools || []
|
|
14
|
+
};
|
|
15
|
+
if (model) metadata.model = model;
|
|
16
|
+
if (voice) metadata.voice = voice;
|
|
17
|
+
return serializeAgentMarkdown(metadata, prompt || "You are a Wingman agent.");
|
|
18
|
+
};
|
|
19
|
+
const parseAgentMarkdown = (content)=>{
|
|
20
|
+
const frontmatterRegex = /^---\s*\n([\s\S]*?)\n---\s*\n?([\s\S]*)$/;
|
|
21
|
+
const match = content.match(frontmatterRegex);
|
|
22
|
+
if (!match) throw new Error("Invalid agent.md format: missing frontmatter");
|
|
23
|
+
const [, rawFrontmatter, prompt] = match;
|
|
24
|
+
const metadata = load(rawFrontmatter) || {};
|
|
25
|
+
return {
|
|
26
|
+
metadata,
|
|
27
|
+
prompt: prompt?.trim() || ""
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
const serializeAgentMarkdown = (metadata, prompt)=>{
|
|
31
|
+
const frontmatter = dump(metadata, {
|
|
32
|
+
lineWidth: 120
|
|
33
|
+
});
|
|
34
|
+
const safePrompt = prompt?.trim() || "You are a Wingman agent.";
|
|
35
|
+
return `---\n${frontmatter}---\n\n${safePrompt}\n`;
|
|
36
|
+
};
|
|
37
|
+
const handleAgentsApi = async (ctx, req, url)=>{
|
|
38
|
+
const config = ctx.getWingmanConfig();
|
|
39
|
+
if ("/api/agents" === url.pathname) {
|
|
40
|
+
if ("GET" === req.method) {
|
|
41
|
+
const loader = new AgentLoader(ctx.configDir, ctx.workspace, config);
|
|
42
|
+
const configs = loader.loadAllAgentConfigs();
|
|
43
|
+
const displayNames = config.agents?.list?.reduce((acc, agent)=>{
|
|
44
|
+
if (agent.name) acc[agent.id] = agent.name;
|
|
45
|
+
return acc;
|
|
46
|
+
}, {}) || {};
|
|
47
|
+
const agents = configs.map((agent)=>({
|
|
48
|
+
id: agent.name,
|
|
49
|
+
displayName: displayNames[agent.name] || agent.name,
|
|
50
|
+
description: agent.description,
|
|
51
|
+
tools: agent.tools || [],
|
|
52
|
+
model: agent.model,
|
|
53
|
+
voice: agent.voice,
|
|
54
|
+
subAgents: agent.subAgents?.map((sub)=>({
|
|
55
|
+
id: sub.name,
|
|
56
|
+
displayName: sub.name,
|
|
57
|
+
description: sub.description,
|
|
58
|
+
tools: sub.tools || [],
|
|
59
|
+
model: sub.model
|
|
60
|
+
})) || []
|
|
61
|
+
}));
|
|
62
|
+
return new Response(JSON.stringify({
|
|
63
|
+
agents,
|
|
64
|
+
tools: getAvailableTools(),
|
|
65
|
+
builtInTools: ctx.getBuiltInTools()
|
|
66
|
+
}, null, 2), {
|
|
67
|
+
headers: {
|
|
68
|
+
"Content-Type": "application/json"
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
if ("POST" === req.method) {
|
|
73
|
+
const body = await req.json();
|
|
74
|
+
let parsedVoice;
|
|
75
|
+
if (body?.voice !== void 0 && null !== body.voice) {
|
|
76
|
+
const voiceResult = AgentVoiceConfigSchema.safeParse(body.voice);
|
|
77
|
+
if (!voiceResult.success) return new Response("Invalid voice configuration", {
|
|
78
|
+
status: 400
|
|
79
|
+
});
|
|
80
|
+
parsedVoice = voiceResult.data;
|
|
81
|
+
}
|
|
82
|
+
const id = body?.id?.trim();
|
|
83
|
+
if (!id || !/^[a-zA-Z0-9_-]+$/.test(id)) return new Response("Invalid agent id", {
|
|
84
|
+
status: 400
|
|
85
|
+
});
|
|
86
|
+
const tools = Array.isArray(body.tools) ? body.tools.filter((tool)=>getAvailableTools().includes(tool)) : [];
|
|
87
|
+
const agentsDir = join(ctx.resolveConfigDirPath(), "agents", id);
|
|
88
|
+
if (existsSync(agentsDir)) return new Response("Agent already exists", {
|
|
89
|
+
status: 409
|
|
90
|
+
});
|
|
91
|
+
mkdirSync(agentsDir, {
|
|
92
|
+
recursive: true
|
|
93
|
+
});
|
|
94
|
+
const agentMarkdown = buildAgentMarkdown({
|
|
95
|
+
id,
|
|
96
|
+
description: body.description,
|
|
97
|
+
tools,
|
|
98
|
+
model: body.model,
|
|
99
|
+
prompt: body.prompt,
|
|
100
|
+
voice: parsedVoice
|
|
101
|
+
});
|
|
102
|
+
writeFileSync(join(agentsDir, "agent.md"), agentMarkdown);
|
|
103
|
+
const agentList = config.agents?.list || [];
|
|
104
|
+
agentList.push({
|
|
105
|
+
id,
|
|
106
|
+
name: body.displayName || id
|
|
107
|
+
});
|
|
108
|
+
const nextConfig = {
|
|
109
|
+
...config,
|
|
110
|
+
agents: {
|
|
111
|
+
list: agentList,
|
|
112
|
+
bindings: config.agents?.bindings || []
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
ctx.setWingmanConfig(nextConfig);
|
|
116
|
+
ctx.setRouter(new GatewayRouter(nextConfig));
|
|
117
|
+
ctx.persistWingmanConfig();
|
|
118
|
+
return new Response(JSON.stringify({
|
|
119
|
+
id,
|
|
120
|
+
displayName: body.displayName || id,
|
|
121
|
+
description: body.description,
|
|
122
|
+
tools,
|
|
123
|
+
model: body.model,
|
|
124
|
+
voice: parsedVoice
|
|
125
|
+
}, null, 2), {
|
|
126
|
+
headers: {
|
|
127
|
+
"Content-Type": "application/json"
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
return new Response("Method Not Allowed", {
|
|
132
|
+
status: 405
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
const agentDetailMatch = url.pathname.match(/^\/api\/agents\/([^/]+)$/);
|
|
136
|
+
if (!agentDetailMatch) return null;
|
|
137
|
+
const agentId = decodeURIComponent(agentDetailMatch[1]);
|
|
138
|
+
const loader = new AgentLoader(ctx.configDir, ctx.workspace, config);
|
|
139
|
+
const configs = loader.loadAllAgentConfigs();
|
|
140
|
+
const agentConfig = configs.find((item)=>item.name === agentId);
|
|
141
|
+
const displayName = config.agents?.list?.find((agent)=>agent.id === agentId)?.name || agentId;
|
|
142
|
+
if ("GET" === req.method) {
|
|
143
|
+
if (!agentConfig) return new Response("Agent not found", {
|
|
144
|
+
status: 404
|
|
145
|
+
});
|
|
146
|
+
return new Response(JSON.stringify({
|
|
147
|
+
id: agentConfig.name,
|
|
148
|
+
displayName,
|
|
149
|
+
description: agentConfig.description,
|
|
150
|
+
tools: agentConfig.tools || [],
|
|
151
|
+
model: agentConfig.model,
|
|
152
|
+
voice: agentConfig.voice,
|
|
153
|
+
prompt: agentConfig.systemPrompt
|
|
154
|
+
}, null, 2), {
|
|
155
|
+
headers: {
|
|
156
|
+
"Content-Type": "application/json"
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
if ("PUT" === req.method) {
|
|
161
|
+
if (!agentConfig) return new Response("Agent not found", {
|
|
162
|
+
status: 404
|
|
163
|
+
});
|
|
164
|
+
const body = await req.json();
|
|
165
|
+
let parsedVoice;
|
|
166
|
+
if (body?.voice === null) parsedVoice = null;
|
|
167
|
+
else if (body?.voice !== void 0) {
|
|
168
|
+
const voiceResult = AgentVoiceConfigSchema.safeParse(body.voice);
|
|
169
|
+
if (!voiceResult.success) return new Response("Invalid voice configuration", {
|
|
170
|
+
status: 400
|
|
171
|
+
});
|
|
172
|
+
parsedVoice = voiceResult.data;
|
|
173
|
+
}
|
|
174
|
+
const tools = Array.isArray(body.tools) ? body.tools.filter((tool)=>getAvailableTools().includes(tool)) : agentConfig.tools || [];
|
|
175
|
+
const nextDescription = body.description ?? agentConfig.description;
|
|
176
|
+
const nextModel = body.model ?? agentConfig.model;
|
|
177
|
+
const nextPrompt = body.prompt ?? agentConfig.systemPrompt;
|
|
178
|
+
const nextVoice = void 0 === parsedVoice ? agentConfig.voice : parsedVoice;
|
|
179
|
+
const agentsDir = join(ctx.resolveConfigDirPath(), "agents", agentId);
|
|
180
|
+
const agentJsonPath = join(agentsDir, "agent.json");
|
|
181
|
+
const agentMarkdownPath = join(agentsDir, "agent.md");
|
|
182
|
+
const hasJson = existsSync(agentJsonPath);
|
|
183
|
+
const hasMarkdown = existsSync(agentMarkdownPath);
|
|
184
|
+
if (!hasJson && !hasMarkdown) return new Response("Agent not found", {
|
|
185
|
+
status: 404
|
|
186
|
+
});
|
|
187
|
+
if (hasJson) {
|
|
188
|
+
const raw = readFileSync(agentJsonPath, "utf-8");
|
|
189
|
+
const parsed = JSON.parse(raw);
|
|
190
|
+
parsed.name = agentId;
|
|
191
|
+
parsed.description = nextDescription;
|
|
192
|
+
parsed.tools = tools;
|
|
193
|
+
if (nextModel) parsed.model = nextModel;
|
|
194
|
+
else delete parsed.model;
|
|
195
|
+
parsed.systemPrompt = nextPrompt;
|
|
196
|
+
if (nextVoice) parsed.voice = nextVoice;
|
|
197
|
+
else delete parsed.voice;
|
|
198
|
+
writeFileSync(agentJsonPath, JSON.stringify(parsed, null, 2));
|
|
199
|
+
} else if (hasMarkdown) {
|
|
200
|
+
const raw = readFileSync(agentMarkdownPath, "utf-8");
|
|
201
|
+
const { metadata } = parseAgentMarkdown(raw);
|
|
202
|
+
metadata.name = agentId;
|
|
203
|
+
metadata.description = nextDescription;
|
|
204
|
+
metadata.tools = tools;
|
|
205
|
+
if (nextModel) metadata.model = nextModel;
|
|
206
|
+
else delete metadata.model;
|
|
207
|
+
if (nextVoice) metadata.voice = nextVoice;
|
|
208
|
+
else delete metadata.voice;
|
|
209
|
+
const updatedMarkdown = serializeAgentMarkdown(metadata, nextPrompt);
|
|
210
|
+
writeFileSync(agentMarkdownPath, updatedMarkdown);
|
|
211
|
+
}
|
|
212
|
+
if (config.agents?.list) {
|
|
213
|
+
const nextList = config.agents.list.map((agent)=>agent.id === agentId ? {
|
|
214
|
+
...agent,
|
|
215
|
+
name: body.displayName || agent.name || agentId
|
|
216
|
+
} : agent);
|
|
217
|
+
const nextConfig = {
|
|
218
|
+
...config,
|
|
219
|
+
agents: {
|
|
220
|
+
list: nextList,
|
|
221
|
+
bindings: config.agents?.bindings || []
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
ctx.setWingmanConfig(nextConfig);
|
|
225
|
+
ctx.setRouter(new GatewayRouter(nextConfig));
|
|
226
|
+
ctx.persistWingmanConfig();
|
|
227
|
+
}
|
|
228
|
+
return new Response(JSON.stringify({
|
|
229
|
+
id: agentId,
|
|
230
|
+
displayName: body.displayName || displayName || agentId,
|
|
231
|
+
description: nextDescription,
|
|
232
|
+
tools,
|
|
233
|
+
model: nextModel,
|
|
234
|
+
voice: nextVoice,
|
|
235
|
+
prompt: nextPrompt
|
|
236
|
+
}, null, 2), {
|
|
237
|
+
headers: {
|
|
238
|
+
"Content-Type": "application/json"
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
return new Response("Method Not Allowed", {
|
|
243
|
+
status: 405
|
|
244
|
+
});
|
|
245
|
+
};
|
|
246
|
+
export { handleAgentsApi };
|
|
@@ -0,0 +1,81 @@
|
|
|
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
|
+
handleFsApi: ()=>handleFsApi
|
|
28
|
+
});
|
|
29
|
+
const external_node_fs_namespaceObject = require("node:fs");
|
|
30
|
+
const external_node_path_namespaceObject = require("node:path");
|
|
31
|
+
const handleFsApi = async (ctx, req, url)=>{
|
|
32
|
+
if ("/api/fs/roots" === url.pathname && "GET" === req.method) {
|
|
33
|
+
const roots = ctx.resolveFsRoots();
|
|
34
|
+
return new Response(JSON.stringify({
|
|
35
|
+
roots
|
|
36
|
+
}, null, 2), {
|
|
37
|
+
headers: {
|
|
38
|
+
"Content-Type": "application/json"
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
if ("/api/fs/list" === url.pathname && "GET" === req.method) {
|
|
43
|
+
const rawPath = url.searchParams.get("path");
|
|
44
|
+
if (!rawPath) return new Response("path required", {
|
|
45
|
+
status: 400
|
|
46
|
+
});
|
|
47
|
+
const resolved = ctx.resolveFsPath(rawPath);
|
|
48
|
+
const roots = ctx.resolveFsRoots();
|
|
49
|
+
if (!ctx.isPathWithinRoots(resolved, roots)) return new Response("path not allowed", {
|
|
50
|
+
status: 403
|
|
51
|
+
});
|
|
52
|
+
if (!(0, external_node_fs_namespaceObject.existsSync)(resolved) || !(0, external_node_fs_namespaceObject.statSync)(resolved).isDirectory()) return new Response("path not found", {
|
|
53
|
+
status: 404
|
|
54
|
+
});
|
|
55
|
+
const entries = (0, external_node_fs_namespaceObject.readdirSync)(resolved, {
|
|
56
|
+
withFileTypes: true
|
|
57
|
+
}).filter((entry)=>entry.isDirectory()).map((entry)=>({
|
|
58
|
+
name: entry.name,
|
|
59
|
+
path: (0, external_node_path_namespaceObject.join)(resolved, entry.name)
|
|
60
|
+
})).sort((a, b)=>a.name.localeCompare(b.name));
|
|
61
|
+
const parent = (0, external_node_path_namespaceObject.normalize)((0, external_node_path_namespaceObject.join)(resolved, ".."));
|
|
62
|
+
const parentAllowed = parent !== resolved && ctx.isPathWithinRoots(parent, roots) ? parent : null;
|
|
63
|
+
return new Response(JSON.stringify({
|
|
64
|
+
path: resolved,
|
|
65
|
+
parent: parentAllowed,
|
|
66
|
+
entries
|
|
67
|
+
}, null, 2), {
|
|
68
|
+
headers: {
|
|
69
|
+
"Content-Type": "application/json"
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
return null;
|
|
74
|
+
};
|
|
75
|
+
exports.handleFsApi = __webpack_exports__.handleFsApi;
|
|
76
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
77
|
+
"handleFsApi"
|
|
78
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
79
|
+
Object.defineProperty(exports, '__esModule', {
|
|
80
|
+
value: true
|
|
81
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { existsSync, readdirSync, statSync } from "node:fs";
|
|
2
|
+
import { join, normalize } from "node:path";
|
|
3
|
+
const handleFsApi = async (ctx, req, url)=>{
|
|
4
|
+
if ("/api/fs/roots" === url.pathname && "GET" === req.method) {
|
|
5
|
+
const roots = ctx.resolveFsRoots();
|
|
6
|
+
return new Response(JSON.stringify({
|
|
7
|
+
roots
|
|
8
|
+
}, null, 2), {
|
|
9
|
+
headers: {
|
|
10
|
+
"Content-Type": "application/json"
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
if ("/api/fs/list" === url.pathname && "GET" === req.method) {
|
|
15
|
+
const rawPath = url.searchParams.get("path");
|
|
16
|
+
if (!rawPath) return new Response("path required", {
|
|
17
|
+
status: 400
|
|
18
|
+
});
|
|
19
|
+
const resolved = ctx.resolveFsPath(rawPath);
|
|
20
|
+
const roots = ctx.resolveFsRoots();
|
|
21
|
+
if (!ctx.isPathWithinRoots(resolved, roots)) return new Response("path not allowed", {
|
|
22
|
+
status: 403
|
|
23
|
+
});
|
|
24
|
+
if (!existsSync(resolved) || !statSync(resolved).isDirectory()) return new Response("path not found", {
|
|
25
|
+
status: 404
|
|
26
|
+
});
|
|
27
|
+
const entries = readdirSync(resolved, {
|
|
28
|
+
withFileTypes: true
|
|
29
|
+
}).filter((entry)=>entry.isDirectory()).map((entry)=>({
|
|
30
|
+
name: entry.name,
|
|
31
|
+
path: join(resolved, entry.name)
|
|
32
|
+
})).sort((a, b)=>a.name.localeCompare(b.name));
|
|
33
|
+
const parent = normalize(join(resolved, ".."));
|
|
34
|
+
const parentAllowed = parent !== resolved && ctx.isPathWithinRoots(parent, roots) ? parent : null;
|
|
35
|
+
return new Response(JSON.stringify({
|
|
36
|
+
path: resolved,
|
|
37
|
+
parent: parentAllowed,
|
|
38
|
+
entries
|
|
39
|
+
}, null, 2), {
|
|
40
|
+
headers: {
|
|
41
|
+
"Content-Type": "application/json"
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
return null;
|
|
46
|
+
};
|
|
47
|
+
export { handleFsApi };
|
|
@@ -0,0 +1,120 @@
|
|
|
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
|
+
handleProvidersApi: ()=>handleProvidersApi
|
|
28
|
+
});
|
|
29
|
+
const credentials_cjs_namespaceObject = require("../../providers/credentials.cjs");
|
|
30
|
+
const registry_cjs_namespaceObject = require("../../providers/registry.cjs");
|
|
31
|
+
const handleProvidersApi = async (_ctx, req, url)=>{
|
|
32
|
+
if ("/api/providers" === url.pathname) {
|
|
33
|
+
if ("GET" === req.method) {
|
|
34
|
+
const credentials = (0, credentials_cjs_namespaceObject.readCredentialsFile)();
|
|
35
|
+
const providers = (0, registry_cjs_namespaceObject.listProviderSpecs)().map((provider)=>{
|
|
36
|
+
const resolved = (0, credentials_cjs_namespaceObject.resolveProviderToken)(provider.name);
|
|
37
|
+
return {
|
|
38
|
+
name: provider.name,
|
|
39
|
+
label: provider.label,
|
|
40
|
+
type: provider.type,
|
|
41
|
+
envVars: provider.envVars,
|
|
42
|
+
category: provider.category,
|
|
43
|
+
source: resolved.source,
|
|
44
|
+
envVar: resolved.envVar,
|
|
45
|
+
requiresAuth: provider.requiresAuth
|
|
46
|
+
};
|
|
47
|
+
});
|
|
48
|
+
return new Response(JSON.stringify({
|
|
49
|
+
providers,
|
|
50
|
+
credentialsPath: (0, credentials_cjs_namespaceObject.getCredentialsPath)(),
|
|
51
|
+
updatedAt: credentials?.updatedAt
|
|
52
|
+
}, null, 2), {
|
|
53
|
+
headers: {
|
|
54
|
+
"Content-Type": "application/json"
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
return new Response("Method Not Allowed", {
|
|
59
|
+
status: 405
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
const providerMatch = url.pathname.match(/^\/api\/providers\/([^/]+)$/);
|
|
63
|
+
if (!providerMatch) return null;
|
|
64
|
+
const providerName = decodeURIComponent(providerMatch[1]);
|
|
65
|
+
const provider = (0, registry_cjs_namespaceObject.getProviderSpec)(providerName);
|
|
66
|
+
if (!provider) return new Response("Unknown provider", {
|
|
67
|
+
status: 404
|
|
68
|
+
});
|
|
69
|
+
if ("POST" === req.method) {
|
|
70
|
+
const body = await req.json();
|
|
71
|
+
const token = (body?.token || body?.apiKey || "").trim();
|
|
72
|
+
if (!token) return new Response("Token required", {
|
|
73
|
+
status: 400
|
|
74
|
+
});
|
|
75
|
+
(0, credentials_cjs_namespaceObject.saveProviderToken)(provider.name, token);
|
|
76
|
+
const resolved = (0, credentials_cjs_namespaceObject.resolveProviderToken)(provider.name);
|
|
77
|
+
return new Response(JSON.stringify({
|
|
78
|
+
name: provider.name,
|
|
79
|
+
label: provider.label,
|
|
80
|
+
type: provider.type,
|
|
81
|
+
envVars: provider.envVars,
|
|
82
|
+
category: provider.category,
|
|
83
|
+
source: resolved.source,
|
|
84
|
+
envVar: resolved.envVar,
|
|
85
|
+
requiresAuth: provider.requiresAuth
|
|
86
|
+
}, null, 2), {
|
|
87
|
+
headers: {
|
|
88
|
+
"Content-Type": "application/json"
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
if ("DELETE" === req.method) {
|
|
93
|
+
(0, credentials_cjs_namespaceObject.deleteProviderCredentials)(provider.name);
|
|
94
|
+
const resolved = (0, credentials_cjs_namespaceObject.resolveProviderToken)(provider.name);
|
|
95
|
+
return new Response(JSON.stringify({
|
|
96
|
+
name: provider.name,
|
|
97
|
+
label: provider.label,
|
|
98
|
+
type: provider.type,
|
|
99
|
+
envVars: provider.envVars,
|
|
100
|
+
category: provider.category,
|
|
101
|
+
source: resolved.source,
|
|
102
|
+
envVar: resolved.envVar,
|
|
103
|
+
requiresAuth: provider.requiresAuth
|
|
104
|
+
}, null, 2), {
|
|
105
|
+
headers: {
|
|
106
|
+
"Content-Type": "application/json"
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
return new Response("Method Not Allowed", {
|
|
111
|
+
status: 405
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
exports.handleProvidersApi = __webpack_exports__.handleProvidersApi;
|
|
115
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
116
|
+
"handleProvidersApi"
|
|
117
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
118
|
+
Object.defineProperty(exports, '__esModule', {
|
|
119
|
+
value: true
|
|
120
|
+
});
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { deleteProviderCredentials, getCredentialsPath, readCredentialsFile, resolveProviderToken, saveProviderToken } from "../../providers/credentials.js";
|
|
2
|
+
import { getProviderSpec, listProviderSpecs } from "../../providers/registry.js";
|
|
3
|
+
const handleProvidersApi = async (_ctx, req, url)=>{
|
|
4
|
+
if ("/api/providers" === url.pathname) {
|
|
5
|
+
if ("GET" === req.method) {
|
|
6
|
+
const credentials = readCredentialsFile();
|
|
7
|
+
const providers = listProviderSpecs().map((provider)=>{
|
|
8
|
+
const resolved = resolveProviderToken(provider.name);
|
|
9
|
+
return {
|
|
10
|
+
name: provider.name,
|
|
11
|
+
label: provider.label,
|
|
12
|
+
type: provider.type,
|
|
13
|
+
envVars: provider.envVars,
|
|
14
|
+
category: provider.category,
|
|
15
|
+
source: resolved.source,
|
|
16
|
+
envVar: resolved.envVar,
|
|
17
|
+
requiresAuth: provider.requiresAuth
|
|
18
|
+
};
|
|
19
|
+
});
|
|
20
|
+
return new Response(JSON.stringify({
|
|
21
|
+
providers,
|
|
22
|
+
credentialsPath: getCredentialsPath(),
|
|
23
|
+
updatedAt: credentials?.updatedAt
|
|
24
|
+
}, null, 2), {
|
|
25
|
+
headers: {
|
|
26
|
+
"Content-Type": "application/json"
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
return new Response("Method Not Allowed", {
|
|
31
|
+
status: 405
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
const providerMatch = url.pathname.match(/^\/api\/providers\/([^/]+)$/);
|
|
35
|
+
if (!providerMatch) return null;
|
|
36
|
+
const providerName = decodeURIComponent(providerMatch[1]);
|
|
37
|
+
const provider = getProviderSpec(providerName);
|
|
38
|
+
if (!provider) return new Response("Unknown provider", {
|
|
39
|
+
status: 404
|
|
40
|
+
});
|
|
41
|
+
if ("POST" === req.method) {
|
|
42
|
+
const body = await req.json();
|
|
43
|
+
const token = (body?.token || body?.apiKey || "").trim();
|
|
44
|
+
if (!token) return new Response("Token required", {
|
|
45
|
+
status: 400
|
|
46
|
+
});
|
|
47
|
+
saveProviderToken(provider.name, token);
|
|
48
|
+
const resolved = resolveProviderToken(provider.name);
|
|
49
|
+
return new Response(JSON.stringify({
|
|
50
|
+
name: provider.name,
|
|
51
|
+
label: provider.label,
|
|
52
|
+
type: provider.type,
|
|
53
|
+
envVars: provider.envVars,
|
|
54
|
+
category: provider.category,
|
|
55
|
+
source: resolved.source,
|
|
56
|
+
envVar: resolved.envVar,
|
|
57
|
+
requiresAuth: provider.requiresAuth
|
|
58
|
+
}, null, 2), {
|
|
59
|
+
headers: {
|
|
60
|
+
"Content-Type": "application/json"
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
if ("DELETE" === req.method) {
|
|
65
|
+
deleteProviderCredentials(provider.name);
|
|
66
|
+
const resolved = resolveProviderToken(provider.name);
|
|
67
|
+
return new Response(JSON.stringify({
|
|
68
|
+
name: provider.name,
|
|
69
|
+
label: provider.label,
|
|
70
|
+
type: provider.type,
|
|
71
|
+
envVars: provider.envVars,
|
|
72
|
+
category: provider.category,
|
|
73
|
+
source: resolved.source,
|
|
74
|
+
envVar: resolved.envVar,
|
|
75
|
+
requiresAuth: provider.requiresAuth
|
|
76
|
+
}, null, 2), {
|
|
77
|
+
headers: {
|
|
78
|
+
"Content-Type": "application/json"
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
return new Response("Method Not Allowed", {
|
|
83
|
+
status: 405
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
export { handleProvidersApi };
|