import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; import { afterAll, beforeAll, beforeEach, describe, expect, it } from "vitest"; import type { OpenClawConfig } from "../config/config.js"; import { updateSessionStore } from "../config/sessions/store.js"; import { buildSubagentList } from "./subagent-list.js"; import {
addSubagentRunForTests,
resetSubagentRegistryForTests,
} from "./subagent-registry.test-helpers.js"; import type { SubagentRunRecord } from "./subagent-registry.types.js"; import { STALE_UNENDED_SUBAGENT_RUN_MS } from "./subagent-run-liveness.js";
describe("buildSubagentList", () => {
it("returns empty active and recent sections when no runs exist", () => { const cfg = {
commands: { text: true },
channels: { whatsapp: { allowFrom: ["*"] } },
} as OpenClawConfig; const list = buildSubagentList({
cfg,
runs: [],
recentMinutes: 30,
taskMaxChars: 110,
});
expect(list.active).toEqual([]);
expect(list.recent).toEqual([]);
expect(list.text).toContain("active subagents:");
expect(list.text).toContain("recent (last 30m):");
});
it("truncates long task text in list lines", () => { const run = {
runId: "run-long-task",
childSessionKey: "agent:main:subagent:long-task",
requesterSessionKey: "agent:main:main",
requesterDisplayKey: "main",
task: "This is a deliberately long task description used to verify that subagent list output keeps the full task text instead of appending ellipsis after a short hard cutoff.",
cleanup: "keep",
createdAt: 1000,
startedAt: 1000,
} satisfies SubagentRunRecord;
addSubagentRunForTests(run); const cfg = {
commands: { text: true },
channels: { whatsapp: { allowFrom: ["*"] } },
} as OpenClawConfig; const list = buildSubagentList({
cfg,
runs: [run],
recentMinutes: 30,
taskMaxChars: 110,
});
expect(list.active[0]?.line).toContain( "This is a deliberately long task description used to verify that subagent list output keeps the full task text",
);
expect(list.active[0]?.line).toContain("...");
expect(list.active[0]?.line).not.toContain("after a short hard cutoff.");
});
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.