feat(cli): include labels and workspace IDs in agent listings (#10076)

Let scripts group a worker’s agents by label and workspace from a single listing.
This commit is contained in:
Mohamed Boudra authored and GitHub committed 2026-11-18 16:01:26 +07:00
1 parent f1f2509c12
commit 017f0d8b0d
2 files changed
+19 -1

No files matched your search

+15 -1
View File
@@ -15,7 +15,8 @@ function createPagingClient() {
cwd: "/tmp/project",
createdAt: `2026-10-0${n}T00:00:00.000Z`,
updatedAt: `2026-10-0${n}T00:00:00.000Z`,
labels: {},
labels: n === 3 ? { bot: "worker", issue: "42" } : {},
workspaceId: n === 3 ? "workspace-3" : undefined,
model: null,
lastUserMessageAt: null,
currentModeId: null,
@@ -124,6 +125,19 @@ describe("buildAgentLsFetchOptions", () => {
});
describe("runLsCommand", () => {
it("includes labels and workspace IDs in JSON listings", async () => {
const result = await listAgents({ daemonTarget, global: true }, async () =>
createPagingClient(),
);
const rows = JSON.parse(render(result, { format: "json" }));
expect(rows).toMatchObject([
{ name: "agent 3", labels: { bot: "worker", issue: "42" }, workspaceId: "workspace-3" },
{ name: "agent 2", labels: {}, workspaceId: null },
{ name: "agent 1", labels: {}, workspaceId: null },
]);
});
it("lists agents on every page, including one updated during the listing", async () => {
const result = await listAgents({ daemonTarget, all: true, global: true }, async () =>
createPagingClient(),
+4
View File
@@ -36,6 +36,8 @@ export interface AgentListItem {
cwd: string;
created: string;
background: boolean;
labels: Record<string, string>;
workspaceId: string | null;
}
/** Helper to get relative time string */
@@ -112,6 +114,8 @@ function toListItem(agent: AgentSnapshotPayload): AgentListItem {
cwd: shortenPath(agent.cwd),
created: relativeTime(agent.createdAt),
background: agent.background === true,
labels: agent.labels,
workspaceId: agent.workspaceId ?? null,
};
}