clarity-engine-sdk
v1.0.0
Published
Proactive AI Clarity Engine — one message away from clean structured memory trees. White-label ready for AI companies.
Maintainers
Readme
Clarity Engine SDK
One message → clean, structured, actionable plans.
Proactive AI clarity coach that auto-relabels messy input, builds a live hierarchical tree, and leads users to full clarity. White-label ready for AI companies.
Install
npm install clarity-engine-sdk openai
# Optional: Supabase for vector memory
npm install @supabase/supabase-js
# Optional: React components
npm install react react-domQuick Start
Node.js / Server
import { ClarityEngine } from "clarity-engine-sdk";
const engine = new ClarityEngine({
openaiApiKey: process.env.OPENAI_API_KEY!,
model: "gpt-4o",
onClarityUpdate: (score, tree) => {
console.log(`Clarity: ${score}/100`);
},
});
const session = await engine.startSession();
const result = await engine.processMessage(
session.id,
"I need to launch my app but I have no idea where to start, everything feels overwhelming"
);
console.log(result.response);
console.log(`Clarity score: ${result.session.clarityScore}/100`);
console.log(engine.getTreeMarkdown(session.id));React Hook
import { useClarity } from "clarity-engine-sdk";
function MyApp() {
const { messages, sendMessage, clarityScore, isLoading, startSession } = useClarity({
openaiApiKey: process.env.OPENAI_API_KEY!,
});
useEffect(() => { startSession(); }, []);
return (
<div>
<div>Clarity Score: {clarityScore}/100</div>
{messages.map(msg => (
<div key={msg.id} style={{ textAlign: msg.role === "user" ? "right" : "left" }}>
{msg.content}
</div>
))}
<button onClick={() => sendMessage("I want to build a startup")} disabled={isLoading}>
Send
</button>
</div>
);
}Drop-in Chat Component
import { ClarityChat } from "clarity-engine-sdk";
function App() {
return (
<div style={{ height: 600 }}>
<ClarityChat
config={{ openaiApiKey: process.env.OPENAI_API_KEY! }}
welcomeMessage="What's on your mind? Let's turn it into a plan."
showClarityScore
onComplete={(markdown) => console.log("Plan ready:\n", markdown)}
/>
</div>
);
}White-Label Branding
const engine = new ClarityEngine({
openaiApiKey: "...",
branding: {
name: "Aria",
persona: "You speak in a warm, coach-like tone.",
},
});<ClarityChat
config={{
openaiApiKey: "...",
branding: { name: "Aria" },
}}
theme={{
primary: "#f97316",
background: "#0a0a0a",
surface: "#161616",
}}
/>API Reference
ClarityEngine
| Method | Description |
|--------|-------------|
| startSession(options?) | Start a new clarity session |
| processMessage(sessionId, message) | Send a message and receive a structured response |
| getSession(sessionId) | Retrieve the current session state |
| getTreeMarkdown(sessionId) | Export the clarity tree as markdown |
| clearSession(sessionId) | End and remove a session |
ClarityEngineConfig
| Property | Type | Description |
|----------|------|-------------|
| openaiApiKey | string | Required. OpenAI API key |
| model | string | Model to use (default: gpt-4o) |
| temperature | number | Sampling temperature (default: 0.7) |
| maxTokens | number | Max tokens per response (default: 1024) |
| supabaseUrl | string | Optional Supabase URL for vector memory |
| supabaseKey | string | Optional Supabase anon key |
| branding | object | White-label name and persona |
| onClarityUpdate | function | Callback on clarity score changes |
| onSessionComplete | function | Callback when session reaches 100 clarity |
useClarity(config)
Returns: { messages, session, tree, clarityScore, phase, isLoading, isComplete, error, startSession, sendMessage, reset, exportMarkdown }
License
Commercial license — see LICENSE.
Personal / internal use: free.
White-label / resell in your product: $4,999 one-time.
Contact: [email protected]
