opencandle 0.2.0 → 0.4.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 +110 -87
- package/assets/logo.svg +187 -0
- package/dist/analysts/orchestrator.js +1 -2
- package/dist/analysts/orchestrator.js.map +1 -1
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +38 -2
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +34 -5
- package/dist/config.js +29 -8
- package/dist/config.js.map +1 -1
- package/dist/infra/browser.d.ts +10 -0
- package/dist/infra/browser.js +1 -0
- package/dist/infra/browser.js.map +1 -1
- package/dist/infra/cache.d.ts +4 -0
- package/dist/infra/cache.js +4 -0
- package/dist/infra/cache.js.map +1 -1
- package/dist/infra/native-dependencies.d.ts +1 -0
- package/dist/infra/native-dependencies.js +10 -0
- package/dist/infra/native-dependencies.js.map +1 -0
- package/dist/infra/node-version.d.ts +2 -0
- package/dist/infra/node-version.js +23 -0
- package/dist/infra/node-version.js.map +1 -0
- package/dist/infra/rate-limiter.js +6 -0
- package/dist/infra/rate-limiter.js.map +1 -1
- package/dist/memory/index.d.ts +2 -0
- package/dist/memory/index.js +1 -0
- package/dist/memory/index.js.map +1 -1
- package/dist/memory/sqlite.js +42 -4
- package/dist/memory/sqlite.js.map +1 -1
- package/dist/memory/storage.d.ts +6 -0
- package/dist/memory/storage.js +3 -3
- package/dist/memory/storage.js.map +1 -1
- package/dist/memory/tool-defaults.d.ts +8 -0
- package/dist/memory/tool-defaults.js +59 -0
- package/dist/memory/tool-defaults.js.map +1 -0
- package/dist/onboarding/connect.d.ts +35 -0
- package/dist/onboarding/connect.js +118 -0
- package/dist/onboarding/connect.js.map +1 -0
- package/dist/onboarding/credential-interceptor.d.ts +44 -0
- package/dist/onboarding/credential-interceptor.js +72 -0
- package/dist/onboarding/credential-interceptor.js.map +1 -0
- package/dist/onboarding/degradation-accumulator.d.ts +21 -0
- package/dist/onboarding/degradation-accumulator.js +55 -0
- package/dist/onboarding/degradation-accumulator.js.map +1 -0
- package/dist/onboarding/prompt-user.d.ts +23 -0
- package/dist/onboarding/prompt-user.js +61 -0
- package/dist/onboarding/prompt-user.js.map +1 -0
- package/dist/onboarding/providers.d.ts +116 -0
- package/dist/onboarding/providers.js +239 -0
- package/dist/onboarding/providers.js.map +1 -0
- package/dist/onboarding/state.d.ts +31 -2
- package/dist/onboarding/state.js +141 -13
- package/dist/onboarding/state.js.map +1 -1
- package/dist/onboarding/tool-helpers.d.ts +34 -0
- package/dist/onboarding/tool-helpers.js +80 -0
- package/dist/onboarding/tool-helpers.js.map +1 -0
- package/dist/onboarding/tool-tags.d.ts +37 -0
- package/dist/onboarding/tool-tags.js +149 -0
- package/dist/onboarding/tool-tags.js.map +1 -0
- package/dist/onboarding/validation.d.ts +19 -0
- package/dist/onboarding/validation.js +117 -0
- package/dist/onboarding/validation.js.map +1 -0
- package/dist/pi/opencandle-extension.d.ts +7 -1
- package/dist/pi/opencandle-extension.js +488 -13
- package/dist/pi/opencandle-extension.js.map +1 -1
- package/dist/pi/session-storage.d.ts +2 -0
- package/dist/pi/session-storage.js +5 -0
- package/dist/pi/session-storage.js.map +1 -0
- package/dist/pi/session.d.ts +4 -1
- package/dist/pi/session.js +25 -3
- package/dist/pi/session.js.map +1 -1
- package/dist/pi/setup.d.ts +1 -2
- package/dist/pi/setup.js +67 -120
- package/dist/pi/setup.js.map +1 -1
- package/dist/pi/tool-adapter.d.ts +2 -2
- package/dist/pi/tool-adapter.js +14 -1
- package/dist/pi/tool-adapter.js.map +1 -1
- package/dist/prompts/context-builder.d.ts +22 -0
- package/dist/prompts/context-builder.js +47 -11
- package/dist/prompts/context-builder.js.map +1 -1
- package/dist/prompts/disclaimer.d.ts +6 -0
- package/dist/prompts/disclaimer.js +9 -0
- package/dist/prompts/disclaimer.js.map +1 -0
- package/dist/prompts/workflow-prompts.d.ts +8 -0
- package/dist/prompts/workflow-prompts.js +39 -5
- package/dist/prompts/workflow-prompts.js.map +1 -1
- package/dist/providers/alpha-vantage.js +20 -1
- package/dist/providers/alpha-vantage.js.map +1 -1
- package/dist/providers/exa-search.d.ts +39 -0
- package/dist/providers/exa-search.js +276 -0
- package/dist/providers/exa-search.js.map +1 -0
- package/dist/providers/finnhub.d.ts +17 -0
- package/dist/providers/finnhub.js +94 -0
- package/dist/providers/finnhub.js.map +1 -0
- package/dist/providers/fred.js +13 -1
- package/dist/providers/fred.js.map +1 -1
- package/dist/providers/index.d.ts +2 -0
- package/dist/providers/index.js +1 -0
- package/dist/providers/index.js.map +1 -1
- package/dist/providers/provider-credential-error.d.ts +8 -0
- package/dist/providers/provider-credential-error.js +22 -0
- package/dist/providers/provider-credential-error.js.map +1 -0
- package/dist/providers/reddit.d.ts +8 -0
- package/dist/providers/reddit.js +36 -9
- package/dist/providers/reddit.js.map +1 -1
- package/dist/providers/twitter.js +2 -8
- package/dist/providers/twitter.js.map +1 -1
- package/dist/providers/web-search.d.ts +17 -0
- package/dist/providers/web-search.js +224 -0
- package/dist/providers/web-search.js.map +1 -0
- package/dist/providers/wrap-provider.d.ts +7 -0
- package/dist/providers/wrap-provider.js +15 -0
- package/dist/providers/wrap-provider.js.map +1 -1
- package/dist/providers/yahoo-finance.js +70 -33
- package/dist/providers/yahoo-finance.js.map +1 -1
- package/dist/routing/classify-intent.js +22 -0
- package/dist/routing/classify-intent.js.map +1 -1
- package/dist/routing/defaults.js +1 -1
- package/dist/routing/defaults.js.map +1 -1
- package/dist/routing/index.d.ts +4 -0
- package/dist/routing/index.js +3 -0
- package/dist/routing/index.js.map +1 -1
- package/dist/routing/router-llm-client.d.ts +11 -0
- package/dist/routing/router-llm-client.js +42 -0
- package/dist/routing/router-llm-client.js.map +1 -0
- package/dist/routing/router-prompt.d.ts +2 -0
- package/dist/routing/router-prompt.js +138 -0
- package/dist/routing/router-prompt.js.map +1 -0
- package/dist/routing/router-types.d.ts +62 -0
- package/dist/routing/router-types.js +2 -0
- package/dist/routing/router-types.js.map +1 -0
- package/dist/routing/router.d.ts +10 -0
- package/dist/routing/router.js +194 -0
- package/dist/routing/router.js.map +1 -0
- package/dist/runtime/session-coordinator.d.ts +63 -4
- package/dist/runtime/session-coordinator.js +155 -4
- package/dist/runtime/session-coordinator.js.map +1 -1
- package/dist/runtime/tool-defaults-wrapper.d.ts +3 -0
- package/dist/runtime/tool-defaults-wrapper.js +25 -0
- package/dist/runtime/tool-defaults-wrapper.js.map +1 -0
- package/dist/sentiment/adapters/finnhub.d.ts +7 -0
- package/dist/sentiment/adapters/finnhub.js +39 -0
- package/dist/sentiment/adapters/finnhub.js.map +1 -0
- package/dist/sentiment/adapters/reddit.d.ts +11 -0
- package/dist/sentiment/adapters/reddit.js +54 -0
- package/dist/sentiment/adapters/reddit.js.map +1 -0
- package/dist/sentiment/adapters/twitter.d.ts +9 -0
- package/dist/sentiment/adapters/twitter.js +32 -0
- package/dist/sentiment/adapters/twitter.js.map +1 -0
- package/dist/sentiment/adapters/web.d.ts +9 -0
- package/dist/sentiment/adapters/web.js +40 -0
- package/dist/sentiment/adapters/web.js.map +1 -0
- package/dist/sentiment/index.d.ts +16 -0
- package/dist/sentiment/index.js +44 -0
- package/dist/sentiment/index.js.map +1 -0
- package/dist/sentiment/keywords.d.ts +2 -0
- package/dist/sentiment/keywords.js +9 -0
- package/dist/sentiment/keywords.js.map +1 -0
- package/dist/sentiment/pipeline.d.ts +9 -0
- package/dist/sentiment/pipeline.js +57 -0
- package/dist/sentiment/pipeline.js.map +1 -0
- package/dist/sentiment/scorer.d.ts +9 -0
- package/dist/sentiment/scorer.js +64 -0
- package/dist/sentiment/scorer.js.map +1 -0
- package/dist/sentiment/store.d.ts +24 -0
- package/dist/sentiment/store.js +182 -0
- package/dist/sentiment/store.js.map +1 -0
- package/dist/sentiment/trends.d.ts +13 -0
- package/dist/sentiment/trends.js +73 -0
- package/dist/sentiment/trends.js.map +1 -0
- package/dist/sentiment/types.d.ts +66 -0
- package/dist/sentiment/types.js +54 -0
- package/dist/sentiment/types.js.map +1 -0
- package/dist/system-prompt.js +29 -13
- package/dist/system-prompt.js.map +1 -1
- package/dist/tool-kit.d.ts +4 -4
- package/dist/tools/fundamentals/company-overview.d.ts +4 -2
- package/dist/tools/fundamentals/company-overview.js +27 -27
- package/dist/tools/fundamentals/company-overview.js.map +1 -1
- package/dist/tools/fundamentals/comps.d.ts +1 -1
- package/dist/tools/fundamentals/comps.js +45 -45
- package/dist/tools/fundamentals/comps.js.map +1 -1
- package/dist/tools/fundamentals/dcf.d.ts +1 -1
- package/dist/tools/fundamentals/dcf.js +82 -82
- package/dist/tools/fundamentals/dcf.js.map +1 -1
- package/dist/tools/fundamentals/earnings.d.ts +4 -2
- package/dist/tools/fundamentals/earnings.js +25 -25
- package/dist/tools/fundamentals/earnings.js.map +1 -1
- package/dist/tools/fundamentals/financials.d.ts +4 -2
- package/dist/tools/fundamentals/financials.js +23 -23
- package/dist/tools/fundamentals/financials.js.map +1 -1
- package/dist/tools/fundamentals/sec-filings.d.ts +1 -1
- package/dist/tools/index.d.ts +28 -1
- package/dist/tools/index.js +35 -2
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/interaction/ask-user.d.ts +1 -1
- package/dist/tools/interaction/ask-user.js +28 -64
- package/dist/tools/interaction/ask-user.js.map +1 -1
- package/dist/tools/interaction/twitter-login.d.ts +1 -1
- package/dist/tools/macro/fear-greed.d.ts +1 -1
- package/dist/tools/macro/fred-data.d.ts +4 -2
- package/dist/tools/macro/fred-data.js +26 -26
- package/dist/tools/macro/fred-data.js.map +1 -1
- package/dist/tools/market/crypto-history.d.ts +1 -1
- package/dist/tools/market/crypto-price.d.ts +1 -1
- package/dist/tools/market/search-ticker.d.ts +1 -1
- package/dist/tools/market/stock-history.d.ts +1 -1
- package/dist/tools/market/stock-quote.d.ts +1 -1
- package/dist/tools/options/option-chain.d.ts +1 -1
- package/dist/tools/options/option-chain.js +4 -1
- package/dist/tools/options/option-chain.js.map +1 -1
- package/dist/tools/portfolio/correlation.d.ts +1 -1
- package/dist/tools/portfolio/predictions.d.ts +1 -1
- package/dist/tools/portfolio/risk-analysis.d.ts +1 -1
- package/dist/tools/portfolio/tracker.d.ts +1 -1
- package/dist/tools/portfolio/watchlist.d.ts +1 -1
- package/dist/tools/sentiment/reddit-sentiment.d.ts +4 -2
- package/dist/tools/sentiment/reddit-sentiment.js +107 -22
- package/dist/tools/sentiment/reddit-sentiment.js.map +1 -1
- package/dist/tools/sentiment/sentiment-summary.d.ts +7 -0
- package/dist/tools/sentiment/sentiment-summary.js +230 -0
- package/dist/tools/sentiment/sentiment-summary.js.map +1 -0
- package/dist/tools/sentiment/sentiment-trend.d.ts +22 -0
- package/dist/tools/sentiment/sentiment-trend.js +39 -0
- package/dist/tools/sentiment/sentiment-trend.js.map +1 -0
- package/dist/tools/sentiment/twitter-sentiment.d.ts +1 -1
- package/dist/tools/sentiment/twitter-sentiment.js +17 -0
- package/dist/tools/sentiment/twitter-sentiment.js.map +1 -1
- package/dist/tools/sentiment/web-search.d.ts +11 -0
- package/dist/tools/sentiment/web-search.js +115 -0
- package/dist/tools/sentiment/web-search.js.map +1 -0
- package/dist/tools/sentiment/web-sentiment.d.ts +8 -0
- package/dist/tools/sentiment/web-sentiment.js +66 -0
- package/dist/tools/sentiment/web-sentiment.js.map +1 -0
- package/dist/tools/technical/backtest.d.ts +1 -1
- package/dist/tools/technical/indicators.d.ts +1 -1
- package/dist/tools/technical/indicators.js +7 -1
- package/dist/tools/technical/indicators.js.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/sentiment.d.ts +21 -0
- package/dist/workflows/options-screener.js +7 -2
- package/dist/workflows/options-screener.js.map +1 -1
- package/dist/workflows/portfolio-builder.js +3 -3
- package/dist/workflows/portfolio-builder.js.map +1 -1
- package/gui/server/background-quotes.ts +31 -0
- package/gui/server/chat-event-adapter.ts +142 -0
- package/gui/server/invoke-tool.ts +89 -0
- package/gui/server/live-chat-event-adapter.ts +181 -0
- package/gui/server/model-setup.ts +100 -0
- package/gui/server/package.json +5 -0
- package/gui/server/projector.ts +212 -0
- package/gui/server/server.ts +592 -0
- package/gui/server/session-actions.ts +31 -0
- package/gui/server/tool-metadata.ts +88 -0
- package/gui/server/websocket.ts +128 -0
- package/gui/server/writer-lock.ts +118 -0
- package/gui/shared/chat-events.ts +118 -0
- package/gui/shared/event-reducer.ts +186 -0
- package/gui/web/dist/assets/CatalogOverlay-D1ImSJTe.js +1 -0
- package/gui/web/dist/assets/index-DBrWq43L.css +1 -0
- package/gui/web/dist/assets/index-RflHaj0y.js +67 -0
- package/gui/web/dist/assets/logo-CWpt6Y2a.svg +187 -0
- package/gui/web/dist/index.html +17 -0
- package/package.json +62 -20
- package/src/analysts/contracts.ts +189 -0
- package/src/analysts/orchestrator.ts +300 -0
- package/src/cli.ts +205 -0
- package/src/config.ts +161 -0
- package/src/index.ts +5 -0
- package/src/infra/browser.ts +111 -0
- package/src/infra/cache.ts +103 -0
- package/src/infra/http-client.ts +68 -0
- package/src/infra/index.ts +18 -0
- package/src/infra/native-dependencies.ts +12 -0
- package/src/infra/node-version.ts +24 -0
- package/src/infra/open-url.ts +28 -0
- package/src/infra/opencandle-paths.ts +64 -0
- package/src/infra/rate-limiter.ts +64 -0
- package/src/memory/index.ts +10 -0
- package/src/memory/manager.ts +159 -0
- package/src/memory/preference-extractor.ts +106 -0
- package/src/memory/retrieval.ts +70 -0
- package/src/memory/sqlite.ts +172 -0
- package/src/memory/storage.ts +204 -0
- package/src/memory/tool-defaults.ts +87 -0
- package/src/memory/types.ts +67 -0
- package/src/onboarding/connect.ts +184 -0
- package/src/onboarding/credential-interceptor.ts +134 -0
- package/src/onboarding/degradation-accumulator.ts +79 -0
- package/src/onboarding/prompt-user.ts +85 -0
- package/src/onboarding/providers.ts +315 -0
- package/src/onboarding/state.ts +218 -0
- package/src/onboarding/tool-helpers.ts +111 -0
- package/src/onboarding/tool-tags.ts +201 -0
- package/src/onboarding/validation.ts +158 -0
- package/src/pi/opencandle-extension.ts +724 -0
- package/src/pi/session-storage.ts +5 -0
- package/src/pi/session.ts +81 -0
- package/src/pi/setup.ts +371 -0
- package/src/pi/tool-adapter.ts +36 -0
- package/src/prompts/context-builder.ts +204 -0
- package/src/prompts/disclaimer.ts +9 -0
- package/src/prompts/sections.ts +46 -0
- package/src/prompts/workflow-prompts.ts +279 -0
- package/src/providers/alpha-vantage.ts +292 -0
- package/src/providers/coingecko.ts +96 -0
- package/src/providers/exa-search.ts +373 -0
- package/src/providers/fear-greed.ts +45 -0
- package/src/providers/finnhub.ts +124 -0
- package/src/providers/fred.ts +83 -0
- package/src/providers/index.ts +9 -0
- package/src/providers/provider-credential-error.ts +23 -0
- package/src/providers/reddit.ts +151 -0
- package/src/providers/sec-edgar.ts +96 -0
- package/src/providers/twitter.ts +173 -0
- package/src/providers/web-search.ts +293 -0
- package/src/providers/with-fallback.ts +41 -0
- package/src/providers/wrap-provider.ts +64 -0
- package/src/providers/yahoo-finance.ts +367 -0
- package/src/routing/classify-intent.ts +194 -0
- package/src/routing/defaults.ts +29 -0
- package/src/routing/entity-extractor.ts +140 -0
- package/src/routing/index.ts +26 -0
- package/src/routing/router-llm-client.ts +51 -0
- package/src/routing/router-prompt.ts +159 -0
- package/src/routing/router-types.ts +66 -0
- package/src/routing/router.ts +213 -0
- package/src/routing/slot-resolver.ts +152 -0
- package/src/routing/types.ts +63 -0
- package/src/runtime/evidence.ts +77 -0
- package/src/runtime/index.ts +55 -0
- package/src/runtime/prompt-step.ts +75 -0
- package/src/runtime/provider-ids.ts +15 -0
- package/src/runtime/provider-tracker.ts +40 -0
- package/src/runtime/run-context.ts +22 -0
- package/src/runtime/session-coordinator.ts +406 -0
- package/src/runtime/tool-defaults-wrapper.ts +35 -0
- package/src/runtime/validation.ts +214 -0
- package/src/runtime/workflow-events.ts +75 -0
- package/src/runtime/workflow-runner.ts +188 -0
- package/src/runtime/workflow-types.ts +102 -0
- package/src/sentiment/adapters/finnhub.ts +44 -0
- package/src/sentiment/adapters/reddit.ts +65 -0
- package/src/sentiment/adapters/twitter.ts +36 -0
- package/src/sentiment/adapters/web.ts +44 -0
- package/src/sentiment/index.ts +58 -0
- package/src/sentiment/keywords.ts +9 -0
- package/src/sentiment/pipeline.ts +68 -0
- package/src/sentiment/scorer.ts +78 -0
- package/src/sentiment/store.ts +260 -0
- package/src/sentiment/trends.ts +90 -0
- package/src/sentiment/types.ts +108 -0
- package/src/system-prompt.ts +115 -0
- package/src/tool-kit.ts +68 -0
- package/src/tools/AGENTS.md +36 -0
- package/src/tools/fundamentals/company-overview.ts +54 -0
- package/src/tools/fundamentals/comps.ts +156 -0
- package/src/tools/fundamentals/dcf.ts +267 -0
- package/src/tools/fundamentals/earnings.ts +47 -0
- package/src/tools/fundamentals/financials.ts +54 -0
- package/src/tools/fundamentals/sec-filings.ts +61 -0
- package/src/tools/index.ts +88 -0
- package/src/tools/interaction/ask-user.ts +81 -0
- package/src/tools/interaction/twitter-login.ts +93 -0
- package/src/tools/macro/fear-greed.ts +41 -0
- package/src/tools/macro/fred-data.ts +54 -0
- package/src/tools/market/crypto-history.ts +51 -0
- package/src/tools/market/crypto-price.ts +53 -0
- package/src/tools/market/search-ticker.ts +53 -0
- package/src/tools/market/stock-history.ts +79 -0
- package/src/tools/market/stock-quote.ts +64 -0
- package/src/tools/options/greeks.ts +82 -0
- package/src/tools/options/option-chain.ts +91 -0
- package/src/tools/portfolio/correlation.ts +162 -0
- package/src/tools/portfolio/predictions.ts +253 -0
- package/src/tools/portfolio/risk-analysis.ts +134 -0
- package/src/tools/portfolio/tracker.ts +147 -0
- package/src/tools/portfolio/watchlist.ts +153 -0
- package/src/tools/sentiment/reddit-sentiment.ts +164 -0
- package/src/tools/sentiment/sentiment-summary.ts +256 -0
- package/src/tools/sentiment/sentiment-trend.ts +58 -0
- package/src/tools/sentiment/twitter-sentiment.ts +96 -0
- package/src/tools/sentiment/web-search.ts +150 -0
- package/src/tools/sentiment/web-sentiment.ts +76 -0
- package/src/tools/technical/backtest.ts +246 -0
- package/src/tools/technical/indicators.ts +258 -0
- package/src/types/fundamentals.ts +46 -0
- package/src/types/index.ts +20 -0
- package/src/types/macro.ts +27 -0
- package/src/types/market.ts +43 -0
- package/src/types/options.ts +35 -0
- package/src/types/portfolio.ts +41 -0
- package/src/types/sentiment.ts +70 -0
- package/src/workflows/compare-assets.ts +39 -0
- package/src/workflows/index.ts +4 -0
- package/src/workflows/options-screener.ts +49 -0
- package/src/workflows/portfolio-builder.ts +52 -0
- package/src/workflows/types.ts +4 -0
- package/dist/tools/sentiment/news-sentiment.d.ts +0 -7
- package/dist/tools/sentiment/news-sentiment.js +0 -55
- package/dist/tools/sentiment/news-sentiment.js.map +0 -1
|
@@ -1,14 +1,39 @@
|
|
|
1
1
|
import { isAnalysisRequest, normalizeSymbol, } from "../analysts/orchestrator.js";
|
|
2
2
|
import { buildComprehensiveAnalysisDefinition } from "../analysts/orchestrator.js";
|
|
3
3
|
import { getConfig } from "../config.js";
|
|
4
|
-
import { classifyIntent, resolveOptionsScreenerSlots, resolvePortfolioSlots } from "../routing/index.js";
|
|
4
|
+
import { classifyIntent, createPiAiRouterClient, resolveOptionsScreenerSlots, resolvePortfolioSlots, route as routeLlm, } from "../routing/index.js";
|
|
5
|
+
import { buildAssumptionsBlockFromRouter } from "../prompts/workflow-prompts.js";
|
|
5
6
|
import { buildPortfolioWorkflowDefinition, buildOptionsScreenerWorkflowDefinition, buildCompareAssetsWorkflowDefinition, } from "../workflows/index.js";
|
|
6
7
|
import { getOpenCandleToolDefinitions } from "./tool-adapter.js";
|
|
7
8
|
import { registerAskUserTool } from "../tools/interaction/ask-user.js";
|
|
8
9
|
import { registerTwitterLoginTool } from "../tools/interaction/twitter-login.js";
|
|
9
10
|
import { SessionCoordinator } from "../runtime/session-coordinator.js";
|
|
11
|
+
import { getProvider, } from "../onboarding/providers.js";
|
|
12
|
+
import { loadOnboardingState, saveOnboardingState, markProviderSnoozed, markProviderNeverAsk, markWelcomeShown, shouldShowWelcome, } from "../onboarding/state.js";
|
|
13
|
+
import { parseToolTag, buildSkippedTag, buildConnectedTag } from "../onboarding/tool-tags.js";
|
|
14
|
+
import { resolveCredentialRequired } from "../onboarding/credential-interceptor.js";
|
|
15
|
+
import { createDegradationAccumulator } from "../onboarding/degradation-accumulator.js";
|
|
16
|
+
import { promptUser } from "../onboarding/prompt-user.js";
|
|
17
|
+
import { runProviderConnect } from "../onboarding/connect.js";
|
|
18
|
+
import { DISCLAIMER_TEXT } from "../prompts/disclaimer.js";
|
|
10
19
|
export default function openCandleExtension(pi, options) {
|
|
11
20
|
const coordinator = new SessionCoordinator();
|
|
21
|
+
// Credential-interception state. Lifetime:
|
|
22
|
+
// `sessionPromptedSet` — cleared on session_start, persists across turns
|
|
23
|
+
// within a session so users don't get re-prompted after picking
|
|
24
|
+
// "continue without".
|
|
25
|
+
// `hardPromptFiredInWorkflow` — reset on turn_start (the nearest clean
|
|
26
|
+
// boundary for a single user request). Enforces the "at most one hard
|
|
27
|
+
// prompt per workflow" cap.
|
|
28
|
+
// `degradationAccumulator` — per-turn record of soft-tier providers that
|
|
29
|
+
// fell back to their keyless alternative. Reset on turn_start; flushed
|
|
30
|
+
// on turn_end via `pi.appendEntry("opencandle-turn-gap", ...)` for
|
|
31
|
+
// session observability. Does NOT pause the workflow or mutate tool
|
|
32
|
+
// results inline — soft-degraded tags remain visible to the LLM so its
|
|
33
|
+
// final answer can surface them in a **Data gaps** section.
|
|
34
|
+
const sessionPromptedSet = new Set();
|
|
35
|
+
let hardPromptFiredInWorkflow = false;
|
|
36
|
+
const degradationAccumulator = createDegradationAccumulator();
|
|
12
37
|
// Register tools
|
|
13
38
|
for (const tool of getOpenCandleToolDefinitions()) {
|
|
14
39
|
pi.registerTool(tool);
|
|
@@ -28,42 +53,345 @@ export default function openCandleExtension(pi, options) {
|
|
|
28
53
|
coordinator.executeWorkflow(pi, definition, ctx);
|
|
29
54
|
},
|
|
30
55
|
});
|
|
31
|
-
// /setup command
|
|
56
|
+
// /setup command — reconfigure the OpenCandle AI model (sign-in / API key).
|
|
57
|
+
// Data providers are configured separately via `/connect`.
|
|
32
58
|
pi.registerCommand("setup", {
|
|
33
|
-
description: "
|
|
59
|
+
description: "Reconfigure the OpenCandle AI model (sign-in or API key)",
|
|
34
60
|
handler: async (_args, ctx) => {
|
|
35
|
-
const result = await coordinator.runSetup(pi, ctx, { mode: "manual"
|
|
61
|
+
const result = await coordinator.runSetup(pi, ctx, { mode: "manual" });
|
|
36
62
|
if (result === "ready") {
|
|
37
63
|
ctx.ui.notify("OpenCandle setup complete.", "info");
|
|
38
64
|
}
|
|
39
65
|
},
|
|
40
66
|
});
|
|
67
|
+
// /connect command — reconfigurable sectioned setup for data providers.
|
|
68
|
+
// `/connect` with no args opens a picker listing all providers.
|
|
69
|
+
// `/connect <alias|id|category>` routes to a specific provider (or a
|
|
70
|
+
// sub-picker for multi-provider categories like "search").
|
|
71
|
+
pi.registerCommand("connect", {
|
|
72
|
+
description: "Connect a data provider (Alpha Vantage, FRED, Finnhub, Brave, Exa)",
|
|
73
|
+
handler: async (args, ctx) => {
|
|
74
|
+
const { listAllProviders, resolveProviderFromArgument, hasCredential } = await import("../onboarding/providers.js");
|
|
75
|
+
const formatState = (id) => {
|
|
76
|
+
const state = loadOnboardingState().providers[id];
|
|
77
|
+
if (state?.status === "completed")
|
|
78
|
+
return "Configured";
|
|
79
|
+
if (state?.status === "snoozed") {
|
|
80
|
+
return `Snoozed until ${state.snoozeUntil.slice(0, 10)}`;
|
|
81
|
+
}
|
|
82
|
+
if (state?.status === "never_ask")
|
|
83
|
+
return "Never-ask";
|
|
84
|
+
if (hasCredential(id))
|
|
85
|
+
return "Configured (via env)";
|
|
86
|
+
return "Not configured";
|
|
87
|
+
};
|
|
88
|
+
const pickProvider = async (providers) => {
|
|
89
|
+
const labels = providers.map((p) => `${p.displayName} — ${p.unlocks.slice(0, 2).join(", ")} [${formatState(p.id)}]`);
|
|
90
|
+
const choice = await ctx.ui.select("Which provider would you like to connect?", labels);
|
|
91
|
+
if (choice === undefined)
|
|
92
|
+
return undefined;
|
|
93
|
+
const index = labels.indexOf(choice);
|
|
94
|
+
return providers[index]?.id;
|
|
95
|
+
};
|
|
96
|
+
const trimmed = args.trim();
|
|
97
|
+
let targetId;
|
|
98
|
+
if (trimmed === "") {
|
|
99
|
+
// Bare /connect → full picker.
|
|
100
|
+
targetId = await pickProvider(listAllProviders());
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
const resolved = resolveProviderFromArgument(trimmed);
|
|
104
|
+
if (!resolved) {
|
|
105
|
+
const all = listAllProviders()
|
|
106
|
+
.map((p) => ` ${p.displayName} (${p.aliases.join(", ")})`)
|
|
107
|
+
.join("\n");
|
|
108
|
+
ctx.ui.notify(`Unknown provider: "${trimmed}". Available:\n${all}`, "warning");
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
if (Array.isArray(resolved)) {
|
|
112
|
+
// Multi-provider category — show a sub-picker.
|
|
113
|
+
targetId = await pickProvider(resolved);
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
targetId = resolved.id;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
if (!targetId) {
|
|
120
|
+
ctx.ui.notify("Connect cancelled.", "info");
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
const result = await runProviderConnect(ctx, targetId);
|
|
124
|
+
if (result.status === "connected") {
|
|
125
|
+
ctx.ui.notify(`${getProvider(targetId).displayName} is now connected.`, "info");
|
|
126
|
+
}
|
|
127
|
+
else if (result.status === "cancelled") {
|
|
128
|
+
ctx.ui.notify("Connect cancelled.", "info");
|
|
129
|
+
}
|
|
130
|
+
// "blocked_by_env" already notifies from inside runProviderConnect.
|
|
131
|
+
},
|
|
132
|
+
});
|
|
41
133
|
// Session start
|
|
42
134
|
pi.on("session_start", async (_event, ctx) => {
|
|
43
135
|
coordinator.initSession(ctx.sessionManager.getSessionId());
|
|
136
|
+
sessionPromptedSet.clear();
|
|
137
|
+
hardPromptFiredInWorkflow = false;
|
|
44
138
|
if (!ctx.hasUI)
|
|
45
139
|
return;
|
|
140
|
+
// Pin the user-facing disclaimer in the UI footer for the entire session.
|
|
141
|
+
// Using `setStatus` keeps it always visible to the user without ever
|
|
142
|
+
// entering the LLM's conversation context (unlike `sendMessage`, which Pi
|
|
143
|
+
// reinjects as a `role:"user"` message every turn).
|
|
144
|
+
ctx.ui.setStatus("opencandle-disclaimer", DISCLAIMER_TEXT);
|
|
46
145
|
const result = await coordinator.runSetup(pi, ctx, { mode: "startup" });
|
|
47
146
|
if (result === "shutdown") {
|
|
48
147
|
return;
|
|
49
148
|
}
|
|
50
|
-
|
|
149
|
+
// One-shot welcome on the very first session (gated on welcomeShownAt).
|
|
150
|
+
// Uses `pi.sendMessage` with `display: true` so the welcome lands in the
|
|
151
|
+
// chat transcript (persistent, scrollable) rather than a transient
|
|
152
|
+
// `ctx.ui.notify` banner.
|
|
153
|
+
const state = loadOnboardingState();
|
|
154
|
+
if (shouldShowWelcome(state, ctx.hasUI)) {
|
|
155
|
+
const WELCOME_BODY = "Welcome to OpenCandle. I'm your AI copilot for market analysis.\n\n" +
|
|
156
|
+
"Try something like:\n" +
|
|
157
|
+
" • analyze NVDA — full deep-dive on a ticker\n" +
|
|
158
|
+
" • quote TSLA — just the price and daily move\n" +
|
|
159
|
+
" • how's bitcoin? — crypto\n" +
|
|
160
|
+
" • what's r/wallstreetbets saying about META? — social sentiment\n\n" +
|
|
161
|
+
"You're running with just an LLM right now, which covers most of what\n" +
|
|
162
|
+
"people want. For fundamentals, economic data, or premium news you'll\n" +
|
|
163
|
+
"need a few free API keys — I'll offer to help when they'd actually\n" +
|
|
164
|
+
"make a difference, or run /connect anytime.";
|
|
165
|
+
pi.sendMessage({
|
|
166
|
+
customType: "opencandle-welcome",
|
|
167
|
+
content: [{ type: "text", text: WELCOME_BODY }],
|
|
168
|
+
display: true,
|
|
169
|
+
});
|
|
170
|
+
saveOnboardingState(markWelcomeShown(state));
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
ctx.ui.notify("OpenCandle ready. Try /analyze NVDA or /connect to add data providers.", "info");
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
// Reset the per-workflow prompt cap AND the degradation accumulator on each
|
|
177
|
+
// new turn. One user request = one workflow invocation = at most one hard
|
|
178
|
+
// prompt and one combined soft-degradation annotation.
|
|
179
|
+
pi.on("turn_start", async () => {
|
|
180
|
+
hardPromptFiredInWorkflow = false;
|
|
181
|
+
degradationAccumulator.reset();
|
|
182
|
+
});
|
|
183
|
+
// At turn_end, flush the soft-degradation accumulator to a session entry so
|
|
184
|
+
// downstream consumers (UI renderers, debug inspectors, later turns) can see
|
|
185
|
+
// which soft providers fell back during this turn. The LLM has already
|
|
186
|
+
// emitted its answer by the time this fires, so the per-tool-result
|
|
187
|
+
// soft-degraded tags remain the primary carrier for the in-turn gap note.
|
|
188
|
+
//
|
|
189
|
+
// Also persist a per-turn disclaimer entry via `appendEntry`. `CustomEntry`
|
|
190
|
+
// is NOT sent to LLM context (unlike `sendMessage`/`CustomMessage`, which
|
|
191
|
+
// Pi's `convertToLlm` reinjects as a `role:"user"` message), so this keeps
|
|
192
|
+
// the stance instruction-free while still producing a session record that
|
|
193
|
+
// downstream renderers / exporters / tests can surface. The always-visible
|
|
194
|
+
// footer status pinned at session_start is the primary user-visible channel.
|
|
195
|
+
pi.on("turn_end", async (event) => {
|
|
196
|
+
const msg = event.message;
|
|
197
|
+
const isFinalAssistantTurn = msg.role === "assistant" && msg.stopReason === "stop";
|
|
198
|
+
if (isFinalAssistantTurn) {
|
|
199
|
+
pi.appendEntry("opencandle-disclaimer", { text: DISCLAIMER_TEXT });
|
|
200
|
+
}
|
|
201
|
+
if (degradationAccumulator.isEmpty())
|
|
202
|
+
return;
|
|
203
|
+
const state = loadOnboardingState();
|
|
204
|
+
const annotation = degradationAccumulator.buildCombinedAnnotation(state);
|
|
205
|
+
if (annotation !== null) {
|
|
206
|
+
pi.appendEntry("opencandle-turn-gap", { annotation });
|
|
207
|
+
}
|
|
208
|
+
degradationAccumulator.reset();
|
|
51
209
|
});
|
|
52
|
-
//
|
|
210
|
+
// Intercept tool results for credential-required and soft-degraded tags.
|
|
211
|
+
pi.on("tool_result", async (event, ctx) => {
|
|
212
|
+
// First pass: record any soft-degradation tags in the per-turn accumulator
|
|
213
|
+
// WITHOUT mutating the tool result (the inline tag stays visible to the
|
|
214
|
+
// LLM so it can surface the gap in its final answer). Multiple tags per
|
|
215
|
+
// tool-result block are deduplicated by the accumulator's Set.
|
|
216
|
+
for (const block of event.content) {
|
|
217
|
+
if (block.type !== "text")
|
|
218
|
+
continue;
|
|
219
|
+
const parsed = parseToolTag(block.text);
|
|
220
|
+
if (parsed?.kind === "soft_degraded") {
|
|
221
|
+
degradationAccumulator.record(parsed.provider);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
// Second pass: look for a credential-required tag; on match, run the
|
|
225
|
+
// interception decision and either replace the tool result or prompt
|
|
226
|
+
// the user. Only the first credential_required tag in the content list
|
|
227
|
+
// is acted on — subsequent hard-tier prompts are silenced by the
|
|
228
|
+
// per-workflow cap at the decision-function level.
|
|
229
|
+
for (const block of event.content) {
|
|
230
|
+
if (block.type !== "text")
|
|
231
|
+
continue;
|
|
232
|
+
const parsed = parseToolTag(block.text);
|
|
233
|
+
if (!parsed || parsed.kind !== "credential_required")
|
|
234
|
+
continue;
|
|
235
|
+
const state = loadOnboardingState();
|
|
236
|
+
const action = resolveCredentialRequired({
|
|
237
|
+
provider: parsed.provider,
|
|
238
|
+
reason: parsed.reason,
|
|
239
|
+
state,
|
|
240
|
+
sessionPromptedSet,
|
|
241
|
+
hardPromptFiredInWorkflow,
|
|
242
|
+
now: new Date(),
|
|
243
|
+
});
|
|
244
|
+
if (action.action === "skip") {
|
|
245
|
+
// Replace content with a skipped placeholder so the LLM sees a
|
|
246
|
+
// neutral gap note instead of the credential-required tag.
|
|
247
|
+
const descriptor = getProvider(parsed.provider);
|
|
248
|
+
const remediation = action.silenced
|
|
249
|
+
? `${action.remediation} (silenced)`
|
|
250
|
+
: action.remediation;
|
|
251
|
+
const tag = buildSkippedTag({
|
|
252
|
+
provider: parsed.provider,
|
|
253
|
+
reason: "credential_not_provided",
|
|
254
|
+
remediation,
|
|
255
|
+
silenced: action.silenced,
|
|
256
|
+
});
|
|
257
|
+
return {
|
|
258
|
+
content: [
|
|
259
|
+
{
|
|
260
|
+
type: "text",
|
|
261
|
+
text: `${tag}\n\n${descriptor.displayName} data was not fetched for this request. ` +
|
|
262
|
+
(action.silenced
|
|
263
|
+
? `You previously asked not to be reminded about this provider.`
|
|
264
|
+
: `To unlock ${descriptor.unlocks.join(", ")}, ${action.remediation}.`),
|
|
265
|
+
},
|
|
266
|
+
],
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
// action === "prompt": pause and ask the user via promptUser.
|
|
270
|
+
const descriptor = getProvider(parsed.provider);
|
|
271
|
+
const connectLabel = `Connect now — ${descriptor.instructionsHint}`;
|
|
272
|
+
const continueLabel = descriptor.fallbackDescription
|
|
273
|
+
? `Continue with ${descriptor.fallbackDescription} for this run`
|
|
274
|
+
: `Continue without ${descriptor.displayName} for this run`;
|
|
275
|
+
const snoozeLabel = `Snooze ${descriptor.snoozeDurationDays} days`;
|
|
276
|
+
const neverLabel = `Never ask again`;
|
|
277
|
+
const questionBody = `${descriptor.displayName} unlocks ${descriptor.unlocks.join(", ")}. ` +
|
|
278
|
+
`Free signup takes about 30 seconds. How would you like to proceed?`;
|
|
279
|
+
// Mark that a hard-tier prompt has now fired in this workflow (for the cap).
|
|
280
|
+
if (descriptor.tier === "hard") {
|
|
281
|
+
hardPromptFiredInWorkflow = true;
|
|
282
|
+
}
|
|
283
|
+
sessionPromptedSet.add(parsed.provider);
|
|
284
|
+
const promptResult = await promptUser(ctx, {
|
|
285
|
+
question: questionBody,
|
|
286
|
+
questionType: "select",
|
|
287
|
+
options: [connectLabel, continueLabel, snoozeLabel, neverLabel],
|
|
288
|
+
}, options?.askUserHandler);
|
|
289
|
+
if (promptResult.cancelled) {
|
|
290
|
+
// Treat cancel like "continue without".
|
|
291
|
+
return {
|
|
292
|
+
content: [
|
|
293
|
+
{
|
|
294
|
+
type: "text",
|
|
295
|
+
text: `${buildSkippedTag({
|
|
296
|
+
provider: parsed.provider,
|
|
297
|
+
reason: "credential_not_provided",
|
|
298
|
+
remediation: `run /connect ${descriptor.aliases[0] ?? descriptor.id} to unlock`,
|
|
299
|
+
})}\n\nPrompt was cancelled.`,
|
|
300
|
+
},
|
|
301
|
+
],
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
const answer = promptResult.answer ?? "";
|
|
305
|
+
if (answer.startsWith("Connect")) {
|
|
306
|
+
const connectResult = await runProviderConnect(ctx, parsed.provider);
|
|
307
|
+
if (connectResult.status === "connected") {
|
|
308
|
+
// Pi has no tool re-dispatch API — emit a CONNECTED placeholder so
|
|
309
|
+
// the LLM knows the key was just saved and can retry on the next
|
|
310
|
+
// turn (or use whatever partial data is in context).
|
|
311
|
+
return {
|
|
312
|
+
content: [
|
|
313
|
+
{
|
|
314
|
+
type: "text",
|
|
315
|
+
text: `${buildConnectedTag({ provider: parsed.provider })}\n\n` +
|
|
316
|
+
`${descriptor.displayName} was just connected. Please re-run the previous request to fetch the data now that the credential is available.`,
|
|
317
|
+
},
|
|
318
|
+
],
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
// Cancelled, blocked-by-env, or invalid_key: fall through to skipped
|
|
322
|
+
// with a result-specific explanation so the LLM can describe what
|
|
323
|
+
// just happened in its final answer.
|
|
324
|
+
const connectOutcomeDescription = connectResult.status === "blocked_by_env"
|
|
325
|
+
? "blocked by an existing environment variable"
|
|
326
|
+
: connectResult.status === "invalid_key"
|
|
327
|
+
? `rejected by ${descriptor.displayName} (the key was invalid and nothing was saved)`
|
|
328
|
+
: "cancelled";
|
|
329
|
+
return {
|
|
330
|
+
content: [
|
|
331
|
+
{
|
|
332
|
+
type: "text",
|
|
333
|
+
text: `${buildSkippedTag({
|
|
334
|
+
provider: parsed.provider,
|
|
335
|
+
reason: "credential_not_provided",
|
|
336
|
+
remediation: `run /connect ${descriptor.aliases[0] ?? descriptor.id} to unlock`,
|
|
337
|
+
})}\n\n${descriptor.displayName} connect was ${connectOutcomeDescription}.`,
|
|
338
|
+
},
|
|
339
|
+
],
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
if (answer.startsWith("Snooze")) {
|
|
343
|
+
saveOnboardingState(markProviderSnoozed(state, parsed.provider, descriptor.snoozeDurationDays));
|
|
344
|
+
}
|
|
345
|
+
else if (answer.startsWith("Never")) {
|
|
346
|
+
saveOnboardingState(markProviderNeverAsk(state, parsed.provider));
|
|
347
|
+
}
|
|
348
|
+
// "Continue" / fallthrough: no state mutation, just skip.
|
|
349
|
+
const silenced = answer.startsWith("Never");
|
|
350
|
+
const remediation = silenced
|
|
351
|
+
? `run /connect ${descriptor.aliases[0] ?? descriptor.id} to unlock (silenced)`
|
|
352
|
+
: `run /connect ${descriptor.aliases[0] ?? descriptor.id} to unlock`;
|
|
353
|
+
return {
|
|
354
|
+
content: [
|
|
355
|
+
{
|
|
356
|
+
type: "text",
|
|
357
|
+
text: `${buildSkippedTag({
|
|
358
|
+
provider: parsed.provider,
|
|
359
|
+
reason: "credential_not_provided",
|
|
360
|
+
remediation,
|
|
361
|
+
silenced,
|
|
362
|
+
})}\n\n${descriptor.displayName} data was omitted per your choice.`,
|
|
363
|
+
},
|
|
364
|
+
],
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
// No OpenCandle tag in this tool result — pass through.
|
|
368
|
+
return undefined;
|
|
369
|
+
});
|
|
370
|
+
// Input handling — branches on OPENCANDLE_ROUTER_MODE.
|
|
53
371
|
pi.on("input", async (event, ctx) => {
|
|
54
372
|
if (event.source === "extension")
|
|
55
373
|
return;
|
|
56
|
-
//
|
|
57
|
-
coordinator.extractAndStorePreferences(event.text);
|
|
58
|
-
const storage = coordinator.getStorage();
|
|
59
|
-
const workflowPrefs = storage?.getWorkflowPreferences("global") ?? {};
|
|
60
|
-
// Check for comprehensive analysis pattern
|
|
374
|
+
// Check for comprehensive analysis pattern — same in both modes.
|
|
61
375
|
const analysis = isAnalysisRequest(event.text);
|
|
62
376
|
if (analysis.match && analysis.symbol) {
|
|
63
377
|
const definition = buildComprehensiveAnalysisDefinition(analysis.symbol, { debate: getConfig().debate });
|
|
64
378
|
coordinator.executeWorkflow(pi, definition, ctx);
|
|
65
379
|
return { action: "handled" };
|
|
66
380
|
}
|
|
381
|
+
const mode = getConfig().routerMode;
|
|
382
|
+
if (mode === "llm") {
|
|
383
|
+
const dispatched = await handleLlmRouterTurn(event.text, ctx);
|
|
384
|
+
// Dispatched a workflow → the original user turn is now represented by
|
|
385
|
+
// the workflow's queued prompts; tell Pi not to also forward it.
|
|
386
|
+
// Fallback path (no dispatch) → let Pi pass the user turn through to the
|
|
387
|
+
// main agent, which will run under the router-supplied fallback context.
|
|
388
|
+
return dispatched ? { action: "handled" } : undefined;
|
|
389
|
+
}
|
|
390
|
+
// --- rules mode (default) ---
|
|
391
|
+
// Extract and persist user preferences (legacy regex path)
|
|
392
|
+
coordinator.extractAndStorePreferences(event.text);
|
|
393
|
+
const storage = coordinator.getStorage();
|
|
394
|
+
const workflowPrefs = storage?.getWorkflowPreferences("global") ?? {};
|
|
67
395
|
// Classify intent
|
|
68
396
|
const classification = classifyIntent(event.text);
|
|
69
397
|
if (classification.workflow === "portfolio_builder") {
|
|
@@ -98,10 +426,157 @@ export default function openCandleExtension(pi, options) {
|
|
|
98
426
|
return { action: "handled" };
|
|
99
427
|
}
|
|
100
428
|
});
|
|
101
|
-
|
|
429
|
+
/**
|
|
430
|
+
* LLM-mode input handler. In this mode `classifyIntent` and
|
|
431
|
+
* `extractPreferences` are NOT called — the router is the single source of
|
|
432
|
+
* classification + preference extraction. Mirrors rule-mode dispatch for
|
|
433
|
+
* identified workflows; for `fallback` turns, stashes a fallback context
|
|
434
|
+
* for the next `before_agent_start` to inject.
|
|
435
|
+
*/
|
|
436
|
+
async function handleLlmRouterTurn(text, ctx) {
|
|
437
|
+
const storage = coordinator.getStorage();
|
|
438
|
+
const { profileSnapshot, recentWorkflowRuns, priorTurns } = coordinator.buildRouterContextBase(ctx.sessionManager);
|
|
439
|
+
// priorTurns is not scrubbed for /forget — tracked in proposal.md follow-ups.
|
|
440
|
+
const input = {
|
|
441
|
+
text,
|
|
442
|
+
priorTurns,
|
|
443
|
+
profileSnapshot,
|
|
444
|
+
recentWorkflowRuns,
|
|
445
|
+
};
|
|
446
|
+
const client = options?.routerLlmClient ?? resolveRouterLlmClient(ctx);
|
|
447
|
+
if (!client) {
|
|
448
|
+
pi.appendEntry("opencandle-router-error", {
|
|
449
|
+
reason: "no_llm_client_available",
|
|
450
|
+
text,
|
|
451
|
+
});
|
|
452
|
+
return false;
|
|
453
|
+
}
|
|
454
|
+
let output;
|
|
455
|
+
try {
|
|
456
|
+
output = await routeLlm(input, client);
|
|
457
|
+
}
|
|
458
|
+
catch (err) {
|
|
459
|
+
pi.appendEntry("opencandle-router-error", {
|
|
460
|
+
reason: "route_failed",
|
|
461
|
+
text,
|
|
462
|
+
message: err instanceof Error ? err.message : String(err),
|
|
463
|
+
});
|
|
464
|
+
return false;
|
|
465
|
+
}
|
|
466
|
+
pi.appendEntry("opencandle-router", { output });
|
|
467
|
+
// Preference writes: HIGH-confidence only. Medium/low are logged for
|
|
468
|
+
// observability even when no storage is available.
|
|
469
|
+
const dropped = [];
|
|
470
|
+
for (const pref of output.preference_updates) {
|
|
471
|
+
if (pref.confidence === "high") {
|
|
472
|
+
storage?.upsertPreference({
|
|
473
|
+
key: pref.key,
|
|
474
|
+
valueJson: JSON.stringify(pref.value),
|
|
475
|
+
confidence: pref.confidence,
|
|
476
|
+
source: pref.source,
|
|
477
|
+
});
|
|
478
|
+
}
|
|
479
|
+
else {
|
|
480
|
+
dropped.push(pref);
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
if (dropped.length > 0) {
|
|
484
|
+
pi.appendEntry("opencandle-router-prefs-dropped", { dropped });
|
|
485
|
+
}
|
|
486
|
+
// Workflow dispatch for recognised workflows.
|
|
487
|
+
if (output.route === "workflow" && output.workflow) {
|
|
488
|
+
return dispatchRouterWorkflow(output, ctx);
|
|
489
|
+
}
|
|
490
|
+
// Fallback: record the turn and stash the fallback context for the
|
|
491
|
+
// upcoming `before_agent_start` hook to render into the system prompt.
|
|
492
|
+
coordinator.recordWorkflowRun("fallback", output.entities, Object.fromEntries(Object.entries(output.slots).map(([k, v]) => [k, v.value])), [], "fallback");
|
|
493
|
+
const assumptionsBlock = buildAssumptionsBlockFromRouter(output.slots);
|
|
494
|
+
coordinator.setPendingFallbackContext({
|
|
495
|
+
assumptionsBlock,
|
|
496
|
+
missingRequired: output.missing_required,
|
|
497
|
+
extraContext: output.entities.symbols.length > 0
|
|
498
|
+
? `Router-extracted symbols: ${output.entities.symbols.join(", ")}.`
|
|
499
|
+
: undefined,
|
|
500
|
+
});
|
|
501
|
+
return false;
|
|
502
|
+
}
|
|
503
|
+
function dispatchRouterWorkflow(output, ctx) {
|
|
504
|
+
const workflow = output.workflow;
|
|
505
|
+
const storage = coordinator.getStorage();
|
|
506
|
+
const workflowPrefs = storage?.getWorkflowPreferences("global") ?? {};
|
|
507
|
+
if (workflow === "portfolio_builder") {
|
|
508
|
+
const resolution = resolvePortfolioSlots(output.entities, workflowPrefs);
|
|
509
|
+
coordinator.recordWorkflowRun("portfolio_builder", output.entities, resolution.resolved, resolution.defaultsUsed, "workflow");
|
|
510
|
+
pi.appendEntry("opencandle-workflow", {
|
|
511
|
+
workflow: "portfolio_builder",
|
|
512
|
+
entities: output.entities,
|
|
513
|
+
resolved: resolution.resolved,
|
|
514
|
+
});
|
|
515
|
+
const definition = buildPortfolioWorkflowDefinition(resolution);
|
|
516
|
+
coordinator.executeWorkflow(pi, definition, ctx);
|
|
517
|
+
return true;
|
|
518
|
+
}
|
|
519
|
+
if (workflow === "options_screener") {
|
|
520
|
+
const resolution = resolveOptionsScreenerSlots(output.entities, workflowPrefs);
|
|
521
|
+
// Router may emit missing_required; main agent handles via ask_user.
|
|
522
|
+
// Still dispatch the workflow when symbol is present.
|
|
523
|
+
if (resolution.missingRequired.length === 0) {
|
|
524
|
+
coordinator.recordWorkflowRun("options_screener", output.entities, resolution.resolved, resolution.defaultsUsed, "workflow");
|
|
525
|
+
pi.appendEntry("opencandle-workflow", {
|
|
526
|
+
workflow: "options_screener",
|
|
527
|
+
entities: output.entities,
|
|
528
|
+
resolved: resolution.resolved,
|
|
529
|
+
});
|
|
530
|
+
const definition = buildOptionsScreenerWorkflowDefinition(resolution);
|
|
531
|
+
coordinator.executeWorkflow(pi, definition, ctx);
|
|
532
|
+
return true;
|
|
533
|
+
}
|
|
534
|
+
// Missing required symbol — treat as fallback with ask_user directive.
|
|
535
|
+
}
|
|
536
|
+
if (workflow === "compare_assets" && output.entities.symbols.length >= 2) {
|
|
537
|
+
const resolution = {
|
|
538
|
+
resolved: { symbols: output.entities.symbols },
|
|
539
|
+
sources: { symbols: "user" },
|
|
540
|
+
defaultsUsed: [],
|
|
541
|
+
missingRequired: [],
|
|
542
|
+
};
|
|
543
|
+
coordinator.recordWorkflowRun("compare_assets", output.entities, resolution.resolved, [], "workflow");
|
|
544
|
+
pi.appendEntry("opencandle-workflow", {
|
|
545
|
+
workflow: "compare_assets",
|
|
546
|
+
symbols: output.entities.symbols,
|
|
547
|
+
});
|
|
548
|
+
const definition = buildCompareAssetsWorkflowDefinition(resolution);
|
|
549
|
+
coordinator.executeWorkflow(pi, definition, ctx);
|
|
550
|
+
return true;
|
|
551
|
+
}
|
|
552
|
+
// single_asset_analysis / watchlist / general_qa + any workflow with
|
|
553
|
+
// unmet required slots: fall through to fallback handling so the main
|
|
554
|
+
// agent still gets an Assumptions block + ask_user directive.
|
|
555
|
+
coordinator.recordWorkflowRun("fallback", output.entities, Object.fromEntries(Object.entries(output.slots).map(([k, v]) => [k, v.value])), [], "fallback");
|
|
556
|
+
const assumptionsBlock = buildAssumptionsBlockFromRouter(output.slots);
|
|
557
|
+
coordinator.setPendingFallbackContext({
|
|
558
|
+
assumptionsBlock,
|
|
559
|
+
missingRequired: output.missing_required,
|
|
560
|
+
extraContext: `Router classified as ${workflow} but declined to dispatch. Symbols: ${output.entities.symbols.join(", ") || "(none)"}.`,
|
|
561
|
+
});
|
|
562
|
+
return false;
|
|
563
|
+
}
|
|
564
|
+
function resolveRouterLlmClient(ctx) {
|
|
565
|
+
// `ctx.model` is the currently selected pi-ai model. When unset (no auth
|
|
566
|
+
// configured yet), we skip the router and the main agent will run with
|
|
567
|
+
// its default unrouted flow (legacy rules path is the safer default).
|
|
568
|
+
const model = ctx.model;
|
|
569
|
+
if (!model)
|
|
570
|
+
return null;
|
|
571
|
+
// biome-ignore lint/suspicious/noExplicitAny: Pi typings keep Model generic
|
|
572
|
+
return createPiAiRouterClient(model);
|
|
573
|
+
}
|
|
574
|
+
// System prompt assembly — delegate to coordinator. When a fallback context
|
|
575
|
+
// is pending (router-mode fallback turns), inject it into the prompt.
|
|
102
576
|
pi.on("before_agent_start", async (event) => {
|
|
577
|
+
const fallbackContext = coordinator.consumePendingFallbackContext() ?? undefined;
|
|
103
578
|
return {
|
|
104
|
-
systemPrompt: coordinator.buildSystemPrompt(event.systemPrompt),
|
|
579
|
+
systemPrompt: coordinator.buildSystemPrompt(event.systemPrompt, undefined, fallbackContext),
|
|
105
580
|
};
|
|
106
581
|
});
|
|
107
582
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"opencandle-extension.js","sourceRoot":"","sources":["../../src/pi/opencandle-extension.ts"],"names":[],"mappings":"AACA,OAAO,EACL,iBAAiB,EACjB,eAAe,GAChB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,oCAAoC,EAAE,MAAM,6BAA6B,CAAC;AACnF,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,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E,CAAC,oBAAoB,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;QAC1C,MAAM,eAAe,GAAG,WAAW,CAAC,6BAA6B,EAAE,IAAI,SAAS,CAAC;QACjF,OAAO;YACL,YAAY,EAAE,WAAW,CAAC,iBAAiB,CAAC,KAAK,CAAC,YAAY,EAAE,SAAS,EAAE,eAAe,CAAC;SAC5F,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-storage.js","sourceRoot":"","sources":["../../src/pi/session-storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAEjE,MAAM,UAAU,yBAAyB,CAAC,GAAW,EAAE,UAAmB;IACxE,OAAO,cAAc,CAAC,cAAc,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;AACxD,CAAC"}
|
package/dist/pi/session.d.ts
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "../infra/node-version.js";
|
|
2
|
+
import { type AuthStorage, type ModelRegistry, type CreateAgentSessionResult, type SettingsManager, type SessionManager } from "@earendil-works/pi-coding-agent";
|
|
2
3
|
import type { AskUserHandler } from "../types/index.js";
|
|
3
4
|
export interface CreateOpenCandleSessionOptions {
|
|
4
5
|
cwd?: string;
|
|
6
|
+
agentDir?: string;
|
|
5
7
|
authStorage?: AuthStorage;
|
|
6
8
|
modelRegistry?: ModelRegistry;
|
|
7
9
|
settingsManager?: SettingsManager;
|
|
8
10
|
sessionManager?: SessionManager;
|
|
9
11
|
useInlineExtension?: boolean;
|
|
12
|
+
bindExtensions?: boolean;
|
|
10
13
|
askUserHandler?: AskUserHandler;
|
|
11
14
|
}
|
|
12
15
|
export declare function createOpenCandleSession(options?: CreateOpenCandleSessionOptions): Promise<CreateAgentSessionResult>;
|