@elizaos/plugin-polymarket-app 2.0.3-beta.5 → 2.0.3-beta.7

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.
Files changed (95) hide show
  1. package/dist/PolymarketAppView.d.ts +3 -0
  2. package/dist/PolymarketAppView.d.ts.map +1 -0
  3. package/dist/PolymarketAppView.helpers.d.ts +10 -0
  4. package/dist/PolymarketAppView.helpers.d.ts.map +1 -0
  5. package/dist/PolymarketAppView.helpers.js +30 -0
  6. package/dist/PolymarketAppView.helpers.js.map +1 -0
  7. package/dist/PolymarketAppView.interact.d.ts +3 -0
  8. package/dist/PolymarketAppView.interact.d.ts.map +1 -0
  9. package/dist/PolymarketAppView.interact.js +70 -0
  10. package/dist/PolymarketAppView.interact.js.map +1 -0
  11. package/dist/PolymarketAppView.js +704 -0
  12. package/dist/PolymarketAppView.js.map +1 -0
  13. package/dist/PolymarketPositionsPanel.d.ts +13 -0
  14. package/dist/PolymarketPositionsPanel.d.ts.map +1 -0
  15. package/dist/PolymarketPositionsPanel.js +349 -0
  16. package/dist/PolymarketPositionsPanel.js.map +1 -0
  17. package/dist/PolymarketView.d.ts +13 -0
  18. package/dist/PolymarketView.d.ts.map +1 -0
  19. package/dist/PolymarketView.js +58 -0
  20. package/dist/PolymarketView.js.map +1 -0
  21. package/dist/__fixtures__/contract.d.ts +9 -0
  22. package/dist/__fixtures__/contract.d.ts.map +1 -0
  23. package/dist/__fixtures__/contract.js +263 -0
  24. package/dist/__fixtures__/contract.js.map +1 -0
  25. package/dist/actions.d.ts +39 -0
  26. package/dist/actions.d.ts.map +1 -0
  27. package/dist/actions.js +661 -0
  28. package/dist/actions.js.map +1 -0
  29. package/dist/client.d.ts +25 -0
  30. package/dist/client.d.ts.map +1 -0
  31. package/dist/client.js +42 -0
  32. package/dist/client.js.map +1 -0
  33. package/dist/components/PolymarketSpatialView.d.ts +34 -0
  34. package/dist/components/PolymarketSpatialView.d.ts.map +1 -0
  35. package/dist/components/PolymarketSpatialView.js +248 -0
  36. package/dist/components/PolymarketSpatialView.js.map +1 -0
  37. package/dist/index.d.ts +14 -0
  38. package/dist/index.d.ts.map +1 -0
  39. package/dist/index.js +24 -0
  40. package/dist/index.js.map +1 -0
  41. package/dist/orderbook.d.ts +15 -0
  42. package/dist/orderbook.d.ts.map +1 -0
  43. package/dist/orderbook.js +45 -0
  44. package/dist/orderbook.js.map +1 -0
  45. package/dist/plugin.d.ts +3 -0
  46. package/dist/plugin.d.ts.map +1 -0
  47. package/dist/plugin.js +108 -0
  48. package/dist/plugin.js.map +1 -0
  49. package/dist/polymarket-app.d.ts +4 -0
  50. package/dist/polymarket-app.d.ts.map +1 -0
  51. package/dist/polymarket-app.js +18 -0
  52. package/dist/polymarket-app.js.map +1 -0
  53. package/dist/polymarket-contracts.d.ts +162 -0
  54. package/dist/polymarket-contracts.d.ts.map +1 -0
  55. package/dist/polymarket-contracts.js +16 -0
  56. package/dist/polymarket-contracts.js.map +1 -0
  57. package/dist/polymarket-view-bundle.d.ts +3 -0
  58. package/dist/polymarket-view-bundle.d.ts.map +1 -0
  59. package/dist/polymarket-view-bundle.js +7 -0
  60. package/dist/polymarket-view-bundle.js.map +1 -0
  61. package/dist/provider-text.d.ts +5 -0
  62. package/dist/provider-text.d.ts.map +1 -0
  63. package/dist/provider-text.js +44 -0
  64. package/dist/provider-text.js.map +1 -0
  65. package/dist/provider.d.ts +3 -0
  66. package/dist/provider.d.ts.map +1 -0
  67. package/dist/provider.js +21 -0
  68. package/dist/provider.js.map +1 -0
  69. package/dist/register-routes.d.ts +2 -0
  70. package/dist/register-routes.d.ts.map +1 -0
  71. package/dist/register-routes.js +6 -0
  72. package/dist/register-routes.js.map +1 -0
  73. package/dist/register-terminal-view.d.ts +15 -0
  74. package/dist/register-terminal-view.d.ts.map +1 -0
  75. package/dist/register-terminal-view.js +25 -0
  76. package/dist/register-terminal-view.js.map +1 -0
  77. package/dist/register.d.ts +2 -0
  78. package/dist/register.d.ts.map +1 -0
  79. package/dist/register.js +17 -0
  80. package/dist/register.js.map +1 -0
  81. package/dist/routes.d.ts +7 -0
  82. package/dist/routes.d.ts.map +1 -0
  83. package/dist/routes.js +455 -0
  84. package/dist/routes.js.map +1 -0
  85. package/dist/ui.d.ts +6 -0
  86. package/dist/ui.d.ts.map +1 -0
  87. package/dist/ui.js +11 -0
  88. package/dist/ui.js.map +1 -0
  89. package/dist/usePolymarketState.d.ts +13 -0
  90. package/dist/usePolymarketState.d.ts.map +1 -0
  91. package/dist/usePolymarketState.js +59 -0
  92. package/dist/usePolymarketState.js.map +1 -0
  93. package/dist/views/bundle.js +535 -0
  94. package/dist/views/bundle.js.map +1 -0
  95. package/package.json +6 -6
