Node SDK
Node workers, Next.js build tasks, Deno/Bun scripts.
The Node SDK mirrors the Python ergonomics - a `track` higher-order function, `ChirpAgent` manual lifecycle, and the same green/red end-state semantics. Zero runtime dependencies; ships TypeScript types out of the box. Works in Node ≥ 18 and any runtime that supports the package's Node APIs.
An additional `chirp/express` submodule ships an Express/Connect error middleware that sends one-shot notifications for uncaught server errors.
Prerequisites
- Node ≥ 18 (or Bun/Deno).
- Chirp installed on your phone, signed in.
Setup
- 1
Install + authenticate
Same one-time browser pairing as the Python SDK. CI uses
CHIRP_API_KEYenv var.shellnpm install chirp npx chirp login - 2
Wrap an async function with `track()`
Higher-order pattern:
track(opts, fn)returns a wrapped version offnthat owns an @agent activity lifecycle. Resolves green, rejects red.deploy.tsimport { track } from 'chirp'; const deploy = track( { name: 'deploy', theme: '#22c55e' }, async (env: string) => { await build(); await push(env); await smoke(env); }, ); await deploy('prod'); - 3
Use `ChirpAgent` callback form for finer control
When you need to start/end the activity manually or branch the lifecycle.
typescriptimport { ChirpAgent } from 'chirp'; const agent = new ChirpAgent({ name: 'sync', theme: '#22c55e' }); await agent.start(); try { await agent.update('halfway'); await doWork(); await agent.done('done'); } catch (err) { await agent.error('failed: ' + String(err)); throw err; } - 4
Use `ChirpClient` for other schemas
The high-level wrapper uses the generic
@agentcard. When you want a schema-specific layout such as@deploy, use the low-level client directly.typescriptimport { ChirpClient } from 'chirp'; const chirp = new ChirpClient(); await chirp.activityStart('@deploy', { repo: 'my-app', stage: 'build', progress: 0.1, }); await chirp.activityUpdate('@deploy', { stage: 'deploy', progress: 0.7 }); await chirp.activityEnd('@deploy', { data: { stage: 'done' }, dismissalPolicy: { afterSeconds: 120 }, });
What you’ll see
Same lifecycle as Python: starts on entry, updates as you call `agent.update()`, ends green/red on resolution/rejection. Multiple concurrent calls each spawn their own activity instance.
Troubleshooting
- I need a progress bar or another template-specific layout.
- Use
ChirpClient.activityStart,activityUpdate, andactivityEndwith the built-in schema you want.track()andChirpAgentintentionally target the generic@agentcard. - Activity doesn't appear in production but works locally.
- Check
CHIRP_API_KEYis set in your production env, or that~/.chirprcexists for the user running the process. The SDK throws a config error when no key is available. - I want Express error notifications.
- Use the separate Express integration on this page. The exported
chirpErrorNotifiermiddleware sends one-shot pushes for 5xx errors; it does not create a Live Activity per request.