@undesirables/plugin-tcg-oracle 1.1.0 → 2.0.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/LICENSE CHANGED
@@ -2,20 +2,81 @@ Business Source License 1.1
2
2
 
3
3
  Parameters
4
4
 
5
- Licensor: The Undesirables LLC
6
- Licensed Work: plugin-undesirables
7
- The Licensed Work is (c) 2026 The Undesirables LLC
8
- Additional Use Grant: You may use the Licensed Work for non-production purposes,
9
- personal projects, and evaluation. Production use requires
10
- a commercial license from The Undesirables LLC.
11
- Change Date: 2030-04-24
12
- Change License: MIT
13
-
14
- Notice
15
-
16
- The Business Source License (this document, or the "License") is not an Open
17
- Source license. However, the Licensed Work will eventually be made available
18
- under an Open Source License, as stated in this License.
19
-
20
- For more information on the Business Source License, please visit:
21
- https://mariadb.com/bsl11/
5
+ Licensor: The Undesirables LLC
6
+ Licensed Work: Plugin TCG Oracle
7
+ Copyright (c) 2026 The Undesirables LLC.
8
+ All Rights Reserved.
9
+ Additional Use Grant: You may make production use of the Licensed Work,
10
+ provided Your use does not include offering the
11
+ Licensed Work to third parties on a hosted or
12
+ embedded basis as a Competitive Offering.
13
+
14
+ A "Competitive Offering" is a product or service
15
+ offered to third parties on a paid basis (including
16
+ through paid support arrangements) that provides
17
+ TCG market intelligence, pricing aggregation, AI
18
+ card grading, or on-chain price oracle functionality
19
+ as a primary feature.
20
+
21
+ If Your product is not a Competitive Offering when
22
+ You first make it generally available, it will not
23
+ become a Competitive Offering later due to the
24
+ Licensor releasing a new version of the Licensed
25
+ Work with additional capabilities.
26
+
27
+ Products that are not provided on a paid basis are
28
+ not Competitive Offerings.
29
+
30
+ Change Date: June 1, 2030
31
+ Change License: MIT
32
+
33
+ For alternative licensing arrangements, contact:
34
+ theundesirables7@gmail.com
35
+
36
+ ─────────────────────────────────────────────────────────────────────────
37
+
38
+ Terms
39
+
40
+ The Licensor hereby grants you the right to copy, modify, create derivative
41
+ works, redistribute, and make non-production use of the Licensed Work. The
42
+ Licensor may make an Additional Use Grant, above, permitting limited
43
+ production use.
44
+
45
+ Effective on the Change Date, or the fourth anniversary of the first publicly
46
+ available distribution of a specific version of the Licensed Work under this
47
+ License, whichever comes first, the Licensor hereby grants you rights under
48
+ the terms of the Change License, and the rights granted in the paragraph
49
+ above terminate.
50
+
51
+ If your use of the Licensed Work does not comply with the requirements
52
+ currently in effect as described in this License, you must purchase a
53
+ commercial license from the Licensor, its affiliated entities, or authorized
54
+ resellers, or you must refrain from using the Licensed Work.
55
+
56
+ All copies of the original and modified Licensed Work, and derivative works
57
+ of the Licensed Work, are subject to this License. This License applies
58
+ separately for each version of the Licensed Work and the Change Date may
59
+ vary for each version of the Licensed Work released by Licensor.
60
+
61
+ You must conspicuously display this License on each original or modified copy
62
+ of the Licensed Work. If you receive the Licensed Work in original or
63
+ modified form from a third party, the terms and conditions set forth in this
64
+ License apply to your use of that work.
65
+
66
+ Any use of the Licensed Work in violation of this License will automatically
67
+ terminate your rights under this License for the current and all other
68
+ versions of the Licensed Work.
69
+
70
+ This License does not grant you any right in any trademark or logo of
71
+ Licensor or its affiliates (provided that you may use a trademark or logo of
72
+ Licensor as expressly required by this License).
73
+
74
+ TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
75
+ AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
76
+ EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
77
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
78
+ TITLE.
79
+
80
+ ─────────────────────────────────────────────────────────────────────────
81
+ "Business Source License" is a trademark of MariaDB Corporation Ab.
82
+ BUSL-1.1 license template: https://mariadb.com/bsl11/
package/README.md CHANGED
@@ -1,11 +1,47 @@
1
- # @undesirables/plugin-tcg-oracle
1
+ <div align="center">
2
2
 
3
3
  ![TCG Oracle Banner](./images/banner.jpg)
4
4
 
