teleton 0.3.0 → 0.5.1

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 (39) hide show
  1. package/README.md +219 -95
  2. package/dist/BigInteger-DQ33LTTE.js +5 -0
  3. package/dist/chunk-4DU3C27M.js +30 -0
  4. package/dist/chunk-5WWR4CU3.js +124 -0
  5. package/dist/{chunk-QQW6KE7Q.js → chunk-BYTHCDZA.js} +282 -263
  6. package/dist/chunk-EHEV7FJ7.js +157 -0
  7. package/dist/{chunk-E2NXSWOS.js → chunk-NUGDTPE4.js} +24 -64
  8. package/dist/{chunk-UYF4TT44.js → chunk-O4R7V5Y2.js} +38 -6
  9. package/dist/chunk-QUAPFI2N.js +42 -0
  10. package/dist/{chunk-ILDG4OPK.js → chunk-RRB6BWU7.js} +9411 -10083
  11. package/dist/chunk-TSKJCWQQ.js +1263 -0
  12. package/dist/{chunk-B2PRMXOH.js → chunk-WL2Q3VRD.js} +0 -2
  13. package/dist/{chunk-OQGNS2FV.js → chunk-YBA6IBGT.js} +20 -5
  14. package/dist/cli/index.js +42 -176
  15. package/dist/endpoint-FLYNEZ2F.js +7 -0
  16. package/dist/format-transactions-FD74HI5N.js +9 -0
  17. package/dist/{get-my-gifts-AFKBG4YQ.js → get-my-gifts-KVULMBJ3.js} +1 -1
  18. package/dist/index.js +13 -11
  19. package/dist/{memory-ZXDAJBL6.js → memory-657W5AS6.js} +4 -5
  20. package/dist/{migrate-7OG67FXP.js → migrate-PMB2JVXH.js} +4 -5
  21. package/dist/server-BQY7CM2N.js +1120 -0
  22. package/dist/{task-dependency-resolver-S45DFI5C.js → task-dependency-resolver-TRPILAHM.js} +4 -4
  23. package/dist/{task-executor-AUTT3VAL.js → task-executor-N7XNVK5N.js} +1 -1
  24. package/dist/{tasks-M3QDPTGY.js → tasks-QSCWSMPS.js} +1 -1
  25. package/dist/{transcript-DF2Y6CFY.js → transcript-7V4UNID4.js} +1 -1
  26. package/dist/web/assets/index-CDMbujHf.css +1 -0
  27. package/dist/web/assets/index-DDX8oQ2z.js +67 -0
  28. package/dist/web/index.html +16 -0
  29. package/dist/web/logo_dark.png +0 -0
  30. package/package.json +23 -4
  31. package/src/templates/IDENTITY.md +1 -1
  32. package/src/templates/MEMORY.md +1 -0
  33. package/src/templates/SECURITY.md +5 -0
  34. package/src/templates/SOUL.md +3 -2
  35. package/dist/chunk-DAMFGHXV.js +0 -74
  36. package/dist/chunk-DUW5VBAZ.js +0 -133
  37. package/dist/chunk-LCMHAUNK.js +0 -62
  38. package/dist/scraper-KXRBQMVQ.js +0 -282
  39. package/dist/timeouts-ZAK6NELA.js +0 -63
