Session Plugins
Plugins extend PTY sessions without modifying the daemon binary. They work by transformingcwd and shell before the daemon sees them.
Plugin Trait
Every plugin implements the same interface:Available Plugins
worktree — Git Isolation
Creates an isolated git worktree so the session operates on a separate branch. Other sessions/workers can run in parallel without file conflicts.git worktree add -B niia-wt-feat-auth /tmp/niia-worktree-feat-auth HEAD- Symlink large directories (node_modules, target, .venv) to save disk
- Set session
cwdto worktree path
- No uncommitted changes → auto-cleanup (worktree remove + branch delete)
- Uncommitted changes → preserve worktree, print path
CreateSession { cwd: "/tmp/niia-worktree-feat-auth" }
Daemon doesn’t know it’s a worktree.
sandbox — OS-Level Isolation
Wraps the shell process with platform-specific sandbox restrictions.sandbox-exec
- Network: denied
- File write: denied except cwd + /tmp
- File read: allowed
CreateSession { shell: "sandbox-exec -p '...' /bin/zsh" }
Daemon doesn’t know it’s sandboxed.
worktree + sandbox (composition)
- worktree runs first → changes
cwdto/tmp/niia-worktree-feat-x - sandbox runs second → reads
cwd, allows writes only there
scratchpad — Shared Knowledge Directory
Creates a shared directory accessible by all workers in a pipeline.{worktree}/scratchpad/ that all sessions can read and write.
Workers share findings, decisions, and intermediate results here.
env — Environment Injection
Injects environment variables into the session.- API key isolation per session
- Proxy configuration per worker
- Model selection via environment
timeout — Session Lifetime
Limits how long a session can run.Plugin Development
Plugins implement theSessionPlugin interface.
A plugin only needs to:
- Optionally modify
cwd(change working directory) - Optionally modify
shell(wrap shell command) - Optionally modify
env(inject variables) - Optionally run cleanup after session
cwd and shell fields.
No daemon modification is needed to add new plugins.
connector.json Integration
Plugins map directly to connector.jsonsession fields:
niia run connector.json reads these fields and builds the plugin chain automatically.