Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,20 @@ export default function piIntercomExtension(pi: ExtensionAPI) {
const entry = { from, message, replyCommand, bodyText };
void (async () => {
if (!ctx.isIdle()) {
// Non-interactive (pipe) mode: cannot interrupt or start new turns.
// Best-effort auto-reply to incoming top-level messages (those without
// `replyTo`) so the sender isn't left hanging; reply messages are skipped.
if (!ctx.hasUI) {
if (client && !message.replyTo) {
try {
await client.send(from.id, {
text: "This agent is running in non-interactive (pipe) mode and cannot respond to messages while working. It will complete its current task and exit.",
replyTo: message.id,
});
} catch { /* best-effort */ }
}
return;
}
const detached = await requestGracefulDetach();
if (detached) {
sendIncomingMessage(entry, "trigger");
Expand Down
9 changes: 9 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@
"license": "MIT",
"type": "module",
"main": "index.ts",
"keywords": ["pi-package"],
"pi": {
"extensions": ["./index.ts"]
},
"peerDependencies": {
"@mariozechner/pi-coding-agent": "*",
"@mariozechner/pi-tui": "*",
"@sinclair/typebox": "*"
},
"dependencies": {
"tsx": "^4.20.0"
}
Expand Down