@@ -1,282 +0,0 @@
1
- import {
2
- addPriceHistory,
3
- getCollectionId,
4
- getScraperStats,
5
- initScraperDb,
6
- upsertCollection,
7
- upsertModel
8
- } from "./chunk-DUW5VBAZ.js";
9
- import {
10
- MARKETAPP_BASE_URL
11
- } from "./chunk-DAMFGHXV.js";
12
- import {
13
- SCRAPER_PARALLEL_WORKERS
14
- } from "./chunk-UYF4TT44.js";
15
- import "./chunk-EYWNOHMJ.js";
16
- import {
17
- BROWSER_NAVIGATION_TIMEOUT_MS,
18
- SCRAPER_COLLECTION_NAV_MS,
19
- SCRAPER_COLLECTION_SCROLL_MS,
20
- SCRAPER_FILTER_CLICK_MS,
21
- SCRAPER_FILTER_OPEN_MS,
22
- SCRAPER_MAX_SCROLL_ITERATIONS,
23
- SCRAPER_MODEL_CLICK_MS,
24
- SCRAPER_MODEL_OPEN_MS,
25
- SCRAPER_PAGE_LOAD_MS,
26
- SCRAPER_PRE_SCROLL_MS,
27
- SCRAPER_SCROLL_INCREMENT_PX,
28
- SCRAPER_SCROLL_PADDING_PX,
29
- SCRAPER_SCROLL_STEP_MS
30
- } from "./chunk-LCMHAUNK.js";
31
- import "./chunk-QGM4M3NI.js";
32
-
33
- // src/market/scraper.ts
34
- import { chromium } from "playwright";
35
- async function scrapeAllModels(page, collection, db) {
36
- try {
37
- const url = `${MARKETAPP_BASE_URL}/collection/${collection.address}/?tab=nfts`;
38
- await page.goto(url, { waitUntil: "domcontentloaded", timeout: BROWSER_NAVIGATION_TIMEOUT_MS });
39
- await page.waitForTimeout(SCRAPER_PAGE_LOAD_MS);
40
- try {
41
- await page.click('button:has-text("Filters")', { timeout: SCRAPER_FILTER_CLICK_MS });
42
- await page.waitForTimeout(SCRAPER_FILTER_OPEN_MS);
43
- } catch (e) {
44
- return 0;
45
- }
46
- try {
47
- await page.click("text=Model", { timeout: SCRAPER_MODEL_CLICK_MS });
48
- await page.waitForTimeout(SCRAPER_MODEL_OPEN_MS);
49
- } catch (e) {
50
- return 0;
51
- }
52
- const allModels = /* @__PURE__ */ new Map();
53
- const wrapperHeight = await page.evaluate(() => {
54
- const wrappers = document.querySelectorAll(".virtual-scroll-wrapper");
55
- const wrapper = wrappers[1];
56
- return wrapper ? wrapper.scrollHeight : 0;
57
- });
58
- for (let scrollPos = 0; scrollPos <= wrapperHeight + SCRAPER_SCROLL_PADDING_PX; scrollPos += SCRAPER_SCROLL_INCREMENT_PX) {
59
- const text = await page.evaluate((pos) => {
60
- const wrappers = document.querySelectorAll(".virtual-scroll-wrapper");
61
- const wrapper = wrappers[1];
62
- if (wrapper) {
63
- wrapper.scrollTop = pos;
64
- return wrapper.innerText;
65
- }
66
- return "";
67
- }, scrollPos);
68
- if (text) {
69
- const lines = text.split("\n").map((l) => l.trim()).filter((l) => l);
70
- let currentModel = null;
71
- for (const line of lines) {
72
- if (line.length > 1 && line.length < 50 && !line.match(/^[\d,.]+$/) && !line.startsWith("Floor:") && !line.includes("%")) {
73
- currentModel = { name: line, floor: null, count: null, pct: null };
74
- }
75
- if (line.startsWith("Floor:") && currentModel) {
76
- const match = line.match(/Floor:\s*([\d,.]+)/);
77
- if (match) currentModel.floor = parseFloat(match[1].replace(/,/g, ""));
78
- }
79
- if (currentModel && line.match(/^\d+$/) && !currentModel.count) {
80
- currentModel.count = parseInt(line);
81
- }
82
- if (line.includes("%") && currentModel) {
83
- currentModel.pct = line;
84
- if (currentModel.name && currentModel.floor) {
85
- allModels.set(currentModel.name, { ...currentModel });
86
- }
87
- currentModel = null;
88
- }
89
- }
90
- }
91
- await page.waitForTimeout(SCRAPER_SCROLL_STEP_MS);
92
- }
93
- const models = [...allModels.values()];
94
- const collectionId = getCollectionId(db, collection.address);
95
- if (!collectionId) return 0;
96
- for (const model of models) {
97
- const modelId = upsertModel(db, collectionId, model);
98
- if (model.floor) {
99
- addPriceHistory(db, collectionId, modelId, model.floor);
100
- }
101
- }
102
- return models.length;
103
- } catch (error) {
104
- return -1;
105
- }
106
- }
107
- async function createWorker(browser, db) {
108
- const context = await browser.newContext({
109
- userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36",
110
- viewport: { width: 1920, height: 1080 }
111
- });
112
- const page = await context.newPage();
113
- return {
114
- page,
115
- async scrape(collection) {
116
- return await scrapeAllModels(page, collection, db);
117
- },
118
- async close() {
119
- await context.close();
120
- }
121
- };
122
- }
123
- async function getCollections(page, db) {
124
- await page.goto(`${MARKETAPP_BASE_URL}/?tab=gifts&sort_by=floor_desc`, {
125
- waitUntil: "domcontentloaded",
126
- timeout: SCRAPER_COLLECTION_NAV_MS
127
- });
128
- await page.waitForTimeout(SCRAPER_PRE_SCROLL_MS);
129
- for (let i = 0; i < SCRAPER_MAX_SCROLL_ITERATIONS; i++) {
130
- await page.evaluate(() => window.scrollBy(0, 2e3));
131
- await page.waitForTimeout(SCRAPER_COLLECTION_SCROLL_MS);
132
- }
133
- const collections = await page.evaluate(() => {
134
- const results = [];
135
- const text = document.body.innerText;
136
- const lines = text.split("\n").map((l) => l.trim()).filter((l) => l);
137
- for (let i = 0; i < lines.length; i++) {
138
- if (lines[i] === "1% fee" && i > 0) {
139
- const name = lines[i - 1];
140
- if (name.length < 3 || name.length > 40 || name === "Name") continue;
141
- let floorTON = null;
142
- let floorUSD = null;
143
- let volume7d = null;
144
- let skipNext = 0;
145
- for (let j = i + 1; j < Math.min(i + 12, lines.length); j++) {
146
- const val = lines[j];
147
- if (floorTON === null && val.match(/^[\d,.]+$/)) {
148
- floorTON = parseFloat(val.replace(/,/g, ""));
149
- continue;
150
- }
151
- if (floorTON !== null && floorUSD === null && val.startsWith("~$")) {
152
- floorUSD = parseFloat(val.replace("~$", "").replace(/,/g, ""));
153
- skipNext = 2;
154
- continue;
155
- }
156
- if (skipNext > 0 && (val.match(/^[\d,.]+$/) || val.startsWith("~$"))) {
157
- skipNext--;
158
- continue;
159
- }
160
- if (floorUSD !== null && volume7d === null && skipNext === 0) {
161
- const volMatch = val.match(/^([\d,.]+)(K|M)?$/);
162
- if (volMatch) {
163
- let vol = parseFloat(volMatch[1].replace(/,/g, ""));
164
- if (volMatch[2] === "K") vol *= 1e3;
165
- if (volMatch[2] === "M") vol *= 1e6;
166
- volume7d = vol;
167
- break;
168
- }
169
- }
170
- if (val === "1% fee") break;
171
- }
172
- if (name && floorTON) {
173
- results.push({ name, floorTON, floorUSD, volume7d, address: null });
174
- }
175
- }
176
- }
177
- const links = document.querySelectorAll('a[href*="/collection/"]');
178
- const addressMap = /* @__PURE__ */ new Map();
179
- links.forEach((link) => {
180
- const href = link.getAttribute("href");
181
- if (!href) return;
182
- const match = href.match(/\/collection\/([^/?]+)/);
183
- if (match) {
184
- const text2 = link.textContent?.trim().split("\n")[0];
185
- if (text2 && text2.length > 2) addressMap.set(text2, match[1]);
186
- }
187
- });
188
- return results.map((r) => ({
189
- ...r,
190
- address: addressMap.get(r.name) || [...addressMap.entries()].find(
191
- ([k]) => k.toLowerCase().includes(r.name.toLowerCase().slice(0, 10))
192
- )?.[1] || null
193
- })).filter((r) => r.address);
194
- });
195
- for (const col of collections) {
196
- const collectionId = upsertCollection(db, col);
197
- addPriceHistory(db, collectionId, null, col.floorTON, col.floorUSD);
198
- }
199
- return collections;
200
- }
201
- async function runScraper(options) {
202
- const workers = options.workers || SCRAPER_PARALLEL_WORKERS;
203
- const limit = options.limit || 0;
204
- console.log("=".repeat(60));
205
- console.log(`SCRAPING ALL MODELS (${workers} workers)`);
206
- console.log("=".repeat(60));
207
- const db = initScraperDb();
208
- const startTime = Date.now();
209
- let browser = null;
210
- try {
211
- browser = await chromium.launch({ headless: true });
212
- console.log("\n1. Collections...");
213
- const mainCtx = await browser.newContext({
214
- userAgent: "Mozilla/5.0",
215
- viewport: { width: 1920, height: 1080 }
216
- });
217
- const mainPage = await mainCtx.newPage();
218
- const collections = await getCollections(mainPage, db);
219
- await mainCtx.close();
220
- console.log(` \u2713 ${collections.length} collections`);
221
- console.log(`
222
- 2. Workers (${workers})...`);
223
- const workerPool = await Promise.all(
224
- Array(workers).fill(null).map(() => createWorker(browser, db))
225
- );
226
- const toProcess = limit > 0 ? collections.slice(0, limit) : collections;
227
- console.log(`
228
- 3. Scraping ${toProcess.length} collections (all models)...
229
- `);
230
- let completed = 0;
231
- let totalModels = 0;
232
- const queue = [...toProcess];
233
- async function processNext(worker) {
234
- while (queue.length > 0) {
235
- const col = queue.shift();
236
- if (!col) break;
237
- const count = await worker.scrape(col);
238
- completed++;
239
- const status = count > 0 ? `\u2713 ${count.toString().padStart(2)}` : count === 0 ? "- 0 " : "\u2717 ";
240
- if (count > 0) totalModels += count;
241
- const elapsed2 = ((Date.now() - startTime) / 1e3).toFixed(1);
242
- console.log(
243
- ` [${completed.toString().padStart(3)}/${toProcess.length}] ${col.name.padEnd(
244
- 22
245
- )} ${status} (${elapsed2}s)`
246
- );
247
- }
248
- }
249
- await Promise.all(workerPool.map((w) => processNext(w)));
250
- await Promise.all(workerPool.map((w) => w.close()));
251
- const elapsed = ((Date.now() - startTime) / 1e3).toFixed(1);
252
- const stats = getScraperStats(db);
253
- console.log("\n" + "=".repeat(60));
254
- console.log(`DONE in ${elapsed}s`);
255
- console.log("=".repeat(60));
256
- console.log(`Collections: ${stats.collections}`);
257
- console.log(`Models: ${stats.models}`);
258
- console.log(`History entries: ${stats.historyEntries}`);
259
- return {
260
- success: true,
261
- collections: stats.collections,
262
- models: stats.models,
263
- duration: parseInt(elapsed)
264
- };
265
- } catch (error) {
266
- return {
267
- success: false,
268
- collections: 0,
269
- models: 0,
270
- duration: Math.round((Date.now() - startTime) / 1e3),
271
- error: error instanceof Error ? error.message : String(error)
272
- };
273
- } finally {
274
- if (browser) {
275
- await browser.close();
276
- }
277
- db.close();
278
- }
279
- }
280
- export {
281
- runScraper
282
- };
@@ -1,63 +0,0 @@
1
- import {
2
- BATCH_TRIGGER_DELAY_MS,
3
- BROWSER_NAVIGATION_TIMEOUT_MS,
4
- DEFAULT_FETCH_TIMEOUT_MS,
5
- GRAMJS_RETRY_DELAY_MS,
6
- MESSAGE_HANDLER_LOCK_TIMEOUT_MS,
7
- ONBOARDING_PROMPT_TIMEOUT_MS,
8
- RETRY_BLOCKCHAIN_BASE_DELAY_MS,
9
- RETRY_BLOCKCHAIN_MAX_DELAY_MS,
10
- RETRY_BLOCKCHAIN_TIMEOUT_MS,
11
- RETRY_DEFAULT_BASE_DELAY_MS,
12
- RETRY_DEFAULT_MAX_ATTEMPTS,
13
- RETRY_DEFAULT_MAX_DELAY_MS,
14
- RETRY_DEFAULT_TIMEOUT_MS,
15
- SCRAPER_COLLECTION_NAV_MS,
16
- SCRAPER_COLLECTION_SCROLL_MS,
17
- SCRAPER_FILTER_CLICK_MS,
18
- SCRAPER_FILTER_OPEN_MS,
19
- SCRAPER_MAX_SCROLL_ITERATIONS,
20
- SCRAPER_MODEL_CLICK_MS,
21
- SCRAPER_MODEL_OPEN_MS,
22
- SCRAPER_PAGE_LOAD_MS,
23
- SCRAPER_PRE_SCROLL_MS,
24
- SCRAPER_SCROLL_INCREMENT_PX,
25
- SCRAPER_SCROLL_PADDING_PX,
26
- SCRAPER_SCROLL_STEP_MS,
27
- SCRAPER_WINDOW_SCROLL_PX,
28
- SHUTDOWN_TIMEOUT_MS,
29
- TOOL_EXECUTION_TIMEOUT_MS,
30
- TTS_TIMEOUT_MS
31
- } from "./chunk-LCMHAUNK.js";
32
- import "./chunk-QGM4M3NI.js";
33
- export {
34
- BATCH_TRIGGER_DELAY_MS,
35
- BROWSER_NAVIGATION_TIMEOUT_MS,
36
- DEFAULT_FETCH_TIMEOUT_MS,
37
- GRAMJS_RETRY_DELAY_MS,
38
- MESSAGE_HANDLER_LOCK_TIMEOUT_MS,
39
- ONBOARDING_PROMPT_TIMEOUT_MS,
40
- RETRY_BLOCKCHAIN_BASE_DELAY_MS,
41
- RETRY_BLOCKCHAIN_MAX_DELAY_MS,
42
- RETRY_BLOCKCHAIN_TIMEOUT_MS,
43
- RETRY_DEFAULT_BASE_DELAY_MS,
44
- RETRY_DEFAULT_MAX_ATTEMPTS,
45
- RETRY_DEFAULT_MAX_DELAY_MS,
46
- RETRY_DEFAULT_TIMEOUT_MS,
47
- SCRAPER_COLLECTION_NAV_MS,
48
- SCRAPER_COLLECTION_SCROLL_MS,
49
- SCRAPER_FILTER_CLICK_MS,
50
- SCRAPER_FILTER_OPEN_MS,
51
- SCRAPER_MAX_SCROLL_ITERATIONS,
52
- SCRAPER_MODEL_CLICK_MS,
53
- SCRAPER_MODEL_OPEN_MS,
54
- SCRAPER_PAGE_LOAD_MS,
55
- SCRAPER_PRE_SCROLL_MS,
56
- SCRAPER_SCROLL_INCREMENT_PX,
57
- SCRAPER_SCROLL_PADDING_PX,
58
- SCRAPER_SCROLL_STEP_MS,
59
- SCRAPER_WINDOW_SCROLL_PX,
60
- SHUTDOWN_TIMEOUT_MS,
61
- TOOL_EXECUTION_TIMEOUT_MS,
62
- TTS_TIMEOUT_MS
63
- };