Skip to main content

Overview

NapCat supports two distinct working environments, each designed for different deployment scenarios. The environment is determined by how NapCat is launched and integrated with NTQQ.
Source: packages/napcat-core/index.ts:56

Shell Mode

Standalone process that launches and controls QQ

Framework Mode

Injected into existing QQ process as a plugin

Shell Mode

What is Shell Mode?

Shell mode runs NapCat as an independent process that:
  • Launches QQ as a child process
  • Manages the QQ lifecycle
  • Handles multi-process coordination
  • Provides process isolation and crash recovery

Architecture

Process Management

Shell mode uses a master-worker pattern for stability:
Source: packages/napcat-shell/napcat.ts:334

Crash Recovery

Shell mode includes automatic crash recovery:
Source: packages/napcat-shell/napcat.ts:284

Restart Process

Source: packages/napcat-shell/napcat.ts:154

Features

  • Worker process crashes don’t affect master
  • Master can restart worker automatically
  • Clean separation of concerns
  • Electron UtilityProcess on desktop
  • Node.js child_process.fork on CLI
  • Configurable via environment variables
  • Pass QQ number via -q or --qq argument
  • Automatically handles quick login flow
  • Preserved on first start only (not restarts)
  • Communicate with external processes
  • Can be disabled via NAPCAT_DISABLE_PIPE=1
  • Platform-specific pipe naming

Use Cases

Recommended for production deployments
  • Running NapCat as a system service
  • Docker containers
  • CLI environments
  • Scenarios requiring automatic restart
  • When you need full process control

Launch Example

Framework Mode

What is Framework Mode?

Framework mode integrates NapCat directly into the QQ process:
  • QQ is already running when NapCat starts
  • NapCat is injected as a framework/plugin
  • Shares the same process space as QQ
  • Typically used with LiteLoaderQQNT or similar loaders

Architecture

Initialization Flow

Source: packages/napcat-framework/napcat.ts:24

Login Handling

Framework mode provides rich login options through WebUI:
Source: packages/napcat-framework/napcat.ts:200

Features

  • WebUI starts before login
  • Control login process via web interface
  • QR code display in browser
  • Multiple login methods (QR/password/quick)
  • Access saved login accounts
  • Quick login with one click
  • Login list populated from QQ’s database
  • Full password login support
  • Captcha handling
  • Device verification
  • Multi-step authentication
  • Lower memory footprint
  • Direct access to QQ internals
  • No need to launch separate QQ

Use Cases

Recommended for desktop users
  • LiteLoaderQQNT plugin
  • Desktop QQ with custom loaders
  • Development and debugging
  • When QQ UI is needed
  • Scenarios where process injection is preferred

Launch Example

Framework mode is typically launched by a plugin loader:

Comparison Table

Environment Detection

NapCat components can detect their working environment:

Best Practices

Choose Shell mode for production servers and Framework mode for desktop development.
Framework mode shares QQ’s process space. A crash in QQ will crash NapCat, and vice versa.
Both modes use the same NapCat Core APIs. Switching between modes doesn’t require code changes.

Architecture

Understand the core architecture

Adapters

Configure network adapters