MCPcopy Index your code
hub / github.com/Recappi/sdk

github.com/Recappi/sdk @v1.2.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.2.0 ↗ · + Follow
377 symbols 721 edges 46 files 23 documented · 6%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

@recappi/sdk

CI

Platform support

Feature macOS Windows Linux (x64 GNU)
decodeAudio / decodeAudioSync Yes Yes Yes
ShareableContent.applications() Yes Yes Yes
ShareableContent.applicationWithProcessId() Yes Yes Yes
ShareableContent.onApplicationListChanged() Yes Yes Yes (polling)
ShareableContent.isUsingMicrophone() Yes Yes Yes (PulseAudio)
ShareableContent.onAppStateChanged() Yes Yes Yes (polling)
ShareableContent.tapGlobalAudio() Yes Yes Yes (PulseAudio monitor)
ShareableContent.tapAudio() Yes Yes Yes (dedicated Pulse sink reroute)

Published Linux artifacts currently target x86_64-unknown-linux-gnu. The Linux implementation ships the same top-level ShareableContent surface as macOS and Windows, but it uses a PulseAudio-compatible userspace and shells out to pactl / ffmpeg, so capture requires those tools to be available at runtime.

If your application needs to choose a Linux fallback backend dynamically, use getPlatformCapabilities() instead of hard-coding platform checks. On Linux, those booleans reflect the currently reachable runtime prerequisites for each capture path, not just whether the functions are exported.

import { getPlatformCapabilities } from '@recappi/sdk'

const capabilities = getPlatformCapabilities()

if (capabilities.tapGlobalAudio) {
  console.log('Use Recappi for realtime capture')
} else {
  console.log('Use your Linux-specific fallback backend')
}

Usage

Recording system audio

Available on macOS, Windows, and Linux. Linux capture requires a PulseAudio-compatible server plus pactl and ffmpeg.

Both input and output devices are recording, mixed into a single audio stream.

import { writeFile } from 'node:fs/promises'
import { setTimeout } from 'node:timers/promises'

import { ShareableContent } from '@recappi/sdk'
import { createWavBuffer } from '@recappi/sdk/encode-wav'

const WavBuffers = []

let totalLength = 0

const session = ShareableContent.tapGlobalAudio([], (err, samples) => {
  if (err) {
    console.error('Error capturing audio:', err)
    return
  }
  WavBuffers.push(samples)
  totalLength += samples.length
})

console.info('Recording audio for 5 seconds...')

await setTimeout(5000) // Record for 5 seconds

session.stop()

console.info(`Recording stopped. Writing ${totalLength} samples to output.wav...`)

const { buf: contactedBuffer } = WavBuffers.reduce(
  ({ buf, offset }, cur) => {
    buf.set(cur, offset)
    return {
      buf,
      offset: offset + cur.length,
    }
  },
  {
    buf: new Float32Array(totalLength),
    offset: 0,
  },
)

console.log(`Creating WAV buffer ...`)

const wavBuffer = Buffer.from(
  createWavBuffer(contactedBuffer, {
    sampleRate: session.sampleRate,
    numChannels: session.channels,
  }),
)

await writeFile('output.wav', wavBuffer)

Listing running applications

Available on macOS, Windows, and Linux.

import { ShareableContent } from '@recappi/sdk'

const apps = ShareableContent.applications()

for (const app of apps) {
  console.log(`Name: ${app.name}, PID: ${app.processId}`)
}

Recording specific application

Available on macOS, Windows, and Linux. On Windows, tapAudio() currently uses the same capture backend as tapGlobalAudio() and does not isolate a single process stream yet. On Linux, tapAudio() reroutes matching Pulse sink-inputs into a dedicated capture sink and records that sink's monitor. This is best-effort and depends on the target application exposing movable Pulse streams.

import { ShareableContent } from '@recappi/sdk'

const apps = ShareableContent.applications()
const musicApp = apps.find((app) => app.name === 'Music')

if (musicApp) {
  const session = ShareableContent.tapAudio(musicApp.processId, (err, samples) => {
    if (err) {
      console.error('Error capturing audio:', err)
      return
    }
    // Process samples...
  })

  // Stop recording after 5 seconds
  setTimeout(() => {
    session.stop()
  }, 5000)
}

Playground

yarn install
yarn build
yarn workspace playground dev:server
yarn workspace playground dev:web

Local Linux Iteration From macOS

Use the bundled Docker environment to exercise the Linux backend locally from a macOS workstation.

bash ./scripts/test-linux-docker.sh

If you want an interactive shell inside the same Linux image:

bash ./scripts/docker-linux.sh bash

The Docker image installs Rust, Node.js, PulseAudio, pactl, and ffmpeg, so the Linux binding tests can run without depending on the host machine.

Extension points exported contracts — how you extend this code

ToCoreFoundation (Interface)
(no doc) [8 implementers]
src/macos/cf_types.rs
Recording (Interface)
(no doc)
playground/server/main.ts
App (Interface)
(no doc)
playground/web/types.ts
RecordingStatus (Interface)
(no doc)
playground/server/main.ts
AppGroup (Interface)
(no doc)
playground/web/types.ts
RecordingMetadata (Interface)
(no doc)
playground/server/main.ts
RecordingStatus (Interface)
(no doc)
playground/web/types.ts
AppInfo (Interface)
(no doc)
playground/server/main.ts

Core symbols most depended-on inside this repo

add
called by 22
src/macos/cf_types.rs
stop
called by 14
src/linux/mod.rs
write
called by 13
src/macos/av_audio_file.rs
linux_backend_error
called by 13
src/linux/mod.rs
runCommand
called by 12
__test__/linux-pulse-fixture.cjs
run_command
called by 11
src/linux/mod.rs
unload_module
called by 10
src/linux/mod.rs
getAppName
called by 7
playground/server/main.ts

Shape

Function 196
Method 108
Class 54
Interface 15
Enum 4

Languages

Rust71%
TypeScript29%

Modules by API surface

src/linux/mod.rs83 symbols
src/windows/microphone_listener.rs27 symbols
__test__/linux-pulse-fixture.cjs27 symbols
src/windows/screen_capture_kit.rs24 symbols
src/macos/tap_audio.rs24 symbols
playground/server/main.ts23 symbols
src/macos/screen_capture_kit.rs20 symbols
playground/web/components/saved-recording-item.tsx18 symbols
src/windows/audio_capture.rs14 symbols
src/macos/audio_buffer.rs13 symbols
src/audio_decoder.rs10 symbols
playground/web/components/icons.tsx10 symbols

For agents

$ claude mcp add sdk \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact