@pc-core/sdk
v0.1.8
Published
Typed TypeScript client for the ProductClient API — ship releases, roll back, triage feedback, open incidents, and run the conversion and ranking commands from code.
Maintainers
Readme
@pc-core/sdk
Typed TypeScript client for the ProductClient API. Ship releases, roll back,
triage feedback, open incidents, and run the conversion and ranking commands
from code — the same calls the pc CLI and the MCP server make.
The API is the contract. The SDK, the CLI, and MCP are three doors into it, so nothing here does work the API cannot do.
Install
npm install @pc-core/sdkWorks on Node 18+ and Bun. Zero dependencies.
Usage
import { createPcClient } from '@pc-core/sdk';
const pc = createPcClient({ token: process.env.PC_TOKEN! });
// Ship a release to the public page.
await pc.ship({
slug: 'acme',
title: 'Faster sync',
version: '1.4.0',
body: 'Sync is now 3× faster on large workspaces.',
commit_sha: process.env.GITHUB_SHA,
repo: 'acme/acme'
});
// See what is live and what is waiting.
const { latest_published, drafts } = await pc.diff('acme');pc({ token }) is shorthand for createPcClient({ token }).
Getting a token
Run the device flow and keep the token in CI:
const token = await pc.login({
onCode: ({ userCode, verificationUrl }) => {
console.log(`Approve ${userCode} at ${verificationUrl}`);
}
});Or grab one once from the CLI (pc login) and store it as PC_TOKEN.
Commands
Auth and workspace — whoami, products, deviceStart, devicePoll, login,
tokens, logout
The page — ship, diff, releases, rollback, inspect, snippet, cta
Feedback — feedback, inbox, reply, triage
Incidents — status, incidentOpen, incidentUpdate, incidentClose
Product agent — agentContext, setOffer, leads
Conversion and ranking — waitlist, funnel, widget, badge, llms,
validateSchema, og, alt, cite, index, directories, announce
Escape hatch — rpc(fn, args) calls any allowlisted pc_api_* function
directly, using the same names the CLI passes.
Launch and distribution — launch, coming, roadmap
The page test — ab
The agent's questions and drafts — agentTest, agentDraft
Directories, illustration and checkout — directory, illustrate, checkout,
featured
Not built yet — cite and index return { configured: false, requires }
rather than pretending to work: both need Search Console OAuth for the
workspace, which nothing has connected yet.
What these report honestly
A few of these commands are worth reading the return value of rather than ignoring, because the field that matters is the one that says what did not happen:
abrecords no traffic itself — the product page does that. Aleadercomes back only once both variants have 30 views and the gap clears 2 points; otherwisecan_decideisfalseandreasonis'COLLECTING'.agentDraftreturnssent: 0. There is no send path and no flag that reaches one.directoryreturnsprepared(ledger rows written) anddelivered: 0. These directories have no anonymous submission API.illustratereturnsrenderer: 'svg'andmodel: null. It renders a real SVG from the release's own fields; no model was involved.featuredreturnspaid: false. It creates the checkout; only the verified Whop webhook marks the rail live.
Errors
Every failure throws a PcError with the HTTP status and the API's stable
code:
import { PcError } from '@pc-core/sdk';
try {
await pc.ship({ slug, title });
} catch (error) {
if (error instanceof PcError && error.status === 401) {
// token expired or revoked
}
}License
MIT