@@ -0,0 +1,45 @@
1
+ function parsePositivePrice(value) {
2
+ if (typeof value === "number") {
3
+ return Number.isFinite(value) && value > 0 ? value : null;
4
+ }
5
+ if (typeof value === "string") {
6
+ const parsed = Number.parseFloat(value);
7
+ return Number.isFinite(parsed) && parsed > 0 ? parsed : null;
8
+ }
9
+ return null;
10
+ }
11
+ function formatPrice(value) {
12
+ return value.toFixed(4).replace(/0+$/, "").replace(/\.$/, "");
13
+ }
14
+ function derivePolymarketTopOfBook(args) {
15
+ const bestBid = args.bids?.reduce((best, level) => {
16
+ const levelPrice = parsePositivePrice(level.price);
17
+ if (levelPrice === null) return best;
18
+ const bestPrice = best ? parsePositivePrice(best.price) : null;
19
+ if (!best || bestPrice === null || levelPrice > bestPrice) {
20
+ return level;
21
+ }
22
+ return best;
23
+ }, null) ?? null;
24
+ const bestAsk = args.asks?.reduce((best, level) => {
25
+ const levelPrice = parsePositivePrice(level.price);
26
+ if (levelPrice === null) return best;
27
+ const bestPrice = best ? parsePositivePrice(best.price) : null;
28
+ if (!best || bestPrice === null || levelPrice < bestPrice) {
29
+ return level;
30
+ }
31
+ return best;
32
+ }, null) ?? null;
33
+ const bidPrice = bestBid ? parsePositivePrice(bestBid.price) : null;
34
+ const askPrice = bestAsk ? parsePositivePrice(bestAsk.price) : null;
35
+ return {
36
+ bestBid,
37
+ bestAsk,
38
+ midpoint: bidPrice !== null && askPrice !== null ? formatPrice((bidPrice + askPrice) / 2) : null,
39
+ spread: bidPrice !== null && askPrice !== null ? formatPrice(askPrice - bidPrice) : null
40
+ };
41
+ }
42
+ export {
43
+ derivePolymarketTopOfBook
44
+ };
45
+ //# sourceMappingURL=orderbook.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/orderbook.ts"],"sourcesContent":["export interface PolymarketOrderbookLevel {\n price: string;\n size: string;\n}\n\nexport interface PolymarketTopOfBook {\n bestBid: PolymarketOrderbookLevel | null;\n bestAsk: PolymarketOrderbookLevel | null;\n midpoint: string | null;\n spread: string | null;\n}\n\nfunction parsePositivePrice(value: string | number | undefined): number | null {\n if (typeof value === \"number\") {\n return Number.isFinite(value) && value > 0 ? value : null;\n }\n if (typeof value === \"string\") {\n const parsed = Number.parseFloat(value);\n return Number.isFinite(parsed) && parsed > 0 ? parsed : null;\n }\n return null;\n}\n\nfunction formatPrice(value: number): string {\n return value.toFixed(4).replace(/0+$/, \"\").replace(/\\.$/, \"\");\n}\n\nexport function derivePolymarketTopOfBook(args: {\n bids?: readonly PolymarketOrderbookLevel[];\n asks?: readonly PolymarketOrderbookLevel[];\n}): PolymarketTopOfBook {\n const bestBid =\n args.bids?.reduce<PolymarketOrderbookLevel | null>((best, level) => {\n const levelPrice = parsePositivePrice(level.price);\n if (levelPrice === null) return best;\n const bestPrice = best ? parsePositivePrice(best.price) : null;\n if (!best || bestPrice === null || levelPrice > bestPrice) {\n return level;\n }\n return best;\n }, null) ?? null;\n\n const bestAsk =\n args.asks?.reduce<PolymarketOrderbookLevel | null>((best, level) => {\n const levelPrice = parsePositivePrice(level.price);\n if (levelPrice === null) return best;\n const bestPrice = best ? parsePositivePrice(best.price) : null;\n if (!best || bestPrice === null || levelPrice < bestPrice) {\n return level;\n }\n return best;\n }, null) ?? null;\n\n const bidPrice = bestBid ? parsePositivePrice(bestBid.price) : null;\n const askPrice = bestAsk ? parsePositivePrice(bestAsk.price) : null;\n return {\n bestBid,\n bestAsk,\n midpoint:\n bidPrice !== null && askPrice !== null\n ? formatPrice((bidPrice + askPrice) / 2)\n : null,\n spread:\n bidPrice !== null && askPrice !== null\n ? formatPrice(askPrice - bidPrice)\n : null,\n };\n}\n"],"mappings":"AAYA,SAAS,mBAAmB,OAAmD;AAC7E,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO,OAAO,SAAS,KAAK,KAAK,QAAQ,IAAI,QAAQ;AAAA,EACvD;AACA,MAAI,OAAO,UAAU,UAAU;AAC7B,UAAM,SAAS,OAAO,WAAW,KAAK;AACtC,WAAO,OAAO,SAAS,MAAM,KAAK,SAAS,IAAI,SAAS;AAAA,EAC1D;AACA,SAAO;AACT;AAEA,SAAS,YAAY,OAAuB;AAC1C,SAAO,MAAM,QAAQ,CAAC,EAAE,QAAQ,OAAO,EAAE,EAAE,QAAQ,OAAO,EAAE;AAC9D;AAEO,SAAS,0BAA0B,MAGlB;AACtB,QAAM,UACJ,KAAK,MAAM,OAAwC,CAAC,MAAM,UAAU;AAClE,UAAM,aAAa,mBAAmB,MAAM,KAAK;AACjD,QAAI,eAAe,KAAM,QAAO;AAChC,UAAM,YAAY,OAAO,mBAAmB,KAAK,KAAK,IAAI;AAC1D,QAAI,CAAC,QAAQ,cAAc,QAAQ,aAAa,WAAW;AACzD,aAAO;AAAA,IACT;AACA,WAAO;AAAA,EACT,GAAG,IAAI,KAAK;AAEd,QAAM,UACJ,KAAK,MAAM,OAAwC,CAAC,MAAM,UAAU;AAClE,UAAM,aAAa,mBAAmB,MAAM,KAAK;AACjD,QAAI,eAAe,KAAM,QAAO;AAChC,UAAM,YAAY,OAAO,mBAAmB,KAAK,KAAK,IAAI;AAC1D,QAAI,CAAC,QAAQ,cAAc,QAAQ,aAAa,WAAW;AACzD,aAAO;AAAA,IACT;AACA,WAAO;AAAA,EACT,GAAG,IAAI,KAAK;AAEd,QAAM,WAAW,UAAU,mBAAmB,QAAQ,KAAK,IAAI;AAC/D,QAAM,WAAW,UAAU,mBAAmB,QAAQ,KAAK,IAAI;AAC/D,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,UACE,aAAa,QAAQ,aAAa,OAC9B,aAAa,WAAW,YAAY,CAAC,IACrC;AAAA,IACN,QACE,aAAa,QAAQ,aAAa,OAC9B,YAAY,WAAW,QAAQ,IAC/B;AAAA,EACR;AACF;","names":[]}
@@ -0,0 +1,3 @@
1
+ import type { Plugin } from "@elizaos/core";
2
+ export declare const polymarketPlugin: Plugin;
3
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,MAAM,EAIP,MAAM,eAAe,CAAC;AAyFvB,eAAO,MAAM,gBAAgB,EAAE,MAkC9B,CAAC"}
package/dist/plugin.js ADDED
@@ -0,0 +1,108 @@
1
+ import {
2
+ PREDICTION_MARKET_SERVICE_TYPE,
3
+ PredictionMarketService,
4
+ polymarketActions
5
+ } from "./actions.js";
6
+ import { polymarketStatusProvider } from "./provider.js";
7
+ import { handlePolymarketRoute } from "./routes.js";
8
+ function toHttpIncomingMessage(req) {
9
+ if (typeof req !== "object" || req === null || typeof req.method !== "string" || typeof req.headers !== "object") {
10
+ throw new TypeError("Polymarket routes require a Node HTTP request");
11
+ }
12
+ return req;
13
+ }
14
+ function toHttpServerResponse(res) {
15
+ if (typeof res !== "object" || res === null || typeof res.end !== "function" || typeof res.setHeader !== "function") {
16
+ throw new TypeError("Polymarket routes require a Node HTTP response");
17
+ }
18
+ return res;
19
+ }
20
+ function polymarketRouteHandler(pathname) {
21
+ return async (req, res, _runtime) => {
22
+ const httpReq = toHttpIncomingMessage(req);
23
+ const httpRes = toHttpServerResponse(res);
24
+ const method = (httpReq.method ?? "GET").toUpperCase();
25
+ await handlePolymarketRoute(httpReq, httpRes, pathname, method);
26
+ };
27
+ }
28
+ const polymarketRoutes = [
29
+ {
30
+ type: "GET",
31
+ path: "/api/polymarket/status",
32
+ rawPath: true,
33
+ handler: polymarketRouteHandler("/api/polymarket/status")
34
+ },
35
+ {
36
+ type: "GET",
37
+ path: "/api/polymarket/markets",
38
+ rawPath: true,
39
+ handler: polymarketRouteHandler("/api/polymarket/markets")
40
+ },
41
+ {
42
+ type: "GET",
43
+ path: "/api/polymarket/market",
44
+ rawPath: true,
45
+ handler: polymarketRouteHandler("/api/polymarket/market")
46
+ },
47
+ {
48
+ type: "GET",
49
+ path: "/api/polymarket/orderbook",
50
+ rawPath: true,
51
+ handler: polymarketRouteHandler("/api/polymarket/orderbook")
52
+ },
53
+ {
54
+ type: "GET",
55
+ path: "/api/polymarket/orders",
56
+ rawPath: true,
57
+ handler: polymarketRouteHandler("/api/polymarket/orders")
58
+ },
59
+ {
60
+ type: "POST",
61
+ path: "/api/polymarket/orders",
62
+ rawPath: true,
63
+ handler: polymarketRouteHandler("/api/polymarket/orders")
64
+ },
65
+ {
66
+ type: "GET",
67
+ path: "/api/polymarket/positions",
68
+ rawPath: true,
69
+ handler: polymarketRouteHandler("/api/polymarket/positions")
70
+ }
71
+ ];
72
+ const polymarketPlugin = {
73
+ name: "@elizaos/plugin-polymarket-app",
74
+ description: "Native Polymarket market discovery, orderbook quote, position, and readiness routes/actions",
75
+ actions: polymarketActions,
76
+ services: [PredictionMarketService],
77
+ providers: [polymarketStatusProvider],
78
+ routes: polymarketRoutes,
79
+ views: [
80
+ // ONE declaration → GUI + XR + TUI, all drawn from the single
81
+ // PolymarketView spatial source. `modalities` is a plain literal here
82
+ // (plugin.ts is not in the view bundle), so no brand-new `@elizaos/core`
83
+ // runtime export reaches the bundle build.
84
+ {
85
+ id: "polymarket",
86
+ label: "Polymarket",
87
+ description: "Polymarket prediction markets \u2014 market discovery, orderbook, and positions",
88
+ icon: "BarChart2",
89
+ path: "/polymarket",
90
+ modalities: ["gui", "xr", "tui"],
91
+ bundlePath: "dist/views/bundle.js",
92
+ componentExport: "PolymarketView",
93
+ tags: ["prediction-markets", "polymarket", "trading"],
94
+ visibleInManager: true,
95
+ desktopTabEnabled: true
96
+ }
97
+ ],
98
+ async dispose(runtime) {
99
+ const svc = runtime.getService(
100
+ PREDICTION_MARKET_SERVICE_TYPE
101
+ );
102
+ await svc?.stop();
103
+ }
104
+ };
105
+ export {
106
+ polymarketPlugin
107
+ };
108
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/plugin.ts"],"sourcesContent":["import type http from \"node:http\";\nimport type {\n IAgentRuntime,\n Plugin,\n Route,\n RouteRequest,\n RouteResponse,\n} from \"@elizaos/core\";\nimport {\n PREDICTION_MARKET_SERVICE_TYPE,\n PredictionMarketService,\n polymarketActions,\n} from \"./actions.js\";\nimport { polymarketStatusProvider } from \"./provider.js\";\nimport { handlePolymarketRoute } from \"./routes.js\";\n\nfunction toHttpIncomingMessage(req: RouteRequest): http.IncomingMessage {\n if (\n typeof req !== \"object\" ||\n req === null ||\n typeof req.method !== \"string\" ||\n typeof req.headers !== \"object\"\n ) {\n throw new TypeError(\"Polymarket routes require a Node HTTP request\");\n }\n return req as http.IncomingMessage;\n}\n\nfunction toHttpServerResponse(res: RouteResponse): http.ServerResponse {\n if (\n typeof res !== \"object\" ||\n res === null ||\n typeof res.end !== \"function\" ||\n typeof res.setHeader !== \"function\"\n ) {\n throw new TypeError(\"Polymarket routes require a Node HTTP response\");\n }\n return res as unknown as http.ServerResponse;\n}\n\nfunction polymarketRouteHandler(\n pathname: string,\n): NonNullable<Route[\"handler\"]> {\n return async (req, res, _runtime) => {\n const httpReq = toHttpIncomingMessage(req);\n const httpRes = toHttpServerResponse(res);\n const method = (httpReq.method ?? \"GET\").toUpperCase();\n await handlePolymarketRoute(httpReq, httpRes, pathname, method);\n };\n}\n\nconst polymarketRoutes: Route[] = [\n {\n type: \"GET\",\n path: \"/api/polymarket/status\",\n rawPath: true,\n handler: polymarketRouteHandler(\"/api/polymarket/status\"),\n },\n {\n type: \"GET\",\n path: \"/api/polymarket/markets\",\n rawPath: true,\n handler: polymarketRouteHandler(\"/api/polymarket/markets\"),\n },\n {\n type: \"GET\",\n path: \"/api/polymarket/market\",\n rawPath: true,\n handler: polymarketRouteHandler(\"/api/polymarket/market\"),\n },\n {\n type: \"GET\",\n path: \"/api/polymarket/orderbook\",\n rawPath: true,\n handler: polymarketRouteHandler(\"/api/polymarket/orderbook\"),\n },\n {\n type: \"GET\",\n path: \"/api/polymarket/orders\",\n rawPath: true,\n handler: polymarketRouteHandler(\"/api/polymarket/orders\"),\n },\n {\n type: \"POST\",\n path: \"/api/polymarket/orders\",\n rawPath: true,\n handler: polymarketRouteHandler(\"/api/polymarket/orders\"),\n },\n {\n type: \"GET\",\n path: \"/api/polymarket/positions\",\n rawPath: true,\n handler: polymarketRouteHandler(\"/api/polymarket/positions\"),\n },\n];\n\nexport const polymarketPlugin: Plugin = {\n name: \"@elizaos/plugin-polymarket-app\",\n description:\n \"Native Polymarket market discovery, orderbook quote, position, and readiness routes/actions\",\n actions: polymarketActions,\n services: [PredictionMarketService],\n providers: [polymarketStatusProvider],\n routes: polymarketRoutes,\n views: [\n // ONE declaration → GUI + XR + TUI, all drawn from the single\n // PolymarketView spatial source. `modalities` is a plain literal here\n // (plugin.ts is not in the view bundle), so no brand-new `@elizaos/core`\n // runtime export reaches the bundle build.\n {\n id: \"polymarket\",\n label: \"Polymarket\",\n description:\n \"Polymarket prediction markets — market discovery, orderbook, and positions\",\n icon: \"BarChart2\",\n path: \"/polymarket\",\n modalities: [\"gui\", \"xr\", \"tui\"],\n bundlePath: \"dist/views/bundle.js\",\n componentExport: \"PolymarketView\",\n tags: [\"prediction-markets\", \"polymarket\", \"trading\"],\n visibleInManager: true,\n desktopTabEnabled: true,\n },\n ],\n async dispose(runtime: IAgentRuntime) {\n const svc = runtime.getService<PredictionMarketService>(\n PREDICTION_MARKET_SERVICE_TYPE,\n );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,SAAS,uBAAuB,wBAAwB;AAAA,EAC1D;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,IACT,SAAS,uBAAuB,wBAAwB;AAAA,EAC1D;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,IACT,SAAS,uBAAuB,2BAA2B;AAAA,EAC7D;AACF;AAEO,MAAM,mBAA2B;AAAA,EACtC,MAAM;AAAA,EACN,aACE;AAAA,EACF,SAAS;AAAA,EACT,UAAU,CAAC,uBAAuB;AAAA,EAClC,WAAW,CAAC,wBAAwB;AAAA,EACpC,QAAQ;AAAA,EACR,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA,IAKL;AAAA,MACE,IAAI;AAAA,MACJ,OAAO;AAAA,MACP,aACE;AAAA,MACF,MAAM;AAAA,MACN,MAAM;AAAA,MACN,YAAY,CAAC,OAAO,MAAM,KAAK;AAAA,MAC/B,YAAY;AAAA,MACZ,iBAAiB;AAAA,MACjB,MAAM,CAAC,sBAAsB,cAAc,SAAS;AAAA,MACpD,kBAAkB;AAAA,MAClB,mBAAmB;AAAA,IACrB;AAAA,EACF;AAAA,EACA,MAAM,QAAQ,SAAwB;AACpC,UAAM,MAAM,QAAQ;AAAA,MAClB;AAAA,IACF;AACA,UAAM,KAAK,KAAK;AAAA,EAClB;AACF;","names":[]}
@@ -0,0 +1,4 @@
1
+ import type { OverlayApp } from "@elizaos/app-core";
2
+ export declare const POLYMARKET_APP_NAME = "@elizaos/plugin-polymarket-app";
3
+ export declare const polymarketApp: OverlayApp;
4
+ //# sourceMappingURL=polymarket-app.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"polymarket-app.d.ts","sourceRoot":"","sources":["../src/polymarket-app.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAGpD,eAAO,MAAM,mBAAmB,mCAAmC,CAAC;AAEpE,eAAO,MAAM,aAAa,EAAE,UAU3B,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { registerOverlayApp } from "@elizaos/app-core";
2
+ const POLYMARKET_APP_NAME = "@elizaos/plugin-polymarket-app";
3
+ const polymarketApp = {
4
+ name: POLYMARKET_APP_NAME,
5
+ displayName: "Polymarket",
6
+ description: "Browse Polymarket markets and inspect native trading readiness",
7
+ category: "trading",
8
+ icon: null,
9
+ loader: () => import("./PolymarketAppView.js").then((m) => ({
10
+ default: m.PolymarketAppView
11
+ }))
12
+ };
13
+ registerOverlayApp(polymarketApp);
14
+ export {
15
+ POLYMARKET_APP_NAME,
16
+ polymarketApp
17
+ };
18
+ //# sourceMappingURL=polymarket-app.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/polymarket-app.ts"],"sourcesContent":["import type { OverlayApp } from \"@elizaos/app-core\";\nimport { registerOverlayApp } from \"@elizaos/app-core\";\n\nexport const POLYMARKET_APP_NAME = \"@elizaos/plugin-polymarket-app\";\n\nexport const polymarketApp: OverlayApp = {\n name: POLYMARKET_APP_NAME,\n displayName: \"Polymarket\",\n description: \"Browse Polymarket markets and inspect native trading readiness\",\n category: \"trading\",\n icon: null,\n loader: () =>\n import(\"./PolymarketAppView.js\").then((m) => ({\n default: m.PolymarketAppView,\n })),\n};\n\nregisterOverlayApp(polymarketApp);\n"],"mappings":"AACA,SAAS,0BAA0B;AAE5B,MAAM,sBAAsB;AAE5B,MAAM,gBAA4B;AAAA,EACvC,MAAM;AAAA,EACN,aAAa;AAAA,EACb,aAAa;AAAA,EACb,UAAU;AAAA,EACV,MAAM;AAAA,EACN,QAAQ,MACN,OAAO,wBAAwB,EAAE,KAAK,CAAC,OAAO;AAAA,IAC5C,SAAS,EAAE;AAAA,EACb,EAAE;AACN;AAEA,mBAAmB,aAAa;","names":[]}
@@ -0,0 +1,162 @@
1
+ export declare const POLYMARKET_GAMMA_API_BASE = "https://gamma-api.polymarket.com";
2
+ export declare const POLYMARKET_DATA_API_BASE = "https://data-api.polymarket.com";
3
+ export declare const POLYMARKET_CLOB_API_BASE = "https://clob.polymarket.com";
4
+ export declare const POLYMARKET_TRADING_ENV_VARS: readonly ["POLYMARKET_PRIVATE_KEY", "CLOB_API_KEY", "CLOB_API_SECRET", "CLOB_API_PASSPHRASE"];
5
+ export type PolymarketTradingEnvVar = (typeof POLYMARKET_TRADING_ENV_VARS)[number];
6
+ export interface PolymarketReadiness {
7
+ ready: boolean;
8
+ reason: string | null;
9
+ }
10
+ export interface PolymarketTradingReadiness extends PolymarketReadiness {
11
+ credentialsReady: boolean;
12
+ missing: readonly PolymarketTradingEnvVar[];
13
+ }
14
+ export interface PolymarketAccountReadiness extends PolymarketReadiness {
15
+ /**
16
+ * The agent's Polygon wallet address used to read positions, resolved from
17
+ * env (POLYMARKET_WALLET_ADDRESS / STEWARD_EVM_ADDRESS / managed EVM
18
+ * address). Null when no address is configured, in which case position reads
19
+ * require an explicit `user` query param.
20
+ */
21
+ address: string | null;
22
+ }
23
+ export interface PolymarketStatusResponse {
24
+ publicReads: PolymarketReadiness & {
25
+ gammaApiBase: string;
26
+ dataApiBase: string;
27
+ };
28
+ /**
29
+ * Position-read readiness. Readable whenever an account address is resolvable
30
+ * (public Data API, no credentials needed). The address is surfaced so the
31
+ * AppView can read the agent's own positions without prompting for a wallet.
32
+ */
33
+ account: PolymarketAccountReadiness;
34
+ trading: PolymarketTradingReadiness & {
35
+ clobApiBase: string;
36
+ };
37
+ }
38
+ export type PolymarketSource = {
39
+ api: "gamma";
40
+ endpoint: string;
41
+ } | {
42
+ api: "data";
43
+ endpoint: string;
44
+ } | {
45
+ api: "clob";
46
+ endpoint: string;
47
+ };
48
+ export interface PolymarketMarketOutcome {
49
+ name: string;
50
+ price: string | null;
51
+ }
52
+ export interface PolymarketMarket {
53
+ id: string;
54
+ slug: string | null;
55
+ question: string | null;
56
+ description: string | null;
57
+ category: string | null;
58
+ active: boolean | null;
59
+ closed: boolean | null;
60
+ archived: boolean | null;
61
+ restricted: boolean | null;
62
+ enableOrderBook: boolean | null;
63
+ conditionId: string | null;
64
+ clobTokenIds: readonly string[];
65
+ outcomes: readonly PolymarketMarketOutcome[];
66
+ liquidity: string | null;
67
+ volume: string | null;
68
+ volume24hr: string | null;
69
+ lastTradePrice: string | null;
70
+ bestBid: string | null;
71
+ bestAsk: string | null;
72
+ image: string | null;
73
+ icon: string | null;
74
+ endDate: string | null;
75
+ startDate: string | null;
76
+ updatedAt: string | null;
77
+ }
78
+ export interface PolymarketMarketsResponse {
79
+ markets: readonly PolymarketMarket[];
80
+ source: PolymarketSource;
81
+ }
82
+ export interface PolymarketMarketResponse {
83
+ market: PolymarketMarket | null;
84
+ source: PolymarketSource;
85
+ }
86
+ export interface PolymarketOrderbookLevel {
87
+ price: string;
88
+ size: string;
89
+ }
90
+ export interface PolymarketOrderbookResponse {
91
+ tokenId: string;
92
+ market: string | null;
93
+ assetId: string | null;
94
+ bids: readonly PolymarketOrderbookLevel[];
95
+ asks: readonly PolymarketOrderbookLevel[];
96
+ bestBid: string | null;
97
+ bestBidSize: string | null;
98
+ bestAsk: string | null;
99
+ bestAskSize: string | null;
100
+ midpoint: string | null;
101
+ spread: string | null;
102
+ bidLevels: number;
103
+ askLevels: number;
104
+ lastTradePrice: string | null;
105
+ tickSize: string | null;
106
+ source: PolymarketSource;
107
+ }
108
+ export interface PolymarketDisabledResponse {
109
+ enabled: false;
110
+ reason: string;
111
+ requiredForTrading: readonly PolymarketTradingEnvVar[];
112
+ }
113
+ /**
114
+ * Account-level aggregate derived from a wallet's open Polymarket positions,
115
+ * mirroring the waifu patron "account health" strip (total position value +
116
+ * aggregate cash PnL across markets). All values are stringified USD; null when
117
+ * the wallet holds no positions or the field is unreadable. This is the
118
+ * prediction-market analogue of the Hyperliquid account summary surfaced in the
119
+ * sibling HL app-plugin.
120
+ */
121
+ export interface PolymarketPositionsSummary {
122
+ /** Sum of per-position `currentValue`, in USD. Null when no positions. */
123
+ totalValue: string | null;
124
+ /** Sum of per-position `cashPnl`, in USD. Null when no positions. */
125
+ totalCashPnl: string | null;
126
+ /**
127
+ * Aggregate return as a fraction of cost basis
128
+ * (totalCashPnl / (totalValue - totalCashPnl)). Null when the basis is
129
+ * zero/unreadable.
130
+ */
131
+ totalPercentPnl: string | null;
132
+ /** Count of open positions contributing to the aggregate. */
133
+ openPositions: number;
134
+ }
135
+ export interface PolymarketPositionsResponse {
136
+ positions: readonly PolymarketPosition[];
137
+ /**
138
+ * The wallet whose positions were read. Resolved from the request `user`
139
+ * query param, or from the agent's configured Polygon address when omitted.
140
+ * Null when no address was resolvable.
141
+ */
142
+ user: string | null;
143
+ /**
144
+ * Account value/PnL aggregate. Optional for back-compat: older route builds
145
+ * and the no-position path emit null.
146
+ */
147
+ summary: PolymarketPositionsSummary | null;
148
+ source: PolymarketSource;
149
+ }
150
+ export interface PolymarketPosition {
151
+ marketId: string | null;
152
+ conditionId: string | null;
153
+ question: string | null;
154
+ outcome: string | null;
155
+ size: string | null;
156
+ currentValue: string | null;
157
+ cashPnl: string | null;
158
+ percentPnl: string | null;
159
+ icon: string | null;
160
+ slug: string | null;
161
+ }
162
+ //# sourceMappingURL=polymarket-contracts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"polymarket-contracts.d.ts","sourceRoot":"","sources":["../src/polymarket-contracts.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,yBAAyB,qCAAqC,CAAC;AAC5E,eAAO,MAAM,wBAAwB,oCAAoC,CAAC;AAC1E,eAAO,MAAM,wBAAwB,gCAAgC,CAAC;AAEtE,eAAO,MAAM,2BAA2B,+FAK9B,CAAC;AAEX,MAAM,MAAM,uBAAuB,GACjC,CAAC,OAAO,2BAA2B,CAAC,CAAC,MAAM,CAAC,CAAC;AAE/C,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAED,MAAM,WAAW,0BAA2B,SAAQ,mBAAmB;IAC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YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB"}
@@ -0,0 +1,16 @@
1
+ const POLYMARKET_GAMMA_API_BASE = "https://gamma-api.polymarket.com";
2
+ const POLYMARKET_DATA_API_BASE = "https://data-api.polymarket.com";
3
+ const POLYMARKET_CLOB_API_BASE = "https://clob.polymarket.com";
4
+ const POLYMARKET_TRADING_ENV_VARS = [
5
+ "POLYMARKET_PRIVATE_KEY",
6
+ "CLOB_API_KEY",
7
+ "CLOB_API_SECRET",
8
+ "CLOB_API_PASSPHRASE"
9
+ ];
10
+ export {
11
+ POLYMARKET_CLOB_API_BASE,
12
+ POLYMARKET_DATA_API_BASE,
13
+ POLYMARKET_GAMMA_API_BASE,
14
+ POLYMARKET_TRADING_ENV_VARS
15
+ };
16
+ //# sourceMappingURL=polymarket-contracts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/polymarket-contracts.ts"],"sourcesContent":["export const POLYMARKET_GAMMA_API_BASE = \"https://gamma-api.polymarket.com\";\nexport const POLYMARKET_DATA_API_BASE = \"https://data-api.polymarket.com\";\nexport const POLYMARKET_CLOB_API_BASE = \"https://clob.polymarket.com\";\n\nexport const POLYMARKET_TRADING_ENV_VARS = [\n \"POLYMARKET_PRIVATE_KEY\",\n \"CLOB_API_KEY\",\n \"CLOB_API_SECRET\",\n \"CLOB_API_PASSPHRASE\",\n] as const;\n\nexport type PolymarketTradingEnvVar =\n (typeof POLYMARKET_TRADING_ENV_VARS)[number];\n\nexport interface PolymarketReadiness {\n ready: boolean;\n reason: string | null;\n}\n\nexport interface PolymarketTradingReadiness extends PolymarketReadiness {\n credentialsReady: boolean;\n missing: readonly PolymarketTradingEnvVar[];\n}\n\nexport interface PolymarketAccountReadiness extends PolymarketReadiness {\n /**\n * The agent's Polygon wallet address used to read positions, resolved from\n * env (POLYMARKET_WALLET_ADDRESS / STEWARD_EVM_ADDRESS / managed EVM\n * address). Null when no address is configured, in which case position reads\n * require an explicit `user` query param.\n */\n address: string | null;\n}\n\nexport interface PolymarketStatusResponse {\n publicReads: PolymarketReadiness & {\n gammaApiBase: string;\n dataApiBase: string;\n };\n /**\n * Position-read readiness. Readable whenever an account address is resolvable\n * (public Data API, no credentials needed). The address is surfaced so the\n * AppView can read the agent's own positions without prompting for a wallet.\n */\n account: PolymarketAccountReadiness;\n trading: PolymarketTradingReadiness & {\n clobApiBase: string;\n };\n}\n\nexport type PolymarketSource =\n | {\n api: \"gamma\";\n endpoint: string;\n }\n | {\n api: \"data\";\n endpoint: string;\n }\n | {\n api: \"clob\";\n endpoint: string;\n };\n\nexport interface PolymarketMarketOutcome {\n name: string;\n price: string | null;\n}\n\nexport interface PolymarketMarket {\n id: string;\n slug: string | null;\n question: string | null;\n description: string | null;\n category: string | null;\n active: boolean | null;\n closed: boolean | null;\n archived: boolean | null;\n restricted: boolean | null;\n enableOrderBook: boolean | null;\n conditionId: string | null;\n clobTokenIds: readonly string[];\n outcomes: readonly PolymarketMarketOutcome[];\n liquidity: string | null;\n volume: string | null;\n volume24hr: string | null;\n lastTradePrice: string | null;\n bestBid: string | null;\n bestAsk: string | null;\n image: string | null;\n icon: string | null;\n endDate: string | null;\n startDate: string | null;\n updatedAt: string | null;\n}\n\nexport interface PolymarketMarketsResponse {\n markets: readonly PolymarketMarket[];\n source: PolymarketSource;\n}\n\nexport interface PolymarketMarketResponse {\n market: PolymarketMarket | null;\n source: PolymarketSource;\n}\n\nexport interface PolymarketOrderbookLevel {\n price: string;\n size: string;\n}\n\nexport interface PolymarketOrderbookResponse {\n tokenId: string;\n market: string | null;\n assetId: string | null;\n bids: readonly PolymarketOrderbookLevel[];\n asks: readonly PolymarketOrderbookLevel[];\n bestBid: string | null;\n bestBidSize: string | null;\n bestAsk: string | null;\n bestAskSize: string | null;\n midpoint: string | null;\n spread: string | null;\n bidLevels: number;\n askLevels: number;\n lastTradePrice: string | null;\n tickSize: string | null;\n source: PolymarketSource;\n}\n\nexport interface PolymarketDisabledResponse {\n enabled: false;\n reason: string;\n requiredForTrading: readonly PolymarketTradingEnvVar[];\n}\n\n/**\n * Account-level aggregate derived from a wallet's open Polymarket positions,\n * mirroring the waifu patron \"account health\" strip (total position value +\n * aggregate cash PnL across markets). All values are stringified USD; null when\n * the wallet holds no positions or the field is unreadable. This is the\n * prediction-market analogue of the Hyperliquid account summary surfaced in the\n * sibling HL app-plugin.\n */\nexport interface PolymarketPositionsSummary {\n /** Sum of per-position `currentValue`, in USD. Null when no positions. */\n totalValue: string | null;\n /** Sum of per-position `cashPnl`, in USD. Null when no positions. */\n totalCashPnl: string | null;\n /**\n * Aggregate return as a fraction of cost basis\n * (totalCashPnl / (totalValue - totalCashPnl)). Null when the basis is\n * zero/unreadable.\n */\n totalPercentPnl: string | null;\n /** Count of open positions contributing to the aggregate. */\n openPositions: number;\n}\n\nexport interface PolymarketPositionsResponse {\n positions: readonly PolymarketPosition[];\n /**\n * The wallet whose positions were read. Resolved from the request `user`\n * query param, or from the agent's configured Polygon address when omitted.\n * Null when no address was resolvable.\n */\n user: string | null;\n /**\n * Account value/PnL aggregate. Optional for back-compat: older route builds\n * and the no-position path emit null.\n */\n summary: PolymarketPositionsSummary | null;\n source: PolymarketSource;\n}\n\nexport interface PolymarketPosition {\n marketId: string | null;\n conditionId: string | null;\n question: string | null;\n outcome: string | null;\n size: string | null;\n currentValue: string | null;\n cashPnl: string | null;\n percentPnl: string | null;\n icon: string | null;\n slug: string | null;\n}\n"],"mappings":"AAAO,MAAM,4BAA4B;AAClC,MAAM,2BAA2B;AACjC,MAAM,2BAA2B;AAEjC,MAAM,8BAA8B;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;","names":[]}
@@ -0,0 +1,3 @@
1
+ export { interact } from "./PolymarketAppView.interact";
2
+ export { PolymarketView } from "./PolymarketView";
3
+ //# sourceMappingURL=polymarket-view-bundle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"polymarket-view-bundle.d.ts","sourceRoot":"","sources":["../src/polymarket-view-bundle.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { interact } from "./PolymarketAppView.interact";
2
+ import { PolymarketView } from "./PolymarketView.js";
3
+ export {
4
+ PolymarketView,
5
+ interact
6
+ };
7
+ //# sourceMappingURL=polymarket-view-bundle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/polymarket-view-bundle.ts"],"sourcesContent":["// Vite view-bundle entry. Re-exports the unified spatial view component plus\n// the `interact` capability handler so the built bundle (dist/views/bundle.js)\n// exposes the named exports the view loader reads (`PolymarketView`,\n// `interact`). Kept separate from PolymarketView.tsx so that file exports only\n// React components and stays Fast-Refresh-compatible in dev.\nexport { interact } from \"./PolymarketAppView.interact\";\nexport { PolymarketView } from \"./PolymarketView.js\";\n"],"mappings":"AAKA,SAAS,gBAAgB;AACzB,SAAS,sBAAsB;","names":[]}
@@ -0,0 +1,5 @@
1
+ export declare function derivePolymarketStatusText(env: Record<string, string | undefined>): {
2
+ text: string;
3
+ data: Record<string, unknown>;
4
+ };
5
+ //# sourceMappingURL=provider-text.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider-text.d.ts","sourceRoot":"","sources":["../src/provider-text.ts"],"names":[],"mappings":"AAuBA,wBAAgB,0BAA0B,CACxC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GACtC;IACD,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B,CA0BA"}
@@ -0,0 +1,44 @@
1
+ import {
2
+ POLYMARKET_CLOB_API_BASE,
3
+ POLYMARKET_DATA_API_BASE,
4
+ POLYMARKET_GAMMA_API_BASE,
5
+ POLYMARKET_TRADING_ENV_VARS
6
+ } from "./polymarket-contracts.js";
7
+ const TRADING_ENV_ALIASES = {
8
+ CLOB_API_KEY: ["POLYMARKET_CLOB_API_KEY"],
9
+ CLOB_API_SECRET: ["POLYMARKET_CLOB_SECRET"],
10
+ CLOB_API_PASSPHRASE: ["POLYMARKET_CLOB_PASSPHRASE"]
11
+ };
12
+ function hasTradingEnvVar(env, name) {
13
+ if (env[name]?.trim()) return true;
14
+ return (TRADING_ENV_ALIASES[name] ?? []).some((alias) => env[alias]?.trim());
15
+ }
16
+ function derivePolymarketStatusText(env) {
17
+ const missing = POLYMARKET_TRADING_ENV_VARS.filter(
18
+ (name) => !hasTradingEnvVar(env, name)
19
+ );
20
+ const credentialsReady = missing.length === 0;
21
+ const text = [
22
+ "Polymarket app context:",
23
+ "- Public reads: ready",
24
+ `- Gamma API: ${POLYMARKET_GAMMA_API_BASE}`,
25
+ `- Data API: ${POLYMARKET_DATA_API_BASE}`,
26
+ `- CLOB API: ${POLYMARKET_CLOB_API_BASE}`,
27
+ `- Trading credentials: ${credentialsReady ? "present" : "missing"}`,
28
+ "- Signed trading: disabled in this app integration",
29
+ missing.length ? `- Missing: ${missing.join(", ")}` : null
30
+ ].filter(Boolean).join("\n");
31
+ return {
32
+ text,
33
+ data: {
34
+ publicReadsReady: true,
35
+ tradingReady: false,
36
+ credentialsReady,
37
+ missing
38
+ }
39
+ };
40
+ }
41
+ export {
42
+ derivePolymarketStatusText
43
+ };
44
+ //# sourceMappingURL=provider-text.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/provider-text.ts"],"sourcesContent":["import {\n POLYMARKET_CLOB_API_BASE,\n POLYMARKET_DATA_API_BASE,\n POLYMARKET_GAMMA_API_BASE,\n POLYMARKET_TRADING_ENV_VARS,\n type PolymarketTradingEnvVar,\n} from \"./polymarket-contracts.js\";\n\nconst TRADING_ENV_ALIASES: Partial<Record<PolymarketTradingEnvVar, string[]>> =\n {\n CLOB_API_KEY: [\"POLYMARKET_CLOB_API_KEY\"],\n CLOB_API_SECRET: [\"POLYMARKET_CLOB_SECRET\"],\n CLOB_API_PASSPHRASE: [\"POLYMARKET_CLOB_PASSPHRASE\"],\n };\n\nfunction hasTradingEnvVar(\n env: Record<string, string | undefined>,\n name: PolymarketTradingEnvVar,\n): boolean {\n if (env[name]?.trim()) return true;\n return (TRADING_ENV_ALIASES[name] ?? []).some((alias) => env[alias]?.trim());\n}\n\nexport function derivePolymarketStatusText(\n env: Record<string, string | undefined>,\n): {\n text: string;\n data: Record<string, unknown>;\n} {\n const missing = POLYMARKET_TRADING_ENV_VARS.filter(\n (name) => !hasTradingEnvVar(env, name),\n );\n const credentialsReady = missing.length === 0;\n const text = [\n \"Polymarket app context:\",\n \"- Public reads: ready\",\n `- Gamma API: ${POLYMARKET_GAMMA_API_BASE}`,\n `- Data API: ${POLYMARKET_DATA_API_BASE}`,\n `- CLOB API: ${POLYMARKET_CLOB_API_BASE}`,\n `- Trading credentials: ${credentialsReady ? \"present\" : \"missing\"}`,\n \"- Signed trading: disabled in this app integration\",\n missing.length ? `- Missing: ${missing.join(\", \")}` : null,\n ]\n .filter(Boolean)\n .join(\"\\n\");\n return {\n text,\n data: {\n publicReadsReady: true,\n tradingReady: false,\n credentialsReady,\n missing,\n },\n };\n}\n"],"mappings":"AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AAEP,MAAM,sBACJ;AAAA,EACE,cAAc,CAAC,yBAAyB;AAAA,EACxC,iBAAiB,CAAC,wBAAwB;AAAA,EAC1C,qBAAqB,CAAC,4BAA4B;AACpD;AAEF,SAAS,iBACP,KACA,MACS;AACT,MAAI,IAAI,IAAI,GAAG,KAAK,EAAG,QAAO;AAC9B,UAAQ,oBAAoB,IAAI,KAAK,CAAC,GAAG,KAAK,CAAC,UAAU,IAAI,KAAK,GAAG,KAAK,CAAC;AAC7E;AAEO,SAAS,2BACd,KAIA;AACA,QAAM,UAAU,4BAA4B;AAAA,IAC1C,CAAC,SAAS,CAAC,iBAAiB,KAAK,IAAI;AAAA,EACvC;AACA,QAAM,mBAAmB,QAAQ,WAAW;AAC5C,QAAM,OAAO;AAAA,IACX;AAAA,IACA;AAAA,IACA,gBAAgB,yBAAyB;AAAA,IACzC,eAAe,wBAAwB;AAAA,IACvC,eAAe,wBAAwB;AAAA,IACvC,0BAA0B,mBAAmB,YAAY,SAAS;AAAA,IAClE;AAAA,IACA,QAAQ,SAAS,cAAc,QAAQ,KAAK,IAAI,CAAC,KAAK;AAAA,EACxD,EACG,OAAO,OAAO,EACd,KAAK,IAAI;AACZ,SAAO;AAAA,IACL;AAAA,IACA,MAAM;AAAA,MACJ,kBAAkB;AAAA,MAClB,cAAc;AAAA,MACd;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
@@ -0,0 +1,3 @@
1
+ import type { Provider } from "@elizaos/core";
2
+ export declare const polymarketStatusProvider: Provider;
3
+ //# sourceMappingURL=provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,QAAQ,EAGT,MAAM,eAAe,CAAC;AAGvB,eAAO,MAAM,wBAAwB,EAAE,QAgBtC,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { derivePolymarketStatusText } from "./provider-text.js";
2
+ const polymarketStatusProvider = {
3
+ name: "POLYMARKET_STATUS",
4
+ description: "Polymarket app readiness context including public reads and trading configuration.",
5
+ dynamic: true,
6
+ contexts: ["finance", "crypto"],
7
+ contextGate: { anyOf: ["finance", "crypto"] },
8
+ cacheStable: false,
9
+ cacheScope: "turn",
10
+ get: async (_runtime, _message, _state) => {
11
+ const status = derivePolymarketStatusText(process.env);
12
+ return {
13
+ text: status.text,
14
+ data: status.data
15
+ };
16
+ }
17
+ };
18
+ export {
19
+ polymarketStatusProvider
20
+ };
21
+ //# sourceMappingURL=provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/provider.ts"],"sourcesContent":["import type {\n IAgentRuntime,\n Memory,\n Provider,\n ProviderDataRecord,\n State,\n} from \"@elizaos/core\";\nimport { derivePolymarketStatusText } from \"./provider-text.js\";\n\nexport const polymarketStatusProvider: Provider = {\n name: \"POLYMARKET_STATUS\",\n description:\n \"Polymarket app readiness context including public reads and trading configuration.\",\n dynamic: true,\n contexts: [\"finance\", \"crypto\"],\n contextGate: { anyOf: [\"finance\", \"crypto\"] },\n cacheStable: false,\n cacheScope: \"turn\",\n get: async (_runtime: IAgentRuntime, _message: Memory, _state: State) => {\n const status = derivePolymarketStatusText(process.env);\n return {\n text: status.text,\n data: status.data as ProviderDataRecord,\n };\n },\n};\n"],"mappings":"AAOA,SAAS,kCAAkC;AAEpC,MAAM,2BAAqC;AAAA,EAChD,MAAM;AAAA,EACN,aACE;AAAA,EACF,SAAS;AAAA,EACT,UAAU,CAAC,WAAW,QAAQ;AAAA,EAC9B,aAAa,EAAE,OAAO,CAAC,WAAW,QAAQ,EAAE;AAAA,EAC5C,aAAa;AAAA,EACb,YAAY;AAAA,EACZ,KAAK,OAAO,UAAyB,UAAkB,WAAkB;AACvE,UAAM,SAAS,2BAA2B,QAAQ,GAAG;AACrD,WAAO;AAAA,MACL,MAAM,OAAO;AAAA,MACb,MAAM,OAAO;AAAA,IACf;AAAA,EACF;AACF;","names":[]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=register-routes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register-routes.d.ts","sourceRoot":"","sources":["../src/register-routes.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ import { registerAppRoutePluginLoader } from "@elizaos/core";
2
+ registerAppRoutePluginLoader("@elizaos/plugin-polymarket-app", async () => {
3
+ const { polymarketPlugin } = await import("./plugin.js");
4
+ return polymarketPlugin;
5
+ });
6
+ //# sourceMappingURL=register-routes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/register-routes.ts"],"sourcesContent":["import { registerAppRoutePluginLoader } from \"@elizaos/core\";\n\nregisterAppRoutePluginLoader(\"@elizaos/plugin-polymarket-app\", async () => {\n const { polymarketPlugin } = await import(\"./plugin.js\");\n return polymarketPlugin;\n});\n"],"mappings":"AAAA,SAAS,oCAAoC;AAE7C,6BAA6B,kCAAkC,YAAY;AACzE,QAAM,EAAE,iBAAiB,IAAI,MAAM,OAAO,aAAa;AACvD,SAAO;AACT,CAAC;","names":[]}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Register the Polymarket view for terminal rendering.
3
+ *
4
+ * The agent terminal mounts plugin views by id from the `@elizaos/tui` terminal
5
+ * registry. This makes Polymarket's `viewType: "tui"` declaration render for real
6
+ * in the terminal (the unified {@link PolymarketSpatialView}) rather than only
7
+ * navigating a GUI shell. A module-level snapshot lets a host push live market
8
+ * data; before any data loads it defaults to an empty, read-blocked view.
9
+ */
10
+ import { type PolymarketSnapshot } from "./components/PolymarketSpatialView.tsx";
11
+ /** Update the snapshot the registered terminal view renders from. */
12
+ export declare function setPolymarketTerminalSnapshot(next: PolymarketSnapshot): void;
13
+ /** Register the Polymarket terminal view; returns an unregister function. */
14
+ export declare function registerPolymarketTerminalView(): () => void;
15
+ //# sourceMappingURL=register-terminal-view.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register-terminal-view.d.ts","sourceRoot":"","sources":["../src/register-terminal-view.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,EACL,KAAK,kBAAkB,EAExB,MAAM,wCAAwC,CAAC;AAShD,qEAAqE;AACrE,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,kBAAkB,GAAG,IAAI,CAE5E;AAED,6EAA6E;AAC7E,wBAAgB,8BAA8B,IAAI,MAAM,IAAI,CAI3D"}
@@ -0,0 +1,25 @@
1
+ import { registerSpatialTerminalView } from "@elizaos/ui/spatial/tui";
2
+ import { createElement } from "react";
3
+ import {
4
+ PolymarketSpatialView
5
+ } from "./components/PolymarketSpatialView.js";
6
+ const EMPTY = {
7
+ status: null,
8
+ markets: [],
9
+ selectedMarket: null
10
+ };
11
+ let current = EMPTY;
12
+ function setPolymarketTerminalSnapshot(next) {
13
+ current = next;
14
+ }
15
+ function registerPolymarketTerminalView() {
16
+ return registerSpatialTerminalView(
17
+ "polymarket",
18
+ () => createElement(PolymarketSpatialView, { snapshot: current })
19
+ );
20
+ }
21
+ export {
22
+ registerPolymarketTerminalView,
23
+ setPolymarketTerminalSnapshot
24
+ };
25
+ //# sourceMappingURL=register-terminal-view.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/register-terminal-view.tsx"],"sourcesContent":["/**\n * Register the Polymarket view for terminal rendering.\n *\n * The agent terminal mounts plugin views by id from the `@elizaos/tui` terminal\n * registry. This makes Polymarket's `viewType: \"tui\"` declaration render for real\n * in the terminal (the unified {@link PolymarketSpatialView}) rather than only\n * navigating a GUI shell. A module-level snapshot lets a host push live market\n * data; before any data loads it defaults to an empty, read-blocked view.\n */\n\nimport { registerSpatialTerminalView } from \"@elizaos/ui/spatial/tui\";\nimport { createElement } from \"react\";\nimport {\n type PolymarketSnapshot,\n PolymarketSpatialView,\n} from \"./components/PolymarketSpatialView.js\";\n\nconst EMPTY: PolymarketSnapshot = {\n status: null,\n markets: [],\n selectedMarket: null,\n};\nlet current: PolymarketSnapshot = EMPTY;\n\n/** Update the snapshot the registered terminal view renders from. */\nexport function setPolymarketTerminalSnapshot(next: PolymarketSnapshot): void {\n current = next;\n}\n\n/** Register the Polymarket terminal view; returns an unregister function. */\nexport function registerPolymarketTerminalView(): () => void {\n return registerSpatialTerminalView(\"polymarket\", () =>\n createElement(PolymarketSpatialView, { snapshot: current }),\n );\n}\n"],"mappings":"AAUA,SAAS,mCAAmC;AAC5C,SAAS,qBAAqB;AAC9B;AAAA,EAEE;AAAA,OACK;AAEP,MAAM,QAA4B;AAAA,EAChC,QAAQ;AAAA,EACR,SAAS,CAAC;AAAA,EACV,gBAAgB;AAClB;AACA,IAAI,UAA8B;AAG3B,SAAS,8BAA8B,MAAgC;AAC5E,YAAU;AACZ;AAGO,SAAS,iCAA6C;AAC3D,SAAO;AAAA,IAA4B;AAAA,IAAc,MAC/C,cAAc,uBAAuB,EAAE,UAAU,QAAQ,CAAC;AAAA,EAC5D;AACF;","names":[]}
@@ -0,0 +1,2 @@
1
+ import "./polymarket-app";
2
+ //# sourceMappingURL=register.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../src/register.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC"}