x402-omni-oracle 0.1.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.
@@ -0,0 +1,28 @@
1
+ import { streamText } from 'ai';
2
+ import { openai } from '@ai-sdk/openai';
3
+ import {
4
+ getKLAXThermalRisk,
5
+ getCoinGeckoPrice,
6
+ getSwarmPulse
7
+ } from '../src/index';
8
+
9
+ // --- EXAMPLE NEXT.JS ROUTE HANDLER ---
10
+
11
+ export async function POST(req: Request) {
12
+ const { messages } = await req.json() as { messages: any[] };
13
+
14
+ const result = await streamText({
15
+ model: openai('gpt-4-turbo'),
16
+ messages,
17
+ system: `You are an Agentic Assistant. You have access to the Omni-Oracle.
18
+ Prices cost money, so ask the user before spending > 0.10 USDC.`,
19
+ tools: {
20
+ // Register whatever tools you want the agent to use
21
+ getKLAXThermalRisk,
22
+ getCoinGeckoPrice,
23
+ getSwarmPulse
24
+ }
25
+ });
26
+
27
+ return result.toTextStreamResponse();
28
+ }
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "x402-omni-oracle",
3
+ "version": "0.1.0",
4
+ "description": "Agent-First Data Provider. Native tools for Vercel AI SDK.",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "publishConfig": {
8
+ "access": "public"
9
+ },
10
+ "scripts": {
11
+ "build": "tsc"
12
+ },
13
+ "keywords": [
14
+ "ai",
15
+ "agent",
16
+ "vercel",
17
+ "x402",
18
+ "oracle"
19
+ ],
20
+ "author": "Omni-Oracle",
21
+ "license": "MIT",
22
+ "dependencies": {
23
+ "zod": "^3.0.0"
24
+ },
25
+ "peerDependencies": {
26
+ "ai": "^3.0.0 || ^4.0.0"
27
+ },
28
+ "devDependencies": {
29
+ "typescript": "^5.0.0"
30
+ }
31
+ }
package/src/index.ts ADDED
@@ -0,0 +1,1014 @@
1
+ import { tool } from 'ai';
2
+ import { z } from 'zod';
3
+
4
+ // Base URL for Omni-Oracle
5
+ const BASE_URL = 'https://omni-oracle.omnioracle.workers.dev';
6
+
7
+
8
+ async function fetchOracle(path: string, params: Record<string, any> = {}) {
9
+ const url = new URL(`${BASE_URL}${path}`);
10
+
11
+ // Substitute path params
12
+ let finalPath = path;
13
+ const queryParams: Record<string, any> = {};
14
+
15
+ for (const [key, value] of Object.entries(params)) {
16
+ if (finalPath.includes(`{${key}}`)) {
17
+ finalPath = finalPath.replace(`{${key}}`, String(value));
18
+ } else {
19
+ queryParams[key] = value;
20
+ }
21
+ }
22
+
23
+ url.pathname = finalPath;
24
+ for (const [key, value] of Object.entries(queryParams)) {
25
+ if (value !== undefined && value !== null) {
26
+ url.searchParams.append(key, String(value));
27
+ }
28
+ }
29
+
30
+ try {
31
+ const res = await fetch(url.toString());
32
+ if (res.status === 200) {
33
+ return await res.json();
34
+ } else if (res.status === 402) {
35
+ return {
36
+ error: 'PAYMENT_REQUIRED',
37
+ message: 'This endpoint requires payment (USDC/ETH). Please attach X-402-Transaction-Hash header.',
38
+ price: res.headers.get('x-402-price'),
39
+ recipient: res.headers.get('x-402-recipient'),
40
+ endpoint: path
41
+ };
42
+ } else {
43
+ return { error: `HTTP ${res.status}`, message: await res.text() };
44
+ }
45
+ } catch (e: any) {
46
+ return { error: 'CONNECTION_ERROR', message: e.message };
47
+ }
48
+ }
49
+
50
+
51
+ export const getKLAXThermalRisk = tool({
52
+ description: "Aviation weather and thermal risk data for Los Angeles International Airport.",
53
+ parameters: z.object({}),
54
+ execute: async (params) => fetchOracle('/logistics/klax', params)
55
+ });
56
+
57
+ export const getKJFKThermalRisk = tool({
58
+ description: "Aviation weather and thermal risk data for John F. Kennedy International Airport.",
59
+ parameters: z.object({}),
60
+ execute: async (params) => fetchOracle('/logistics/kjfk', params)
61
+ });
62
+
63
+ export const getKMEMThermalRisk = tool({
64
+ description: "Aviation weather for Memphis International (FedEx SuperHub).",
65
+ parameters: z.object({}),
66
+ execute: async (params) => fetchOracle('/logistics/kmem', params)
67
+ });
68
+
69
+ export const getKORDThermalRisk = tool({
70
+ description: "Aviation weather for Chicago O'Hare International Airport.",
71
+ parameters: z.object({}),
72
+ execute: async (params) => fetchOracle('/logistics/kord', params)
73
+ });
74
+
75
+ export const getKIAHThermalRisk = tool({
76
+ description: "Aviation weather for George Bush Intercontinental Airport.",
77
+ parameters: z.object({}),
78
+ execute: async (params) => fetchOracle('/logistics/kiah', params)
79
+ });
80
+
81
+ export const getLHRThermalRisk = tool({
82
+ description: "Aviation weather for London Heathrow. Europe gateway risk.",
83
+ parameters: z.object({}),
84
+ execute: async (params) => fetchOracle('/logistics/lhr', params)
85
+ });
86
+
87
+ export const getHNDThermalRisk = tool({
88
+ description: "Aviation weather for Tokyo Haneda. Asia gateway risk.",
89
+ parameters: z.object({}),
90
+ execute: async (params) => fetchOracle('/logistics/hnd', params)
91
+ });
92
+
93
+ export const getDXBThermalRisk = tool({
94
+ description: "Aviation weather for Dubai Intl. Middle East hub risk.",
95
+ parameters: z.object({}),
96
+ execute: async (params) => fetchOracle('/logistics/dxb', params)
97
+ });
98
+
99
+ export const getHKGThermalRisk = tool({
100
+ description: "Aviation weather for Hong Kong. Global Air Cargo hub.",
101
+ parameters: z.object({}),
102
+ execute: async (params) => fetchOracle('/logistics/hkg', params)
103
+ });
104
+
105
+ export const getFRAThermalRisk = tool({
106
+ description: "Aviation weather for Frankfurt. Europe cargo hub.",
107
+ parameters: z.object({}),
108
+ execute: async (params) => fetchOracle('/logistics/fra', params)
109
+ });
110
+
111
+ export const getGreenComputeWindow = tool({
112
+ description: "Returns a boolean `green_window_active` flag when the US Grid carbon intensity is low (<40%). Use for scheduling AI training jobs and compute workloads.",
113
+ parameters: z.object({}),
114
+ execute: async (params) => fetchOracle('/compute/green-window', params)
115
+ });
116
+
117
+ export const getJupiterQuote = tool({
118
+ description: "Get optimal swap route from Jupiter Aggregator v6 on Solana.",
119
+ parameters: z.object({
120
+ inputMint: z.string().describe("Input token mint address"),
121
+ outputMint: z.string().describe("Output token mint address"),
122
+ amount: z.string().describe("Amount in smallest units"),
123
+ slippageBps: z.number().int().describe("Slippage tolerance in basis points").optional()
124
+ }),
125
+ execute: async (params) => fetchOracle('/finance/jupiter/quote', params)
126
+ });
127
+
128
+ export const getCoinGeckoPrice = tool({
129
+ description: "Real-time USD price from CoinGecko with 24h change and volatility triggers.",
130
+ parameters: z.object({
131
+ id: z.string().describe("CoinGecko token ID")
132
+ }),
133
+ execute: async (params) => fetchOracle('/finance/coingecko/price/{id}', params)
134
+ });
135
+
136
+ export const getCoinGeckoTrending = tool({
137
+ description: "Top 10 trending tokens on CoinGecko.",
138
+ parameters: z.object({}),
139
+ execute: async (params) => fetchOracle('/finance/coingecko/trending', params)
140
+ });
141
+
142
+ export const getGlobalMarketStats = tool({
143
+ description: "Total market cap, volume, and BTC/ETH dominance.",
144
+ parameters: z.object({}),
145
+ execute: async (params) => fetchOracle('/finance/coingecko/global', params)
146
+ });
147
+
148
+ export const getFREDSeries = tool({
149
+ description: "Economic indicator data from St. Louis Fed (CPI, GDP, Fed Funds Rate, etc.).",
150
+ parameters: z.object({
151
+ id: z.string().describe("FRED series ID")
152
+ }),
153
+ execute: async (params) => fetchOracle('/finance/fred/series/{id}', params)
154
+ });
155
+
156
+ export const getPopularEconomicIndicators = tool({
157
+ description: "List of commonly used FRED series with descriptions.",
158
+ parameters: z.object({}),
159
+ execute: async (params) => fetchOracle('/finance/fred/popular', params)
160
+ });
161
+
162
+ export const getDexScreenerPairs = tool({
163
+ description: "Real-time price, volume, and liquidity data for token pairs from DexScreener.",
164
+ parameters: z.object({
165
+ chainId: z.string().describe(""),
166
+ addresses: z.string().describe("Comma-separated token addresses")
167
+ }),
168
+ execute: async (params) => fetchOracle('/market/dexscreener/token-pairs/{chainId}/{addresses}', params)
169
+ });
170
+
171
+ export const getProtocolTVL = tool({
172
+ description: "Total Value Locked and protocol details from DeFiLlama.",
173
+ parameters: z.object({
174
+ protocol: z.string().describe("")
175
+ }),
176
+ execute: async (params) => fetchOracle('/analytics/defillama/tvl/{protocol}', params)
177
+ });
178
+
179
+ export const getTopStablecoins = tool({
180
+ description: "Top 5 stablecoins by market cap with peg status.",
181
+ parameters: z.object({}),
182
+ execute: async (params) => fetchOracle('/analytics/defillama/stablecoins', params)
183
+ });
184
+
185
+ export const get3Stats = tool({
186
+ description: "Protocol statistics from Uniswap V3 Ethereum subgraph.",
187
+ parameters: z.object({}),
188
+ execute: async (params) => fetchOracle('/analytics/thegraph/uniswap/stats', params)
189
+ });
190
+
191
+ export const getAaveV3Stats = tool({
192
+ description: "Protocol statistics from Aave V3 Ethereum subgraph.",
193
+ parameters: z.object({}),
194
+ execute: async (params) => fetchOracle('/analytics/thegraph/aave/stats', params)
195
+ });
196
+
197
+ export const getBitcoinFees = tool({
198
+ description: "Real-time recommended fees (sat/vB) from Mempool.space.",
199
+ parameters: z.object({}),
200
+ execute: async (params) => fetchOracle('/crypto/btc/fees', params)
201
+ });
202
+
203
+ export const getBitcoinBlockStatus = tool({
204
+ description: "Latest block height from Mempool.space.",
205
+ parameters: z.object({}),
206
+ execute: async (params) => fetchOracle('/crypto/btc/block-status', params)
207
+ });
208
+
209
+ export const getEthereumGas = tool({
210
+ description: "Real-time Gas (Wei) from Beaconcha.in.",
211
+ parameters: z.object({}),
212
+ execute: async (params) => fetchOracle('/crypto/eth/gas-forecast', params)
213
+ });
214
+
215
+ export const getChainlinkPrice = tool({
216
+ description: "On-chain price from Chainlink aggregator on Base. Available pairs: ETH/USD, BTC/USD, USDC/USD, DAI/USD, LINK/USD.",
217
+ parameters: z.object({
218
+ pair: z.string().describe("")
219
+ }),
220
+ execute: async (params) => fetchOracle('/crypto/chainlink/price/{pair}', params)
221
+ });
222
+
223
+ export const getSeismicAlerts = tool({
224
+ description: "List of recent significant seismic events from USGS.",
225
+ parameters: z.object({}),
226
+ execute: async (params) => fetchOracle('/risk/seismic/recent', params)
227
+ });
228
+
229
+ export const getSolarStormAlert = tool({
230
+ description: "Boolean `storm_active` flag for G/S/R scale events from NOAA.",
231
+ parameters: z.object({}),
232
+ execute: async (params) => fetchOracle('/risk/solar/storm-alert', params)
233
+ });
234
+
235
+ export const getMarketCrashProbability = tool({
236
+ description: "Composite risk score (0-100) aggregating VIX, Fear&Greed, BTC Fees. High value Alpha signal.",
237
+ parameters: z.object({}),
238
+ execute: async (params) => fetchOracle('/risk/market-crash-probability', params)
239
+ });
240
+
241
+ export const getHackerNewsTopStories = tool({
242
+ description: "Top 10 trending stories from HackerNews.",
243
+ parameters: z.object({}),
244
+ execute: async (params) => fetchOracle('/sentiment/hn/top-stories', params)
245
+ });
246
+
247
+ export const searchHackerNews = tool({
248
+ description: "Search HackerNews stories by keyword.",
249
+ parameters: z.object({
250
+ query: z.string().describe("")
251
+ }),
252
+ execute: async (params) => fetchOracle('/sentiment/hn/keyword/{query}', params)
253
+ });
254
+
255
+ export const getDailyAIPapers = tool({
256
+ description: "Latest AI/ML papers from ArXiv (cs.AI + cs.LG).",
257
+ parameters: z.object({}),
258
+ execute: async (params) => fetchOracle('/sentiment/arxiv/daily/ai', params)
259
+ });
260
+
261
+ export const searchArXiv = tool({
262
+ description: "Search ArXiv papers by keyword.",
263
+ parameters: z.object({
264
+ q: z.string().describe("")
265
+ }),
266
+ execute: async (params) => fetchOracle('/sentiment/arxiv/search', params)
267
+ });
268
+
269
+ export const getFearGreedIndex = tool({
270
+ description: "Current crypto Fear & Greed Index with extreme_fear/extreme_greed triggers.",
271
+ parameters: z.object({}),
272
+ execute: async (params) => fetchOracle('/sentiment/feargreed/index', params)
273
+ });
274
+
275
+ export const getFearGreedHistory = tool({
276
+ description: "30-day historical Fear & Greed Index with trend analysis.",
277
+ parameters: z.object({}),
278
+ execute: async (params) => fetchOracle('/sentiment/feargreed/history', params)
279
+ });
280
+
281
+ export const getMarketHeadlines = tool({
282
+ description: "Latest market news headlines. Requires POLYGON_API_KEY.",
283
+ parameters: z.object({}),
284
+ execute: async (params) => fetchOracle('/sentiment/news/headlines', params)
285
+ });
286
+
287
+ export const getTickerNews = tool({
288
+ description: "News for specific ticker with sentiment analysis. Requires POLYGON_API_KEY.",
289
+ parameters: z.object({
290
+ symbol: z.string().describe("")
291
+ }),
292
+ execute: async (params) => fetchOracle('/sentiment/news/ticker/{symbol}', params)
293
+ });
294
+
295
+ export const getIPGeolocation = tool({
296
+ description: "Geographic location data for an IP address.",
297
+ parameters: z.object({
298
+ address: z.string().describe("")
299
+ }),
300
+ execute: async (params) => fetchOracle('/network/ip/{address}', params)
301
+ });
302
+
303
+ export const checkSSLCertificate = tool({
304
+ description: "Validate SSL certificate for a domain.",
305
+ parameters: z.object({
306
+ domain: z.string().describe("")
307
+ }),
308
+ execute: async (params) => fetchOracle('/network/ssl-check', params)
309
+ });
310
+
311
+ export const convertHtmlToMarkdown = tool({
312
+ description: "Convert any URL to clean Markdown for easier agent consumption.",
313
+ parameters: z.object({
314
+ url: z.string().describe("")
315
+ }),
316
+ execute: async (params) => fetchOracle('/utility/html-to-markdown', params)
317
+ });
318
+
319
+ export const resolveDNS = tool({
320
+ description: "Resolve DNS records securely via Cloudflare DoH.",
321
+ parameters: z.object({
322
+ domain: z.string().describe(""),
323
+ type: z.string().describe("").optional()
324
+ }),
325
+ execute: async (params) => fetchOracle('/utility/dns-lookup', params)
326
+ });
327
+
328
+ export const validateJSON = tool({
329
+ description: "Validate strict JSON syntax. Returns boolean valid/invalid.",
330
+ parameters: z.object({}),
331
+ execute: async (params) => fetchOracle('/utility/json-validator', params)
332
+ });
333
+
334
+ export const convertRSStoJSON = tool({
335
+ description: "Convert any RSS/Atom XML feed into structured JSON.",
336
+ parameters: z.object({
337
+ url: z.string().describe("")
338
+ }),
339
+ execute: async (params) => fetchOracle('/utility/rss-to-json', params)
340
+ });
341
+
342
+ export const getSignedTimestamp = tool({
343
+ description: "Cryptographically signed timestamp for trusted time synchronization.",
344
+ parameters: z.object({}),
345
+ execute: async (params) => fetchOracle('/utility/timestamp', params)
346
+ });
347
+
348
+ export const convertUnits = tool({
349
+ description: "Convert units (c/f, kg/lbs, km/mi, eth/wei).",
350
+ parameters: z.object({
351
+ value: z.number().describe(""),
352
+ from: z.string().describe(""),
353
+ to: z.string().describe("")
354
+ }),
355
+ execute: async (params) => fetchOracle('/utility/unit-converter', params)
356
+ });
357
+
358
+ export const whoami = tool({
359
+ description: "Echoes back the caller identity, IP, and headers as seen by the Oracle, signed.",
360
+ parameters: z.object({}),
361
+ execute: async (params) => fetchOracle('/identity/whoami', params)
362
+ });
363
+
364
+ export const getReputationScore = tool({
365
+ description: "Get the credit score of an agent based on their on-chain payment history to this Oracle.",
366
+ parameters: z.object({
367
+ address: z.string().describe("")
368
+ }),
369
+ execute: async (params) => fetchOracle('/identity/score/{address}', params)
370
+ });
371
+
372
+ export const getSwarmPulse = tool({
373
+ description: "Real-time aggregated attention metrics from the agent swarm. 'Where are agents looking right now?'",
374
+ parameters: z.object({}),
375
+ execute: async (params) => fetchOracle('/meta/pulse', params)
376
+ });
377
+
378
+ export const getSwarmSentiment = tool({
379
+ description: "Crowd-sourced sentiment derived from the ratio of Risk queries vs Finance queries.",
380
+ parameters: z.object({}),
381
+ execute: async (params) => fetchOracle('/meta/sentiment', params)
382
+ });
383
+
384
+ export const getTokenMetadata = tool({
385
+ description: "Get logo, website, and socials for any token.",
386
+ parameters: z.object({
387
+ address: z.string().describe("")
388
+ }),
389
+ execute: async (params) => fetchOracle('/token/metadata/{address}', params)
390
+ });
391
+
392
+ export const getWhaleMovements = tool({
393
+ description: "Large transfers (> $1M) detected in the last hour.",
394
+ parameters: z.object({}),
395
+ execute: async (params) => fetchOracle('/whale/recent', params)
396
+ });
397
+
398
+ export const resolveENS = tool({
399
+ description: "Resolve ENS name to address and vice versa.",
400
+ parameters: z.object({
401
+ name: z.string().describe("")
402
+ }),
403
+ execute: async (params) => fetchOracle('/ens/resolve/{name}', params)
404
+ });
405
+
406
+ export const getBlockData = tool({
407
+ description: "Get block details by height or 'latest'.",
408
+ parameters: z.object({
409
+ height: z.string().describe("")
410
+ }),
411
+ execute: async (params) => fetchOracle('/chain/block/{height}', params)
412
+ });
413
+
414
+ export const checkAirdropEligibility = tool({
415
+ description: "Check eligibility for known active airdrops.",
416
+ parameters: z.object({
417
+ address: z.string().describe("")
418
+ }),
419
+ execute: async (params) => fetchOracle('/airdrop/check/{address}', params)
420
+ });
421
+
422
+ export const getTradePreflight = tool({
423
+ description: "BUNDLE: Gas + slippage + risk check before executing a swap.",
424
+ parameters: z.object({
425
+ token: z.string().describe("")
426
+ }),
427
+ execute: async (params) => fetchOracle('/preflight/trade', params)
428
+ });
429
+
430
+ export const getWalletValues = tool({
431
+ description: "BUNDLE: Portfolio balance across chains.",
432
+ parameters: z.object({
433
+ address: z.string().describe("")
434
+ }),
435
+ execute: async (params) => fetchOracle('/preflight/wallet', params)
436
+ });
437
+
438
+ export const getDeFiDashboard = tool({
439
+ description: "BUNDLE: Top yields, L2 TVL, and stablecoin health.",
440
+ parameters: z.object({}),
441
+ execute: async (params) => fetchOracle('/dashboard/defi', params)
442
+ });
443
+
444
+ export const getMarketDashboard = tool({
445
+ description: "BUNDLE: Fear/Greed, trending tokens, and BTC dominance.",
446
+ parameters: z.object({}),
447
+ execute: async (params) => fetchOracle('/dashboard/market', params)
448
+ });
449
+
450
+ export const getBatchPrices = tool({
451
+ description: "Get prices for multiple tokens in one call.",
452
+ parameters: z.object({
453
+ tokens: z.string().describe("Comma separated addresses")
454
+ }),
455
+ execute: async (params) => fetchOracle('/price/batch', params)
456
+ });
457
+
458
+ export const getStablecoinYields = tool({
459
+ description: "Top APY/APR for stablecoins across lending protocols.",
460
+ parameters: z.object({}),
461
+ execute: async (params) => fetchOracle('/apy/stablecoin', params)
462
+ });
463
+
464
+ export const getDAOTreasuries = tool({
465
+ description: "Top DAO treasury balances and holdings.",
466
+ parameters: z.object({}),
467
+ execute: async (params) => fetchOracle('/dao/treasuries', params)
468
+ });
469
+
470
+ export const getX402BazaarCatalog = tool({
471
+ description: "Agent discovery metadata with full service catalog and pricing.",
472
+ parameters: z.object({}),
473
+ execute: async (params) => fetchOracle('/.well-known/x402-bazaar', params)
474
+ });
475
+
476
+ export const getOpenAPISpec = tool({
477
+ description: "This OpenAPI 3.1 specification.",
478
+ parameters: z.object({}),
479
+ execute: async (params) => fetchOracle('/doc', params)
480
+ });
481
+
482
+ export const getMarketRegime = tool({
483
+ description: "SYNTHETIC: Composite market state (Risk-On/Off/Euphoria/Capitulation). Aggregates Fear&Greed, BTC mempool, stablecoin pegs.",
484
+ parameters: z.object({}),
485
+ execute: async (params) => fetchOracle('/alpha/market-regime', params)
486
+ });
487
+
488
+ export const getWhaleMomentum = tool({
489
+ description: "SYNTHETIC: Aggregated large transaction patterns. Are whales accumulating or distributing?",
490
+ parameters: z.object({}),
491
+ execute: async (params) => fetchOracle('/alpha/whale-momentum', params)
492
+ });
493
+
494
+ export const getSentimentDivergence = tool({
495
+ description: "SYNTHETIC: News sentiment vs price action divergence. Contrarian trading signals.",
496
+ parameters: z.object({}),
497
+ execute: async (params) => fetchOracle('/alpha/sentiment-divergence', params)
498
+ });
499
+
500
+ export const getRiskAdjustedYield = tool({
501
+ description: "SYNTHETIC: DeFi yields weighted by TVL risk and IL exposure. Best risk-adjusted returns.",
502
+ parameters: z.object({}),
503
+ execute: async (params) => fetchOracle('/alpha/risk-adjusted-yield', params)
504
+ });
505
+
506
+ export const getTrendingQueries = tool({
507
+ description: "UNIQUE: Real-time view of what agents are querying most. Derived from live traffic.",
508
+ parameters: z.object({}),
509
+ execute: async (params) => fetchOracle('/meta/trending-queries', params)
510
+ });
511
+
512
+ export const getSectorRotation = tool({
513
+ description: "UNIQUE: Track volume shifts between categories over 24h. Detect agent pivots.",
514
+ parameters: z.object({}),
515
+ execute: async (params) => fetchOracle('/meta/sector-rotation', params)
516
+ });
517
+
518
+ export const getAnomalyAlert = tool({
519
+ description: "UNIQUE: Unusual agent behavior pattern detection. Volume spikes and drops.",
520
+ parameters: z.object({}),
521
+ execute: async (params) => fetchOracle('/meta/anomaly-alert', params)
522
+ });
523
+
524
+ export const getSwarmConsensus = tool({
525
+ description: "UNIQUE: Network-wide bull/bear ratio from actual agent query patterns.",
526
+ parameters: z.object({}),
527
+ execute: async (params) => fetchOracle('/meta/consensus', params)
528
+ });
529
+
530
+ export const getSINThermalRisk = tool({
531
+ description: "NOAA Aviation Weather for Singapore Changi. Asia-Pacific hub.",
532
+ parameters: z.object({}),
533
+ execute: async (params) => fetchOracle('/logistics/sin', params)
534
+ });
535
+
536
+ export const getPEKThermalRisk = tool({
537
+ description: "NOAA Aviation Weather for Beijing Capital. China gateway.",
538
+ parameters: z.object({}),
539
+ execute: async (params) => fetchOracle('/logistics/pek', params)
540
+ });
541
+
542
+ export const getCDGThermalRisk = tool({
543
+ description: "NOAA Aviation Weather for Paris Charles de Gaulle.",
544
+ parameters: z.object({}),
545
+ execute: async (params) => fetchOracle('/logistics/cdg', params)
546
+ });
547
+
548
+ export const getAMSThermalRisk = tool({
549
+ description: "NOAA Aviation Weather for Amsterdam Schiphol.",
550
+ parameters: z.object({}),
551
+ execute: async (params) => fetchOracle('/logistics/ams', params)
552
+ });
553
+
554
+ export const getICNThermalRisk = tool({
555
+ description: "NOAA Aviation Weather for Seoul Incheon.",
556
+ parameters: z.object({}),
557
+ execute: async (params) => fetchOracle('/logistics/icn', params)
558
+ });
559
+
560
+ export const getSYDThermalRisk = tool({
561
+ description: "NOAA Aviation Weather for Sydney Kingsford Smith.",
562
+ parameters: z.object({}),
563
+ execute: async (params) => fetchOracle('/logistics/syd', params)
564
+ });
565
+
566
+ export const getGRUThermalRisk = tool({
567
+ description: "NOAA Aviation Weather for São Paulo Guarulhos.",
568
+ parameters: z.object({}),
569
+ execute: async (params) => fetchOracle('/logistics/gru', params)
570
+ });
571
+
572
+ export const getBOMThermalRisk = tool({
573
+ description: "NOAA Aviation Weather for Mumbai Chhatrapati Shivaji.",
574
+ parameters: z.object({}),
575
+ execute: async (params) => fetchOracle('/logistics/bom', params)
576
+ });
577
+
578
+ export const getJNBThermalRisk = tool({
579
+ description: "NOAA Aviation Weather for Johannesburg O.R. Tambo.",
580
+ parameters: z.object({}),
581
+ execute: async (params) => fetchOracle('/logistics/jnb', params)
582
+ });
583
+
584
+ export const getMEXThermalRisk = tool({
585
+ description: "NOAA Aviation Weather for Mexico City International.",
586
+ parameters: z.object({}),
587
+ execute: async (params) => fetchOracle('/logistics/mex', params)
588
+ });
589
+
590
+ export const getMarketHours = tool({
591
+ description: "Check if NYSE, NASDAQ, or crypto markets are currently open.",
592
+ parameters: z.object({
593
+ market: z.string().describe("Market: nyse, nasdaq, crypto").optional()
594
+ }),
595
+ execute: async (params) => fetchOracle('/utility/market-hours', params)
596
+ });
597
+
598
+ export const convertTimezone = tool({
599
+ description: "Convert time between timezones.",
600
+ parameters: z.object({
601
+ time: z.string().describe("ISO 8601 time string"),
602
+ from: z.string().describe("Source timezone"),
603
+ to: z.string().describe("Target timezone")
604
+ }),
605
+ execute: async (params) => fetchOracle('/utility/timezone-convert', params)
606
+ });
607
+
608
+ export const checkHoliday = tool({
609
+ description: "Check if a date is a public holiday in any country.",
610
+ parameters: z.object({
611
+ date: z.string().describe("Date YYYY-MM-DD").optional(),
612
+ country: z.string().describe("ISO country code")
613
+ }),
614
+ execute: async (params) => fetchOracle('/utility/holiday-check', params)
615
+ });
616
+
617
+ export const getCronNext = tool({
618
+ description: "Parse cron expression and get next N occurrences.",
619
+ parameters: z.object({
620
+ cron: z.string().describe("Cron expression"),
621
+ n: z.number().int().describe("Number of occurrences").optional()
622
+ }),
623
+ execute: async (params) => fetchOracle('/utility/cron-next', params)
624
+ });
625
+
626
+ export const getDateDiff = tool({
627
+ description: "Calculate difference between two dates.",
628
+ parameters: z.object({
629
+ from: z.string().describe(""),
630
+ to: z.string().describe("")
631
+ }),
632
+ execute: async (params) => fetchOracle('/utility/date-diff', params)
633
+ });
634
+
635
+ export const convertUnixTimestamp = tool({
636
+ description: "Convert Unix timestamps to ISO dates and vice versa.",
637
+ parameters: z.object({
638
+ value: z.string().describe("")
639
+ }),
640
+ execute: async (params) => fetchOracle('/utility/unix-convert', params)
641
+ });
642
+
643
+ export const getTokenUnlocks = tool({
644
+ description: "Upcoming token unlock events via DeFiLlama.",
645
+ parameters: z.object({}),
646
+ execute: async (params) => fetchOracle('/token/unlocks', params)
647
+ });
648
+
649
+ export const getTokenSupply = tool({
650
+ description: "Circulating, total, and max supply for any token.",
651
+ parameters: z.object({
652
+ id: z.string().describe("")
653
+ }),
654
+ execute: async (params) => fetchOracle('/token/supply/{id}', params)
655
+ });
656
+
657
+ export const getTokenATHATL = tool({
658
+ description: "ATH and ATL prices with dates.",
659
+ parameters: z.object({
660
+ id: z.string().describe("")
661
+ }),
662
+ execute: async (params) => fetchOracle('/token/ath-atl/{id}', params)
663
+ });
664
+
665
+ export const getTokenCategories = tool({
666
+ description: "Get categories a token belongs to.",
667
+ parameters: z.object({
668
+ id: z.string().describe("")
669
+ }),
670
+ execute: async (params) => fetchOracle('/token/categories/{id}', params)
671
+ });
672
+
673
+ export const getTokenExchanges = tool({
674
+ description: "Exchanges where a token trades and their volumes.",
675
+ parameters: z.object({
676
+ id: z.string().describe("")
677
+ }),
678
+ execute: async (params) => fetchOracle('/token/exchanges/{id}', params)
679
+ });
680
+
681
+ export const getProtocolsByChain = tool({
682
+ description: "List all DeFi protocols on a specific chain with TVL.",
683
+ parameters: z.object({
684
+ chain: z.string().describe("")
685
+ }),
686
+ execute: async (params) => fetchOracle('/defi/protocols-by-chain', params)
687
+ });
688
+
689
+ export const getTVLChange = tool({
690
+ description: "24h and 7d TVL changes for protocols.",
691
+ parameters: z.object({
692
+ protocol: z.string().describe("").optional()
693
+ }),
694
+ execute: async (params) => fetchOracle('/defi/tvl-change', params)
695
+ });
696
+
697
+ export const getLendingRates = tool({
698
+ description: "Borrow and supply APYs from Aave, Compound, etc.",
699
+ parameters: z.object({
700
+ token: z.string().describe("").optional()
701
+ }),
702
+ execute: async (params) => fetchOracle('/defi/lending-rates', params)
703
+ });
704
+
705
+ export const getStakingYields = tool({
706
+ description: "Native staking APYs for ETH, SOL, ATOM, etc.",
707
+ parameters: z.object({}),
708
+ execute: async (params) => fetchOracle('/defi/staking-yields', params)
709
+ });
710
+
711
+ export const getDeFiLiquidations = tool({
712
+ description: "Recent liquidation events and at-risk capital.",
713
+ parameters: z.object({}),
714
+ execute: async (params) => fetchOracle('/defi/liquidations', params)
715
+ });
716
+
717
+ export const getDeFiHacks = tool({
718
+ description: "Recent exploit and hack history from DeFiLlama.",
719
+ parameters: z.object({
720
+ days: z.number().int().describe("").optional()
721
+ }),
722
+ execute: async (params) => fetchOracle('/defi/hacks', params)
723
+ });
724
+
725
+ export const getBridgesTVL = tool({
726
+ description: "Cross-chain bridge TVL and volume.",
727
+ parameters: z.object({}),
728
+ execute: async (params) => fetchOracle('/defi/bridges-tvl', params)
729
+ });
730
+
731
+ export const getDEXVolume = tool({
732
+ description: "24h DEX trading volume by chain or globally.",
733
+ parameters: z.object({
734
+ chain: z.string().describe("").optional()
735
+ }),
736
+ execute: async (params) => fetchOracle('/defi/dex-volume', params)
737
+ });
738
+
739
+ export const getFundingRates = tool({
740
+ description: "Perpetual futures funding rates from Binance.",
741
+ parameters: z.object({
742
+ symbol: z.string().describe("").optional()
743
+ }),
744
+ execute: async (params) => fetchOracle('/derivatives/funding-rates', params)
745
+ });
746
+
747
+ export const getOpenInterest = tool({
748
+ description: "Open interest data for crypto derivatives.",
749
+ parameters: z.object({
750
+ symbol: z.string().describe("")
751
+ }),
752
+ execute: async (params) => fetchOracle('/derivatives/open-interest', params)
753
+ });
754
+
755
+ export const getLongShortRatio = tool({
756
+ description: "Global long vs short ratio.",
757
+ parameters: z.object({
758
+ symbol: z.string().describe("")
759
+ }),
760
+ execute: async (params) => fetchOracle('/derivatives/long-short-ratio', params)
761
+ });
762
+
763
+ export const getTopTraders = tool({
764
+ description: "What are the top traders doing?",
765
+ parameters: z.object({
766
+ symbol: z.string().describe("")
767
+ }),
768
+ execute: async (params) => fetchOracle('/derivatives/top-traders', params)
769
+ });
770
+
771
+ export const getDerivativesLiquidations = tool({
772
+ description: "Recent futures liquidation data.",
773
+ parameters: z.object({
774
+ symbol: z.string().describe("").optional()
775
+ }),
776
+ execute: async (params) => fetchOracle('/derivatives/liquidations', params)
777
+ });
778
+
779
+ export const lookupTransaction = tool({
780
+ description: "Look up any transaction by hash.",
781
+ parameters: z.object({
782
+ hash: z.string().describe(""),
783
+ chain: z.string().describe("").optional()
784
+ }),
785
+ execute: async (params) => fetchOracle('/chain/tx-lookup', params)
786
+ });
787
+
788
+ export const getAddressBalance = tool({
789
+ description: "Get native ETH/MATIC/etc balance for any address.",
790
+ parameters: z.object({
791
+ address: z.string().describe(""),
792
+ chain: z.string().describe("").optional()
793
+ }),
794
+ execute: async (params) => fetchOracle('/chain/address-balance', params)
795
+ });
796
+
797
+ export const getTokenBalances = tool({
798
+ description: "Check major ERC-20 token balances for an address.",
799
+ parameters: z.object({
800
+ address: z.string().describe(""),
801
+ chain: z.string().describe("").optional()
802
+ }),
803
+ execute: async (params) => fetchOracle('/chain/token-balances', params)
804
+ });
805
+
806
+ export const checkContractVerified = tool({
807
+ description: "Check if a smart contract is verified on Etherscan.",
808
+ parameters: z.object({
809
+ address: z.string().describe(""),
810
+ chain: z.string().describe("").optional()
811
+ }),
812
+ execute: async (params) => fetchOracle('/chain/contract-verified', params)
813
+ });
814
+
815
+ export const getGasHistory = tool({
816
+ description: "Gas prices over last N blocks.",
817
+ parameters: z.object({
818
+ chain: z.string().describe("").optional(),
819
+ blocks: z.number().int().describe("").optional()
820
+ }),
821
+ execute: async (params) => fetchOracle('/chain/gas-history', params)
822
+ });
823
+
824
+ export const getBlockTime = tool({
825
+ description: "Get timestamp for any block number.",
826
+ parameters: z.object({
827
+ block: z.string().describe(""),
828
+ chain: z.string().describe("").optional()
829
+ }),
830
+ execute: async (params) => fetchOracle('/chain/block-time', params)
831
+ });
832
+
833
+ export const getActiveProposals = tool({
834
+ description: "Currently active voting proposals from major DAOs via Snapshot.",
835
+ parameters: z.object({}),
836
+ execute: async (params) => fetchOracle('/governance/active-proposals', params)
837
+ });
838
+
839
+ export const getDAOProposals = tool({
840
+ description: "Proposals for a specific DAO/space.",
841
+ parameters: z.object({
842
+ space: z.string().describe("")
843
+ }),
844
+ execute: async (params) => fetchOracle('/governance/dao-proposals', params)
845
+ });
846
+
847
+ export const getVotingPower = tool({
848
+ description: "Check voting power for an address in a specific DAO.",
849
+ parameters: z.object({
850
+ space: z.string().describe(""),
851
+ address: z.string().describe("")
852
+ }),
853
+ execute: async (params) => fetchOracle('/governance/voting-power', params)
854
+ });
855
+
856
+ export const getRecentVotes = tool({
857
+ description: "Recent voting events across DAOs.",
858
+ parameters: z.object({}),
859
+ execute: async (params) => fetchOracle('/governance/recent-votes', params)
860
+ });
861
+
862
+ export const getLensProfile = tool({
863
+ description: "Lens Protocol profile lookup.",
864
+ parameters: z.object({
865
+ handle: z.string().describe("")
866
+ }),
867
+ execute: async (params) => fetchOracle('/identity/lens-profile', params)
868
+ });
869
+
870
+ export const getFarcasterProfile = tool({
871
+ description: "Farcaster profile lookup.",
872
+ parameters: z.object({
873
+ username: z.string().describe("")
874
+ }),
875
+ execute: async (params) => fetchOracle('/identity/farcaster-profile', params)
876
+ });
877
+
878
+ export const getENSRecords = tool({
879
+ description: "Full ENS records: owner, expiry, avatar, text records.",
880
+ parameters: z.object({
881
+ name: z.string().describe("")
882
+ }),
883
+ execute: async (params) => fetchOracle('/identity/ens-records', params)
884
+ });
885
+
886
+ export const getAddressLabels = tool({
887
+ description: "Known labels for addresses: Exchange wallets, DEX routers.",
888
+ parameters: z.object({
889
+ address: z.string().describe("")
890
+ }),
891
+ execute: async (params) => fetchOracle('/identity/address-labels', params)
892
+ });
893
+
894
+ export const getPrice24hAgo = tool({
895
+ description: "Token price exactly 24 hours ago.",
896
+ parameters: z.object({
897
+ id: z.string().describe("")
898
+ }),
899
+ execute: async (params) => fetchOracle('/history/price-24h/{id}', params)
900
+ });
901
+
902
+ export const getPrice7dAgo = tool({
903
+ description: "Token price 7 days ago.",
904
+ parameters: z.object({
905
+ id: z.string().describe("")
906
+ }),
907
+ execute: async (params) => fetchOracle('/history/price-7d/{id}', params)
908
+ });
909
+
910
+ export const getPrice30dAgo = tool({
911
+ description: "Token price 30 days ago.",
912
+ parameters: z.object({
913
+ id: z.string().describe("")
914
+ }),
915
+ execute: async (params) => fetchOracle('/history/price-30d/{id}', params)
916
+ });
917
+
918
+ export const getOHLC30d = tool({
919
+ description: "Open-High-Low-Close data for 30 days.",
920
+ parameters: z.object({
921
+ id: z.string().describe("")
922
+ }),
923
+ execute: async (params) => fetchOracle('/history/ohlc-30d/{id}', params)
924
+ });
925
+
926
+ export const getVolume7d = tool({
927
+ description: "7 days of trading volume.",
928
+ parameters: z.object({
929
+ id: z.string().describe("")
930
+ }),
931
+ execute: async (params) => fetchOracle('/history/volume-7d/{id}', params)
932
+ });
933
+
934
+ export const getAgentRankings = tool({
935
+ description: "PROPRIETARY: Ranked list of most-called endpoints.",
936
+ parameters: z.object({}),
937
+ execute: async (params) => fetchOracle('/meta/agent-rankings', params)
938
+ });
939
+
940
+ export const getCategoryVelocity = tool({
941
+ description: "PROPRIETARY: 7-day growth rate by category.",
942
+ parameters: z.object({}),
943
+ execute: async (params) => fetchOracle('/meta/category-velocity', params)
944
+ });
945
+
946
+ export const getCorrelationMatrix = tool({
947
+ description: "PROPRIETARY: Which endpoints are queried together.",
948
+ parameters: z.object({}),
949
+ execute: async (params) => fetchOracle('/meta/correlation-matrix', params)
950
+ });
951
+
952
+ export const getHourlyVolume = tool({
953
+ description: "PROPRIETARY: 24-hour volume by hour.",
954
+ parameters: z.object({}),
955
+ execute: async (params) => fetchOracle('/meta/hourly-volume', params)
956
+ });
957
+
958
+ export const getErrorPatterns = tool({
959
+ description: "PROPRIETARY: Common error patterns across the network.",
960
+ parameters: z.object({}),
961
+ execute: async (params) => fetchOracle('/meta/error-patterns', params)
962
+ });
963
+
964
+ export const getTopCallers = tool({
965
+ description: "PROPRIETARY: Most active agent wallets.",
966
+ parameters: z.object({}),
967
+ execute: async (params) => fetchOracle('/meta/top-callers', params)
968
+ });
969
+
970
+ export const getEntrySignal = tool({
971
+ description: "SYNTHETIC: Buy signal 0-100. Contrarian entry timing.",
972
+ parameters: z.object({
973
+ id: z.string().describe("Token ID (default: bitcoin)").optional()
974
+ }),
975
+ execute: async (params) => fetchOracle('/alpha/entry-signal', params)
976
+ });
977
+
978
+ export const getExitSignal = tool({
979
+ description: "SYNTHETIC: Sell signal 0-100. Take profit timing.",
980
+ parameters: z.object({
981
+ id: z.string().describe("Token ID (default: bitcoin)").optional()
982
+ }),
983
+ execute: async (params) => fetchOracle('/alpha/exit-signal', params)
984
+ });
985
+
986
+ export const getDipDetector = tool({
987
+ description: "SYNTHETIC: Buy-the-dip trigger. Accumulation zone detector.",
988
+ parameters: z.object({
989
+ id: z.string().describe("Token ID (default: bitcoin)").optional()
990
+ }),
991
+ execute: async (params) => fetchOracle('/alpha/dip-detector', params)
992
+ });
993
+
994
+ export const getMomentumScore = tool({
995
+ description: "SYNTHETIC: Trend strength -100 to +100.",
996
+ parameters: z.object({
997
+ id: z.string().describe("Token ID (default: bitcoin)").optional()
998
+ }),
999
+ execute: async (params) => fetchOracle('/alpha/momentum-score', params)
1000
+ });
1001
+
1002
+ export const getVolatilityRegime = tool({
1003
+ description: "SYNTHETIC: Volatility state (Low/Normal/High/Extreme).",
1004
+ parameters: z.object({
1005
+ id: z.string().describe("Token ID (default: bitcoin)").optional()
1006
+ }),
1007
+ execute: async (params) => fetchOracle('/alpha/volatility-regime', params)
1008
+ });
1009
+
1010
+ export const getSmartMoneyFlow = tool({
1011
+ description: "SYNTHETIC: Stablecoin vs BTC ratio as smart money indicator.",
1012
+ parameters: z.object({}),
1013
+ execute: async (params) => fetchOracle('/alpha/smart-money-flow', params)
1014
+ });