Handler Overview
TaskDaemon handlers are containerized programs that process tasks. They communicate via a simple JSON protocol over stdin/stdout, making it possible to write handlers in any programming language.How Handlers Work
- TaskDaemon sends a JSON task to the handler’s stdin
- Handler processes the task
- Handler writes a JSON result to stdout
- TaskDaemon captures the result
Protocol
Input (stdin)
Output (stdout)
Success:Official SDKs
We provide SDKs that handle the protocol for you:Python
pip install taskdaemonNode.js
npm install @taskdaemon/handlerGo
go get github.com/taskdaemon/handler-goRust
cargo add taskdaemon-handlerC++
Header-only library
Java
Maven/Gradle package
C#
NuGet package
Raw Protocol
Any language
Handler Requirements
1
Read JSON from stdin
Handler must continuously read line-delimited JSON from stdin
2
Process the task
Parse the task data and perform the work
3
Write JSON to stdout
Output a single JSON line with status and result
4
Flush output
Ensure stdout is flushed after each response
Print statements are safe. TaskDaemon automatically skips non-JSON lines in handler output, so
print() statements for debugging won’t break the protocol. However, for production use, logging to stderr is recommended.Logging to stderr
For production handlers, log to stderr instead of stdout to keep logs separate from the JSON protocol:- Python
- Node.js
- Go
- Rust
- Java
- C#
- C++
Minimal Example
Here’s the simplest possible handler in Python:Dockerfile
Handlers must be packaged as Docker images. Make sure to install the SDK from the package manager:Configuration
Register handlers inhandlers.toml: