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
package/src/memory/storage.ts
DELETED
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
import type Database from "better-sqlite3";
|
|
2
|
-
|
|
3
|
-
interface PreferenceInput {
|
|
4
|
-
namespace?: string;
|
|
5
|
-
key: string;
|
|
6
|
-
valueJson: string;
|
|
7
|
-
confidence?: string;
|
|
8
|
-
source?: string;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface WorkflowPreferences {
|
|
12
|
-
riskProfile?: string;
|
|
13
|
-
timeHorizon?: string;
|
|
14
|
-
assetScope?: string;
|
|
15
|
-
positionCount?: number;
|
|
16
|
-
maxSinglePositionPct?: number;
|
|
17
|
-
dteTarget?: string;
|
|
18
|
-
objective?: string;
|
|
19
|
-
moneynessPreference?: string;
|
|
20
|
-
liquidityMinimum?: string;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
interface WorkflowRunInput {
|
|
24
|
-
sessionId: string;
|
|
25
|
-
workflowType: string;
|
|
26
|
-
inputSlotsJson: string;
|
|
27
|
-
resolvedSlotsJson: string;
|
|
28
|
-
defaultsUsedJson: string;
|
|
29
|
-
outputSummary?: string;
|
|
30
|
-
/**
|
|
31
|
-
* Router route verbatim. Legacy rows contain `"workflow"` or `"fallback"`;
|
|
32
|
-
* typed-router rows may contain canonical route kinds. Defaults to
|
|
33
|
-
* `"workflow"` at the schema layer so legacy callers (rules-mode cascade)
|
|
34
|
-
* don't need to pass anything. Router-mode callers MUST pass this explicitly.
|
|
35
|
-
*/
|
|
36
|
-
turnType?: string;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
interface RecommendationInput {
|
|
40
|
-
workflowRunId: number;
|
|
41
|
-
recommendationType: string;
|
|
42
|
-
symbol?: string;
|
|
43
|
-
payloadJson?: string;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export class MemoryStorage {
|
|
47
|
-
constructor(private readonly db: Database.Database) {}
|
|
48
|
-
|
|
49
|
-
// --- Preferences ---
|
|
50
|
-
|
|
51
|
-
upsertPreference(input: PreferenceInput): void {
|
|
52
|
-
const now = new Date().toISOString();
|
|
53
|
-
const ns = input.namespace ?? "global";
|
|
54
|
-
const confidence = input.confidence ?? "medium";
|
|
55
|
-
const source = input.source ?? "explicit";
|
|
56
|
-
|
|
57
|
-
this.db
|
|
58
|
-
.prepare(
|
|
59
|
-
`INSERT INTO user_preferences (namespace, key, value_json, confidence, source, created_at, updated_at)
|
|
60
|
-
VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
61
|
-
ON CONFLICT(namespace, key) DO UPDATE SET
|
|
62
|
-
value_json = excluded.value_json,
|
|
63
|
-
confidence = excluded.confidence,
|
|
64
|
-
source = excluded.source,
|
|
65
|
-
updated_at = excluded.updated_at`,
|
|
66
|
-
)
|
|
67
|
-
.run(ns, input.key, input.valueJson, confidence, source, now, now);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
getPreference(namespace: string, key: string): Record<string, string | number | null> | null {
|
|
71
|
-
return (
|
|
72
|
-
(this.db
|
|
73
|
-
.prepare("SELECT * FROM user_preferences WHERE namespace = ? AND key = ?")
|
|
74
|
-
.get(namespace, key) as Record<string, string | number | null>) ?? null
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
getPreferencesByNamespace(namespace: string): Array<Record<string, string | number | null>> {
|
|
79
|
-
return this.db
|
|
80
|
-
.prepare("SELECT * FROM user_preferences WHERE namespace = ?")
|
|
81
|
-
.all(namespace) as Array<Record<string, string | number | null>>;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
getWorkflowPreferences(namespace: string = "global"): WorkflowPreferences {
|
|
85
|
-
const prefs = this.getPreferencesByNamespace(namespace);
|
|
86
|
-
const out: WorkflowPreferences = {};
|
|
87
|
-
|
|
88
|
-
for (const pref of prefs) {
|
|
89
|
-
const key = String(pref.key);
|
|
90
|
-
const raw = pref.value_json == null ? undefined : safeParseJson(String(pref.value_json));
|
|
91
|
-
|
|
92
|
-
switch (key) {
|
|
93
|
-
case "risk_profile":
|
|
94
|
-
if (typeof raw === "string") out.riskProfile = raw;
|
|
95
|
-
break;
|
|
96
|
-
case "time_horizon":
|
|
97
|
-
if (typeof raw === "string") out.timeHorizon = raw;
|
|
98
|
-
break;
|
|
99
|
-
case "asset_scope":
|
|
100
|
-
if (typeof raw === "string") out.assetScope = raw;
|
|
101
|
-
break;
|
|
102
|
-
case "position_count":
|
|
103
|
-
if (typeof raw === "number") out.positionCount = raw;
|
|
104
|
-
break;
|
|
105
|
-
case "max_single_position_pct":
|
|
106
|
-
if (typeof raw === "number") out.maxSinglePositionPct = raw;
|
|
107
|
-
break;
|
|
108
|
-
case "dte_target":
|
|
109
|
-
if (typeof raw === "string") out.dteTarget = raw;
|
|
110
|
-
break;
|
|
111
|
-
case "objective":
|
|
112
|
-
if (typeof raw === "string") out.objective = raw;
|
|
113
|
-
break;
|
|
114
|
-
case "moneyness_preference":
|
|
115
|
-
if (typeof raw === "string") out.moneynessPreference = raw;
|
|
116
|
-
break;
|
|
117
|
-
case "options_liquidity":
|
|
118
|
-
case "liquidity_minimum":
|
|
119
|
-
if (typeof raw === "string") {
|
|
120
|
-
out.liquidityMinimum = raw === "high" ? "high_open_interest_and_tight_spread" : raw;
|
|
121
|
-
}
|
|
122
|
-
break;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
return out;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
// --- Workflow Runs ---
|
|
130
|
-
|
|
131
|
-
insertWorkflowRun(input: WorkflowRunInput): number {
|
|
132
|
-
const now = new Date().toISOString();
|
|
133
|
-
const result = this.db
|
|
134
|
-
.prepare(
|
|
135
|
-
`INSERT INTO workflow_runs (session_id, workflow_type, input_slots_json, resolved_slots_json, defaults_used_json, output_summary, created_at, turn_type)
|
|
136
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?)`,
|
|
137
|
-
)
|
|
138
|
-
.run(
|
|
139
|
-
input.sessionId,
|
|
140
|
-
input.workflowType,
|
|
141
|
-
input.inputSlotsJson,
|
|
142
|
-
input.resolvedSlotsJson,
|
|
143
|
-
input.defaultsUsedJson,
|
|
144
|
-
input.outputSummary ?? null,
|
|
145
|
-
now,
|
|
146
|
-
input.turnType ?? "workflow",
|
|
147
|
-
);
|
|
148
|
-
return Number(result.lastInsertRowid);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
getRecentWorkflowRuns(limit: number): Array<Record<string, string | number | null>> {
|
|
152
|
-
return this.db
|
|
153
|
-
.prepare("SELECT * FROM workflow_runs ORDER BY id DESC LIMIT ?")
|
|
154
|
-
.all(limit) as Array<Record<string, string | number | null>>;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
updateWorkflowRunOutputSummary(workflowRunId: number, outputSummary: string): void {
|
|
158
|
-
this.db
|
|
159
|
-
.prepare("UPDATE workflow_runs SET output_summary = ? WHERE id = ?")
|
|
160
|
-
.run(outputSummary, workflowRunId);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
// --- Recommendations ---
|
|
164
|
-
|
|
165
|
-
insertRecommendation(input: RecommendationInput): number {
|
|
166
|
-
const now = new Date().toISOString();
|
|
167
|
-
const result = this.db
|
|
168
|
-
.prepare(
|
|
169
|
-
`INSERT INTO recommendations (workflow_run_id, recommendation_type, symbol, payload_json, created_at)
|
|
170
|
-
VALUES (?, ?, ?, ?, ?)`,
|
|
171
|
-
)
|
|
172
|
-
.run(
|
|
173
|
-
input.workflowRunId,
|
|
174
|
-
input.recommendationType,
|
|
175
|
-
input.symbol ?? null,
|
|
176
|
-
input.payloadJson ?? null,
|
|
177
|
-
now,
|
|
178
|
-
);
|
|
179
|
-
return Number(result.lastInsertRowid);
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
getRecommendationsByRun(workflowRunId: number): Array<Record<string, string | number | null>> {
|
|
183
|
-
return this.db
|
|
184
|
-
.prepare("SELECT * FROM recommendations WHERE workflow_run_id = ? ORDER BY id")
|
|
185
|
-
.all(workflowRunId) as Array<Record<string, string | number | null>>;
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
function safeParseJson(json: string): unknown {
|
|
190
|
-
try {
|
|
191
|
-
return JSON.parse(json);
|
|
192
|
-
} catch {
|
|
193
|
-
return json;
|
|
194
|
-
}
|
|
195
|
-
}
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { initDefaultDatabase } from "./sqlite.js";
|
|
2
|
-
|
|
3
|
-
export type ToolDefaults = Record<string, unknown>;
|
|
4
|
-
type SqliteDb = ReturnType<typeof initDefaultDatabase>;
|
|
5
|
-
|
|
6
|
-
export function getDefaults(toolName: string, db?: SqliteDb): ToolDefaults {
|
|
7
|
-
const ownedDb = db == null;
|
|
8
|
-
const connection = db ?? initDefaultDatabase();
|
|
9
|
-
try {
|
|
10
|
-
const rows = connection
|
|
11
|
-
.prepare(
|
|
12
|
-
`SELECT param_path, value_json FROM tool_defaults WHERE tool_name = ? ORDER BY param_path`,
|
|
13
|
-
)
|
|
14
|
-
.all(toolName) as Array<{ param_path: string; value_json: string }>;
|
|
15
|
-
|
|
16
|
-
const defaults: ToolDefaults = {};
|
|
17
|
-
for (const row of rows) {
|
|
18
|
-
setPath(defaults, row.param_path, parseStoredValue(row.value_json));
|
|
19
|
-
}
|
|
20
|
-
return defaults;
|
|
21
|
-
} finally {
|
|
22
|
-
if (ownedDb) connection.close();
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export function getAllDefaults(db?: SqliteDb): Map<string, ToolDefaults> {
|
|
27
|
-
const ownedDb = db == null;
|
|
28
|
-
const connection = db ?? initDefaultDatabase();
|
|
29
|
-
try {
|
|
30
|
-
const rows = connection
|
|
31
|
-
.prepare(
|
|
32
|
-
`SELECT tool_name, param_path, value_json FROM tool_defaults ORDER BY tool_name, param_path`,
|
|
33
|
-
)
|
|
34
|
-
.all() as Array<{ tool_name: string; param_path: string; value_json: string }>;
|
|
35
|
-
|
|
36
|
-
const groups = new Map<string, ToolDefaults>();
|
|
37
|
-
for (const row of rows) {
|
|
38
|
-
const defaults = groups.get(row.tool_name) ?? {};
|
|
39
|
-
setPath(defaults, row.param_path, parseStoredValue(row.value_json));
|
|
40
|
-
groups.set(row.tool_name, defaults);
|
|
41
|
-
}
|
|
42
|
-
return groups;
|
|
43
|
-
} finally {
|
|
44
|
-
if (ownedDb) connection.close();
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export function setDefault(
|
|
49
|
-
toolName: string,
|
|
50
|
-
paramPath: string,
|
|
51
|
-
value: unknown,
|
|
52
|
-
db?: SqliteDb,
|
|
53
|
-
): void {
|
|
54
|
-
const ownedDb = db == null;
|
|
55
|
-
const connection = db ?? initDefaultDatabase();
|
|
56
|
-
try {
|
|
57
|
-
connection
|
|
58
|
-
.prepare(
|
|
59
|
-
`INSERT INTO tool_defaults (tool_name, param_path, value_json, set_at)
|
|
60
|
-
VALUES (?, ?, ?, ?)
|
|
61
|
-
ON CONFLICT(tool_name, param_path) DO UPDATE SET
|
|
62
|
-
value_json = excluded.value_json,
|
|
63
|
-
set_at = excluded.set_at`,
|
|
64
|
-
)
|
|
65
|
-
.run(toolName, paramPath, JSON.stringify(value), new Date().toISOString());
|
|
66
|
-
} finally {
|
|
67
|
-
if (ownedDb) connection.close();
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export function clearDefault(toolName: string, paramPath: string, db?: SqliteDb): void {
|
|
72
|
-
const ownedDb = db == null;
|
|
73
|
-
const connection = db ?? initDefaultDatabase();
|
|
74
|
-
try {
|
|
75
|
-
connection
|
|
76
|
-
.prepare(`DELETE FROM tool_defaults WHERE tool_name = ? AND param_path = ?`)
|
|
77
|
-
.run(toolName, paramPath);
|
|
78
|
-
} finally {
|
|
79
|
-
if (ownedDb) connection.close();
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function parseStoredValue(valueJson: string): unknown {
|
|
84
|
-
try {
|
|
85
|
-
return JSON.parse(valueJson);
|
|
86
|
-
} catch {
|
|
87
|
-
return valueJson;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
function setPath(target: ToolDefaults, path: string, value: unknown): void {
|
|
92
|
-
const parts = path.split(".").filter(Boolean);
|
|
93
|
-
if (parts.length === 0) return;
|
|
94
|
-
|
|
95
|
-
let cursor: Record<string, unknown> = target;
|
|
96
|
-
for (const part of parts.slice(0, -1)) {
|
|
97
|
-
const existing = cursor[part];
|
|
98
|
-
if (!isPlainObject(existing)) {
|
|
99
|
-
cursor[part] = {};
|
|
100
|
-
}
|
|
101
|
-
cursor = cursor[part] as Record<string, unknown>;
|
|
102
|
-
}
|
|
103
|
-
cursor[parts[parts.length - 1]] = value;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
function isPlainObject(value: unknown): value is Record<string, unknown> {
|
|
107
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
108
|
-
}
|
package/src/memory/types.ts
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
/** Memory categories for typed, selective retrieval. */
|
|
2
|
-
export type MemoryCategory =
|
|
3
|
-
| "investor_profile"
|
|
4
|
-
| "interaction_feedback"
|
|
5
|
-
| "workflow_history"
|
|
6
|
-
| "references";
|
|
7
|
-
|
|
8
|
-
/** A memory entry with category and freshness metadata. */
|
|
9
|
-
export interface MemoryEntry {
|
|
10
|
-
key: string;
|
|
11
|
-
value: string;
|
|
12
|
-
category: MemoryCategory;
|
|
13
|
-
recordedAt: string;
|
|
14
|
-
confidence?: string;
|
|
15
|
-
source?: string;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/** Staleness thresholds in milliseconds per category. */
|
|
19
|
-
export const STALENESS_THRESHOLDS: Record<MemoryCategory, number> = {
|
|
20
|
-
investor_profile: 90 * 24 * 60 * 60 * 1000, // 90 days
|
|
21
|
-
interaction_feedback: 14 * 24 * 60 * 60 * 1000, // 14 days
|
|
22
|
-
workflow_history: 7 * 24 * 60 * 60 * 1000, // 7 days
|
|
23
|
-
references: 30 * 24 * 60 * 60 * 1000, // 30 days
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
/** Map preference keys to memory categories. */
|
|
27
|
-
export const KEY_TO_CATEGORY: Record<string, MemoryCategory> = {
|
|
28
|
-
risk_profile: "investor_profile",
|
|
29
|
-
time_horizon: "investor_profile",
|
|
30
|
-
asset_scope: "investor_profile",
|
|
31
|
-
position_count: "investor_profile",
|
|
32
|
-
max_single_position_pct: "investor_profile",
|
|
33
|
-
account_type: "investor_profile",
|
|
34
|
-
income_vs_growth: "investor_profile",
|
|
35
|
-
dte_target: "investor_profile",
|
|
36
|
-
objective: "investor_profile",
|
|
37
|
-
moneyness_preference: "investor_profile",
|
|
38
|
-
liquidity_minimum: "investor_profile",
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
/** Categories relevant to each workflow type. */
|
|
42
|
-
export const WORKFLOW_RELEVANT_CATEGORIES: Record<string, MemoryCategory[]> = {
|
|
43
|
-
portfolio_builder: ["investor_profile", "interaction_feedback", "workflow_history"],
|
|
44
|
-
options_screener: ["investor_profile", "interaction_feedback", "workflow_history"],
|
|
45
|
-
compare_assets: ["investor_profile", "workflow_history"],
|
|
46
|
-
comprehensive_analysis: ["investor_profile", "workflow_history"],
|
|
47
|
-
single_asset_analysis: ["investor_profile"],
|
|
48
|
-
general_finance_qa: ["investor_profile"],
|
|
49
|
-
workflow_dispatch: ["investor_profile", "workflow_history"],
|
|
50
|
-
agent_task: ["investor_profile", "workflow_history"],
|
|
51
|
-
clarification: ["investor_profile", "workflow_history"],
|
|
52
|
-
pass_through: [],
|
|
53
|
-
unclassified: ["investor_profile"],
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
/** Check whether a memory entry is stale. */
|
|
57
|
-
export function isStale(entry: MemoryEntry, now: Date = new Date()): boolean {
|
|
58
|
-
const threshold = STALENESS_THRESHOLDS[entry.category];
|
|
59
|
-
const age = now.getTime() - new Date(entry.recordedAt).getTime();
|
|
60
|
-
return age > threshold;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/** Keys whose values are market-sensitive and must never be trusted from memory. */
|
|
64
|
-
export const NEVER_TRUST_FROM_MEMORY = new Set([
|
|
65
|
-
"stock_price",
|
|
66
|
-
"crypto_price",
|
|
67
|
-
"market_thesis",
|
|
68
|
-
"target_price",
|
|
69
|
-
"entry_price",
|
|
70
|
-
"stop_loss",
|
|
71
|
-
]);
|
package/src/monitor.ts
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { parseArgs } from "node:util";
|
|
3
|
-
import { loadEnv } from "./config.js";
|
|
4
|
-
import { assertSupportedNodeVersion } from "./infra/node-version.js";
|
|
5
|
-
import { runLocalAutomationHeartbeat } from "./market-state/local-automation-service.js";
|
|
6
|
-
import { MarketStateService } from "./market-state/service.js";
|
|
7
|
-
import { initDefaultDatabase } from "./memory/sqlite.js";
|
|
8
|
-
|
|
9
|
-
assertSupportedNodeVersion();
|
|
10
|
-
|
|
11
|
-
const DEFAULT_MONITOR_INTERVAL_MS = 60_000;
|
|
12
|
-
const MIN_MONITOR_INTERVAL_MS = 5_000;
|
|
13
|
-
const MONITOR_OWNER_ID = `monitor:${process.pid}`;
|
|
14
|
-
|
|
15
|
-
interface MonitorOptions {
|
|
16
|
-
once: boolean;
|
|
17
|
-
intervalMs: number;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function parseMonitorOptions(argv = process.argv.slice(2)): MonitorOptions {
|
|
21
|
-
const parsed = parseArgs({
|
|
22
|
-
args: argv,
|
|
23
|
-
options: {
|
|
24
|
-
once: { type: "boolean", default: false },
|
|
25
|
-
"interval-ms": { type: "string" },
|
|
26
|
-
},
|
|
27
|
-
strict: false,
|
|
28
|
-
});
|
|
29
|
-
return {
|
|
30
|
-
once: parsed.values.once === true,
|
|
31
|
-
intervalMs: normalizeMonitorIntervalMs(parsed.values["interval-ms"]),
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function normalizeMonitorIntervalMs(raw: string | boolean | undefined): number {
|
|
36
|
-
if (typeof raw !== "string" || raw.trim() === "") return DEFAULT_MONITOR_INTERVAL_MS;
|
|
37
|
-
const parsed = Number(raw);
|
|
38
|
-
if (!Number.isFinite(parsed) || parsed < MIN_MONITOR_INTERVAL_MS)
|
|
39
|
-
return DEFAULT_MONITOR_INTERVAL_MS;
|
|
40
|
-
return Math.floor(parsed);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
async function runMonitorHeartbeat(
|
|
44
|
-
intervalMs: number,
|
|
45
|
-
releaseLeaseOnComplete = false,
|
|
46
|
-
): Promise<void> {
|
|
47
|
-
const db = initDefaultDatabase();
|
|
48
|
-
const now = new Date().toISOString();
|
|
49
|
-
try {
|
|
50
|
-
const result = await runLocalAutomationHeartbeat(db, {
|
|
51
|
-
ownerId: MONITOR_OWNER_ID,
|
|
52
|
-
ownerKind: "monitor",
|
|
53
|
-
now,
|
|
54
|
-
ttlSeconds: Math.max(90, Math.ceil((intervalMs * 2) / 1000)),
|
|
55
|
-
checkAlerts: true,
|
|
56
|
-
checkReports: true,
|
|
57
|
-
releaseLeaseOnComplete,
|
|
58
|
-
});
|
|
59
|
-
if (!result.lease.acquired) {
|
|
60
|
-
console.log(
|
|
61
|
-
`OpenCandle monitor standby: runner owned by ${result.lease.ownerId} until ${result.lease.expiresAt}`,
|
|
62
|
-
);
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
const alertSummary = result.alertCheck
|
|
66
|
-
? `${result.alertCheck.checked} alert(s), ${result.alertCheck.triggered} triggered, ${result.alertCheck.unavailable} unavailable`
|
|
67
|
-
: "no due alerts";
|
|
68
|
-
const reportSummary = result.reportRuns.length
|
|
69
|
-
? `${result.reportRuns.length} report run(s)`
|
|
70
|
-
: "no due reports";
|
|
71
|
-
console.log(`OpenCandle monitor heartbeat ${now}: ${alertSummary}; ${reportSummary}.`);
|
|
72
|
-
} finally {
|
|
73
|
-
db.close();
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
async function main(): Promise<void> {
|
|
78
|
-
loadEnv();
|
|
79
|
-
const options = parseMonitorOptions();
|
|
80
|
-
let inFlight = false;
|
|
81
|
-
const runOnce = async (): Promise<void> => {
|
|
82
|
-
if (inFlight) {
|
|
83
|
-
console.log("OpenCandle monitor heartbeat skipped: previous run is still active.");
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
inFlight = true;
|
|
87
|
-
try {
|
|
88
|
-
await runMonitorHeartbeat(options.intervalMs, options.once);
|
|
89
|
-
} finally {
|
|
90
|
-
inFlight = false;
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
await runOnce();
|
|
95
|
-
if (options.once) return;
|
|
96
|
-
|
|
97
|
-
console.log(
|
|
98
|
-
`OpenCandle monitor running locally every ${options.intervalMs}ms. Keep this process open for local alerts and reports.`,
|
|
99
|
-
);
|
|
100
|
-
const timer = setInterval(() => {
|
|
101
|
-
void runOnce().catch((error) => {
|
|
102
|
-
console.error(
|
|
103
|
-
`OpenCandle monitor heartbeat failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
104
|
-
);
|
|
105
|
-
});
|
|
106
|
-
}, options.intervalMs);
|
|
107
|
-
|
|
108
|
-
const stop = () => {
|
|
109
|
-
clearInterval(timer);
|
|
110
|
-
const db = initDefaultDatabase();
|
|
111
|
-
try {
|
|
112
|
-
new MarketStateService(db).releaseAutomationRunnerLease(MONITOR_OWNER_ID);
|
|
113
|
-
} finally {
|
|
114
|
-
db.close();
|
|
115
|
-
}
|
|
116
|
-
console.log("OpenCandle monitor stopped.");
|
|
117
|
-
process.exit(0);
|
|
118
|
-
};
|
|
119
|
-
process.once("SIGINT", stop);
|
|
120
|
-
process.once("SIGTERM", stop);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
await main();
|
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
// Shared `runProviderConnect` function — the actual side-effectful flow that
|
|
2
|
-
// opens a browser, collects a pasted API key, validates it against the
|
|
3
|
-
// provider's API, persists it to `~/.opencandle/config.json`, and refreshes
|
|
4
|
-
// the cached Config so the next tool call sees the new credential.
|
|
5
|
-
//
|
|
6
|
-
// Called from two places:
|
|
7
|
-
// 1. The Pi `tool_result` extension handler when the user picks "Connect now"
|
|
8
|
-
// in the just-in-time prompt (Task Group 10).
|
|
9
|
-
// 2. The `/connect` Pi command (Task Group 13).
|
|
10
|
-
//
|
|
11
|
-
// Validation (Task Group 8 final pass): before persisting, the pasted key is
|
|
12
|
-
// validated via `validateCredential`, which makes a single cheap request to
|
|
13
|
-
// the provider's canonical API and classifies the response. A hard
|
|
14
|
-
// auth failure (401/403 or a provider-specific error-in-200-body) is
|
|
15
|
-
// returned as `invalid_key` WITHOUT persisting the bad value; a transient
|
|
16
|
-
// failure (timeout, 5xx, network error) warns the user but still persists
|
|
17
|
-
// the key so they aren't blocked on a provider outage — the next real tool
|
|
18
|
-
// call will surface any lingering issue via the credential-required tag.
|
|
19
|
-
|
|
20
|
-
import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
21
|
-
import {
|
|
22
|
-
loadConfig,
|
|
23
|
-
loadFileConfig,
|
|
24
|
-
type OpenCandleFileConfig,
|
|
25
|
-
saveFileConfig,
|
|
26
|
-
} from "../config.js";
|
|
27
|
-
import { openInBrowser } from "../infra/open-url.js";
|
|
28
|
-
import {
|
|
29
|
-
type ApiKeyProviderId,
|
|
30
|
-
getCredentialSource,
|
|
31
|
-
getProvider,
|
|
32
|
-
isApiKeyProvider,
|
|
33
|
-
type ProviderId,
|
|
34
|
-
} from "./providers.js";
|
|
35
|
-
import { loadOnboardingState, markProviderCompleted, saveOnboardingState } from "./state.js";
|
|
36
|
-
import { validateCredential } from "./validation.js";
|
|
37
|
-
|
|
38
|
-
export type ConnectResult =
|
|
39
|
-
| { status: "connected" }
|
|
40
|
-
| { status: "cancelled" }
|
|
41
|
-
| { status: "blocked_by_env" }
|
|
42
|
-
| { status: "invalid_key"; httpStatus?: number; message?: string };
|
|
43
|
-
|
|
44
|
-
function writeNested(
|
|
45
|
-
obj: Record<string, unknown>,
|
|
46
|
-
path: readonly string[],
|
|
47
|
-
value: string,
|
|
48
|
-
): Record<string, unknown> {
|
|
49
|
-
if (path.length === 0) return obj;
|
|
50
|
-
const [head, ...rest] = path;
|
|
51
|
-
const next = { ...obj };
|
|
52
|
-
if (rest.length === 0) {
|
|
53
|
-
next[head] = value;
|
|
54
|
-
} else {
|
|
55
|
-
const child =
|
|
56
|
-
next[head] && typeof next[head] === "object" ? (next[head] as Record<string, unknown>) : {};
|
|
57
|
-
next[head] = writeNested(child, rest, value);
|
|
58
|
-
}
|
|
59
|
-
return next;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Persist an already-validated provider credential.
|
|
64
|
-
*
|
|
65
|
-
* Writes the key into `~/.opencandle/config.json` (preserving sibling fields),
|
|
66
|
-
* refreshes the cached `Config` so the next tool call sees the new value, and
|
|
67
|
-
* marks the provider as completed in the onboarding state.
|
|
68
|
-
*
|
|
69
|
-
* Shared by the TUI `/connect` flow (`runProviderConnect`) and the GUI
|
|
70
|
-
* provider-setup form. Validation is the caller's responsibility — both
|
|
71
|
-
* call sites run `validateCredential` before invoking this helper.
|
|
72
|
-
*/
|
|
73
|
-
export function persistProviderCredential(providerId: ApiKeyProviderId, key: string): void {
|
|
74
|
-
const descriptor = getProvider(providerId);
|
|
75
|
-
if (!isApiKeyProvider(descriptor)) {
|
|
76
|
-
throw new Error(`Provider ${providerId} does not accept API keys`);
|
|
77
|
-
}
|
|
78
|
-
const existing = loadFileConfig() as unknown as Record<string, unknown>;
|
|
79
|
-
const updated = writeNested(existing, descriptor.configPath, key) as OpenCandleFileConfig;
|
|
80
|
-
saveFileConfig(updated);
|
|
81
|
-
loadConfig();
|
|
82
|
-
const state = loadOnboardingState();
|
|
83
|
-
saveOnboardingState(markProviderCompleted(state, providerId));
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Run the connect flow for a single provider.
|
|
88
|
-
*
|
|
89
|
-
* Env-precedence short-circuit: if the provider's configured credential
|
|
90
|
-
* already comes from an environment variable, the file-config write would
|
|
91
|
-
* be invisible to the next tool call (env vars win in `resolveConfig`).
|
|
92
|
-
* Notify the user explicitly and return `blocked_by_env` — do not open
|
|
93
|
-
* the browser or collect a pasted value.
|
|
94
|
-
*/
|
|
95
|
-
export async function runProviderConnect(
|
|
96
|
-
ctx: ExtensionContext,
|
|
97
|
-
providerId: ProviderId,
|
|
98
|
-
): Promise<ConnectResult> {
|
|
99
|
-
const descriptor = getProvider(providerId);
|
|
100
|
-
if (!isApiKeyProvider(descriptor)) {
|
|
101
|
-
ctx.ui.notify(
|
|
102
|
-
`${descriptor.displayName} is not configured with an API key. Run opencandle doctor for setup status.`,
|
|
103
|
-
"warning",
|
|
104
|
-
);
|
|
105
|
-
return { status: "cancelled" };
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// Env-precedence check.
|
|
109
|
-
if (getCredentialSource(providerId) === "env") {
|
|
110
|
-
ctx.ui.notify(
|
|
111
|
-
`${descriptor.displayName} is currently set via the ${descriptor.envVar} environment variable. ` +
|
|
112
|
-
`To change it from here, unset that variable first and reopen /connect ${descriptor.aliases[0] ?? descriptor.id}. ` +
|
|
113
|
-
`Otherwise, update ${descriptor.envVar} directly in your shell profile.`,
|
|
114
|
-
"warning",
|
|
115
|
-
);
|
|
116
|
-
return { status: "blocked_by_env" };
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
// Open the signup URL in the user's browser. We ignore errors here — if
|
|
120
|
-
// the browser can't be opened, the user can still paste a key they
|
|
121
|
-
// already have, so we continue rather than bailing.
|
|
122
|
-
await openInBrowser(descriptor.signupUrl).catch(() => {});
|
|
123
|
-
ctx.ui.notify(`Opening ${descriptor.displayName} signup in your browser...`, "info");
|
|
124
|
-
|
|
125
|
-
// Prompt for the key. Uses the provider's instructionsHint as the
|
|
126
|
-
// placeholder text to remind the user what they're pasting.
|
|
127
|
-
const pasted = await ctx.ui.input(
|
|
128
|
-
`Paste your ${descriptor.displayName} API key`,
|
|
129
|
-
descriptor.instructionsHint,
|
|
130
|
-
);
|
|
131
|
-
if (!pasted) {
|
|
132
|
-
return { status: "cancelled" };
|
|
133
|
-
}
|
|
134
|
-
const trimmed = pasted.trim();
|
|
135
|
-
if (trimmed.length === 0) {
|
|
136
|
-
return { status: "cancelled" };
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// Validate the key with the provider BEFORE persisting. Hard auth failures
|
|
140
|
-
// short-circuit here without writing anything; transient failures warn
|
|
141
|
-
// but proceed to persist so users don't get stuck on a provider outage.
|
|
142
|
-
ctx.ui.notify(`Verifying your ${descriptor.displayName} key...`, "info");
|
|
143
|
-
const validation = await validateCredential(descriptor.id, trimmed);
|
|
144
|
-
|
|
145
|
-
if (validation.status === "invalid") {
|
|
146
|
-
const statusHint =
|
|
147
|
-
validation.httpStatus !== undefined ? ` (HTTP ${validation.httpStatus})` : "";
|
|
148
|
-
const messageHint = validation.message ? ` — ${validation.message}` : "";
|
|
149
|
-
ctx.ui.notify(
|
|
150
|
-
`${descriptor.displayName} rejected the key${statusHint}${messageHint}. ` +
|
|
151
|
-
`Your existing configuration was not changed. Re-run /connect ${
|
|
152
|
-
descriptor.aliases[0] ?? descriptor.id
|
|
153
|
-
} to try a different key.`,
|
|
154
|
-
"error",
|
|
155
|
-
);
|
|
156
|
-
return {
|
|
157
|
-
status: "invalid_key",
|
|
158
|
-
httpStatus: validation.httpStatus,
|
|
159
|
-
message: validation.message,
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
if (validation.status === "transient") {
|
|
164
|
-
ctx.ui.notify(
|
|
165
|
-
`Couldn't reach ${descriptor.displayName} to verify the key (${validation.reason}). ` +
|
|
166
|
-
`Saving it anyway — the next request will surface any issue.`,
|
|
167
|
-
"warning",
|
|
168
|
-
);
|
|
169
|
-
// Fall through to persist.
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
persistProviderCredential(descriptor.id, trimmed);
|
|
173
|
-
|
|
174
|
-
ctx.ui.notify(`${descriptor.displayName} connected. Your key has been saved.`, "info");
|
|
175
|
-
|
|
176
|
-
return { status: "connected" };
|
|
177
|
-
}
|