opencandle 0.11.0 → 0.12.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/README.md +25 -28
- package/dist/analysts/contracts.js +0 -1
- package/dist/analysts/orchestrator.d.ts +2 -0
- package/dist/analysts/orchestrator.js +19 -1
- package/dist/cli-main.js +13 -7
- package/dist/cli-options.d.ts +4 -0
- package/dist/cli-options.js +33 -0
- package/dist/cli.js +8 -3
- package/dist/config.js +0 -1
- package/dist/doctor/cli-command.js +2 -1
- package/dist/doctor/render.js +0 -1
- package/dist/doctor/report.js +41 -12
- package/dist/gui/server/ask-user-bridge.d.ts +19 -0
- package/dist/gui/server/ask-user-bridge.js +55 -0
- package/dist/gui/server/automation-heartbeat.d.ts +25 -0
- package/dist/gui/server/automation-heartbeat.js +61 -0
- package/dist/gui/server/background-quotes.d.ts +39 -0
- package/dist/gui/server/background-quotes.js +71 -0
- package/dist/gui/server/chat-event-adapter.d.ts +16 -0
- package/dist/gui/server/chat-event-adapter.js +263 -0
- package/dist/gui/server/gui-session-manager.d.ts +2 -0
- package/dist/gui/server/gui-session-manager.js +4 -0
- package/dist/gui/server/http-routes.d.ts +69 -0
- package/dist/gui/server/http-routes.js +1008 -0
- package/dist/gui/server/invoke-tool.d.ts +47 -0
- package/dist/gui/server/invoke-tool.js +373 -0
- package/dist/gui/server/live-chat-event-adapter.d.ts +19 -0
- package/dist/gui/server/live-chat-event-adapter.js +206 -0
- package/dist/gui/server/local-session-coordinator.d.ts +26 -0
- package/dist/gui/server/local-session-coordinator.js +53 -0
- package/dist/gui/server/market-state-api.d.ts +138 -0
- package/dist/gui/server/market-state-api.js +355 -0
- package/dist/gui/server/model-setup.d.ts +64 -0
- package/dist/gui/server/model-setup.js +150 -0
- package/dist/gui/server/private-api-access.d.ts +6 -0
- package/dist/gui/server/private-api-access.js +53 -0
- package/dist/gui/server/projector.d.ts +49 -0
- package/dist/gui/server/projector.js +296 -0
- package/dist/gui/server/prompt-observation.d.ts +8 -0
- package/dist/gui/server/prompt-observation.js +43 -0
- package/dist/gui/server/quote-snapshot-store.d.ts +14 -0
- package/dist/gui/server/quote-snapshot-store.js +49 -0
- package/dist/gui/server/server.d.ts +1 -0
- package/dist/gui/server/server.js +259 -0
- package/dist/gui/server/session-actions.d.ts +60 -0
- package/dist/gui/server/session-actions.js +218 -0
- package/dist/gui/server/session-entry-wait.d.ts +27 -0
- package/dist/gui/server/session-entry-wait.js +129 -0
- package/dist/gui/server/session-list.d.ts +2 -0
- package/dist/gui/server/session-list.js +11 -0
- package/dist/gui/server/shutdown.d.ts +10 -0
- package/dist/gui/server/shutdown.js +29 -0
- package/dist/gui/server/tool-invoke-ack.d.ts +17 -0
- package/dist/gui/server/tool-invoke-ack.js +26 -0
- package/dist/gui/server/tool-metadata.d.ts +93 -0
- package/dist/gui/server/tool-metadata.js +148 -0
- package/dist/gui/server/websocket.d.ts +9 -0
- package/dist/gui/server/websocket.js +124 -0
- package/dist/gui/server/writer-lock.d.ts +1 -0
- package/dist/gui/server/writer-lock.js +1 -0
- package/dist/gui/server/ws-hub.d.ts +50 -0
- package/dist/gui/server/ws-hub.js +284 -0
- package/dist/gui/shared/chat-events.d.ts +174 -0
- package/dist/gui/shared/chat-events.js +13 -0
- package/dist/gui/shared/event-reducer.d.ts +3 -0
- package/dist/gui/shared/event-reducer.js +187 -0
- package/dist/index.js +0 -1
- package/dist/infra/cache.d.ts +6 -0
- package/dist/infra/cache.js +16 -7
- package/dist/infra/freshness.d.ts +21 -0
- package/dist/infra/freshness.js +118 -0
- package/dist/infra/http-client.js +1 -2
- package/dist/infra/index.js +0 -1
- package/dist/infra/market-calendar.d.ts +14 -0
- package/dist/infra/market-calendar.js +136 -0
- package/dist/infra/native-dependencies.js +0 -1
- package/dist/infra/node-version.js +0 -1
- package/dist/infra/open-url.js +0 -1
- package/dist/infra/opencandle-paths.js +0 -1
- package/dist/infra/rate-limiter.js +1 -1
- package/dist/market-state/alert-conditions.js +0 -1
- package/dist/market-state/alert-runner.d.ts +1 -0
- package/dist/market-state/alert-runner.js +5 -4
- package/dist/market-state/daily-report.js +0 -1
- package/dist/market-state/local-automation-service.js +0 -1
- package/dist/market-state/notification-delivery.js +0 -1
- package/dist/market-state/resolve-for-mutation.js +0 -1
- package/dist/market-state/resolve.js +0 -1
- package/dist/market-state/service.d.ts +26 -21
- package/dist/market-state/service.js +175 -36
- package/dist/market-state/summaries.d.ts +8 -0
- package/dist/market-state/summaries.js +58 -0
- package/dist/memory/index.js +0 -1
- package/dist/memory/manager.js +0 -1
- package/dist/memory/preference-extractor.js +0 -1
- package/dist/memory/retrieval.js +0 -1
- package/dist/memory/sqlite.js +60 -11
- package/dist/memory/storage.js +0 -1
- package/dist/memory/tool-defaults.js +0 -1
- package/dist/memory/types.js +0 -1
- package/dist/monitor.js +0 -1
- package/dist/onboarding/connect.js +0 -1
- package/dist/onboarding/credential-interceptor.js +0 -1
- package/dist/onboarding/degradation-accumulator.js +0 -1
- package/dist/onboarding/prompt-user.d.ts +1 -1
- package/dist/onboarding/prompt-user.js +0 -1
- package/dist/onboarding/provider-status.js +0 -1
- package/dist/onboarding/providers.d.ts +25 -1
- package/dist/onboarding/providers.js +26 -1
- package/dist/onboarding/state.js +0 -1
- package/dist/onboarding/tool-helpers.js +0 -1
- package/dist/onboarding/tool-tags.js +0 -1
- package/dist/onboarding/validate-model-key.d.ts +17 -0
- package/dist/onboarding/validate-model-key.js +54 -0
- package/dist/onboarding/validation.js +0 -1
- package/dist/pi/opencandle-extension.js +46 -7
- package/dist/pi/session-action-dedupe.js +0 -1
- package/dist/pi/session-storage.js +0 -1
- package/dist/pi/session-writer-lock.js +0 -1
- package/dist/pi/session.js +0 -1
- package/dist/pi/setup.d.ts +2 -0
- package/dist/pi/setup.js +10 -3
- package/dist/pi/tool-adapter.js +0 -1
- package/dist/pi/tui-session-coordinator.js +0 -1
- package/dist/prompts/context-builder.js +1 -2
- package/dist/prompts/disclaimer.js +0 -1
- package/dist/prompts/policy-cards.js +0 -1
- package/dist/prompts/sections.js +0 -1
- package/dist/prompts/symbol-preflight.js +0 -1
- package/dist/prompts/workflow-prompts.js +0 -1
- package/dist/providers/alpha-vantage.js +8 -3
- package/dist/providers/coingecko.js +1 -1
- package/dist/providers/errors.js +0 -1
- package/dist/providers/exa-search.js +11 -10
- package/dist/providers/external-tool-command.js +0 -1
- package/dist/providers/external-tool-error.js +0 -1
- package/dist/providers/fear-greed.js +0 -1
- package/dist/providers/finnhub.js +0 -1
- package/dist/providers/fred.js +0 -1
- package/dist/providers/index.js +0 -1
- package/dist/providers/polymarket.d.ts +2 -0
- package/dist/providers/polymarket.js +162 -0
- package/dist/providers/provider-credential-error.js +0 -1
- package/dist/providers/reddit-cli.js +0 -1
- package/dist/providers/reddit.js +0 -1
- package/dist/providers/sec-edgar.js +0 -1
- package/dist/providers/tradingview.js +1 -2
- package/dist/providers/twitter-cli.js +0 -1
- package/dist/providers/twitter.js +0 -1
- package/dist/providers/web-search.js +15 -12
- package/dist/providers/with-fallback.js +0 -1
- package/dist/providers/wrap-provider.js +5 -4
- package/dist/providers/yahoo-finance.d.ts +3 -0
- package/dist/providers/yahoo-finance.js +272 -13
- package/dist/routing/classify-intent.js +0 -1
- package/dist/routing/defaults.js +0 -1
- package/dist/routing/entity-extractor.js +18 -3
- package/dist/routing/fund-symbols.js +0 -1
- package/dist/routing/horizon.js +0 -1
- package/dist/routing/index.js +0 -1
- package/dist/routing/legacy-rule-router.js +0 -1
- package/dist/routing/planning.js +0 -1
- package/dist/routing/route-manifest.js +1 -2
- package/dist/routing/router-llm-client.d.ts +2 -2
- package/dist/routing/router-llm-client.js +18 -4
- package/dist/routing/router-prompt.js +0 -1
- package/dist/routing/router-types.js +0 -1
- package/dist/routing/router.d.ts +1 -1
- package/dist/routing/router.js +274 -6
- package/dist/routing/slot-resolver.d.ts +1 -0
- package/dist/routing/slot-resolver.js +1 -2
- package/dist/routing/symbol-disambiguator.js +0 -1
- package/dist/routing/turn-context.js +0 -1
- package/dist/routing/types.js +0 -1
- package/dist/runtime/answer-contracts.js +0 -1
- package/dist/runtime/artifact-contracts.js +0 -1
- package/dist/runtime/evidence.d.ts +1 -0
- package/dist/runtime/evidence.js +0 -1
- package/dist/runtime/numeric-claims.d.ts +23 -0
- package/dist/runtime/numeric-claims.js +99 -0
- package/dist/runtime/planning-evidence.js +1 -77
- package/dist/runtime/prompt-step.d.ts +10 -1
- package/dist/runtime/prompt-step.js +116 -3
- package/dist/runtime/provider-tracker.js +0 -1
- package/dist/runtime/run-context.js +0 -1
- package/dist/runtime/session-coordinator.d.ts +11 -1
- package/dist/runtime/session-coordinator.js +352 -50
- package/dist/runtime/session-title.js +0 -1
- package/dist/runtime/tool-defaults-wrapper.js +0 -1
- package/dist/runtime/validation.d.ts +3 -1
- package/dist/runtime/validation.js +0 -1
- package/dist/runtime/workflow-events.d.ts +1 -1
- package/dist/runtime/workflow-events.js +0 -1
- package/dist/runtime/workflow-runner.d.ts +1 -0
- package/dist/runtime/workflow-runner.js +8 -3
- package/dist/runtime/workflow-types.d.ts +3 -0
- package/dist/runtime/workflow-types.js +0 -1
- package/dist/sentiment/adapters/finnhub.js +0 -1
- package/dist/sentiment/adapters/reddit.js +0 -1
- package/dist/sentiment/adapters/twitter.js +0 -1
- package/dist/sentiment/adapters/web.js +0 -1
- package/dist/sentiment/index.js +4 -2
- package/dist/sentiment/insights.js +0 -1
- package/dist/sentiment/keywords.js +0 -1
- package/dist/sentiment/pipeline.js +0 -1
- package/dist/sentiment/scorer.js +0 -1
- package/dist/sentiment/store.js +0 -1
- package/dist/sentiment/trends.js +0 -1
- package/dist/sentiment/types.js +0 -1
- package/dist/system-prompt.js +0 -1
- package/dist/tool-kit.js +0 -1
- package/dist/tools/fundamentals/company-overview.d.ts +1 -1
- package/dist/tools/fundamentals/company-overview.js +2 -1
- package/dist/tools/fundamentals/comps.d.ts +1 -0
- package/dist/tools/fundamentals/comps.js +25 -12
- package/dist/tools/fundamentals/dcf.js +183 -113
- package/dist/tools/fundamentals/earnings.d.ts +1 -1
- package/dist/tools/fundamentals/earnings.js +2 -1
- package/dist/tools/fundamentals/financials.js +2 -1
- package/dist/tools/fundamentals/sec-filings.js +0 -1
- package/dist/tools/index.d.ts +117 -2
- package/dist/tools/index.js +3 -1
- package/dist/tools/interaction/ask-user.js +11 -1
- package/dist/tools/macro/event-probabilities.d.ts +8 -0
- package/dist/tools/macro/event-probabilities.js +120 -0
- package/dist/tools/macro/fear-greed.d.ts +1 -1
- package/dist/tools/macro/fear-greed.js +0 -1
- package/dist/tools/macro/fred-data.d.ts +1 -1
- package/dist/tools/macro/fred-data.js +2 -1
- package/dist/tools/market/crypto-history.js +0 -1
- package/dist/tools/market/crypto-price.d.ts +4 -1
- package/dist/tools/market/crypto-price.js +10 -2
- package/dist/tools/market/screen-stocks.js +14 -4
- package/dist/tools/market/search-ticker.js +1 -2
- package/dist/tools/market/stock-history.js +0 -1
- package/dist/tools/market/stock-quote.d.ts +4 -1
- package/dist/tools/market/stock-quote.js +9 -5
- package/dist/tools/options/greeks.js +0 -1
- package/dist/tools/options/option-chain.d.ts +4 -1
- package/dist/tools/options/option-chain.js +12 -2
- package/dist/tools/portfolio/alerts.d.ts +2 -1
- package/dist/tools/portfolio/alerts.js +228 -2
- package/dist/tools/portfolio/correlation.js +23 -5
- package/dist/tools/portfolio/daily-report.js +0 -1
- package/dist/tools/portfolio/holdings-overlap.js +0 -1
- package/dist/tools/portfolio/notifications.js +0 -1
- package/dist/tools/portfolio/risk-analysis.d.ts +1 -1
- package/dist/tools/portfolio/risk-analysis.js +1 -2
- package/dist/tools/portfolio/tracker.d.ts +3 -1
- package/dist/tools/portfolio/tracker.js +57 -10
- package/dist/tools/portfolio/watchlist.d.ts +3 -6
- package/dist/tools/portfolio/watchlist.js +101 -110
- package/dist/tools/sentiment/insight-format.js +0 -1
- package/dist/tools/sentiment/query-match.js +0 -1
- package/dist/tools/sentiment/reddit-sentiment.js +0 -1
- package/dist/tools/sentiment/sentiment-summary.js +8 -4
- package/dist/tools/sentiment/sentiment-trend.d.ts +5 -1
- package/dist/tools/sentiment/sentiment-trend.js +6 -2
- package/dist/tools/sentiment/twitter-sentiment.js +0 -1
- package/dist/tools/sentiment/untrusted-text.js +0 -1
- package/dist/tools/sentiment/web-search.d.ts +1 -1
- package/dist/tools/sentiment/web-search.js +0 -1
- package/dist/tools/sentiment/web-sentiment.js +0 -1
- package/dist/tools/technical/backtest.js +0 -1
- package/dist/tools/technical/indicators.js +1 -2
- package/dist/types/fundamentals.d.ts +1 -0
- package/dist/types/fundamentals.js +0 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +0 -1
- package/dist/types/macro.js +0 -1
- package/dist/types/market.d.ts +8 -0
- package/dist/types/market.js +0 -1
- package/dist/types/options.d.ts +1 -0
- package/dist/types/options.js +0 -1
- package/dist/types/portfolio.js +0 -1
- package/dist/types/prediction-markets.d.ts +13 -0
- package/dist/types/prediction-markets.js +1 -0
- package/dist/types/sentiment.js +0 -1
- package/dist/workflows/compare-assets.js +0 -1
- package/dist/workflows/index.js +0 -1
- package/dist/workflows/options-screener.js +0 -1
- package/dist/workflows/portfolio-builder.js +0 -1
- package/gui/web/dist/assets/CatalogOverlay-CAc7e3Pf.js +1 -0
- package/gui/web/dist/assets/index-BOEKd9wT.css +2 -0
- package/gui/web/dist/assets/index-C-H05cQ2.js +65 -0
- package/gui/web/dist/index.html +2 -2
- package/package.json +16 -22
- package/dist/analysts/contracts.js.map +0 -1
- package/dist/analysts/orchestrator.js.map +0 -1
- package/dist/cli-main.js.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/config.js.map +0 -1
- package/dist/doctor/cli-command.js.map +0 -1
- package/dist/doctor/render.js.map +0 -1
- package/dist/doctor/report.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/infra/cache.js.map +0 -1
- package/dist/infra/http-client.js.map +0 -1
- package/dist/infra/index.js.map +0 -1
- package/dist/infra/native-dependencies.js.map +0 -1
- package/dist/infra/node-version.js.map +0 -1
- package/dist/infra/open-url.js.map +0 -1
- package/dist/infra/opencandle-paths.js.map +0 -1
- package/dist/infra/rate-limiter.js.map +0 -1
- package/dist/market-state/alert-conditions.js.map +0 -1
- package/dist/market-state/alert-runner.js.map +0 -1
- package/dist/market-state/daily-report.js.map +0 -1
- package/dist/market-state/local-automation-service.js.map +0 -1
- package/dist/market-state/notification-delivery.js.map +0 -1
- package/dist/market-state/resolve-for-mutation.js.map +0 -1
- package/dist/market-state/resolve.js.map +0 -1
- package/dist/market-state/service.js.map +0 -1
- package/dist/memory/index.js.map +0 -1
- package/dist/memory/manager.js.map +0 -1
- package/dist/memory/preference-extractor.js.map +0 -1
- package/dist/memory/retrieval.js.map +0 -1
- package/dist/memory/sqlite.js.map +0 -1
- package/dist/memory/storage.js.map +0 -1
- package/dist/memory/tool-defaults.js.map +0 -1
- package/dist/memory/types.js.map +0 -1
- package/dist/monitor.js.map +0 -1
- package/dist/onboarding/connect.js.map +0 -1
- package/dist/onboarding/credential-interceptor.js.map +0 -1
- package/dist/onboarding/degradation-accumulator.js.map +0 -1
- package/dist/onboarding/prompt-user.js.map +0 -1
- package/dist/onboarding/provider-status.js.map +0 -1
- package/dist/onboarding/providers.js.map +0 -1
- package/dist/onboarding/state.js.map +0 -1
- package/dist/onboarding/tool-helpers.js.map +0 -1
- package/dist/onboarding/tool-tags.js.map +0 -1
- package/dist/onboarding/validation.js.map +0 -1
- package/dist/pi/opencandle-extension.js.map +0 -1
- package/dist/pi/session-action-dedupe.js.map +0 -1
- package/dist/pi/session-storage.js.map +0 -1
- package/dist/pi/session-writer-lock.js.map +0 -1
- package/dist/pi/session.js.map +0 -1
- package/dist/pi/setup.js.map +0 -1
- package/dist/pi/tool-adapter.js.map +0 -1
- package/dist/pi/tui-session-coordinator.js.map +0 -1
- package/dist/prompts/context-builder.js.map +0 -1
- package/dist/prompts/disclaimer.js.map +0 -1
- package/dist/prompts/policy-cards.js.map +0 -1
- package/dist/prompts/sections.js.map +0 -1
- package/dist/prompts/symbol-preflight.js.map +0 -1
- package/dist/prompts/workflow-prompts.js.map +0 -1
- package/dist/providers/alpha-vantage.js.map +0 -1
- package/dist/providers/coingecko.js.map +0 -1
- package/dist/providers/errors.js.map +0 -1
- package/dist/providers/exa-search.js.map +0 -1
- package/dist/providers/external-tool-command.js.map +0 -1
- package/dist/providers/external-tool-error.js.map +0 -1
- package/dist/providers/fear-greed.js.map +0 -1
- package/dist/providers/finnhub.js.map +0 -1
- package/dist/providers/fred.js.map +0 -1
- package/dist/providers/index.js.map +0 -1
- package/dist/providers/provider-credential-error.js.map +0 -1
- package/dist/providers/reddit-cli.js.map +0 -1
- package/dist/providers/reddit.js.map +0 -1
- package/dist/providers/sec-edgar.js.map +0 -1
- package/dist/providers/tradingview.js.map +0 -1
- package/dist/providers/twitter-cli.js.map +0 -1
- package/dist/providers/twitter.js.map +0 -1
- package/dist/providers/web-search.js.map +0 -1
- package/dist/providers/with-fallback.js.map +0 -1
- package/dist/providers/wrap-provider.js.map +0 -1
- package/dist/providers/yahoo-finance.js.map +0 -1
- package/dist/routing/classify-intent.js.map +0 -1
- package/dist/routing/defaults.js.map +0 -1
- package/dist/routing/entity-extractor.js.map +0 -1
- package/dist/routing/fund-symbols.js.map +0 -1
- package/dist/routing/horizon.js.map +0 -1
- package/dist/routing/index.js.map +0 -1
- package/dist/routing/legacy-rule-router.js.map +0 -1
- package/dist/routing/planning.js.map +0 -1
- package/dist/routing/route-manifest.js.map +0 -1
- package/dist/routing/router-llm-client.js.map +0 -1
- package/dist/routing/router-prompt.js.map +0 -1
- package/dist/routing/router-types.js.map +0 -1
- package/dist/routing/router.js.map +0 -1
- package/dist/routing/slot-resolver.js.map +0 -1
- package/dist/routing/symbol-disambiguator.js.map +0 -1
- package/dist/routing/turn-context.js.map +0 -1
- package/dist/routing/types.js.map +0 -1
- package/dist/runtime/answer-contracts.js.map +0 -1
- package/dist/runtime/artifact-contracts.js.map +0 -1
- package/dist/runtime/evidence.js.map +0 -1
- package/dist/runtime/planning-evidence.js.map +0 -1
- package/dist/runtime/prompt-step.js.map +0 -1
- package/dist/runtime/provider-tracker.js.map +0 -1
- package/dist/runtime/run-context.js.map +0 -1
- package/dist/runtime/session-coordinator.js.map +0 -1
- package/dist/runtime/session-title.js.map +0 -1
- package/dist/runtime/tool-defaults-wrapper.js.map +0 -1
- package/dist/runtime/validation.js.map +0 -1
- package/dist/runtime/workflow-events.js.map +0 -1
- package/dist/runtime/workflow-runner.js.map +0 -1
- package/dist/runtime/workflow-types.js.map +0 -1
- package/dist/sentiment/adapters/finnhub.js.map +0 -1
- package/dist/sentiment/adapters/reddit.js.map +0 -1
- package/dist/sentiment/adapters/twitter.js.map +0 -1
- package/dist/sentiment/adapters/web.js.map +0 -1
- package/dist/sentiment/index.js.map +0 -1
- package/dist/sentiment/insights.js.map +0 -1
- package/dist/sentiment/keywords.js.map +0 -1
- package/dist/sentiment/pipeline.js.map +0 -1
- package/dist/sentiment/scorer.js.map +0 -1
- package/dist/sentiment/store.js.map +0 -1
- package/dist/sentiment/trends.js.map +0 -1
- package/dist/sentiment/types.js.map +0 -1
- package/dist/system-prompt.js.map +0 -1
- package/dist/tool-kit.js.map +0 -1
- package/dist/tools/fundamentals/company-overview.js.map +0 -1
- package/dist/tools/fundamentals/comps.js.map +0 -1
- package/dist/tools/fundamentals/dcf.js.map +0 -1
- package/dist/tools/fundamentals/earnings.js.map +0 -1
- package/dist/tools/fundamentals/financials.js.map +0 -1
- package/dist/tools/fundamentals/sec-filings.js.map +0 -1
- package/dist/tools/index.js.map +0 -1
- package/dist/tools/interaction/ask-user.js.map +0 -1
- package/dist/tools/macro/fear-greed.js.map +0 -1
- package/dist/tools/macro/fred-data.js.map +0 -1
- package/dist/tools/market/crypto-history.js.map +0 -1
- package/dist/tools/market/crypto-price.js.map +0 -1
- package/dist/tools/market/screen-stocks.js.map +0 -1
- package/dist/tools/market/search-ticker.js.map +0 -1
- package/dist/tools/market/stock-history.js.map +0 -1
- package/dist/tools/market/stock-quote.js.map +0 -1
- package/dist/tools/options/greeks.js.map +0 -1
- package/dist/tools/options/option-chain.js.map +0 -1
- package/dist/tools/portfolio/alerts.js.map +0 -1
- package/dist/tools/portfolio/correlation.js.map +0 -1
- package/dist/tools/portfolio/daily-report.js.map +0 -1
- package/dist/tools/portfolio/holdings-overlap.js.map +0 -1
- package/dist/tools/portfolio/notifications.js.map +0 -1
- package/dist/tools/portfolio/risk-analysis.js.map +0 -1
- package/dist/tools/portfolio/tracker.js.map +0 -1
- package/dist/tools/portfolio/watchlist.js.map +0 -1
- package/dist/tools/sentiment/insight-format.js.map +0 -1
- package/dist/tools/sentiment/query-match.js.map +0 -1
- package/dist/tools/sentiment/reddit-sentiment.js.map +0 -1
- package/dist/tools/sentiment/sentiment-summary.js.map +0 -1
- package/dist/tools/sentiment/sentiment-trend.js.map +0 -1
- package/dist/tools/sentiment/twitter-sentiment.js.map +0 -1
- package/dist/tools/sentiment/untrusted-text.js.map +0 -1
- package/dist/tools/sentiment/web-search.js.map +0 -1
- package/dist/tools/sentiment/web-sentiment.js.map +0 -1
- package/dist/tools/technical/backtest.js.map +0 -1
- package/dist/tools/technical/indicators.js.map +0 -1
- package/dist/types/fundamentals.js.map +0 -1
- package/dist/types/index.js.map +0 -1
- package/dist/types/macro.js.map +0 -1
- package/dist/types/market.js.map +0 -1
- package/dist/types/options.js.map +0 -1
- package/dist/types/portfolio.js.map +0 -1
- package/dist/types/sentiment.js.map +0 -1
- package/dist/workflows/compare-assets.js.map +0 -1
- package/dist/workflows/index.js.map +0 -1
- package/dist/workflows/options-screener.js.map +0 -1
- package/dist/workflows/portfolio-builder.js.map +0 -1
- package/gui/server/ask-user-bridge.ts +0 -89
- package/gui/server/automation-heartbeat.ts +0 -97
- package/gui/server/background-quotes.ts +0 -127
- package/gui/server/chat-event-adapter.ts +0 -210
- package/gui/server/chat-run-session.ts +0 -16
- package/gui/server/gui-session-manager.ts +0 -5
- package/gui/server/http-routes.ts +0 -953
- package/gui/server/invoke-tool.ts +0 -489
- package/gui/server/live-chat-event-adapter.ts +0 -208
- package/gui/server/local-session-coordinator.ts +0 -97
- package/gui/server/market-state-api.ts +0 -273
- package/gui/server/model-setup.ts +0 -254
- package/gui/server/package.json +0 -5
- package/gui/server/private-api-access.ts +0 -62
- package/gui/server/projector.ts +0 -263
- package/gui/server/prompt-observation.ts +0 -58
- package/gui/server/quote-snapshot-store.ts +0 -50
- package/gui/server/server.ts +0 -289
- package/gui/server/session-actions.ts +0 -331
- package/gui/server/session-entry-wait.ts +0 -160
- package/gui/server/shutdown.ts +0 -47
- package/gui/server/tool-invoke-ack.ts +0 -49
- package/gui/server/tool-metadata.ts +0 -167
- package/gui/server/websocket.ts +0 -138
- package/gui/server/writer-lock.ts +0 -1
- package/gui/server/ws-hub.ts +0 -391
- package/gui/shared/chat-events.ts +0 -156
- package/gui/shared/event-reducer.ts +0 -219
- package/gui/web/dist/assets/CatalogOverlay-ChRTKNlf.js +0 -1
- package/gui/web/dist/assets/index-BzyqyVnd.css +0 -2
- package/gui/web/dist/assets/index-DvMjkOP9.js +0 -65
- package/src/analysts/contracts.ts +0 -176
- package/src/analysts/orchestrator.ts +0 -224
- package/src/cli-main.ts +0 -510
- package/src/cli.ts +0 -17
- package/src/config.ts +0 -272
- package/src/doctor/cli-command.ts +0 -83
- package/src/doctor/render.ts +0 -37
- package/src/doctor/report.ts +0 -638
- package/src/index.ts +0 -5
- package/src/infra/cache.ts +0 -114
- package/src/infra/http-client.ts +0 -134
- package/src/infra/index.ts +0 -14
- package/src/infra/native-dependencies.ts +0 -84
- package/src/infra/node-version.ts +0 -23
- package/src/infra/open-url.ts +0 -28
- package/src/infra/opencandle-paths.ts +0 -53
- package/src/infra/rate-limiter.ts +0 -76
- package/src/market-state/alert-conditions.ts +0 -82
- package/src/market-state/alert-runner.ts +0 -863
- package/src/market-state/daily-report.ts +0 -237
- package/src/market-state/local-automation-service.ts +0 -162
- package/src/market-state/notification-delivery.ts +0 -158
- package/src/market-state/resolve-for-mutation.ts +0 -24
- package/src/market-state/resolve.ts +0 -112
- package/src/market-state/service.ts +0 -2208
- package/src/memory/index.ts +0 -10
- package/src/memory/manager.ts +0 -190
- package/src/memory/preference-extractor.ts +0 -106
- package/src/memory/retrieval.ts +0 -71
- package/src/memory/sqlite.ts +0 -577
- package/src/memory/storage.ts +0 -195
- package/src/memory/tool-defaults.ts +0 -108
- package/src/memory/types.ts +0 -71
- package/src/monitor.ts +0 -123
- package/src/onboarding/connect.ts +0 -177
- package/src/onboarding/credential-interceptor.ts +0 -122
- package/src/onboarding/degradation-accumulator.ts +0 -77
- package/src/onboarding/prompt-user.ts +0 -85
- package/src/onboarding/provider-status.ts +0 -382
- package/src/onboarding/providers.ts +0 -414
- package/src/onboarding/state.ts +0 -216
- package/src/onboarding/tool-helpers.ts +0 -104
- package/src/onboarding/tool-tags.ts +0 -244
- package/src/onboarding/validation.ts +0 -152
- package/src/pi/opencandle-extension.ts +0 -1244
- package/src/pi/session-action-dedupe.ts +0 -155
- package/src/pi/session-storage.ts +0 -5
- package/src/pi/session-writer-lock.ts +0 -426
- package/src/pi/session.ts +0 -84
- package/src/pi/setup.ts +0 -399
- package/src/pi/tool-adapter.ts +0 -49
- package/src/pi/tui-session-coordinator.ts +0 -351
- package/src/prompts/context-builder.ts +0 -326
- package/src/prompts/disclaimer.ts +0 -9
- package/src/prompts/policy-cards.ts +0 -228
- package/src/prompts/sections.ts +0 -46
- package/src/prompts/symbol-preflight.ts +0 -80
- package/src/prompts/workflow-prompts.ts +0 -504
- package/src/providers/alpha-vantage.ts +0 -334
- package/src/providers/coingecko.ts +0 -93
- package/src/providers/errors.ts +0 -9
- package/src/providers/exa-search.ts +0 -375
- package/src/providers/external-tool-command.ts +0 -164
- package/src/providers/external-tool-error.ts +0 -20
- package/src/providers/fear-greed.ts +0 -45
- package/src/providers/finnhub.ts +0 -125
- package/src/providers/fred.ts +0 -83
- package/src/providers/index.ts +0 -17
- package/src/providers/provider-credential-error.ts +0 -23
- package/src/providers/reddit-cli.ts +0 -286
- package/src/providers/reddit.ts +0 -106
- package/src/providers/sec-edgar.ts +0 -326
- package/src/providers/tradingview.ts +0 -399
- package/src/providers/twitter-cli.ts +0 -202
- package/src/providers/twitter.ts +0 -102
- package/src/providers/web-search.ts +0 -303
- package/src/providers/with-fallback.ts +0 -42
- package/src/providers/wrap-provider.ts +0 -103
- package/src/providers/yahoo-finance.ts +0 -672
- package/src/routing/classify-intent.ts +0 -380
- package/src/routing/defaults.ts +0 -29
- package/src/routing/entity-extractor.ts +0 -540
- package/src/routing/fund-symbols.ts +0 -58
- package/src/routing/horizon.ts +0 -7
- package/src/routing/index.ts +0 -70
- package/src/routing/legacy-rule-router.ts +0 -13
- package/src/routing/planning.ts +0 -829
- package/src/routing/route-manifest.ts +0 -308
- package/src/routing/router-llm-client.ts +0 -52
- package/src/routing/router-prompt.ts +0 -159
- package/src/routing/router-types.ts +0 -84
- package/src/routing/router.ts +0 -997
- package/src/routing/slot-resolver.ts +0 -213
- package/src/routing/symbol-disambiguator.ts +0 -72
- package/src/routing/turn-context.ts +0 -108
- package/src/routing/types.ts +0 -77
- package/src/runtime/answer-contracts.ts +0 -693
- package/src/runtime/artifact-contracts.ts +0 -77
- package/src/runtime/evidence.ts +0 -77
- package/src/runtime/planning-evidence.ts +0 -682
- package/src/runtime/prompt-step.ts +0 -60
- package/src/runtime/provider-tracker.ts +0 -40
- package/src/runtime/run-context.ts +0 -32
- package/src/runtime/session-coordinator.ts +0 -632
- package/src/runtime/session-title.ts +0 -60
- package/src/runtime/tool-defaults-wrapper.ts +0 -43
- package/src/runtime/validation.ts +0 -211
- package/src/runtime/workflow-events.ts +0 -75
- package/src/runtime/workflow-runner.ts +0 -182
- package/src/runtime/workflow-types.ts +0 -102
- package/src/sentiment/adapters/finnhub.ts +0 -49
- package/src/sentiment/adapters/reddit.ts +0 -65
- package/src/sentiment/adapters/twitter.ts +0 -36
- package/src/sentiment/adapters/web.ts +0 -44
- package/src/sentiment/index.ts +0 -49
- package/src/sentiment/insights.ts +0 -269
- package/src/sentiment/keywords.ts +0 -31
- package/src/sentiment/pipeline.ts +0 -91
- package/src/sentiment/scorer.ts +0 -89
- package/src/sentiment/store.ts +0 -260
- package/src/sentiment/trends.ts +0 -96
- package/src/sentiment/types.ts +0 -112
- package/src/system-prompt.ts +0 -115
- package/src/tool-kit.ts +0 -69
- package/src/tools/AGENTS.md +0 -36
- package/src/tools/fundamentals/company-overview.ts +0 -64
- package/src/tools/fundamentals/comps.ts +0 -169
- package/src/tools/fundamentals/dcf.ts +0 -367
- package/src/tools/fundamentals/earnings.ts +0 -57
- package/src/tools/fundamentals/financials.ts +0 -63
- package/src/tools/fundamentals/sec-filings.ts +0 -105
- package/src/tools/index.ts +0 -101
- package/src/tools/interaction/ask-user.ts +0 -93
- package/src/tools/macro/fear-greed.ts +0 -41
- package/src/tools/macro/fred-data.ts +0 -92
- package/src/tools/market/crypto-history.ts +0 -72
- package/src/tools/market/crypto-price.ts +0 -53
- package/src/tools/market/screen-stocks.ts +0 -279
- package/src/tools/market/search-ticker.ts +0 -254
- package/src/tools/market/stock-history.ts +0 -104
- package/src/tools/market/stock-quote.ts +0 -67
- package/src/tools/options/greeks.ts +0 -81
- package/src/tools/options/option-chain.ts +0 -120
- package/src/tools/portfolio/alerts.ts +0 -457
- package/src/tools/portfolio/correlation.ts +0 -189
- package/src/tools/portfolio/daily-report.ts +0 -107
- package/src/tools/portfolio/holdings-overlap.ts +0 -139
- package/src/tools/portfolio/notifications.ts +0 -45
- package/src/tools/portfolio/risk-analysis.ts +0 -173
- package/src/tools/portfolio/tracker.ts +0 -308
- package/src/tools/portfolio/watchlist.ts +0 -288
- package/src/tools/sentiment/insight-format.ts +0 -50
- package/src/tools/sentiment/query-match.ts +0 -117
- package/src/tools/sentiment/reddit-sentiment.ts +0 -403
- package/src/tools/sentiment/sentiment-summary.ts +0 -383
- package/src/tools/sentiment/sentiment-trend.ts +0 -75
- package/src/tools/sentiment/twitter-sentiment.ts +0 -287
- package/src/tools/sentiment/untrusted-text.ts +0 -21
- package/src/tools/sentiment/web-search.ts +0 -186
- package/src/tools/sentiment/web-sentiment.ts +0 -96
- package/src/tools/technical/backtest.ts +0 -336
- package/src/tools/technical/indicators.ts +0 -281
- package/src/types/fundamentals.ts +0 -46
- package/src/types/index.ts +0 -25
- package/src/types/macro.ts +0 -27
- package/src/types/market.ts +0 -44
- package/src/types/options.ts +0 -52
- package/src/types/portfolio.ts +0 -83
- package/src/types/sentiment.ts +0 -129
- package/src/workflows/compare-assets.ts +0 -89
- package/src/workflows/index.ts +0 -3
- package/src/workflows/options-screener.ts +0 -125
- package/src/workflows/portfolio-builder.ts +0 -63
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import type { AgentTool } from "@earendil-works/pi-agent-core";
|
|
2
|
-
import { Type } from "@sinclair/typebox";
|
|
3
|
-
import { getConfig } from "../../config.js";
|
|
4
|
-
import { withCredentialCheck } from "../../onboarding/tool-helpers.js";
|
|
5
|
-
import { getFinancials } from "../../providers/alpha-vantage.js";
|
|
6
|
-
import { wrapProvider } from "../../providers/wrap-provider.js";
|
|
7
|
-
import type { FinancialStatement } from "../../types/fundamentals.js";
|
|
8
|
-
|
|
9
|
-
const params = Type.Object({
|
|
10
|
-
symbol: Type.String({ description: "Stock ticker symbol (e.g. AAPL, MSFT)" }),
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
export const financialsTool: AgentTool<
|
|
14
|
-
typeof params,
|
|
15
|
-
FinancialStatement[] | { credentialRequired: unknown }
|
|
16
|
-
> = {
|
|
17
|
-
name: "get_financials",
|
|
18
|
-
label: "Financial Statements",
|
|
19
|
-
description:
|
|
20
|
-
"Get annual income statement data: revenue, gross profit, operating income, net income, and EPS. Requires Alpha Vantage.",
|
|
21
|
-
parameters: params,
|
|
22
|
-
async execute(_toolCallId, args) {
|
|
23
|
-
return withCredentialCheck("alpha_vantage", async () => {
|
|
24
|
-
const apiKey = getConfig().alphaVantageApiKey!;
|
|
25
|
-
const result = await wrapProvider("alphavantage", () =>
|
|
26
|
-
getFinancials(args.symbol.toUpperCase(), apiKey),
|
|
27
|
-
);
|
|
28
|
-
if (result.status === "unavailable") {
|
|
29
|
-
return {
|
|
30
|
-
content: [
|
|
31
|
-
{
|
|
32
|
-
type: "text",
|
|
33
|
-
text: `⚠ Financial statements unavailable for ${args.symbol.toUpperCase()} (${result.reason}). Analysis will proceed without financials.`,
|
|
34
|
-
},
|
|
35
|
-
],
|
|
36
|
-
details: [],
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
const statements = result.data;
|
|
40
|
-
if (statements.length === 0) {
|
|
41
|
-
return {
|
|
42
|
-
content: [{ type: "text", text: `No financial data found for ${args.symbol}` }],
|
|
43
|
-
details: [],
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const header = `${args.symbol.toUpperCase()} — Annual Income Statement (${statements.length} years)`;
|
|
48
|
-
const rows = statements.map(
|
|
49
|
-
(s) =>
|
|
50
|
-
`${s.fiscalDate} | Rev: $${fmt(s.revenue)} | GP: $${fmt(s.grossProfit)} | OpInc: $${fmt(s.operatingIncome)} | Net: $${fmt(s.netIncome)}`,
|
|
51
|
-
);
|
|
52
|
-
|
|
53
|
-
const text = [header, ...rows].join("\n");
|
|
54
|
-
return { content: [{ type: "text", text }], details: statements };
|
|
55
|
-
});
|
|
56
|
-
},
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
function fmt(n: number): string {
|
|
60
|
-
if (n >= 1e9) return `${(n / 1e9).toFixed(2)}B`;
|
|
61
|
-
if (n >= 1e6) return `${(n / 1e6).toFixed(2)}M`;
|
|
62
|
-
return n.toLocaleString();
|
|
63
|
-
}
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import type { AgentTool } from "@earendil-works/pi-agent-core";
|
|
2
|
-
import { Type } from "@sinclair/typebox";
|
|
3
|
-
import { searchFilings } from "../../providers/sec-edgar.js";
|
|
4
|
-
import { wrapProvider } from "../../providers/wrap-provider.js";
|
|
5
|
-
import { renderUntrustedText, untrustedContentHeader } from "../sentiment/untrusted-text.js";
|
|
6
|
-
|
|
7
|
-
const params = Type.Object({
|
|
8
|
-
symbol: Type.String({ description: "Stock ticker symbol (e.g. AAPL, MSFT, TSLA)" }),
|
|
9
|
-
form_types: Type.Optional(
|
|
10
|
-
Type.Array(Type.String(), {
|
|
11
|
-
description:
|
|
12
|
-
"Filing types to search: 10-K (annual), 10-Q (quarterly), 8-K (material events). Default: all three.",
|
|
13
|
-
}),
|
|
14
|
-
),
|
|
15
|
-
limit: Type.Optional(
|
|
16
|
-
Type.Number({ description: "Maximum number of filings to return (default: 10)" }),
|
|
17
|
-
),
|
|
18
|
-
include_snippets: Type.Optional(
|
|
19
|
-
Type.Boolean({
|
|
20
|
-
description:
|
|
21
|
-
"Include short filing-text evidence snippets for risk/MD&A/litigation themes. Default: true.",
|
|
22
|
-
}),
|
|
23
|
-
),
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
export const secFilingsTool: AgentTool<typeof params> = {
|
|
27
|
-
name: "get_sec_filings",
|
|
28
|
-
label: "SEC Filings",
|
|
29
|
-
description:
|
|
30
|
-
"Search SEC EDGAR for company filings (10-K annual reports, 10-Q quarterly reports, 8-K material events). Returns filing dates, types, and direct links to the documents. Free API, no key required.",
|
|
31
|
-
parameters: params,
|
|
32
|
-
async execute(_toolCallId, args) {
|
|
33
|
-
const symbol = args.symbol.toUpperCase();
|
|
34
|
-
const formTypes = args.form_types ?? ["10-K", "10-Q", "8-K"];
|
|
35
|
-
const limit = args.limit ?? 10;
|
|
36
|
-
const includeSnippets = args.include_snippets ?? true;
|
|
37
|
-
|
|
38
|
-
const result = await wrapProvider("sec-edgar", () =>
|
|
39
|
-
searchFilings(symbol, formTypes, limit, { includeSnippets, snippetLimitPerFiling: 2 }),
|
|
40
|
-
);
|
|
41
|
-
if (result.status === "unavailable") {
|
|
42
|
-
return {
|
|
43
|
-
content: [
|
|
44
|
-
{ type: "text", text: `⚠ SEC filings unavailable for ${symbol} (${result.reason}).` },
|
|
45
|
-
],
|
|
46
|
-
details: null,
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
const filings = result.data;
|
|
50
|
-
|
|
51
|
-
if (filings.length === 0) {
|
|
52
|
-
return {
|
|
53
|
-
content: [
|
|
54
|
-
{
|
|
55
|
-
type: "text",
|
|
56
|
-
text: `No SEC filings found for ${symbol}. Verify the ticker is a US-listed company.`,
|
|
57
|
-
},
|
|
58
|
-
],
|
|
59
|
-
details: null,
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const lines = [
|
|
64
|
-
`**${symbol} SEC Filings** (${filings.length} found)`,
|
|
65
|
-
``,
|
|
66
|
-
...filings.map(
|
|
67
|
-
(f) =>
|
|
68
|
-
` ${f.formType.padEnd(6)} | Filed: ${f.filedDate} | Period: ${f.periodOfReport || "N/A"} | ${f.entityName}`,
|
|
69
|
-
),
|
|
70
|
-
``,
|
|
71
|
-
`Links:`,
|
|
72
|
-
...filings.map((f) => ` ${f.formType} (${f.filedDate}): ${f.url}`),
|
|
73
|
-
``,
|
|
74
|
-
`Primary documents:`,
|
|
75
|
-
...filings.flatMap((f) => [
|
|
76
|
-
` ${f.formType} (${f.filedDate}): ${f.primaryDocumentUrl ?? "N/A"}`,
|
|
77
|
-
...(f.items?.length ? [` 8-K items: ${f.items.join(", ")}`] : []),
|
|
78
|
-
]),
|
|
79
|
-
...(includeSnippets
|
|
80
|
-
? [
|
|
81
|
-
``,
|
|
82
|
-
`Evidence snippets (short excerpts; review source filing for full context):`,
|
|
83
|
-
untrustedContentHeader("SEC filing snippets"),
|
|
84
|
-
...filings.flatMap((f) =>
|
|
85
|
-
f.evidenceWarning
|
|
86
|
-
? [` ${f.formType} ${f.filedDate}: ${f.evidenceWarning}`]
|
|
87
|
-
: f.evidenceSnippets?.length
|
|
88
|
-
? f.evidenceSnippets.map(
|
|
89
|
-
(snippet) =>
|
|
90
|
-
` ${f.formType} ${f.filedDate}: ${renderUntrustedText(snippet, 500)}`,
|
|
91
|
-
)
|
|
92
|
-
: [
|
|
93
|
-
` ${f.formType} ${f.filedDate}: No keyword snippet found in fetched primary document.`,
|
|
94
|
-
],
|
|
95
|
-
),
|
|
96
|
-
]
|
|
97
|
-
: []),
|
|
98
|
-
];
|
|
99
|
-
|
|
100
|
-
return {
|
|
101
|
-
content: [{ type: "text", text: lines.join("\n") }],
|
|
102
|
-
details: { symbol, filings },
|
|
103
|
-
};
|
|
104
|
-
},
|
|
105
|
-
};
|
package/src/tools/index.ts
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import type { AgentTool } from "@earendil-works/pi-agent-core";
|
|
2
|
-
import type { AskUserHandler } from "../types/index.js";
|
|
3
|
-
import { companyOverviewTool } from "./fundamentals/company-overview.js";
|
|
4
|
-
import { compsTool } from "./fundamentals/comps.js";
|
|
5
|
-
import { dcfTool } from "./fundamentals/dcf.js";
|
|
6
|
-
import { earningsTool } from "./fundamentals/earnings.js";
|
|
7
|
-
import { financialsTool } from "./fundamentals/financials.js";
|
|
8
|
-
import { secFilingsTool } from "./fundamentals/sec-filings.js";
|
|
9
|
-
import { fearGreedTool } from "./macro/fear-greed.js";
|
|
10
|
-
import { fredDataTool } from "./macro/fred-data.js";
|
|
11
|
-
import { cryptoHistoryTool } from "./market/crypto-history.js";
|
|
12
|
-
import { cryptoPriceTool } from "./market/crypto-price.js";
|
|
13
|
-
import { screenStocksTool } from "./market/screen-stocks.js";
|
|
14
|
-
import { searchTickerTool } from "./market/search-ticker.js";
|
|
15
|
-
import { stockHistoryTool } from "./market/stock-history.js";
|
|
16
|
-
import { stockQuoteTool } from "./market/stock-quote.js";
|
|
17
|
-
import { optionChainTool } from "./options/option-chain.js";
|
|
18
|
-
import { alertsTool } from "./portfolio/alerts.js";
|
|
19
|
-
import { correlationTool } from "./portfolio/correlation.js";
|
|
20
|
-
import { dailyReportTool } from "./portfolio/daily-report.js";
|
|
21
|
-
import { holdingsOverlapTool } from "./portfolio/holdings-overlap.js";
|
|
22
|
-
import { notificationsTool } from "./portfolio/notifications.js";
|
|
23
|
-
import { riskAnalysisTool } from "./portfolio/risk-analysis.js";
|
|
24
|
-
import { portfolioTrackerTool } from "./portfolio/tracker.js";
|
|
25
|
-
import { watchlistTool } from "./portfolio/watchlist.js";
|
|
26
|
-
import { createRedditSentimentTool } from "./sentiment/reddit-sentiment.js";
|
|
27
|
-
import { createSentimentSummaryTool } from "./sentiment/sentiment-summary.js";
|
|
28
|
-
import { sentimentTrendTool } from "./sentiment/sentiment-trend.js";
|
|
29
|
-
import { createTwitterSentimentTool } from "./sentiment/twitter-sentiment.js";
|
|
30
|
-
import { webSearchTool } from "./sentiment/web-search.js";
|
|
31
|
-
import { webSentimentTool } from "./sentiment/web-sentiment.js";
|
|
32
|
-
import { backtestTool } from "./technical/backtest.js";
|
|
33
|
-
import { technicalIndicatorsTool } from "./technical/indicators.js";
|
|
34
|
-
|
|
35
|
-
export { companyOverviewTool } from "./fundamentals/company-overview.js";
|
|
36
|
-
export { compsTool } from "./fundamentals/comps.js";
|
|
37
|
-
export { dcfTool } from "./fundamentals/dcf.js";
|
|
38
|
-
export { earningsTool } from "./fundamentals/earnings.js";
|
|
39
|
-
export { financialsTool } from "./fundamentals/financials.js";
|
|
40
|
-
export { secFilingsTool } from "./fundamentals/sec-filings.js";
|
|
41
|
-
export { fearGreedTool } from "./macro/fear-greed.js";
|
|
42
|
-
export { fredDataTool } from "./macro/fred-data.js";
|
|
43
|
-
export { cryptoHistoryTool } from "./market/crypto-history.js";
|
|
44
|
-
export { cryptoPriceTool } from "./market/crypto-price.js";
|
|
45
|
-
export { screenStocksTool } from "./market/screen-stocks.js";
|
|
46
|
-
export { searchTickerTool } from "./market/search-ticker.js";
|
|
47
|
-
export { stockHistoryTool } from "./market/stock-history.js";
|
|
48
|
-
export { stockQuoteTool } from "./market/stock-quote.js";
|
|
49
|
-
export { optionChainTool } from "./options/option-chain.js";
|
|
50
|
-
export { alertsTool } from "./portfolio/alerts.js";
|
|
51
|
-
export { correlationTool } from "./portfolio/correlation.js";
|
|
52
|
-
export { dailyReportTool } from "./portfolio/daily-report.js";
|
|
53
|
-
export { holdingsOverlapTool } from "./portfolio/holdings-overlap.js";
|
|
54
|
-
export { notificationsTool } from "./portfolio/notifications.js";
|
|
55
|
-
export { riskAnalysisTool } from "./portfolio/risk-analysis.js";
|
|
56
|
-
export { portfolioTrackerTool } from "./portfolio/tracker.js";
|
|
57
|
-
export { watchlistTool } from "./portfolio/watchlist.js";
|
|
58
|
-
export { redditSentimentTool } from "./sentiment/reddit-sentiment.js";
|
|
59
|
-
export { createSentimentSummaryTool, sentimentSummaryTool } from "./sentiment/sentiment-summary.js";
|
|
60
|
-
export { sentimentTrendTool } from "./sentiment/sentiment-trend.js";
|
|
61
|
-
export { twitterSentimentTool } from "./sentiment/twitter-sentiment.js";
|
|
62
|
-
export { webSearchTool } from "./sentiment/web-search.js";
|
|
63
|
-
export { webSentimentTool } from "./sentiment/web-sentiment.js";
|
|
64
|
-
export { backtestTool } from "./technical/backtest.js";
|
|
65
|
-
export { technicalIndicatorsTool } from "./technical/indicators.js";
|
|
66
|
-
|
|
67
|
-
export function getAllTools(options: { askUserHandler?: AskUserHandler } = {}): AgentTool<any>[] {
|
|
68
|
-
return [
|
|
69
|
-
searchTickerTool,
|
|
70
|
-
stockQuoteTool,
|
|
71
|
-
stockHistoryTool,
|
|
72
|
-
screenStocksTool,
|
|
73
|
-
cryptoPriceTool,
|
|
74
|
-
cryptoHistoryTool,
|
|
75
|
-
companyOverviewTool,
|
|
76
|
-
financialsTool,
|
|
77
|
-
earningsTool,
|
|
78
|
-
dcfTool,
|
|
79
|
-
compsTool,
|
|
80
|
-
secFilingsTool,
|
|
81
|
-
fredDataTool,
|
|
82
|
-
fearGreedTool,
|
|
83
|
-
createRedditSentimentTool({ askUserHandler: options.askUserHandler }),
|
|
84
|
-
createTwitterSentimentTool({ askUserHandler: options.askUserHandler }),
|
|
85
|
-
technicalIndicatorsTool,
|
|
86
|
-
backtestTool,
|
|
87
|
-
portfolioTrackerTool,
|
|
88
|
-
riskAnalysisTool,
|
|
89
|
-
watchlistTool,
|
|
90
|
-
correlationTool,
|
|
91
|
-
holdingsOverlapTool,
|
|
92
|
-
alertsTool,
|
|
93
|
-
dailyReportTool,
|
|
94
|
-
notificationsTool,
|
|
95
|
-
optionChainTool,
|
|
96
|
-
webSearchTool,
|
|
97
|
-
webSentimentTool,
|
|
98
|
-
sentimentTrendTool,
|
|
99
|
-
createSentimentSummaryTool({ askUserHandler: options.askUserHandler }),
|
|
100
|
-
];
|
|
101
|
-
}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
import { Type } from "@sinclair/typebox";
|
|
3
|
-
import { promptUser } from "../../onboarding/prompt-user.js";
|
|
4
|
-
import type { AskUserHandler } from "../../types/index.js";
|
|
5
|
-
|
|
6
|
-
interface AskUserDetails {
|
|
7
|
-
question: string;
|
|
8
|
-
questionType: string;
|
|
9
|
-
answer: string | null;
|
|
10
|
-
cancelled: boolean;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const AskUserParams = Type.Object({
|
|
14
|
-
question: Type.String({ description: "The question to ask the user" }),
|
|
15
|
-
question_type: Type.Union(
|
|
16
|
-
[Type.Literal("select"), Type.Literal("text"), Type.Literal("confirm")],
|
|
17
|
-
{
|
|
18
|
-
description:
|
|
19
|
-
"Type of answer expected: select (pick from options), text (free input), or confirm (yes/no)",
|
|
20
|
-
},
|
|
21
|
-
),
|
|
22
|
-
options: Type.Optional(
|
|
23
|
-
Type.Array(Type.String(), { description: "Choices for select-type questions" }),
|
|
24
|
-
),
|
|
25
|
-
placeholder: Type.Optional(Type.String({ description: "Hint text for text input" })),
|
|
26
|
-
reason: Type.Optional(
|
|
27
|
-
Type.String({ description: "Brief context for why this clarification is needed" }),
|
|
28
|
-
),
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
export function registerAskUserTool(pi: ExtensionAPI, askUserHandler?: AskUserHandler): void {
|
|
32
|
-
pi.registerTool({
|
|
33
|
-
name: "ask_user",
|
|
34
|
-
label: "Ask User",
|
|
35
|
-
description:
|
|
36
|
-
"Ask the user a clarification question when their request is ambiguous or missing key details. Use select for multiple-choice, text for free input, or confirm for yes/no.",
|
|
37
|
-
promptSnippet:
|
|
38
|
-
"ask_user: Ask the user a clarification question when their request is ambiguous or missing key details",
|
|
39
|
-
parameters: AskUserParams,
|
|
40
|
-
|
|
41
|
-
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
|
|
42
|
-
const { question, question_type: questionType } = params;
|
|
43
|
-
|
|
44
|
-
// Preserve the pre-refactor error message for the specific misuse case
|
|
45
|
-
// where the model asks a select question with no options — this is a
|
|
46
|
-
// model/caller bug, not a cancellation.
|
|
47
|
-
if (questionType === "select" && (!params.options || params.options.length === 0)) {
|
|
48
|
-
return {
|
|
49
|
-
content: [
|
|
50
|
-
{
|
|
51
|
-
type: "text",
|
|
52
|
-
text: "Error: No options provided for select question. Provide options or use text type instead.",
|
|
53
|
-
},
|
|
54
|
-
],
|
|
55
|
-
details: { question, questionType, answer: null, cancelled: true } as AskUserDetails,
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const result = await promptUser(
|
|
60
|
-
ctx!,
|
|
61
|
-
{
|
|
62
|
-
question,
|
|
63
|
-
questionType,
|
|
64
|
-
options: params.options,
|
|
65
|
-
placeholder: params.placeholder,
|
|
66
|
-
reason: params.reason,
|
|
67
|
-
},
|
|
68
|
-
askUserHandler,
|
|
69
|
-
);
|
|
70
|
-
|
|
71
|
-
if (result.cancelled) {
|
|
72
|
-
const text =
|
|
73
|
-
!askUserHandler && !ctx?.hasUI
|
|
74
|
-
? "UI not available (non-interactive mode). Proceed with your best judgment and clearly disclose your assumption."
|
|
75
|
-
: "User cancelled the selection. Proceed with your best judgment and disclose your assumption.";
|
|
76
|
-
return {
|
|
77
|
-
content: [{ type: "text", text }],
|
|
78
|
-
details: { question, questionType, answer: null, cancelled: true } as AskUserDetails,
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return {
|
|
83
|
-
content: [{ type: "text", text: `User answered: ${result.answer}` }],
|
|
84
|
-
details: {
|
|
85
|
-
question,
|
|
86
|
-
questionType,
|
|
87
|
-
answer: result.answer,
|
|
88
|
-
cancelled: false,
|
|
89
|
-
} as AskUserDetails,
|
|
90
|
-
};
|
|
91
|
-
},
|
|
92
|
-
});
|
|
93
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import type { AgentTool } from "@earendil-works/pi-agent-core";
|
|
2
|
-
import { Type } from "@sinclair/typebox";
|
|
3
|
-
import { getFearGreedIndex } from "../../providers/fear-greed.js";
|
|
4
|
-
import { wrapProvider } from "../../providers/wrap-provider.js";
|
|
5
|
-
import type { FearGreedData } from "../../types/sentiment.js";
|
|
6
|
-
|
|
7
|
-
const params = Type.Object({});
|
|
8
|
-
|
|
9
|
-
export const fearGreedTool: AgentTool<typeof params, FearGreedData> = {
|
|
10
|
-
name: "get_fear_greed",
|
|
11
|
-
label: "Fear & Greed Index",
|
|
12
|
-
description:
|
|
13
|
-
"Get the Crypto Fear & Greed Index (alternative.me) — a sentiment indicator from 0 (Extreme Fear) to 100 (Extreme Greed). Includes current value and previous close.",
|
|
14
|
-
parameters: params,
|
|
15
|
-
async execute(_toolCallId, _args) {
|
|
16
|
-
const result = await wrapProvider("feargreed", () => getFearGreedIndex());
|
|
17
|
-
if (result.status === "unavailable") {
|
|
18
|
-
return {
|
|
19
|
-
content: [{ type: "text", text: `⚠ Fear & Greed Index unavailable (${result.reason}).` }],
|
|
20
|
-
details: null as any,
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
const fg = result.data;
|
|
24
|
-
|
|
25
|
-
const gauge = buildGauge(fg.value);
|
|
26
|
-
const text = [
|
|
27
|
-
`**Fear & Greed Index: ${fg.value} — ${fg.label}**`,
|
|
28
|
-
gauge,
|
|
29
|
-
`Previous Close: ${fg.previousClose}${fg.weekAgo != null ? ` | Week Ago: ${fg.weekAgo}` : ""}${fg.monthAgo != null ? ` | Month Ago: ${fg.monthAgo}` : ""}`,
|
|
30
|
-
].join("\n");
|
|
31
|
-
|
|
32
|
-
return { content: [{ type: "text", text }], details: fg };
|
|
33
|
-
},
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
function buildGauge(value: number): string {
|
|
37
|
-
const width = 20;
|
|
38
|
-
const pos = Math.round((value / 100) * width);
|
|
39
|
-
const bar = "█".repeat(pos) + "░".repeat(width - pos);
|
|
40
|
-
return `[${bar}] ${value}/100`;
|
|
41
|
-
}
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import type { AgentTool } from "@earendil-works/pi-agent-core";
|
|
2
|
-
import { Type } from "@sinclair/typebox";
|
|
3
|
-
import { getConfig } from "../../config.js";
|
|
4
|
-
import { withCredentialCheck } from "../../onboarding/tool-helpers.js";
|
|
5
|
-
import { getSeries } from "../../providers/fred.js";
|
|
6
|
-
import { wrapProvider } from "../../providers/wrap-provider.js";
|
|
7
|
-
import type { FredSeries } from "../../types/macro.js";
|
|
8
|
-
import { FRED_SERIES } from "../../types/macro.js";
|
|
9
|
-
|
|
10
|
-
const params = Type.Object({
|
|
11
|
-
series_id: Type.String({
|
|
12
|
-
description: `FRED series ID. Common ones: ${Object.entries(FRED_SERIES)
|
|
13
|
-
.map(([k, v]) => `${v} (${k})`)
|
|
14
|
-
.join(", ")}`,
|
|
15
|
-
}),
|
|
16
|
-
limit: Type.Optional(
|
|
17
|
-
Type.Integer({
|
|
18
|
-
minimum: 1,
|
|
19
|
-
maximum: 1000,
|
|
20
|
-
description: "Number of observations to return. Default: 30",
|
|
21
|
-
}),
|
|
22
|
-
),
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
export const fredDataTool: AgentTool<typeof params, FredSeries | { credentialRequired: unknown }> =
|
|
26
|
-
{
|
|
27
|
-
name: "get_economic_data",
|
|
28
|
-
label: "FRED Economic Data",
|
|
29
|
-
description:
|
|
30
|
-
"Get economic data from FRED (Federal Reserve Economic Data): interest rates, CPI, GDP, unemployment, yield curve, and more. Requires FRED.",
|
|
31
|
-
parameters: params,
|
|
32
|
-
async execute(_toolCallId, args) {
|
|
33
|
-
return withCredentialCheck("fred", async () => {
|
|
34
|
-
const apiKey = getConfig().fredApiKey!;
|
|
35
|
-
const seriesId = args.series_id.toUpperCase();
|
|
36
|
-
const limit = normalizeLimit(seriesId, args.limit);
|
|
37
|
-
const result = await wrapProvider("fred", () => getSeries(seriesId, apiKey, limit));
|
|
38
|
-
if (result.status === "unavailable") {
|
|
39
|
-
return {
|
|
40
|
-
content: [
|
|
41
|
-
{ type: "text", text: `⚠ FRED data unavailable for ${seriesId} (${result.reason}).` },
|
|
42
|
-
],
|
|
43
|
-
details: null as any,
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
const series = result.data;
|
|
47
|
-
|
|
48
|
-
const latest = series.observations[series.observations.length - 1];
|
|
49
|
-
const header = `**${series.title}** (${series.id})`;
|
|
50
|
-
const meta = `Units: ${series.units} | Frequency: ${series.frequency} | Last updated: ${series.lastUpdated}`;
|
|
51
|
-
const current = latest ? `Latest: ${latest.value} (${latest.date})` : "No data";
|
|
52
|
-
const derived = formatDerivedChange(series);
|
|
53
|
-
|
|
54
|
-
// Show last 10 observations
|
|
55
|
-
const recent = series.observations.slice(-10);
|
|
56
|
-
const table = recent.map((o) => `${o.date}: ${o.value}`).join("\n");
|
|
57
|
-
|
|
58
|
-
const text = [header, meta, current, derived, "", "Recent observations:", table]
|
|
59
|
-
.filter(Boolean)
|
|
60
|
-
.join("\n");
|
|
61
|
-
const prefix = result.stale
|
|
62
|
-
? `⚠ Using cached FRED data from ${result.timestamp} (FRED unavailable)\n`
|
|
63
|
-
: "";
|
|
64
|
-
return { content: [{ type: "text", text: prefix + text }], details: series };
|
|
65
|
-
});
|
|
66
|
-
},
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
function normalizeLimit(seriesId: string, requested: number | undefined): number {
|
|
70
|
-
const limit = requested ?? 30;
|
|
71
|
-
if (!Number.isInteger(limit) || limit < 1 || limit > 1000) {
|
|
72
|
-
throw new Error("limit must be an integer between 1 and 1000.");
|
|
73
|
-
}
|
|
74
|
-
if (seriesId === FRED_SERIES.CPI && limit < 13) return 13;
|
|
75
|
-
return limit;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function formatDerivedChange(series: FredSeries): string | null {
|
|
79
|
-
const latest = series.observations.at(-1);
|
|
80
|
-
if (!latest) return null;
|
|
81
|
-
if (!/monthly/i.test(series.frequency) || !/\bindex\b/i.test(series.units)) return null;
|
|
82
|
-
|
|
83
|
-
const latestYear = Number(latest.date.slice(0, 4));
|
|
84
|
-
const monthDay = latest.date.slice(4);
|
|
85
|
-
const prior = series.observations.find(
|
|
86
|
-
(observation) => observation.date === `${latestYear - 1}${monthDay}`,
|
|
87
|
-
);
|
|
88
|
-
if (!prior || prior.value === 0) return null;
|
|
89
|
-
|
|
90
|
-
const pct = (latest.value / prior.value - 1) * 100;
|
|
91
|
-
return `Derived YoY change: ${pct.toFixed(2)}% (${prior.date} to ${latest.date}).`;
|
|
92
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import type { AgentTool } from "@earendil-works/pi-agent-core";
|
|
2
|
-
import { Type } from "@sinclair/typebox";
|
|
3
|
-
import { getCryptoHistory } from "../../providers/coingecko.js";
|
|
4
|
-
import { wrapProvider } from "../../providers/wrap-provider.js";
|
|
5
|
-
import type { OHLCV } from "../../types/market.js";
|
|
6
|
-
import { computeRiskMetrics } from "../portfolio/risk-analysis.js";
|
|
7
|
-
|
|
8
|
-
const params = Type.Object({
|
|
9
|
-
id: Type.String({
|
|
10
|
-
description: "CoinGecko coin ID (e.g. bitcoin, ethereum, solana)",
|
|
11
|
-
}),
|
|
12
|
-
days: Type.Optional(
|
|
13
|
-
Type.Number({
|
|
14
|
-
description: "Number of days of history: 1, 7, 14, 30, 90, 180, 365, max. Default: 180",
|
|
15
|
-
}),
|
|
16
|
-
),
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
export const cryptoHistoryTool: AgentTool<typeof params, OHLCV[]> = {
|
|
20
|
-
name: "get_crypto_history",
|
|
21
|
-
label: "Crypto History",
|
|
22
|
-
description: "Get historical OHLC data for a cryptocurrency",
|
|
23
|
-
parameters: params,
|
|
24
|
-
async execute(_toolCallId, args) {
|
|
25
|
-
const id = args.id.toLowerCase();
|
|
26
|
-
const days = args.days ?? 180;
|
|
27
|
-
const result = await wrapProvider("coingecko", () => getCryptoHistory(id, days));
|
|
28
|
-
if (result.status === "unavailable") {
|
|
29
|
-
return {
|
|
30
|
-
content: [
|
|
31
|
-
{ type: "text", text: `⚠ Crypto history unavailable for ${id} (${result.reason}).` },
|
|
32
|
-
],
|
|
33
|
-
details: [],
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
const bars = result.data;
|
|
37
|
-
|
|
38
|
-
const summary = [
|
|
39
|
-
`${id} — ${bars.length} bars (${days} days)`,
|
|
40
|
-
`Period: ${bars[0]?.date} to ${bars[bars.length - 1]?.date}`,
|
|
41
|
-
];
|
|
42
|
-
|
|
43
|
-
const recent = bars.slice(-10);
|
|
44
|
-
const table = recent
|
|
45
|
-
.map(
|
|
46
|
-
(b) =>
|
|
47
|
-
`${b.date} | O:${b.open.toFixed(2)} H:${b.high.toFixed(2)} L:${b.low.toFixed(2)} C:${b.close.toFixed(2)}`,
|
|
48
|
-
)
|
|
49
|
-
.join("\n");
|
|
50
|
-
|
|
51
|
-
const riskLines = buildRiskLines(id, bars);
|
|
52
|
-
const text = [...summary, ...riskLines, "", "Recent bars:", table].join("\n");
|
|
53
|
-
return { content: [{ type: "text", text }], details: bars };
|
|
54
|
-
},
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
function buildRiskLines(id: string, bars: OHLCV[]): string[] {
|
|
58
|
-
if (bars.length < 30) return [];
|
|
59
|
-
const metrics = computeRiskMetrics(
|
|
60
|
-
id.toUpperCase(),
|
|
61
|
-
bars.map((bar) => bar.close),
|
|
62
|
-
);
|
|
63
|
-
return [
|
|
64
|
-
"",
|
|
65
|
-
"Risk metrics from crypto history:",
|
|
66
|
-
`Annualized Return: ${(metrics.annualizedReturn * 100).toFixed(2)}%`,
|
|
67
|
-
`Annualized Volatility: ${(metrics.annualizedVolatility * 100).toFixed(2)}%`,
|
|
68
|
-
`Sharpe Ratio: ${metrics.sharpeRatio.toFixed(2)}`,
|
|
69
|
-
`Max Drawdown: ${(metrics.maxDrawdown * 100).toFixed(2)}%`,
|
|
70
|
-
`Value at Risk (95%, daily): ${(metrics.var95 * 100).toFixed(2)}%`,
|
|
71
|
-
];
|
|
72
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import type { AgentTool } from "@earendil-works/pi-agent-core";
|
|
2
|
-
import { Type } from "@sinclair/typebox";
|
|
3
|
-
import { getCryptoPrice } from "../../providers/coingecko.js";
|
|
4
|
-
import { wrapProvider } from "../../providers/wrap-provider.js";
|
|
5
|
-
import type { CryptoPrice } from "../../types/market.js";
|
|
6
|
-
|
|
7
|
-
const params = Type.Object({
|
|
8
|
-
id: Type.String({
|
|
9
|
-
description: "CoinGecko coin ID (e.g. bitcoin, ethereum, solana, dogecoin). Use lowercase.",
|
|
10
|
-
}),
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
export const cryptoPriceTool: AgentTool<typeof params, CryptoPrice> = {
|
|
14
|
-
name: "get_crypto_price",
|
|
15
|
-
label: "Crypto Price",
|
|
16
|
-
description: "Get current crypto price, 24h change, market cap, volume, ATH, and supply data",
|
|
17
|
-
parameters: params,
|
|
18
|
-
async execute(_toolCallId, args) {
|
|
19
|
-
const result = await wrapProvider("coingecko", () => getCryptoPrice(args.id.toLowerCase()));
|
|
20
|
-
if (result.status === "unavailable") {
|
|
21
|
-
return {
|
|
22
|
-
content: [
|
|
23
|
-
{ type: "text", text: `⚠ Crypto price unavailable for ${args.id} (${result.reason}).` },
|
|
24
|
-
],
|
|
25
|
-
details: null as any,
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
const crypto = result.data;
|
|
29
|
-
const sign = crypto.changePercent24h >= 0 ? "+" : "";
|
|
30
|
-
const text = [
|
|
31
|
-
`${crypto.name} (${crypto.symbol.toUpperCase()}): $${formatPrice(crypto.price)} (${sign}${crypto.changePercent24h.toFixed(2)}%)`,
|
|
32
|
-
`24h High: $${formatPrice(crypto.high24h)} | 24h Low: $${formatPrice(crypto.low24h)}`,
|
|
33
|
-
`Market Cap: $${formatLargeNumber(crypto.marketCap)} | 24h Volume: $${formatLargeNumber(crypto.volume24h)}`,
|
|
34
|
-
`ATH: $${formatPrice(crypto.ath)} (${crypto.athDate.split("T")[0]})`,
|
|
35
|
-
`Circulating: ${formatLargeNumber(crypto.circulatingSupply)} ${crypto.symbol.toUpperCase()}`,
|
|
36
|
-
].join("\n");
|
|
37
|
-
|
|
38
|
-
return { content: [{ type: "text", text }], details: crypto };
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
function formatPrice(n: number): string {
|
|
43
|
-
if (n >= 1) return n.toFixed(2);
|
|
44
|
-
if (n >= 0.01) return n.toFixed(4);
|
|
45
|
-
return n.toFixed(8);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function formatLargeNumber(n: number): string {
|
|
49
|
-
if (n >= 1e12) return `${(n / 1e12).toFixed(2)}T`;
|
|
50
|
-
if (n >= 1e9) return `${(n / 1e9).toFixed(2)}B`;
|
|
51
|
-
if (n >= 1e6) return `${(n / 1e6).toFixed(2)}M`;
|
|
52
|
-
return n.toLocaleString();
|
|
53
|
-
}
|