crypto-quant-signal-mcp 1.23.0 → 1.23.2
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 +9 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +261 -23
- package/dist/index.js.map +1 -1
- package/dist/lib/account-handlers.d.ts +12 -2
- package/dist/lib/account-handlers.d.ts.map +1 -1
- package/dist/lib/account-handlers.js +24 -8
- package/dist/lib/account-handlers.js.map +1 -1
- package/dist/lib/adapters/kucoin.d.ts +8 -0
- package/dist/lib/adapters/kucoin.d.ts.map +1 -1
- package/dist/lib/adapters/kucoin.js +47 -17
- package/dist/lib/adapters/kucoin.js.map +1 -1
- package/dist/lib/agent-activity-format.d.ts +25 -10
- package/dist/lib/agent-activity-format.d.ts.map +1 -1
- package/dist/lib/agent-activity-format.js +63 -24
- package/dist/lib/agent-activity-format.js.map +1 -1
- package/dist/lib/analytics-snippet.d.ts +29 -0
- package/dist/lib/analytics-snippet.d.ts.map +1 -0
- package/dist/lib/analytics-snippet.js +42 -0
- package/dist/lib/analytics-snippet.js.map +1 -0
- package/dist/lib/analytics.d.ts +14 -0
- package/dist/lib/analytics.d.ts.map +1 -1
- package/dist/lib/analytics.js +126 -1
- package/dist/lib/analytics.js.map +1 -1
- package/dist/lib/attribution-sources.d.ts +44 -12
- package/dist/lib/attribution-sources.d.ts.map +1 -1
- package/dist/lib/attribution-sources.js +165 -23
- package/dist/lib/attribution-sources.js.map +1 -1
- package/dist/lib/auth-providers.d.ts +49 -0
- package/dist/lib/auth-providers.d.ts.map +1 -0
- package/dist/lib/auth-providers.js +182 -0
- package/dist/lib/auth-providers.js.map +1 -0
- package/dist/lib/carry-divergence-log.d.ts +23 -0
- package/dist/lib/carry-divergence-log.d.ts.map +1 -0
- package/dist/lib/carry-divergence-log.js +59 -0
- package/dist/lib/carry-divergence-log.js.map +1 -0
- package/dist/lib/carry-rank-reader.d.ts +9 -0
- package/dist/lib/carry-rank-reader.d.ts.map +1 -0
- package/dist/lib/carry-rank-reader.js +65 -0
- package/dist/lib/carry-rank-reader.js.map +1 -0
- package/dist/lib/channel-registry.d.ts +51 -0
- package/dist/lib/channel-registry.d.ts.map +1 -0
- package/dist/lib/channel-registry.js +154 -0
- package/dist/lib/channel-registry.js.map +1 -0
- package/dist/lib/deferred-signup.d.ts +37 -0
- package/dist/lib/deferred-signup.d.ts.map +1 -0
- package/dist/lib/deferred-signup.js +64 -0
- package/dist/lib/deferred-signup.js.map +1 -0
- package/dist/lib/docs-outline.d.ts +110 -0
- package/dist/lib/docs-outline.d.ts.map +1 -0
- package/dist/lib/docs-outline.js +250 -0
- package/dist/lib/docs-outline.js.map +1 -0
- package/dist/lib/email.js +2 -2
- package/dist/lib/equities/equity-hold.d.ts +28 -0
- package/dist/lib/equities/equity-hold.d.ts.map +1 -0
- package/dist/lib/equities/equity-hold.js +34 -0
- package/dist/lib/equities/equity-hold.js.map +1 -0
- package/dist/lib/equities/equity-tool-formatters.d.ts.map +1 -1
- package/dist/lib/equities/equity-tool-formatters.js +6 -3
- package/dist/lib/equities/equity-tool-formatters.js.map +1 -1
- package/dist/lib/equities/equity-tools-flag.d.ts +20 -0
- package/dist/lib/equities/equity-tools-flag.d.ts.map +1 -0
- package/dist/lib/equities/equity-tools-flag.js +50 -0
- package/dist/lib/equities/equity-tools-flag.js.map +1 -0
- package/dist/lib/erc8004-reputation.d.ts +2 -1
- package/dist/lib/erc8004-reputation.d.ts.map +1 -1
- package/dist/lib/erc8004-reputation.js +4 -0
- package/dist/lib/erc8004-reputation.js.map +1 -1
- package/dist/lib/errors.d.ts +33 -0
- package/dist/lib/errors.d.ts.map +1 -1
- package/dist/lib/errors.js +29 -0
- package/dist/lib/errors.js.map +1 -1
- package/dist/lib/feature-registry.d.ts +22 -0
- package/dist/lib/feature-registry.d.ts.map +1 -1
- package/dist/lib/feature-registry.js +15 -0
- package/dist/lib/feature-registry.js.map +1 -1
- package/dist/lib/footer-content.d.ts +1 -1
- package/dist/lib/footer-content.js +3 -3
- package/dist/lib/footer-content.js.map +1 -1
- package/dist/lib/free-keys-store.d.ts +15 -0
- package/dist/lib/free-keys-store.d.ts.map +1 -1
- package/dist/lib/free-keys-store.js +84 -0
- package/dist/lib/free-keys-store.js.map +1 -1
- package/dist/lib/funding-venues.d.ts +27 -0
- package/dist/lib/funding-venues.d.ts.map +1 -1
- package/dist/lib/funding-venues.js +39 -1
- package/dist/lib/funding-venues.js.map +1 -1
- package/dist/lib/funnel-dashboard-html.d.ts +19 -0
- package/dist/lib/funnel-dashboard-html.d.ts.map +1 -0
- package/dist/lib/funnel-dashboard-html.js +192 -0
- package/dist/lib/funnel-dashboard-html.js.map +1 -0
- package/dist/lib/funnel-scoreboard.d.ts +406 -0
- package/dist/lib/funnel-scoreboard.d.ts.map +1 -0
- package/dist/lib/funnel-scoreboard.js +727 -0
- package/dist/lib/funnel-scoreboard.js.map +1 -0
- package/dist/lib/geo-decide.d.ts +27 -2
- package/dist/lib/geo-decide.d.ts.map +1 -1
- package/dist/lib/geo-decide.js +42 -1
- package/dist/lib/geo-decide.js.map +1 -1
- package/dist/lib/geo-digest.d.ts +72 -6
- package/dist/lib/geo-digest.d.ts.map +1 -1
- package/dist/lib/geo-digest.js +115 -17
- package/dist/lib/geo-digest.js.map +1 -1
- package/dist/lib/geo-rates.d.ts +64 -0
- package/dist/lib/geo-rates.d.ts.map +1 -1
- package/dist/lib/geo-rates.js +83 -0
- package/dist/lib/geo-rates.js.map +1 -1
- package/dist/lib/integrations-data/render.d.ts.map +1 -1
- package/dist/lib/integrations-data/render.js +10 -3
- package/dist/lib/integrations-data/render.js.map +1 -1
- package/dist/lib/license.d.ts +9 -0
- package/dist/lib/license.d.ts.map +1 -1
- package/dist/lib/license.js +9 -1
- package/dist/lib/license.js.map +1 -1
- package/dist/lib/llm-clients.d.ts +28 -0
- package/dist/lib/llm-clients.d.ts.map +1 -0
- package/dist/lib/llm-clients.js +48 -0
- package/dist/lib/llm-clients.js.map +1 -0
- package/dist/lib/nav-manifest.d.ts +94 -0
- package/dist/lib/nav-manifest.d.ts.map +1 -0
- package/dist/lib/nav-manifest.js +211 -0
- package/dist/lib/nav-manifest.js.map +1 -0
- package/dist/lib/okx-a2mcp-config.d.ts +60 -0
- package/dist/lib/okx-a2mcp-config.d.ts.map +1 -0
- package/dist/lib/okx-a2mcp-config.js +78 -0
- package/dist/lib/okx-a2mcp-config.js.map +1 -0
- package/dist/lib/okx-a2mcp.d.ts +3 -59
- package/dist/lib/okx-a2mcp.d.ts.map +1 -1
- package/dist/lib/okx-a2mcp.js +34 -75
- package/dist/lib/okx-a2mcp.js.map +1 -1
- package/dist/lib/performance-db.d.ts +2 -0
- package/dist/lib/performance-db.d.ts.map +1 -1
- package/dist/lib/performance-db.js +18 -8
- package/dist/lib/performance-db.js.map +1 -1
- package/dist/lib/public-cta.d.ts +46 -0
- package/dist/lib/public-cta.d.ts.map +1 -0
- package/dist/lib/public-cta.js +46 -0
- package/dist/lib/public-cta.js.map +1 -0
- package/dist/lib/referral-pages.d.ts +11 -1
- package/dist/lib/referral-pages.d.ts.map +1 -1
- package/dist/lib/referral-pages.js +8 -16
- package/dist/lib/referral-pages.js.map +1 -1
- package/dist/lib/signin-component.d.ts +52 -0
- package/dist/lib/signin-component.d.ts.map +1 -0
- package/dist/lib/signin-component.js +176 -0
- package/dist/lib/signin-component.js.map +1 -0
- package/dist/lib/site-nav.d.ts +4 -15
- package/dist/lib/site-nav.d.ts.map +1 -1
- package/dist/lib/site-nav.js +167 -83
- package/dist/lib/site-nav.js.map +1 -1
- package/dist/lib/stripe.d.ts +15 -0
- package/dist/lib/stripe.d.ts.map +1 -1
- package/dist/lib/stripe.js +55 -0
- package/dist/lib/stripe.js.map +1 -1
- package/dist/lib/tagged-link.d.ts +15 -0
- package/dist/lib/tagged-link.d.ts.map +1 -0
- package/dist/lib/tagged-link.js +57 -0
- package/dist/lib/tagged-link.js.map +1 -0
- package/dist/lib/tier-warning.d.ts +7 -0
- package/dist/lib/tier-warning.d.ts.map +1 -1
- package/dist/lib/tier-warning.js +14 -1
- package/dist/lib/tier-warning.js.map +1 -1
- package/dist/lib/welcome-page.d.ts +11 -0
- package/dist/lib/welcome-page.d.ts.map +1 -1
- package/dist/lib/welcome-page.js +28 -2
- package/dist/lib/welcome-page.js.map +1 -1
- package/dist/lib/x402-http-routes.d.ts.map +1 -1
- package/dist/lib/x402-http-routes.js +4 -1
- package/dist/lib/x402-http-routes.js.map +1 -1
- package/dist/lib/x402-idempotency-store.d.ts +12 -1
- package/dist/lib/x402-idempotency-store.d.ts.map +1 -1
- package/dist/lib/x402-idempotency-store.js +47 -6
- package/dist/lib/x402-idempotency-store.js.map +1 -1
- package/dist/lib/x402-nudge.d.ts +16 -0
- package/dist/lib/x402-nudge.d.ts.map +1 -0
- package/dist/lib/x402-nudge.js +113 -0
- package/dist/lib/x402-nudge.js.map +1 -0
- package/dist/lib/x402-operator-wallets.d.ts +32 -0
- package/dist/lib/x402-operator-wallets.d.ts.map +1 -0
- package/dist/lib/x402-operator-wallets.js +46 -0
- package/dist/lib/x402-operator-wallets.js.map +1 -0
- package/dist/scripts/acp-graduation-buyer.d.ts +56 -0
- package/dist/scripts/acp-graduation-buyer.d.ts.map +1 -0
- package/dist/scripts/acp-graduation-buyer.js +318 -0
- package/dist/scripts/acp-graduation-buyer.js.map +1 -0
- package/dist/scripts/agent-forum-post.js +2 -1
- package/dist/scripts/agent-forum-post.js.map +1 -1
- package/dist/scripts/backfill-funding-episodes.d.ts +19 -0
- package/dist/scripts/backfill-funding-episodes.d.ts.map +1 -0
- package/dist/scripts/backfill-funding-episodes.js +389 -0
- package/dist/scripts/backfill-funding-episodes.js.map +1 -0
- package/dist/scripts/backfill-x402-payer-wallet.d.ts +7 -0
- package/dist/scripts/backfill-x402-payer-wallet.d.ts.map +1 -0
- package/dist/scripts/backfill-x402-payer-wallet.js +89 -0
- package/dist/scripts/backfill-x402-payer-wallet.js.map +1 -0
- package/dist/scripts/carry-freshness-helpers.d.ts +14 -0
- package/dist/scripts/carry-freshness-helpers.d.ts.map +1 -0
- package/dist/scripts/carry-freshness-helpers.js +33 -0
- package/dist/scripts/carry-freshness-helpers.js.map +1 -0
- package/dist/scripts/funding-baseline-report.d.ts +2 -0
- package/dist/scripts/funding-baseline-report.d.ts.map +1 -0
- package/dist/scripts/funding-baseline-report.js +237 -0
- package/dist/scripts/funding-baseline-report.js.map +1 -0
- package/dist/scripts/funding-episode-builder.d.ts +51 -0
- package/dist/scripts/funding-episode-builder.d.ts.map +1 -0
- package/dist/scripts/funding-episode-builder.js +107 -0
- package/dist/scripts/funding-episode-builder.js.map +1 -0
- package/dist/scripts/geo-weekly-cron.js +92 -17
- package/dist/scripts/geo-weekly-cron.js.map +1 -1
- package/dist/scripts/nightly-carry-labeler.d.ts +19 -0
- package/dist/scripts/nightly-carry-labeler.d.ts.map +1 -0
- package/dist/scripts/nightly-carry-labeler.js +123 -0
- package/dist/scripts/nightly-carry-labeler.js.map +1 -0
- package/dist/scripts/seed-signals.d.ts +1 -0
- package/dist/scripts/seed-signals.d.ts.map +1 -1
- package/dist/scripts/seed-signals.js +39 -4
- package/dist/scripts/seed-signals.js.map +1 -1
- package/dist/scripts/tool-readiness-report.d.ts +2 -2
- package/dist/scripts/tool-readiness-report.d.ts.map +1 -1
- package/dist/scripts/tool-readiness-report.js +5 -5
- package/dist/scripts/tool-readiness-report.js.map +1 -1
- package/dist/scripts/venue-readiness-report.d.ts.map +1 -1
- package/dist/scripts/venue-readiness-report.js +14 -5
- package/dist/scripts/venue-readiness-report.js.map +1 -1
- package/dist/tools/get-market-regime.d.ts.map +1 -1
- package/dist/tools/get-market-regime.js +2 -0
- package/dist/tools/get-market-regime.js.map +1 -1
- package/dist/tools/get-trade-call.d.ts.map +1 -1
- package/dist/tools/get-trade-call.js +2 -0
- package/dist/tools/get-trade-call.js.map +1 -1
- package/dist/tools/scan-funding-arb.d.ts +16 -2
- package/dist/tools/scan-funding-arb.d.ts.map +1 -1
- package/dist/tools/scan-funding-arb.js +141 -3
- package/dist/tools/scan-funding-arb.js.map +1 -1
- package/dist/tools/scan-trade-calls.d.ts +4 -1
- package/dist/tools/scan-trade-calls.d.ts.map +1 -1
- package/dist/tools/scan-trade-calls.js +8 -0
- package/dist/tools/scan-trade-calls.js.map +1 -1
- package/dist/types.d.ts +47 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +3 -3
- package/server.json +1 -1
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
</p>
|
|
12
12
|
|
|
13
13
|
<p align="center">
|
|
14
|
-
<span data-tr-field="pfe_wr">91.
|
|
14
|
+
<span data-tr-field="pfe_wr">91.6%</span>% PFE win rate across <span data-tr-field="total_calls">374,696</span>+ verified calls. Merkle-verified on Base L2. Don't trust — verify. <!-- SNAPSHOT-LINE -->
|
|
15
15
|
</p>
|
|
16
16
|
|
|
17
17
|
<p align="center">
|
|
@@ -110,7 +110,7 @@ The `_algovault` block makes outputs composable: downstream risk and backtest to
|
|
|
110
110
|
scripts/snapshot-landing-data.mjs at npm-publish + Hetzner-deploy. Do NOT hand-edit the
|
|
111
111
|
numbers; edit "What's new" by hand. Wired by OPS-NPM-README-SINGLE-SOT-W1 (2026-05-31). -->
|
|
112
112
|
<p align="center">
|
|
113
|
-
<strong><span data-tr-field="pfe_wr">91.
|
|
113
|
+
<strong><span data-tr-field="pfe_wr">91.6%</span>% PFE Win Rate</strong> · <strong><span data-tr-field="total_calls">374,696</span> trade calls</strong> · <strong><span data-tr-field="merkle_batches">98</span> on-chain batches</strong> · <strong><span data-tr-field="hold_rate">99.1%</span>% HOLD rate</strong> <!-- SNAPSHOT-LINE -->
|
|
114
114
|
</p>
|
|
115
115
|
|
|
116
116
|
<p align="center">
|
|
@@ -224,7 +224,7 @@ Quota-only tiers. Every tier gets all venues, all assets, all timeframes — you
|
|
|
224
224
|
| Feature | Free | Starter ($9.99/mo) | Pro ($49/mo) | Enterprise ($299/mo) | x402 (per call) |
|
|
225
225
|
|---------|------|-------------------|-------------|---------------------|-----------------|
|
|
226
226
|
| Exchanges | All 12 | All 12 | All 12 | All 12 | All 12 | <!-- SNAPSHOT-LINE-TABLE -->
|
|
227
|
-
| Assets | All
|
|
227
|
+
| Assets | All 1300+ | All 1300+ | All 1300+ | All 1300+ | All 1300+ | <!-- SNAPSHOT-LINE-TABLE -->
|
|
228
228
|
| Asset classes | Crypto + TradFi | Crypto + TradFi | Crypto + TradFi | Crypto + TradFi | Crypto + TradFi |
|
|
229
229
|
| Timeframes | All 11 | All 11 | All 11 | All 11 | All 11 |
|
|
230
230
|
| Funding arb results | Top 5 | Unlimited | Unlimited | Unlimited | Unlimited |
|
|
@@ -242,7 +242,12 @@ Quota-only tiers. Every tier gets all venues, all assets, all timeframes — you
|
|
|
242
242
|
|
|
243
243
|
---
|
|
244
244
|
|
|
245
|
-
## What's new in v1.23.
|
|
245
|
+
## What's new in v1.23.1
|
|
246
|
+
|
|
247
|
+
- **🔗 A dedicated page for every way to connect.** New hub pages walk through each access channel end-to-end, with copy-paste code and a quick FAQ: [MCP](https://algovault.com/mcp), [REST API](https://algovault.com/rest-api), and [webhooks](https://algovault.com/webhooks).
|
|
248
|
+
- **🧭 Tools index + unified navigation.** Browse all public tools at [algovault.com/tools](https://algovault.com/tools); a new Platform menu makes the whole site easier to navigate.
|
|
249
|
+
|
|
250
|
+
### v1.23.0 highlights (recap)
|
|
246
251
|
|
|
247
252
|
- **📡 Cross-venue funding arbitrage now spans 7 venues.** `scan_funding_arb` expanded from 3 to 7 — Hyperliquid, Binance, Bybit, Gate, KuCoin, Aster, and OKX — with interval-correct annualization per venue and a per-leg liquidity filter, so only tradeable spreads surface.
|
|
248
253
|
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAWA,OAAO,EAAE,SAAS,EAAuC,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAWA,OAAO,EAAE,SAAS,EAAuC,MAAM,yCAAyC,CAAC;AA2SzG;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,MAAM,EAAE,MAAM,GACb,MAAM,CAOR;AAED;;;;;;;GAOG;AACH,wBAAsB,kBAAkB,CACtC,GAAG,EAAE,OAAO,SAAS,EAAE,OAAO,EAC9B,GAAG,EAAE,OAAO,SAAS,EAAE,QAAQ,EAC/B,UAAU,EAAE,MAAM,SAAS,GAC1B,OAAO,CAAC,IAAI,CAAC,CAYf;AAg+HD,wBAAgB,mBAAmB,cAElC"}
|
package/dist/index.js
CHANGED
|
@@ -67,9 +67,11 @@ const webhook_delivery_js_1 = require("./lib/webhook-delivery.js");
|
|
|
67
67
|
const scan_digest_scheduler_js_1 = require("./lib/scan-digest-scheduler.js");
|
|
68
68
|
const pkg_version_js_1 = require("./lib/pkg-version.js");
|
|
69
69
|
const erc8004_reputation_js_1 = require("./lib/erc8004-reputation.js");
|
|
70
|
+
const public_cta_js_1 = require("./lib/public-cta.js");
|
|
70
71
|
const merkle_js_1 = require("./lib/merkle.js");
|
|
71
72
|
const asset_tiers_js_1 = require("./lib/asset-tiers.js");
|
|
72
73
|
const capabilities_js_1 = require("./lib/capabilities.js");
|
|
74
|
+
const funding_venues_js_1 = require("./lib/funding-venues.js");
|
|
73
75
|
const license_js_1 = require("./lib/license.js");
|
|
74
76
|
const x402_js_1 = require("./lib/x402.js");
|
|
75
77
|
const x402_http_routes_js_1 = require("./lib/x402-http-routes.js");
|
|
@@ -107,12 +109,20 @@ const traffic_classifier_js_1 = require("./lib/traffic-classifier.js");
|
|
|
107
109
|
const attribution_sources_js_1 = require("./lib/attribution-sources.js");
|
|
108
110
|
const stripe_js_1 = require("./lib/stripe.js");
|
|
109
111
|
const errors_js_1 = require("./lib/errors.js");
|
|
112
|
+
// FUNNEL-FIX-AGENT-X402-NUDGE-W1: at the quota edge, offer the agent an in-protocol x402
|
|
113
|
+
// pay-per-call rail. The helper is a LEAF (imports only pure/SDK modules) so this root import
|
|
114
|
+
// adds no cycle. Dark behind X402_NUDGE_ENABLED (default OFF ⇒ envelope byte-identical).
|
|
115
|
+
const x402_nudge_js_1 = require("./lib/x402-nudge.js");
|
|
110
116
|
const upstream_weight_budget_js_1 = require("./lib/upstream-weight-budget.js");
|
|
111
117
|
const venue_store_js_1 = require("./lib/venue-store.js");
|
|
112
118
|
const bot_auth_js_1 = require("./lib/bot-auth.js");
|
|
113
119
|
const welcome_page_js_1 = require("./lib/welcome-page.js");
|
|
114
120
|
const tool_descriptions_js_1 = require("./tool-descriptions.js");
|
|
115
121
|
const feature_registry_js_1 = require("./lib/feature-registry.js");
|
|
122
|
+
// EQUITY-TOOLS-DARK-RETIRE-W1: the live tools/list set is env-gated (get_equity_call /
|
|
123
|
+
// get_equity_regime dark behind EQUITY_TOOLS_ENABLED, default OFF). allToolNames() stays
|
|
124
|
+
// the DECLARED set (9); liveMcpToolNames() is what actually registers (7 OFF / 9 ON).
|
|
125
|
+
const equity_tools_flag_js_1 = require("./lib/equities/equity-tools-flag.js");
|
|
116
126
|
const knowledge_store_js_1 = require("./lib/knowledge-store.js");
|
|
117
127
|
// AV-CHAT-MCP-W1 (C2, 2026-05-18) — knowledge search substrate. Module-level
|
|
118
128
|
// singletons shared between the MCP tool handler (in createServer()) and the
|
|
@@ -176,19 +186,14 @@ function toolErrorContent(err) {
|
|
|
176
186
|
return { content: [{ type: 'text', text: JSON.stringify(payload) }], isError: true };
|
|
177
187
|
}
|
|
178
188
|
if (err instanceof errors_js_1.TierLimitReachedError) {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
retry_after_days: err.retry_after_days,
|
|
188
|
-
// REFERRAL-INPRODUCT-NUDGE-W1: additive, allow-listed referral hint (agent-
|
|
189
|
-
// relayable). The human `message` already leads with the referral arm.
|
|
190
|
-
referral_hint: err.referral_hint,
|
|
191
|
-
};
|
|
189
|
+
// FUNNEL-FIX-AGENT-X402-NUDGE-W1: additive `suggested_x402` in-protocol pay-per-call branch
|
|
190
|
+
// (the agent can settle with its own wallet, no human signup) alongside the intact Stripe/
|
|
191
|
+
// referral fields — closes the quota-crossing→paid leak (a machine can't fill a Stripe
|
|
192
|
+
// checkout). Derived from the feature-registry channels{} SoT + live rail predicates; omitted
|
|
193
|
+
// (envelope byte-identical) when X402_NUDGE_ENABLED is off, no public rail is live, or the
|
|
194
|
+
// tool is HELD. The allow-list formatter (buildTierLimitPayload) is the single wire shape.
|
|
195
|
+
const suggestedX402 = (0, x402_nudge_js_1.isX402NudgeEnabled)() && err.tool ? (0, x402_nudge_js_1.buildSuggestedX402)(err.tool) : undefined;
|
|
196
|
+
const payload = (0, errors_js_1.buildTierLimitPayload)(err, { suggestedX402 });
|
|
192
197
|
return { content: [{ type: 'text', text: JSON.stringify(payload) }], isError: true };
|
|
193
198
|
}
|
|
194
199
|
if (err instanceof errors_js_1.InsufficientCandlesError) {
|
|
@@ -441,6 +446,7 @@ function createServer() {
|
|
|
441
446
|
tool: toolNameForAnalytics,
|
|
442
447
|
tier: license.tier,
|
|
443
448
|
ipHash: (0, license_js_1.getRequestIpHash)() ?? null,
|
|
449
|
+
source: (0, license_js_1.getRequestSource)() ?? null,
|
|
444
450
|
}).catch((e) => console.debug('upsertAgentSession failed:', e instanceof Error ? e.message : e));
|
|
445
451
|
}
|
|
446
452
|
// P0 VERDICT-WITH-RECEIPTS-W1: content[0] stays the JSON envelope (now with
|
|
@@ -493,6 +499,7 @@ function createServer() {
|
|
|
493
499
|
tool: 'scan_funding_arb',
|
|
494
500
|
tier: license.tier,
|
|
495
501
|
ipHash: (0, license_js_1.getRequestIpHash)() ?? null,
|
|
502
|
+
source: (0, license_js_1.getRequestSource)() ?? null,
|
|
496
503
|
}).catch((e) => console.debug('upsertAgentSession failed:', e instanceof Error ? e.message : e));
|
|
497
504
|
}
|
|
498
505
|
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
@@ -529,6 +536,7 @@ function createServer() {
|
|
|
529
536
|
tool: 'get_market_regime',
|
|
530
537
|
tier: license.tier,
|
|
531
538
|
ipHash: (0, license_js_1.getRequestIpHash)() ?? null,
|
|
539
|
+
source: (0, license_js_1.getRequestSource)() ?? null,
|
|
532
540
|
}).catch((e) => console.debug('upsertAgentSession failed:', e instanceof Error ? e.message : e));
|
|
533
541
|
}
|
|
534
542
|
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
@@ -617,6 +625,7 @@ function createServer() {
|
|
|
617
625
|
tool: 'scan_trade_calls',
|
|
618
626
|
tier: license.tier,
|
|
619
627
|
ipHash: (0, license_js_1.getRequestIpHash)() ?? null,
|
|
628
|
+
source: (0, license_js_1.getRequestSource)() ?? null,
|
|
620
629
|
}).catch((e) => console.debug('upsertAgentSession failed:', e instanceof Error ? e.message : e));
|
|
621
630
|
}
|
|
622
631
|
// content[0] = the JSON envelope (with the shared `_receipts` block).
|
|
@@ -757,7 +766,10 @@ function createServer() {
|
|
|
757
766
|
// handler/schema/annotations/description from toolDefs. Bidirectional parity guard:
|
|
758
767
|
// a registry name with no handler def — or a handler def absent from the registry —
|
|
759
768
|
// throws at boot (drift can't ship silently; the CH4 canary enforces the same live).
|
|
760
|
-
|
|
769
|
+
// EQUITY-TOOLS-DARK-RETIRE-W1: iterate the ENV-GATED live set (liveMcpToolNames) — OFF
|
|
770
|
+
// drops the 2 equity tools (9→7). The equity register() calls above stay (harmless,
|
|
771
|
+
// just not iterated); guard B below still checks toolDefs ⊆ allToolNames (DECLARED set).
|
|
772
|
+
for (const name of (0, equity_tools_flag_js_1.liveMcpToolNames)()) {
|
|
761
773
|
const d = toolDefs[name];
|
|
762
774
|
if (!d)
|
|
763
775
|
throw new Error(`[feature-registry] "${name}" is in FEATURE_REGISTRY but has no handler def in createServer()`);
|
|
@@ -1055,7 +1067,15 @@ async function startHttp() {
|
|
|
1055
1067
|
// FEATURE_REGISTRY) — no hand-maintained per-channel slice. No internal fields.
|
|
1056
1068
|
app.get('/capabilities', (_req, res) => {
|
|
1057
1069
|
res.setHeader('Cache-Control', 'public, max-age=60, must-revalidate');
|
|
1058
|
-
|
|
1070
|
+
// EQUITY-TOOLS-DARK-RETIRE-W1: the /capabilities MCP-channel projection tracks the
|
|
1071
|
+
// LIVE tools/list — both derive from liveMcpToolNames() so the two stay self-consistent
|
|
1072
|
+
// (the feature-registry `--live` drift canary asserts tools/list == /capabilities; a
|
|
1073
|
+
// gated tools/list with an ungated /capabilities would be a real MCP-channel drift).
|
|
1074
|
+
// projectCapabilities() itself stays the pristine 9-name registry projection (the
|
|
1075
|
+
// STATIC `--check` canary + feature-registry unit test read it directly).
|
|
1076
|
+
const liveNames = new Set((0, equity_tools_flag_js_1.liveMcpToolNames)());
|
|
1077
|
+
const tools = (0, feature_registry_js_1.projectCapabilities)().tools.filter((t) => liveNames.has(t.name));
|
|
1078
|
+
res.json({ server: 'crypto-quant-signal-mcp', version: pkg_version_js_1.PKG_VERSION, tools });
|
|
1059
1079
|
});
|
|
1060
1080
|
// ── Integration tutorial mirrors ──
|
|
1061
1081
|
// Static HTML pre-rendered from algovault-skills/docs/integrations/<x>.md
|
|
@@ -1394,13 +1414,21 @@ async function startHttp() {
|
|
|
1394
1414
|
const sessionId = req.query.session_id;
|
|
1395
1415
|
const utmSource = typeof req.query.utm_source === 'string' ? req.query.utm_source : null;
|
|
1396
1416
|
const utmCampaign = typeof req.query.utm_campaign === 'string' ? req.query.utm_campaign : null;
|
|
1417
|
+
// FUNNEL-FIX-HUMAN-SIGNUP-W1: render the value-before-email + OAuth options only when flagged;
|
|
1418
|
+
// each OAuth button renders ONLY when its real creds exist (no stub buttons shown to users).
|
|
1419
|
+
const { isNewSignupEnabled, isUnifiedSigninEnabled, getAuthProvider } = await import('./lib/auth-providers.js');
|
|
1420
|
+
const newSignupEnabled = isNewSignupEnabled();
|
|
1421
|
+
// FUNNEL-FIX-AUTH-UNIFY-W1: outer flag → the ONE shared sign-in card on the organic arm.
|
|
1422
|
+
const unifiedSignin = isUnifiedSigninEnabled();
|
|
1423
|
+
const oauthProviders = { google: getAuthProvider('google').live, github: getAuthProvider('github').live };
|
|
1424
|
+
const src = typeof req.query.src === 'string' ? req.query.src : null;
|
|
1397
1425
|
// Organic visit (no session_id) — render paywall CTA + no API-key reveal.
|
|
1398
1426
|
if (!sessionId) {
|
|
1399
|
-
return res.send((0, welcome_page_js_1.getWelcomePageHtml)(null, null, null, { utmSource, utmCampaign }));
|
|
1427
|
+
return res.send((0, welcome_page_js_1.getWelcomePageHtml)(null, null, null, { utmSource, utmCampaign, newSignupEnabled, oauthProviders, unifiedSignin, src }));
|
|
1400
1428
|
}
|
|
1401
1429
|
try {
|
|
1402
1430
|
const { apiKey, tier, email } = await (0, stripe_js_1.getCustomerApiKey)(sessionId);
|
|
1403
|
-
res.send((0, welcome_page_js_1.getWelcomePageHtml)(apiKey, tier, email, { utmSource, utmCampaign }));
|
|
1431
|
+
res.send((0, welcome_page_js_1.getWelcomePageHtml)(apiKey, tier, email, { utmSource, utmCampaign, newSignupEnabled, oauthProviders, unifiedSignin, src }));
|
|
1404
1432
|
}
|
|
1405
1433
|
catch (err) {
|
|
1406
1434
|
console.error('Welcome page error:', err instanceof Error ? err.message : err);
|
|
@@ -1434,10 +1462,22 @@ async function startHttp() {
|
|
|
1434
1462
|
// destination (incentive-first; CTA routes anon visitors to /account). Served
|
|
1435
1463
|
// on the apex via the Caddyfile `handle /referral` reverse_proxy (same path as
|
|
1436
1464
|
// /track-record) so algovault.com/referral resolves; mirrors /referral-terms.
|
|
1437
|
-
app.get('/referral', async (
|
|
1465
|
+
app.get('/referral', async (req, res) => {
|
|
1438
1466
|
const { renderReferralLandingPage } = await import('./lib/referral-pages.js');
|
|
1467
|
+
// FUNNEL-FIX-AUTH-UNIFY-W1: outer flag OFF → email-only legacy page (byte-identical);
|
|
1468
|
+
// ON → the shared sign-in card (referral reachable by one-tap Google/GitHub).
|
|
1469
|
+
const { isUnifiedSigninEnabled, isNewSignupEnabled, getAuthProvider } = await import('./lib/auth-providers.js');
|
|
1470
|
+
const unifiedSignin = isUnifiedSigninEnabled();
|
|
1471
|
+
const referralOpts = unifiedSignin
|
|
1472
|
+
? {
|
|
1473
|
+
unifiedSignin,
|
|
1474
|
+
newSignupEnabled: isNewSignupEnabled(),
|
|
1475
|
+
oauthProviders: { google: getAuthProvider('google').live, github: getAuthProvider('github').live },
|
|
1476
|
+
src: typeof req.query.src === 'string' ? req.query.src : null,
|
|
1477
|
+
}
|
|
1478
|
+
: {};
|
|
1439
1479
|
res.setHeader('Content-Type', 'text/html; charset=utf-8');
|
|
1440
|
-
res.send(renderReferralLandingPage());
|
|
1480
|
+
res.send(renderReferralLandingPage(referralOpts));
|
|
1441
1481
|
});
|
|
1442
1482
|
// REFERRAL-WEB-FIX-W1: the branded apex referee landing every web share link points
|
|
1443
1483
|
// to. Validates ?ref= (invalid/missing → graceful general start-free, no bonus claim);
|
|
@@ -1984,6 +2024,52 @@ async function startHttp() {
|
|
|
1984
2024
|
res.status(500).send('Internal error rendering subscriber tracker');
|
|
1985
2025
|
}
|
|
1986
2026
|
});
|
|
2027
|
+
// H0-C4-MEASURE-CLOSE: always-on activation-funnel scoreboard (INTERNAL/META).
|
|
2028
|
+
// JSON — the single getFunnelScoreboard() aggregation (composes the existing
|
|
2029
|
+
// generateFunnelSnapshot + subscriber-attribution + Stripe census; adds no MCP
|
|
2030
|
+
// tool, no version bump). Admin-gated like every /dashboard/api/* endpoint.
|
|
2031
|
+
app.get('/dashboard/api/funnel-scoreboard', async (req, res) => {
|
|
2032
|
+
if (!isAdminAuthorized(req)) {
|
|
2033
|
+
return res.status(401).json({ error: 'Unauthorized' });
|
|
2034
|
+
}
|
|
2035
|
+
try {
|
|
2036
|
+
// FUNNEL-SCOREBOARD-V2: ?window=7|30|90|180|365|all (default all) scopes both funnels.
|
|
2037
|
+
const allowed = new Set(['7', '30', '90', '180', '365', 'all']);
|
|
2038
|
+
const wRaw = String(req.query.window ?? 'all');
|
|
2039
|
+
const window = (allowed.has(wRaw) ? wRaw : 'all');
|
|
2040
|
+
const { getFunnelScoreboard } = await import('./lib/funnel-scoreboard.js');
|
|
2041
|
+
const scoreboard = await getFunnelScoreboard({ window });
|
|
2042
|
+
res.setHeader('Cache-Control', 'no-store');
|
|
2043
|
+
res.json(scoreboard);
|
|
2044
|
+
}
|
|
2045
|
+
catch (err) {
|
|
2046
|
+
console.error(`[/dashboard/api/funnel-scoreboard] internal error: ${err instanceof Error ? err.message : err}`);
|
|
2047
|
+
res.status(500).json({ error: 'Failed to compute funnel scoreboard' });
|
|
2048
|
+
}
|
|
2049
|
+
});
|
|
2050
|
+
// HTML shell — cookie-gated EXACTLY like /dashboard (anonymous → 401; ?key= sets
|
|
2051
|
+
// the session cookie then redirects). The served HTML embeds no data; it fetches
|
|
2052
|
+
// the gated JSON above via a same-origin XHR carrying the admin cookie.
|
|
2053
|
+
app.get('/dashboard/funnel', (req, res) => {
|
|
2054
|
+
const key = req.query.key;
|
|
2055
|
+
if (key && safeCompare(key, adminKey)) {
|
|
2056
|
+
const sessionToken = createAdminSession();
|
|
2057
|
+
res.setHeader('Set-Cookie', `${ADMIN_COOKIE_NAME}=${sessionToken}; HttpOnly; SameSite=Strict; Path=/; Max-Age=${ADMIN_SESSION_TTL / 1000}${req.secure ? '; Secure' : ''}`);
|
|
2058
|
+
return res.redirect(303, '/dashboard/funnel');
|
|
2059
|
+
}
|
|
2060
|
+
if (!isValidAdminSession(req.headers.cookie)) {
|
|
2061
|
+
return res.status(401).send('Unauthorized — add ?key=YOUR_ADMIN_KEY to the URL');
|
|
2062
|
+
}
|
|
2063
|
+
res.setHeader('Cache-Control', 'no-store');
|
|
2064
|
+
res.setHeader('Content-Type', 'text/html; charset=utf-8');
|
|
2065
|
+
// Lazy require keeps the shell out of the hot import graph; sync render.
|
|
2066
|
+
import('./lib/funnel-dashboard-html.js')
|
|
2067
|
+
.then(({ renderFunnelDashboardHtml }) => res.send(renderFunnelDashboardHtml()))
|
|
2068
|
+
.catch((err) => {
|
|
2069
|
+
console.error(`[/dashboard/funnel] render error: ${err instanceof Error ? err.message : err}`);
|
|
2070
|
+
res.status(500).send('Internal error rendering funnel scoreboard');
|
|
2071
|
+
});
|
|
2072
|
+
});
|
|
1987
2073
|
}
|
|
1988
2074
|
// ── Public track record (no auth) ──
|
|
1989
2075
|
// WEBSITE-REFRESH-CLEANUP-W1 R2: also returns `hold_rate` (computed from
|
|
@@ -2056,6 +2142,14 @@ async function startHttp() {
|
|
|
2056
2142
|
exchange_count: capabilities_js_1.EXCHANGE_COUNT,
|
|
2057
2143
|
timeframe_count: capabilities_js_1.TIMEFRAME_COUNT,
|
|
2058
2144
|
shadow_venue_count,
|
|
2145
|
+
// OPS-LANDING-FUNDING-VENUE-RECONCILE-W1: additive PUBLIC funding-arb venue
|
|
2146
|
+
// count (=7), single-derived from FUNDING_VENUE_META. Count-only, no outcome_*;
|
|
2147
|
+
// lets landing copy live-bind funding_venue_count the same way exchange_count does.
|
|
2148
|
+
funding_venue_count: funding_venues_js_1.FUNDING_VENUE_COUNT,
|
|
2149
|
+
// OPS-PUBLIC-API-CONVERT-NUDGE-W1: additive machine-readable conversion
|
|
2150
|
+
// CTA. Existing fields byte-unchanged; single-derivation from
|
|
2151
|
+
// src/lib/public-cta.ts (no data withheld, no rate-limit).
|
|
2152
|
+
_algovault: (0, public_cta_js_1.buildPublicCtaBlock)(),
|
|
2059
2153
|
});
|
|
2060
2154
|
}
|
|
2061
2155
|
catch (err) {
|
|
@@ -2217,6 +2311,10 @@ async function startHttp() {
|
|
|
2217
2311
|
})),
|
|
2218
2312
|
contractAddress: MERKLE_CONTRACT_ADDR,
|
|
2219
2313
|
chain: 'Base (8453)',
|
|
2314
|
+
// OPS-PUBLIC-API-CONVERT-NUDGE-W1: additive machine-readable conversion
|
|
2315
|
+
// CTA (single-derivation from src/lib/public-cta.ts). Existing fields
|
|
2316
|
+
// byte-unchanged.
|
|
2317
|
+
_algovault: (0, public_cta_js_1.buildPublicCtaBlock)(),
|
|
2220
2318
|
});
|
|
2221
2319
|
}
|
|
2222
2320
|
catch {
|
|
@@ -2435,10 +2533,25 @@ async function startHttp() {
|
|
|
2435
2533
|
// REFERRAL-FREE-KEY-SIGNUP-W1: mint an av_free_ key for EVERY signup (idempotent
|
|
2436
2534
|
// on email), then derive the persisted referral code + share link. The keyless
|
|
2437
2535
|
// free tier (no key passed) is untouched — this only ADDS the opt-in account.
|
|
2438
|
-
const { mintFreeKey } = await import('./lib/free-keys-store.js');
|
|
2536
|
+
const { mintFreeKey, isEphemeralKey } = await import('./lib/free-keys-store.js');
|
|
2439
2537
|
const { ensureUserCode } = await import('./lib/referral-store.js');
|
|
2440
2538
|
const { shareLink } = await import('./lib/referral-constants.js');
|
|
2441
|
-
const
|
|
2539
|
+
const { isNewSignupEnabled } = await import('./lib/auth-providers.js');
|
|
2540
|
+
// FUNNEL-FIX-HUMAN-SIGNUP-W1: if this signup CLAIMS a prior ephemeral key (deferred
|
|
2541
|
+
// email), MERGE it (email = identity; idempotent; no double key) instead of minting
|
|
2542
|
+
// anew — behind NEW_SIGNUP_ENABLED. Legacy path (no ephemeral_key / flag off) unchanged.
|
|
2543
|
+
const ephemeralKey = typeof body.ephemeral_key === 'string' ? body.ephemeral_key : null;
|
|
2544
|
+
let key;
|
|
2545
|
+
if (referral.freeKey) {
|
|
2546
|
+
key = referral.freeKey;
|
|
2547
|
+
}
|
|
2548
|
+
else if (ephemeralKey && isNewSignupEnabled() && (await isEphemeralKey(ephemeralKey))) {
|
|
2549
|
+
const { captureEmail } = await import('./lib/deferred-signup.js');
|
|
2550
|
+
key = (await captureEmail(ephemeralKey, email, ref ?? null)).key;
|
|
2551
|
+
}
|
|
2552
|
+
else {
|
|
2553
|
+
key = await mintFreeKey(email);
|
|
2554
|
+
}
|
|
2442
2555
|
const referralCode = await ensureUserCode(key, email);
|
|
2443
2556
|
const referralLink = shareLink(referralCode);
|
|
2444
2557
|
// Transactional key email (NOT gated on marketing consent) — referred → bonus
|
|
@@ -2479,6 +2592,121 @@ async function startHttp() {
|
|
|
2479
2592
|
return res.status(500).json({ ok: false, error: 'internal_error' });
|
|
2480
2593
|
}
|
|
2481
2594
|
});
|
|
2595
|
+
// ── FUNNEL-FIX-HUMAN-SIGNUP-W1: value-before-email + one-tap sign-in ──
|
|
2596
|
+
// ALL new-signup routes are behind NEW_SIGNUP_ENABLED (default OFF → 404, invisible).
|
|
2597
|
+
// The legacy email-first flow above stays intact. MCP/TG surfaces untouched.
|
|
2598
|
+
// Value BEFORE email: mint an ephemeral key + return a real signal, no email required.
|
|
2599
|
+
app.post('/api/start-free', express.json({ limit: '2kb' }), async (req, res) => {
|
|
2600
|
+
const { isNewSignupEnabled } = await import('./lib/auth-providers.js');
|
|
2601
|
+
if (!isNewSignupEnabled())
|
|
2602
|
+
return res.status(404).json({ ok: false, error: 'not_found' });
|
|
2603
|
+
try {
|
|
2604
|
+
const q = req.query;
|
|
2605
|
+
const b = (req.body ?? {});
|
|
2606
|
+
const str = (v) => (typeof v === 'string' && v.length <= 200 ? v : null);
|
|
2607
|
+
const { startFree } = await import('./lib/deferred-signup.js');
|
|
2608
|
+
const result = await startFree({
|
|
2609
|
+
src: str(q.src) ?? str(b.src),
|
|
2610
|
+
ref: str(q.ref) ?? str(b.ref),
|
|
2611
|
+
utm_source: str(q.utm_source) ?? str(b.utm_source),
|
|
2612
|
+
utm_campaign: str(q.utm_campaign) ?? str(b.utm_campaign),
|
|
2613
|
+
landing_path: str(q.landing_path),
|
|
2614
|
+
});
|
|
2615
|
+
res.setHeader('Cache-Control', 'no-store');
|
|
2616
|
+
return res.status(200).json({ ok: true, ...result });
|
|
2617
|
+
}
|
|
2618
|
+
catch (err) {
|
|
2619
|
+
console.error(`[/api/start-free] internal error: ${err instanceof Error ? err.message : err}`);
|
|
2620
|
+
return res.status(500).json({ ok: false, error: 'internal_error' });
|
|
2621
|
+
}
|
|
2622
|
+
});
|
|
2623
|
+
// One-tap OAuth start: redirect to the IdP (or the Stub loopback) with a CSRF state cookie.
|
|
2624
|
+
app.get('/auth/:provider', async (req, res) => {
|
|
2625
|
+
const { isNewSignupEnabled, getAuthProvider, generateOAuthState, safeRedirectPath } = await import('./lib/auth-providers.js');
|
|
2626
|
+
if (!isNewSignupEnabled())
|
|
2627
|
+
return res.status(404).send('Not found');
|
|
2628
|
+
const id = req.params.provider;
|
|
2629
|
+
if (id !== 'google' && id !== 'github')
|
|
2630
|
+
return res.status(404).send('Unknown provider');
|
|
2631
|
+
try {
|
|
2632
|
+
const provider = getAuthProvider(id);
|
|
2633
|
+
const state = generateOAuthState();
|
|
2634
|
+
const next = safeRedirectPath(req.query.next);
|
|
2635
|
+
const redirectUri = `https://${req.get('host')}/auth/${id}/callback`;
|
|
2636
|
+
const secure = req.secure || req.get('x-forwarded-proto') === 'https';
|
|
2637
|
+
// Short-lived, HttpOnly CSRF + next cookies (10 min).
|
|
2638
|
+
res.setHeader('Set-Cookie', [
|
|
2639
|
+
`av_oauth_state=${state}; HttpOnly; SameSite=Lax; Path=/auth; Max-Age=600${secure ? '; Secure' : ''}`,
|
|
2640
|
+
`av_oauth_next=${encodeURIComponent(next)}; HttpOnly; SameSite=Lax; Path=/auth; Max-Age=600${secure ? '; Secure' : ''}`,
|
|
2641
|
+
...(typeof req.query.src === 'string' ? [`av_oauth_src=${encodeURIComponent(req.query.src.slice(0, 60))}; HttpOnly; SameSite=Lax; Path=/auth; Max-Age=600${secure ? '; Secure' : ''}`] : []),
|
|
2642
|
+
]);
|
|
2643
|
+
return res.redirect(302, provider.authorizeUrl({ state, redirectUri }));
|
|
2644
|
+
}
|
|
2645
|
+
catch (err) {
|
|
2646
|
+
console.error(`[/auth/${id}] internal error: ${err instanceof Error ? err.message : err}`);
|
|
2647
|
+
return res.status(500).send('Sign-in error');
|
|
2648
|
+
}
|
|
2649
|
+
});
|
|
2650
|
+
// OAuth callback: verify state → exchange → issue a free key for the verified email.
|
|
2651
|
+
app.get('/auth/:provider/callback', async (req, res) => {
|
|
2652
|
+
const { isNewSignupEnabled, getAuthProvider, safeRedirectPath } = await import('./lib/auth-providers.js');
|
|
2653
|
+
if (!isNewSignupEnabled())
|
|
2654
|
+
return res.status(404).send('Not found');
|
|
2655
|
+
const id = req.params.provider;
|
|
2656
|
+
if (id !== 'google' && id !== 'github')
|
|
2657
|
+
return res.status(404).send('Unknown provider');
|
|
2658
|
+
try {
|
|
2659
|
+
const cookie = req.headers.cookie ?? '';
|
|
2660
|
+
const readCookie = (n) => {
|
|
2661
|
+
const m = cookie.match(new RegExp(`${n}=([^;]+)`));
|
|
2662
|
+
return m ? decodeURIComponent(m[1]) : null;
|
|
2663
|
+
};
|
|
2664
|
+
const expectState = readCookie('av_oauth_state');
|
|
2665
|
+
const gotState = typeof req.query.state === 'string' ? req.query.state : '';
|
|
2666
|
+
if (!expectState || !gotState || !safeCompare(expectState, gotState)) {
|
|
2667
|
+
return res.status(400).send('Invalid or expired sign-in state. Please try again.');
|
|
2668
|
+
}
|
|
2669
|
+
const code = typeof req.query.code === 'string' ? req.query.code : '';
|
|
2670
|
+
if (!code)
|
|
2671
|
+
return res.status(400).send('Missing authorization code.');
|
|
2672
|
+
const provider = getAuthProvider(id);
|
|
2673
|
+
const redirectUri = `https://${req.get('host')}/auth/${id}/callback`;
|
|
2674
|
+
const profile = await provider.exchange({ code, redirectUri });
|
|
2675
|
+
// Issue (or return the existing) free key for the verified email — email = identity.
|
|
2676
|
+
const { mintFreeKey } = await import('./lib/free-keys-store.js');
|
|
2677
|
+
const { ensureUserCode } = await import('./lib/referral-store.js');
|
|
2678
|
+
const { shareLink } = await import('./lib/referral-constants.js');
|
|
2679
|
+
const key = await mintFreeKey(profile.email);
|
|
2680
|
+
const referralCode = await ensureUserCode(key, profile.email);
|
|
2681
|
+
const referralLink = shareLink(referralCode);
|
|
2682
|
+
// Attribution first-touch survives the redirect: stamp ?src (cookie) against the key.
|
|
2683
|
+
try {
|
|
2684
|
+
const src = readCookie('av_oauth_src');
|
|
2685
|
+
const { recordSignupAttribution } = await import('./lib/subscriber-attribution.js');
|
|
2686
|
+
recordSignupAttribution({ clientReferenceId: key, utmSource: src, tierRequested: 'free' });
|
|
2687
|
+
}
|
|
2688
|
+
catch { /* best-effort */ }
|
|
2689
|
+
// Clear the CSRF cookies.
|
|
2690
|
+
res.setHeader('Set-Cookie', [
|
|
2691
|
+
'av_oauth_state=; HttpOnly; SameSite=Lax; Path=/auth; Max-Age=0',
|
|
2692
|
+
'av_oauth_next=; HttpOnly; SameSite=Lax; Path=/auth; Max-Age=0',
|
|
2693
|
+
'av_oauth_src=; HttpOnly; SameSite=Lax; Path=/auth; Max-Age=0',
|
|
2694
|
+
]);
|
|
2695
|
+
res.setHeader('Content-Type', 'text/html; charset=utf-8');
|
|
2696
|
+
const stubNote = provider.live ? '' : ' <em>(stub — set the provider OAuth creds to go live)</em>';
|
|
2697
|
+
return res.send(`<!doctype html><meta charset="utf-8"><title>You're in — AlgoVault</title>` +
|
|
2698
|
+
`<body style="font-family:system-ui;background:#0d1117;color:#c9d1d9;max-width:560px;margin:60px auto;padding:0 20px">` +
|
|
2699
|
+
`<h1 style="color:#56d364">You're in via ${id}${stubNote}</h1>` +
|
|
2700
|
+
`<p>Your free API key (100 calls/mo, no card):</p>` +
|
|
2701
|
+
`<pre style="background:#161b22;border:1px solid #30363d;border-radius:8px;padding:12px;user-select:all">${key}</pre>` +
|
|
2702
|
+
`<p>Referral link: <a style="color:#58a6ff" href="${referralLink}">${referralLink}</a></p>` +
|
|
2703
|
+
`<p style="color:#8b949e;font-size:13px">Use it as <code>Authorization: Bearer <key></code>. <a style="color:#58a6ff" href="/account">Manage your account →</a></p></body>`);
|
|
2704
|
+
}
|
|
2705
|
+
catch (err) {
|
|
2706
|
+
console.error(`[/auth/${id}/callback] internal error: ${err instanceof Error ? err.message : err}`);
|
|
2707
|
+
return res.status(500).send('Sign-in error. Please try again.');
|
|
2708
|
+
}
|
|
2709
|
+
});
|
|
2482
2710
|
// ── AV-CHAT-MCP-W1 (C3, 2026-05-18): /api/chat HTTP endpoint ──
|
|
2483
2711
|
// LLM-synthesized answer with citations. Quota tracked separately from
|
|
2484
2712
|
// tool quotas via ChatRateLimit + chat_usage_monthly table. Falls back
|
|
@@ -2794,9 +3022,19 @@ async function startHttp() {
|
|
|
2794
3022
|
req.body.method === 'tools/list') {
|
|
2795
3023
|
(0, tools_list_event_js_1.recordMcpToolsListEvent)({ sessionId, licenseTier: license.tier, identityTier });
|
|
2796
3024
|
}
|
|
3025
|
+
// FUNNEL-FIX-ATTRIBUTION-W1: resolve the classified acquisition source ONCE here (request
|
|
3026
|
+
// headers in scope) and thread it via the ALS to the agent_sessions first-touch stamp.
|
|
3027
|
+
// Additive — resolveSessionIdentity + the stateless resolver are untouched.
|
|
3028
|
+
const attributionSource = (0, attribution_sources_js_1.classifySource)({
|
|
3029
|
+
srcParam: req.query?.src,
|
|
3030
|
+
utmSource: req.query?.utm_source, // OPS-UTM-SHORTEN-W1: legacy backward-compat fallback (behind ?src)
|
|
3031
|
+
userAgent: req.headers['user-agent'],
|
|
3032
|
+
origin: req.headers['origin'],
|
|
3033
|
+
referer: req.headers['referer'],
|
|
3034
|
+
}).source;
|
|
2797
3035
|
// Run the entire request handling inside AsyncLocalStorage context
|
|
2798
3036
|
// so tool handlers read the correct per-request license
|
|
2799
|
-
await license_js_1.requestContext.run({ license, sessionId, ipHash, isAutomated: requestAuthenticity.is_automated }, async () => {
|
|
3037
|
+
await license_js_1.requestContext.run({ license, sessionId, ipHash, isAutomated: requestAuthenticity.is_automated, source: attributionSource }, async () => {
|
|
2800
3038
|
try {
|
|
2801
3039
|
const sessionId = req.headers['mcp-session-id'];
|
|
2802
3040
|
// OPS-X402-MCP-PRICE-BINDING-W1: an x402 proof was presented for a priced
|
|
@@ -3363,7 +3601,7 @@ tailwind.config = {
|
|
|
3363
3601
|
</head>
|
|
3364
3602
|
<body>
|
|
3365
3603
|
<!-- LANDING-MOBILE-NAV-FUNCTION-RENDERED-W1: canonical Nav via shared renderSiteNav() (src/lib/site-nav.ts) — desktop byte-identical to the prior inline nav (Track Record active) + mobile hamburger/#mobile-menu panel/controller. -->
|
|
3366
|
-
${(0, site_nav_js_1.renderSiteNav)(
|
|
3604
|
+
${(0, site_nav_js_1.renderSiteNav)()}
|
|
3367
3605
|
<!-- DESIGN-W11 / C2 / Q-W11-3: canonical artboard wrapper OPEN (max-width:1400px preserves dashboard layout; 80px top padding clears 56px fixed Nav + breathing). Foreground content stacks above 3 bg-* layers via position:relative;z-index:1. -->
|
|
3368
3606
|
<main class="lp-track-record">
|
|
3369
3607
|
<div class="artboard" style="padding:80px 24px 64px;max-width:1400px;margin:0 auto;width:100%">
|