5
- [![npm](https://img.shields.io/npm/v/@undesirables/plugin-tcg-oracle)](https://www.npmjs.com/package/@undesirables/plugin-tcg-oracle)
6
- [![License: BUSL-1.1](https://img.shields.io/badge/License-BUSL--1.1-blue)](LICENSE)
5
+ # @undesirables/plugin-tcg-oracle
6
+
7
+ > **Status 2026-09-12:** the USD price panel behind this plugin froze on 2026-09-07. Search still works (prices carry `usd_panel {frozen, as_of}`); the market, simulate and trending actions are suspended and return `{"status":"suspended"}` without charging. See `GET https://oracle.the-undesirables.com/` → `endpoints.suspended`.
8
+
9
+ ## 🔌 Connect over MCP — one URL, no install
10
+
11
+ ```
12
+ https://mcp.the-undesirables.com
13
+ ```
14
+
15
+ Paste into any MCP client (Claude, Cursor, ChatGPT) — free card search & forecasts, paid calls via x402.
16
+
17
+
18
+ **Give any ElizaOS agent real trading card market intelligence — search, grade, and forecast.**
7
19
 
8
- > Give any ElizaOS agent real trading card market intelligence — search 370K+ products, grade cards with AI vision, and simulate future prices with Monte Carlo models.
20
+ [![npm](https://img.shields.io/npm/v/@undesirables/plugin-tcg-oracle?style=flat-square)](https://www.npmjs.com/package/@undesirables/plugin-tcg-oracle)
21
+ [![npm downloads](https://img.shields.io/npm/dm/@undesirables/plugin-tcg-oracle?style=flat-square)](https://www.npmjs.com/package/@undesirables/plugin-tcg-oracle)
22
+ [![License: BUSL-1.1](https://img.shields.io/badge/License-BUSL--1.1-red?style=flat-square)](LICENSE)
23
+ [![ElizaOS](https://img.shields.io/badge/ElizaOS-Compatible-5A67D8?style=flat-square&logo=data:image/svg+xml;base64,&logoColor=white)](https://elizaos.ai)
24
+ [![Games](https://img.shields.io/badge/Games-Pok%C3%A9mon%20%C2%B7%20MTG%20%C2%B7%20Yu--Gi--Oh!-ff14a0?style=flat-square)](https://oracle.the-undesirables.com)
25
+
26
+ [npm](https://www.npmjs.com/package/@undesirables/plugin-tcg-oracle) · [TCG Oracle API](https://the-undesirables.com/docs)
27
+
28
+ </div>
29
+
30
+ ---
31
+
32
+ ## Table of Contents
33
+
34
+ - [Why This Exists](#why-this-exists)
35
+ - [Quick Start](#quick-start)
36
+ - [Actions](#actions)
37
+ - [How It Works](#how-it-works)
38
+ - [Supported Games](#supported-games-25)
39
+ - [How the Data Works](#how-the-data-works)
40
+ - [Self-Hosting](#self-hosting)
41
+ - [Configuration](#configuration)
42
+ - [Architecture](#architecture)
43
+ - [Related Projects](#related-projects)
44
+ - [License & Commercial Use](#-license--commercial-use)
9
45
 
10
46
  ---
11
47
 
@@ -15,10 +51,10 @@ The trading card market is worth **$50 billion** and growing. Millions of people
15
51
 
16
52
  This plugin gives your ElizaOS agent the ability to do all of that in one conversation:
17
53
 
18
- 1. **"Search for Charizard cards"** → Instantly searches 370K+ real products across 25 games
54
+ 1. **"Search for Charizard cards"** → Instantly searches 456K+ real products across 25+ games
19
55
  2. **"Grade this card"** → AI vision analyzes centering, corners, edges, surface → predicts PSA/Beckett score
20
- 3. **"Simulate Charizard VMAX at $350 for 60 days"** → Runs 10,000 Monte Carlo simulations using Heston, Merton, or Kou stochastic models → returns percentile price bands
21
- 4. **"Show me the Pokemon market"** → Pulls the latest daily market snapshot with top movers and volume trends
56
+ 3. **"Simulate Charizard VMAX at $350 for 60 days"** → Runs a calibrated conformal risk forecast → returns honest VaR + percentile price bands
57
+ 4. **"Show me the Pokemon market"** → Market snapshot — **suspended since 2026-09-12** while the USD price panel is frozen (the oracle answers `{"status":"suspended"}`, no charge)
22
58
 
23
59
  No API keys required from third parties. You just point it at the TCG Oracle server (self-hosted or public).
24
60
 
@@ -55,30 +91,63 @@ That's it. Your agent can now search cards, grade images, and run simulations.
55
91
 
56
92
  | Action | What It Does | Example Prompt |
57
93
  |--------|-------------|----------------|
58
- | `TCG_ORACLE_SEARCH` | Search 370K+ products by card name, set, or keyword | "Search for Base Set Charizard" |
94
+ | `TCG_ORACLE_SEARCH` | Search 456K+ products by card name, set, or keyword | "Search for Base Set Charizard" |
59
95
  | `TCG_ORACLE_GRADE` | Grade a card image URL — returns PSA/Beckett prediction | "Grade this card: https://..." |
60
- | `TCG_ORACLE_SIMULATE` | Monte Carlo price forecast with 3 stochastic models | "Simulate Charizard at $350 for 60 days" |
61
- | `TCG_ORACLE_MARKET` | Pull the latest daily market snapshot for any game | "Show me the Pokemon market" |
96
+ | `TCG_ORACLE_SIMULATE` | **Suspended while the USD panel is frozen (since 2026-09-07)** — the oracle returns `{status: suspended}`, no charge | "Simulate Charizard at $350 for 60 days" |
97
+ | `TCG_ORACLE_MARKET` | **Suspended while the USD panel is frozen** — returns `{status: suspended}`, no charge | "Show me the Pokemon market" |
62
98
  | `TCG_ORACLE_GRADE_OR_NOT` | Grade-or-Not ROI engine — "will grading this make me money?" | "Should I grade my Charizard?" |
63
- | `TCG_ORACLE_TRENDING` | Trending cards by 30-day sales volume and price velocity | "What Pokemon cards are trending?" |
64
- | `TCG_ORACLE_ARB_GRADE` | Grading arbitrage scanner — finds profitable cards to grade | "Find me profitable cards to grade" |
99
+ | `TCG_ORACLE_TRENDING` | **Suspended while the USD panel is frozen** — returns `{status: suspended}`, no charge | "What Pokemon cards are trending?" |
100
+ | `TCG_ORACLE_JP_SUMMARY` | Japanese two-sided dealer board (bid + ask, yen) as daily aggregates — bands, per-game, movement, on-chain root. Free, live | "How is the Japanese card market moving?" |
101
+ | `TCG_ORACLE_SPORTS_BOARD` | Daily sports movers board per live league with conformal 7-day context. Free, live | "Who are the hot NFL players this week?" |
102
+ | `TCG_ORACLE_LOAN_PREVIEW` | Graded-slab loan terms v2 — six-step LTV derivation (live value basis, empirical-VaR tail). Free for free-board slabs | "Loan terms for a PSA 10 of product 566544" |
103
+
104
+ ---
105
+
106
+ ## How It Works
107
+
108
+ ```
109
+ ┌────────────────────────────────────────────────────────────────┐
110
+ │ ElizaOS Agent │
111
+ │ │
112
+ │ User: "Simulate Charizard VMAX at $350 for 60 days" │
113
+ │ │ │
114
+ │ ▼ │
115
+ │ ┌─────────────────────┐ │
116
+ │ │ Action Router │ │
117
+ │ │ (LLM selects best │ │
118
+ │ │ action + params) │ │
119
+ │ └────────┬────────────┘ │
120
+ └───────────────────────┼────────────────────────────────────────┘
121
+ │ fetch() + 30s timeout
122
+ ▼
123
+ ┌────────────────────────────────────────────────────────────────┐
124
+ │ TCG Oracle API Server │
125
+ │ │
126
+ │ /api/v1/search ─────── 456K+ products │
127
+ │ /api/v1/grade ──────── Vision LLM + OpenCV → PSA/BGS score │
128
+ │ /api/v1/simulate ───── SUSPENDED (USD panel frozen 09-07) │
129
+ │ /api/v1/market ─────── SUSPENDED (USD panel frozen 09-07) │
130
+ │ /api/v1/trending ───── SUSPENDED (USD panel frozen 09-07) │
131
+ │ /api/v1/grade-or-not ─ PSA fee × grade × value = GO/NO-GO │
132
+ │ │
133
+ └────────────────────────────────────────────────────────────────┘
134
+ ```
65
135
 
66
136
  ---
67
137
 
68
138
  ## Supported Games (25)
69
139
 
70
- Pokémon · Magic: The Gathering · Yu-Gi-Oh! · Disney Lorcana · One Piece · Flesh and Blood · Star Wars: Unlimited · Dragon Ball Super · Digimon · MetaZoo · Union Arena · Gundam Card Game · LoL Riftbound · and 12 more via TCGCSV
140
+ Pokémon · Magic: The Gathering · Yu-Gi-Oh! · Disney Lorcana · One Piece · Flesh and Blood · Star Wars: Unlimited · Dragon Ball Super · Digimon · MetaZoo · Union Arena · Gundam Card Game · LoL Riftbound · and 12 more
71
141
 
72
142
  ---
73
143
 
74
144
  ## How the Data Works
75
145
 
76
- All market data comes from [TCGCSV](https://tcgcsv.com) — a community project that snapshots pricing data daily for 25 TCG games. Our GitLab CI pipeline automatically refreshes this data every 24 hours. The full dataset (370K+ products) is also available on [Kaggle](https://www.kaggle.com/datasets/sailorpepe/tcg-market-intelligence).
146
+ USD market prices originate from TCGPlayer. **That upstream feed is currently unavailable, so USD prices are frozen at their last good date** — every response carries its own `latest_date`, and the oracle root publishes panel freshness under `panels`. A Japanese-print panel (24 games, 364K cards, 167K of them with both an ask and a dealer buyback bid) refreshes every morning. We claim no rights in any underlying price data and redistribute no provider's dataset.
147
+
148
+ **Risk model — conformal calibration (default):**
77
149
 
78
- **Monte Carlo models explained:**
79
- - **Heston** — Models volatility itself as stochastic (volatility changes over time). Best for cards with unpredictable hype cycles.
80
- - **Merton** — Adds random jumps to the price process. Best for cards that can spike on tournament results or reprints.
81
- - **Kou** — Uses double-exponential jump distribution. Best for modeling asymmetric risk (big upside spikes vs gradual decline).
150
+ Price forecasts default to a **regime-aware split-conformal** model: distribution-free bands calibrated on real cross-card price history, so the published downside risk (VaR) is *honest* — out-of-sample, a "5% loss" actually happens about 5% of the time — and fully **deterministic**, so anyone can reproduce the exact numbers. Each card also gets two letter grades: **Safe-Hold** (downside protection) and **Momentum** (direction). Monte Carlo models (GBM and Merton jump-diffusion) remain available via `model=`, seeded from the public **drand** randomness beacon for provably-fair draws. Forecast responses include the model parameters (e.g. `drift_mu`, `diffusion_sigma`, `regime`) for full transparency.
82
151
 
83
152
  ---
84
153
 
@@ -117,6 +186,43 @@ This is a **native TypeScript** ElizaOS plugin. It runs natively in the ElizaOS
117
186
 
118
187
  ---
119
188
 
120
- ## License
189
+ ## 📝 License & Commercial Use
190
+
191
+ This project is licensed under the **[Business Source License 1.1 (BUSL-1.1)](LICENSE)**.
192
+
193
+ We build in public and support the developer ecosystem — but we also protect the infrastructure and IP of **The Undesirables LLC**.
194
+
195
+ ### ✅ What You CAN Do (Free)
196
+
197
+ - **Personal & Educational Use** — Download, modify, and run locally for learning, research, or personal projects.
198
+ - **Non-Competing Applications** — Integrate our packages into your app, provided your app does not offer TCG market intelligence, pricing aggregation, AI card grading, or on-chain price oracle services as its primary function.
199
+ - **MCP / Agent Integration** — Connect your AI agent to our tools for non-commercial use.
200
+ - **Community Contributions** — Security audits, bug fixes, and PRs are always welcome.
201
+
202
+ ### 🚫 What You CANNOT Do (Use Limitation)
203
+
204
+ - **Competing Service** — You may not use this code to operate a competing TCG market intelligence, pricing aggregation, AI card grading, or on-chain price oracle service.
205
+ - **Commercial Resale** — You may not wrap our API, data pipelines, or AI models into a paid service without a commercial license.
206
+ - **Hosted SaaS** — You may not host this software as a service for third parties without written permission.
207
+
208
+ ### 🔓 Open-Source Conversion
209
+
210
+ On **June 1, 2030** (or 4 years after the first public release of each version), this code automatically converts to the **MIT License** — fully open source, forever.
211
+
212
+ ### 🤝 Commercial Licensing
213
+
214
+ Building a commercial product? Want guaranteed API access or white-label integration? Contact us:
215
+
216
+ 📧 **oracle@the-undesirables.com** · 🐦 **[@undesirables_ai](https://x.com/undesirables_ai)**
217
+
218
+ © 2026 The Undesirables LLC
219
+
220
+ ---
221
+
222
+ <div align="center">
223
+
224
+ ⭐ **If this project helped you, please star this repo** — it helps others find it.
225
+
226
+ [Report Bug](../../issues) · [Request Feature](../../issues)
121
227
 
122
- [BUSL-1.1](LICENSE) — Business Source License 1.1. Copyright © 2026 The Undesirables LLC.
228
+ </div>
package/dist/index.d.ts CHANGED
@@ -1,16 +1,19 @@
1
1
  import { Plugin } from '@elizaos/core';
2
2
 
3
3
  /**
4
- * TCG Oracle — ElizaOS Plugin v1.0.0
4
+ * TCG Oracle — ElizaOS Plugin v2.0.2
5
5
  * ====================================
6
6
  * AI-powered trading card market intelligence for ElizaOS agents.
7
7
  * Native TypeScript rewrite of the Python G.A.M.E. SDK version.
8
8
  *
9
9
  * Features:
10
- * - Search 370K+ TCG products across 25 games (Pokemon, MTG, Yu-Gi-Oh, etc.)
10
+ * - Search 455K+ TCG products across 25+ games (Pokemon, MTG, Yu-Gi-Oh, etc.)
11
+ * - Japanese two-sided dealer board summary, graded-slab loan terms, daily sports movers board
11
12
  * - AI Vision card grading (PSA/Beckett prediction via Qwen VL)
12
- * - Monte Carlo price simulation (Heston, Merton, Kou stochastic models)
13
- * - Real-time market snapshots from TCGCSV daily data
13
+ * - Conformal-calibrated risk forecasts (honest VaR + Safe-Hold/Momentum grades);
14
+ * Monte Carlo (GBM/Merton) opt-in via the model parameter
15
+ * - Market snapshots / simulate / trending: SUSPENDED since the USD panel froze 2026-09-07
16
+ * (the oracle answers {"status":"suspended"} and never charges) — actions surface that honestly
14
17
  * - License key purchase & verification (Ethereum NFT)
15
18
  *
16
19
  * @see https://the-undesirables.com
@@ -18,7 +21,7 @@ import { Plugin } from '@elizaos/core';
18
21
  */
19
22
 
20
23
  declare const SUPPORTED_GAMES: readonly ["Pokemon", "Magic: The Gathering", "Yu-Gi-Oh!", "Lorcana", "One Piece", "Flesh and Blood", "Star Wars: Unlimited", "Dragon Ball Super", "Digimon", "MetaZoo", "Union Arena", "Gundam Card Game", "LoL Riftbound"];
21
- declare const SIMULATION_MODELS: readonly ["heston", "merton", "kou"];
24
+ declare const SIMULATION_MODELS: readonly ["conformal", "merton", "gbm"];
22
25
  declare const tcgOraclePlugin: Plugin;
23
26
 
24
27
  export { SIMULATION_MODELS, SUPPORTED_GAMES, tcgOraclePlugin as default };
package/dist/index.js CHANGED
@@ -63,7 +63,7 @@ var SUPPORTED_GAMES = [
63
63
  "Gundam Card Game",
64
64
  "LoL Riftbound"
65
65
  ];
66
- var SIMULATION_MODELS = ["heston", "merton", "kou"];
66
+ var SIMULATION_MODELS = ["conformal", "merton", "gbm"];
67
67
  function getBaseUrl(runtime) {
68
68
  return runtime.getSetting?.("TCG_ORACLE_URL") || process.env.TCG_ORACLE_URL || "";
69
69
  }
@@ -84,13 +84,19 @@ async function callApi(baseUrl, endpoint, params) {
84
84
  const timeout = setTimeout(() => controller.abort(), 3e4);
85
85
  const response = await fetch(url.toString(), {
86
86
  signal: controller.signal,
87
- headers: { "User-Agent": "elizaos-tcg-oracle-plugin/1.0.0" }
87
+ headers: { "User-Agent": "elizaos-tcg-oracle-plugin/2.0.2" }
88
88
  });
89
89
  clearTimeout(timeout);
90
90
  if (!response.ok) {
91
91
  return { error: `API returned HTTP ${response.status}` };
92
92
  }
93
93
  const json = await response.json();
94
+ if (json && json.status === "suspended") {
95
+ const alts = json.alternatives ? Object.entries(json.alternatives).map(([k, v]) => `${k}: ${v}`).join("; ") : "";
96
+ return {
97
+ error: `${endpoint} is SUSPENDED (not charged). ${json.reason || ""} Resumes when: ${json.resumes_when || "unknown"}.` + (alts ? ` Live alternatives \u2014 ${alts}` : "")
98
+ };
99
+ }
94
100
  return { data: json.data || json };
95
101
  } catch (err) {
96
102
  if (err.name === "AbortError") {
@@ -109,7 +115,7 @@ function safeStringify(data, maxItems = 10) {
109
115
  }
110
116
  var searchAction = {
111
117
  name: "TCG_ORACLE_SEARCH",
112
- description: "Search for trading card products across 25 games including Pokemon, Magic: The Gathering, Yu-Gi-Oh, Lorcana, One Piece, and more. Returns product names, set info, and current market prices from 370K+ real products sourced from TCGCSV daily.",
118
+ description: "Search for trading card products across 25+ games including Pokemon, Magic: The Gathering, Yu-Gi-Oh, Lorcana, One Piece, and more. Returns product names, set info, and the last published USD price (the USD panel froze 2026-09-07 and every row says so in-band) from 455K+ real products.",
113
119
  similes: [
114
120
  "SEARCH_CARDS",
115
121
  "FIND_CARD",
@@ -238,7 +244,7 @@ ${summary}`;
238
244
  };
239
245
  var simulateAction = {
240
246
  name: "TCG_ORACLE_SIMULATE",
241
- description: "Run Monte Carlo simulation on a TCG card's price to predict future value. Uses real drift and volatility computed from TCGCSV historical data. Supports three stochastic models: Heston (stochastic volatility), Merton (jump-diffusion), and Kou (double-exponential jumps). Returns percentile bands (5th, 25th, 50th, 75th, 95th) for the forecast period.",
247
+ description: "SUSPENDED since 2026-09-07 (frozen USD panel; the oracle returns status=suspended and does not charge \u2014 the action reports that). Was: forecast a TCG card's future value with a conformal-calibrated risk model \u2014 honest VaR plus Safe-Hold/Momentum letter grades. Monte Carlo (GBM/Merton) is opt-in via the model parameter. Uses real drift and volatility computed from the historical USD panel. Monte Carlo models available opt-in: merton (jump-diffusion) and gbm. Returns percentile bands (5th, 25th, 50th, 75th, 95th) for the forecast period.",
242
248
  similes: [
243
249
  "SIMULATE_PRICE",
244
250
  "PRICE_PREDICTION",
@@ -262,9 +268,9 @@ var simulateAction = {
262
268
  },
263
269
  {
264
270
  name: "model",
265
- description: "Stochastic model: 'heston', 'merton', or 'kou'",
271
+ description: "Forecast model (default 'conformal'): 'conformal' (regime-aware split-conformal bands, honest calibrated VaR), or opt into Monte Carlo with 'merton' (jump-diffusion) or 'gbm'",
266
272
  required: false,
267
- schema: { type: "string", enumValues: ["heston", "merton", "kou"] }
273
+ schema: { type: "string", enumValues: ["conformal", "merton", "gbm"] }
268
274
  },
269
275
  {
270
276
  name: "days",
@@ -292,11 +298,11 @@ var simulateAction = {
292
298
  const text = message.content.text || "";
293
299
  const priceMatch = text.match(/\$?([\d,]+(?:\.\d{2})?)/);
294
300
  const daysMatch = text.match(/(\d+)\s*days?/i);
295
- const modelMatch = text.match(/\b(heston|merton|kou)\b/i);
296
- const cardName = text.replace(/simulate|price|forecast|monte carlo|at|\$[\d,.]+|\d+\s*days?|heston|merton|kou/gi, "").replace(/\s+/g, " ").trim() || "Unknown Card";
301
+ const modelMatch = text.match(/\b(conformal|merton|gbm)\b/i);
302
+ const cardName = text.replace(/simulate|price|forecast|monte carlo|at|\$[\d,.]+|\d+\s*days?|conformal|merton|gbm/gi, "").replace(/\s+/g, " ").trim() || "Unknown Card";
297
303
  const currentPrice = priceMatch ? parseFloat(priceMatch[1].replace(",", "")) : 0;
298
304
  const days = daysMatch ? parseInt(daysMatch[1]) : 30;
299
- const model = modelMatch ? modelMatch[1].toLowerCase() : "heston";
305
+ const model = modelMatch ? modelMatch[1].toLowerCase() : "conformal";
300
306
  if (currentPrice <= 0) {
301
307
  if (callback) await callback({ text: "Please provide a current price for the simulation. Example: 'Simulate Charizard VMAX at $350 for 60 days'" });
302
308
  return { success: false, error: "Invalid or missing current price" };
@@ -322,7 +328,7 @@ ${summary}`;
322
328
  };
323
329
  var marketAction = {
324
330
  name: "TCG_ORACLE_MARKET",
325
- description: "Retrieve the latest daily market data snapshot from TCGCSV for a specific game. Returns top movers, price changes, volume data, and market trends. Data is refreshed daily via automated pipeline.",
331
+ description: "SUSPENDED since 2026-09-07 (frozen USD panel; the oracle returns status=suspended and does not charge \u2014 the action reports that and points at the live alternatives: TCG_ORACLE_JP_SUMMARY, TCG_ORACLE_SPORTS_BOARD, TCG_ORACLE_LOAN_PREVIEW). Was: daily USD market snapshot for a game.",
326
332
  similes: [
327
333
  "MARKET_SNAPSHOT",
328
334
  "MARKET_DATA",
@@ -446,7 +452,7 @@ ${safeStringify(data)}`;
446
452
  };
447
453
  var trendingAction = {
448
454
  name: "TCG_ORACLE_TRENDING",
449
- description: "Returns the top trending trading cards by market activity (30-day sales volume, views, and price velocity). Covers all 25 supported TCG games. Useful for spotting market momentum and emerging opportunities.",
455
+ description: "SUSPENDED since 2026-09-07 (frozen USD panel; the oracle returns status=suspended and does not charge \u2014 the action reports that). Was: returns the top trending trading cards by market activity (30-day sales volume, views, and price velocity). Covers all 25 supported TCG games. Useful for spotting market momentum and emerging opportunities.",
450
456
  similes: [
451
457
  "TRENDING_CARDS",
452
458
  "HOT_CARDS",
@@ -504,66 +510,205 @@ ${summary}`;
504
510
  return { success: true, text: responseText, data: { trending: result.data } };
505
511
  }
506
512
  };
507
- var arbGradeAction = {
508
- name: "TCG_ORACLE_ARB_GRADE",
509
- description: "Scans the TCG database for undervalued raw cards where grading would produce ROI above a threshold. Estimates PSA grades based on price tier and rarity, calculates expected graded values, and returns ranked opportunities sorted by expected profit.",
513
+ var jpSummaryAction = {
514
+ name: "TCG_ORACLE_JP_SUMMARY",
515
+ description: "Daily aggregate summary of the Japanese two-sided dealer board (bid AND ask, yen): card/set/game totals, two-sided share, ask price bands, per-game breakdown, day-over-day and week-over-week movement, and the on-chain commitment root. Aggregates only \u2014 no per-card names, ids or prices. Free, live (this is the feed the Card Souls call from 2026-09-14).",
510
516
  similes: [
511
- "GRADING_ARBITRAGE",
512
- "FIND_UNDERVALUED",
513
- "ARBITRAGE_SCAN",
514
- "PROFITABLE_CARDS",
515
- "WHAT_TO_GRADE"
517
+ "JAPANESE_MARKET",
518
+ "JP_BOARD",
519
+ "JP_SUMMARY",
520
+ "YEN_MARKET",
521
+ "JAPANESE_CARDS",
522
+ "DEALER_BOARD"
516
523
  ],
517
524
  parameters: [
518
525
  {
519
- name: "game",
520
- description: "TCG game to scan (default: Pokemon)",
526
+ name: "section",
527
+ description: "Optional: narrow the answer to one block \u2014 totals, bands, per_game or movement (default: all)",
528
+ required: false,
529
+ schema: { type: "string" }
530
+ }
531
+ ],
532
+ examples: [
533
+ [
534
+ { name: "{{user1}}", content: { text: "How is the Japanese card market moving today?" } },
535
+ { name: "{{agentName}}", content: { text: "Pulling the Japanese two-sided board summary...", action: "TCG_ORACLE_JP_SUMMARY" } }
536
+ ],
537
+ [
538
+ { name: "{{user1}}", content: { text: "Give me the JP dealer board summary" } },
539
+ { name: "{{agentName}}", content: { text: "Fetching today's Japanese board aggregates...", action: "TCG_ORACLE_JP_SUMMARY" } }
540
+ ]
541
+ ],
542
+ validate: async (runtime) => !!getBaseUrl(runtime),
543
+ handler: async (runtime, message, _state, options, callback) => {
544
+ const text = message.content.text?.toLowerCase() || "";
545
+ const sections = ["totals", "bands", "per_game", "movement"];
546
+ const section = options?.section || sections.find((k) => text.includes(k.replace("_", " ")) || text.includes(k)) || "";
547
+ const result = await callApi(getBaseUrl(runtime), "/api/v1/jp/summary", {});
548
+ if (result.error) {
549
+ if (callback) await callback({ text: `Japanese board summary failed: ${result.error}` });
550
+ return { success: false, error: result.error };
551
+ }
552
+ const d = result.data || {};
553
+ const t = d.totals || {};
554
+ const dod = d.movement?.day_over_day || {};
555
+ const headline = `Japanese two-sided board \u2014 ${d.as_of}: ${t.cards} cards / ${t.sets} sets / ${t.games} games, ${t.two_sided} two-sided (${Math.round((t.two_sided_share || 0) * 100)}%), median ask \xA5${t.median_ask_yen}. Day-over-day: ${dod.asks_changed} asks moved (${dod.up} up / ${dod.down} down).`;
556
+ const body = section && d[section] !== void 0 ? { as_of: d.as_of, [section]: d[section], onchain: d.onchain } : d;
557
+ const responseText = `${headline}
558
+
559
+ ${safeStringify(body)}`;
560
+ if (callback) await callback({ text: responseText }, "TCG_ORACLE_JP_SUMMARY");
561
+ return { success: true, text: responseText, data: { jp_summary: d } };
562
+ }
563
+ };
564
+ var SPORTS_LEAGUES = ["mlb", "nhl", "nfl", "ncaaf", "nba", "ncaab", "wnba"];
565
+ var sportsBoardAction = {
566
+ name: "TCG_ORACLE_SPORTS_BOARD",
567
+ description: "Daily sports movers board \u2014 hot players per live league (MLB, NHL, NFL, NCAAF, NBA, ...) with conformal 7-day context, headshots and the current calibration verdict. Free, live. Name a league to narrow the answer.",
568
+ similes: [
569
+ "SPORTS_MOVERS",
570
+ "HOT_PLAYERS",
571
+ "SPORTS_BOARD",
572
+ "PLAYER_MOVERS",
573
+ "SPORTS_CARDS"
574
+ ],
575
+ parameters: [
576
+ {
577
+ name: "league",
578
+ description: "Optional league filter: mlb, nhl, nfl, ncaaf, nba, ncaab, wnba",
579
+ required: false,
580
+ schema: { type: "string" }
581
+ }
582
+ ],
583
+ examples: [
584
+ [
585
+ { name: "{{user1}}", content: { text: "Who are the hot NFL players this week?" } },
586
+ { name: "{{agentName}}", content: { text: "Pulling the NFL movers board...", action: "TCG_ORACLE_SPORTS_BOARD" } }
587
+ ],
588
+ [
589
+ { name: "{{user1}}", content: { text: "Show me the sports movers board" } },
590
+ { name: "{{agentName}}", content: { text: "Fetching today's sports board across live leagues...", action: "TCG_ORACLE_SPORTS_BOARD" } }
591
+ ]
592
+ ],
593
+ validate: async (runtime) => !!getBaseUrl(runtime),
594
+ handler: async (runtime, message, _state, _options, callback) => {
595
+ const text = message.content.text?.toLowerCase() || "";
596
+ const league = SPORTS_LEAGUES.find((l) => new RegExp(`\\b${l}\\b`).test(text));
597
+ const result = await callApi(getBaseUrl(runtime), "/api/v1/sports/board", {});
598
+ if (result.error) {
599
+ if (callback) await callback({ text: `Sports board failed: ${result.error}` });
600
+ return { success: false, error: result.error };
601
+ }
602
+ const d = result.data || {};
603
+ const leagues = d.leagues || {};
604
+ const live = Object.keys(leagues);
605
+ let body;
606
+ let label;
607
+ if (league && leagues[league]) {
608
+ body = leagues[league];
609
+ label = league.toUpperCase();
610
+ } else if (league) {
611
+ body = { live_leagues: live, note: `${league} is not on today's board` };
612
+ label = league.toUpperCase();
613
+ } else {
614
+ body = leagues;
615
+ label = live.map((l) => l.toUpperCase()).join(", ");
616
+ }
617
+ const responseText = `Sports movers board (${d.horizon_days || 7}-day horizon) \u2014 ${label}. Calibration: ${safeStringify(d.calibration)}
618
+
619
+ ${safeStringify(body, 25)}`;
620
+ if (callback) await callback({ text: responseText }, "TCG_ORACLE_SPORTS_BOARD");
621
+ return { success: true, text: responseText, data: { sports_board: d, league: league || null } };
622
+ }
623
+ };
624
+ var loanPreviewAction = {
625
+ name: "TCG_ORACLE_LOAN_PREVIEW",
626
+ description: "Graded-slab lending terms (loan-terms v2, live basis): the six-step worked LTV derivation \u2014 collateral value, empirical-VaR tail, max LTV, liquidation price, census liquidity tier, APR premium \u2014 for a graded card. Give a product_id + grade (e.g. 'PSA 10'); without one it walks the top of today's free board. Free for free-board slabs; other slabs point at the paid /api/v1/loan-terms quote ($0.10, x402).",
627
+ similes: [
628
+ "LOAN_TERMS",
629
+ "CARD_LOAN",
630
+ "LTV",
631
+ "COLLATERAL_VALUE",
632
+ "SLAB_LOAN",
633
+ "LENDING_TERMS"
634
+ ],
635
+ parameters: [
636
+ {
637
+ name: "product_id",
638
+ description: "TCG product id of the card (from TCG_ORACLE_SEARCH)",
639
+ required: false,
640
+ schema: { type: "number" }
641
+ },
642
+ {
643
+ name: "grade",
644
+ description: "Slab grade, e.g. 'PSA 10', 'PSA 9', 'BGS 9.5', 'CGC 10'",
521
645
  required: false,
522
646
  schema: { type: "string" }
523
647
  },
524
648
  {
525
- name: "min_roi",
526
- description: "Minimum expected ROI % to flag as opportunity (default: 50)",
649
+ name: "term_days",
650
+ description: "Loan term in days (default 30)",
527
651
  required: false,
528
652
  schema: { type: "number" }
529
653
  }
530
654
  ],
531
655
  examples: [
532
656
  [
533
- { name: "{{user1}}", content: { text: "Find me profitable Pokemon cards to grade" } },
534
- { name: "{{agentName}}", content: { text: "Scanning for grading arbitrage opportunities...", action: "TCG_ORACLE_ARB_GRADE" } }
657
+ { name: "{{user1}}", content: { text: "What loan terms would a PSA 10 of product 566544 get?" } },
658
+ { name: "{{agentName}}", content: { text: "Working the graded-slab LTV derivation...", action: "TCG_ORACLE_LOAN_PREVIEW" } }
535
659
  ],
536
660
  [
537
- { name: "{{user1}}", content: { text: "What Magic cards have the best grading ROI?" } },
538
- { name: "{{agentName}}", content: { text: "Running arbitrage scanner on Magic: The Gathering...", action: "TCG_ORACLE_ARB_GRADE" } }
661
+ { name: "{{user1}}", content: { text: "Show me the loan free board" } },
662
+ { name: "{{agentName}}", content: { text: "Pulling today's rated slab universe and the free-board derivation...", action: "TCG_ORACLE_LOAN_PREVIEW" } }
539
663
  ]
540
664
  ],
541
665
  validate: async (runtime) => !!getBaseUrl(runtime),
542
- handler: async (runtime, message, _state, _options, callback) => {
543
- const text = message.content?.text?.toLowerCase() || "";
544
- let game = "Pokemon";
545
- for (const g of SUPPORTED_GAMES) {
546
- if (text.includes(g.toLowerCase())) {
547
- game = g;
548
- break;
666
+ handler: async (runtime, message, _state, options, callback) => {
667
+ const text = message.content.text || "";
668
+ const baseUrl = getBaseUrl(runtime);
669
+ let productId = Number(options?.product_id) || 0;
670
+ if (!productId) {
671
+ const m = text.match(/\b(\d{5,7})\b/);
672
+ if (m) productId = Number(m[1]);
673
+ }
674
+ let grade = options?.grade || "";
675
+ if (!grade) {
676
+ const g = text.match(/\b(PSA|BGS|CGC|SGC)\s*(10|9\.5|9|8\.5|8|7|6|5)\b/i);
677
+ if (g) grade = `${g[1].toUpperCase()} ${g[2]}`;
678
+ }
679
+ const termDays = Number(options?.term_days) || (text.match(/\b(\d{1,3})\s*-?\s*day/i)?.[1] ? Number(text.match(/\b(\d{1,3})\s*-?\s*day/i)[1]) : 30);
680
+ let universeNote = "";
681
+ if (!productId || !grade) {
682
+ const uni = await callApi(baseUrl, "/api/v1/loan-terms/universe", {});
683
+ if (uni.error) {
684
+ if (callback) await callback({ text: `Loan universe failed: ${uni.error}` });
685
+ return { success: false, error: uni.error };
686
+ }
687
+ const cards = uni.data?.cards || [];
688
+ const pick = cards.find((c) => c.free_board && (!productId || c.product_id === productId));
689
+ if (!pick) {
690
+ const msg = productId ? `product ${productId} is not on today's free board \u2014 a full quote is the paid /api/v1/loan-terms?product_id=${productId}&grade= ($0.10, x402).` : "no free-board slab published today.";
691
+ if (callback) await callback({ text: `Loan preview: ${msg}` });
692
+ return { success: false, error: msg };
549
693
  }
694
+ productId = pick.product_id;
695
+ grade = pick.grade;
696
+ universeNote = `Universe ${uni.data?.universe_date}: ${uni.data?.total} rated slabs, ${uni.data?.free_board} on the free board (${uni.data?.method_version}). Showing #${pick.rank} ${pick.name} ${pick.grade}.
697
+
698
+ `;
550
699
  }
551
- const params = {
552
- game,
553
- min_roi: 50,
554
- limit: 20
555
- };
556
- const result = await callApi(getBaseUrl(runtime), "/api/v1/arb-grade", params);
700
+ const result = await callApi(baseUrl, `/api/v1/loan-terms/preview/${productId}`, { grade, term_days: termDays });
557
701
  if (result.error) {
558
- if (callback) await callback({ text: `Arbitrage scan failed: ${result.error}` });
702
+ const hint = result.error.includes("404") ? ` (${productId} ${grade} is not on today's free board \u2014 full quote: /api/v1/loan-terms?product_id=${productId}&grade=${encodeURIComponent(grade)}, $0.10 x402)` : "";
703
+ if (callback) await callback({ text: `Loan preview failed: ${result.error}${hint}` });
559
704
  return { success: false, error: result.error };
560
705
  }
561
- const summary = safeStringify(result.data, 15);
562
- const responseText = `Grading arbitrage opportunities for ${game}:
706
+ const d = result.data || {};
707
+ const responseText = `${universeNote}Loan terms \u2014 ${d.card || productId} ${d.grade || grade}, ${d.term_days || termDays}-day (${d.method_version}):
563
708
 
564
- ${summary}`;
565
- if (callback) await callback({ text: responseText }, "TCG_ORACLE_ARB_GRADE");
566
- return { success: true, text: responseText, data: { arbitrage: result.data } };
709
+ ${safeStringify(d)}`;
710
+ if (callback) await callback({ text: responseText }, "TCG_ORACLE_LOAN_PREVIEW");
711
+ return { success: true, text: responseText, data: { loan_preview: d, product_id: productId, grade } };
567
712
  }
568
713
  };
569
714
  var tcgOracleProvider = {
@@ -573,36 +718,36 @@ var tcgOracleProvider = {
573
718
  const baseUrl = getBaseUrl(runtime);
574
719
  const status = baseUrl ? "connected" : "not configured";
575
720
  return {
576
- text: `[TCG Oracle v1.1.0]
721
+ text: `[TCG Oracle v2.0.2]
577
722
  Status: ${status}
578
- Database: 370,158 products across 25 games
579
- Data source: TCGCSV daily snapshots
580
- Models: Heston (stochastic vol), Merton (jump-diffusion), Kou (double-exp)
581
- Actions: search, grade, simulate, market, grade-or-not, trending, arb-grade
723
+ Database: 455K+ products across 25+ games (USD panel FROZEN 2026-09-07 \u2014 served as last-published, labelled)
724
+ Live feeds: Japanese two-sided dealer board (daily, on-chain root), graded-slab loan terms v2, sports movers board
725
+ Models: conformal (default \u2014 regime-aware split-conformal bands, honest VaR), merton (jump-diffusion), gbm \u2014 Monte Carlo is opt-in
726
+ Actions: search, grade, grade-or-not, jp-summary, sports-board, loan-preview (live) \xB7 simulate, market, trending (SUSPENDED \u2014 oracle answers status=suspended, never charges)
582
727
  Supported games: ${SUPPORTED_GAMES.join(", ")}
583
728
  API: ${baseUrl || "TCG_ORACLE_URL not set"}
584
729
 
585
- The agent can search cards, grade card images, simulate prices via Monte Carlo, pull market snapshots, check grading ROI, view trending cards, and scan for grading arbitrage opportunities.`,
730
+ The agent can search cards, grade card images, check grading ROI, summarise the Japanese two-sided board, pull the sports movers board and work graded-slab loan terms. Simulate / market / trending are suspended until a live USD series exists again.`,
586
731
  values: {
587
732
  tcgOracleStatus: status,
588
733
  tcgOracleUrl: baseUrl || "not set",
589
- totalProducts: 370158
734
+ totalProducts: 455e3
590
735
  }
591
736
  };
592
737
  }
593
738
  };
594
739
  var tcgOraclePlugin = {
595
740
  name: "@undesirables/plugin-tcg-oracle",
596
- description: "TCG Oracle \u2014 AI-powered trading card market intelligence for ElizaOS agents. Covers 370K+ products across 25 games with Monte Carlo price simulation (Heston/Merton/Kou), AI vision card grading with ROI analysis, trending cards feed, grading arbitrage scanner, and real-time market snapshots. Powered by TCGCSV daily data pipeline.",
741
+ description: "TCG Oracle \u2014 AI-powered trading card market intelligence for ElizaOS agents. Covers 455K+ products across 25+ games: set-aware search, AI vision card grading with ROI analysis, the Japanese two-sided dealer board summary, graded-slab loan terms (empirical-VaR LTV, live basis) and the daily sports movers board. USD-panel forecasts, market snapshots and trending are suspended since 2026-09-07 (the oracle answers status=suspended and never charges).",
597
742
  init: async (config, runtime) => {
598
743
  const validation = validateTcgOracleConfig(runtime);
599
744
  if (!validation.valid) {
600
745
  console.warn(`\u26A0\uFE0F TCG Oracle: ${validation.error}`);
601
746
  } else {
602
- console.log(`\u2705 TCG Oracle v1.1.0 connected to ${runtime.getSetting?.("TCG_ORACLE_URL")}`);
747
+ console.log(`\u2705 TCG Oracle v2.0.2 connected to ${runtime.getSetting?.("TCG_ORACLE_URL")}`);
603
748
  }
604
749
  },
605
- actions: [searchAction, gradeAction, simulateAction, marketAction, gradeOrNotAction, trendingAction, arbGradeAction],
750
+ actions: [searchAction, gradeAction, simulateAction, marketAction, gradeOrNotAction, trendingAction, jpSummaryAction, sportsBoardAction, loanPreviewAction],
606
751
  providers: [tcgOracleProvider],
607
752
  evaluators: [],
608
753
  services: [MarketMonitorService]
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/environment.ts","../src/services.ts","../src/index.ts"],"sourcesContent":["import type { IAgentRuntime } from \"@elizaos/core\";\n\n/**\n * Validates that the TCG Oracle plugin has all required configuration.\n * Called during plugin init and before each action.\n */\nexport function validateTcgOracleConfig(\n runtime: IAgentRuntime\n): { valid: boolean; error?: string } {\n const url =\n (runtime.getSetting?.(\"TCG_ORACLE_URL\") as string) ||\n process.env.TCG_ORACLE_URL ||\n \"\";\n\n if (!url) {\n return {\n valid: false,\n error:\n \"TCG_ORACLE_URL is required. Set it in your character.json settings \" +\n \"or as an environment variable. Example: https://oracle.the-undesirables.com\",\n };\n }\n\n try {\n new URL(url);\n } catch {\n return {\n valid: false,\n error: `TCG_ORACLE_URL is not a valid URL: \"${url}\"`,\n };\n }\n\n return { valid: true };\n}\n","import { Service, IAgentRuntime } from \"@elizaos/core\";\n\nexport class MarketMonitorService extends Service {\n // Use a string getter to satisfy ElizaOS ServiceType constraints if needed,\n // or define static serviceType depending on the core version.\n static serviceType = \"TCG_MARKET_MONITOR\";\n\n get capabilityDescription(): string {\n return \"Monitors TCG market data for price spikes and trending cards\";\n }\n\n static async start(runtime: IAgentRuntime): Promise<MarketMonitorService> {\n const service = new MarketMonitorService();\n await service.initialize(runtime);\n return service;\n }\n\n private monitorInterval: NodeJS.Timeout | null = null;\n\n async initialize(_runtime: IAgentRuntime): Promise<void> {\n console.log(\"[TCG Oracle Service] Market Monitor Service initialized.\");\n // Example: Start background polling for market spikes every hour\n // this.monitorInterval = setInterval(() => this.pollMarket(), 1000 * 60 * 60);\n }\n\n async stop(): Promise<void> {\n if (this.monitorInterval) {\n clearInterval(this.monitorInterval);\n }\n console.log(\"[TCG Oracle Service] Market Monitor Service stopped.\");\n }\n\n private pollMarket() {\n console.log(\"[TCG Oracle Service] Background task: Polling TCG market for price spikes...\");\n }\n}\n","/**\n * TCG Oracle — ElizaOS Plugin v1.0.0\n * ====================================\n * AI-powered trading card market intelligence for ElizaOS agents.\n * Native TypeScript rewrite of the Python G.A.M.E. SDK version.\n *\n * Features:\n * - Search 370K+ TCG products across 25 games (Pokemon, MTG, Yu-Gi-Oh, etc.)\n * - AI Vision card grading (PSA/Beckett prediction via Qwen VL)\n * - Monte Carlo price simulation (Heston, Merton, Kou stochastic models)\n * - Real-time market snapshots from TCGCSV daily data\n * - License key purchase & verification (Ethereum NFT)\n *\n * @see https://the-undesirables.com\n * @see https://github.com/sailorpepe/elizaos-tcg-oracle-plugin\n */\n\nimport { validateTcgOracleConfig } from \"./environment.js\";\nimport { MarketMonitorService } from \"./services.js\";\n\nimport type {\n Plugin,\n Action,\n Provider,\n IAgentRuntime,\n Memory,\n State,\n HandlerCallback,\n ActionExample,\n ActionResult,\n ProviderResult,\n} from \"@elizaos/core\";\n\n// ============================================================\n// Configuration\n// ============================================================\n\nconst SUPPORTED_GAMES = [\n \"Pokemon\",\n \"Magic: The Gathering\",\n \"Yu-Gi-Oh!\",\n \"Lorcana\",\n \"One Piece\",\n \"Flesh and Blood\",\n \"Star Wars: Unlimited\",\n \"Dragon Ball Super\",\n \"Digimon\",\n \"MetaZoo\",\n \"Union Arena\",\n \"Gundam Card Game\",\n \"LoL Riftbound\",\n] as const;\n\nconst SIMULATION_MODELS = [\"heston\", \"merton\", \"kou\"] as const;\n\n// ============================================================\n// API Client\n// ============================================================\n\nfunction getBaseUrl(runtime: IAgentRuntime): string {\n return (\n (runtime.getSetting?.(\"TCG_ORACLE_URL\") as string) ||\n process.env.TCG_ORACLE_URL ||\n \"\"\n );\n}\n\nasync function callApi(\n baseUrl: string,\n endpoint: string,\n params: Record<string, string | number>\n): Promise<{ data?: any; error?: string }> {\n if (!baseUrl) {\n return {\n error:\n \"TCG_ORACLE_URL not set. Set it in your character.json settings or as an environment variable. Install the server: pip install undesirables-mcp-server\",\n };\n }\n\n const url = new URL(`${baseUrl}${endpoint}`);\n for (const [key, value] of Object.entries(params)) {\n if (value !== undefined && value !== null && value !== \"\") {\n url.searchParams.set(key, String(value));\n }\n }\n\n try {\n const controller = new AbortController();\n const timeout = setTimeout(() => controller.abort(), 30_000);\n\n const response = await fetch(url.toString(), {\n signal: controller.signal,\n headers: { \"User-Agent\": \"elizaos-tcg-oracle-plugin/1.0.0\" },\n });\n clearTimeout(timeout);\n\n if (!response.ok) {\n return { error: `API returned HTTP ${response.status}` };\n }\n\n const json = (await response.json()) as Record<string, any>;\n return { data: json.data || json };\n } catch (err: any) {\n if (err.name === \"AbortError\") {\n return { error: \"TCG Oracle API timed out (30s)\" };\n }\n return {\n error: \"Failed to connect to TCG Oracle API. Is the server running?\",\n };\n }\n}\n\n// ============================================================\n// Helper: Truncate data safely before JSON.stringify\n// ============================================================\n\nfunction safeStringify(data: any, maxItems = 10): string {\n if (Array.isArray(data)) {\n return JSON.stringify(data.slice(0, maxItems), null, 2);\n }\n return JSON.stringify(data, null, 2).slice(0, 2000);\n}\n\n// ============================================================\n// ACTION 1: Search TCG Products\n// ============================================================\n\nconst searchAction: Action = {\n name: \"TCG_ORACLE_SEARCH\",\n description:\n \"Search for trading card products across 25 games including Pokemon, Magic: The Gathering, Yu-Gi-Oh, Lorcana, One Piece, and more. Returns product names, set info, and current market prices from 370K+ real products sourced from TCGCSV daily.\",\n similes: [\n \"SEARCH_CARDS\",\n \"FIND_CARD\",\n \"CARD_LOOKUP\",\n \"CARD_SEARCH\",\n \"TCG_SEARCH\",\n \"FIND_POKEMON\",\n \"SEARCH_MTG\",\n ],\n parameters: [\n {\n name: \"query\",\n description: \"The card name, set name, or keyword to search for (e.g., 'Charizard', 'Base Set', 'Pikachu VMAX')\",\n required: true,\n schema: { type: \"string\" },\n },\n {\n name: \"limit\",\n description: \"Maximum number of results to return (default: 10, max: 50)\",\n required: false,\n schema: { type: \"number\" },\n },\n ],\n examples: [\n [\n { name: \"{{user1}}\", content: { text: \"Search for Charizard cards\" } } as ActionExample,\n { name: \"{{agentName}}\", content: { text: \"Searching TCG Oracle for Charizard...\", action: \"TCG_ORACLE_SEARCH\" } } as ActionExample,\n ],\n [\n { name: \"{{user1}}\", content: { text: \"What Pikachu VMAX cards are available?\" } } as ActionExample,\n { name: \"{{agentName}}\", content: { text: \"Looking up Pikachu VMAX products...\", action: \"TCG_ORACLE_SEARCH\" } } as ActionExample,\n ],\n [\n { name: \"{{user1}}\", content: { text: \"Find me Base Set holographic cards\" } } as ActionExample,\n { name: \"{{agentName}}\", content: { text: \"Searching for Base Set holographic cards...\", action: \"TCG_ORACLE_SEARCH\" } } as ActionExample,\n ],\n ],\n validate: async (runtime: IAgentRuntime) => {\n return !!getBaseUrl(runtime);\n },\n handler: async (\n runtime: IAgentRuntime,\n message: Memory,\n _state?: State,\n _options?: Record<string, unknown>,\n callback?: HandlerCallback\n ): Promise<ActionResult | undefined> => {\n const text = message.content.text || \"\";\n\n // Extract search query — strip common prefixes\n const query = text\n .replace(/^(search|find|look up|lookup|what|show me)\\s+(for\\s+)?/i, \"\")\n .replace(/\\s+cards?\\s*$/i, \"\")\n .trim();\n\n if (!query) {\n if (callback) await callback({ text: \"What card would you like me to search for?\" });\n return { success: false, error: \"No search query provided\" };\n }\n\n const result = await callApi(getBaseUrl(runtime), \"/api/v1/search\", {\n query,\n limit: 10,\n });\n\n if (result.error) {\n if (callback) await callback({ text: `Search failed: ${result.error}` });\n return { success: false, error: result.error };\n }\n\n const summary = safeStringify(result.data);\n const responseText = `Found products matching \"${query}\":\\n\\n${summary}`;\n\n if (callback) await callback({ text: responseText }, \"TCG_ORACLE_SEARCH\");\n return { success: true, text: responseText, data: { search_results: result.data } };\n },\n};\n\n// ============================================================\n// ACTION 2: AI Card Grading\n// ============================================================\n\nconst gradeAction: Action = {\n name: \"TCG_ORACLE_GRADE\",\n description:\n \"Grade a TCG card image using AI vision (Qwen VL model running locally). Predicts PSA and Beckett grading scores by analyzing centering, corners, edges, surface condition, and print quality. Works with Pokemon, MTG, Yu-Gi-Oh, and other TCG cards.\",\n similes: [\n \"GRADE_CARD\",\n \"CARD_GRADING\",\n \"PSA_GRADE\",\n \"BECKETT_GRADE\",\n \"RATE_CARD\",\n \"EVALUATE_CARD\",\n ],\n parameters: [\n {\n name: \"image_url\",\n description: \"Direct URL to the card image (PNG, JPG, or WebP)\",\n required: true,\n schema: { type: \"string\" },\n },\n {\n name: \"game\",\n description: \"The TCG game this card belongs to (default: Pokemon)\",\n required: false,\n schema: { type: \"string\" },\n },\n ],\n examples: [\n [\n { name: \"{{user1}}\", content: { text: \"Grade this card: https://example.com/charizard.jpg\" } } as ActionExample,\n { name: \"{{agentName}}\", content: { text: \"Analyzing card image for grading...\", action: \"TCG_ORACLE_GRADE\" } } as ActionExample,\n ],\n [\n { name: \"{{user1}}\", content: { text: \"What PSA grade would this get? https://i.imgur.com/card.png\" } } as ActionExample,\n { name: \"{{agentName}}\", content: { text: \"Running AI vision grading analysis...\", action: \"TCG_ORACLE_GRADE\" } } as ActionExample,\n ],\n [\n { name: \"{{user1}}\", content: { text: \"Rate the condition of this Magic card https://example.com/mtg.jpg\" } } as ActionExample,\n { name: \"{{agentName}}\", content: { text: \"Evaluating card condition for Beckett grading...\", action: \"TCG_ORACLE_GRADE\" } } as ActionExample,\n ],\n ],\n validate: async (runtime: IAgentRuntime) => !!getBaseUrl(runtime),\n handler: async (\n runtime: IAgentRuntime,\n message: Memory,\n _state?: State,\n _options?: Record<string, unknown>,\n callback?: HandlerCallback\n ): Promise<ActionResult | undefined> => {\n const text = message.content.text || \"\";\n\n // Extract URL from message\n const urlMatch = text.match(/https?:\\/\\/[^\\s]+/);\n if (!urlMatch) {\n if (callback) await callback({ text: \"Please provide a card image URL to grade.\" });\n return { success: false, error: \"No image URL found in message\" };\n }\n\n const result = await callApi(getBaseUrl(runtime), \"/api/v1/grade\", {\n image_url: urlMatch[0],\n game: \"Pokemon\",\n });\n\n if (result.error) {\n if (callback) await callback({ text: `Grading failed: ${result.error}` });\n return { success: false, error: result.error };\n }\n\n const summary = safeStringify(result.data);\n const responseText = `Card grading complete:\\n\\n${summary}`;\n\n if (callback) await callback({ text: responseText }, \"TCG_ORACLE_GRADE\");\n return { success: true, text: responseText, data: { grade_result: result.data } };\n },\n};\n\n// ============================================================\n// ACTION 3: Monte Carlo Price Simulation\n// ============================================================\n\nconst simulateAction: Action = {\n name: \"TCG_ORACLE_SIMULATE\",\n description:\n \"Run Monte Carlo simulation on a TCG card's price to predict future value. Uses real drift and volatility computed from TCGCSV historical data. Supports three stochastic models: Heston (stochastic volatility), Merton (jump-diffusion), and Kou (double-exponential jumps). Returns percentile bands (5th, 25th, 50th, 75th, 95th) for the forecast period.\",\n similes: [\n \"SIMULATE_PRICE\",\n \"PRICE_PREDICTION\",\n \"FORECAST_PRICE\",\n \"MONTE_CARLO\",\n \"PRICE_FORECAST\",\n \"WHAT_WILL_THIS_BE_WORTH\",\n ],\n parameters: [\n {\n name: \"card_name\",\n description: \"Name of the card to simulate\",\n required: true,\n schema: { type: \"string\" },\n },\n {\n name: \"current_price\",\n description: \"Current price in USD\",\n required: true,\n schema: { type: \"number\" },\n },\n {\n name: \"model\",\n description: \"Stochastic model: 'heston', 'merton', or 'kou'\",\n required: false,\n schema: { type: \"string\", enumValues: [\"heston\", \"merton\", \"kou\"] },\n },\n {\n name: \"days\",\n description: \"Forecast horizon in days (default: 30)\",\n required: false,\n schema: { type: \"number\" },\n },\n ],\n examples: [\n [\n { name: \"{{user1}}\", content: { text: \"Simulate the price of Charizard VMAX at $350 for 60 days\" } } as ActionExample,\n { name: \"{{agentName}}\", content: { text: \"Running Monte Carlo simulation on Charizard VMAX...\", action: \"TCG_ORACLE_SIMULATE\" } } as ActionExample,\n ],\n [\n { name: \"{{user1}}\", content: { text: \"What will a PSA 10 Base Set Blastoise worth $800 be in 90 days using merton model?\" } } as ActionExample,\n { name: \"{{agentName}}\", content: { text: \"Running Merton jump-diffusion simulation for Blastoise...\", action: \"TCG_ORACLE_SIMULATE\" } } as ActionExample,\n ],\n [\n { name: \"{{user1}}\", content: { text: \"Forecast Lorcana Elsa at $25 for 30 days\" } } as ActionExample,\n { name: \"{{agentName}}\", content: { text: \"Simulating Lorcana Elsa price trajectory...\", action: \"TCG_ORACLE_SIMULATE\" } } as ActionExample,\n ],\n ],\n validate: async (runtime: IAgentRuntime) => !!getBaseUrl(runtime),\n handler: async (\n runtime: IAgentRuntime,\n message: Memory,\n _state?: State,\n options?: Record<string, unknown>,\n callback?: HandlerCallback\n ): Promise<ActionResult | undefined> => {\n const text = message.content.text || \"\";\n\n // Try to extract parameters from text\n const priceMatch = text.match(/\\$?([\\d,]+(?:\\.\\d{2})?)/);\n const daysMatch = text.match(/(\\d+)\\s*days?/i);\n const modelMatch = text.match(/\\b(heston|merton|kou)\\b/i);\n\n const cardName =\n text\n .replace(/simulate|price|forecast|monte carlo|at|\\$[\\d,.]+|\\d+\\s*days?|heston|merton|kou/gi, \"\")\n .replace(/\\s+/g, \" \")\n .trim() || \"Unknown Card\";\n\n const currentPrice = priceMatch ? parseFloat(priceMatch[1].replace(\",\", \"\")) : 0;\n const days = daysMatch ? parseInt(daysMatch[1]) : 30;\n const model = modelMatch ? modelMatch[1].toLowerCase() : \"heston\";\n\n if (currentPrice <= 0) {\n if (callback) await callback({ text: \"Please provide a current price for the simulation. Example: 'Simulate Charizard VMAX at $350 for 60 days'\" });\n return { success: false, error: \"Invalid or missing current price\" };\n }\n\n const result = await callApi(getBaseUrl(runtime), \"/api/v1/simulate\", {\n card_name: cardName,\n current_price: currentPrice,\n model,\n days,\n simulations: 10000,\n });\n\n if (result.error) {\n if (callback) await callback({ text: `Simulation failed: ${result.error}` });\n return { success: false, error: result.error };\n }\n\n const summary = safeStringify(result.data);\n const responseText = `Monte Carlo simulation for ${cardName} ($${currentPrice}, ${model} model, ${days} days):\\n\\n${summary}`;\n\n if (callback) await callback({ text: responseText }, \"TCG_ORACLE_SIMULATE\");\n return { success: true, text: responseText, data: { simulation_result: result.data } };\n },\n};\n\n// ============================================================\n// ACTION 4: Market Snapshot\n// ============================================================\n\nconst marketAction: Action = {\n name: \"TCG_ORACLE_MARKET\",\n description:\n \"Retrieve the latest daily market data snapshot from TCGCSV for a specific game. Returns top movers, price changes, volume data, and market trends. Data is refreshed daily via automated pipeline.\",\n similes: [\n \"MARKET_SNAPSHOT\",\n \"MARKET_DATA\",\n \"TCG_MARKET\",\n \"CARD_MARKET\",\n \"TOP_MOVERS\",\n \"PRICE_CHANGES\",\n ],\n parameters: [\n {\n name: \"game\",\n description: \"Game name: Pokemon, Magic: The Gathering, Yu-Gi-Oh, Lorcana, One Piece, etc\",\n required: false,\n schema: { type: \"string\" },\n },\n ],\n examples: [\n [\n { name: \"{{user1}}\", content: { text: \"Show me the Pokemon market snapshot\" } } as ActionExample,\n { name: \"{{agentName}}\", content: { text: \"Pulling the latest Pokemon market data...\", action: \"TCG_ORACLE_MARKET\" } } as ActionExample,\n ],\n [\n { name: \"{{user1}}\", content: { text: \"What's happening in the Yu-Gi-Oh market today?\" } } as ActionExample,\n { name: \"{{agentName}}\", content: { text: \"Fetching Yu-Gi-Oh market snapshot...\", action: \"TCG_ORACLE_MARKET\" } } as ActionExample,\n ],\n [\n { name: \"{{user1}}\", content: { text: \"Top movers in Magic: The Gathering\" } } as ActionExample,\n { name: \"{{agentName}}\", content: { text: \"Pulling Magic: The Gathering market data...\", action: \"TCG_ORACLE_MARKET\" } } as ActionExample,\n ],\n ],\n validate: async (runtime: IAgentRuntime) => !!getBaseUrl(runtime),\n handler: async (\n runtime: IAgentRuntime,\n message: Memory,\n _state?: State,\n _options?: Record<string, unknown>,\n callback?: HandlerCallback\n ): Promise<ActionResult | undefined> => {\n const text = message.content.text?.toLowerCase() || \"\";\n\n // Detect game from message\n let game = \"Pokemon\";\n for (const g of SUPPORTED_GAMES) {\n if (text.includes(g.toLowerCase())) {\n game = g;\n break;\n }\n }\n\n const result = await callApi(getBaseUrl(runtime), \"/api/v1/market\", { game });\n\n if (result.error) {\n if (callback) await callback({ text: `Market data failed: ${result.error}` });\n return { success: false, error: result.error };\n }\n\n const summary = safeStringify(result.data, 25);\n const responseText = `Market snapshot for ${game}:\\n\\n${summary}`;\n\n if (callback) await callback({ text: responseText }, \"TCG_ORACLE_MARKET\");\n return { success: true, text: responseText, data: { market_data: result.data } };\n },\n};\n\n// ============================================================\n// ACTION 5: Grade-or-Not Decision Engine\n// ============================================================\n\nconst gradeOrNotAction: Action = {\n name: \"TCG_ORACLE_GRADE_OR_NOT\",\n description:\n \"Answers 'will grading this card make me money?' by combining AI grade prediction with PSA fee schedules, shipping costs, and graded market values. Returns a GO/NO-GO verdict with expected ROI and profit scenarios (best case, predicted, worst case).\",\n similes: [\n \"SHOULD_I_GRADE\",\n \"GRADE_ROI\",\n \"GRADING_PROFIT\",\n \"IS_IT_WORTH_GRADING\",\n \"GRADE_OR_NOT\",\n ],\n parameters: [\n {\n name: \"card_name\",\n description: \"Name of the card to evaluate (e.g., 'Base Set Charizard Holo')\",\n required: true,\n schema: { type: \"string\" },\n },\n {\n name: \"predicted_grade\",\n description: \"Your predicted PSA grade (0 = auto-estimate)\",\n required: false,\n schema: { type: \"number\" },\n },\n {\n name: \"raw_price\",\n description: \"Current raw card value in USD (0 = auto-lookup)\",\n required: false,\n schema: { type: \"number\" },\n },\n ],\n examples: [\n [\n { name: \"{{user1}}\", content: { text: \"Should I grade my Base Set Charizard?\" } } as ActionExample,\n { name: \"{{agentName}}\", content: { text: \"Running Grade-or-Not analysis...\", action: \"TCG_ORACLE_GRADE_OR_NOT\" } } as ActionExample,\n ],\n [\n { name: \"{{user1}}\", content: { text: \"Is it worth grading a PSA 8 Pikachu VMAX worth $45?\" } } as ActionExample,\n { name: \"{{agentName}}\", content: { text: \"Calculating grading ROI for Pikachu VMAX...\", action: \"TCG_ORACLE_GRADE_OR_NOT\" } } as ActionExample,\n ],\n ],\n validate: async (runtime: IAgentRuntime) => !!getBaseUrl(runtime),\n handler: async (\n runtime: IAgentRuntime,\n message: Memory,\n _state?: State,\n _options?: Record<string, unknown>,\n callback?: HandlerCallback\n ): Promise<ActionResult | undefined> => {\n const text = message.content.text || \"\";\n\n // Extract card name\n const cardName = text\n .replace(/^(should i|is it worth|grade or not|grading roi|will grading)\\s*/i, \"\")\n .replace(/\\s*(make me money|be profitable|worth it)\\s*\\??$/i, \"\")\n .replace(/^(grade|grading)\\s*/i, \"\")\n .replace(/\\bmy\\b/i, \"\")\n .trim() || \"Unknown Card\";\n\n // Extract price and grade if mentioned\n const priceMatch = text.match(/\\$?([\\d,]+(?:\\.\\d{2})?)/);\n const gradeMatch = text.match(/\\bpsa\\s*(\\d+(?:\\.\\d)?)\\b/i) || text.match(/\\bgrade\\s*(\\d+(?:\\.\\d)?)\\b/i);\n\n const params: Record<string, string | number> = { card_name: cardName };\n if (priceMatch) params.raw_price = parseFloat(priceMatch[1].replace(\",\", \"\"));\n if (gradeMatch) params.predicted_grade = parseFloat(gradeMatch[1]);\n\n const result = await callApi(getBaseUrl(runtime), \"/api/v1/grade-or-not\", params);\n\n if (result.error) {\n if (callback) await callback({ text: `Grade-or-Not analysis failed: ${result.error}` });\n return { success: false, error: result.error };\n }\n\n const data = result.data;\n const verdict = data?.verdict || \"Unknown\";\n const explanation = data?.explanation || \"\";\n const responseText = `Grade-or-Not verdict for ${cardName}:\\n\\n${verdict}\\n${explanation}\\n\\nFull analysis:\\n${safeStringify(data)}`;\n\n if (callback) await callback({ text: responseText }, \"TCG_ORACLE_GRADE_OR_NOT\");\n return { success: true, text: responseText, data: { grade_or_not: data } };\n },\n};\n\n// ============================================================\n// ACTION 6: Trending Cards\n// ============================================================\n\nconst trendingAction: Action = {\n name: \"TCG_ORACLE_TRENDING\",\n description:\n \"Returns the top trending trading cards by market activity (30-day sales volume, views, and price velocity). Covers all 25 supported TCG games. Useful for spotting market momentum and emerging opportunities.\",\n similes: [\n \"TRENDING_CARDS\",\n \"HOT_CARDS\",\n \"TOP_MOVERS\",\n \"WHATS_TRENDING\",\n \"POPULAR_CARDS\",\n \"MARKET_TRENDS\",\n ],\n parameters: [\n {\n name: \"game\",\n description: \"Filter by game name (empty = all games)\",\n required: false,\n schema: { type: \"string\" },\n },\n {\n name: \"limit\",\n description: \"Number of results (default: 25, max: 100)\",\n required: false,\n schema: { type: \"number\" },\n },\n ],\n examples: [\n [\n { name: \"{{user1}}\", content: { text: \"What Pokemon cards are trending right now?\" } } as ActionExample,\n { name: \"{{agentName}}\", content: { text: \"Pulling trending Pokemon cards...\", action: \"TCG_ORACLE_TRENDING\" } } as ActionExample,\n ],\n [\n { name: \"{{user1}}\", content: { text: \"Show me the hottest cards across all games\" } } as ActionExample,\n { name: \"{{agentName}}\", content: { text: \"Fetching trending cards across all TCG games...\", action: \"TCG_ORACLE_TRENDING\" } } as ActionExample,\n ],\n ],\n validate: async (runtime: IAgentRuntime) => !!getBaseUrl(runtime),\n handler: async (\n runtime: IAgentRuntime,\n message: Memory,\n _state?: State,\n _options?: Record<string, unknown>,\n callback?: HandlerCallback\n ): Promise<ActionResult | undefined> => {\n const text = message.content?.text?.toLowerCase() || \"\";\n\n // Detect game from message\n let game = \"\";\n for (const g of SUPPORTED_GAMES) {\n if (text.includes(g.toLowerCase())) {\n game = g;\n break;\n }\n }\n\n const params: Record<string, string | number> = { limit: 25 };\n if (game) params.game = game;\n\n const result = await callApi(getBaseUrl(runtime), \"/api/v1/trending\", params);\n\n if (result.error) {\n if (callback) await callback({ text: `Trending cards failed: ${result.error}` });\n return { success: false, error: result.error };\n }\n\n const summary = safeStringify(result.data, 15);\n const responseText = `Trending cards${game ? ` for ${game}` : \" across all games\"}:\\n\\n${summary}`;\n\n if (callback) await callback({ text: responseText }, \"TCG_ORACLE_TRENDING\");\n return { success: true, text: responseText, data: { trending: result.data } };\n },\n};\n\n// ============================================================\n// ACTION 7: Raw Card Arbitrage Scanner\n// ============================================================\n\nconst arbGradeAction: Action = {\n name: \"TCG_ORACLE_ARB_GRADE\",\n description:\n \"Scans the TCG database for undervalued raw cards where grading would produce ROI above a threshold. Estimates PSA grades based on price tier and rarity, calculates expected graded values, and returns ranked opportunities sorted by expected profit.\",\n similes: [\n \"GRADING_ARBITRAGE\",\n \"FIND_UNDERVALUED\",\n \"ARBITRAGE_SCAN\",\n \"PROFITABLE_CARDS\",\n \"WHAT_TO_GRADE\",\n ],\n parameters: [\n {\n name: \"game\",\n description: \"TCG game to scan (default: Pokemon)\",\n required: false,\n schema: { type: \"string\" },\n },\n {\n name: \"min_roi\",\n description: \"Minimum expected ROI % to flag as opportunity (default: 50)\",\n required: false,\n schema: { type: \"number\" },\n },\n ],\n examples: [\n [\n { name: \"{{user1}}\", content: { text: \"Find me profitable Pokemon cards to grade\" } } as ActionExample,\n { name: \"{{agentName}}\", content: { text: \"Scanning for grading arbitrage opportunities...\", action: \"TCG_ORACLE_ARB_GRADE\" } } as ActionExample,\n ],\n [\n { name: \"{{user1}}\", content: { text: \"What Magic cards have the best grading ROI?\" } } as ActionExample,\n { name: \"{{agentName}}\", content: { text: \"Running arbitrage scanner on Magic: The Gathering...\", action: \"TCG_ORACLE_ARB_GRADE\" } } as ActionExample,\n ],\n ],\n validate: async (runtime: IAgentRuntime) => !!getBaseUrl(runtime),\n handler: async (\n runtime: IAgentRuntime,\n message: Memory,\n _state?: State,\n _options?: Record<string, unknown>,\n callback?: HandlerCallback\n ): Promise<ActionResult | undefined> => {\n const text = message.content?.text?.toLowerCase() || \"\";\n\n // Detect game from message\n let game = \"Pokemon\";\n for (const g of SUPPORTED_GAMES) {\n if (text.includes(g.toLowerCase())) {\n game = g;\n break;\n }\n }\n\n const params: Record<string, string | number> = {\n game,\n min_roi: 50,\n limit: 20,\n };\n\n const result = await callApi(getBaseUrl(runtime), \"/api/v1/arb-grade\", params);\n\n if (result.error) {\n if (callback) await callback({ text: `Arbitrage scan failed: ${result.error}` });\n return { success: false, error: result.error };\n }\n\n const summary = safeStringify(result.data, 15);\n const responseText = `Grading arbitrage opportunities for ${game}:\\n\\n${summary}`;\n\n if (callback) await callback({ text: responseText }, \"TCG_ORACLE_ARB_GRADE\");\n return { success: true, text: responseText, data: { arbitrage: result.data } };\n },\n};\n\n// ============================================================\n// PROVIDER: TCG Oracle Context\n// ============================================================\n\nconst tcgOracleProvider: Provider = {\n name: \"tcg-oracle\",\n description: \"Provides TCG Oracle market intelligence context to the agent\",\n get: async (\n runtime: IAgentRuntime,\n _message: Memory,\n _state: State\n ): Promise<ProviderResult> => {\n const baseUrl = getBaseUrl(runtime);\n const status = baseUrl ? \"connected\" : \"not configured\";\n\n return {\n text: `[TCG Oracle v1.1.0]\nStatus: ${status}\nDatabase: 370,158 products across 25 games\nData source: TCGCSV daily snapshots\nModels: Heston (stochastic vol), Merton (jump-diffusion), Kou (double-exp)\nActions: search, grade, simulate, market, grade-or-not, trending, arb-grade\nSupported games: ${SUPPORTED_GAMES.join(\", \")}\nAPI: ${baseUrl || \"TCG_ORACLE_URL not set\"}\n\nThe agent can search cards, grade card images, simulate prices via Monte Carlo, pull market snapshots, check grading ROI, view trending cards, and scan for grading arbitrage opportunities.`,\n values: {\n tcgOracleStatus: status,\n tcgOracleUrl: baseUrl || \"not set\",\n totalProducts: 370158,\n },\n };\n },\n};\n\n// ============================================================\n// PLUGIN EXPORT\n// ============================================================\n\nconst tcgOraclePlugin: Plugin = {\n name: \"@undesirables/plugin-tcg-oracle\",\n description:\n \"TCG Oracle — AI-powered trading card market intelligence for ElizaOS agents. \" +\n \"Covers 370K+ products across 25 games with Monte Carlo price simulation \" +\n \"(Heston/Merton/Kou), AI vision card grading with ROI analysis, \" +\n \"trending cards feed, grading arbitrage scanner, and real-time market snapshots. \" +\n \"Powered by TCGCSV daily data pipeline.\",\n init: async (config: Record<string, string>, runtime: IAgentRuntime) => {\n const validation = validateTcgOracleConfig(runtime);\n if (!validation.valid) {\n console.warn(`⚠️ TCG Oracle: ${validation.error}`);\n } else {\n console.log(`✅ TCG Oracle v1.1.0 connected to ${runtime.getSetting?.(\"TCG_ORACLE_URL\")}`);\n }\n },\n actions: [searchAction, gradeAction, simulateAction, marketAction, gradeOrNotAction, trendingAction, arbGradeAction],\n providers: [tcgOracleProvider],\n evaluators: [],\n services: [MarketMonitorService],\n};\n\nexport default tcgOraclePlugin;\nexport { SUPPORTED_GAMES, SIMULATION_MODELS };\n\n"],"mappings":";AAMO,SAAS,wBACd,SACoC;AACpC,QAAM,MACH,QAAQ,aAAa,gBAAgB,KACtC,QAAQ,IAAI,kBACZ;AAEF,MAAI,CAAC,KAAK;AACR,WAAO;AAAA,MACL,OAAO;AAAA,MACP,OACE;AAAA,IAEJ;AAAA,EACF;AAEA,MAAI;AACF,QAAI,IAAI,GAAG;AAAA,EACb,QAAQ;AACN,WAAO;AAAA,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AAM,eAAe,uCAAuC,IAAI;AAAA;AAAA,EAAQ,OAAO;AAE/E,QAAI,SAAU,OAAM,SAAS,EAAE,MAAM,aAAa,GAAG,sBAAsB;AAC3E,WAAO,EAAE,SAAS,MAAM,MAAM,cAAc,MAAM,EAAE,WAAW,OAAO,KAAK,EAAE;AAAA,EAC/E;AACF;AAMA,IAAM,oBAA8B;AAAA,EAClC,MAAM;AAAA,EACN,aAAa;AAAA,EACb,KAAK,OACH,SACA,UACA,WAC4B;AAC5B,UAAM,UAAU,WAAW,OAAO;AAClC,UAAM,SAAS,UAAU,cAAc;AAEvC,WAAO;AAAA,MACL,MAAM;AAAA,UACF,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA,mBAKG,gBAAgB,KAAK,IAAI,CAAC;AAAA,OACtC,WAAW,wBAAwB;AAAA;AAAA;AAAA,MAGpC,QAAQ;AAAA,QACN,iBAAiB;AAAA,QACjB,cAAc,WAAW;AAAA,QACzB,eAAe;AAAA,MACjB;AAAA,IACF;AAAA,EACF;AACF;AAMA,IAAM,kBAA0B;AAAA,EAC9B,MAAM;AAAA,EACN,aACE;AAAA,EAKF,MAAM,OAAO,QAAgC,YAA2B;AACtE,UAAM,aAAa,wBAAwB,OAAO;AAClD,QAAI,CAAC,WAAW,OAAO;AACrB,cAAQ,KAAK,4BAAkB,WAAW,KAAK,EAAE;AAAA,IACnD,OAAO;AACL,cAAQ,IAAI,yCAAoC,QAAQ,aAAa,gBAAgB,CAAC,EAAE;AAAA,IAC1F;AAAA,EACF;AAAA,EACA,SAAS,CAAC,cAAc,aAAa,gBAAgB,cAAc,kBAAkB,gBAAgB,cAAc;AAAA,EACnH,WAAW,CAAC,iBAAiB;AAAA,EAC7B,YAAY,CAAC;AAAA,EACb,UAAU,CAAC,oBAAoB;AACjC;AAEA,IAAO,gBAAQ;","names":[]}
1
+ {"version":3,"sources":["../src/environment.ts","../src/services.ts","../src/index.ts"],"sourcesContent":["import type { IAgentRuntime } from \"@elizaos/core\";\n\n/**\n * Validates that the TCG Oracle plugin has all required configuration.\n * Called during plugin init and before each action.\n */\nexport function validateTcgOracleConfig(\n runtime: IAgentRuntime\n): { valid: boolean; error?: string } {\n const url =\n (runtime.getSetting?.(\"TCG_ORACLE_URL\") as string) ||\n process.env.TCG_ORACLE_URL ||\n \"\";\n\n if (!url) {\n return {\n valid: false,\n error:\n \"TCG_ORACLE_URL is required. Set it in your character.json settings \" +\n \"or as an environment variable. Example: https://oracle.the-undesirables.com\",\n };\n }\n\n try {\n new URL(url);\n } catch {\n return {\n valid: false,\n error: `TCG_ORACLE_URL is not a valid URL: \"${url}\"`,\n };\n }\n\n return { valid: true };\n}\n","import { Service, IAgentRuntime } from \"@elizaos/core\";\n\nexport class MarketMonitorService extends Service {\n // Use a string getter to satisfy ElizaOS ServiceType constraints if needed,\n // or define static serviceType depending on the core version.\n static serviceType = \"TCG_MARKET_MONITOR\";\n\n get capabilityDescription(): string {\n return \"Monitors TCG market data for price spikes and trending cards\";\n }\n\n static async start(runtime: IAgentRuntime): Promise<MarketMonitorService> {\n const service = new MarketMonitorService();\n await service.initialize(runtime);\n return service;\n }\n\n private monitorInterval: NodeJS.Timeout | null = null;\n\n async initialize(_runtime: IAgentRuntime): Promise<void> {\n console.log(\"[TCG Oracle Service] Market Monitor Service initialized.\");\n // Example: Start background polling for market spikes every hour\n // this.monitorInterval = setInterval(() => this.pollMarket(), 1000 * 60 * 60);\n }\n\n async stop(): Promise<void> {\n if (this.monitorInterval) {\n clearInterval(this.monitorInterval);\n }\n console.log(\"[TCG Oracle Service] Market Monitor Service stopped.\");\n }\n\n private pollMarket() {\n console.log(\"[TCG Oracle Service] Background task: Polling TCG market for price spikes...\");\n }\n}\n","/**\n * TCG Oracle — ElizaOS Plugin v2.0.2\n * ====================================\n * AI-powered trading card market intelligence for ElizaOS agents.\n * Native TypeScript rewrite of the Python G.A.M.E. SDK version.\n *\n * Features:\n * - Search 455K+ TCG products across 25+ games (Pokemon, MTG, Yu-Gi-Oh, etc.)\n * - Japanese two-sided dealer board summary, graded-slab loan terms, daily sports movers board\n * - AI Vision card grading (PSA/Beckett prediction via Qwen VL)\n * - Conformal-calibrated risk forecasts (honest VaR + Safe-Hold/Momentum grades);\n * Monte Carlo (GBM/Merton) opt-in via the model parameter\n * - Market snapshots / simulate / trending: SUSPENDED since the USD panel froze 2026-09-07\n * (the oracle answers {\"status\":\"suspended\"} and never charges) — actions surface that honestly\n * - License key purchase & verification (Ethereum NFT)\n *\n * @see https://the-undesirables.com\n * @see https://github.com/sailorpepe/elizaos-tcg-oracle-plugin\n */\n\nimport { validateTcgOracleConfig } from \"./environment.js\";\nimport { MarketMonitorService } from \"./services.js\";\n\nimport type {\n Plugin,\n Action,\n Provider,\n IAgentRuntime,\n Memory,\n State,\n HandlerCallback,\n ActionExample,\n ActionResult,\n ProviderResult,\n} from \"@elizaos/core\";\n\n// ============================================================\n// Configuration\n// ============================================================\n\nconst SUPPORTED_GAMES = [\n \"Pokemon\",\n \"Magic: The Gathering\",\n \"Yu-Gi-Oh!\",\n \"Lorcana\",\n \"One Piece\",\n \"Flesh and Blood\",\n \"Star Wars: Unlimited\",\n \"Dragon Ball Super\",\n \"Digimon\",\n \"MetaZoo\",\n \"Union Arena\",\n \"Gundam Card Game\",\n \"LoL Riftbound\",\n] as const;\n\nconst SIMULATION_MODELS = [\"conformal\", \"merton\", \"gbm\"] as const;\n\n// ============================================================\n// API Client\n// ============================================================\n\nfunction getBaseUrl(runtime: IAgentRuntime): string {\n return (\n (runtime.getSetting?.(\"TCG_ORACLE_URL\") as string) ||\n process.env.TCG_ORACLE_URL ||\n \"\"\n );\n}\n\nasync function callApi(\n baseUrl: string,\n endpoint: string,\n params: Record<string, string | number>\n): Promise<{ data?: any; error?: string }> {\n if (!baseUrl) {\n return {\n error:\n \"TCG_ORACLE_URL not set. Set it in your character.json settings or as an environment variable. Install the server: pip install undesirables-mcp-server\",\n };\n }\n\n const url = new URL(`${baseUrl}${endpoint}`);\n for (const [key, value] of Object.entries(params)) {\n if (value !== undefined && value !== null && value !== \"\") {\n url.searchParams.set(key, String(value));\n }\n }\n\n try {\n const controller = new AbortController();\n const timeout = setTimeout(() => controller.abort(), 30_000);\n\n const response = await fetch(url.toString(), {\n signal: controller.signal,\n headers: { \"User-Agent\": \"elizaos-tcg-oracle-plugin/2.0.2\" },\n });\n clearTimeout(timeout);\n\n if (!response.ok) {\n return { error: `API returned HTTP ${response.status}` };\n }\n\n const json = (await response.json()) as Record<string, any>;\n if (json && json.status === \"suspended\") {\n const alts = json.alternatives\n ? Object.entries(json.alternatives as Record<string, string>)\n .map(([k, v]) => `${k}: ${v}`)\n .join(\"; \")\n : \"\";\n return {\n error:\n `${endpoint} is SUSPENDED (not charged). ${json.reason || \"\"} ` +\n `Resumes when: ${json.resumes_when || \"unknown\"}.` +\n (alts ? ` Live alternatives — ${alts}` : \"\"),\n };\n }\n return { data: json.data || json };\n } catch (err: any) {\n if (err.name === \"AbortError\") {\n return { error: \"TCG Oracle API timed out (30s)\" };\n }\n return {\n error: \"Failed to connect to TCG Oracle API. Is the server running?\",\n };\n }\n}\n\n// ============================================================\n// Helper: Truncate data safely before JSON.stringify\n// ============================================================\n\nfunction safeStringify(data: any, maxItems = 10): string {\n if (Array.isArray(data)) {\n return JSON.stringify(data.slice(0, maxItems), null, 2);\n }\n return JSON.stringify(data, null, 2).slice(0, 2000);\n}\n\n// ============================================================\n// ACTION 1: Search TCG Products\n// ============================================================\n\nconst searchAction: Action = {\n name: \"TCG_ORACLE_SEARCH\",\n description:\n \"Search for trading card products across 25+ games including Pokemon, Magic: The Gathering, Yu-Gi-Oh, Lorcana, One Piece, and more. Returns product names, set info, and the last published USD price (the USD panel froze 2026-09-07 and every row says so in-band) from 455K+ real products.\",\n similes: [\n \"SEARCH_CARDS\",\n \"FIND_CARD\",\n \"CARD_LOOKUP\",\n \"CARD_SEARCH\",\n \"TCG_SEARCH\",\n \"FIND_POKEMON\",\n \"SEARCH_MTG\",\n ],\n parameters: [\n {\n name: \"query\",\n description: \"The card name, set name, or keyword to search for (e.g., 'Charizard', 'Base Set', 'Pikachu VMAX')\",\n required: true,\n schema: { type: \"string\" },\n },\n {\n name: \"limit\",\n description: \"Maximum number of results to return (default: 10, max: 50)\",\n required: false,\n schema: { type: \"number\" },\n },\n ],\n examples: [\n [\n { name: \"{{user1}}\", content: { text: \"Search for Charizard cards\" } } as ActionExample,\n { name: \"{{agentName}}\", content: { text: \"Searching TCG Oracle for Charizard...\", action: \"TCG_ORACLE_SEARCH\" } } as ActionExample,\n ],\n [\n { name: \"{{user1}}\", content: { text: \"What Pikachu VMAX cards are available?\" } } as ActionExample,\n { name: \"{{agentName}}\", content: { text: \"Looking up Pikachu VMAX products...\", action: \"TCG_ORACLE_SEARCH\" } } as ActionExample,\n ],\n [\n { name: \"{{user1}}\", content: { text: \"Find me Base Set holographic cards\" } } as ActionExample,\n { name: \"{{agentName}}\", content: { text: \"Searching for Base Set holographic cards...\", action: \"TCG_ORACLE_SEARCH\" } } as ActionExample,\n ],\n ],\n validate: async (runtime: IAgentRuntime) => {\n return !!getBaseUrl(runtime);\n },\n handler: async (\n runtime: IAgentRuntime,\n message: Memory,\n _state?: State,\n _options?: Record<string, unknown>,\n callback?: HandlerCallback\n ): Promise<ActionResult | undefined> => {\n const text = message.content.text || \"\";\n\n // Extract search query — strip common prefixes\n const query = text\n .replace(/^(search|find|look up|lookup|what|show me)\\s+(for\\s+)?/i, \"\")\n .replace(/\\s+cards?\\s*$/i, \"\")\n .trim();\n\n if (!query) {\n if (callback) await callback({ text: \"What card would you like me to search for?\" });\n return { success: false, error: \"No search query provided\" };\n }\n\n const result = await callApi(getBaseUrl(runtime), \"/api/v1/search\", {\n query,\n limit: 10,\n });\n\n if (result.error) {\n if (callback) await callback({ text: `Search failed: ${result.error}` });\n return { success: false, error: result.error };\n }\n\n const summary = safeStringify(result.data);\n const responseText = `Found products matching \"${query}\":\\n\\n${summary}`;\n\n if (callback) await callback({ text: responseText }, \"TCG_ORACLE_SEARCH\");\n return { success: true, text: responseText, data: { search_results: result.data } };\n },\n};\n\n// ============================================================\n// ACTION 2: AI Card Grading\n// ============================================================\n\nconst gradeAction: Action = {\n name: \"TCG_ORACLE_GRADE\",\n description:\n \"Grade a TCG card image using AI vision (Qwen VL model running locally). Predicts PSA and Beckett grading scores by analyzing centering, corners, edges, surface condition, and print quality. Works with Pokemon, MTG, Yu-Gi-Oh, and other TCG cards.\",\n similes: [\n \"GRADE_CARD\",\n \"CARD_GRADING\",\n \"PSA_GRADE\",\n \"BECKETT_GRADE\",\n \"RATE_CARD\",\n \"EVALUATE_CARD\",\n ],\n parameters: [\n {\n name: \"image_url\",\n description: \"Direct URL to the card image (PNG, JPG, or WebP)\",\n required: true,\n schema: { type: \"string\" },\n },\n {\n name: \"game\",\n description: \"The TCG game this card belongs to (default: Pokemon)\",\n required: false,\n schema: { type: \"string\" },\n },\n ],\n examples: [\n [\n { name: \"{{user1}}\", content: { text: \"Grade this card: https://example.com/charizard.jpg\" } } as ActionExample,\n { name: \"{{agentName}}\", content: { text: \"Analyzing card image for grading...\", action: \"TCG_ORACLE_GRADE\" } } as ActionExample,\n ],\n [\n { name: \"{{user1}}\", content: { text: \"What PSA grade would this get? https://i.imgur.com/card.png\" } } as ActionExample,\n { name: \"{{agentName}}\", content: { text: \"Running AI vision grading analysis...\", action: \"TCG_ORACLE_GRADE\" } } as ActionExample,\n ],\n [\n { name: \"{{user1}}\", content: { text: \"Rate the condition of this Magic card https://example.com/mtg.jpg\" } } as ActionExample,\n { name: \"{{agentName}}\", content: { text: \"Evaluating card condition for Beckett grading...\", action: \"TCG_ORACLE_GRADE\" } } as ActionExample,\n ],\n ],\n validate: async (runtime: IAgentRuntime) => !!getBaseUrl(runtime),\n handler: async (\n runtime: IAgentRuntime,\n message: Memory,\n _state?: State,\n _options?: Record<string, unknown>,\n callback?: HandlerCallback\n ): Promise<ActionResult | undefined> => {\n const text = message.content.text || \"\";\n\n // Extract URL from message\n const urlMatch = text.match(/https?:\\/\\/[^\\s]+/);\n if (!urlMatch) {\n if (callback) await callback({ text: \"Please provide a card image URL to grade.\" });\n return { success: false, error: \"No image URL found in message\" };\n }\n\n const result = await callApi(getBaseUrl(runtime), \"/api/v1/grade\", {\n image_url: urlMatch[0],\n game: \"Pokemon\",\n });\n\n if (result.error) {\n if (callback) await callback({ text: `Grading failed: ${result.error}` });\n return { success: false, error: result.error };\n }\n\n const summary = safeStringify(result.data);\n const responseText = `Card grading complete:\\n\\n${summary}`;\n\n if (callback) await callback({ text: responseText }, \"TCG_ORACLE_GRADE\");\n return { success: true, text: responseText, data: { grade_result: result.data } };\n },\n};\n\n// ============================================================\n// ACTION 3: Conformal-Calibrated Price Forecast (Monte Carlo opt-in)\n// ============================================================\n\nconst simulateAction: Action = {\n name: \"TCG_ORACLE_SIMULATE\",\n description:\n \"SUSPENDED since 2026-09-07 (frozen USD panel; the oracle returns status=suspended and does not charge — the action reports that). Was: forecast a TCG card's future value with a conformal-calibrated risk model — honest VaR plus Safe-Hold/Momentum letter grades. Monte Carlo (GBM/Merton) is opt-in via the model parameter. Uses real drift and volatility computed from the historical USD panel. Monte Carlo models available opt-in: merton (jump-diffusion) and gbm. Returns percentile bands (5th, 25th, 50th, 75th, 95th) for the forecast period.\",\n similes: [\n \"SIMULATE_PRICE\",\n \"PRICE_PREDICTION\",\n \"FORECAST_PRICE\",\n \"MONTE_CARLO\",\n \"PRICE_FORECAST\",\n \"WHAT_WILL_THIS_BE_WORTH\",\n ],\n parameters: [\n {\n name: \"card_name\",\n description: \"Name of the card to simulate\",\n required: true,\n schema: { type: \"string\" },\n },\n {\n name: \"current_price\",\n description: \"Current price in USD\",\n required: true,\n schema: { type: \"number\" },\n },\n {\n name: \"model\",\n description: \"Forecast model (default 'conformal'): 'conformal' (regime-aware split-conformal bands, honest calibrated VaR), or opt into Monte Carlo with 'merton' (jump-diffusion) or 'gbm'\",\n required: false,\n schema: { type: \"string\", enumValues: [\"conformal\", \"merton\", \"gbm\"] },\n },\n {\n name: \"days\",\n description: \"Forecast horizon in days (default: 30)\",\n required: false,\n schema: { type: \"number\" },\n },\n ],\n examples: [\n [\n { name: \"{{user1}}\", content: { text: \"Simulate the price of Charizard VMAX at $350 for 60 days\" } } as ActionExample,\n { name: \"{{agentName}}\", content: { text: \"Running Monte Carlo simulation on Charizard VMAX...\", action: \"TCG_ORACLE_SIMULATE\" } } as ActionExample,\n ],\n [\n { name: \"{{user1}}\", content: { text: \"What will a PSA 10 Base Set Blastoise worth $800 be in 90 days using merton model?\" } } as ActionExample,\n { name: \"{{agentName}}\", content: { text: \"Running Merton jump-diffusion simulation for Blastoise...\", action: \"TCG_ORACLE_SIMULATE\" } } as ActionExample,\n ],\n [\n { name: \"{{user1}}\", content: { text: \"Forecast Lorcana Elsa at $25 for 30 days\" } } as ActionExample,\n { name: \"{{agentName}}\", content: { text: \"Simulating Lorcana Elsa price trajectory...\", action: \"TCG_ORACLE_SIMULATE\" } } as ActionExample,\n ],\n ],\n validate: async (runtime: IAgentRuntime) => !!getBaseUrl(runtime),\n handler: async (\n runtime: IAgentRuntime,\n message: Memory,\n _state?: State,\n options?: Record<string, unknown>,\n callback?: HandlerCallback\n ): Promise<ActionResult | undefined> => {\n const text = message.content.text || \"\";\n\n // Try to extract parameters from text\n const priceMatch = text.match(/\\$?([\\d,]+(?:\\.\\d{2})?)/);\n const daysMatch = text.match(/(\\d+)\\s*days?/i);\n const modelMatch = text.match(/\\b(conformal|merton|gbm)\\b/i);\n\n const cardName =\n text\n .replace(/simulate|price|forecast|monte carlo|at|\\$[\\d,.]+|\\d+\\s*days?|conformal|merton|gbm/gi, \"\")\n .replace(/\\s+/g, \" \")\n .trim() || \"Unknown Card\";\n\n const currentPrice = priceMatch ? parseFloat(priceMatch[1].replace(\",\", \"\")) : 0;\n const days = daysMatch ? parseInt(daysMatch[1]) : 30;\n const model = modelMatch ? modelMatch[1].toLowerCase() : \"conformal\";\n\n if (currentPrice <= 0) {\n if (callback) await callback({ text: \"Please provide a current price for the simulation. Example: 'Simulate Charizard VMAX at $350 for 60 days'\" });\n return { success: false, error: \"Invalid or missing current price\" };\n }\n\n const result = await callApi(getBaseUrl(runtime), \"/api/v1/simulate\", {\n card_name: cardName,\n current_price: currentPrice,\n model,\n days,\n simulations: 10000,\n });\n\n if (result.error) {\n if (callback) await callback({ text: `Simulation failed: ${result.error}` });\n return { success: false, error: result.error };\n }\n\n const summary = safeStringify(result.data);\n const responseText = `Monte Carlo simulation for ${cardName} ($${currentPrice}, ${model} model, ${days} days):\\n\\n${summary}`;\n\n if (callback) await callback({ text: responseText }, \"TCG_ORACLE_SIMULATE\");\n return { success: true, text: responseText, data: { simulation_result: result.data } };\n },\n};\n\n// ============================================================\n// ACTION 4: Market Snapshot\n// ============================================================\n\nconst marketAction: Action = {\n name: \"TCG_ORACLE_MARKET\",\n description:\n \"SUSPENDED since 2026-09-07 (frozen USD panel; the oracle returns status=suspended and does not charge — the action reports that and points at the live alternatives: TCG_ORACLE_JP_SUMMARY, TCG_ORACLE_SPORTS_BOARD, TCG_ORACLE_LOAN_PREVIEW). Was: daily USD market snapshot for a game.\",\n similes: [\n \"MARKET_SNAPSHOT\",\n \"MARKET_DATA\",\n \"TCG_MARKET\",\n \"CARD_MARKET\",\n \"TOP_MOVERS\",\n \"PRICE_CHANGES\",\n ],\n parameters: [\n {\n name: \"game\",\n description: \"Game name: Pokemon, Magic: The Gathering, Yu-Gi-Oh, Lorcana, One Piece, etc\",\n required: false,\n schema: { type: \"string\" },\n },\n ],\n examples: [\n [\n { name: \"{{user1}}\", content: { text: \"Show me the Pokemon market snapshot\" } } as ActionExample,\n { name: \"{{agentName}}\", content: { text: \"Pulling the latest Pokemon market data...\", action: \"TCG_ORACLE_MARKET\" } } as ActionExample,\n ],\n [\n { name: \"{{user1}}\", content: { text: \"What's happening in the Yu-Gi-Oh market today?\" } } as ActionExample,\n { name: \"{{agentName}}\", content: { text: \"Fetching Yu-Gi-Oh market snapshot...\", action: \"TCG_ORACLE_MARKET\" } } as ActionExample,\n ],\n [\n { name: \"{{user1}}\", content: { text: \"Top movers in Magic: The Gathering\" } } as ActionExample,\n { name: \"{{agentName}}\", content: { text: \"Pulling Magic: The Gathering market data...\", action: \"TCG_ORACLE_MARKET\" } } as ActionExample,\n ],\n ],\n validate: async (runtime: IAgentRuntime) => !!getBaseUrl(runtime),\n handler: async (\n runtime: IAgentRuntime,\n message: Memory,\n _state?: State,\n _options?: Record<string, unknown>,\n callback?: HandlerCallback\n ): Promise<ActionResult | undefined> => {\n const text = message.content.text?.toLowerCase() || \"\";\n\n // Detect game from message\n let game = \"Pokemon\";\n for (const g of SUPPORTED_GAMES) {\n if (text.includes(g.toLowerCase())) {\n game = g;\n break;\n }\n }\n\n const result = await callApi(getBaseUrl(runtime), \"/api/v1/market\", { game });\n\n if (result.error) {\n if (callback) await callback({ text: `Market data failed: ${result.error}` });\n return { success: false, error: result.error };\n }\n\n const summary = safeStringify(result.data, 25);\n const responseText = `Market snapshot for ${game}:\\n\\n${summary}`;\n\n if (callback) await callback({ text: responseText }, \"TCG_ORACLE_MARKET\");\n return { success: true, text: responseText, data: { market_data: result.data } };\n },\n};\n\n// ============================================================\n// ACTION 5: Grade-or-Not Decision Engine\n// ============================================================\n\nconst gradeOrNotAction: Action = {\n name: \"TCG_ORACLE_GRADE_OR_NOT\",\n description:\n \"Answers 'will grading this card make me money?' by combining AI grade prediction with PSA fee schedules, shipping costs, and graded market values. Returns a GO/NO-GO verdict with expected ROI and profit scenarios (best case, predicted, worst case).\",\n similes: [\n \"SHOULD_I_GRADE\",\n \"GRADE_ROI\",\n \"GRADING_PROFIT\",\n \"IS_IT_WORTH_GRADING\",\n \"GRADE_OR_NOT\",\n ],\n parameters: [\n {\n name: \"card_name\",\n description: \"Name of the card to evaluate (e.g., 'Base Set Charizard Holo')\",\n required: true,\n schema: { type: \"string\" },\n },\n {\n name: \"predicted_grade\",\n description: \"Your predicted PSA grade (0 = auto-estimate)\",\n required: false,\n schema: { type: \"number\" },\n },\n {\n name: \"raw_price\",\n description: \"Current raw card value in USD (0 = auto-lookup)\",\n required: false,\n schema: { type: \"number\" },\n },\n ],\n examples: [\n [\n { name: \"{{user1}}\", content: { text: \"Should I grade my Base Set Charizard?\" } } as ActionExample,\n { name: \"{{agentName}}\", content: { text: \"Running Grade-or-Not analysis...\", action: \"TCG_ORACLE_GRADE_OR_NOT\" } } as ActionExample,\n ],\n [\n { name: \"{{user1}}\", content: { text: \"Is it worth grading a PSA 8 Pikachu VMAX worth $45?\" } } as ActionExample,\n { name: \"{{agentName}}\", content: { text: \"Calculating grading ROI for Pikachu VMAX...\", action: \"TCG_ORACLE_GRADE_OR_NOT\" } } as ActionExample,\n ],\n ],\n validate: async (runtime: IAgentRuntime) => !!getBaseUrl(runtime),\n handler: async (\n runtime: IAgentRuntime,\n message: Memory,\n _state?: State,\n _options?: Record<string, unknown>,\n callback?: HandlerCallback\n ): Promise<ActionResult | undefined> => {\n const text = message.content.text || \"\";\n\n // Extract card name\n const cardName = text\n .replace(/^(should i|is it worth|grade or not|grading roi|will grading)\\s*/i, \"\")\n .replace(/\\s*(make me money|be profitable|worth it)\\s*\\??$/i, \"\")\n .replace(/^(grade|grading)\\s*/i, \"\")\n .replace(/\\bmy\\b/i, \"\")\n .trim() || \"Unknown Card\";\n\n // Extract price and grade if mentioned\n const priceMatch = text.match(/\\$?([\\d,]+(?:\\.\\d{2})?)/);\n const gradeMatch = text.match(/\\bpsa\\s*(\\d+(?:\\.\\d)?)\\b/i) || text.match(/\\bgrade\\s*(\\d+(?:\\.\\d)?)\\b/i);\n\n const params: Record<string, string | number> = { card_name: cardName };\n if (priceMatch) params.raw_price = parseFloat(priceMatch[1].replace(\",\", \"\"));\n if (gradeMatch) params.predicted_grade = parseFloat(gradeMatch[1]);\n\n const result = await callApi(getBaseUrl(runtime), \"/api/v1/grade-or-not\", params);\n\n if (result.error) {\n if (callback) await callback({ text: `Grade-or-Not analysis failed: ${result.error}` });\n return { success: false, error: result.error };\n }\n\n const data = result.data;\n const verdict = data?.verdict || \"Unknown\";\n const explanation = data?.explanation || \"\";\n const responseText = `Grade-or-Not verdict for ${cardName}:\\n\\n${verdict}\\n${explanation}\\n\\nFull analysis:\\n${safeStringify(data)}`;\n\n if (callback) await callback({ text: responseText }, \"TCG_ORACLE_GRADE_OR_NOT\");\n return { success: true, text: responseText, data: { grade_or_not: data } };\n },\n};\n\n// ============================================================\n// ACTION 6: Trending Cards\n// ============================================================\n\nconst trendingAction: Action = {\n name: \"TCG_ORACLE_TRENDING\",\n description:\n \"SUSPENDED since 2026-09-07 (frozen USD panel; the oracle returns status=suspended and does not charge — the action reports that). Was: returns the top trending trading cards by market activity (30-day sales volume, views, and price velocity). Covers all 25 supported TCG games. Useful for spotting market momentum and emerging opportunities.\",\n similes: [\n \"TRENDING_CARDS\",\n \"HOT_CARDS\",\n \"TOP_MOVERS\",\n \"WHATS_TRENDING\",\n \"POPULAR_CARDS\",\n \"MARKET_TRENDS\",\n ],\n parameters: [\n {\n name: \"game\",\n description: \"Filter by game name (empty = all games)\",\n required: false,\n schema: { type: \"string\" },\n },\n {\n name: \"limit\",\n description: \"Number of results (default: 25, max: 100)\",\n required: false,\n schema: { type: \"number\" },\n },\n ],\n examples: [\n [\n { name: \"{{user1}}\", content: { text: \"What Pokemon cards are trending right now?\" } } as ActionExample,\n { name: \"{{agentName}}\", content: { text: \"Pulling trending Pokemon cards...\", action: \"TCG_ORACLE_TRENDING\" } } as ActionExample,\n ],\n [\n { name: \"{{user1}}\", content: { text: \"Show me the hottest cards across all games\" } } as ActionExample,\n { name: \"{{agentName}}\", content: { text: \"Fetching trending cards across all TCG games...\", action: \"TCG_ORACLE_TRENDING\" } } as ActionExample,\n ],\n ],\n validate: async (runtime: IAgentRuntime) => !!getBaseUrl(runtime),\n handler: async (\n runtime: IAgentRuntime,\n message: Memory,\n _state?: State,\n _options?: Record<string, unknown>,\n callback?: HandlerCallback\n ): Promise<ActionResult | undefined> => {\n const text = message.content?.text?.toLowerCase() || \"\";\n\n // Detect game from message\n let game = \"\";\n for (const g of SUPPORTED_GAMES) {\n if (text.includes(g.toLowerCase())) {\n game = g;\n break;\n }\n }\n\n const params: Record<string, string | number> = { limit: 25 };\n if (game) params.game = game;\n\n const result = await callApi(getBaseUrl(runtime), \"/api/v1/trending\", params);\n\n if (result.error) {\n if (callback) await callback({ text: `Trending cards failed: ${result.error}` });\n return { success: false, error: result.error };\n }\n\n const summary = safeStringify(result.data, 15);\n const responseText = `Trending cards${game ? ` for ${game}` : \" across all games\"}:\\n\\n${summary}`;\n\n if (callback) await callback({ text: responseText }, \"TCG_ORACLE_TRENDING\");\n return { success: true, text: responseText, data: { trending: result.data } };\n },\n};\n\n// ============================================================\n// ACTION 7: Japanese two-sided dealer board — summary (free, live)\n// ============================================================\n\nconst jpSummaryAction: Action = {\n name: \"TCG_ORACLE_JP_SUMMARY\",\n description:\n \"Daily aggregate summary of the Japanese two-sided dealer board (bid AND ask, yen): card/set/game totals, two-sided share, ask price bands, per-game breakdown, day-over-day and week-over-week movement, and the on-chain commitment root. Aggregates only — no per-card names, ids or prices. Free, live (this is the feed the Card Souls call from 2026-09-14).\",\n similes: [\n \"JAPANESE_MARKET\",\n \"JP_BOARD\",\n \"JP_SUMMARY\",\n \"YEN_MARKET\",\n \"JAPANESE_CARDS\",\n \"DEALER_BOARD\",\n ],\n parameters: [\n {\n name: \"section\",\n description: \"Optional: narrow the answer to one block — totals, bands, per_game or movement (default: all)\",\n required: false,\n schema: { type: \"string\" },\n },\n ],\n examples: [\n [\n { name: \"{{user1}}\", content: { text: \"How is the Japanese card market moving today?\" } } as ActionExample,\n { name: \"{{agentName}}\", content: { text: \"Pulling the Japanese two-sided board summary...\", action: \"TCG_ORACLE_JP_SUMMARY\" } } as ActionExample,\n ],\n [\n { name: \"{{user1}}\", content: { text: \"Give me the JP dealer board summary\" } } as ActionExample,\n { name: \"{{agentName}}\", content: { text: \"Fetching today's Japanese board aggregates...\", action: \"TCG_ORACLE_JP_SUMMARY\" } } as ActionExample,\n ],\n ],\n validate: async (runtime: IAgentRuntime) => !!getBaseUrl(runtime),\n handler: async (\n runtime: IAgentRuntime,\n message: Memory,\n _state?: State,\n options?: Record<string, unknown>,\n callback?: HandlerCallback\n ): Promise<ActionResult | undefined> => {\n const text = message.content.text?.toLowerCase() || \"\";\n const sections = [\"totals\", \"bands\", \"per_game\", \"movement\"];\n const section =\n (options?.section as string) ||\n sections.find((k) => text.includes(k.replace(\"_\", \" \")) || text.includes(k)) ||\n \"\";\n\n const result = await callApi(getBaseUrl(runtime), \"/api/v1/jp/summary\", {});\n\n if (result.error) {\n if (callback) await callback({ text: `Japanese board summary failed: ${result.error}` });\n return { success: false, error: result.error };\n }\n\n const d = result.data || {};\n const t = d.totals || {};\n const dod = d.movement?.day_over_day || {};\n const headline =\n `Japanese two-sided board — ${d.as_of}: ${t.cards} cards / ${t.sets} sets / ${t.games} games, ` +\n `${t.two_sided} two-sided (${Math.round((t.two_sided_share || 0) * 100)}%), median ask ¥${t.median_ask_yen}. ` +\n `Day-over-day: ${dod.asks_changed} asks moved (${dod.up} up / ${dod.down} down).`;\n const body = section && d[section] !== undefined ? { as_of: d.as_of, [section]: d[section], onchain: d.onchain } : d;\n const responseText = `${headline}\\n\\n${safeStringify(body)}`;\n\n if (callback) await callback({ text: responseText }, \"TCG_ORACLE_JP_SUMMARY\");\n return { success: true, text: responseText, data: { jp_summary: d } };\n },\n};\n\n// ============================================================\n// ACTION 8: Daily sports movers board (free, live)\n// ============================================================\n\nconst SPORTS_LEAGUES = [\"mlb\", \"nhl\", \"nfl\", \"ncaaf\", \"nba\", \"ncaab\", \"wnba\"];\n\nconst sportsBoardAction: Action = {\n name: \"TCG_ORACLE_SPORTS_BOARD\",\n description:\n \"Daily sports movers board — hot players per live league (MLB, NHL, NFL, NCAAF, NBA, ...) with conformal 7-day context, headshots and the current calibration verdict. Free, live. Name a league to narrow the answer.\",\n similes: [\n \"SPORTS_MOVERS\",\n \"HOT_PLAYERS\",\n \"SPORTS_BOARD\",\n \"PLAYER_MOVERS\",\n \"SPORTS_CARDS\",\n ],\n parameters: [\n {\n name: \"league\",\n description: \"Optional league filter: mlb, nhl, nfl, ncaaf, nba, ncaab, wnba\",\n required: false,\n schema: { type: \"string\" },\n },\n ],\n examples: [\n [\n { name: \"{{user1}}\", content: { text: \"Who are the hot NFL players this week?\" } } as ActionExample,\n { name: \"{{agentName}}\", content: { text: \"Pulling the NFL movers board...\", action: \"TCG_ORACLE_SPORTS_BOARD\" } } as ActionExample,\n ],\n [\n { name: \"{{user1}}\", content: { text: \"Show me the sports movers board\" } } as ActionExample,\n { name: \"{{agentName}}\", content: { text: \"Fetching today's sports board across live leagues...\", action: \"TCG_ORACLE_SPORTS_BOARD\" } } as ActionExample,\n ],\n ],\n validate: async (runtime: IAgentRuntime) => !!getBaseUrl(runtime),\n handler: async (\n runtime: IAgentRuntime,\n message: Memory,\n _state?: State,\n _options?: Record<string, unknown>,\n callback?: HandlerCallback\n ): Promise<ActionResult | undefined> => {\n const text = message.content.text?.toLowerCase() || \"\";\n const league = SPORTS_LEAGUES.find((l) => new RegExp(`\\\\b${l}\\\\b`).test(text));\n\n const result = await callApi(getBaseUrl(runtime), \"/api/v1/sports/board\", {});\n\n if (result.error) {\n if (callback) await callback({ text: `Sports board failed: ${result.error}` });\n return { success: false, error: result.error };\n }\n\n const d = result.data || {};\n const leagues: Record<string, any> = d.leagues || {};\n const live = Object.keys(leagues);\n let body: any;\n let label: string;\n if (league && leagues[league]) {\n body = leagues[league];\n label = league.toUpperCase();\n } else if (league) {\n body = { live_leagues: live, note: `${league} is not on today's board` };\n label = league.toUpperCase();\n } else {\n body = leagues;\n label = live.map((l) => l.toUpperCase()).join(\", \");\n }\n const responseText =\n `Sports movers board (${d.horizon_days || 7}-day horizon) — ${label}. Calibration: ${safeStringify(d.calibration)}\\n\\n${safeStringify(body, 25)}`;\n\n if (callback) await callback({ text: responseText }, \"TCG_ORACLE_SPORTS_BOARD\");\n return { success: true, text: responseText, data: { sports_board: d, league: league || null } };\n },\n};\n\n// ============================================================\n// ACTION 9: Graded-slab loan terms — free worked derivation\n// ============================================================\n\nconst loanPreviewAction: Action = {\n name: \"TCG_ORACLE_LOAN_PREVIEW\",\n description:\n \"Graded-slab lending terms (loan-terms v2, live basis): the six-step worked LTV derivation — collateral value, empirical-VaR tail, max LTV, liquidation price, census liquidity tier, APR premium — for a graded card. Give a product_id + grade (e.g. 'PSA 10'); without one it walks the top of today's free board. Free for free-board slabs; other slabs point at the paid /api/v1/loan-terms quote ($0.10, x402).\",\n similes: [\n \"LOAN_TERMS\",\n \"CARD_LOAN\",\n \"LTV\",\n \"COLLATERAL_VALUE\",\n \"SLAB_LOAN\",\n \"LENDING_TERMS\",\n ],\n parameters: [\n {\n name: \"product_id\",\n description: \"TCG product id of the card (from TCG_ORACLE_SEARCH)\",\n required: false,\n schema: { type: \"number\" },\n },\n {\n name: \"grade\",\n description: \"Slab grade, e.g. 'PSA 10', 'PSA 9', 'BGS 9.5', 'CGC 10'\",\n required: false,\n schema: { type: \"string\" },\n },\n {\n name: \"term_days\",\n description: \"Loan term in days (default 30)\",\n required: false,\n schema: { type: \"number\" },\n },\n ],\n examples: [\n [\n { name: \"{{user1}}\", content: { text: \"What loan terms would a PSA 10 of product 566544 get?\" } } as ActionExample,\n { name: \"{{agentName}}\", content: { text: \"Working the graded-slab LTV derivation...\", action: \"TCG_ORACLE_LOAN_PREVIEW\" } } as ActionExample,\n ],\n [\n { name: \"{{user1}}\", content: { text: \"Show me the loan free board\" } } as ActionExample,\n { name: \"{{agentName}}\", content: { text: \"Pulling today's rated slab universe and the free-board derivation...\", action: \"TCG_ORACLE_LOAN_PREVIEW\" } } as ActionExample,\n ],\n ],\n validate: async (runtime: IAgentRuntime) => !!getBaseUrl(runtime),\n handler: async (\n runtime: IAgentRuntime,\n message: Memory,\n _state?: State,\n options?: Record<string, unknown>,\n callback?: HandlerCallback\n ): Promise<ActionResult | undefined> => {\n const text = message.content.text || \"\";\n const baseUrl = getBaseUrl(runtime);\n\n let productId = Number(options?.product_id) || 0;\n if (!productId) {\n const m = text.match(/\\b(\\d{5,7})\\b/);\n if (m) productId = Number(m[1]);\n }\n let grade = (options?.grade as string) || \"\";\n if (!grade) {\n const g = text.match(/\\b(PSA|BGS|CGC|SGC)\\s*(10|9\\.5|9|8\\.5|8|7|6|5)\\b/i);\n if (g) grade = `${g[1].toUpperCase()} ${g[2]}`;\n }\n const termDays = Number(options?.term_days) || (text.match(/\\b(\\d{1,3})\\s*-?\\s*day/i)?.[1] ? Number(text.match(/\\b(\\d{1,3})\\s*-?\\s*day/i)![1]) : 30);\n\n // No slab named: walk the free board (universe → first free_board slab)\n let universeNote = \"\";\n if (!productId || !grade) {\n const uni = await callApi(baseUrl, \"/api/v1/loan-terms/universe\", {});\n if (uni.error) {\n if (callback) await callback({ text: `Loan universe failed: ${uni.error}` });\n return { success: false, error: uni.error };\n }\n const cards: any[] = uni.data?.cards || [];\n const pick = cards.find((c) => c.free_board && (!productId || c.product_id === productId));\n if (!pick) {\n const msg = productId\n ? `product ${productId} is not on today's free board — a full quote is the paid /api/v1/loan-terms?product_id=${productId}&grade= ($0.10, x402).`\n : \"no free-board slab published today.\";\n if (callback) await callback({ text: `Loan preview: ${msg}` });\n return { success: false, error: msg };\n }\n productId = pick.product_id;\n grade = pick.grade;\n universeNote = `Universe ${uni.data?.universe_date}: ${uni.data?.total} rated slabs, ${uni.data?.free_board} on the free board (${uni.data?.method_version}). Showing #${pick.rank} ${pick.name} ${pick.grade}.\\n\\n`;\n }\n\n const result = await callApi(baseUrl, `/api/v1/loan-terms/preview/${productId}`, { grade, term_days: termDays });\n\n if (result.error) {\n const hint = result.error.includes(\"404\")\n ? ` (${productId} ${grade} is not on today's free board — full quote: /api/v1/loan-terms?product_id=${productId}&grade=${encodeURIComponent(grade)}, $0.10 x402)`\n : \"\";\n if (callback) await callback({ text: `Loan preview failed: ${result.error}${hint}` });\n return { success: false, error: result.error };\n }\n\n const d = result.data || {};\n const responseText = `${universeNote}Loan terms — ${d.card || productId} ${d.grade || grade}, ${d.term_days || termDays}-day (${d.method_version}):\\n\\n${safeStringify(d)}`;\n\n if (callback) await callback({ text: responseText }, \"TCG_ORACLE_LOAN_PREVIEW\");\n return { success: true, text: responseText, data: { loan_preview: d, product_id: productId, grade } };\n },\n};\n\n// ============================================================\n// PROVIDER: TCG Oracle Context\n// ============================================================\n\nconst tcgOracleProvider: Provider = {\n name: \"tcg-oracle\",\n description: \"Provides TCG Oracle market intelligence context to the agent\",\n get: async (\n runtime: IAgentRuntime,\n _message: Memory,\n _state: State\n ): Promise<ProviderResult> => {\n const baseUrl = getBaseUrl(runtime);\n const status = baseUrl ? \"connected\" : \"not configured\";\n\n return {\n text: `[TCG Oracle v2.0.2]\nStatus: ${status}\nDatabase: 455K+ products across 25+ games (USD panel FROZEN 2026-09-07 — served as last-published, labelled)\nLive feeds: Japanese two-sided dealer board (daily, on-chain root), graded-slab loan terms v2, sports movers board\nModels: conformal (default — regime-aware split-conformal bands, honest VaR), merton (jump-diffusion), gbm — Monte Carlo is opt-in\nActions: search, grade, grade-or-not, jp-summary, sports-board, loan-preview (live) · simulate, market, trending (SUSPENDED — oracle answers status=suspended, never charges)\nSupported games: ${SUPPORTED_GAMES.join(\", \")}\nAPI: ${baseUrl || \"TCG_ORACLE_URL not set\"}\n\nThe agent can search cards, grade card images, check grading ROI, summarise the Japanese two-sided board, pull the sports movers board and work graded-slab loan terms. Simulate / market / trending are suspended until a live USD series exists again.`,\n values: {\n tcgOracleStatus: status,\n tcgOracleUrl: baseUrl || \"not set\",\n totalProducts: 455000,\n },\n };\n },\n};\n\n// ============================================================\n// PLUGIN EXPORT\n// ============================================================\n\nconst tcgOraclePlugin: Plugin = {\n name: \"@undesirables/plugin-tcg-oracle\",\n description:\n \"TCG Oracle — AI-powered trading card market intelligence for ElizaOS agents. \" +\n \"Covers 455K+ products across 25+ games: set-aware search, AI vision card grading \" +\n \"with ROI analysis, the Japanese two-sided dealer board summary, graded-slab loan \" +\n \"terms (empirical-VaR LTV, live basis) and the daily sports movers board. \" +\n \"USD-panel forecasts, market snapshots and trending are suspended since 2026-09-07 \" +\n \"(the oracle answers status=suspended and never charges).\",\n init: async (config: Record<string, string>, runtime: IAgentRuntime) => {\n const validation = validateTcgOracleConfig(runtime);\n if (!validation.valid) {\n console.warn(`⚠️ TCG Oracle: ${validation.error}`);\n } else {\n console.log(`✅ TCG Oracle v2.0.2 connected to ${runtime.getSetting?.(\"TCG_ORACLE_URL\")}`);\n }\n },\n actions: [searchAction, gradeAction, simulateAction, marketAction, gradeOrNotAction, trendingAction, jpSummaryAction, sportsBoardAction, loanPreviewAction],\n providers: [tcgOracleProvider],\n evaluators: [],\n services: [MarketMonitorService],\n};\n\nexport default tcgOraclePlugin;\nexport { SUPPORTED_GAMES, SIMULATION_MODELS };\n\n"],"mappings":";AAMO,SAAS,wBACd,SACoC;AACpC,QAAM,MACH,QAAQ,aAAa,gBAAgB,KACtC,QAAQ,IAAI,kBACZ;AAEF,MAAI,CAAC,KAAK;AACR,WAAO;AAAA,MACL,OAAO;AAAA,MACP,OACE;AAAA,IAEJ;AAAA,EACF;AAEA,MAAI;AACF,QAAI,IAAI,GAAG;AAAA,EACb,QAAQ;AACN,WAAO;AAAA,MACL,OAAO;AAAA,MACP,OAAO,uCAAuC,GAAG;AAAA,IACnD;AAAA,EACF;AAEA,SAAO,EAAE,OAAO,KAAK;AACvB;;;ACjCA,SAAS,eAA8B;AAEhC,IAAM,uBAAN,MAAM,8BAA6B,QAAQ;AAAA;AAAA;AAAA,EAGhD,OAAO,cAAc;AAAA,EAErB,IAAI,wBAAgC;AAClC,WAAO;AAAA,EACT;AAAA,EAEA,aAAa,MAAM,SAAuD;AACxE,UAAM,UAAU,IAAI,sBAAqB;AACzC,UAAM,QAAQ,WAAW,OAAO;AAChC,WAAO;AAAA,EACT;AAAA,EAEQ,kBAAyC;AAAA,EAEjD,MAAM,WAAW,UAAwC;AACvD,YAAQ,IAAI,0DAA0D;AAA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,aAAa,gBAAgB,CAAC,EAAE;AAAA,IAC1F;AAAA,EACF;AAAA,EACA,SAAS,CAAC,cAAc,aAAa,gBAAgB,cAAc,kBAAkB,gBAAgB,iBAAiB,mBAAmB,iBAAiB;AAAA,EAC1J,WAAW,CAAC,iBAAiB;AAAA,EAC7B,YAAY,CAAC;AAAA,EACb,UAAU,CAAC,oBAAoB;AACjC;AAEA,IAAO,gBAAQ;","names":[]}
package/images/banner.jpg CHANGED
Binary file
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@undesirables/plugin-tcg-oracle",
3
- "version": "1.1.0",
4
- "description": "ElizaOS plugin for TCG Oracle — AI-powered trading card market intelligence. 7 actions: search, grade, simulate, market, grade-or-not ROI engine, trending cards, and grading arbitrage scanner. Covers 370K+ products across 25 games.",
3
+ "version": "2.0.2",
4
+ "description": "ElizaOS plugin for TCG Oracle — AI-powered trading card market intelligence. 6 actions: search, grade, simulate, market, grade-or-not ROI engine, and trending cards. Covers 456K+ (USD prices frozen 2026-09-07) products across 25+ games with conformal-calibrated risk forecasts.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "type": "module",
@@ -26,7 +26,7 @@
26
26
  "pokemon",
27
27
  "magic-the-gathering",
28
28
  "yugioh",
29
- "monte-carlo",
29
+ "risk-forecasting",
30
30
  "card-grading",
31
31
  "market-intelligence",
32
32
  "price-prediction"
package/plugin.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@undesirables/plugin-tcg-oracle",
3
3
  "version": "1.0.0",
4
- "description": "ElizaOS plugin for TCG Oracle — AI-powered trading card market intelligence with Monte Carlo simulation and AI vision grading for 370K+ products across 25 games.",
4
+ "description": "ElizaOS plugin for TCG Oracle — AI-powered trading card market intelligence with calibrated risk forecasts and AI vision grading for 370K+ products across 25 games.",
5
5
  "author": "The Undesirables LLC",
6
6
  "license": "BUSL-1.1",
7
7
  "type": "module",
@@ -17,7 +17,7 @@
17
17
  "elizaos-plugins",
18
18
  "tcg",
19
19
  "trading-cards",
20
- "monte-carlo",
20
+ "risk-forecasting",
21
21
  "card-grading",
22
22
  "market-intelligence"
23
23
  ],