@tencent-ai/codebuddy-code (cbc / codebuddy)cbc complete the cold start first and then suspend (load bundle → container initialization → authentication → product configuration → MCP discovery). After that, when woken up via local IPC, it only needs to bind the working directory to serve immediately. This is suitable for scenarios that require "starting sessions in seconds" (such as serve/acp gateways, session pools, and scheduler pre-warm-up).--prewarm is explicitly passed, without affecting any existing usage.cbc --prewarm --prewarm-id pool1
/tmp/codebuddy-prewarm-pool1.sock (permission 0600, current user only;CODEBUDDY_CODE_PREWARM_SOCKET_PATH).\\\\.\\pipe\\codebuddy-prewarm-pool1--prewarm-id can be omitted. By default, the process PID is used as the identifier.cbc-prewarm)cbc-prewarm is a lightweight, pure Node command with zero dependencies. It does not load the main program bundle and returns in milliseconds.# List prewarmed processes found on the current machinecbc-prewarm list# Health Checkcbc-prewarm ping pool1# Query status (idle / activating / active)cbc-prewarm status pool1# Wake Up: Bind to the Target Working Directory and Start the Servicecbc-prewarm activate pool1 --cwd /path/to/project -- --serve
-- in activate are passed through to the awakened process (equivalent to a normal cbc <args>). After being awakened, the process chdirs to --cwd, enters the corresponding mode based on the passed-through arguments (such as --serve / --acp), and actively closes the IPC socket (one-time wake-up, after which it serves externally through its own service port).--cwd is optional: when --cwd is omitted, the prewarmed process keeps the working directory from the cold start (no chdir and no cwd change broadcast). This is suitable for scenarios where the caller does not need to switch directories and only wants to reuse the prewarmed container. Pass --cwd only when you need to bind to a specific project directory.cbc arguments. Resident modes such as --serve and --acp take effect as-is, and the prewarmed process does not restrict or rewrite any mode. To run a resident service, pass --serve / --acp. If no resident mode flag is passed, the process follows the one-shot command path and exits after execution (headless and without a TTY).macOS/Linux: <dir>/codebuddy-prewarm-<id>.sock (<dir> defaults to /tmp)Windows : \\\\.\\pipe\\codebuddy-prewarm-<id>
/tmp. It can be overridden by the env variable CODEBUDDY_CODE_PREWARM_SOCKET_PATH (for example, when /tmp is mounted as noexec or read-only, or when the socket needs to be placed in a controlled directory). The process side and the client side read the same env variable to stay consistent. The Windows named pipe namespace has no directory concept and is not affected by this env variable.// Health Check{ "cmd": "ping" }// → { "ok": true, "cmd": "ping", "status": "idle", "pid": 12345 }// Query status{ "cmd": "status" }// → { "ok": true, "status": "idle"|"activating"|"active", "cwd": "...", "endpoint": "..." }// Wake Up (cwd is optional. If omitted, the cold-start cwd is retained. args are the parameters passed through to cbc.){ "cmd": "activate", "cwd": "/path/to/project", "args": ["--serve"], "sessionId": "optional" }// → { "ok": true, "cmd": "activate", "status": "activating", "cwd": "..." }// Wake up and wait for the ACP service to be ready (opt-in; recommended to use with --port 0){"cmd": "activate","ackMode": "ready","cwd": "/path/to/project","args": ["--serve", "--port", "0"],"sessionId": "session-1"}// → Responds only after ACP /api/v1/acp initialization is complete:// {// "ok": true,// "cmd": "activate",// "status": "active",// "pid": 12345,// "sessionId": "session-1",// "cwd": "/path/to/project",// "endpoint": "http://127.0.0.1:54321/api/v1/acp"// }
activate can succeed only once. A repeated activate returns { ok: false, error: "already activated" }.ackMode is omitted by default, preserving the backward-compatible immediate ACK: the IPC server returns status: "activating" as soon as it receives a request, which does not mean that the HTTP listener or ACP routes are already available. Hosts that need to hand the endpoint directly to downstream clients should explicitly pass "ackMode": "ready":--port 0 to have the kernel assign a contention-free port./api/v1/acp initialization is complete.pid, and the sessionId returned as-is. The caller should verify all three.const net = require('net');function prewarmAddr(id) {if (process.platform === 'win32') {return `\\\\\\\\.\\\\pipe\\\\codebuddy-prewarm-${id}`;}const dir = (process.env.CODEBUDDY_CODE_PREWARM_SOCKET_PATH || '').trim() || '/tmp';return require('path').join(dir, `codebuddy-prewarm-${id}.sock`);}function activate(id, { cwd, args = [] }) {return new Promise((resolve, reject) => {const sock = net.connect(prewarmAddr(id), () => {sock.write(JSON.stringify({ cmd: 'activate', cwd, args }) + '\\n');});let buf = '';sock.on('data', d => {buf += d;const nl = buf.indexOf('\\n');if (nl >= 0) { sock.end(); resolve(JSON.parse(buf.slice(0, nl))); }});sock.on('error', reject);});}// Wake up pool1, bind the target directory, and start it in serve modeconst res = await activate('pool1', { cwd: '/Users/me/project-A', args: ['--serve'] });console.log(res); // { ok: true, cmd: 'activate', status: 'activating', cwd: '...' }
sock.write(JSON.stringify({cmd: 'activate',ackMode: 'ready',sessionId: 'session-1',cwd,args: ['--serve', '--port', '0'],}) + '\\n');
--prewarm-id values. They are independent and do not affect each other.chdir and broadcasts the cwd change. File watchers are automatically rebound, and project-level caches (settings, memory, skills, plugins, and product configurations) are automatically invalidated and rescanned, ensuring that stale configurations from the temporary directory used during prewarming are never read.~/.codebuddy/ are naturally shared across all prewarmed processes.0600 (owner only) to prevent connection hijacking by other users on the same machine.--prewarm, --prewarm-id <id>, and --prewarm-force.env | Function | Default Value |
CODEBUDDY_CODE_PREWARM_SOCKET_PATH | Customizes the unix socket storage directory (for example, /dev/abc/, with the trailing slash optional). The process side creates + the client side connects to read the same env. unix only; Windows named pipes are not affected. | /tmp |
Was this page helpful?
You can also Contact sales or Submit a Ticket for help.
Help us improve! Rate your documentation experience in 5 mins.
Feedback