No work step here. This is probably a skill that reads or coordinates, not one that produces something.
.md file to compare - side-by-side diff against crayon-sdk
crayon-sdk
What it does for you
Reference for the building blocks behind your assistant's live screens.
What it produces
A recent result, so you can see the kind of work it returns.
loading…
How to get it
These run inside the Snappy workspace. Want this working in your business? I set skills like this up with you, in one focused week.
For developers how this skill is built, graded, and how it runs
at a glance- the short version
what's inside - the parts that make up a skill 2/4 present
A skill is just a few plain-text files. Only the main one is required. The rest are optional, added as the work needs them. This is what the skill is made of; how it runs is just below.
state/skills/crayon-sdk/SKILL.md
present
state/lib/crayon-sdk.ts
not present
state/bin/crayon-sdk/
not present
state/skills/crayon-sdk/AGENTS.md
present
how it's graded - what counts as a good run 3 criteria · 2 deterministic · 1 judge
Each row is one thing a good run has to get right. deterministic means a quick check decides, pass or fail. judge means the AI reads the result and rates it. Grading each piece on its own (instead of one overall score) shows exactly where a run fell short, so the fix is obvious.
how it runs - the shared frame every skill uses 2/5 present
Every skill runs the same way. One part does the work, a separate part checks it, and a short loader hands the AI exactly what it needs for the job. Anything this skill doesn't use shows a one-line note saying why, on purpose, not by accident.
This skill doesn't fix its own gaps yet.
state/log/evals.ndjson what it has learned - fixes written back in over time sample
When a run hits something this skill didn't handle, the fix gets written back into the skill so it doesn't happen again. FIXED means it was corrected on the spot. LOGGED means it's queued for a bigger rewrite. Either way, the skill gets a little better and never makes the same mistake twice.
- Loading feedback rows…
SKILL.md- the skill, written out in plain English
Crayon SDK - Master Reference
Purpose
Operate like a master with the Thesys generative-UI stack. This skill captures every hard-won lesson from a production implementation (Orbiter Frontend's copilot - 2,400+ LOC orchestrator, 18 templates, voice integration, full conversation persistence) plus the official ecosystem (Crayon, C1, OpenUI).
When to Use This Skill
Activates when working with:
@crayonai/react-core,@crayonai/react-ui, or the new@openuidev/*packages- Thesys C1 GenUI API (the OpenAI-compatible streaming endpoint that emits Crayon responses)
CrayonChat,useThreadManager,useThreadState,useThreadActions,processStreamedMessage- Building AI chat UIs with SSE streaming + interactive response templates
- Voice composers, portal-mounted UI inside Crayon's composer
- Migrating from
@crayonai/*to the open-source@openuidev/*packages - Any prompt mentioning C1, Crayon, CrayonChat, OpenUI, GenUI, generative UI, response template, thread manager
Rubric
criteria:
- name: reference_completeness
kind: deterministic
check: "All major sections present: Crayon Ecosystem (3 products), Quick Start standalone example, thread manager flow, SSE streaming, templates, portal mounting patterns, persistence, migration notes."
- name: example_parses
kind: deterministic
check: "The Quick Start code example (useThreadManager + CrayonChat) is syntactically valid and demonstrates processStreamedMessage integration."
- name: agent_ecosystem_clarity
kind: judge
check: "When a future agent encounters @crayonai/* or @openuidev/*, they understand the three products (Crayon SDK, C1, OpenUI), when to use each, and how to migrate. The distinction Crayon vs C1 vs OpenUI is unambiguous."
The Crayon Ecosystem (April 2026)
There are three related products. They are easy to confuse.
| Product | What it is | NPM | License | Notes |
|---|---|---|---|---|
| Crayon SDK | Original React UI kit + chat shell | @crayonai/react-core, @crayonai/react-ui | MIT | The one Orbiter uses today |
| C1 | Hosted GenUI API (OpenAI-compatible). Emits UI components in a stream | (HTTP API, not npm) | Closed (managed) | Uses Crayon under the hood |
| OpenUI | Open-source rewrite, March 2026 launch. Streaming-first language + React runtime | @openuidev/react-lang, @openuidev/react-headless, @openuidev/react-ui, @openuidev/cli | MIT | Repo: github.com/thesysdev/openui. 67% fewer tokens than JSON. Includes Carousel, CarouselCard, ShadCN/MUI/DaisyUI/Base UI integrations |
Practical guidance:
- Existing project on
@crayonai/*? Stay there. Everything in this skill applies. The packages still work and are still maintained. - New project? Try
@openuidev/*first vianpx @openuidev/cli@latest create. The token efficiency is real and the API surface is cleaner. - Want a hosted backend? C1 is the managed offering - point your client at
c1.thesys.devlike an OpenAI endpoint.
The rest of this skill uses @crayonai/* examples because that's the production-tested surface. See ecosystem.md for OpenUI migration notes and side-by-side comparison.
Quick Start (Standalone Chat)
import { useThreadManager, processStreamedMessage } from "@crayonai/react-core";
import { CrayonChat } from "@crayonai/react-ui";
import "@crayonai/react-ui/styles/index.css";
import { templates } from "./templates"; // [{ name, Component }]
import { processMessage } from "./process-message"; // returns Promise<Response> with SSE body
function Copilot({ conversationId }: { conversationId: number | null }) {
const threadManager = useThreadManager({
threadId: conversationId ? String(conversationId) : null,
shouldResetThreadState: true,
loadThread: async (threadId) => loadFromBackend(threadId),
onProcessMessage: async ({ message, threadManager: tm, abortController }) => {
tm.appendMessages({ ...message, id: crypto.randomUUID() });
const response = await processMessage({
threadId: String(conversationId ?? "new"),
messages: [...tm.messages, { ...message, id: crypto.randomUUID() }],
abortController,
});
await processStreamedMessage({
response,
createMessage: tm.appendMessages,
updateMessage: tm.updateMessage,
deleteMessage: tm.deleteMessage,
});
return [];
},
responseTemplates: templates,
});
return (
<CrayonChat
key={conversationId ?? "new"} // remount on switch
type="standalone"
threadManager={threadManager}
responseTemplates={templates}
agentName="Assistant"
logoUrl="/logo.svg"
scrollVariant="always"
messageLoadingComponent={() => <Loader />}
welcomeMessage={{ title: "Hello", description: "How can I help?" }}
conversationStarters={{
variant: "long",
options: [{ displayText: "Get started", prompt: "Help me get started" }],
}}
/>
);
}
Three things to internalize:
- Thread ID is always a string (
String(numericId)if your backend uses numbers - passing a number silently breaks). onProcessMessageMUST callprocessStreamedMessageand return[]- not the messages.- Bump the
keyprop to force-remount when switching conversations or modes.
Navigation Guide
| Need to... | Read this |
|---|---|
Understand Crayon vs C1 vs OpenUI vs @openuidev | ecosystem.md |
Build the SSE stream that processMessage returns | sse-streaming.md |
Wire up useThreadManager + persistence + raw-JSON recovery | thread-management.md |
| Register custom templates, fire follow-ups, communicate with parent | templates.md |
| Configure every CrayonChat prop (welcome, starters, artifacts) | component-api.md |
Scope CSS, override every .crayon-* selector, animate cards | styling.md |
| Portal-mount a voice mic / custom UI into the composer | voice-integration.md |
| Insert a node next to the submit button on OpenUI (not Crayon) | openui-dom-map.md |
| Programmatically send messages from outside CrayonChat | dom-patterns.md |
| Refs vs state, race guards, mode state machines, polling | production-patterns.md |
| Avoid every trap I've seen in production | gotchas.md |
Core Architecture
┌─────────────────────────────────────────────────────┐
│ CrayonChat (UI shell) │
│ ├── threadManager ← from useThreadManager │
│ │ ├── messages[] UserMessage|Assistant… │
│ │ ├── isRunning true while streaming │
│ │ ├── appendMessages, updateMessage, … │
│ │ └── onProcessMessage(message, tm, abort) │
│ │ └── return processStreamedMessage(…) │
│ │ │
│ ├── responseTemplates[] { name, Component } │
│ │ └── inside Component: │
│ │ useThreadState() / useThreadActions() │
│ │ │
│ └── SSE wire format: │
│ event: text\ndata: <word>\n\n │
│ event: tpl \ndata: {name,templateProps}\n\n │
└─────────────────────────────────────────────────────┘
Key Types (from @crayonai/react-core)
type UserMessage = {
id: string;
role: "user";
type: "prompt";
message?: string;
context?: JSONValue[];
};
type AssistantMessage = {
id: string;
role: "assistant";
context?: JSONValue[];
message?: (
| { type: "text"; text: string }
| { type: "template"; name: string; templateProps: any }
)[];
};
type Message = UserMessage | AssistantMessage;
type CreateMessage = Omit<UserMessage, "id">;
interface ResponseTemplate {
name: string;
Component: React.ComponentType<any>;
}
type ThreadState = {
isRunning?: boolean;
isLoadingMessages?: boolean;
messages: Message[];
error: Error | null | undefined;
responseTemplates: Record<string, ResponseTemplate>;
isInitialized: boolean;
};
type ThreadActions = {
processMessage: (message: CreateMessage) => Promise<void>;
appendMessages: (...messages: Message[]) => void;
updateMessage: (message: Message) => void;
deleteMessage: (messageId: string) => void;
onCancel: () => void;
setMessages: (messages: Message[]) => void;
};
SSE Wire Format (memorize this)
event: text
data: Hello
event: text
data: world
event: tpl
data: {"name":"contact_card","templateProps":{"name":"Jane","company":"Acme"}}
Rules:
- Two events:
text(streamed prose) andtpl(instant template card). - Word-by-word
textevents with a leading space gives the smoothest typing illusion. - Paragraph break = a
textevent with emptydatalines. - Template
datais a single JSON line. ThenameMUST exactly match a registered template - no fallback, no fuzzy match. Content-Type: text/event-stream,Cache-Control: no-cache, no-transform.- Always close the stream controller or
isRunningstays true forever.
Quick Reference
Imports
// Core
import {
useThreadManager,
useThreadState,
useThreadActions,
processStreamedMessage,
} from "@crayonai/react-core";
import type {
Message,
UserMessage,
AssistantMessage,
CreateMessage,
ResponseTemplate,
ThreadManager,
} from "@crayonai/react-core";
// UI
import { CrayonChat } from "@crayonai/react-ui";
import "@crayonai/react-ui/styles/index.css";
CrayonChat shapes
| Prop | Choices | ||
|---|---|---|---|
type | "standalone" \ | "copilot" \ | "bottom-tray" |
scrollVariant | "always" (safe default) \ | "smart" \ | "manual" |
welcomeMessage | { title?, description?, image? } or a custom component | ||
conversationStarters.variant | "short" (pills) \ | "long" (vertical) |
Inside a template component
const { processMessage } = useThreadActions(); // send a follow-up user message
const { isRunning, messages } = useThreadState(); // read live state reactively
Cross-tree communication: window.dispatchEvent(new CustomEvent("…", { detail })) (see templates.md).
Programmatic send into the composer: native-setter DOM hack (see dom-patterns.md).
Resource Files
ecosystem.md
Crayon SDK vs C1 vs OpenUI. Package matrix. Migration notes. Token-efficiency claims (67% fewer tokens than JSON for OpenUI Lang v0.5).
sse-streaming.md
Exact SSE format. Word-by-word chunking. Response normalization for the four shapes backends actually return (string, array, stringified JSON, {response: …}). Abort handling. Conversation history extraction.
thread-management.md
useThreadManager configuration. loadThread with raw-JSON recovery. Conversation persistence write paths. useThreadListManager for sidebar threads. processMessage (CrayonChat prop) vs onProcessMessage (hook param).
templates.md
Template registry. useThreadActions / useThreadState. Interactive cards. Cross-tree CustomEvent pattern. Blocked-templates-during-interview filter. Mode-aware template logic.
component-api.md
Every CrayonChat prop. Welcome message variants. Conversation starters. Artifacts (side panel). Available @crayonai/react-ui primitives (Accordion, Carousel, Charts, CodeBlock, DatePicker, Steps, Tabs, etc.).
styling.md
Wrapper-class scoping. The complete list of overridable .crayon-shell-* selectors (composer, thread, message bubbles, conversation starters, send button). Card-entrance animation. Dark theme via CSS variables. Inline-style strategy for templates.
voice-integration.md
Portal-mounting a voice mic into .crayon-shell-thread-composer__input-wrapper. MutationObserver re-injection so it survives Crayon rerenders. Dual-provider TTS (Gradium primary, ElevenLabs streaming fallback). STT with Web Speech API + MediaRecorder fallback. The stoppingRef flag pattern. Selectors here are Crayon-only - for OpenUI (@openuidev/*), see openui-dom-map.md; the submit button lives one level deeper, inside __action-bar.
openui-dom-map.md
Canonical parent-child DOM map for @openuidev/react-ui v0.11.4 (snappy-os's stack). Every .openui-shell-* class with its real children, generated from a source-of-truth read of the installed dist. Covers composer (in-thread + welcome), thread messages, welcome screen, sidebar, IconButton. Insertion-point cookbook ("where do I put a mic", "what's the submit button's parent") and anti-patterns ported from real production crashes - including the inputWrapper.insertBefore(node, submit) NotFoundError that took down the React tree on 2026-04-28.
dom-patterns.md
Native HTMLTextAreaElement.value setter to bypass React's controlled-input. Selector chains for the composer input + send button. Enter-key fallback. Live-transcription class toggle on the input wrapper.
production-patterns.md
Refs vs state in async callbacks. Conversation creation race guard. Mode state machines (default / leverage / outcome / meeting). Suggestion request polling with visibility pause. Auto-generated dispatch-confirmation fallback. Quick-action markers. FLIP avatar-travel animations between picker and chat.
gotchas.md
14 hard-won lessons with why they bite: remount flashing, history building strips templates, response format inconsistency, raw-JSON in stored content, useThreadActions outside CrayonChat throws, return-type mismatch between processMessage and onProcessMessage, threadId must be string, shouldResetThreadState timing, card filtering during interviews, programmatic message injection, exact template-name matching, stream controller MUST close, multi-template ordering, AbortError silencing.
Related Skills
- crayonchat - The previous version of this skill. Superseded by this one but still installed.
- seymour-papert - Design philosophy that pairs well with Crayon's progressive-disclosure card stream.
- emil-design-eng - UI polish principles for animating cards.
Skill Status: COMPLETE Line Count: ~290 Progressive Disclosure: 10 resource files Reference Implementation: orbiter-frontend/src/features/copilot/ (2,400+ LOC, 18 templates, voice, persistence)
AGENTS.md- what the AI loads when this skill comes up
crayon-sdk - loader
Per-turn reference for the Thesys generative-UI stack. Full skill: state/skills/crayon-sdk/SKILL.md. Prose-only with 11 sub-files; eval=auto-shape. Reference resource for chat integrations.
Critical Rules
- Prose-only with 11 sub-files, no lib/sidecar. "RUN THIS" briefs →
[SKIPPED]. Deliverable is guidance + reference docs, not executable code. - Three ecosystems (April 2026). Crayon SDK (
@crayonai/react-core|react-ui, MIT, production-tested) | C1 (hosted GenUI API at c1.thesys.dev, managed) | OpenUI (@openuidev/*, open-source, 67% token efficiency). Existing projects: stay on Crayon. New projects: try OpenUI. Want hosted: use C1. - Quick Start traps. (a) threadId MUST be string (
String(numericId)if needed). (b)onProcessMessageMUST callprocessStreamedMessage()and return[]. (c) Bumpkeyprop on<CrayonChat>to force-remount on conversation switch. - SSE wire format. Two events:
text(streamed prose, word-by-word with leading space) andtpl(one JSON line{name, templateProps}). TemplatenameEXACTLY matches registered name. Headers:Content-Type: text/event-stream,Cache-Control: no-cache, no-transform. Always close stream controller. Paragraph breaks = emptydatalines. - 8 navigation domains → 8 sub-files. Ecosystems→ecosystem.md | SSE→sse-streaming.md | useThreadManager→thread-management.md | Templates→templates.md | CrayonChat props→component-api.md | CSS→styling.md | Voice→voice-integration.md | OpenUI DOM→openui-dom-map.md.
- OpenUI DOM:
__submit-buttonis GRANDCHILD of__input-wrapper. Parent is__action-bar.insertBefore(node, submit)throwsNotFoundErrorif submit not in its direct children → React tree teardown. Read openui-dom-map.md FIRST before any DOM mutation. - Theme three-leg cream-canvas. (1) MutationObserver on
documentElement.dataset.theme→ React state. (2)theme={{mode: themeMode}}prop to<FullScreen>. (3) DeeplightTheme/darkThemeobjects to ThemeProvider (not just mode). - chat-inject serialization: MIN_COMMIT_FRAMES=3 rAFs. OpenUI IconButton has NO
disabledattr →:not(:disabled)matches stale closure first rAF. Serialize concurrent injects OR thread-id-scope. Endpoints:chat-inject-push(text + auto-submit) |chat-inject-control(button click only). POLL_MS=3000. - Shape emitters run on failure path. When dispatch backend fails (spawn ENOENT), shapes stop unless emitter fires regardless. Check dispatch-chat.ndjson for spawn errors before diagnosing missing card.
- KNOWN_COMPONENTS gate must include all shapes. Missing entries silently filter LLM-emitted blocks. Add new shapes to server gate before claiming live.
Commands
This skill is prose-only reference with 11 sub-files. No HTTP endpoints.
| verb | invoke | input | output |
|---|---|---|---|
| (reference) | - | - | - |
Sub-files: ecosystem.md | sse-streaming.md | thread-management.md | templates.md | component-api.md | styling.md | voice-integration.md | openui-dom-map.md | dom-patterns.md | production-patterns.md | gotchas.md
Reference impl: ~/projects/orbiter-frontend/src/features/copilot/ (2400+ LOC, 18 templates, voice, persistence)
Self-Test
- [ ] Know 3 ecosystems + when to choose each (Crayon/C1/OpenUI)
- [ ] Know Quick Start traps: threadId string, return [], bump key
- [ ] Know SSE: text + tpl events, exact name match, always close
- [ ] Know 8 navigation domains + sub-file refs
- [ ] Know OpenUI DOM trap: submit GRANDCHILD, read openui-dom-map.md
- [ ] Know 3-leg cream-canvas: MutationObserver + theme prop + deep tokens
- [ ] Know chat-inject: MIN_COMMIT_FRAMES=3, serialize, POLL_MS=3000
- [ ] Know shape emitters run failure path
- [ ] Know KNOWN_COMPONENTS gate must include all shapes
- [ ] Know 11 sub-files are reference, not generated
<!-- footer-injection-point -->
api.ts- the code it can call
⚠ no api.ts - this skill has no typed action surface
scripts- helper scripts it can run
prose-only skill - 7 inline code blocks live in SKILL.md above (no state/bin/ sidecar yet).
how we check it- the checks, plus the last 10 runs
no recent runs logged - the eval contract is declared but nothing has been graded yet