deepspider 0.3.0 → 0.3.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deepspider",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "智能爬虫工程平台 - 基于 DeepAgents + Patchright 的 AI 爬虫 Agent",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -53,7 +53,7 @@ export class PanelBridge {
53
53
  const escaped = JSON.stringify(content.trim());
54
54
  const code = `window.__deepspider__?.addMessage?.('${role}', ${escaped})`;
55
55
  await this.evaluateInPage(code);
56
- } catch (e) {
56
+ } catch {
57
57
  // ignore
58
58
  }
59
59
  }
@@ -110,7 +110,7 @@ export class PanelBridge {
110
110
  })()`;
111
111
  await this.evaluateInPage(code);
112
112
  }
113
- } catch (e) {
113
+ } catch {
114
114
  // ignore
115
115
  }
116
116
 
@@ -5,7 +5,7 @@
5
5
 
6
6
  import { BaseCallbackHandler } from '@langchain/core/callbacks/base';
7
7
  import { appendFileSync, mkdirSync, existsSync } from 'fs';
8
- import { join, dirname } from 'path';
8
+ import { join } from 'path';
9
9
  import { DEEPSPIDER_HOME } from '../config/paths.js';
10
10
 
11
11
  const LOG_DIR = join(DEEPSPIDER_HOME, 'logs');
@@ -44,7 +44,7 @@ export function createReportMiddleware(options = {}) {
44
44
  console.log('[reportMiddleware] 检测到 .md 文件:', content.path);
45
45
  return { lastWrittenMdFile: content.path };
46
46
  }
47
- } catch (e) {
47
+ } catch {
48
48
  // 解析失败,忽略
49
49
  }
50
50
  }
@@ -3,9 +3,6 @@
3
3
  * 合并静态 SKILL.md + 动态 evolved.md
4
4
  */
5
5
 
6
- import fs from 'fs';
7
- import path from 'path';
8
-
9
6
  // 配置
10
7
  const MAX_RECENT_ITEMS = 10;
11
8
  const MERGE_THRESHOLD = 20;
@@ -106,7 +106,7 @@ export const captchaSlideDetect = tool(
106
106
 
107
107
  // 获取背景图和滑块图
108
108
  const bgElement = await page.$(bg_selector);
109
- const slideElement = slide_selector ? await page.$(slide_selector) : null;
109
+ const _slideElement = slide_selector ? await page.$(slide_selector) : null;
110
110
 
111
111
  if (!bgElement) {
112
112
  return JSON.stringify({ success: false, error: '未找到背景图' });
@@ -100,7 +100,7 @@ export const evolveSkill = tool(
100
100
  let content = '';
101
101
  try {
102
102
  content = fs.readFileSync(evolvedPath, 'utf-8');
103
- } catch (e) {
103
+ } catch {
104
104
  // 文件不存在,使用空内容
105
105
  }
106
106
 
@@ -5,7 +5,7 @@
5
5
 
6
6
  import { z } from 'zod';
7
7
  import { tool } from '@langchain/core/tools';
8
- import { writeFileSync, readFileSync, existsSync, readdirSync, statSync } from 'fs';
8
+ import { writeFileSync, readFileSync, existsSync, readdirSync } from 'fs';
9
9
  import { dirname, join, isAbsolute, relative } from 'path';
10
10
  import { PATHS, ensureDir, DEEPSPIDER_HOME } from '../../config/paths.js';
11
11
 
@@ -186,7 +186,7 @@ function searchInFile(filePath, pattern, isRegex) {
186
186
  if (isRegex) regex.lastIndex = 0; // 重置正则
187
187
  }
188
188
  return matches;
189
- } catch (e) {
189
+ } catch {
190
190
  return [];
191
191
  }
192
192
  }
@@ -53,7 +53,7 @@ async function executePython(code, timeout = 10000) {
53
53
  * 生成 Python 验证代码
54
54
  */
55
55
  function generateVerifyCode(algorithm, params) {
56
- const { plaintext, ciphertext, key, iv, mode, format, hmacKey, digestmod } = params;
56
+ const { plaintext, ciphertext, key, iv, _mode, format, hmacKey, digestmod } = params;
57
57
 
58
58
  const templates = {
59
59
  // AES
@@ -223,7 +223,7 @@ print('MATCH' if result == expected else f'MISMATCH: got {result}')
223
223
  * 生成可复用的 Python 代码片段
224
224
  */
225
225
  function generatePythonSnippet(algorithm, params) {
226
- const { key, iv, mode, format, hmacKey, digestmod } = params;
226
+ const { key, iv, _mode, _format, hmacKey, digestmod } = params;
227
227
 
228
228
  const snippets = {
229
229
  'AES-CBC': `
