an open-source alternative to the dots, bots and muses of the world, run an office of claude code/codex like agents on your laptop, sandboxes or anywhere, uses your existing subscriptions
HTML agent-harnessagent-orchestrationagentsai-agentsautonomous-agentsclaude-codecodexcoding-agentsdesktop-appdeveloper-toolselectrongemini-cliharnessharness-engineeringlocal-firstmemorymulti-agentopencodeorchestrationtypescript
<!doctype html>
<html lang="en">
<head>
<!-- Google tag (gtag.js), Google Ads AW-18388216863. Loaded only when Do Not Track is
off, so it follows the same rule as the PostHog block on this site. -->
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){ dataLayer.push(arguments); }
if (navigator.doNotTrack !== '1') {
var gtagScript = document.createElement('script');
gtagScript.async = true;
gtagScript.src = 'https://www.googletagmanager.com/gtag/js?id=AW-18388216863';
document.head.appendChild(gtagScript);
gtag('js', new Date());
gtag('config', 'AW-18388216863');
}
</script>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>The Newline That Silenced Every Windows Agent — Munder Difflin Blog</title>
<meta name="description" content="A cmd.exe parsing rule from the 1980s meant Windows agents received exactly one line of their multi-line startup protocol — and nothing errored. The anatomy of our worst silent failure, and the fix." />
<link rel="canonical" href="https://munderdiffl.in/blog/the-newline-that-silenced-windows-agents/" />
<link rel="icon" type="image/png" href="https://munderdiffl.in/logo.png" />
<link rel="apple-touch-icon" href="https://munderdiffl.in/logo.png" />
<meta name="theme-color" content="#F5F2E8" />
<!-- Open Graph -->
<meta property="og:site_name" content="Munder Difflin Blog" />
<meta property="og:type" content="article" />
<meta property="og:title" content="The Newline That Silenced Every Windows Agent — Munder Difflin Blog" />
<meta property="og:description" content="A cmd.exe parsing rule from the 1980s meant Windows agents received exactly one line of their multi-line startup protocol — and nothing errored. The anatomy of our worst silent failure, and the fix." />
<meta property="og:url" content="https://munderdiffl.in/blog/the-newline-that-silenced-windows-agents/" />
<meta property="og:image" content="https://munderdiffl.in/blog/assets/media/the-newline-that-silenced-windows-agents/hero.png" />
<meta property="og:image:width" content="1600" />
<meta property="og:image:height" content="904" />
<meta property="og:image:alt" content="Illustration: The Newline That Silenced Every Windows Agent" />
<meta property="og:locale" content="en_US" />
<meta property="article:published_time" content="2026-08-19T00:00:00.000Z" />
<meta property="article:author" content="Chaitanya Giri" />
<meta property="article:tag" content="Internals" />
<meta property="article:tag" content="Windows" />
<meta property="article:tag" content="Debugging" />
<meta property="article:tag" content="node-pty" />
<meta property="article:tag" content="Postmortem" />
<!-- Twitter -->
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:title" content="The Newline That Silenced Every Windows Agent — Munder Difflin Blog" />
<meta name="twitter:description" content="A cmd.exe parsing rule from the 1980s meant Windows agents received exactly one line of their multi-line startup protocol — and nothing errored. The anatomy of our worst silent failure, and the fix." />
<meta name="twitter:image" content="https://munderdiffl.in/blog/assets/media/the-newline-that-silenced-windows-agents/hero.png" />
<meta name="twitter:image:alt" content="Illustration: The Newline That Silenced Every Windows Agent" />
<link rel="alternate" type="application/atom+xml" title="Munder Difflin Blog" href="https://munderdiffl.in/blog/feed.xml" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link href="https://fonts.googleapis.com/css2?family=Fraunces:opsz,[email protected],500;9..144,600;9..144,700;9..144,900&family=Source+Serif+4:opsz,[email protected],400;8..60,600;8..60,700&family=Space+Grotesk:wght@500;600;700&family=JetBrains+Mono:wght@400;600&display=swap" rel="stylesheet" />
<link rel="stylesheet" href="/blog/assets/blog-press.css" />
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "BlogPosting",
"headline": "The Newline That Silenced Every Windows Agent",
"description": "A cmd.exe parsing rule from the 1980s meant Windows agents received exactly one line of their multi-line startup protocol — and nothing errored. The anatomy of our worst silent failure, and the fix.",
"image": ["https://munderdiffl.in/blog/assets/media/the-newline-that-silenced-windows-agents/hero.png"],
"datePublished": "2026-08-19T00:00:00.000Z",
"dateModified": "2026-08-19T00:00:00.000Z",
"author": { "@type": "Person", "name": "Chaitanya Giri" },
"publisher": {
"@type": "Organization",
"name": "Munder Difflin",
"logo": { "@type": "ImageObject", "url": "https://munderdiffl.in/logo.png" }
},
"mainEntityOfPage": { "@type": "WebPage", "@id": "https://munderdiffl.in/blog/the-newline-that-silenced-windows-agents/" },
"keywords": "cmd.exe newline argument truncation, windows spawn npm cmd shim, createprocess cmd.exe, node spawn windows newline, electron child_process windows, npm shim decode",
"articleSection": "Internals",
"inLanguage": "en-US",
"url": "https://munderdiffl.in/blog/the-newline-that-silenced-windows-agents/"
}
</script>
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [
{ "@type": "ListItem", "position": 1, "name": "Home", "item": "https://munderdiffl.in/" },
{ "@type": "ListItem", "position": 2, "name": "Blog", "item": "https://munderdiffl.in/blog/" },
{ "@type": "ListItem", "position": 3, "name": "The Newline That Silenced Every Windows Agent", "item": "https://munderdiffl.in/blog/the-newline-that-silenced-windows-agents/" }
]
}
</script>
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "FAQPage",
"mainEntity": [
{ "@type": "Question", "name": "Why did agent messaging fail only on Windows?", "acceptedAnswer": { "@type": "Answer", "text": "On macOS and Linux, the multi-line hive protocol passes to the engine binary as one argv entry, newlines intact. On Windows, npm installs CLIs as .cmd shims, which can't go directly to CreateProcess — so the spawn ran through cmd.exe, and cmd.exe cuts an argument at its first newline. The agent got line one of its job description and nothing else." } },
{ "@type": "Question", "name": "Why didn't anything error?", "acceptedAnswer": { "@type": "Answer", "text": "Because nothing failed by any definition the code knew. The process spawned, the engine started, the agent answered prompts. The only casualty was the text after the first newline — which happened to contain everything about inboxes, outboxes, and memory. Truncation isn't an error; it's just less." } },
{ "@type": "Question", "name": "How was it fixed?", "acceptedAnswer": { "@type": "Answer", "text": "The spawner now reads the .cmd shim, extracts the real interpreter and script it points at, and launches that directly with an argv array — no cmd.exe in the path. A follow-up handled npm's interpreter-less shims for compiled binaries like OpenCode's. Anything undecodable falls back to the old path, but now logs what it couldn't decode." } }
]
}
</script>
<script>
// Anonymous blog analytics (PostHog) — same posture as the main site and the
// app's TELEMETRY.md: public write-only token ('' = inert), anonymous-only
// (person_profiles 'never'), no autocapture/recording, DNT respected.
(function () {
var PH_KEY = 'phc_qJzsokwcbtTGHemnvywR3nSqivNNgMjHeNVEWkZNydFB';
if (!PH_KEY || navigator.doNotTrack === '1') return;
var s = document.createElement('script');
s.async = true;
s.src = 'https://us-assets.i.posthog.com/static/array.js';
s.onload = function () {
if (!window.posthog) return;
window.posthog.init(PH_KEY, {
api_host: 'https://us.i.posthog.com',
person_profiles: 'never',
autocapture: false,
before_send: function (event) {
// PostHog fills $ip from the connection unless the event carries one.
// Null it here and disable the GeoIP lookup so no IP, city, postal
// code or lat/long is ever derived or stored for this page view.
if (event && event.properties) {
event.properties.$ip = null;
event.properties.$geoip_disable = true;
}
return event;
},
disable_session_recording: true,
respect_dnt: true
});
};
document.head.appendChild(s);
})();
</script>
</head>
<body class="theme-press">
<a class="skip-link" href="#main">Skip to content</a>
<nav id="nav">
<a class="brand" href="https://munderdiffl.in" aria-label="Munder Difflin home">
<img class="brand-logo" src="https://munderdiffl.in/logo.png" width="1318" height="840" alt="Munder Difflin, Inc. — Multi-Agent Harness" />
</a>
<span class="spacer"></span>
<div class="links">
<a href="/blog/">Latest</a>
<a href="/blog/topics/">Topics</a>
<a href="/blog/about/">About</a>
<a href="https://munderdiffl.in">↗ Product</a>
</div>
<div class="nav-actions">
<a class="btn sm" href="https://munderdiffl.in/blog/feed.xml" aria-label="RSS feed">⤵ RSS</a>
<a class="btn sm primary" href="https://munderdiffl.in/#install">⤓ Download</a>
</div>
</nav>
<main id="main">
<article class="t-internals">
<header class="post-head wrap">
<nav class="crumbs" aria-label="Breadcrumb">
<a href="/blog/">Blog</a>
<span>/</span>
<a href="/blog/topics/internals/">Internals</a>
</nav>
<h1>The Newline That Silenced Every Windows Agent</h1>
<p class="dek">A cmd.exe parsing rule from the 1980s meant Windows agents received exactly one line of their multi-line startup protocol — and nothing errored. The anatomy of our worst silent failure, and the fix.</p>
<div class="byline">
<span class="av" aria-hidden="true">CG</span>
<strong>Chaitanya Giri</strong>
<span class="dot" aria-hidden="true">·</span>
<time datetime="2026-08-19">Aug 19, 2026</time>
<span class="dot" aria-hidden="true">·</span>
<span>4 min read</span>
<span class="tag kind">Internals</span>
</div>
</header>
<div class="hero-wrap wrap"><figure class="fig fig-hero"><img src="/blog/assets/media/the-newline-that-silenced-windows-agents/hero.png" alt="Illustration: The Newline That Silenced Every Windows Agent" loading="lazy" decoding="async" /></figure></div>
<div class="post-wrap wrap">
<div class="prose">
<div class="callout tldr"><span class="ic">TL;DR</span><p>Windows agents booted, rendered, and
answered prompts — while never sending or receiving a single message. The cause: npm installs
CLIs as <code>.cmd</code> shims, <code>.cmd</code> files must run through <code>cmd.exe</code>,
and <strong>cmd.exe truncates an argument at its first newline</strong>. Our startup protocol is
multi-line. Every Windows agent got line one and lost the rest. Here's the full anatomy, because
this bug class is hiding in more codebases than ours.</p></div>
<p>A huge share of the people who install Munder Difflin do it on Windows. For an uncomfortably
long time, the core of the product —
<a href="/blog/can-claude-code-agents-talk-to-each-other/">agents talking to each other</a> — did not work
for those users, and neither they nor we could tell. This is the autopsy.</p>
<h2 id="the-setup" tabindex="-1">The setup <a class="anchor" href="#the-setup" aria-hidden="true">#</a></h2>
<p>When Munder Difflin spawns an agent, it passes the <strong>hive protocol</strong> as a command-line argument
to the engine CLI: a multi-line block that names the agent, points at its <code>inbox/</code> and
<code>outbox/</code> folders, explains the <a href="/blog/atomic-file-mailboxes-for-agents/">file-mailbox rules</a>,
and tells it where its memory lives. One argument, many lines. On POSIX systems this is
completely unremarkable — argv entries can contain any byte except NUL, and newlines ride along
happily.</p>
<h2 id="the-three-layer-trap" tabindex="-1">The three-layer trap <a class="anchor" href="#the-three-layer-trap" aria-hidden="true">#</a></h2>
<p><strong>Layer one: npm shims.</strong> On Windows, <code>npm install -g</code> doesn’t put a real executable on your
PATH. It writes a <code>.cmd</code> batch shim that locates node and runs the actual JS entry point.</p>
<p><strong>Layer two: CreateProcess.</strong> A <code>.cmd</code> is not a PE executable, so it can’t be the target of
<code>CreateProcess</code> directly. Node’s <code>child_process</code> (and everything built on it) handles this by
silently rewriting your spawn into <code>cmd.exe /d /s /c "your command here"</code>.</p>
<p><strong>Layer three: cmd.exe.</strong> And cmd.exe, parsing that command string with rules essentially
unchanged since DOS, <strong>stops at the first newline</strong>. Everything after it isn’t escaped or
mangled — it’s simply gone.</p>
<figure class="fig fig-inline"><img src="/blog/assets/media/the-newline-that-silenced-windows-agents/note-1.png" alt="Hand-drawn sketch from “The Newline That Silenced Every Windows Agent”" loading="lazy" decoding="async" /><figcaption>Three layers deep: npm's .cmd shim forces cmd.exe into the spawn path, and cmd.exe stops reading at the first newline.</figcaption></figure>
<p>Stack the layers and you get: a multi-line protocol enters the spawn, and a one-line protocol
arrives at the agent. Deterministically. On every Windows machine. With zero errors.</p>
<h2 id="why-it-was-invisible" tabindex="-1">Why it was invisible <a class="anchor" href="#why-it-was-invisible" aria-hidden="true">#</a></h2>
<p>Here’s what made this bug expensive: <strong>every observable signal said healthy.</strong></p>
<p>The process spawned — exit code irrelevant, it’s a long-running CLI. The agent’s terminal
rendered in the app and responded to typing. The engine received <em>a</em> prompt (line one:
something like “You are an autonomous agent in a collaborating hive”), which is coherent enough
that the agent behaved plausibly. It just never mentioned inboxes, because it had never heard
of them.</p>
<p>From the floor’s perspective, Windows agents were simply… quiet. And “the agent didn’t happen
to send mail” is indistinguishable from “the agent cannot send mail” unless you go looking. No
log line existed to catch, because truncation isn’t a failure — cmd.exe was working as
documented. The documentation is just from 1987.</p>
<figure class="fig fig-inline"><img src="/blog/assets/media/the-newline-that-silenced-windows-agents/note-2.png" alt="Hand-drawn sketch from “The Newline That Silenced Every Windows Agent”" loading="lazy" decoding="async" /><figcaption>Every signal read healthy: process up, terminal live, prompts answered. The agent just never knew it had a mailbox.</figcaption></figure>
<h2 id="the-fix-refuse-the-middleman" tabindex="-1">The fix: refuse the middleman <a class="anchor" href="#the-fix-refuse-the-middleman" aria-hidden="true">#</a></h2>
<p>The fix is conceptually simple: <strong>never let a prompt-carrying spawn touch cmd.exe.</strong> The spawner
now opens the <code>.cmd</code> shim, decodes what it actually points at — npm shims are formulaic — and
launches the real interpreter directly: <code>node.exe C:\...\cli.js --args</code>, passed as an argv
array, which goes through <code>CreateProcess</code> with the multi-line argument intact.</p>
<p>Then reality added a second chapter, as it does. OpenCode’s npm package ships a <em>compiled
binary</em>, so npm writes an interpreter-less shim the decoder didn’t model — it returned null for
every Windows OpenCode install and fell back to the truncating path. That’s the
<a href="/blog/launching-munder-difflin-v0-4-4/">0.4.4</a> follow-up: direct-executable shims are handled,
and — the real lesson — <strong>the fallback is no longer silent.</strong> If the decoder meets a shim it
can’t parse, it logs exactly what it couldn’t decode. The next variant of this bug will
announce itself.</p>
<h2 id="the-takeaways-we-actually-wrote-down" tabindex="-1">The takeaways we actually wrote down <a class="anchor" href="#the-takeaways-we-actually-wrote-down" aria-hidden="true">#</a></h2>
<ul>
<li><strong>A fallback that doesn’t log is a bug with a delay timer.</strong> The first fix’s silent fallback
is why the OpenCode variant survived a release.</li>
<li><strong>“Nothing errored” is a claim, not evidence.</strong> The failure mode of dropping <em>part</em> of an
input is nastier than crashing, because every health check you own passes. Our
<a href="/blog/why-our-auto-update-never-ran/">auto-update postmortem</a> is the same lesson wearing a
different coat.</li>
<li><strong>Test the platform’s spawn path, not your code’s intent.</strong> Our protocol handling was
correct on every platform. The three layers underneath it were not ours — and the user
doesn’t care whose layer it was.</li>
</ul>
<p>If you’re building anything that passes structured prompts to CLIs on Windows —
<a href="/blog/the-hook-shim-pattern/">hooks</a>, harnesses, wrappers — go check what your spawns do when
the target is a <code>.cmd</code>. We’ll wait. It’s probably ten minutes and one very bad surprise.</p>
<section class="faq" aria-label="Frequently asked questions">
<h2 id="faq">FAQ</h2>
<div class="qa">
<p class="q">Why did agent messaging fail only on Windows?</p>
<p class="a">On macOS and Linux, the multi-line hive protocol passes to the engine binary as one argv entry, newlines intact. On Windows, npm installs CLIs as .cmd shims, which can't go directly to CreateProcess — so the spawn ran through cmd.exe, and cmd.exe cuts an argument at its first newline. The agent got line one of its job description and nothing else.</p>
</div>
<div class="qa">
<p class="q">Why didn't anything error?</p>
<p class="a">Because nothing failed by any definition the code knew. The process spawned, the engine started, the agent answered prompts. The only casualty was the text after the first newline — which happened to contain everything about inboxes, outboxes, and memory. Truncation isn't an error; it's just less.</p>
</div>
<div class="qa">
<p class="q">How was it fixed?</p>
<p class="a">The spawner now reads the .cmd shim, extracts the real interpreter and script it points at, and launches that directly with an argv array — no cmd.exe in the path. A follow-up handled npm's interpreter-less shims for compiled binaries like OpenCode's. Anything undecodable falls back to the old path, but now logs what it couldn't decode.</p>
</div>
</section>
<hr />
<div class="share">
<span class="lbl">Tags</span>
<a class="tag" href="/blog/tags/internals/">Internals</a><a class="tag" href="/blog/tags/windows/">Windows</a><a class="tag" href="/blog/tags/debugging/">Debugging</a><a class="tag" href="/blog/tags/node-pty/">node-pty</a><a class="tag" href="/blog/tags/postmortem/">Postmortem</a>
</div>
</div>
<aside class="toc-rail" aria-label="Table of contents">
<div class="tt">On this page</div>
<ol>
<li class="lvl-2"><a href="#the-setup">The setup</a></li><li class="lvl-2"><a href="#the-three-layer-trap">The three-layer trap</a></li><li class="lvl-2"><a href="#why-it-was-invisible">Why it was invisible</a></li><li class="lvl-2"><a href="#the-fix-refuse-the-middleman">The fix: refuse the middleman</a></li><li class="lvl-2"><a href="#the-takeaways-we-actually-wrote-down">The takeaways we actually wrote down</a></li>
</ol>
</aside>
</div>
<footer class="post-foot wrap"><div class="prevnext">
<a class="pn prev" href="/blog/turn-feedback-into-a-backlog-with-agents/"><span class="k">← Older</span><span class="t">Turn a Firehose of Feedback into a Backlog with Agents</span></a>
<a class="pn next" href="/blog/seven-releases-in-eight-days/"><span class="k">Newer →</span><span class="t">Seven Releases in Eight Days: 0.3.8 → 0.4.4</span></a>
</div>
<section class="related">
<h2>Related in Internals</h2>
<div class="post-grid">
<article class="card t-internals">
<a class="thumb t-internals" href="/blog/the-spend-counter-that-went-back-to-zero/" aria-hidden="true" tabindex="-1"><img src="/blog/assets/media/the-spend-counter-that-went-back-to-zero/hero.png" alt="" loading="lazy" decoding="async" /></a>
<div class="body">
<div class="meta">
<time datetime="2026-08-22">Aug 22, 2026</time>
<span class="dot" aria-hidden="true"></span>
<span>10 min</span>
</div>
<h3><a href="/blog/the-spend-counter-that-went-back-to-zero/">The Spend Counter That Went Back to Zero</a></h3>
<p class="dek">Our own floor was under reporting what it cost by 59 percent. The counter was cumulative since process start, the app restarts, and the session id stayed the same. Here is how a monotonic invariant let us recover the real number from an append-only log.</p>
<div class="foot">
<span class="tag kind">Internals</span>
<a class="more" href="/blog/the-spend-counter-that-went-back-to-zero/" aria-label="Read: The Spend Counter That Went Back to Zero">Read →</a>
</div>
</div>
</article>
<article class="card t-internals">
<a class="thumb t-internals" href="/blog/why-our-auto-update-never-ran/" aria-hidden="true" tabindex="-1"><img src="/blog/assets/media/why-our-auto-update-never-ran/hero.png" alt="" loading="lazy" decoding="async" /></a>
<div class="body">
<div class="meta">
<time datetime="2026-08-08">Aug 8, 2026</time>
<span class="dot" aria-hidden="true"></span>
<span>5 min</span>
</div>
<h3><a href="/blog/why-our-auto-update-never-ran/">Our Auto-Update Never Ran Once: A CommonJS Export That Vanished Into an ESM Namespace</a></h3>
<p class="dek">Munder Difflin shipped auto-update in v0.3.4 and it silently never worked in a single packaged build. The cause was one destructuring assignment across the CommonJS/ESM boundary — and a catch block that threw the evidence away. Here's how we found it, and what v0.3.7 changes.</p>
<div class="foot">
<span class="tag kind">Internals</span>
<a class="more" href="/blog/why-our-auto-update-never-ran/" aria-label="Read: Our Auto-Update Never Ran Once: A CommonJS Export That Vanished Into an ESM Namespace">Read →</a>
</div>
</div>
</article>
<article class="card t-internals">
<a class="thumb t-internals" href="/blog/hire-manifest-untrusted-input/" aria-hidden="true" tabindex="-1"><img src="/blog/assets/media/hire-manifest-untrusted-input/hero.png" alt="" loading="lazy" decoding="async" /></a>
<div class="body">
<div class="meta">
<time datetime="2026-06-15">Jun 15, 2026</time>
<span class="dot" aria-hidden="true"></span>
<span>12 min</span>
</div>
<h3><a href="/blog/hire-manifest-untrusted-input/">Treating a Hire Manifest as Untrusted Input</a></h3>
<p class="dek">A shareable agent-config manifest is attacker input. How Munder Difflin's import pipeline stays inert: no auto-spawn, default-deny flags, and an SSRF-safe bounded fetch.</p>
<div class="foot">
<span class="tag kind">Internals</span>
<a class="more" href="/blog/hire-manifest-untrusted-input/" aria-label="Read: Treating a Hire Manifest as Untrusted Input">Read →</a>
</div>
</div>
</article>
</div>
</section>
</footer>
</article>
</main>
<footer class="site-foot">
<div class="wrap">
<div class="foot-top">
<a class="foot-brand brand" href="https://munderdiffl.in" aria-label="Munder Difflin home">
<img class="brand-logo" src="https://munderdiffl.in/logo.png" width="1318" height="840" alt="Munder Difflin, Inc. — Multi-Agent Harness" />
</a>
<div class="foot-links">
<a href="/blog/">Latest</a>
<a href="/blog/topics/">Topics</a>
<a href="/blog/about/">About</a>
<a href="https://munderdiffl.in/blog/feed.xml">RSS</a>
<a href="https://github.com/chaitanyagiri/munder-difflin">GitHub</a>
<a href="https://munderdiffl.in">munderdiffl.in ↗</a>
</div>
</div>
<div class="foot-meta">
© 2026 Munder Difflin · Local-first · MIT-licensed ·
Built on <a href="https://munderdiffl.in">Electron, React, Pixi.js, xterm.js & node-pty</a>.
Run an office of agents while you sleep.
</div>
</div>
</footer>
<script>
// sticky-nav border on scroll
(function () {
var nav = document.getElementById('nav');
if (!nav) return;
var onScroll = function () { nav.classList.toggle('scrolled', window.scrollY > 8); };
onScroll(); window.addEventListener('scroll', onScroll, { passive: true });
})();
// YouTube click-to-load: thumbnail button → youtube-nocookie iframe
(function () {
document.addEventListener('click', function (e) {
var btn = e.target.closest('.yt-load');
if (!btn) return;
var box = btn.closest('.yt');
var id = box && box.getAttribute('data-yt');
// Only an 11 character YouTube video id may reach the iframe URL.
if (!id || !/^[A-Za-z0-9_-]{11}$/.test(id)) return;
var frame = document.createElement('iframe');
frame.src = 'https://www.youtube-nocookie.com/embed/' + encodeURIComponent(id) + '?autoplay=1';
frame.title = box.getAttribute('data-title') || 'YouTube video';
frame.allow = 'accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share';
frame.setAttribute('allowfullscreen', '');
box.replaceChildren(frame);
});
})();
</script>
</body>
</html>