// Two helpers that used to live in page folders: how long a run took, and the // paths one terminal is reached at. import assert from "node:assert/strict"; import { test } from "node:test"; import { durationLabel } from "../src/util.ts"; import { termPaths } from "../src/agent/terminal/term-paths.ts"; test("durationLabel names seconds, minutes and hours", () => { assert.equal(durationLabel(0, 45), "45s"); assert.equal(durationLabel(0, 192), "3m 12s"); assert.equal(durationLabel(0, 3840), "1h 4m"); }); test("durationLabel reads a clock that ran backwards as 0s", () => { assert.equal(durationLabel(100, 90), "0s"); }); test("an agent's terminal has a turn-state stream, a subagent's has none", () => { const agent = termPaths("iris"); assert.equal(agent.page, "/agents/iris/terminal"); assert.equal(agent.state, "/api/agents/iris/state/stream"); const sub = termPaths("iris", "t 1"); assert.equal(sub.label, "iris/t 1"); assert.equal(sub.page, "/agents/iris/subagents/t%201/terminal"); assert.equal(sub.state, null); });