@chieflab/sdk
v0.1.0
Published
TypeScript SDK for ChiefLab after-build GTM. Typed methods for getUsersAfterBuild, launchProduct, publishApprovedPost, sendApprovedEmail, measureLaunchResults, connections, tenants, and signup. Wraps the hosted MCP at chieflab.io/api/mcp.
Downloads
102
Maintainers
Readme
@chieflab/sdk
TypeScript SDK for ChiefLab. Typed methods for the closed-loop launch flow. Wraps the hosted MCP at https://api.chieflab.io/api/mcp. Zero runtime deps.
Package status: this SDK is packaged in the repo but not published to npm yet. Do not tell users to run
npm install @chieflab/sdkuntilnpm view @chieflab/sdkresolves. Use the hosted MCP endpoint directly today.
After npm publish:
npm install @chieflab/sdkQuick start
import { createClient } from "@chieflab/sdk";
const chieflab = createClient({ apiKey: process.env.CHIEFLAB_API_KEY });
// 1. Plan + draft a launch
const launch = await chieflab.launchProduct({
productUrl: "https://yoursite.com",
goal: "Get our first 100 users",
channels: ["linkedin", "x", "email"]
});
console.log("Approve here:", launch.reviewUrl);
console.log(launch.agentProofLine);
// 2. (User approves on the reviewUrl in their browser)
// 3. Fire each approved action via its executorTool
for (const action of launch.publishActions) {
if (action.connector === "zernio") {
await chieflab.publishApprovedPost({
actionId: action.id,
content: "...", // your LLM rendered this from the brief
platforms: [{ platform: "linkedin", accountId: "zer_acc_..." }]
});
} else if (action.connector === "resend") {
await chieflab.sendApprovedEmail({
actionId: action.id,
from: "Brand <[email protected]>",
to: "[email protected]",
subject: "Launch day",
html: "<h1>...</h1>"
});
}
}
// 4. ≥24h later — pull metrics + next-iteration recommendation
const review = await chieflab.measureLaunchResults({ runId: launch.launchId });
console.log(review.brief);For agent-built repos, install the after-build hook so coding agents discover this automatically:
Working installer today:
curl -fsSL https://chieflab.io/install-agent-hook.mjs | node -Windows PowerShell:
iwr https://chieflab.io/install-agent-hook.mjs -OutFile .chieflab-install-agent-hook.mjs; node .\.chieflab-install-agent-hook.mjsnpm command after publish:
npx @chieflab/cli initWhy this exists
Three audiences:
- TS app developers building agent-native products who want typed methods rather than hand-rolling JSON-RPC envelopes.
- Server-side runtime authors integrating ChiefLab into a product where the agent runs on YOUR backend (not in Cursor / Claude Desktop).
- CI / scheduled jobs that need to drive launches programmatically.
If you're inside Cursor / Claude Desktop / Claude Code, use the hosted MCP URL directly today. After npm publish, @chieflab/mcp-server is the stdio MCP host plug-in.
If you're calling from a non-Node runtime (Python, Go, etc.), use plain fetch against https://api.chieflab.io/api/mcp — the SDK is just sugar around that.
API surface
Closed-loop methods:
| Method | Tool it wraps | When |
|---|---|---|
| launchProduct(args) | chiefmo_launch_product | User wants to launch a new product. Default first call. |
| getUsersAfterBuild(args) | chieflab_get_users_after_build | Outcome-named after-build call for "get users / make money / what now". |
| continueLaunchLoop(args) | chiefmo_continue_launch_loop | Resume from runId and get the exact next action. |
| launchHealth(args) | chiefmo_launch_health | Inspect approvals, blockers, execution, measurement windows, and next moves. |
| publishApprovedPost(args) | chiefmo_publish_approved_post | After approval. Fires via Zernio. |
| sendApprovedEmail(args) | chiefmo_send_approved_email | After approval. Fires via Resend. |
| measureLaunchResults(args) | chiefmo_measure_launch_results | ≥24h after publish. |
| createSocialGraphics(args) | chiefmo_create_social_graphics | Ad-hoc graphics outside a launch run. |
| diagnoseMarketing(args) | chiefmo_diagnose_marketing | EXISTING campaigns ("why isn't X working"). |
Operators:
diagnoseSales, diagnoseSupport, diagnoseFinance, diagnoseOps.
Connections:
connectProvider, connectionStatus, listPublishAccounts, listEmailSenders, setZernioKey, setResendKey.
Tenants:
createTenant, listTenants, setTenantContext, recordVoiceSample.
Approval surface:
approveAction, transitionApproval.
Signup (no auth):
signupWorkspace — mint a key on the user's behalf.
Anything else: callTool(name, args) — raw MCP call, returns the parsed payload.
Errors
import { ChiefLabError } from "@chieflab/sdk";
try {
await chieflab.launchProduct({ goal: "..." });
} catch (err) {
if (err instanceof ChiefLabError) {
console.error(err.code, err.status, err.message);
if (err.code === "unauthorized") {
// refresh key flow
}
}
}Env
| Var | Default | What |
|---|---|---|
| CHIEFLAB_API_KEY | (required) | Bearer key. clp_live_... or clp_dev_.... |
| CHIEFLAB_ENDPOINT | https://api.chieflab.io/api/mcp | Override. |
(Both can also be passed inline to createClient({ apiKey, endpoint, timeoutMs }).)
License
Apache 2.0. Source: https://github.com/bdentech/chieflab/tree/main/packages/sdk
