An Agent Host that's both Small and Secure? Meet KaozKit

September 15, 2026 | Peter Hoddie, Principal

KaozKit Title

This article isn't about Embedded JavaScript. It's about a new project from a long-time friend of Moddable, Sébastien Burel. Like many entrepreneurial developers, Sébastien has been exploring ways to apply LLMs to his projects. From time to time, Sébastien has generously shared his experiences with the Moddable team. Those insights have helped shape how LLMs are supported in the Moddable SDK – most notably the tool support in our ChatAudioIO API that powers our conversationalAI app.

Introducing KaozKit

Sébastien created KaozKit to integrate any LLM into apps on macOS and, eventually, iOS. There are more than a few solutions to integrating multiple LLMs into apps, but they tend to be big. Really big. They depend on large runtimes like Python and Node.js. These large runtimes take time and space to install, which is tolerated by developers but not users in the real world. Worse, those large runtimes are so powerful that they need to be sandboxed to protect the user's privacy. And you need to be sure that the language interpreter itself is secure, so scripts can't escape the sandbox. Suddenly, deploying a simple, useful LLM-powered app requires a developer to become a sophisticated cybersecurity expert too. Life's too short.

XS for Agents?

Eventually, Sébastien realized that the solution to this problem is the XS JavaScript engine, the core of the Moddable SDK. Because XS is designed for embedded systems where every byte of code and runtime memory matters, XS has a negligible footprint on computers and phones. Command-line tools that incorporate the full XS engine are often just 1 or 2 MB. Even better, there's nothing to sandbox. Because XS provides only the JavaScript language, and not a runtime, the most personal information a script can access is your timezone. And thanks to the simple internal design of XS combined with years of adversarial fuzz testing and security reviews, XS has no known security vulnerabilities, so scripts can't escape the JavaScript sandbox.

Of course, a runtime is necessary for scripts to communicate with LLMs, get data from the web, and access OS services. KaozKit solves this with a lightweight runtime implemented in Swift. A project includes the services it needs, and nothing more. There are no default services, so there is nothing to remove. And because the runtime is implemented in Swift, it's trivial to call Apple's native services as needed.

The result is near magic. A few dozen or so lines of modern JavaScript can weave together multiple LLMs to deliver real solutions for users that tightly integrate with Apple's powerful APIs. Execution is secure and respects user privacy without additional effort. Importantly, adding this to an app doesn't meaningfully increase its footprint.

Agents on Ice

Many uses of an LLM agent take time, often even at regular intervals or in response to an external event. Still, at some point, the process running the agent will terminate. The device might reboot. The user might quit the app. The app might be updated to a newer version. Using a traditional framework, each agent needs to include code to save and restore its full state so it can resume where it left off. As you might expect, this code is difficult to test and consequently tends to be fragile.

KaozKit cleverly avoids most of this problem with a little-known feature of the XS engine: snapshots. A snapshot captures the JavaScript execution state to a file. Every detail of every object is there. When KaozKit needs to pause an agent, it creates a snapshot. To resume, it loads the snapshot. Agents are notified when they are suspended and resumed so they can take necessary steps, but these are often simple because the snapshot does so much. The snapshot is also device independent, so it can even continue running on another device with a compatible version of KaozKit. A little more magic.

Dig Deeper

Sébastien wrote an engaging article on the creation of KaozKit titled, A JavaScript engine built for microcontrollers turns out to be a great runtime for AI agents. It includes architectural details and code snippets that will help you understand how KaozKit works and how it integrates XS. Join the KaosKit discussion on Hacker News.

What's a framework without an app to show what it can do? That's where TyKaoz comes in. TyKaoz is a private AI wiki for macOS that lets you ask questions about your documents and get answers with citations. TyKaoz uses all the key ideas in KaozKit: resident agents, on-device models, and a small enough capability surface that the TyKaoz can promise nothing leaves your Mac unless you decide it should. It launches this autumn.

Lesson 14

KaozKit's use of XS reminds me of a lesson from Eric Raymond's influential work The Cathedral & The Bazaar:

Any tool should be useful in the expected way, but a truly great tool lends itself to uses you never expected.

When Sébastien demoed KaozKit to me, I was surprised at the simplicity and power of what he has created with our XS engine. It's a long way from a JavaScript-powered lightbulb, but no less illuminating. KaozKit achieves an unexpectedly remarkable result by transplanting the heart of the Moddable SDK to a completely different world.