npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@bsbofmusic/cdper-core

v1.3.10

Published

Shared runtime core for cdper plugins: CDP connection, smart wait, health, recovery, and plugin contracts

Downloads

4,102

Readme

@bsbofmusic/cdper-core

cdper standalone CLI 的共享核心包,被 @bsbofmusic/cdper-chatgpt@bsbofmusic/cdper-doubao 自动依赖,无需单独安装。

⚠️ FOR LEARNING PURPOSES ONLY | 仅供学习研究使用


包含模块

@bsbofmusic/cdper-core 是 ChatGPT / 豆包 workflow 的共享核心,不是通用浏览器自动化框架。通用页面点击、截图、爬取、上传等操作请直接使用官方 playwright-core 连接已有 Chrome CDP:chromium.connectOverCDP('http://127.0.0.1:9222')

| 模块 | 文件 | 说明 | |------|------|------| | cdp | src/cdp.js | cdper workflow 内部 CDP 连接封装(Playwright-only) | | smart_wait | src/smart_wait.js | AI 回复智能等待(停止按钮轮询 + 熔断 + 延续机制) | | session | src/session.js | 会话管理器(内存 + 文件持久化双层,TTL 30min) | | check | src/check.js | 环境预检(5 项检测,输出 Agent 可直接执行的修复指令) | | logger | src/logger.js | 结构化日志(四级:ERROR / WARN / INFO / DEBUG) |


依赖版本

playwright-core          1.59.1

cdper-core 不做安装期探测;浏览器真实执行由已登录 Chrome + playwright-core connectOverCDP 完成。Puppeteer rollback 已移除。


环境变量

| 变量 | 说明 | |------|------| | CDP_WS | 可选。显式 CDP WebSocket URL;未设置时自动探测本机 127.0.0.1:9222/json/version | | LOG_LEVEL | debug | info | warn | error(默认 info) | | QUIET=1 | 抑制所有日志输出 |


模块使用示例

cdp(workflow 内部 CDP 连接)

const { connect, disconnect } = require('@bsbofmusic/cdper-core/cdp');

const { resolveCdpWs } = require('@bsbofmusic/cdper-core/cdp-ws');
const { page, browser } = await connect(resolveCdpWs());
// ... 执行操作 ...
await disconnect(page, browser);

smart_wait(智能等待)

const { waitForChatGPTReply } = require('@bsbofmusic/cdper-core/smart_wait');

const result = await waitForChatGPTReply(page, {
  minWait: 15000,
  maxWait: 180000,
  pollInterval: 2000,
  stableThreshold: 4,
  enableCircuitBreaker: true,
  enableExtend: true,
  maxExtends: 4,
});

console.log(result.content);        // 回复文本
console.log(result.completeness);    // 完整度评估 { score, issues, isComplete }

session(会话管理)

const { getSession, updateSession, closeSession, listSessions } = require('@bsbofmusic/cdper-core/session');

// 创建或获取会话
const session = getSession('my-research', 'chatgpt');
// { sessionId, platform, page, createdAt, updatedAt, turns }

// 更新会话数据
updateSession(session.sessionId, { turns: session.turns + 1 });

// 关闭会话
closeSession(session.sessionId);

// 列出所有活跃会话
const sessions = listSessions();

check(环境预检)

const { fullCheck, formatAgentHints } = require('@bsbofmusic/cdper-core/check');

const result = await fullCheck();
// {
//   allPassed: false,
//   passed: 2,
//   total: 5,
//   results: [{ id, label, ok, detail }],
//   summary: '⚠️ 环境未就绪(2/5)'
// }

if (!result.allPassed) {
  console.log(formatAgentHints(result));
  // 输出可直接执行的修复指令
}

logger(日志)

const { log, createLogger } = require('@bsbofmusic/cdper-core/logger');

log('INFO', '[mytag]', '操作完成');
log('DEBUG', '[mytag]', '详细调试信息');
log('ERROR', '[mytag]', '出错了', error.message);

const logger = createLogger({ component: 'cdp-query', plugin: 'chatgpt', run_id: 'run_xxx' });
logger.info({ step: 'dispatch', action: 'spawn_cli', status: 'start' }, '开始转发');
logger.info({ session_id: 'sess_xxx', step: 'reply', action: 'wait', status: 'success' }, '获取回复完成');

最小字段约定:

  • 核心字段:componentpluginrun_idsession_id
  • 过程字段:stepactionstatusmessage
  • 输出格式:默认文本;设 LOG_FORMAT=json 可输出 JSON 行,便于后续前端/日志平台消费

架构图

@bsbofmusic/cdper-chatgpt
@bsbofmusic/cdper-doubao
         ↓
  @bsbofmusic/cdper-core
  ├─ cdp.js        → Playwright 默认连接到已有 Chrome(Puppeteer 临时回滚)
  ├─ smart_wait.js → AI 回复检测
  ├─ session.js    → 内存 + 文件双层会话
  ├─ check.js      → 5项环境预检
  └─ logger.js     → 结构化日志

链接


免责声明

⚠️ 使用本工具即表示您同意自行承担所有合规风险。 作者不对任何使用后果负责。

Release notes — 1.2.7

  • runtime-status now treats both bridge: "ready" (remote bridge) and bridge: "local" (direct local Chrome) as valid ready states. This fixes status --json reporting ok=false while doctor and the CDP layers were actually healthy.
  • Local Chrome on 127.0.0.1:9222 remains a first-class path; CDP_WS is optional when local DevTools discovery succeeds.
  • Added tests/runtime-status-smoke.cjs so the local/remote ready-state contract is protected by the package smoke suite.

Design note: status semantics must describe the actual runtime layer, not force every healthy topology to look like the old remote bridge path. The invariant is browser=ready && ws=alive && bridge in {ready,local}.


许可证

MIT License