Open source packages for Perspective AI — AI-powered conversation agents.
| Package | Description | Version |
|---|---|---|
| @perspective-ai/sdk | Core embed SDK for vanilla JS and CDN usage | |
| @perspective-ai/sdk-react | React components for Perspective embeds |
See package READMEs for detailed documentation:
# Install dependencies
pnpm install
# Build all packages
pnpm build
# Run tests
pnpm test
# Development mode (watch)
pnpm devWhen working on unreleased SDK changes, there are several ways to use the local packages in a consuming app.
Every PR with a changeset automatically publishes snapshot packages to npm. Install using the PR tag:
# Use the PR-specific tag (always points to latest snapshot from that PR)
pnpm add @perspective-ai/sdk@pr-21
pnpm add @perspective-ai/sdk-react@pr-21
# Or pin to a specific snapshot version
pnpm add @perspective-ai/sdk@0.0.0-pr-21-20260224144030No local setup required — works in CI and for teammates.
Use pnpm overrides in the consuming app's package.json to point at local packages:
Then run pnpm install. To restore published versions, remove the overrides and run pnpm install again.
For apps using Next.js Turbopack (e.g. the demos repo), pnpm link symlinks don't work — Turbopack can't resolve peer deps through symlinks. Use file: protocol with --config.install-links=true to copy packages instead:
# 1. Build SDK
cd /path/to/embed && pnpm build
# 2. Install both packages together (so sdk-react can resolve sdk as peer dep)
cd /path/to/consuming-app
pnpm add @perspective-ai/sdk@file:/path/to/embed/packages/sdk \
@perspective-ai/sdk-react@file:/path/to/embed/packages/sdk-react \
--config.install-links=trueYou may also need transpilePackages in next.config.ts:
const nextConfig: NextConfig = {
transpilePackages: ["@perspective-ai/sdk", "@perspective-ai/sdk-react"],
};This simulates what npm would install, catching issues like missing files entries:
# 1. Build
pnpm build
# 2. Pack each package
cd packages/sdk && pnpm pack # creates perspective-ai-sdk-x.x.x.tgz
cd packages/sdk-react && pnpm pack # creates perspective-ai-sdk-react-x.x.x.tgz
# 3. Install the tarballs in your consuming app
pnpm add /path/to/embed/packages/sdk/perspective-ai-sdk-1.1.3.tgz
pnpm add /path/to/embed/packages/sdk-react/perspective-ai-sdk-react-1.1.3.tgz- Always nuke
.nextafter relinking — Turbopack caches resolved modules aggressively. After relinking you'll get "Unable to open static sorted file" panics or stale code unless yourm -rf .nextin the consuming app. - Dev server won't auto-detect SDK rebuilds — after
pnpm buildin the SDK repo, restart the consuming app's dev server. It doesn't watchnode_modules. - Don't commit lockfile/package.json changes from linking — restore published versions before committing.
This repo uses Changesets for versioning and publishing.
When making changes that should be released, add a changeset:
pnpm changesetSelect the packages affected and bump type (patch/minor/major). This creates a file in .changeset/ describing the change.
- PRs with changesets merge to
main - Release workflow creates a "Version Packages" PR
- Merging that PR publishes to npm
MIT