← Public packages
@kentcdodds/kody-connect-talk
Kent C. Dodds's Cloudflare Connect 2026 talk: why your agents' stuff needs a common house, and how Kody builds one on Cloudflare.
Files
// HTML builders used by slides.mjs. Everything here runs at build time in Node
// and returns markup strings for the generated HyperFrames composition.
export const html = String.raw
export const TOPIC_NAMES = {
search: 'search',
execute: 'execute',
mcp: 'MCP',
cli: 'CLI',
api: 'API',
memory: 'memory',
packages: 'packages',
triggers: 'triggers',
credentials: 'credentials',
apps: 'apps',
sharing: 'sharing',
}
export function esc(s) {
// `{` as an entity: code samples show secret placeholders, and the literal
// text in built HTML reads as a credential use to Kody's publish checks.
return String(s).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/\{/g, '{').replace(/\}/g, '}').replace(/:/g, ':')
}
// Every topic gets the same mark: a disc in its hue with a drawn icon.
export const TOPIC_HUES = {
search: '#06b6d4',
execute: '#10b981',
mcp: '#6366f1',
cli: '#84cc16',
api: '#64748b',
memory: '#ef4444',
packages: '#3b82f6',
triggers: '#eab308',
credentials: '#22c55e',
apps: '#a855f7',
sharing: '#ec4899',
secrets: '#14b8a6',
}
const ICONS = {
search: '<circle cx="10.5" cy="10.5" r="6.5"/><path d="M15.5 15.5 21 21"/>',
execute: '<path d="M8 7 3 12l5 5"/><path d="m16 7 5 5-5 5"/><path d="m13.5 4-3 16"/>',
mcp: '<path d="M9 7V3M15 7V3"/><path d="M6 7h12v4a6 6 0 0 1-12 0z"/><path d="M12 17v4"/>',
api: '<path d="M8 4C5.5 4 6 8 4 12c2 4 1.5 8 4 8"/><path d="M16 4c2.5 0 2 4 4 8-2 4-1.5 8-4 8"/><path d="M10.5 12h3"/>',
cli: '<rect x="2.5" y="4" width="19" height="16" rx="2.5"/><path d="m6.5 9 3 3-3 3"/><path d="M12 15h5"/>',
sharing:
'<circle cx="9" cy="8" r="3.5"/><path d="M2.5 20c.8-3.6 3.4-5.5 6.5-5.5s5.7 1.9 6.5 5.5"/><circle cx="17" cy="9" r="2.5"/><path d="M16.8 14.6c2.4.3 4.1 2 4.7 4.9"/>',
memory: '<path d="M18 21 12 17.5 6 21V5.5A2.5 2.5 0 0 1 8.5 3h7A2.5 2.5 0 0 1 18 5.5z"/><path d="M9.5 8.5h5M9.5 12h3"/>',
packages:
'<path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"/><path d="M3.3 7 12 12l8.7-5"/><path d="M12 22V12"/>',
triggers: '<path d="M13 2 4 14h7.5l-1 8 9-12H12l1-8z"/>',
credentials: '<circle cx="7.5" cy="15.5" r="4.5"/><path d="m10.7 12.3 9.8-9.8"/><path d="m16 7 3 3"/><path d="m18.5 4.5 2 2"/>',
apps: '<rect x="3" y="3" width="7.5" height="7.5" rx="1.8"/><rect x="13.5" y="3" width="7.5" height="7.5" rx="1.8"/><rect x="3" y="13.5" width="7.5" height="7.5" rx="1.8"/><rect x="13.5" y="13.5" width="7.5" height="7.5" rx="1.8"/>',
secrets: '<rect x="4.5" y="10.5" width="15" height="10.5" rx="2.2"/><path d="M8 10.5V7.5a4 4 0 0 1 8 0v3"/><path d="M12 14.5v2.5"/>',
}
/** A topic's mark: a disc in its hue with a white drawn icon. */
export function badge(topic, size = 96, { float = true, id = '', cls = '' } = {}) {
const hue = TOPIC_HUES[topic]
const r = (n) => Math.round(size * n)
const inner = `<span class="mark${float ? ' amb-float' : ''}" style="display:grid;place-items:center;width:${size}px;height:${size}px;border-radius:50%;background:${hue};color:#fff;box-shadow:inset 0 -${r(0.06)}px ${r(0.12)}px rgba(0,0,0,.18)"><svg class="icon" viewBox="0 0 24 24" style="width:${r(0.5)}px;height:${r(0.5)}px;stroke-width:2.2">${ICONS[topic]}</svg></span>`
return `<span class="orb-wrap ${cls}"${id ? ` id="${id}"` : ''} style="display:block;width:${size}px;height:${size}px">${inner}</span>`
}
/** Features in a room or a list. Same mark as everywhere else. */
export const orb = (name, size = 96, opts = {}) => badge(name, size, opts)
// Agents are picked at random on every load (page.js assignAgents), from the
// coding agents Kody's site has logos for.
export const AGENT_POOL = [
'claudecode',
'claude',
'chatgpt',
'codex',
'cursor',
'gemini',
'goose',
'openclaw',
'zed',
'githubcopilot',
'devin',
'amp',
'warp',
'grok',
'grokbot',
'pi',
]
/**
* An agent logo slot. Slots in the same group get distinct agents; slots that
* share a group and an index always show the same agent (so "your" agent stays
* yours from slide to slide).
*/
export function agent(group, index, size = 56, { cls = '' } = {}) {
return `<svg class="agent-logo ${cls}" data-agent-group="${group}" data-agent-index="${index}" style="width:${size}px;height:${size}px"><use href="#ag-claudecode"/></svg>`
}
/** A mouse pointer whose tip rests on the center of its (positioned) parent. */
export function cursor(id) {
return `<svg id="${id}" viewBox="0 0 24 24" style="position:absolute;left:50%;top:50%;width:46px;height:46px;margin:-2px 0 0 -4px;z-index:2;overflow:visible;filter:drop-shadow(0 3px 4px rgba(0,0,0,.3))"><path d="M4 2.5 4 19.5 8.6 15.2 11.6 21.6 14.4 20.3 11.4 14 17.6 14Z" fill="#111" stroke="#fff" stroke-width="1.6" stroke-linejoin="round"/></svg>`
}
export function cfLogo(size = 34) {
return `<svg style="width:${size}px;height:${size}px;color:var(--cf);flex:none"><use href="#ag-cloudflare"/></svg>`
}
export function person(color = '', { id = '', name = '', style = '' } = {}) {
const disc = `<div class="person ${color}"><svg><use href="#g-person"/></svg></div>`
if (!name && !id && !style) return disc
return `<div class="who"${id ? ` id="${id}"` : ''} style="${style}">${disc}${name ? `<div class="who-name">${name}</div>` : ''}</div>`
}
export function house({ id, x, y, agent: logo = '', room = '', roomId = '', extra = '' }) {
return html`<div class="house" id="${id}" style="left:${x}px;top:${y}px">
<svg viewBox="0 0 520 560"><path class="house-shape" d="M20 230 L260 30 L500 230 V540 H20 Z" /></svg>
<div class="house-tag">${logo}</div>
<div class="house-room"${roomId ? ` id="${roomId}"` : ''}>${room}</div>
${extra}
</div>`
}
// ---------------------------------------------------------------- code
const KEYWORDS = new Set([
'import',
'from',
'export',
'default',
'async',
'function',
'await',
'const',
'return',
'let',
'new',
])
/** Minimal JS highlighter. Wrap a span of a line in ⟦…⟧ to mark it highlighted. */
export function highlight(src) {
const out = []
const re =
/(\/\/[^\n]*)|('(?:[^'\\]|\\.)*'|`(?:[^`\\]|\\.)*`|"(?:[^"\\]|\\.)*")|([A-Za-z_$][\w$]*)(?=\s*\()|([A-Za-z_$][\w$]*)|(⟦|⟧)|([\s\S])/g
let m
while ((m = re.exec(src))) {
const [, com, str, fn, word, mark, other] = m
if (com) out.push(`<span class="com">${esc(com)}</span>`)
else if (str) out.push(`<span class="str">${esc(str)}</span>`)
else if (fn) out.push(KEYWORDS.has(fn) ? `<span class="kw">${fn}</span>` : `<span class="fn">${fn}</span>`)
else if (word) out.push(KEYWORDS.has(word) ? `<span class="kw">${word}</span>` : word)
else if (mark) out.push(mark === '⟦' ? '<span class="hl">' : '</span>')
else out.push(esc(other))
}
return out.join('')
}
/** Code card. Each line gets its own span so lines can be revealed or highlighted. */
export function code(src, { id, x, y, w, size } = {}) {
// ⟪ ⟫ stand in for double braces, so a credential placeholder shown on a slide
// never appears as a string in this package's source (Kody's publish checks
// read string literals and would treat it as a real credential use)
src = src.replace(/⟪/g, '{'.repeat(2)).replace(/⟫/g, '}'.repeat(2))
const lines = src.replace(/^\n|\n\s*$/g, '').split('\n')
const body = lines.map((l, i) => `<span class="ln" id="${id}-l${i}">${highlight(l) || ' '}</span>`).join('\n')
return `<div class="code" id="${id}" style="left:${x}px;top:${y}px;${w ? `width:${w}px;` : ''}${size ? `font-size:${size}px;` : ''}">${body}</div>`
}
export function term(lines, { id, x, y, w }) {
const body = lines.map((l, i) => `<div class="term-line" id="${id}-l${i}">${l}</div>`).join('')
return `<div class="term" id="${id}" style="left:${x}px;top:${y}px;width:${w}px"><div class="term-bar"><i></i><i></i><i></i></div>${body}</div>`
}
// ---------------------------------------------------------------- diagrams
/**
* Boxes plus flowing connectors. nodes: { id, x, y, w?, label, sub, cf, plain, cls }.
* edges: [fromId, toId, { from: 'r'|'b'|'l'|'t', to: ..., cls, id }].
* Node heights are estimated so connector endpoints land on box edges.
*/
export function diagram(nodes, edges, { id = 'd' } = {}) {
const byId = Object.fromEntries(nodes.map((n) => [n.id, { w: 360, h: n.sub ? 156 : 108, ...n }]))
const point = (n, side) => {
if (side === 'r') return [n.x + n.w, n.y + n.h / 2]
if (side === 'l') return [n.x, n.y + n.h / 2]
if (side === 'b') return [n.x + n.w / 2, n.y + n.h]
return [n.x + n.w / 2, n.y]
}
const wires = edges
.map(([a, b, o = {}], i) => {
const A = byId[a]
const B = byId[b]
const fromSide = o.from ?? (B.x >= A.x + A.w ? 'r' : B.y > A.y ? 'b' : 't')
const toSide = o.to ?? (fromSide === 'r' ? 'l' : fromSide === 'b' ? 't' : fromSide === 't' ? 'b' : 'r')
const [x1, y1] = point(A, fromSide)
const [x2r, y2r] = point(B, toSide)
// stop short of the box so the arrowhead sits outside it
const gap = 14
const dir = { l: [-1, 0], r: [1, 0], t: [0, -1], b: [0, 1] }[toSide]
const x2 = x2r + dir[0] * gap
const y2 = y2r + dir[1] * gap
let d
if (fromSide === 'r' && toSide === 'l' && Math.abs(y1 - y2) > 2) {
const mx = (x1 + x2) / 2
d = `M${x1 + 10} ${y1} C${mx} ${y1} ${mx} ${y2} ${x2 - 6} ${y2}`
} else if ((fromSide === 'b' || fromSide === 't') && toSide === 'l') {
d = `M${x1} ${y1 + (fromSide === 'b' ? 10 : -10)} C${x1} ${y2} ${x1} ${y2} ${x2 - 6} ${y2}`
} else {
d = `M${x1 + (fromSide === 'r' ? 10 : 0)} ${y1 + (fromSide === 'b' ? 10 : fromSide === 't' ? -10 : 0)} L${x2 - dir[0] * 6} ${y2 - dir[1] * 6}`
}
const ang = { l: 0, r: 180, t: 90, b: 270 }[toSide]
const head = `<path class="wire-head" d="M0 0 L-18 -11 L-18 11 Z" transform="translate(${x2 + dir[0] * -2} ${y2 + dir[1] * -2}) rotate(${ang})" />`
return `<g class="wire-g ${o.cls ?? ''}" id="${o.id ?? `${id}-w${i}`}"><path class="wire" d="${d}" />${head}</g>`
})
.join('')
const boxes = nodes
.map((n) => {
const N = byId[n.id]
const cls = ['node', n.cf ? 'cf' : '', n.plain ? 'plain' : '', n.cls ?? ''].join(' ')
const label = n.cf ? `${cfLogo(36)}<span>${n.label}</span>` : n.label
return `<div class="${cls}" id="${n.id}" style="left:${N.x}px;top:${N.y}px;width:${N.w}px"><div class="label">${label}</div>${n.sub ? `<div class="sub">${n.sub}</div>` : ''}</div>`
})
.join('')
return `<svg class="wires" viewBox="0 0 1920 1080">${wires}</svg>${boxes}`
}
// ---------------------------------------------------------------- wayfinding
export function wayfind(topic, step) {
const steps = ['problem', 'solution', 'under the hood']
const i = { problem: 0, solution: 1, hood: 2 }[step]
return html`<div class="wayfind">
<div class="wayfind-topic">${badge(topic, 52, { float: false })}<span>${TOPIC_NAMES[topic]}</span></div>
${step ? `<div class="steps">${steps.map((s, j) => `<span class="${j === i ? 'on' : ''}">${s}</span>`).join('')}</div>` : ''}
</div>`
}
/** Where the wayfinding badge sits, so color can collapse into it. */
export const WAYFIND_BADGE = [146, 998]