@blockrun/clawrouter 0.12.88 → 0.12.90

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/dist/index.js CHANGED
@@ -51839,6 +51839,21 @@ function detectDegradedSuccessResponse(body) {
51839
51839
  if (errorText && PROVIDER_ERROR_PATTERNS.some((pattern) => pattern.test(errorText))) {
51840
51840
  return `degraded response: ${errorText.slice(0, 120)}`;
51841
51841
  }
51842
+ const choices = parsed.choices;
51843
+ if (Array.isArray(choices) && choices.length > 0) {
51844
+ const choice = choices[0];
51845
+ const msg = choice.message ?? choice.delta;
51846
+ if (msg) {
51847
+ const content = msg.content;
51848
+ const toolCalls = msg.tool_calls;
51849
+ const hasContent = typeof content === "string" && content.trim().length > 0;
51850
+ const hasToolCalls = Array.isArray(toolCalls) && toolCalls.length > 0;
51851
+ const finishReason = choice.finish_reason;
51852
+ if (!hasContent && !hasToolCalls && finishReason === "stop") {
51853
+ return "degraded response: empty turn (no content or tool calls)";
51854
+ }
51855
+ }
51856
+ }
51842
51857
  const assistantContent = extractAssistantContent(parsed);
51843
51858
  if (!assistantContent) return void 0;
51844
51859
  if (DEGRADED_RESPONSE_PATTERNS.some((pattern) => pattern.test(assistantContent))) {
@@ -54630,6 +54645,195 @@ var PARTNER_SERVICES = [
54630
54645
  input: { usernames: ["elonmusk", "naval", "balaboris"] },
54631
54646
  description: "Look up 3 Twitter/X user profiles"
54632
54647
  }
54648
+ },
54649
+ // ---------------------------------------------------------------------------
54650
+ // Predexon — Prediction Market Data
54651
+ // ---------------------------------------------------------------------------
54652
+ {
54653
+ id: "predexon_events",
54654
+ name: "Polymarket Events",
54655
+ partner: "Predexon",
54656
+ description: "Get live Polymarket prediction market events with current odds, volume, and liquidity. Call this for ANY request about prediction markets, Polymarket markets, current odds, what people are betting on, or market sentiment. Do NOT use browser or web scraping \u2014 this returns structured real-time data directly. Returns: event title, YES/NO prices (implied probability), volume, liquidity, end date.",
54657
+ proxyPath: "/pm/polymarket/events",
54658
+ method: "GET",
54659
+ params: [
54660
+ {
54661
+ name: "limit",
54662
+ type: "number",
54663
+ description: "Number of events to return (default: 20, max: 100)",
54664
+ required: false
54665
+ },
54666
+ {
54667
+ name: "tag",
54668
+ type: "string",
54669
+ description: "Filter by category: crypto, politics, sports, science, economics, etc.",
54670
+ required: false
54671
+ }
54672
+ ],
54673
+ pricing: { perUnit: "$0.001", unit: "request", minimum: "$0.001", maximum: "$0.001" },
54674
+ example: {
54675
+ input: { limit: 20 },
54676
+ description: "Get top 20 live Polymarket events"
54677
+ }
54678
+ },
54679
+ {
54680
+ id: "predexon_leaderboard",
54681
+ name: "Polymarket Leaderboard",
54682
+ partner: "Predexon",
54683
+ description: "Get the Polymarket leaderboard of top traders ranked by profit. Call this for ANY request about top Polymarket traders, whale wallets, best performers, richest traders, or who is making the most money on Polymarket. Do NOT use browser or web scraping \u2014 this returns structured data directly. Returns: wallet address/username, total profit, total volume, win rate.",
54684
+ proxyPath: "/pm/polymarket/leaderboard",
54685
+ method: "GET",
54686
+ params: [
54687
+ {
54688
+ name: "limit",
54689
+ type: "number",
54690
+ description: "Number of wallets to return (default: 20, max: 100)",
54691
+ required: false
54692
+ }
54693
+ ],
54694
+ pricing: { perUnit: "$0.001", unit: "request", minimum: "$0.001", maximum: "$0.001" },
54695
+ example: {
54696
+ input: { limit: 20 },
54697
+ description: "Get top 20 Polymarket whale wallets by profit"
54698
+ }
54699
+ },
54700
+ {
54701
+ id: "predexon_markets",
54702
+ name: "Polymarket Markets Search",
54703
+ partner: "Predexon",
54704
+ description: "Search and filter Polymarket markets. Use this to find a market by keyword and get its conditionId for follow-up calls (smart money, top holders, etc.). Returns: question, conditionId, YES/NO prices, volume.",
54705
+ proxyPath: "/pm/polymarket/markets",
54706
+ method: "GET",
54707
+ params: [
54708
+ {
54709
+ name: "search",
54710
+ type: "string",
54711
+ description: "Keyword to search for (e.g. 'bitcoin', 'election', 'fed rate')",
54712
+ required: false
54713
+ },
54714
+ {
54715
+ name: "limit",
54716
+ type: "number",
54717
+ description: "Number of markets to return (default: 20)",
54718
+ required: false
54719
+ }
54720
+ ],
54721
+ pricing: { perUnit: "$0.001", unit: "request", minimum: "$0.001", maximum: "$0.001" },
54722
+ example: {
54723
+ input: { search: "bitcoin", limit: 10 },
54724
+ description: "Search for Bitcoin-related prediction markets"
54725
+ }
54726
+ },
54727
+ {
54728
+ id: "predexon_smart_money",
54729
+ name: "Polymarket Smart Money",
54730
+ partner: "Predexon",
54731
+ description: "See how high-performing wallets are positioned on a specific Polymarket market. Use this after finding a market's conditionId via predexon_markets or predexon_events. Returns: wallet addresses, their YES/NO positions, size, P&L, win rate.",
54732
+ proxyPath: "/pm/polymarket/market/:condition_id/smart-money",
54733
+ method: "GET",
54734
+ params: [
54735
+ {
54736
+ name: "condition_id",
54737
+ type: "string",
54738
+ description: "The market's conditionId (get this from predexon_markets or predexon_events)",
54739
+ required: true
54740
+ },
54741
+ {
54742
+ name: "limit",
54743
+ type: "number",
54744
+ description: "Number of positions to return (default: 20)",
54745
+ required: false
54746
+ }
54747
+ ],
54748
+ pricing: { perUnit: "$0.005", unit: "request", minimum: "$0.005", maximum: "$0.005" },
54749
+ example: {
54750
+ input: { condition_id: "0xabc123...", limit: 10 },
54751
+ description: "See smart money positioning on a specific market"
54752
+ }
54753
+ },
54754
+ {
54755
+ id: "predexon_smart_activity",
54756
+ name: "Polymarket Smart Activity",
54757
+ partner: "Predexon",
54758
+ description: "Discover which Polymarket markets high-performing wallets are currently active in. Use this to find where smart money is flowing right now. Returns: market titles, smart money volume, number of smart wallets active.",
54759
+ proxyPath: "/pm/polymarket/markets/smart-activity",
54760
+ method: "GET",
54761
+ params: [
54762
+ {
54763
+ name: "limit",
54764
+ type: "number",
54765
+ description: "Number of markets to return (default: 20)",
54766
+ required: false
54767
+ }
54768
+ ],
54769
+ pricing: { perUnit: "$0.005", unit: "request", minimum: "$0.005", maximum: "$0.005" },
54770
+ example: {
54771
+ input: { limit: 10 },
54772
+ description: "Find markets where smart money is most active"
54773
+ }
54774
+ },
54775
+ {
54776
+ id: "predexon_wallet",
54777
+ name: "Polymarket Wallet Profile",
54778
+ partner: "Predexon",
54779
+ description: "Get a complete profile for a Polymarket wallet address: profit, volume, win rate, markets traded, open positions. Use this when the user asks to analyze or look up a specific wallet address.",
54780
+ proxyPath: "/pm/polymarket/wallet/:wallet",
54781
+ method: "GET",
54782
+ params: [
54783
+ {
54784
+ name: "wallet",
54785
+ type: "string",
54786
+ description: "Ethereum wallet address (0x...)",
54787
+ required: true
54788
+ }
54789
+ ],
54790
+ pricing: { perUnit: "$0.005", unit: "request", minimum: "$0.005", maximum: "$0.005" },
54791
+ example: {
54792
+ input: { wallet: "0x1234...abcd" },
54793
+ description: "Get complete profile for a Polymarket wallet"
54794
+ }
54795
+ },
54796
+ {
54797
+ id: "predexon_wallet_pnl",
54798
+ name: "Polymarket Wallet P&L",
54799
+ partner: "Predexon",
54800
+ description: "Get P&L history and realized profit/loss time series for a Polymarket wallet. Use this when the user wants to see how a wallet has performed over time.",
54801
+ proxyPath: "/pm/polymarket/wallet/pnl/:wallet",
54802
+ method: "GET",
54803
+ params: [
54804
+ {
54805
+ name: "wallet",
54806
+ type: "string",
54807
+ description: "Ethereum wallet address (0x...)",
54808
+ required: true
54809
+ }
54810
+ ],
54811
+ pricing: { perUnit: "$0.005", unit: "request", minimum: "$0.005", maximum: "$0.005" },
54812
+ example: {
54813
+ input: { wallet: "0x1234...abcd" },
54814
+ description: "Get P&L history for a Polymarket wallet"
54815
+ }
54816
+ },
54817
+ {
54818
+ id: "predexon_matching_markets",
54819
+ name: "Cross-Market Matching (Polymarket vs Kalshi)",
54820
+ partner: "Predexon",
54821
+ description: "Find equivalent markets across Polymarket and Kalshi to compare odds and spot arbitrage. Use this when the user wants to compare prediction market prices across platforms.",
54822
+ proxyPath: "/pm/matching-markets",
54823
+ method: "GET",
54824
+ params: [
54825
+ {
54826
+ name: "limit",
54827
+ type: "number",
54828
+ description: "Number of matched pairs to return (default: 20)",
54829
+ required: false
54830
+ }
54831
+ ],
54832
+ pricing: { perUnit: "$0.005", unit: "request", minimum: "$0.005", maximum: "$0.005" },
54833
+ example: {
54834
+ input: { limit: 10 },
54835
+ description: "Compare equivalent markets on Polymarket vs Kalshi"
54836
+ }
54633
54837
  }
54634
54838
  ];
