mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-01 22:23:07 +00:00
* fix(cli): resolve agent archive through the daemon, not a listing page `paseo agent archive` resolved its argument against a single `fetch_agents` response. That listing is capped at 200 entries per page and the command never pages, so an agent past the cap could not be archived: the CLI reported AGENT_NOT_FOUND before any request reached the daemon, while `paseo agent ls --global` and `paseo agent inspect` still returned it. Resolve the argument with `fetch_agent` instead, the same authoritative daemon lookup `agent inspect`, `agent stop` and `agent delete` use. The already-archived and running checks read the returned record unchanged. Closes #4909 * fix(cli): only report a missing agent as AGENT_NOT_FOUND in archive The lookup rejection was mapped to AGENT_NOT_FOUND whatever it said, so an ambiguous identifier, a timeout or a daemon handler failure all read as a missing agent. The daemon reports an unknown identifier only as an error string, so recognize that one rejection by its text and rethrow anything else unchanged. --------- Co-authored-by: L4XB <lukas.buck@e-mail.de> Co-authored-by: paseo-bot[bot] <266920839+paseo-bot[bot]@users.noreply.github.com> Co-authored-by: HTeo <hteo1337@gmail.com>
34 lines
1.2 KiB
TypeScript
34 lines
1.2 KiB
TypeScript
import type { AgentSnapshotPayload } from "@getpaseo/protocol/messages";
|
|
import type { connectToDaemon } from "./client.js";
|
|
|
|
type FetchAgentsOptions = NonNullable<
|
|
Parameters<Awaited<ReturnType<typeof connectToDaemon>>["fetchAgents"]>[0]
|
|
>;
|
|
|
|
interface AgentDirectoryClient {
|
|
fetchAgents(options?: FetchAgentsOptions): Promise<{
|
|
entries: { agent: AgentSnapshotPayload }[];
|
|
pageInfo: { nextCursor: string | null };
|
|
}>;
|
|
}
|
|
|
|
/** Read the complete directory without agents moving between pages as they update. */
|
|
export async function fetchAllAgents(
|
|
client: AgentDirectoryClient,
|
|
options: Omit<FetchAgentsOptions, "page" | "sort" | "subscribe"> = {},
|
|
): Promise<AgentSnapshotPayload[]> {
|
|
const agents: AgentSnapshotPayload[] = [];
|
|
let cursor: string | undefined;
|
|
// createdAt never changes, so agents cannot move past the cursor while the pages are read.
|
|
do {
|
|
const payload = await client.fetchAgents({
|
|
...options,
|
|
sort: [{ key: "created_at", direction: "desc" }],
|
|
page: { limit: 200, ...(cursor ? { cursor } : {}) },
|
|
});
|
|
agents.push(...payload.entries.map((entry) => entry.agent));
|
|
cursor = payload.pageInfo.nextCursor ?? undefined;
|
|
} while (cursor);
|
|
return agents;
|
|
}
|