opencandle 0.5.0 → 0.7.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 +170 -186
- package/dist/analysts/contracts.d.ts +1 -3
- package/dist/analysts/contracts.js +1 -11
- package/dist/analysts/contracts.js.map +1 -1
- package/dist/analysts/orchestrator.d.ts +1 -3
- package/dist/analysts/orchestrator.js +1 -26
- package/dist/analysts/orchestrator.js.map +1 -1
- package/dist/cli.js +66 -7
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +13 -3
- package/dist/config.js +25 -5
- package/dist/config.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/infra/cache.d.ts +8 -11
- package/dist/infra/cache.js +17 -15
- package/dist/infra/cache.js.map +1 -1
- package/dist/infra/http-client.d.ts +4 -1
- package/dist/infra/http-client.js +59 -6
- package/dist/infra/http-client.js.map +1 -1
- package/dist/infra/index.d.ts +2 -3
- package/dist/infra/index.js +2 -3
- package/dist/infra/index.js.map +1 -1
- package/dist/infra/native-dependencies.js +2 -2
- package/dist/infra/native-dependencies.js.map +1 -1
- package/dist/infra/node-version.js.map +1 -1
- package/dist/infra/opencandle-paths.d.ts +0 -3
- package/dist/infra/opencandle-paths.js +4 -11
- package/dist/infra/opencandle-paths.js.map +1 -1
- package/dist/infra/rate-limiter.js +12 -9
- package/dist/infra/rate-limiter.js.map +1 -1
- package/dist/market-state/alert-conditions.d.ts +34 -0
- package/dist/market-state/alert-conditions.js +23 -0
- package/dist/market-state/alert-conditions.js.map +1 -0
- package/dist/market-state/alert-runner.d.ts +55 -0
- package/dist/market-state/alert-runner.js +634 -0
- package/dist/market-state/alert-runner.js.map +1 -0
- package/dist/market-state/daily-report.d.ts +26 -0
- package/dist/market-state/daily-report.js +179 -0
- package/dist/market-state/daily-report.js.map +1 -0
- package/dist/market-state/local-automation-service.d.ts +25 -0
- package/dist/market-state/local-automation-service.js +119 -0
- package/dist/market-state/local-automation-service.js.map +1 -0
- package/dist/market-state/notification-delivery.d.ts +14 -0
- package/dist/market-state/notification-delivery.js +139 -0
- package/dist/market-state/notification-delivery.js.map +1 -0
- package/dist/market-state/resolve-for-mutation.d.ts +10 -0
- package/dist/market-state/resolve-for-mutation.js +15 -0
- package/dist/market-state/resolve-for-mutation.js.map +1 -0
- package/dist/market-state/resolve.d.ts +14 -0
- package/dist/market-state/resolve.js +89 -0
- package/dist/market-state/resolve.js.map +1 -0
- package/dist/market-state/service.d.ts +527 -0
- package/dist/market-state/service.js +1099 -0
- package/dist/market-state/service.js.map +1 -0
- package/dist/memory/index.d.ts +7 -7
- package/dist/memory/index.js +6 -6
- package/dist/memory/index.js.map +1 -1
- package/dist/memory/manager.js +11 -11
- package/dist/memory/manager.js.map +1 -1
- package/dist/memory/retrieval.js +7 -4
- package/dist/memory/retrieval.js.map +1 -1
- package/dist/memory/sqlite.js +385 -3
- package/dist/memory/sqlite.js.map +1 -1
- package/dist/memory/storage.js +1 -2
- package/dist/memory/storage.js.map +1 -1
- package/dist/memory/tool-defaults.js +64 -28
- package/dist/memory/tool-defaults.js.map +1 -1
- package/dist/memory/types.js.map +1 -1
- package/dist/monitor.d.ts +2 -0
- package/dist/monitor.js +104 -0
- package/dist/monitor.js.map +1 -0
- package/dist/onboarding/connect.d.ts +2 -2
- package/dist/onboarding/connect.js +13 -8
- package/dist/onboarding/connect.js.map +1 -1
- package/dist/onboarding/credential-interceptor.js +1 -1
- package/dist/onboarding/credential-interceptor.js.map +1 -1
- package/dist/onboarding/degradation-accumulator.js +1 -3
- package/dist/onboarding/degradation-accumulator.js.map +1 -1
- package/dist/onboarding/provider-status.d.ts +48 -0
- package/dist/onboarding/provider-status.js +285 -0
- package/dist/onboarding/provider-status.js.map +1 -0
- package/dist/onboarding/providers.d.ts +85 -8
- package/dist/onboarding/providers.js +83 -18
- package/dist/onboarding/providers.js.map +1 -1
- package/dist/onboarding/state.d.ts +1 -0
- package/dist/onboarding/state.js +5 -0
- package/dist/onboarding/state.js.map +1 -1
- package/dist/onboarding/tool-helpers.js +1 -1
- package/dist/onboarding/tool-helpers.js.map +1 -1
- package/dist/onboarding/tool-tags.d.ts +12 -1
- package/dist/onboarding/tool-tags.js +37 -5
- package/dist/onboarding/tool-tags.js.map +1 -1
- package/dist/onboarding/validation.d.ts +2 -2
- package/dist/onboarding/validation.js +1 -1
- package/dist/onboarding/validation.js.map +1 -1
- package/dist/pi/opencandle-extension.d.ts +8 -0
- package/dist/pi/opencandle-extension.js +502 -42
- package/dist/pi/opencandle-extension.js.map +1 -1
- package/dist/pi/session.d.ts +1 -1
- package/dist/pi/session.js +3 -1
- package/dist/pi/session.js.map +1 -1
- package/dist/pi/setup.js +8 -3
- package/dist/pi/setup.js.map +1 -1
- package/dist/pi/tool-adapter.d.ts +4 -1
- package/dist/pi/tool-adapter.js +10 -6
- package/dist/pi/tool-adapter.js.map +1 -1
- package/dist/prompts/context-builder.d.ts +1 -1
- package/dist/prompts/context-builder.js +20 -7
- package/dist/prompts/context-builder.js.map +1 -1
- package/dist/prompts/policy-cards.d.ts +1 -1
- package/dist/prompts/policy-cards.js +2 -2
- package/dist/prompts/policy-cards.js.map +1 -1
- package/dist/prompts/sections.d.ts +1 -1
- package/dist/prompts/symbol-preflight.d.ts +20 -0
- package/dist/prompts/symbol-preflight.js +49 -0
- package/dist/prompts/symbol-preflight.js.map +1 -0
- package/dist/prompts/workflow-prompts.d.ts +1 -1
- package/dist/prompts/workflow-prompts.js +54 -16
- package/dist/prompts/workflow-prompts.js.map +1 -1
- package/dist/providers/alpha-vantage.d.ts +1 -1
- package/dist/providers/alpha-vantage.js +26 -7
- package/dist/providers/alpha-vantage.js.map +1 -1
- package/dist/providers/coingecko.js +1 -1
- package/dist/providers/coingecko.js.map +1 -1
- package/dist/providers/errors.d.ts +5 -0
- package/dist/providers/errors.js +11 -0
- package/dist/providers/errors.js.map +1 -0
- package/dist/providers/exa-search.d.ts +2 -2
- package/dist/providers/exa-search.js +19 -11
- package/dist/providers/exa-search.js.map +1 -1
- package/dist/providers/external-tool-error.d.ts +10 -0
- package/dist/providers/external-tool-error.js +21 -0
- package/dist/providers/external-tool-error.js.map +1 -0
- package/dist/providers/fear-greed.js +1 -1
- package/dist/providers/fear-greed.js.map +1 -1
- package/dist/providers/finnhub.js +3 -5
- package/dist/providers/finnhub.js.map +1 -1
- package/dist/providers/fred.js +2 -2
- package/dist/providers/fred.js.map +1 -1
- package/dist/providers/index.d.ts +7 -6
- package/dist/providers/index.js +6 -5
- package/dist/providers/index.js.map +1 -1
- package/dist/providers/reddit-cli.d.ts +36 -0
- package/dist/providers/reddit-cli.js +201 -0
- package/dist/providers/reddit-cli.js.map +1 -0
- package/dist/providers/reddit.d.ts +1 -1
- package/dist/providers/reddit.js +9 -37
- package/dist/providers/reddit.js.map +1 -1
- package/dist/providers/sec-edgar.d.ts +1 -0
- package/dist/providers/sec-edgar.js +12 -4
- package/dist/providers/sec-edgar.js.map +1 -1
- package/dist/providers/tradingview.d.ts +47 -0
- package/dist/providers/tradingview.js +275 -0
- package/dist/providers/tradingview.js.map +1 -0
- package/dist/providers/twitter-cli.d.ts +40 -0
- package/dist/providers/twitter-cli.js +153 -0
- package/dist/providers/twitter-cli.js.map +1 -0
- package/dist/providers/twitter.d.ts +0 -8
- package/dist/providers/twitter.js +8 -60
- package/dist/providers/twitter.js.map +1 -1
- package/dist/providers/web-search.js +26 -12
- package/dist/providers/web-search.js.map +1 -1
- package/dist/providers/with-fallback.js +4 -2
- package/dist/providers/with-fallback.js.map +1 -1
- package/dist/providers/wrap-provider.d.ts +2 -3
- package/dist/providers/wrap-provider.js +44 -8
- package/dist/providers/wrap-provider.js.map +1 -1
- package/dist/providers/yahoo-finance.d.ts +1 -1
- package/dist/providers/yahoo-finance.js +153 -48
- package/dist/providers/yahoo-finance.js.map +1 -1
- package/dist/routing/classify-intent.d.ts +6 -0
- package/dist/routing/classify-intent.js +78 -7
- package/dist/routing/classify-intent.js.map +1 -1
- package/dist/routing/defaults.d.ts +1 -1
- package/dist/routing/entity-extractor.d.ts +1 -0
- package/dist/routing/entity-extractor.js +234 -29
- package/dist/routing/entity-extractor.js.map +1 -1
- package/dist/routing/fund-symbols.d.ts +2 -0
- package/dist/routing/fund-symbols.js +55 -0
- package/dist/routing/fund-symbols.js.map +1 -0
- package/dist/routing/horizon.d.ts +1 -0
- package/dist/routing/horizon.js +10 -0
- package/dist/routing/horizon.js.map +1 -0
- package/dist/routing/index.d.ts +10 -10
- package/dist/routing/index.js +6 -6
- package/dist/routing/index.js.map +1 -1
- package/dist/routing/planning.d.ts +2 -2
- package/dist/routing/planning.js +65 -34
- package/dist/routing/planning.js.map +1 -1
- package/dist/routing/route-manifest.d.ts +2 -2
- package/dist/routing/route-manifest.js +25 -4
- package/dist/routing/route-manifest.js.map +1 -1
- package/dist/routing/router-llm-client.js.map +1 -1
- package/dist/routing/router-prompt.js +7 -9
- package/dist/routing/router-prompt.js.map +1 -1
- package/dist/routing/router-types.d.ts +1 -0
- package/dist/routing/router.js +137 -22
- package/dist/routing/router.js.map +1 -1
- package/dist/routing/slot-resolver.d.ts +1 -1
- package/dist/routing/slot-resolver.js +2 -4
- package/dist/routing/slot-resolver.js.map +1 -1
- package/dist/routing/symbol-disambiguator.d.ts +11 -0
- package/dist/routing/symbol-disambiguator.js +52 -0
- package/dist/routing/symbol-disambiguator.js.map +1 -0
- package/dist/routing/turn-context.d.ts +1 -1
- package/dist/routing/turn-context.js +1 -1
- package/dist/routing/turn-context.js.map +1 -1
- package/dist/routing/types.d.ts +2 -0
- package/dist/runtime/answer-contracts.d.ts +1 -1
- package/dist/runtime/answer-contracts.js +48 -9
- package/dist/runtime/answer-contracts.js.map +1 -1
- package/dist/runtime/artifact-contracts.js.map +1 -1
- package/dist/runtime/planning-evidence.js +47 -26
- package/dist/runtime/planning-evidence.js.map +1 -1
- package/dist/runtime/prompt-step.d.ts +1 -9
- package/dist/runtime/prompt-step.js +0 -10
- package/dist/runtime/prompt-step.js.map +1 -1
- package/dist/runtime/run-context.d.ts +5 -2
- package/dist/runtime/run-context.js +8 -1
- package/dist/runtime/run-context.js.map +1 -1
- package/dist/runtime/session-coordinator.d.ts +13 -5
- package/dist/runtime/session-coordinator.js +160 -20
- package/dist/runtime/session-coordinator.js.map +1 -1
- package/dist/runtime/session-title.d.ts +14 -0
- package/dist/runtime/session-title.js +50 -0
- package/dist/runtime/session-title.js.map +1 -0
- package/dist/runtime/tool-defaults-wrapper.js +7 -5
- package/dist/runtime/tool-defaults-wrapper.js.map +1 -1
- package/dist/runtime/validation.js.map +1 -1
- package/dist/runtime/workflow-events.js.map +1 -1
- package/dist/runtime/workflow-runner.d.ts +3 -3
- package/dist/runtime/workflow-runner.js +1 -1
- package/dist/runtime/workflow-runner.js.map +1 -1
- package/dist/sentiment/adapters/finnhub.d.ts +1 -1
- package/dist/sentiment/adapters/finnhub.js +6 -1
- package/dist/sentiment/adapters/finnhub.js.map +1 -1
- package/dist/sentiment/adapters/reddit.d.ts +2 -2
- package/dist/sentiment/adapters/twitter.d.ts +1 -1
- package/dist/sentiment/adapters/web.d.ts +1 -1
- package/dist/sentiment/index.d.ts +10 -11
- package/dist/sentiment/index.js +10 -20
- package/dist/sentiment/index.js.map +1 -1
- package/dist/sentiment/insights.d.ts +17 -0
- package/dist/sentiment/insights.js +206 -0
- package/dist/sentiment/insights.js.map +1 -0
- package/dist/sentiment/keywords.js +26 -4
- package/dist/sentiment/keywords.js.map +1 -1
- package/dist/sentiment/pipeline.d.ts +2 -2
- package/dist/sentiment/pipeline.js +14 -2
- package/dist/sentiment/pipeline.js.map +1 -1
- package/dist/sentiment/scorer.d.ts +2 -0
- package/dist/sentiment/scorer.js +11 -2
- package/dist/sentiment/scorer.js.map +1 -1
- package/dist/sentiment/store.d.ts +1 -1
- package/dist/sentiment/store.js +1 -1
- package/dist/sentiment/store.js.map +1 -1
- package/dist/sentiment/trends.d.ts +1 -1
- package/dist/sentiment/trends.js.map +1 -1
- package/dist/sentiment/types.d.ts +2 -0
- package/dist/sentiment/types.js.map +1 -1
- package/dist/system-prompt.js +6 -9
- package/dist/system-prompt.js.map +1 -1
- package/dist/tool-kit.d.ts +7 -7
- package/dist/tool-kit.js +4 -4
- package/dist/tool-kit.js.map +1 -1
- package/dist/tools/fundamentals/company-overview.js +11 -6
- package/dist/tools/fundamentals/company-overview.js.map +1 -1
- package/dist/tools/fundamentals/comps.js +18 -9
- package/dist/tools/fundamentals/comps.js.map +1 -1
- package/dist/tools/fundamentals/dcf.js +23 -11
- package/dist/tools/fundamentals/dcf.js.map +1 -1
- package/dist/tools/fundamentals/earnings.js +8 -3
- package/dist/tools/fundamentals/earnings.js.map +1 -1
- package/dist/tools/fundamentals/financials.js +8 -3
- package/dist/tools/fundamentals/financials.js.map +1 -1
- package/dist/tools/fundamentals/sec-filings.js +21 -6
- package/dist/tools/fundamentals/sec-filings.js.map +1 -1
- package/dist/tools/index.d.ts +27 -20
- package/dist/tools/index.js +55 -43
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/interaction/ask-user.js +15 -3
- package/dist/tools/interaction/ask-user.js.map +1 -1
- package/dist/tools/macro/fear-greed.js.map +1 -1
- package/dist/tools/macro/fred-data.d.ts +1 -1
- package/dist/tools/macro/fred-data.js +17 -6
- package/dist/tools/macro/fred-data.js.map +1 -1
- package/dist/tools/market/crypto-history.js +3 -1
- package/dist/tools/market/crypto-history.js.map +1 -1
- package/dist/tools/market/crypto-price.js +3 -1
- package/dist/tools/market/crypto-price.js.map +1 -1
- package/dist/tools/market/screen-stocks.d.ts +18 -0
- package/dist/tools/market/screen-stocks.js +252 -0
- package/dist/tools/market/screen-stocks.js.map +1 -0
- package/dist/tools/market/search-ticker.js +160 -8
- package/dist/tools/market/search-ticker.js.map +1 -1
- package/dist/tools/market/stock-history.d.ts +2 -2
- package/dist/tools/market/stock-history.js +26 -7
- package/dist/tools/market/stock-history.js.map +1 -1
- package/dist/tools/market/stock-quote.js +5 -3
- package/dist/tools/market/stock-quote.js.map +1 -1
- package/dist/tools/options/greeks.js +1 -1
- package/dist/tools/options/greeks.js.map +1 -1
- package/dist/tools/options/option-chain.js +19 -6
- package/dist/tools/options/option-chain.js.map +1 -1
- package/dist/tools/portfolio/alerts.d.ts +15 -0
- package/dist/tools/portfolio/alerts.js +357 -0
- package/dist/tools/portfolio/alerts.js.map +1 -0
- package/dist/tools/portfolio/correlation.d.ts +1 -1
- package/dist/tools/portfolio/correlation.js +33 -13
- package/dist/tools/portfolio/correlation.js.map +1 -1
- package/dist/tools/portfolio/daily-report.d.ts +8 -0
- package/dist/tools/portfolio/daily-report.js +83 -0
- package/dist/tools/portfolio/daily-report.js.map +1 -0
- package/dist/tools/portfolio/holdings-overlap.js +10 -3
- package/dist/tools/portfolio/holdings-overlap.js.map +1 -1
- package/dist/tools/portfolio/notifications.d.ts +7 -0
- package/dist/tools/portfolio/notifications.js +43 -0
- package/dist/tools/portfolio/notifications.js.map +1 -0
- package/dist/tools/portfolio/predictions.d.ts +12 -6
- package/dist/tools/portfolio/predictions.js +337 -87
- package/dist/tools/portfolio/predictions.js.map +1 -1
- package/dist/tools/portfolio/risk-analysis.d.ts +1 -1
- package/dist/tools/portfolio/risk-analysis.js +45 -6
- package/dist/tools/portfolio/risk-analysis.js.map +1 -1
- package/dist/tools/portfolio/tracker.d.ts +4 -3
- package/dist/tools/portfolio/tracker.js +246 -101
- package/dist/tools/portfolio/tracker.js.map +1 -1
- package/dist/tools/portfolio/watchlist.d.ts +6 -4
- package/dist/tools/portfolio/watchlist.js +208 -108
- package/dist/tools/portfolio/watchlist.js.map +1 -1
- package/dist/tools/sentiment/insight-format.d.ts +2 -0
- package/dist/tools/sentiment/insight-format.js +36 -0
- package/dist/tools/sentiment/insight-format.js.map +1 -0
- package/dist/tools/sentiment/query-match.d.ts +3 -0
- package/dist/tools/sentiment/query-match.js +113 -0
- package/dist/tools/sentiment/query-match.js.map +1 -0
- package/dist/tools/sentiment/reddit-sentiment.d.ts +12 -1
- package/dist/tools/sentiment/reddit-sentiment.js +266 -107
- package/dist/tools/sentiment/reddit-sentiment.js.map +1 -1
- package/dist/tools/sentiment/sentiment-summary.d.ts +9 -1
- package/dist/tools/sentiment/sentiment-summary.js +223 -205
- package/dist/tools/sentiment/sentiment-summary.js.map +1 -1
- package/dist/tools/sentiment/sentiment-trend.d.ts +1 -1
- package/dist/tools/sentiment/sentiment-trend.js +12 -2
- package/dist/tools/sentiment/sentiment-trend.js.map +1 -1
- package/dist/tools/sentiment/twitter-sentiment.d.ts +11 -1
- package/dist/tools/sentiment/twitter-sentiment.js +188 -58
- package/dist/tools/sentiment/twitter-sentiment.js.map +1 -1
- package/dist/tools/sentiment/untrusted-text.d.ts +2 -0
- package/dist/tools/sentiment/untrusted-text.js +17 -0
- package/dist/tools/sentiment/untrusted-text.js.map +1 -0
- package/dist/tools/sentiment/web-search.js +9 -13
- package/dist/tools/sentiment/web-search.js.map +1 -1
- package/dist/tools/sentiment/web-sentiment.js +19 -3
- package/dist/tools/sentiment/web-sentiment.js.map +1 -1
- package/dist/tools/technical/backtest.d.ts +1 -1
- package/dist/tools/technical/backtest.js +27 -20
- package/dist/tools/technical/backtest.js.map +1 -1
- package/dist/tools/technical/indicators.js +23 -5
- package/dist/tools/technical/indicators.js.map +1 -1
- package/dist/types/index.d.ts +3 -3
- package/dist/types/index.js.map +1 -1
- package/dist/types/market.d.ts +1 -0
- package/dist/types/portfolio.d.ts +14 -4
- package/dist/types/sentiment.d.ts +52 -0
- package/dist/workflows/compare-assets.d.ts +0 -3
- package/dist/workflows/compare-assets.js +20 -11
- package/dist/workflows/compare-assets.js.map +1 -1
- package/dist/workflows/index.d.ts +3 -4
- package/dist/workflows/index.js +3 -3
- package/dist/workflows/index.js.map +1 -1
- package/dist/workflows/options-screener.d.ts +0 -3
- package/dist/workflows/options-screener.js +4 -11
- package/dist/workflows/options-screener.js.map +1 -1
- package/dist/workflows/portfolio-builder.d.ts +0 -3
- package/dist/workflows/portfolio-builder.js +0 -8
- package/dist/workflows/portfolio-builder.js.map +1 -1
- package/gui/server/ask-user-bridge.ts +1 -1
- package/gui/server/automation-heartbeat.ts +97 -0
- package/gui/server/background-quotes.ts +97 -1
- package/gui/server/chat-event-adapter.ts +32 -10
- package/gui/server/chat-run-session.ts +16 -0
- package/gui/server/invoke-tool.ts +160 -3
- package/gui/server/live-chat-event-adapter.ts +21 -6
- package/gui/server/market-state-api.ts +315 -0
- package/gui/server/model-setup.ts +156 -2
- package/gui/server/private-api-access.ts +62 -0
- package/gui/server/projector.ts +18 -9
- package/gui/server/prompt-observation.ts +4 -7
- package/gui/server/quote-snapshot-store.ts +50 -0
- package/gui/server/server.ts +218 -451
- package/gui/server/session-actions.ts +186 -1
- package/gui/server/shutdown.ts +47 -0
- package/gui/server/tool-invoke-ack.ts +49 -0
- package/gui/server/tool-metadata.ts +101 -24
- package/gui/server/websocket.ts +13 -3
- package/gui/server/writer-lock.ts +6 -2
- package/gui/server/ws-hub.ts +311 -0
- package/gui/shared/chat-events.ts +16 -1
- package/gui/shared/event-reducer.ts +24 -6
- package/gui/web/dist/assets/CatalogOverlay-CgeY5Pkp.js +1 -0
- package/gui/web/dist/assets/index-C6W_2eAn.js +69 -0
- package/gui/web/dist/assets/index-hwbx24a5.css +1 -0
- package/gui/web/dist/index.html +2 -2
- package/package.json +9 -6
- package/src/analysts/contracts.ts +10 -23
- package/src/analysts/orchestrator.ts +8 -43
- package/src/cli.ts +76 -12
- package/src/config.ts +44 -9
- package/src/index.ts +1 -1
- package/src/infra/cache.ts +41 -30
- package/src/infra/http-client.ts +72 -6
- package/src/infra/index.ts +6 -10
- package/src/infra/native-dependencies.ts +8 -3
- package/src/infra/node-version.ts +3 -1
- package/src/infra/opencandle-paths.ts +3 -14
- package/src/infra/rate-limiter.ts +22 -19
- package/src/market-state/alert-conditions.ts +82 -0
- package/src/market-state/alert-runner.ts +863 -0
- package/src/market-state/daily-report.ts +247 -0
- package/src/market-state/local-automation-service.ts +162 -0
- package/src/market-state/notification-delivery.ts +158 -0
- package/src/market-state/resolve-for-mutation.ts +24 -0
- package/src/market-state/resolve.ts +112 -0
- package/src/market-state/service.ts +2344 -0
- package/src/memory/index.ts +7 -7
- package/src/memory/manager.ts +14 -16
- package/src/memory/retrieval.ts +8 -7
- package/src/memory/sqlite.ts +407 -6
- package/src/memory/storage.ts +5 -15
- package/src/memory/tool-defaults.ts +60 -39
- package/src/memory/types.ts +3 -3
- package/src/monitor.ts +121 -0
- package/src/onboarding/connect.ts +24 -31
- package/src/onboarding/credential-interceptor.ts +3 -15
- package/src/onboarding/degradation-accumulator.ts +1 -3
- package/src/onboarding/provider-status.ts +410 -0
- package/src/onboarding/providers.ts +144 -45
- package/src/onboarding/state.ts +13 -15
- package/src/onboarding/tool-helpers.ts +2 -9
- package/src/onboarding/tool-tags.ts +51 -8
- package/src/onboarding/validation.ts +16 -22
- package/src/pi/opencandle-extension.ts +643 -101
- package/src/pi/session.ts +7 -5
- package/src/pi/setup.ts +61 -43
- package/src/pi/tool-adapter.ts +19 -6
- package/src/prompts/context-builder.ts +24 -13
- package/src/prompts/policy-cards.ts +3 -3
- package/src/prompts/sections.ts +1 -1
- package/src/prompts/symbol-preflight.ts +80 -0
- package/src/prompts/workflow-prompts.ts +77 -28
- package/src/providers/alpha-vantage.ts +58 -39
- package/src/providers/coingecko.ts +2 -5
- package/src/providers/errors.ts +9 -0
- package/src/providers/exa-search.ts +24 -22
- package/src/providers/external-tool-error.ts +20 -0
- package/src/providers/fear-greed.ts +1 -1
- package/src/providers/finnhub.ts +7 -6
- package/src/providers/fred.ts +3 -3
- package/src/providers/index.ts +14 -6
- package/src/providers/reddit-cli.ts +317 -0
- package/src/providers/reddit.ts +14 -59
- package/src/providers/sec-edgar.ts +20 -6
- package/src/providers/tradingview.ts +399 -0
- package/src/providers/twitter-cli.ts +233 -0
- package/src/providers/twitter.ts +8 -79
- package/src/providers/web-search.ts +30 -20
- package/src/providers/with-fallback.ts +8 -7
- package/src/providers/wrap-provider.ts +49 -10
- package/src/providers/yahoo-finance.ts +204 -66
- package/src/routing/classify-intent.ts +101 -10
- package/src/routing/defaults.ts +1 -1
- package/src/routing/entity-extractor.ts +287 -38
- package/src/routing/fund-symbols.ts +58 -0
- package/src/routing/horizon.ts +7 -0
- package/src/routing/index.ts +48 -48
- package/src/routing/planning.ts +145 -53
- package/src/routing/route-manifest.ts +37 -15
- package/src/routing/router-llm-client.ts +4 -4
- package/src/routing/router-prompt.ts +15 -19
- package/src/routing/router-types.ts +2 -5
- package/src/routing/router.ts +251 -53
- package/src/routing/slot-resolver.ts +34 -11
- package/src/routing/symbol-disambiguator.ts +72 -0
- package/src/routing/turn-context.ts +6 -9
- package/src/routing/types.ts +2 -0
- package/src/runtime/answer-contracts.ts +105 -45
- package/src/runtime/artifact-contracts.ts +2 -1
- package/src/runtime/planning-evidence.ts +157 -66
- package/src/runtime/prompt-step.ts +1 -16
- package/src/runtime/run-context.ts +12 -2
- package/src/runtime/session-coordinator.ts +238 -63
- package/src/runtime/session-title.ts +60 -0
- package/src/runtime/tool-defaults-wrapper.ts +13 -5
- package/src/runtime/validation.ts +1 -4
- package/src/runtime/workflow-events.ts +7 -7
- package/src/runtime/workflow-runner.ts +5 -11
- package/src/sentiment/adapters/finnhub.ts +7 -2
- package/src/sentiment/adapters/reddit.ts +2 -2
- package/src/sentiment/adapters/twitter.ts +1 -1
- package/src/sentiment/adapters/web.ts +1 -1
- package/src/sentiment/index.ts +17 -26
- package/src/sentiment/insights.ts +269 -0
- package/src/sentiment/keywords.ts +26 -4
- package/src/sentiment/pipeline.ts +28 -5
- package/src/sentiment/scorer.ts +13 -2
- package/src/sentiment/store.ts +2 -2
- package/src/sentiment/trends.ts +9 -3
- package/src/sentiment/types.ts +8 -4
- package/src/system-prompt.ts +6 -9
- package/src/tool-kit.ts +10 -9
- package/src/tools/fundamentals/company-overview.ts +19 -9
- package/src/tools/fundamentals/comps.ts +68 -55
- package/src/tools/fundamentals/dcf.ts +145 -95
- package/src/tools/fundamentals/earnings.ts +16 -6
- package/src/tools/fundamentals/financials.ts +16 -7
- package/src/tools/fundamentals/sec-filings.ts +37 -16
- package/src/tools/index.ts +56 -43
- package/src/tools/interaction/ask-user.ts +22 -10
- package/src/tools/macro/fear-greed.ts +1 -1
- package/src/tools/macro/fred-data.ts +58 -46
- package/src/tools/market/crypto-history.ts +8 -3
- package/src/tools/market/crypto-price.ts +6 -6
- package/src/tools/market/screen-stocks.ts +279 -0
- package/src/tools/market/search-ticker.ts +218 -17
- package/src/tools/market/stock-history.ts +37 -12
- package/src/tools/market/stock-quote.ts +10 -7
- package/src/tools/options/greeks.ts +5 -5
- package/src/tools/options/option-chain.ts +41 -17
- package/src/tools/portfolio/alerts.ts +457 -0
- package/src/tools/portfolio/correlation.ts +47 -20
- package/src/tools/portfolio/daily-report.ts +101 -0
- package/src/tools/portfolio/holdings-overlap.ts +31 -15
- package/src/tools/portfolio/notifications.ts +45 -0
- package/src/tools/portfolio/predictions.ts +406 -106
- package/src/tools/portfolio/risk-analysis.ts +46 -7
- package/src/tools/portfolio/tracker.ts +270 -109
- package/src/tools/portfolio/watchlist.ts +250 -121
- package/src/tools/sentiment/insight-format.ts +50 -0
- package/src/tools/sentiment/query-match.ts +117 -0
- package/src/tools/sentiment/reddit-sentiment.ts +360 -121
- package/src/tools/sentiment/sentiment-summary.ts +302 -235
- package/src/tools/sentiment/sentiment-trend.ts +24 -7
- package/src/tools/sentiment/twitter-sentiment.ts +264 -73
- package/src/tools/sentiment/untrusted-text.ts +21 -0
- package/src/tools/sentiment/web-search.ts +21 -18
- package/src/tools/sentiment/web-sentiment.ts +30 -10
- package/src/tools/technical/backtest.ts +32 -22
- package/src/tools/technical/indicators.ts +39 -14
- package/src/types/index.ts +8 -3
- package/src/types/market.ts +1 -0
- package/src/types/portfolio.ts +14 -4
- package/src/types/sentiment.ts +61 -2
- package/src/workflows/compare-assets.ts +33 -21
- package/src/workflows/index.ts +3 -4
- package/src/workflows/options-screener.ts +27 -29
- package/src/workflows/portfolio-builder.ts +34 -27
- package/dist/infra/browser.d.ts +0 -35
- package/dist/infra/browser.js +0 -103
- package/dist/infra/browser.js.map +0 -1
- package/dist/tools/interaction/twitter-login.d.ts +0 -8
- package/dist/tools/interaction/twitter-login.js +0 -77
- package/dist/tools/interaction/twitter-login.js.map +0 -1
- package/dist/workflows/types.d.ts +0 -4
- package/dist/workflows/types.js +0 -2
- package/dist/workflows/types.js.map +0 -1
- package/gui/web/dist/assets/CatalogOverlay-Bmp6Knu7.js +0 -1
- package/gui/web/dist/assets/index-Bxt9QpLX.css +0 -1
- package/gui/web/dist/assets/index-CZ9DHZYy.js +0 -67
- package/src/infra/browser.ts +0 -111
- package/src/tools/interaction/twitter-login.ts +0 -93
- package/src/workflows/types.ts +0 -4
|
@@ -1,20 +1,25 @@
|
|
|
1
|
-
import { Type } from "@sinclair/typebox";
|
|
2
1
|
import type { AgentTool } from "@earendil-works/pi-agent-core";
|
|
2
|
+
import { Type } from "@sinclair/typebox";
|
|
3
3
|
import { searchFilings } from "../../providers/sec-edgar.js";
|
|
4
4
|
import { wrapProvider } from "../../providers/wrap-provider.js";
|
|
5
|
+
import { renderUntrustedText, untrustedContentHeader } from "../sentiment/untrusted-text.js";
|
|
5
6
|
|
|
6
7
|
const params = Type.Object({
|
|
7
8
|
symbol: Type.String({ description: "Stock ticker symbol (e.g. AAPL, MSFT, TSLA)" }),
|
|
8
9
|
form_types: Type.Optional(
|
|
9
10
|
Type.Array(Type.String(), {
|
|
10
|
-
description:
|
|
11
|
+
description:
|
|
12
|
+
"Filing types to search: 10-K (annual), 10-Q (quarterly), 8-K (material events). Default: all three.",
|
|
11
13
|
}),
|
|
12
14
|
),
|
|
13
15
|
limit: Type.Optional(
|
|
14
16
|
Type.Number({ description: "Maximum number of filings to return (default: 10)" }),
|
|
15
17
|
),
|
|
16
18
|
include_snippets: Type.Optional(
|
|
17
|
-
Type.Boolean({
|
|
19
|
+
Type.Boolean({
|
|
20
|
+
description:
|
|
21
|
+
"Include short filing-text evidence snippets for risk/MD&A/litigation themes. Default: true.",
|
|
22
|
+
}),
|
|
18
23
|
),
|
|
19
24
|
});
|
|
20
25
|
|
|
@@ -31,11 +36,13 @@ export const secFilingsTool: AgentTool<typeof params> = {
|
|
|
31
36
|
const includeSnippets = args.include_snippets ?? true;
|
|
32
37
|
|
|
33
38
|
const result = await wrapProvider("sec-edgar", () =>
|
|
34
|
-
searchFilings(symbol, formTypes, limit, { includeSnippets, snippetLimitPerFiling: 2 })
|
|
39
|
+
searchFilings(symbol, formTypes, limit, { includeSnippets, snippetLimitPerFiling: 2 }),
|
|
35
40
|
);
|
|
36
41
|
if (result.status === "unavailable") {
|
|
37
42
|
return {
|
|
38
|
-
content: [
|
|
43
|
+
content: [
|
|
44
|
+
{ type: "text", text: `⚠ SEC filings unavailable for ${symbol} (${result.reason}).` },
|
|
45
|
+
],
|
|
39
46
|
details: null,
|
|
40
47
|
};
|
|
41
48
|
}
|
|
@@ -43,7 +50,12 @@ export const secFilingsTool: AgentTool<typeof params> = {
|
|
|
43
50
|
|
|
44
51
|
if (filings.length === 0) {
|
|
45
52
|
return {
|
|
46
|
-
content: [
|
|
53
|
+
content: [
|
|
54
|
+
{
|
|
55
|
+
type: "text",
|
|
56
|
+
text: `No SEC filings found for ${symbol}. Verify the ticker is a US-listed company.`,
|
|
57
|
+
},
|
|
58
|
+
],
|
|
47
59
|
details: null,
|
|
48
60
|
};
|
|
49
61
|
}
|
|
@@ -51,8 +63,9 @@ export const secFilingsTool: AgentTool<typeof params> = {
|
|
|
51
63
|
const lines = [
|
|
52
64
|
`**${symbol} SEC Filings** (${filings.length} found)`,
|
|
53
65
|
``,
|
|
54
|
-
...filings.map(
|
|
55
|
-
|
|
66
|
+
...filings.map(
|
|
67
|
+
(f) =>
|
|
68
|
+
` ${f.formType.padEnd(6)} | Filed: ${f.filedDate} | Period: ${f.periodOfReport || "N/A"} | ${f.entityName}`,
|
|
56
69
|
),
|
|
57
70
|
``,
|
|
58
71
|
`Links:`,
|
|
@@ -65,14 +78,22 @@ export const secFilingsTool: AgentTool<typeof params> = {
|
|
|
65
78
|
]),
|
|
66
79
|
...(includeSnippets
|
|
67
80
|
? [
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
(f
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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
|
+
]
|
|
76
97
|
: []),
|
|
77
98
|
];
|
|
78
99
|
|
package/src/tools/index.ts
CHANGED
|
@@ -1,67 +1,77 @@
|
|
|
1
1
|
import type { AgentTool } from "@earendil-works/pi-agent-core";
|
|
2
|
-
import {
|
|
3
|
-
import { stockHistoryTool } from "./market/stock-history.js";
|
|
4
|
-
import { cryptoPriceTool } from "./market/crypto-price.js";
|
|
5
|
-
import { cryptoHistoryTool } from "./market/crypto-history.js";
|
|
6
|
-
import { searchTickerTool } from "./market/search-ticker.js";
|
|
2
|
+
import type { AskUserHandler } from "../types/index.js";
|
|
7
3
|
import { companyOverviewTool } from "./fundamentals/company-overview.js";
|
|
8
|
-
import {
|
|
4
|
+
import { compsTool } from "./fundamentals/comps.js";
|
|
5
|
+
import { dcfTool } from "./fundamentals/dcf.js";
|
|
9
6
|
import { earningsTool } from "./fundamentals/earnings.js";
|
|
10
|
-
import {
|
|
7
|
+
import { financialsTool } from "./fundamentals/financials.js";
|
|
8
|
+
import { secFilingsTool } from "./fundamentals/sec-filings.js";
|
|
11
9
|
import { fearGreedTool } from "./macro/fear-greed.js";
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
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";
|
|
18
19
|
import { correlationTool } from "./portfolio/correlation.js";
|
|
20
|
+
import { dailyReportTool } from "./portfolio/daily-report.js";
|
|
19
21
|
import { holdingsOverlapTool } from "./portfolio/holdings-overlap.js";
|
|
20
|
-
import {
|
|
21
|
-
import { dcfTool } from "./fundamentals/dcf.js";
|
|
22
|
-
import { compsTool } from "./fundamentals/comps.js";
|
|
23
|
-
import { secFilingsTool } from "./fundamentals/sec-filings.js";
|
|
24
|
-
import { backtestTool } from "./technical/backtest.js";
|
|
22
|
+
import { notificationsTool } from "./portfolio/notifications.js";
|
|
25
23
|
import { predictionsTool } from "./portfolio/predictions.js";
|
|
24
|
+
import { riskAnalysisTool } from "./portfolio/risk-analysis.js";
|
|
25
|
+
import { portfolioTrackerTool } from "./portfolio/tracker.js";
|
|
26
|
+
import { watchlistTool } from "./portfolio/watchlist.js";
|
|
27
|
+
import { createRedditSentimentTool } from "./sentiment/reddit-sentiment.js";
|
|
28
|
+
import { createSentimentSummaryTool } from "./sentiment/sentiment-summary.js";
|
|
29
|
+
import { sentimentTrendTool } from "./sentiment/sentiment-trend.js";
|
|
30
|
+
import { createTwitterSentimentTool } from "./sentiment/twitter-sentiment.js";
|
|
26
31
|
import { webSearchTool } from "./sentiment/web-search.js";
|
|
27
32
|
import { webSentimentTool } from "./sentiment/web-sentiment.js";
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
33
|
+
import { backtestTool } from "./technical/backtest.js";
|
|
34
|
+
import { technicalIndicatorsTool } from "./technical/indicators.js";
|
|
30
35
|
|
|
31
|
-
export { stockQuoteTool } from "./market/stock-quote.js";
|
|
32
|
-
export { stockHistoryTool } from "./market/stock-history.js";
|
|
33
|
-
export { cryptoPriceTool } from "./market/crypto-price.js";
|
|
34
|
-
export { cryptoHistoryTool } from "./market/crypto-history.js";
|
|
35
|
-
export { searchTickerTool } from "./market/search-ticker.js";
|
|
36
36
|
export { companyOverviewTool } from "./fundamentals/company-overview.js";
|
|
37
|
-
export { financialsTool } from "./fundamentals/financials.js";
|
|
38
|
-
export { earningsTool } from "./fundamentals/earnings.js";
|
|
39
|
-
export { dcfTool } from "./fundamentals/dcf.js";
|
|
40
37
|
export { compsTool } from "./fundamentals/comps.js";
|
|
38
|
+
export { dcfTool } from "./fundamentals/dcf.js";
|
|
39
|
+
export { earningsTool } from "./fundamentals/earnings.js";
|
|
40
|
+
export { financialsTool } from "./fundamentals/financials.js";
|
|
41
41
|
export { secFilingsTool } from "./fundamentals/sec-filings.js";
|
|
42
|
-
export { fredDataTool } from "./macro/fred-data.js";
|
|
43
42
|
export { fearGreedTool } from "./macro/fear-greed.js";
|
|
43
|
+
export { fredDataTool } from "./macro/fred-data.js";
|
|
44
|
+
export { cryptoHistoryTool } from "./market/crypto-history.js";
|
|
45
|
+
export { cryptoPriceTool } from "./market/crypto-price.js";
|
|
46
|
+
export { screenStocksTool } from "./market/screen-stocks.js";
|
|
47
|
+
export { searchTickerTool } from "./market/search-ticker.js";
|
|
48
|
+
export { stockHistoryTool } from "./market/stock-history.js";
|
|
49
|
+
export { stockQuoteTool } from "./market/stock-quote.js";
|
|
50
|
+
export { optionChainTool } from "./options/option-chain.js";
|
|
51
|
+
export { alertsTool } from "./portfolio/alerts.js";
|
|
52
|
+
export { correlationTool } from "./portfolio/correlation.js";
|
|
53
|
+
export { dailyReportTool } from "./portfolio/daily-report.js";
|
|
54
|
+
export { holdingsOverlapTool } from "./portfolio/holdings-overlap.js";
|
|
55
|
+
export { notificationsTool } from "./portfolio/notifications.js";
|
|
56
|
+
export { predictionsTool } from "./portfolio/predictions.js";
|
|
57
|
+
export { riskAnalysisTool } from "./portfolio/risk-analysis.js";
|
|
58
|
+
export { portfolioTrackerTool } from "./portfolio/tracker.js";
|
|
59
|
+
export { watchlistTool } from "./portfolio/watchlist.js";
|
|
44
60
|
export { redditSentimentTool } from "./sentiment/reddit-sentiment.js";
|
|
61
|
+
export { createSentimentSummaryTool, sentimentSummaryTool } from "./sentiment/sentiment-summary.js";
|
|
62
|
+
export { sentimentTrendTool } from "./sentiment/sentiment-trend.js";
|
|
45
63
|
export { twitterSentimentTool } from "./sentiment/twitter-sentiment.js";
|
|
46
64
|
export { webSearchTool } from "./sentiment/web-search.js";
|
|
47
65
|
export { webSentimentTool } from "./sentiment/web-sentiment.js";
|
|
48
|
-
export { sentimentTrendTool } from "./sentiment/sentiment-trend.js";
|
|
49
|
-
export { sentimentSummaryTool } from "./sentiment/sentiment-summary.js";
|
|
50
|
-
export { technicalIndicatorsTool } from "./technical/indicators.js";
|
|
51
66
|
export { backtestTool } from "./technical/backtest.js";
|
|
52
|
-
export {
|
|
53
|
-
export { riskAnalysisTool } from "./portfolio/risk-analysis.js";
|
|
54
|
-
export { watchlistTool } from "./portfolio/watchlist.js";
|
|
55
|
-
export { correlationTool } from "./portfolio/correlation.js";
|
|
56
|
-
export { holdingsOverlapTool } from "./portfolio/holdings-overlap.js";
|
|
57
|
-
export { predictionsTool } from "./portfolio/predictions.js";
|
|
58
|
-
export { optionChainTool } from "./options/option-chain.js";
|
|
67
|
+
export { technicalIndicatorsTool } from "./technical/indicators.js";
|
|
59
68
|
|
|
60
|
-
export function getAllTools(): AgentTool<any>[] {
|
|
69
|
+
export function getAllTools(options: { askUserHandler?: AskUserHandler } = {}): AgentTool<any>[] {
|
|
61
70
|
return [
|
|
62
71
|
searchTickerTool,
|
|
63
72
|
stockQuoteTool,
|
|
64
73
|
stockHistoryTool,
|
|
74
|
+
screenStocksTool,
|
|
65
75
|
cryptoPriceTool,
|
|
66
76
|
cryptoHistoryTool,
|
|
67
77
|
companyOverviewTool,
|
|
@@ -72,8 +82,8 @@ export function getAllTools(): AgentTool<any>[] {
|
|
|
72
82
|
secFilingsTool,
|
|
73
83
|
fredDataTool,
|
|
74
84
|
fearGreedTool,
|
|
75
|
-
|
|
76
|
-
|
|
85
|
+
createRedditSentimentTool({ askUserHandler: options.askUserHandler }),
|
|
86
|
+
createTwitterSentimentTool({ askUserHandler: options.askUserHandler }),
|
|
77
87
|
technicalIndicatorsTool,
|
|
78
88
|
backtestTool,
|
|
79
89
|
portfolioTrackerTool,
|
|
@@ -82,10 +92,13 @@ export function getAllTools(): AgentTool<any>[] {
|
|
|
82
92
|
correlationTool,
|
|
83
93
|
holdingsOverlapTool,
|
|
84
94
|
predictionsTool,
|
|
95
|
+
alertsTool,
|
|
96
|
+
dailyReportTool,
|
|
97
|
+
notificationsTool,
|
|
85
98
|
optionChainTool,
|
|
86
99
|
webSearchTool,
|
|
87
100
|
webSentimentTool,
|
|
88
101
|
sentimentTrendTool,
|
|
89
|
-
|
|
102
|
+
createSentimentSummaryTool({ askUserHandler: options.askUserHandler }),
|
|
90
103
|
];
|
|
91
104
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Type } from "@sinclair/typebox";
|
|
2
1
|
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { Type } from "@sinclair/typebox";
|
|
3
3
|
import { promptUser } from "../../onboarding/prompt-user.js";
|
|
4
4
|
import type { AskUserHandler } from "../../types/index.js";
|
|
5
5
|
|
|
@@ -14,14 +14,15 @@ const AskUserParams = Type.Object({
|
|
|
14
14
|
question: Type.String({ description: "The question to ask the user" }),
|
|
15
15
|
question_type: Type.Union(
|
|
16
16
|
[Type.Literal("select"), Type.Literal("text"), Type.Literal("confirm")],
|
|
17
|
-
{
|
|
17
|
+
{
|
|
18
|
+
description:
|
|
19
|
+
"Type of answer expected: select (pick from options), text (free input), or confirm (yes/no)",
|
|
20
|
+
},
|
|
18
21
|
),
|
|
19
22
|
options: Type.Optional(
|
|
20
23
|
Type.Array(Type.String(), { description: "Choices for select-type questions" }),
|
|
21
24
|
),
|
|
22
|
-
placeholder: Type.Optional(
|
|
23
|
-
Type.String({ description: "Hint text for text input" }),
|
|
24
|
-
),
|
|
25
|
+
placeholder: Type.Optional(Type.String({ description: "Hint text for text input" })),
|
|
25
26
|
reason: Type.Optional(
|
|
26
27
|
Type.String({ description: "Brief context for why this clarification is needed" }),
|
|
27
28
|
),
|
|
@@ -45,7 +46,12 @@ export function registerAskUserTool(pi: ExtensionAPI, askUserHandler?: AskUserHa
|
|
|
45
46
|
// model/caller bug, not a cancellation.
|
|
46
47
|
if (questionType === "select" && (!params.options || params.options.length === 0)) {
|
|
47
48
|
return {
|
|
48
|
-
content: [
|
|
49
|
+
content: [
|
|
50
|
+
{
|
|
51
|
+
type: "text",
|
|
52
|
+
text: "Error: No options provided for select question. Provide options or use text type instead.",
|
|
53
|
+
},
|
|
54
|
+
],
|
|
49
55
|
details: { question, questionType, answer: null, cancelled: true } as AskUserDetails,
|
|
50
56
|
};
|
|
51
57
|
}
|
|
@@ -63,9 +69,10 @@ export function registerAskUserTool(pi: ExtensionAPI, askUserHandler?: AskUserHa
|
|
|
63
69
|
);
|
|
64
70
|
|
|
65
71
|
if (result.cancelled) {
|
|
66
|
-
const text =
|
|
67
|
-
|
|
68
|
-
|
|
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.";
|
|
69
76
|
return {
|
|
70
77
|
content: [{ type: "text", text }],
|
|
71
78
|
details: { question, questionType, answer: null, cancelled: true } as AskUserDetails,
|
|
@@ -74,7 +81,12 @@ export function registerAskUserTool(pi: ExtensionAPI, askUserHandler?: AskUserHa
|
|
|
74
81
|
|
|
75
82
|
return {
|
|
76
83
|
content: [{ type: "text", text: `User answered: ${result.answer}` }],
|
|
77
|
-
details: {
|
|
84
|
+
details: {
|
|
85
|
+
question,
|
|
86
|
+
questionType,
|
|
87
|
+
answer: result.answer,
|
|
88
|
+
cancelled: false,
|
|
89
|
+
} as AskUserDetails,
|
|
78
90
|
};
|
|
79
91
|
},
|
|
80
92
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Type } from "@sinclair/typebox";
|
|
2
1
|
import type { AgentTool } from "@earendil-works/pi-agent-core";
|
|
2
|
+
import { Type } from "@sinclair/typebox";
|
|
3
3
|
import { getFearGreedIndex } from "../../providers/fear-greed.js";
|
|
4
4
|
import { wrapProvider } from "../../providers/wrap-provider.js";
|
|
5
5
|
import type { FearGreedData } from "../../types/sentiment.js";
|
|
@@ -1,64 +1,76 @@
|
|
|
1
|
-
import { Type } from "@sinclair/typebox";
|
|
2
1
|
import type { AgentTool } from "@earendil-works/pi-agent-core";
|
|
3
|
-
import {
|
|
4
|
-
import { wrapProvider } from "../../providers/wrap-provider.js";
|
|
2
|
+
import { Type } from "@sinclair/typebox";
|
|
5
3
|
import { getConfig } from "../../config.js";
|
|
6
4
|
import { withCredentialCheck } from "../../onboarding/tool-helpers.js";
|
|
7
|
-
import {
|
|
5
|
+
import { getSeries } from "../../providers/fred.js";
|
|
6
|
+
import { wrapProvider } from "../../providers/wrap-provider.js";
|
|
8
7
|
import type { FredSeries } from "../../types/macro.js";
|
|
8
|
+
import { FRED_SERIES } from "../../types/macro.js";
|
|
9
9
|
|
|
10
10
|
const params = Type.Object({
|
|
11
11
|
series_id: Type.String({
|
|
12
|
-
description: `FRED series ID. Common ones: ${Object.entries(FRED_SERIES)
|
|
12
|
+
description: `FRED series ID. Common ones: ${Object.entries(FRED_SERIES)
|
|
13
|
+
.map(([k, v]) => `${v} (${k})`)
|
|
14
|
+
.join(", ")}`,
|
|
13
15
|
}),
|
|
14
16
|
limit: Type.Optional(
|
|
15
|
-
Type.
|
|
17
|
+
Type.Integer({
|
|
18
|
+
minimum: 1,
|
|
19
|
+
maximum: 1000,
|
|
20
|
+
description: "Number of observations to return. Default: 30",
|
|
21
|
+
}),
|
|
16
22
|
),
|
|
17
23
|
});
|
|
18
24
|
|
|
19
|
-
export const fredDataTool: AgentTool<typeof params, FredSeries | { credentialRequired: unknown }> =
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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;
|
|
38
47
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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);
|
|
44
53
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
54
|
+
// Show last 10 observations
|
|
55
|
+
const recent = series.observations.slice(-10);
|
|
56
|
+
const table = recent.map((o) => `${o.date}: ${o.value}`).join("\n");
|
|
48
57
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
};
|
|
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
|
+
};
|
|
59
68
|
|
|
60
69
|
function normalizeLimit(seriesId: string, requested: number | undefined): number {
|
|
61
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
|
+
}
|
|
62
74
|
if (seriesId === FRED_SERIES.CPI && limit < 13) return 13;
|
|
63
75
|
return limit;
|
|
64
76
|
}
|
|
@@ -70,11 +82,11 @@ function formatDerivedChange(series: FredSeries): string | null {
|
|
|
70
82
|
|
|
71
83
|
const latestYear = Number(latest.date.slice(0, 4));
|
|
72
84
|
const monthDay = latest.date.slice(4);
|
|
73
|
-
const prior = series.observations.find(
|
|
74
|
-
observation.date === `${latestYear - 1}${monthDay}
|
|
85
|
+
const prior = series.observations.find(
|
|
86
|
+
(observation) => observation.date === `${latestYear - 1}${monthDay}`,
|
|
75
87
|
);
|
|
76
88
|
if (!prior || prior.value === 0) return null;
|
|
77
89
|
|
|
78
|
-
const pct = (
|
|
90
|
+
const pct = (latest.value / prior.value - 1) * 100;
|
|
79
91
|
return `Derived YoY change: ${pct.toFixed(2)}% (${prior.date} to ${latest.date}).`;
|
|
80
92
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Type } from "@sinclair/typebox";
|
|
2
1
|
import type { AgentTool } from "@earendil-works/pi-agent-core";
|
|
2
|
+
import { Type } from "@sinclair/typebox";
|
|
3
3
|
import { getCryptoHistory } from "../../providers/coingecko.js";
|
|
4
4
|
import { wrapProvider } from "../../providers/wrap-provider.js";
|
|
5
5
|
import type { OHLCV } from "../../types/market.js";
|
|
@@ -27,7 +27,9 @@ export const cryptoHistoryTool: AgentTool<typeof params, OHLCV[]> = {
|
|
|
27
27
|
const result = await wrapProvider("coingecko", () => getCryptoHistory(id, days));
|
|
28
28
|
if (result.status === "unavailable") {
|
|
29
29
|
return {
|
|
30
|
-
content: [
|
|
30
|
+
content: [
|
|
31
|
+
{ type: "text", text: `⚠ Crypto history unavailable for ${id} (${result.reason}).` },
|
|
32
|
+
],
|
|
31
33
|
details: [],
|
|
32
34
|
};
|
|
33
35
|
}
|
|
@@ -54,7 +56,10 @@ export const cryptoHistoryTool: AgentTool<typeof params, OHLCV[]> = {
|
|
|
54
56
|
|
|
55
57
|
function buildRiskLines(id: string, bars: OHLCV[]): string[] {
|
|
56
58
|
if (bars.length < 30) return [];
|
|
57
|
-
const metrics = computeRiskMetrics(
|
|
59
|
+
const metrics = computeRiskMetrics(
|
|
60
|
+
id.toUpperCase(),
|
|
61
|
+
bars.map((bar) => bar.close),
|
|
62
|
+
);
|
|
58
63
|
return [
|
|
59
64
|
"",
|
|
60
65
|
"Risk metrics from crypto history:",
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { Type } from "@sinclair/typebox";
|
|
2
1
|
import type { AgentTool } from "@earendil-works/pi-agent-core";
|
|
2
|
+
import { Type } from "@sinclair/typebox";
|
|
3
3
|
import { getCryptoPrice } from "../../providers/coingecko.js";
|
|
4
4
|
import { wrapProvider } from "../../providers/wrap-provider.js";
|
|
5
5
|
import type { CryptoPrice } from "../../types/market.js";
|
|
6
6
|
|
|
7
7
|
const params = Type.Object({
|
|
8
8
|
id: Type.String({
|
|
9
|
-
description:
|
|
10
|
-
"CoinGecko coin ID (e.g. bitcoin, ethereum, solana, dogecoin). Use lowercase.",
|
|
9
|
+
description: "CoinGecko coin ID (e.g. bitcoin, ethereum, solana, dogecoin). Use lowercase.",
|
|
11
10
|
}),
|
|
12
11
|
});
|
|
13
12
|
|
|
14
13
|
export const cryptoPriceTool: AgentTool<typeof params, CryptoPrice> = {
|
|
15
14
|
name: "get_crypto_price",
|
|
16
15
|
label: "Crypto Price",
|
|
17
|
-
description:
|
|
18
|
-
"Get current crypto price, 24h change, market cap, volume, ATH, and supply data",
|
|
16
|
+
description: "Get current crypto price, 24h change, market cap, volume, ATH, and supply data",
|
|
19
17
|
parameters: params,
|
|
20
18
|
async execute(_toolCallId, args) {
|
|
21
19
|
const result = await wrapProvider("coingecko", () => getCryptoPrice(args.id.toLowerCase()));
|
|
22
20
|
if (result.status === "unavailable") {
|
|
23
21
|
return {
|
|
24
|
-
content: [
|
|
22
|
+
content: [
|
|
23
|
+
{ type: "text", text: `⚠ Crypto price unavailable for ${args.id} (${result.reason}).` },
|
|
24
|
+
],
|
|
25
25
|
details: null as any,
|
|
26
26
|
};
|
|
27
27
|
}
|