54635
54839
  function getPartnerService(id) {
@@ -54669,11 +54873,29 @@ function buildTool(service, proxyBaseUrl) {
54669
54873
  required
54670
54874
  },
54671
54875
  execute: async (_toolCallId, params) => {
54672
- const url = `${proxyBaseUrl}/v1${service.proxyPath}`;
54876
+ let path2 = `/v1${service.proxyPath}`;
54877
+ const leftoverParams = {};
54878
+ for (const [key, value] of Object.entries(params)) {
54879
+ if (value === void 0 || value === null) continue;
54880
+ const placeholder = `:${key}`;
54881
+ if (path2.includes(placeholder)) {
54882
+ path2 = path2.replace(placeholder, encodeURIComponent(String(value)));
54883
+ } else {
54884
+ leftoverParams[key] = value;
54885
+ }
54886
+ }
54887
+ let url = `${proxyBaseUrl}${path2}`;
54888
+ if (service.method === "GET" && Object.keys(leftoverParams).length > 0) {
54889
+ const qs = new URLSearchParams();
54890
+ for (const [key, value] of Object.entries(leftoverParams)) {
54891
+ qs.set(key, Array.isArray(value) ? value.join(",") : String(value));
54892
+ }
54893
+ url += `?${qs.toString()}`;
54894
+ }
54673
54895
  const response = await fetch(url, {
54674
54896
  method: service.method,
54675
54897
  headers: { "Content-Type": "application/json" },
54676
- body: JSON.stringify(params)
54898
+ body: service.method === "POST" ? JSON.stringify(params) : void 0
54677
54899
  });
54678
54900
  if (!response.ok) {
54679
54901
  const errText = await response.text().catch(() => "");