@@ -488,7 +488,7 @@ export const executePythonCode = tool(
488
488
  export const generateExecjsCode = tool(
489
489
  async ({ jsCode, functionName, description }) => {
490
490
  // 转义 JS 代码中的特殊字符
491
- const escapedJs = jsCode
491
+ const _escapedJs = jsCode
492
492
  .replace(/\\/g, '\\\\')
493
493
  .replace(/"""/g, '\\"\\"\\"')
494
494
  .replace(/\n/g, '\\n');
@@ -539,7 +539,7 @@ def ${functionName || 'execute_js'}(*args):
539
539
  * 分析 JS 代码,判断转换策略
540
540
  */
541
541
  export const analyzeJsForPython = tool(
542
- async ({ jsCode, cryptoPatterns }) => {
542
+ async ({ jsCode, cryptoPatterns: _cryptoPatterns }) => {
543
543
  const analysis = {
544
544
  canPureRewrite: true,
545
545
  reasons: [],
@@ -7,8 +7,8 @@
7
7
  import { z } from 'zod';
8
8
  import { tool } from '@langchain/core/tools';
9
9
  import { writeFileSync, readFileSync, existsSync } from 'fs';
10
- import { join, basename } from 'path';
11
- import { PATHS, ensureDir, DEEPSPIDER_HOME } from '../../config/paths.js';
10
+ import { join } from 'path';
11
+ import { PATHS, ensureDir } from '../../config/paths.js';
12
12
 
13
13
  const OUTPUT_DIR = PATHS.REPORTS_DIR;
14
14
 
@@ -110,7 +110,7 @@ export const addInitScript = tool(
110
110
  * 清除 Cookie
111
111
  */
112
112
  export const clearCookies = tool(
113
- async ({ domain }) => {
113
+ async ({ domain: _domain }) => {
114
114
  const browser = await getBrowser();
115
115
  const context = browser.getContext();
116
116
  await context.clearCookies();
@@ -51,7 +51,7 @@ export class EncryptionAnalyzer {
51
51
  }
52
52
 
53
53
  traceParam(code, paramName) {
54
- const ast = this.astAnalyzer.parse(code);
54
+ const _ast = this.astAnalyzer.parse(code);
55
55
  const traces = [];
56
56
 
57
57
  // 简化实现:查找参数使用位置
@@ -80,7 +80,7 @@ export class EncryptionAnalyzer {
80
80
  // 使用模式库进行深度检测
81
81
  detectWithPatterns(code) {
82
82
  const detected = [];
83
- for (const [key, pattern] of Object.entries(cryptoPatterns)) {
83
+ for (const [_key, pattern] of Object.entries(cryptoPatterns)) {
84
84
  for (const sig of pattern.signatures) {
85
85
  if (sig.test(code)) {
86
86
  detected.push({
@@ -21,7 +21,7 @@ export class EnvCollector {
21
21
  return this.cache.get(path);
22
22
  }
23
23
 
24
- const result = await this.page.evaluate(({ path, depth, includeProto }) => {
24
+ const result = await this.page.evaluate(({ path, depth, includeProto: _includeProto }) => {
25
25
  function getByPath(obj, path) {
26
26
  return path.split('.').reduce((o, k) => o && o[k], obj);
27
27
  }
@@ -105,7 +105,7 @@ export class NetworkInterceptor {
105
105
  console.error('[NetworkInterceptor] 保存失败:', e.message);
106
106
  });
107
107
 
108
- } catch (e) {
108
+ } catch {
109
109
  // 某些响应无法获取 body
110
110
  }
111
111
 
@@ -38,7 +38,7 @@ export class ScriptInterceptor {
38
38
  }
39
39
 
40
40
  async onScriptParsed(params) {
41
- const { scriptId, url, length } = params;
41
+ const { scriptId, url, length: _length } = params;
42
42
 
43
43
  // 跳过扩展和空脚本
44
44
  if (!url || url.startsWith('chrome-extension://')) return;
@@ -67,7 +67,7 @@ export class ScriptInterceptor {
67
67
  timestamp: Date.now(),
68
68
  pageUrl: this.getPageUrl() // 传递页面 URL
69
69
  });
70
- } catch (e) {
70
+ } catch {
71
71
  // 获取失败,跳过
72
72
  }
73
73
  }
@@ -169,7 +169,7 @@ export class PatchGenerator {
169
169
  return defaults[type] || 'undefined';
170
170
  }
171
171
 
172
- _generateSmartTemplate(property, context = {}) {
172
+ _generateSmartTemplate(property, _context = {}) {
173
173
  const parts = property.split('.');
174
174
  const propName = parts[parts.length - 1];
175
175
  const type = this._inferType(property);
@@ -232,7 +232,7 @@ export class PatchGenerator {
232
232
  }
233
233
 
234
234
  // 检测同一对象的重复定义
235
- for (const [root, props] of roots) {
235
+ for (const [_root, props] of roots) {
236
236
  if (props.length > 1) {
237
237
  const seen = new Set();
238
238
  for (const p of props) {
@@ -4,7 +4,7 @@
4
4
  * 根据 Hook 收集的数据生成可在 Node.js 运行的浏览器环境代码
5
5
  */
6
6
 
7
- import { GETSET_LIST, FUNC_LIST, HTML_TAG_MAP } from './BrowserAPIList.js';
7
+ import { GETSET_LIST, FUNC_LIST, HTML_TAG_MAP } from './BrowserAPIList.js'; // eslint-disable-line no-unused-vars
8
8
 
9
9
  export class EnvCodeGenerator {
10
10
  constructor() {
@@ -4,8 +4,8 @@
4
4
  * 支持会话隔离、内容去重、自动清理
5
5
  */
6
6
 
7
- import { mkdirSync, existsSync, readFileSync, statSync } from 'fs';
8
- import { writeFile, readFile, readdir, rm, stat } from 'fs/promises';
7
+ import { existsSync, readFileSync } from 'fs';
8
+ import { writeFile, readFile, rm } from 'fs/promises';
9
9
  import { join } from 'path';
10
10
  import { createHash } from 'crypto';
11
11
  import { PATHS, ensureDir } from '../config/paths.js';
@@ -201,7 +201,7 @@ export class DataStore {
201
201
  if (existsSync(indexFile)) {
202
202
  index = JSON.parse(readFileSync(indexFile, 'utf-8'));
203
203
  }
204
- } catch (e) {
204
+ } catch {
205
205
  // 使用默认索引
206
206
  }
207
207
 
@@ -446,7 +446,7 @@ export class DataStore {
446
446
  timestamp: meta.timestamp
447
447
  });
448
448
  }
449
- } catch (e) { /* skip */ }
449
+ } catch { /* skip */ }
450
450
  }
451
451
  }
452
452
  return results;
@@ -477,7 +477,7 @@ export class DataStore {
477
477
  timestamp: meta.timestamp
478
478
  });
479
479
  }
480
- } catch (e) { /* skip */ }
480
+ } catch { /* skip */ }
481
481
  }
482
482
  }
483
483
  return results;