Files
Mohamed Boudra 9c8d775895 Let plugins customize agent creation and observe lifecycle events (#4435)
* feat(plugins): expose agent and workspace lifecycle hooks

* test(plugins): verify lifecycle examples with version requirements

* fix(plugins): publish archive hooks for closed agents

* test(plugins): remove diagnostic catch from lifecycle test

* refactor(plugins): define hook handlers in lifecycle module
2026-09-07 19:17:42 +02:00

29 lines
784 B
TypeScript

import type { AgentPermissionRequest, AgentTimelineItem } from "@getpaseo/protocol/agent-types";
export function latestOutputText(timeline: readonly AgentTimelineItem[]): string {
let output = "";
for (const item of timeline) {
if (item.type === "user_message") {
output = "";
} else if ("text" in item && typeof item.text === "string") {
output += item.text;
} else {
output += JSON.stringify(item) + "\n";
}
}
return output;
}
export function shellCommand(request: AgentPermissionRequest): string | null {
if (!request.input) {
return null;
}
if (typeof request.input.command === "string") {
return request.input.command;
}
if (typeof request.input.cmd === "string") {
return request.input.cmd;
}
return null;
}