mirror of
https://github.com/getpaseo/paseo.git
synced 2026-10-21 08:42:39 +00:00
* 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
29 lines
784 B
TypeScript
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;
|
|
}
|