Spaces:
Sleeping
Sleeping
Johnsteve Costanos commited on
Commit ·
9ed3ad8
1
Parent(s): 9914e5c
Fix Dola SSE parsing: use for-await stream, handle STREAM_MSG_NOTIFY + STREAM_CHUNK + SSE_REPLY_END events
Browse filesFiles changed (12)
- data/dola_cookies.jsonAdded+20
- dola_capture.mjsAdded+68
- dola_debug.mjsAdded+83
- dola_interact.mjsAdded+103
- dola_scrape.mjsAdded+152
- dola_sse.mjsAdded+63
- package-lock.json+298
- package.json+1
- scrape_deepseek2.jsAdded+45
- src/core/deepseek.js+6-5
- src/core/dola.js+66-56
- test_dola.mjsAdded+8
1234567891011121314151617181920[ {"name":"_ga","value":"GA1.1.893565526.1782523872","domain":".dola.com","path":"/"}, {"name":"_ga_5MR93B9JT5","value":"GS2.1.s1782523872$o1$g1$t1782523999$j60$l0$h0","domain":".dola.com","path":"/"}, {"name":"sessionid","value":"9817b0693aa49444cdbc4c684beab70f","domain":".dola.com","path":"/"}, {"name":"oauth_token","value":"95be823c-17e4-4b38-b7da-e8471a6de8f3","domain":".dola.com","path":"/"}, {"name":"oauth_token_v2","value":"95be823c-17e4-4b38-b7da-e8471a6de8f3","domain":".dola.com","path":"/"}, {"name":"sid_guard","value":"9817b0693aa49444cdbc4c684beab70f%7C1782523946%7C5184000%7CWed%2C+26-Aug-2026+01%3A32%3A26+GMT","domain":".dola.com","path":"/"}, {"name":"sid_tt","value":"9817b0693aa49444cdbc4c684beab70f","domain":".dola.com","path":"/"}, {"name":"uid_tt","value":"bfdae90a249cb0167f79d62c64429bd2ea5637c1e7687df1a92f5f90f7656f04","domain":".dola.com","path":"/"}, {"name":"uid_tt_ss","value":"bfdae90a249cb0167f79d62c64429bd2ea5637c1e7687df1a92f5f90f7656f04","domain":".dola.com","path":"/"}, {"name":"sid_ucp_v1","value":"1.0.0-KDJmYjNhOGY3ZDY2ZWQ1YzJkZWNjMDM0MDA5ZDdiN2RlNTQxNTIzMjUKIAiBiOLkvZXGpGcQqtD80QYYt6AeIAww27GkugY4CEASEAMaA215YSIgOTgxN2IwNjkzYWE0OTQ0NGNkYmM0YzY4NGJlYWI3MGY","domain":".dola.com","path":"/"}, {"name":"ttwid","value":"1%7CV7wxcR2ZConDtvZpam3JOx1YwpUdw5fNnrZmMnZd_ss%7C1782523961%7C16311b439bb21763f13ef8d106065753ea1d1df6d8864e11fbc503f68eefe081","domain":".dola.com","path":"/"}, {"name":"passport_csrf_token","value":"724ddac828f7eb1ad1e7c404bffdbad3","domain":".dola.com","path":"/"}, {"name":"passport_csrf_token_default","value":"724ddac828f7eb1ad1e7c404bffdbad3","domain":".dola.com","path":"/"}, {"name":"store-country-code","value":"ph","domain":".dola.com","path":"/"}, {"name":"store-country-code-src","value":"uid","domain":".dola.com","path":"/"}, {"name":"store-idc","value":"mya","domain":".dola.com","path":"/"}, {"name":"i18next","value":"en","domain":"www.dola.com","path":"/"}, {"name":"msToken","value":"q2V1UDjy6Dx7xwo5KIExi_N3Cr20ZIJ3jAZj90c4UNVG6blySGvRSrpHNEBBdpsJn6I3cHqPO1RTCI15dpzmLp7fiFY1x7emAdryuBQqxkF-6hEC-4Fy-GMsqKjlnrc=","domain":"www.dola.com","path":"/"}]1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768import puppeteer from 'puppeteer-core';import fs from 'fs';
const rawCookies = JSON.parse(fs.readFileSync('/tmp/dola_cookies.json', 'utf8'));
const browser = await puppeteer.launch({ headless: true, executablePath: '/usr/bin/chromium', args: ['--no-sandbox', '--disable-setuid-sandbox', '--disable-gpu']});
const page = await browser.newPage();await page.setCookie(...rawCookies.map(c => ({ name: c.name, value: c.value, domain: c.domain === '.dola.com' ? 'dola.com' : c.domain.replace(/^\./, ''), path: c.path, httpOnly: c.httpOnly || false, secure: c.secure || false, sameSite: 'Lax',})));
// Capture all IM request/responsespage.on('request', req => { const url = req.url(); if (url.includes('dola.com/') && req.method() === 'POST' && !url.includes('.js') && !url.includes('.css') && !url.includes('.png') && !url.includes('.svg')) { const pd = req.postData(); console.log('\n>>> REQ:', req.method(), url.split('?')[0]); if (pd) console.log(' BODY:', pd.substring(0, 1500)); }});
page.on('response', async res => { const url = res.url(); if (url.includes('dola.com/') && !url.includes('.js') && !url.includes('.css') && !url.includes('.png')) { const ct = res.headers()['content-type'] || ''; if (ct.includes('json')) { try { const body = await res.json(); console.log('<<< RES:', res.status(), url.split('?')[0]); console.log(' BODY:', JSON.stringify(body).substring(0, 1500)); } catch(e) { console.log('<<< RES:', res.status(), url.split('?')[0], '(parse err)'); } } }});
console.log('Loading chat...');await page.goto('https://www.dola.com/chat', { waitUntil: 'networkidle0', timeout: 45000 }).catch(e => console.log('Nav err:', e.message));console.log('\nURL:', page.url());await new Promise(r => setTimeout(r, 5000));
// Find textarea and typeconst textareas = await page.$$('textarea');console.log('\nTextareas:', textareas.length);if (textareas.length > 0) { await textareas[0].click(); await textareas[0].type('hello', { delay: 30 }); await new Promise(r => setTimeout(r, 1000)); await page.keyboard.press('Enter'); console.log('Sent message, waiting 10s...'); await new Promise(r => setTimeout(r, 10000));}
await page.screenshot({ path: '/tmp/dola_chat2.png' });console.log('\nScreenshot saved');await browser.close();1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283import puppeteer from 'puppeteer-core';import fs from 'fs';
const rawCookies = JSON.parse(fs.readFileSync('/tmp/dola_cookies.json', 'utf8'));
const browser = await puppeteer.launch({ headless: true, executablePath: '/usr/bin/chromium', args: ['--no-sandbox', '--disable-setuid-sandbox', '--disable-gpu']});
const page = await browser.newPage();await page.setCookie(...rawCookies.map(c => ({ name: c.name, value: c.value, domain: '.dola.com', path: c.path, httpOnly: c.httpOnly || false, secure: c.secure || false, sameSite: 'Lax',})));
page.on('request', req => { const url = req.url(); if (url.includes('/chat/completion')) { console.log('\n*** CHAT COMPLETION REQ ***'); console.log('POST', url.split('?')[0]); console.log('Body:', (req.postData() || '').substring(0, 2000)); }});page.on('response', async res => { const url = res.url(); if (url.includes('/chat/completion')) { console.log('\n*** CHAT COMPLETION RES ***'); console.log('Status:', res.status()); const ct = res.headers()['content-type'] || ''; console.log('Content-Type:', ct); try { const text = await res.text(); console.log('Body:', text.substring(0, 3000)); } catch(e) { console.log('Error:', e.message); } }});
await page.goto('https://www.dola.com/chat', { waitUntil: 'domcontentloaded', timeout: 45000 }).catch(e => console.log('Nav err:', e.message));console.log('URL:', page.url());await new Promise(r => setTimeout(r, 5000));
await page.screenshot({ path: '/tmp/dola_state.png' });
// Try to find input using evaluateconst inputInfo = await page.evaluate(() => { const t = document.querySelectorAll('textarea'); const r = []; t.forEach((el, i) => { r.push({ idx: i, placeholder: el.placeholder, visible: el.offsetParent !== null, rect: el.getBoundingClientRect() }); }); return r;});console.log('Textareas:', JSON.stringify(inputInfo));
// Find the last visible textarea and typeif (inputInfo.length > 0) { const last = inputInfo.filter(i => i.visible).pop(); if (last) { const ta = (await page.$$('textarea'))[last.idx]; await ta.click(); await ta.type('hello', { delay: 30 }); await new Promise(r => setTimeout(r, 300)); await page.keyboard.press('Enter'); console.log('Message sent'); await new Promise(r => setTimeout(r, 12000)); }}
await browser.close();123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103import puppeteer from 'puppeteer-core';import fs from 'fs';
const rawCookies = JSON.parse(fs.readFileSync('/tmp/dola_cookies.json', 'utf8'));
const browser = await puppeteer.launch({ headless: false, executablePath: '/usr/bin/chromium', defaultViewport: { width: 1280, height: 900 }, args: ['--no-sandbox', '--disable-setuid-sandbox']});
const page = await browser.newPage();
// Capture ALL requests including websocketconst allReqs = [];page.on('request', req => { const url = req.url(); if (url.includes('dola.com') || url.includes('ciciai.com')) { const entry = { url, method: req.method(), type: req.resourceType() }; try { entry.postData = req.postData(); } catch {} allReqs.push(entry); }});
// Capture websocket framesconst wsFrames = [];page.on('request', req => { if (req.url().startsWith('ws')) { console.log('WS CONNECT:', req.url()); wsFrames.push({ type: 'connect', url: req.url() }); }});
page.on('websocket', ws => { const url = ws.url(); console.log('WEBSOCKET CREATED:', url); ws.on('framereceived', frame => { console.log('WS RECV:', frame.payload.substring(0, 200)); }); ws.on('framesent', frame => { console.log('WS SENT:', frame.payload.substring(0, 200)); });});
// Set cookies and go to chatawait page.setCookie(...rawCookies.map(c => ({ name: c.name, value: c.value, domain: c.domain === '.dola.com' ? 'dola.com' : c.domain.replace(/^\./, ''), path: c.path, httpOnly: c.httpOnly || false, secure: c.secure || false, sameSite: 'Lax',})));
await page.goto('https://www.dola.com/chat', { waitUntil: 'domcontentloaded', timeout: 45000 }).catch(e => console.log('Nav:', e.message));console.log('URL:', page.url());await new Promise(r => setTimeout(r, 5000));
// Take screenshotawait page.screenshot({ path: '/tmp/dola_chat.png', fullPage: false });console.log('Screenshot saved');
// Look for inputconst textareas = await page.$$('textarea');console.log('Textareas:', textareas.length);const contenteditables = await page.$$('[contenteditable]');console.log('Contenteditables:', contenteditables.length);
let target = null;if (textareas.length > 0) target = textareas[0];else if (contenteditables.length > 0) target = contenteditables[0];
if (target) { console.log('Found input, typing...'); await target.click(); await target.type('hello', { delay: 100 }); await new Promise(r => setTimeout(r, 1000)); // Try pressing Enter await page.keyboard.press('Enter'); console.log('Sent, waiting 10s for response...'); await new Promise(r => setTimeout(r, 10000));}
// Print recorded requestsconsole.log('\n\n=== ALL REQUESTS (filtered) ===');for (const r of allReqs) { if (r.url.includes('api') || r.url.includes('im/') || r.url.includes('message') || r.url.includes('chat') || r.url.includes('send')) { console.log(r.method, r.type, r.url.substring(0, 200)); if (r.postData) console.log(' BODY:', r.postData.substring(0, 500)); }}
console.log('\n\n=== WS FRAMES ===');for (const w of wsFrames) { console.log(JSON.stringify(w));}
await new Promise(r => setTimeout(r, 2000));await browser.close();console.log('\nDone');123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152import puppeteer from 'puppeteer-core';import fs from 'fs';
const rawCookies = JSON.parse(fs.readFileSync('/tmp/dola_cookies.json', 'utf8'));
const browser = await puppeteer.launch({ headless: true, executablePath: '/usr/bin/chromium', defaultViewport: { width: 1280, height: 800 }, args: ['--no-sandbox', '--disable-setuid-sandbox', '--disable-gpu']});
const page = await browser.newPage();
// Set cookies before navigatingawait page.setCookie(...rawCookies.map(c => ({ name: c.name, value: c.value, domain: c.domain === '.dola.com' ? 'dola.com' : c.domain, path: c.path, httpOnly: c.httpOnly || false, secure: c.secure || false, sameSite: 'Lax', expires: c.expirationDate ? Math.floor(c.expirationDate) : -1})));
const requests = [];page.on('request', req => { const url = req.url(); if (url.includes('dola.com') && !url.match(/\.(js|css|png|jpg|svg|ico|woff|ttf|json|map)/)) { requests.push({ url: url, method: req.method(), postData: req.postData(), headers: req.headers() }); }});
const responses = [];page.on('response', async res => { const url = res.url(); if (url.includes('dola.com') && url.includes('chat') || url.includes('api') || url.includes('gateway') || url.includes('ai')) { let body; try { body = await res.text(); } catch { body = '(unreadable)'; } responses.push({ url: url, status: res.status(), contentType: res.headers()['content-type'], body: body.substring(0, 3000) }); }});
console.log('Navigating to dola.com...');try { await page.goto('https://www.dola.com', { waitUntil: 'domcontentloaded', timeout: 30000 }); console.log('Page loaded, url:', page.url());} catch(e) { console.log('Nav warning:', e.message); console.log('Current url:', page.url());}// wait a bit for any XHRawait new Promise(r => setTimeout(r, 5000));
console.log('\n=== PAGE TITLE ===', await page.title());console.log('=== URL ===', page.url());
// Try clicking chat-related linksconst links = await page.$$('a');for (const link of links) { const href = await link.evaluate(el => el.getAttribute('href')).catch(() => ''); const text = await link.evaluate(el => el.textContent?.trim().toLowerCase() || '').catch(() => ''); if (text.includes('chat') || text.includes('ai') || text.includes('message') || (href && (href.includes('chat') || href.includes('ai')))) { console.log('Link:', text, '->', href); }}
// Check for textarea / inputconst hasTextarea = await page.$('textarea');console.log('Has textarea:', !!hasTextarea);const hasInput = await page.$('input[type="text"]');console.log('Has text input:', !!hasInput);const editable = await page.$('[contenteditable]');console.log('Has contenteditable:', !!editable);
// If logged in, navigate to /chattry { console.log('\nNavigating to /chat...'); await page.goto('https://www.dola.com/chat', { waitUntil: 'networkidle2', timeout: 30000 }); console.log('Chat page loaded, url:', page.url()); await new Promise(r => setTimeout(r, 3000));} catch(e) { console.log('Chat nav error:', e.message);}
// Take screenshotawait page.screenshot({ path: '/tmp/dola_page.png', fullPage: false });console.log('Screenshot saved to /tmp/dola_page.png');
// Check if there's a send button or inputtry { const inputs = await page.$$('input:not([type="hidden"]):not([type="checkbox"])'); console.log('Inputs count:', inputs.length); for (const inp of inputs) { const type = await inp.evaluate(el => el.getAttribute('type') || '').catch(() => ''); const ph = await inp.evaluate(el => el.getAttribute('placeholder') || '').catch(() => ''); const cls = await inp.evaluate(el => el.className || '').catch(() => ''); if (ph || cls) console.log(' Input:', 'type=' + type, 'placeholder=' + ph, 'class=' + cls.substring(0,60)); } const buttons = await page.$$('button'); console.log('Buttons count:', buttons.length); for (const btn of buttons) { const text = await btn.evaluate(el => el.textContent?.trim() || '').catch(() => ''); if (text) console.log(' Button:', JSON.stringify(text.substring(0,40))); } // Try typing in the first textarea/input let target = await page.$('textarea'); if (!target) target = await page.$('input[type="text"]'); if (!target) target = await page.$('[contenteditable]'); if (target) { const tag = await target.evaluate(el => el.tagName).catch(() => ''); console.log('\nFound input element:', tag); await target.click(); await target.type('hello', { delay: 50 }); await new Promise(r => setTimeout(r, 1000)); // Press Enter await page.keyboard.press('Enter'); console.log('Sent message, waiting for response...'); await new Promise(r => setTimeout(r, 5000)); }} catch(e) { console.log('Interaction error:', e.message, e.stack);}
console.log('\n\n=== REQUESTS CAPTURED ===');for (const r of requests) { console.log(r.method, r.url.substring(0, 150)); if (r.postData) console.log(' BODY:', r.postData.substring(0, 1000));}
console.log('\n\n=== AI-RELATED RESPONSES ===');for (const r of responses) { console.log(r.status, r.url.substring(0, 150), r.contentType); if (r.body && r.body.length > 10) console.log(' BODY:', r.body.substring(0, 1000));}
await browser.close();console.log('\nDone');123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263import puppeteer from 'puppeteer-core';import fs from 'fs';
const rawCookies = JSON.parse(fs.readFileSync('/tmp/dola_cookies.json', 'utf8'));
const browser = await puppeteer.launch({ headless: true, executablePath: '/usr/bin/chromium', args: ['--no-sandbox', '--disable-setuid-sandbox', '--disable-gpu']});
const page = await browser.newPage();await page.setCookie(...rawCookies.map(c => ({ name: c.name, value: c.value, domain: c.domain === '.dola.com' ? 'dola.com' : c.domain.replace(/^\./, ''), path: c.path, httpOnly: c.httpOnly || false, secure: c.secure || false, sameSite: 'Lax',})));
// Capture chat/completion responsepage.on('response', async res => { const url = res.url(); if (url.includes('/chat/completion')) { console.log('=== CHAT COMPLETION RESPONSE ==='); console.log('Status:', res.status()); console.log('Headers:', JSON.stringify(res.headers())); try { const body = await res.text(); console.log('Body (first 3000 chars):', body.substring(0, 3000)); } catch(e) { console.log('Body error:', e.message); } console.log('==============================='); }});
// Capture the completion request headerspage.on('request', req => { const url = req.url(); if (url.includes('/chat/completion')) { console.log('=== CHAT COMPLETION REQUEST ==='); console.log('Headers:', JSON.stringify(req.headers())); console.log('Body length:', req.postData()?.length || 0); }});
await page.goto('https://www.dola.com/chat', { waitUntil: 'domcontentloaded', timeout: 30000 }).catch(e => console.log('Nav err:', e.message));await new Promise(r => setTimeout(r, 5000));
const textareas = await page.$$('textarea');if (textareas.length > 0) { await textareas[0].click(); await textareas[0].type('say hello in one word', { delay: 20 }); await new Promise(r => setTimeout(r, 500)); await page.keyboard.press('Enter'); console.log('Sent, waiting 15s...'); await new Promise(r => setTimeout(r, 15000));}
await browser.close();11 unmodified lines1213141516176 unmodified lines24252627282912 unmodified lines42434445464785 unmodified lines13313413513613713860 unmodified lines19920020120220320463 unmodified lines26826927027127227364 unmodified lines33833934034134234339 unmodified lines383384385386387388151 unmodified lines54054154254354454530 unmodified lines57657757857958058183 unmodified lines66566666766866967067167267367467567610 unmodified lines6876886896906916923 unmodified lines69669769869970070116 unmodified lines71871972072172272311 unmodified lines"axios": "^1.16.1","cheerio": "^1.2.0","protobufjs": "^8.3.0","zod": "^4.4.3"}},6 unmodified lines"gradient-string": "^3.0.0"}},"node_modules/@types/tinycolor2": {"version": "1.4.6","resolved": "https://registry.npmjs.org/@types/tinycolor2/-/tinycolor2-1.4.6.tgz",12 unmodified lines"node": ">= 6.0.0"}},"node_modules/asynckit": {"version": "0.4.0","resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",85 unmodified lines"url": "https://github.com/sponsors/fb55"}},"node_modules/combined-stream": {"version": "1.0.8","resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",60 unmodified lines"node": ">=0.4.0"}},"node_modules/dom-serializer": {"version": "2.0.0","resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-2.0.0.tgz",63 unmodified lines"node": ">= 0.4"}},"node_modules/encoding-sniffer": {"version": "0.2.1","resolved": "https://registry.npmjs.org/encoding-sniffer/-/encoding-sniffer-0.2.1.tgz",64 unmodified lines"node": ">= 0.4"}},"node_modules/follow-redirects": {"version": "1.16.0","resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.16.0.tgz",39 unmodified lines"url": "https://github.com/sponsors/ljharb"}},"node_modules/get-intrinsic": {"version": "1.3.0","resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz",151 unmodified lines"node": ">=0.10.0"}},"node_modules/long": {"version": "5.3.2","resolved": "https://registry.npmjs.org/long/-/long-5.3.2.tgz",30 unmodified lines"node": ">= 0.6"}},"node_modules/ms": {"version": "2.1.3","resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",83 unmodified lines"node": ">=10"}},"node_modules/safer-buffer": {"version": "2.1.2","resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz","integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==","license": "MIT"},"node_modules/tinycolor2": {"version": "1.6.0","resolved": "https://registry.npmjs.org/tinycolor2/-/tinycolor2-1.6.0.tgz",10 unmodified lines"tinycolor2": "^1.0.0"}},"node_modules/undici": {"version": "7.25.0","resolved": "https://registry.npmjs.org/undici/-/undici-7.25.0.tgz",3 unmodified lines"node": ">=20.18.1"}},"node_modules/whatwg-encoding": {"version": "3.1.1","resolved": "https://registry.npmjs.org/whatwg-encoding/-/whatwg-encoding-3.1.1.tgz",16 unmodified lines"node": ">=18"}},"node_modules/zod": {"version": "4.4.3","resolved": "https://registry.npmjs.org/zod/-/zod-4.4.3.tgz",11 unmodified lines121314151617186 unmodified lines25262728293031323334353637383940414243444546474849505152535412 unmodified lines67686970717273747576777879808182838485868788899091929394959685 unmodified lines18218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324460 unmodified lines30530630730830931031131231331431531663 unmodified lines38038138238338438538638738838939039164 unmodified lines45645745845946046146246346446546646746846947039 unmodified lines510511512513514515516517518519520521522523524151 unmodified lines67667767867968068168268368468568668768868969030 unmodified lines72172272372472572672772872973073173273373473573673773873974074183 unmodified lines82582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788810 unmodified lines8999009019029039049059069079089099103 unmodified lines91491591691791891992092192292392492516 unmodified lines942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102111 unmodified lines"axios": "^1.16.1","cheerio": "^1.2.0","protobufjs": "^8.3.0","puppeteer-core": "^25.1.0","zod": "^4.4.3"}},6 unmodified lines"gradient-string": "^3.0.0"}},"node_modules/@puppeteer/browsers": {"version": "3.0.4","resolved": "https://registry.npmjs.org/@puppeteer/browsers/-/browsers-3.0.4.tgz","integrity": "sha512-HGM8iAmGTf+Y7t0373szVbTmt3d7vPkYL/1bpOkOFO0YUYLgSeuYBCzESklogNPvOBnZ/MRD5f07OkpqH1trtA==","license": "Apache-2.0","dependencies": {"modern-tar": "^0.7.6","yargs": "^17.7.2"},"bin": {"browsers": "lib/main-cli.js"},"engines": {"node": ">=22.12.0"},"peerDependencies": {"proxy-agent": ">=8.0.1"},"peerDependenciesMeta": {"proxy-agent": {"optional": true}}},"node_modules/@types/tinycolor2": {"version": "1.4.6","resolved": "https://registry.npmjs.org/@types/tinycolor2/-/tinycolor2-1.4.6.tgz",12 unmodified lines"node": ">= 6.0.0"}},"node_modules/ansi-regex": {"version": "5.0.1","resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz","integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==","license": "MIT","engines": {"node": ">=8"}},"node_modules/ansi-styles": {"version": "4.3.0","resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz","integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==","license": "MIT","dependencies": {"color-convert": "^2.0.1"},"engines": {"node": ">=8"},"funding": {"url": "https://github.com/chalk/ansi-styles?sponsor=1"}},"node_modules/asynckit": {"version": "0.4.0","resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",85 unmodified lines"url": "https://github.com/sponsors/fb55"}},"node_modules/chromium-bidi": {"version": "16.0.1","resolved": "https://registry.npmjs.org/chromium-bidi/-/chromium-bidi-16.0.1.tgz","integrity": "sha512-J63PGu/9PpeCwLIcKYyzWP6yaVL5pxuBc0shlYCYM8BaAkmlwiQboXO1iNbOgSDbVklEyYFfNEcHD8oOAWacUA==","license": "Apache-2.0","dependencies": {"mitt": "^3.0.1","zod": "^3.24.1"},"engines": {"node": ">=20.19.0 <22.0.0 || >=22.12.0"},"peerDependencies": {"devtools-protocol": "*"}},"node_modules/chromium-bidi/node_modules/zod": {"version": "3.25.76","resolved": "https://registry.npmjs.org/zod/-/zod-3.25.76.tgz","integrity": "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==","license": "MIT","funding": {"url": "https://github.com/sponsors/colinhacks"}},"node_modules/cliui": {"version": "8.0.1","resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz","integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==","license": "ISC","dependencies": {"string-width": "^4.2.0","strip-ansi": "^6.0.1","wrap-ansi": "^7.0.0"},"engines": {"node": ">=12"}},"node_modules/color-convert": {"version": "2.0.1","resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz","integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==","license": "MIT","dependencies": {"color-name": "~1.1.4"},"engines": {"node": ">=7.0.0"}},"node_modules/color-name": {"version": "1.1.4","resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz","integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==","license": "MIT"},"node_modules/combined-stream": {"version": "1.0.8","resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",60 unmodified lines"node": ">=0.4.0"}},"node_modules/devtools-protocol": {"version": "0.0.1624250","resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.1624250.tgz","integrity": "sha512-YFAat/lOiIk0ARmBweG+ygrEcbZrq5B9urRyUoeQKp53MlidHXE2TmTbxKcaXoQj7u/aX+jebDO4BW55rs0WwA==","license": "BSD-3-Clause"},"node_modules/dom-serializer": {"version": "2.0.0","resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-2.0.0.tgz",63 unmodified lines"node": ">= 0.4"}},"node_modules/emoji-regex": {"version": "8.0.0","resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz","integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==","license": "MIT"},"node_modules/encoding-sniffer": {"version": "0.2.1","resolved": "https://registry.npmjs.org/encoding-sniffer/-/encoding-sniffer-0.2.1.tgz",64 unmodified lines"node": ">= 0.4"}},"node_modules/escalade": {"version": "3.2.0","resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz","integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==","license": "MIT","engines": {"node": ">=6"}},"node_modules/follow-redirects": {"version": "1.16.0","resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.16.0.tgz",39 unmodified lines"url": "https://github.com/sponsors/ljharb"}},"node_modules/get-caller-file": {"version": "2.0.5","resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz","integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==","license": "ISC","engines": {"node": "6.* || 8.* || >= 10.*"}},"node_modules/get-intrinsic": {"version": "1.3.0","resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz",151 unmodified lines"node": ">=0.10.0"}},"node_modules/is-fullwidth-code-point": {"version": "3.0.0","resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz","integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==","license": "MIT","engines": {"node": ">=8"}},"node_modules/long": {"version": "5.3.2","resolved": "https://registry.npmjs.org/long/-/long-5.3.2.tgz",30 unmodified lines"node": ">= 0.6"}},"node_modules/mitt": {"version": "3.0.1","resolved": "https://registry.npmjs.org/mitt/-/mitt-3.0.1.tgz","integrity": "sha512-vKivATfr97l2/QBCYAkXYDbrIWPM2IIKEl7YPhjCvKlG3kE2gm+uBo6nEXK3M5/Ffh/FLpKExzOQ3JJoJGFKBw==","license": "MIT"},"node_modules/modern-tar": {"version": "0.7.6","resolved": "https://registry.npmjs.org/modern-tar/-/modern-tar-0.7.6.tgz","integrity": "sha512-sweCIVXzx1aIGTCdzcMlSZt1h8k5Tmk08VNAuRk3IU28XamGiOH5ypi11g6De2CH7PhYqSSnGy2A/EFhbWnVKg==","license": "MIT","engines": {"node": ">=18.0.0"}},"node_modules/ms": {"version": "2.1.3","resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",83 unmodified lines"node": ">=10"}},"node_modules/puppeteer-core": {"version": "25.1.0","resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-25.1.0.tgz","integrity": "sha512-jKzy5y4WG6uNuFbTWgW1D7mqoT9o0nllc/6a1DGF775T1mPmgw3scdFEtEq67yVFikavQmbYq6NLfbTfxHSlqQ==","license": "Apache-2.0","dependencies": {"@puppeteer/browsers": "3.0.4","chromium-bidi": "16.0.1","devtools-protocol": "0.0.1624250","typed-query-selector": "^2.12.2","webdriver-bidi-protocol": "0.4.2","ws": "^8.21.0"},"engines": {"node": ">=22.12.0"}},"node_modules/require-directory": {"version": "2.1.1","resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz","integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==","license": "MIT","engines": {"node": ">=0.10.0"}},"node_modules/safer-buffer": {"version": "2.1.2","resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz","integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==","license": "MIT"},"node_modules/string-width": {"version": "4.2.3","resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz","integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==","license": "MIT","dependencies": {"emoji-regex": "^8.0.0","is-fullwidth-code-point": "^3.0.0","strip-ansi": "^6.0.1"},"engines": {"node": ">=8"}},"node_modules/strip-ansi": {"version": "6.0.1","resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz","integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==","license": "MIT","dependencies": {"ansi-regex": "^5.0.1"},"engines": {"node": ">=8"}},"node_modules/tinycolor2": {"version": "1.6.0","resolved": "https://registry.npmjs.org/tinycolor2/-/tinycolor2-1.6.0.tgz",10 unmodified lines"tinycolor2": "^1.0.0"}},"node_modules/typed-query-selector": {"version": "2.12.2","resolved": "https://registry.npmjs.org/typed-query-selector/-/typed-query-selector-2.12.2.tgz","integrity": "sha512-EOPFbyIub4ngnEdqi2yOcNeDLaX/0jcE1JoAXQDDMIthap7FoN795lc/SHfIq2d416VufXpM8z/lD+WRm2gfOQ==","license": "MIT"},"node_modules/undici": {"version": "7.25.0","resolved": "https://registry.npmjs.org/undici/-/undici-7.25.0.tgz",3 unmodified lines"node": ">=20.18.1"}},"node_modules/webdriver-bidi-protocol": {"version": "0.4.2","resolved": "https://registry.npmjs.org/webdriver-bidi-protocol/-/webdriver-bidi-protocol-0.4.2.tgz","integrity": "sha512-VSV+fzfChirL3e7jay2yUC7B4HQCGtEWEg/MSSQbK+qWbqeGlRLlXTzPpYr3XGUvbpDHumWZBJxgesg4N7dbtA==","license": "Apache-2.0"},"node_modules/whatwg-encoding": {"version": "3.1.1","resolved": "https://registry.npmjs.org/whatwg-encoding/-/whatwg-encoding-3.1.1.tgz",16 unmodified lines"node": ">=18"}},"node_modules/wrap-ansi": {"version": "7.0.0","resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz","integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==","license": "MIT","dependencies": {"ansi-styles": "^4.0.0","string-width": "^4.1.0","strip-ansi": "^6.0.0"},"engines": {"node": ">=10"},"funding": {"url": "https://github.com/chalk/wrap-ansi?sponsor=1"}},"node_modules/ws": {"version": "8.21.0","resolved": "https://registry.npmjs.org/ws/-/ws-8.21.0.tgz","integrity": "sha512-Vsp28b7DRcimFQvrqu2Wek3z1iYxDCWqHYB8Qsnk/S4RfaCQzPGPyBNuVjJV3cd6UiKtUtp6sNM77gWvzcCH+g==","license": "MIT","engines": {"node": ">=10.0.0"},"peerDependencies": {"bufferutil": "^4.0.1","utf-8-validate": ">=5.0.2"},"peerDependenciesMeta": {"bufferutil": {"optional": true},"utf-8-validate": {"optional": true}}},"node_modules/y18n": {"version": "5.0.8","resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz","integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==","license": "ISC","engines": {"node": ">=10"}},"node_modules/yargs": {"version": "17.7.3","resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.3.tgz","integrity": "sha512-GZtjxm/J/4TSxuL3FNYjCmLktBTnIw/rVmKSIyKeYAZpmJB2ig9VauCC5xsa82GNKVKDAqpOn3KVzNt0zmrU0g==","license": "MIT","dependencies": {"cliui": "^8.0.1","escalade": "^3.1.1","get-caller-file": "^2.0.5","require-directory": "^2.1.1","string-width": "^4.2.3","y18n": "^5.0.5","yargs-parser": "^21.1.1"},"engines": {"node": ">=12"}},"node_modules/yargs-parser": {"version": "21.1.1","resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz","integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==","license": "ISC","engines": {"node": ">=12"}},"node_modules/zod": {"version": "4.4.3","resolved": "https://registry.npmjs.org/zod/-/zod-4.4.3.tgz",
11 unmodified lines12131415161711 unmodified lines"axios": "^1.16.1","cheerio": "^1.2.0","protobufjs": "^8.3.0","zod": "^4.4.3"}}11 unmodified lines1213141516171811 unmodified lines"axios": "^1.16.1","cheerio": "^1.2.0","protobufjs": "^8.3.0","puppeteer-core": "^25.1.0","zod": "^4.4.3"}}
123456789101112131415161718192021222324252627282930313233343536373839404142434445import puppeteer from 'puppeteer-core';import fs from 'fs';import axios from 'axios';
const APP_VERSION = '59344f68';const BASE = 'https://chat.deepseek.com/api/v0';
const cfg = JSON.parse(fs.readFileSync('data/deepseek.json', 'utf8'));const token = cfg.userToken || cfg.token;
// Use the existing API clientimport { DeepSeek } from './src/core/deepseek.js';
const ds = new DeepSeek(token, { hifLeim: cfg.hifLeim });
// 1) Get user settings to see available model typestry { const settings = await ds.getUserSettings(); console.log('=== User Settings ==='); console.log(JSON.stringify(settings, null, 2).substring(0, 2000));} catch (e) { console.log('Settings error:', e.message);}
// 2) Try creating sessions with different model typesfor (const mt of ['default', 'expert', 'vision', 'thinking']) { try { const session = await ds.createSession(); console.log(`\nSession with model_type=${mt || 'default'}:`, session.modelType); // Try sending a message const result = await ds.ask(session.id, `Hello, what model type am I using?`, { modelType: mt, thinkingEnabled: mt === 'expert' || mt === 'thinking', }); console.log(`Response (${mt}):`, result.substring(0, 100)); await ds.deleteSession(session.id).catch(() => {}); } catch (e) { console.log(`Error with model_type=${mt}:`, e.message?.substring(0, 100)); }}
// Clean upfs.unlinkSync('/home/choruyt/documents/Exocore-gateway/scrape_deepseek2.js');427 unmodified lines4284294304314324334344 unmodified lines439440441442443444445446447448427 unmodified lines}async uploadFile(sessionId, file, options = {}) {const { thinkingEnabled = false, modelType = null, onUploadProgress = null, powChallengeResponse = null } = options;const formData = new FormData();formData.append('file', file);4 unmodified lines'x-file-size': String(file.size)};if (powChallengeResponse) {const { key, value } = powChallengeResponse;headers[key] = value;}const { data } = await this.client.post('/file/upload_file', formData, {headers: { ...headers, 'Content-Type': 'multipart/form-data' },427 unmodified lines4284294304314324334344 unmodified lines439440441442443444445446447448449427 unmodified lines}async uploadFile(sessionId, file, options = {}) {const { thinkingEnabled = false, modelType = null, onUploadProgress = null } = options;const formData = new FormData();formData.append('file', file);4 unmodified lines'x-file-size': String(file.size)};if (this.hifLeim) headers['x-hif-leim'] = this.hifLeim;if (this.hifDliq) headers['x-hif-dliq'] = this.hifDliq;const powHeaders = await this._buildPowHeaders('/api/v0/file/upload_file');Object.assign(headers, powHeaders);const { data } = await this.client.post('/file/upload_file', formData, {headers: { ...headers, 'Content-Type': 'multipart/form-data' },
125 unmodified lines126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199125 unmodified lines},};const now = Date.now();const response = await this.client.post('/chat/completion', body, {responseType: 'stream',timeout: 120000,headers: {'Cookie': this.cookieHeader,},});return new Promise((resolve, reject) => {let buffer = '';let fullContent = '';let finished = false;response.data.on('data', (chunk) => {buffer += chunk.toString();const lines = buffer.split('\n');buffer = lines.pop();for (const line of lines) {if (line.startsWith('data:')) {try {const json = JSON.parse(line.slice(5).trim());const event = json.event || '';const data = json.data || json;if (event === 'message' || event === 'delta') {let text = '';if (typeof data === 'string') text = data;else if (data.text) text = data.text;else if (data.content) text = data.content;else if (data.message) text = typeof data.message === 'string' ? data.message : JSON.stringify(data.message);else if (data.answer) text = data.answer;if (text) {fullContent += text;if (onDelta) onDelta({ text });}} else if (event === 'done' || event === 'finish' || event === 'complete') {finished = true;if (onDone) onDone({ content: fullContent });resolve({ content: fullContent });} else if (event === 'error') {const errMsg = typeof data === 'string' ? data : (data.msg || data.message || 'SSE error');if (onError) onError(new Error(errMsg));reject(new Error(errMsg));} else if (event === 'status' || event === 'progress') {// ignore status updates}} catch (e) {// skip parse errors}}}});response.data.on('end', () => {if (!finished) {if (onDone) onDone({ content: fullContent });resolve({ content: fullContent });}});response.data.on('error', (err) => {if (onError) onError(err);reject(err);});});}async ask(prompt, options = {}) {125 unmodified lines126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209125 unmodified lines},};const response = await this.client.post('/chat/completion', body, {responseType: 'stream',timeout: 120000,});let buffer = '';let fullContent = '';let currentEvent = null;for await (const chunk of response.data) {buffer += chunk.toString();const lines = buffer.split('\n');buffer = lines.pop();for (const line of lines) {const trimmed = line.trim();if (trimmed.startsWith('event:')) {currentEvent = trimmed.slice(6).trim();} else if (trimmed.startsWith('data:')) {try {const json = JSON.parse(trimmed.slice(5).trim());if (currentEvent === 'STREAM_MSG_NOTIFY') {const contentRaw = json?.content?.content;if (contentRaw && typeof contentRaw === 'string') {try {const parsed = JSON.parse(contentRaw);const text = parsed.text || parsed.content || contentRaw;if (text) {fullContent += text;if (onDelta) onDelta({ text });}} catch {fullContent += contentRaw;if (onDelta) onDelta({ text: contentRaw });}}} else if (currentEvent === 'STREAM_CHUNK') {const patches = json?.patch_op;if (Array.isArray(patches)) {for (const patch of patches) {if (patch.patch_type === 1) {const patchContent = patch.patch_value?.content;if (patchContent && typeof patchContent === 'string') {try {const parsed = JSON.parse(patchContent);const text = parsed.text || parsed.content || patchContent;if (text) {fullContent += text;if (onDelta) onDelta({ text });}} catch {fullContent += patchContent;if (onDelta) onDelta({ text: patchContent });}}}}}} else if (currentEvent === 'SSE_REPLY_END') {const endType = json?.end_type;if (endType === 1) {if (onDone) onDone({ content: fullContent });return { content: fullContent };}}} catch (e) {// skip parse errors}currentEvent = null;}}}// Stream ended without SSE_REPLY_ENDif (onDone) onDone({ content: fullContent });return { content: fullContent };}async ask(prompt, options = {}) {
12345678import { Dola } from './src/core/dola.js';import fs from 'fs';
const cfg = JSON.parse(fs.readFileSync('data/dola.json', 'utf8'));const dola = new Dola(cfg.cookies);
const result = await dola.ask('say hello in one word', { mode: 'fast' });console.log('Result:', JSON.stringify(result));data/dola_cookies.jsonAdded+20
dola_capture.mjsAdded+68
dola_debug.mjsAdded+83
dola_interact.mjsAdded+103
dola_scrape.mjsAdded+152
dola_sse.mjsAdded+63
package-lock.json+298
package.json+1
scrape_deepseek2.jsAdded+45
src/core/deepseek.js+6-5
src/core/dola.js+66-56
test_dola.mjsAdded+8