mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-11 10:57:07 +00:00
* feat(plugins): give plugins the agent's sidebar indicator and background flag Plugin UI re-derived agent state from status and attention fields and could not see background work, so it showed agents as done while a shell they left running was still live. Agent snapshots now carry the sidebar's own bucket as indicator/indicatorLabel, computed by the same function the sidebar uses so the two cannot drift. Lifecycle hooks and the agent.open.before request now carry `background`, so a hook can skip a hidden helper agent without a lookup. A hook cannot change it; an omitted value means unchanged, like metadata. `finished` attention still means the turn finished; background work is the indicator's concern. * fix(plugins): keep session-open hooks that omit background typechecking A hook that returns its own object instead of spreading the request has no background field; the result type now treats it as optional, like metadata, matching the runtime where an omitted value means unchanged. * refactor(plugins): give agent snapshots the background work count instead of an indicator * fix(plugins): keep legacy session-open hooks that omit background typechecking
43 lines
1.5 KiB
TypeScript
43 lines
1.5 KiB
TypeScript
import type { PluginAgentSnapshot } from "@getpaseo/plugin";
|
|
import { ScrollView, View } from "react-native";
|
|
import { useAgents, type PluginSidebarViewProps } from "@getpaseo/plugin/client";
|
|
import { AgentRow, Heading } from "./rows";
|
|
export function agentTask(agent: PluginAgentSnapshot) {
|
|
if (agent.attentionReason === "permission") return "Respond";
|
|
if (agent.status === "error") return "Review";
|
|
// An agent whose turn ended still works while shells or monitors it started are live.
|
|
if (
|
|
agent.status === "running" ||
|
|
agent.status === "initializing" ||
|
|
agent.backgroundWork.count > 0
|
|
)
|
|
return "Wait";
|
|
if (agent.requiresAttention) return "Review";
|
|
return "Start";
|
|
}
|
|
function Task({ title, view }: { title: string; view: PluginSidebarViewProps }) {
|
|
const agents = useAgents({
|
|
// Background agents are helpers the user never opens; leave them out like the sidebar does.
|
|
where: (item) => !item.background && agentTask(item) === title,
|
|
orderBy: ["lastActivityAt", "desc"],
|
|
});
|
|
return (
|
|
<View>
|
|
<Heading title={title} view={view} />
|
|
{agents.map((reference) => (
|
|
<AgentRow key={reference.key} reference={reference} view={view} />
|
|
))}
|
|
</View>
|
|
);
|
|
}
|
|
export function Agents(view: PluginSidebarViewProps) {
|
|
return (
|
|
<ScrollView>
|
|
<Task title="Respond" view={view} />
|
|
<Task title="Review" view={view} />
|
|
<Task title="Wait" view={view} />
|
|
<Task title="Start" view={view} />
|
|
</ScrollView>
|
|
);
|
|
}
|