@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,122 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { analyzeOptionStructure } from "./optionsAnalytics.js";
|
|
3
|
+
describe("optionsAnalytics", ()=>{
|
|
4
|
+
it("computes long call payoff metrics", ()=>{
|
|
5
|
+
const result = analyzeOptionStructure({
|
|
6
|
+
underlyingPrice: 100,
|
|
7
|
+
legs: [
|
|
8
|
+
{
|
|
9
|
+
type: "call",
|
|
10
|
+
side: "buy",
|
|
11
|
+
strike: 100,
|
|
12
|
+
premium: 5
|
|
13
|
+
}
|
|
14
|
+
]
|
|
15
|
+
});
|
|
16
|
+
expect(result.netDebit).toBeCloseTo(500, 2);
|
|
17
|
+
expect(result.maxProfit.unbounded).toBe(true);
|
|
18
|
+
expect(result.maxLoss.unbounded).toBe(false);
|
|
19
|
+
expect(result.maxLoss.usd).toBeCloseTo(500, 2);
|
|
20
|
+
expect(result.breakevens).toContain(105);
|
|
21
|
+
});
|
|
22
|
+
it("computes bull call debit spread metrics", ()=>{
|
|
23
|
+
const result = analyzeOptionStructure({
|
|
24
|
+
underlyingPrice: 100,
|
|
25
|
+
legs: [
|
|
26
|
+
{
|
|
27
|
+
type: "call",
|
|
28
|
+
side: "buy",
|
|
29
|
+
strike: 100,
|
|
30
|
+
premium: 5
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
type: "call",
|
|
34
|
+
side: "sell",
|
|
35
|
+
strike: 110,
|
|
36
|
+
premium: 2
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
});
|
|
40
|
+
expect(result.netDebit).toBeCloseTo(300, 2);
|
|
41
|
+
expect(result.maxProfit.unbounded).toBe(false);
|
|
42
|
+
expect(result.maxProfit.usd).toBeCloseTo(700, 2);
|
|
43
|
+
expect(result.maxLoss.usd).toBeCloseTo(300, 2);
|
|
44
|
+
expect(result.breakevens).toContain(103);
|
|
45
|
+
});
|
|
46
|
+
it("computes bear call credit spread metrics", ()=>{
|
|
47
|
+
const result = analyzeOptionStructure({
|
|
48
|
+
underlyingPrice: 100,
|
|
49
|
+
legs: [
|
|
50
|
+
{
|
|
51
|
+
type: "call",
|
|
52
|
+
side: "sell",
|
|
53
|
+
strike: 100,
|
|
54
|
+
premium: 5
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
type: "call",
|
|
58
|
+
side: "buy",
|
|
59
|
+
strike: 110,
|
|
60
|
+
premium: 2
|
|
61
|
+
}
|
|
62
|
+
]
|
|
63
|
+
});
|
|
64
|
+
expect(result.netCredit).toBeCloseTo(300, 2);
|
|
65
|
+
expect(result.maxProfit.unbounded).toBe(false);
|
|
66
|
+
expect(result.maxProfit.usd).toBeCloseTo(300, 2);
|
|
67
|
+
expect(result.maxLoss.usd).toBeCloseTo(700, 2);
|
|
68
|
+
expect(result.breakevens).toContain(103);
|
|
69
|
+
});
|
|
70
|
+
it("flags unbounded loss for naked short call", ()=>{
|
|
71
|
+
const result = analyzeOptionStructure({
|
|
72
|
+
underlyingPrice: 100,
|
|
73
|
+
legs: [
|
|
74
|
+
{
|
|
75
|
+
type: "call",
|
|
76
|
+
side: "sell",
|
|
77
|
+
strike: 100,
|
|
78
|
+
premium: 5
|
|
79
|
+
}
|
|
80
|
+
]
|
|
81
|
+
});
|
|
82
|
+
expect(result.maxLoss.unbounded).toBe(true);
|
|
83
|
+
expect(result.maxProfit.unbounded).toBe(false);
|
|
84
|
+
expect(result.maxProfit.usd).toBeCloseTo(500, 2);
|
|
85
|
+
expect(result.breakevens).toContain(105);
|
|
86
|
+
});
|
|
87
|
+
it("computes greeks when inputs provided", ()=>{
|
|
88
|
+
const result = analyzeOptionStructure({
|
|
89
|
+
underlyingPrice: 100,
|
|
90
|
+
daysToExpiry: 30,
|
|
91
|
+
riskFreeRate: 0.01,
|
|
92
|
+
legs: [
|
|
93
|
+
{
|
|
94
|
+
type: "call",
|
|
95
|
+
side: "buy",
|
|
96
|
+
strike: 100,
|
|
97
|
+
premium: 5,
|
|
98
|
+
impliedVol: 0.2
|
|
99
|
+
}
|
|
100
|
+
]
|
|
101
|
+
});
|
|
102
|
+
expect(result.greeks.status).toBe("ok");
|
|
103
|
+
expect(result.greeks.delta).toBeGreaterThan(0);
|
|
104
|
+
expect(result.greeks.theta).toBeLessThan(0);
|
|
105
|
+
});
|
|
106
|
+
it("returns insufficient-data greeks when missing IV", ()=>{
|
|
107
|
+
const result = analyzeOptionStructure({
|
|
108
|
+
underlyingPrice: 100,
|
|
109
|
+
daysToExpiry: 30,
|
|
110
|
+
legs: [
|
|
111
|
+
{
|
|
112
|
+
type: "call",
|
|
113
|
+
side: "buy",
|
|
114
|
+
strike: 100,
|
|
115
|
+
premium: 5
|
|
116
|
+
}
|
|
117
|
+
]
|
|
118
|
+
});
|
|
119
|
+
expect(result.greeks.status).toBe("insufficient-data");
|
|
120
|
+
expect(result.greeks.legsMissing).toBe(1);
|
|
121
|
+
});
|
|
122
|
+
});
|
|
@@ -0,0 +1,111 @@
|
|
|
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
|
+
buildTechnicalSnapshot: ()=>buildTechnicalSnapshot,
|
|
28
|
+
calculateAtr: ()=>calculateAtr,
|
|
29
|
+
calculateEma: ()=>calculateEma,
|
|
30
|
+
calculateRsi: ()=>calculateRsi
|
|
31
|
+
});
|
|
32
|
+
const calculateEma = (values, period)=>{
|
|
33
|
+
if (period <= 0 || values.length < period) return null;
|
|
34
|
+
let ema = 0;
|
|
35
|
+
for(let i = 0; i < period; i += 1)ema += values[i];
|
|
36
|
+
ema /= period;
|
|
37
|
+
const multiplier = 2 / (period + 1);
|
|
38
|
+
for(let i = period; i < values.length; i += 1)ema = values[i] * multiplier + ema * (1 - multiplier);
|
|
39
|
+
return ema;
|
|
40
|
+
};
|
|
41
|
+
const calculateRsi = (values, period)=>{
|
|
42
|
+
if (period <= 0 || values.length < period + 1) return null;
|
|
43
|
+
let gains = 0;
|
|
44
|
+
let losses = 0;
|
|
45
|
+
for(let i = 1; i <= period; i += 1){
|
|
46
|
+
const delta = values[i] - values[i - 1];
|
|
47
|
+
if (delta >= 0) gains += delta;
|
|
48
|
+
else losses -= delta;
|
|
49
|
+
}
|
|
50
|
+
let avgGain = gains / period;
|
|
51
|
+
let avgLoss = losses / period;
|
|
52
|
+
for(let i = period + 1; i < values.length; i += 1){
|
|
53
|
+
const delta = values[i] - values[i - 1];
|
|
54
|
+
const gain = delta > 0 ? delta : 0;
|
|
55
|
+
const loss = delta < 0 ? -delta : 0;
|
|
56
|
+
avgGain = (avgGain * (period - 1) + gain) / period;
|
|
57
|
+
avgLoss = (avgLoss * (period - 1) + loss) / period;
|
|
58
|
+
}
|
|
59
|
+
if (0 === avgLoss) return 100;
|
|
60
|
+
const rs = avgGain / avgLoss;
|
|
61
|
+
return 100 - 100 / (1 + rs);
|
|
62
|
+
};
|
|
63
|
+
const calculateAtr = (highs, lows, closes, period)=>{
|
|
64
|
+
if (period <= 0 || highs.length < period + 1 || lows.length < period + 1 || closes.length < period + 1) return null;
|
|
65
|
+
let atr = 0;
|
|
66
|
+
for(let i = 1; i <= period; i += 1){
|
|
67
|
+
const high = highs[i];
|
|
68
|
+
const low = lows[i];
|
|
69
|
+
const prevClose = closes[i - 1];
|
|
70
|
+
const tr = Math.max(high - low, Math.abs(high - prevClose), Math.abs(low - prevClose));
|
|
71
|
+
atr += tr;
|
|
72
|
+
}
|
|
73
|
+
atr /= period;
|
|
74
|
+
for(let i = period + 1; i < highs.length; i += 1){
|
|
75
|
+
const high = highs[i];
|
|
76
|
+
const low = lows[i];
|
|
77
|
+
const prevClose = closes[i - 1];
|
|
78
|
+
const tr = Math.max(high - low, Math.abs(high - prevClose), Math.abs(low - prevClose));
|
|
79
|
+
atr = (atr * (period - 1) + tr) / period;
|
|
80
|
+
}
|
|
81
|
+
return atr;
|
|
82
|
+
};
|
|
83
|
+
const buildTechnicalSnapshot = ({ closes, highs, lows })=>{
|
|
84
|
+
const lastClose = closes.at(-1) ?? null;
|
|
85
|
+
const ema20 = calculateEma(closes, 20);
|
|
86
|
+
const ema50 = calculateEma(closes, 50);
|
|
87
|
+
const ema200 = calculateEma(closes, 200);
|
|
88
|
+
const rsi14 = calculateRsi(closes, 14);
|
|
89
|
+
const atr14 = calculateAtr(highs, lows, closes, 14);
|
|
90
|
+
return {
|
|
91
|
+
lastClose,
|
|
92
|
+
ema20,
|
|
93
|
+
ema50,
|
|
94
|
+
ema200,
|
|
95
|
+
rsi14,
|
|
96
|
+
atr14
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
exports.buildTechnicalSnapshot = __webpack_exports__.buildTechnicalSnapshot;
|
|
100
|
+
exports.calculateAtr = __webpack_exports__.calculateAtr;
|
|
101
|
+
exports.calculateEma = __webpack_exports__.calculateEma;
|
|
102
|
+
exports.calculateRsi = __webpack_exports__.calculateRsi;
|
|
103
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
104
|
+
"buildTechnicalSnapshot",
|
|
105
|
+
"calculateAtr",
|
|
106
|
+
"calculateEma",
|
|
107
|
+
"calculateRsi"
|
|
108
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
109
|
+
Object.defineProperty(exports, '__esModule', {
|
|
110
|
+
value: true
|
|
111
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const calculateEma: (values: number[], period: number) => number | null;
|
|
2
|
+
export declare const calculateRsi: (values: number[], period: number) => number | null;
|
|
3
|
+
export declare const calculateAtr: (highs: number[], lows: number[], closes: number[], period: number) => number | null;
|
|
4
|
+
export declare const buildTechnicalSnapshot: ({ closes, highs, lows, }: {
|
|
5
|
+
closes: number[];
|
|
6
|
+
highs: number[];
|
|
7
|
+
lows: number[];
|
|
8
|
+
}) => {
|
|
9
|
+
lastClose: number | null;
|
|
10
|
+
ema20: number | null;
|
|
11
|
+
ema50: number | null;
|
|
12
|
+
ema200: number | null;
|
|
13
|
+
rsi14: number | null;
|
|
14
|
+
atr14: number | null;
|
|
15
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
const calculateEma = (values, period)=>{
|
|
2
|
+
if (period <= 0 || values.length < period) return null;
|
|
3
|
+
let ema = 0;
|
|
4
|
+
for(let i = 0; i < period; i += 1)ema += values[i];
|
|
5
|
+
ema /= period;
|
|
6
|
+
const multiplier = 2 / (period + 1);
|
|
7
|
+
for(let i = period; i < values.length; i += 1)ema = values[i] * multiplier + ema * (1 - multiplier);
|
|
8
|
+
return ema;
|
|
9
|
+
};
|
|
10
|
+
const calculateRsi = (values, period)=>{
|
|
11
|
+
if (period <= 0 || values.length < period + 1) return null;
|
|
12
|
+
let gains = 0;
|
|
13
|
+
let losses = 0;
|
|
14
|
+
for(let i = 1; i <= period; i += 1){
|
|
15
|
+
const delta = values[i] - values[i - 1];
|
|
16
|
+
if (delta >= 0) gains += delta;
|
|
17
|
+
else losses -= delta;
|
|
18
|
+
}
|
|
19
|
+
let avgGain = gains / period;
|
|
20
|
+
let avgLoss = losses / period;
|
|
21
|
+
for(let i = period + 1; i < values.length; i += 1){
|
|
22
|
+
const delta = values[i] - values[i - 1];
|
|
23
|
+
const gain = delta > 0 ? delta : 0;
|
|
24
|
+
const loss = delta < 0 ? -delta : 0;
|
|
25
|
+
avgGain = (avgGain * (period - 1) + gain) / period;
|
|
26
|
+
avgLoss = (avgLoss * (period - 1) + loss) / period;
|
|
27
|
+
}
|
|
28
|
+
if (0 === avgLoss) return 100;
|
|
29
|
+
const rs = avgGain / avgLoss;
|
|
30
|
+
return 100 - 100 / (1 + rs);
|
|
31
|
+
};
|
|
32
|
+
const calculateAtr = (highs, lows, closes, period)=>{
|
|
33
|
+
if (period <= 0 || highs.length < period + 1 || lows.length < period + 1 || closes.length < period + 1) return null;
|
|
34
|
+
let atr = 0;
|
|
35
|
+
for(let i = 1; i <= period; i += 1){
|
|
36
|
+
const high = highs[i];
|
|
37
|
+
const low = lows[i];
|
|
38
|
+
const prevClose = closes[i - 1];
|
|
39
|
+
const tr = Math.max(high - low, Math.abs(high - prevClose), Math.abs(low - prevClose));
|
|
40
|
+
atr += tr;
|
|
41
|
+
}
|
|
42
|
+
atr /= period;
|
|
43
|
+
for(let i = period + 1; i < highs.length; i += 1){
|
|
44
|
+
const high = highs[i];
|
|
45
|
+
const low = lows[i];
|
|
46
|
+
const prevClose = closes[i - 1];
|
|
47
|
+
const tr = Math.max(high - low, Math.abs(high - prevClose), Math.abs(low - prevClose));
|
|
48
|
+
atr = (atr * (period - 1) + tr) / period;
|
|
49
|
+
}
|
|
50
|
+
return atr;
|
|
51
|
+
};
|
|
52
|
+
const buildTechnicalSnapshot = ({ closes, highs, lows })=>{
|
|
53
|
+
const lastClose = closes.at(-1) ?? null;
|
|
54
|
+
const ema20 = calculateEma(closes, 20);
|
|
55
|
+
const ema50 = calculateEma(closes, 50);
|
|
56
|
+
const ema200 = calculateEma(closes, 200);
|
|
57
|
+
const rsi14 = calculateRsi(closes, 14);
|
|
58
|
+
const atr14 = calculateAtr(highs, lows, closes, 14);
|
|
59
|
+
return {
|
|
60
|
+
lastClose,
|
|
61
|
+
ema20,
|
|
62
|
+
ema50,
|
|
63
|
+
ema200,
|
|
64
|
+
rsi14,
|
|
65
|
+
atr14
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
export { buildTechnicalSnapshot, calculateAtr, calculateEma, calculateRsi };
|
|
@@ -0,0 +1,125 @@
|
|
|
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
|
+
buildYahooChartUrl: ()=>buildYahooChartUrl,
|
|
28
|
+
extractYahooCandles: ()=>extractYahooCandles,
|
|
29
|
+
mapYahooInterval: ()=>mapYahooInterval
|
|
30
|
+
});
|
|
31
|
+
const SUPPORTED_INTRADAY_MINUTES = new Set([
|
|
32
|
+
1,
|
|
33
|
+
2,
|
|
34
|
+
5,
|
|
35
|
+
15,
|
|
36
|
+
30,
|
|
37
|
+
60,
|
|
38
|
+
90
|
|
39
|
+
]);
|
|
40
|
+
const mapYahooInterval = (resolution)=>{
|
|
41
|
+
if (!resolution) return "1d";
|
|
42
|
+
const normalized = resolution.trim().toUpperCase();
|
|
43
|
+
if ("D" === normalized) return "1d";
|
|
44
|
+
if ("W" === normalized) return "1wk";
|
|
45
|
+
if ("M" === normalized) return "1mo";
|
|
46
|
+
if (/^\d+$/.test(normalized)) {
|
|
47
|
+
const minutes = Number.parseInt(normalized, 10);
|
|
48
|
+
if (SUPPORTED_INTRADAY_MINUTES.has(minutes)) return `${minutes}m`;
|
|
49
|
+
}
|
|
50
|
+
return "1d";
|
|
51
|
+
};
|
|
52
|
+
const buildYahooChartUrl = ({ baseUrl, symbol, from, to, interval, includePrePost })=>{
|
|
53
|
+
const url = new URL(`${baseUrl}/v8/finance/chart/${symbol}`);
|
|
54
|
+
url.searchParams.set("period1", String(from));
|
|
55
|
+
url.searchParams.set("period2", String(to));
|
|
56
|
+
url.searchParams.set("interval", interval);
|
|
57
|
+
url.searchParams.set("includePrePost", includePrePost ? "true" : "false");
|
|
58
|
+
url.searchParams.set("events", "div,splits");
|
|
59
|
+
return url.toString();
|
|
60
|
+
};
|
|
61
|
+
const extractYahooCandles = (payload)=>{
|
|
62
|
+
const error = payload.chart?.error;
|
|
63
|
+
if (error) return {
|
|
64
|
+
s: "error",
|
|
65
|
+
source: "yahoo",
|
|
66
|
+
error: error.description || error.code || "Unknown Yahoo error"
|
|
67
|
+
};
|
|
68
|
+
const result = payload.chart?.result?.[0];
|
|
69
|
+
const timestamps = result?.timestamp ?? [];
|
|
70
|
+
const quote = result?.indicators?.quote?.[0];
|
|
71
|
+
if (!Array.isArray(timestamps) || 0 === timestamps.length || !quote) return {
|
|
72
|
+
s: "no_data",
|
|
73
|
+
source: "yahoo"
|
|
74
|
+
};
|
|
75
|
+
const closes = quote.close ?? [];
|
|
76
|
+
const highs = quote.high ?? [];
|
|
77
|
+
const lows = quote.low ?? [];
|
|
78
|
+
const opens = quote.open ?? [];
|
|
79
|
+
const volumes = quote.volume ?? [];
|
|
80
|
+
const c = [];
|
|
81
|
+
const h = [];
|
|
82
|
+
const l = [];
|
|
83
|
+
const o = [];
|
|
84
|
+
const v = [];
|
|
85
|
+
const t = [];
|
|
86
|
+
for(let i = 0; i < timestamps.length; i += 1){
|
|
87
|
+
const close = closes[i];
|
|
88
|
+
const high = highs[i];
|
|
89
|
+
const low = lows[i];
|
|
90
|
+
if ("number" != typeof close || "number" != typeof high || "number" != typeof low) continue;
|
|
91
|
+
const open = opens[i];
|
|
92
|
+
const volume = volumes[i];
|
|
93
|
+
t.push(timestamps[i]);
|
|
94
|
+
c.push(close);
|
|
95
|
+
h.push(high);
|
|
96
|
+
l.push(low);
|
|
97
|
+
o.push("number" == typeof open ? open : close);
|
|
98
|
+
v.push("number" == typeof volume ? volume : 0);
|
|
99
|
+
}
|
|
100
|
+
if (0 === c.length) return {
|
|
101
|
+
s: "no_data",
|
|
102
|
+
source: "yahoo"
|
|
103
|
+
};
|
|
104
|
+
return {
|
|
105
|
+
c,
|
|
106
|
+
h,
|
|
107
|
+
l,
|
|
108
|
+
o,
|
|
109
|
+
t,
|
|
110
|
+
v,
|
|
111
|
+
s: "ok",
|
|
112
|
+
source: "yahoo"
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
exports.buildYahooChartUrl = __webpack_exports__.buildYahooChartUrl;
|
|
116
|
+
exports.extractYahooCandles = __webpack_exports__.extractYahooCandles;
|
|
117
|
+
exports.mapYahooInterval = __webpack_exports__.mapYahooInterval;
|
|
118
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
119
|
+
"buildYahooChartUrl",
|
|
120
|
+
"extractYahooCandles",
|
|
121
|
+
"mapYahooInterval"
|
|
122
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
123
|
+
Object.defineProperty(exports, '__esModule', {
|
|
124
|
+
value: true
|
|
125
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export type CandleSeries = {
|
|
2
|
+
c?: number[];
|
|
3
|
+
h?: number[];
|
|
4
|
+
l?: number[];
|
|
5
|
+
o?: number[];
|
|
6
|
+
t?: number[];
|
|
7
|
+
v?: number[];
|
|
8
|
+
s?: string;
|
|
9
|
+
source?: "yahoo";
|
|
10
|
+
error?: string;
|
|
11
|
+
};
|
|
12
|
+
export type YahooChartResponse = {
|
|
13
|
+
chart?: {
|
|
14
|
+
result?: Array<{
|
|
15
|
+
timestamp?: number[];
|
|
16
|
+
indicators?: {
|
|
17
|
+
quote?: Array<{
|
|
18
|
+
close?: Array<number | null>;
|
|
19
|
+
high?: Array<number | null>;
|
|
20
|
+
low?: Array<number | null>;
|
|
21
|
+
open?: Array<number | null>;
|
|
22
|
+
volume?: Array<number | null>;
|
|
23
|
+
}>;
|
|
24
|
+
};
|
|
25
|
+
}>;
|
|
26
|
+
error?: {
|
|
27
|
+
description?: string;
|
|
28
|
+
code?: string;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
export declare const mapYahooInterval: (resolution?: string) => string;
|
|
33
|
+
export declare const buildYahooChartUrl: ({ baseUrl, symbol, from, to, interval, includePrePost, }: {
|
|
34
|
+
baseUrl: string;
|
|
35
|
+
symbol: string;
|
|
36
|
+
from: number;
|
|
37
|
+
to: number;
|
|
38
|
+
interval: string;
|
|
39
|
+
includePrePost?: boolean;
|
|
40
|
+
}) => string;
|
|
41
|
+
export declare const extractYahooCandles: (payload: YahooChartResponse) => CandleSeries;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
const SUPPORTED_INTRADAY_MINUTES = new Set([
|
|
2
|
+
1,
|
|
3
|
+
2,
|
|
4
|
+
5,
|
|
5
|
+
15,
|
|
6
|
+
30,
|
|
7
|
+
60,
|
|
8
|
+
90
|
|
9
|
+
]);
|
|
10
|
+
const mapYahooInterval = (resolution)=>{
|
|
11
|
+
if (!resolution) return "1d";
|
|
12
|
+
const normalized = resolution.trim().toUpperCase();
|
|
13
|
+
if ("D" === normalized) return "1d";
|
|
14
|
+
if ("W" === normalized) return "1wk";
|
|
15
|
+
if ("M" === normalized) return "1mo";
|
|
16
|
+
if (/^\d+$/.test(normalized)) {
|
|
17
|
+
const minutes = Number.parseInt(normalized, 10);
|
|
18
|
+
if (SUPPORTED_INTRADAY_MINUTES.has(minutes)) return `${minutes}m`;
|
|
19
|
+
}
|
|
20
|
+
return "1d";
|
|
21
|
+
};
|
|
22
|
+
const buildYahooChartUrl = ({ baseUrl, symbol, from, to, interval, includePrePost })=>{
|
|
23
|
+
const url = new URL(`${baseUrl}/v8/finance/chart/${symbol}`);
|
|
24
|
+
url.searchParams.set("period1", String(from));
|
|
25
|
+
url.searchParams.set("period2", String(to));
|
|
26
|
+
url.searchParams.set("interval", interval);
|
|
27
|
+
url.searchParams.set("includePrePost", includePrePost ? "true" : "false");
|
|
28
|
+
url.searchParams.set("events", "div,splits");
|
|
29
|
+
return url.toString();
|
|
30
|
+
};
|
|
31
|
+
const extractYahooCandles = (payload)=>{
|
|
32
|
+
const error = payload.chart?.error;
|
|
33
|
+
if (error) return {
|
|
34
|
+
s: "error",
|
|
35
|
+
source: "yahoo",
|
|
36
|
+
error: error.description || error.code || "Unknown Yahoo error"
|
|
37
|
+
};
|
|
38
|
+
const result = payload.chart?.result?.[0];
|
|
39
|
+
const timestamps = result?.timestamp ?? [];
|
|
40
|
+
const quote = result?.indicators?.quote?.[0];
|
|
41
|
+
if (!Array.isArray(timestamps) || 0 === timestamps.length || !quote) return {
|
|
42
|
+
s: "no_data",
|
|
43
|
+
source: "yahoo"
|
|
44
|
+
};
|
|
45
|
+
const closes = quote.close ?? [];
|
|
46
|
+
const highs = quote.high ?? [];
|
|
47
|
+
const lows = quote.low ?? [];
|
|
48
|
+
const opens = quote.open ?? [];
|
|
49
|
+
const volumes = quote.volume ?? [];
|
|
50
|
+
const c = [];
|
|
51
|
+
const h = [];
|
|
52
|
+
const l = [];
|
|
53
|
+
const o = [];
|
|
54
|
+
const v = [];
|
|
55
|
+
const t = [];
|
|
56
|
+
for(let i = 0; i < timestamps.length; i += 1){
|
|
57
|
+
const close = closes[i];
|
|
58
|
+
const high = highs[i];
|
|
59
|
+
const low = lows[i];
|
|
60
|
+
if ("number" != typeof close || "number" != typeof high || "number" != typeof low) continue;
|
|
61
|
+
const open = opens[i];
|
|
62
|
+
const volume = volumes[i];
|
|
63
|
+
t.push(timestamps[i]);
|
|
64
|
+
c.push(close);
|
|
65
|
+
h.push(high);
|
|
66
|
+
l.push(low);
|
|
67
|
+
o.push("number" == typeof open ? open : close);
|
|
68
|
+
v.push("number" == typeof volume ? volume : 0);
|
|
69
|
+
}
|
|
70
|
+
if (0 === c.length) return {
|
|
71
|
+
s: "no_data",
|
|
72
|
+
source: "yahoo"
|
|
73
|
+
};
|
|
74
|
+
return {
|
|
75
|
+
c,
|
|
76
|
+
h,
|
|
77
|
+
l,
|
|
78
|
+
o,
|
|
79
|
+
t,
|
|
80
|
+
v,
|
|
81
|
+
s: "ok",
|
|
82
|
+
source: "yahoo"
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
export { buildYahooChartUrl, extractYahooCandles, mapYahooInterval };
|