You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
65 example extensions for iosm-cli demonstrating the full extension API: custom tools, lifecycle hooks, commands, UI components, and provider integrations.
Quick Start
# Load an extension via CLI flag
iosm -e examples/extensions/permission-gate.ts
# Or copy to extensions directory for auto-discovery
cp permission-gate.ts ~/.iosm/agent/extensions/
# Reload at runtime
/reload
Extension Template
Every extension exports a default function receiving the ExtensionAPI:
import{StringEnum}from"@mariozechner/pi-ai";// ✅ Works everywhere
action: StringEnum(["list","add","remove"]asconst)// ❌ Breaks with Google API
action: Type.Union([Type.Literal("list"),Type.Literal("add")])
Extension API Reference
Registration
Method
Description
pi.registerTool(def)
Register a custom tool
pi.registerCommand(name, handler)
Register a slash command
pi.on(event, handler)
Subscribe to lifecycle event
pi.exec(cmd, args)
Execute a shell command
pi.sendUserMessage(text)
Send a user message programmatically
Lifecycle Hooks
Hook
When
Can Block
session_start
Session begins or is resumed
No
session_switch
Active session changes
No
session_fork
Session is forked
No
session_tree
Tree navigation occurs
No
session_before_fork
Before fork is executed
No
before_agent_start
Before model is called
No (can modify prompt)
tool_call
Before tool executes
Yes ({ block: true })
tool_result
After tool returns
No
turn_start
Conversation turn begins
No
turn_end
Conversation turn ends
No
agent_start
Agent begins processing
No
agent_end
Agent finishes
No
model_select
Model is changed
No
input
User input received
No (can transform)
UI Context Methods
Method
Description
ctx.ui.confirm(title, message)
Show yes/no dialog
ctx.ui.select(title, options)
Show selection dialog
ctx.ui.notify(message, level)
Show notification
ctx.ui.setStatus(text, level)
Set status bar text
ctx.ui.setFooter(factory)
Custom footer renderer
ctx.ui.setHeader(factory)
Custom header renderer
ctx.ui.setWidget(placement, component)
Show widget above/below editor
ctx.ui.setEditorText(text)
Set editor content
ctx.ui.setEditorComponent(factory)
Replace editor with custom component
ctx.ui.custom(factory)
Show full-screen custom UI
ctx.hasUI
Check if interactive mode (for non-interactive safety)
Writing Your Own Extension
Create a .ts file with the extension template
Place it in ~/.iosm/agent/extensions/ (global) or .iosm/extensions/ (project)