d4faee3a1e
Branch-length batch covering tooling, the model layer, the Web App and the public surfaces. Highlights: - Changelog: a per-release `changelog/<version>/` tree, grouped by the surface each change touches, with a root CHANGELOG.md holding one line per release. - Dev startup: `scripts/dev-prebuild.mjs` serializes the skills+core prebuild behind a lock and keeps `pnpm install` current; `pnpm dev` runs server+web together. - AgentHub 0.3.3 -> 0.4.0: OmniMessage complete payloads carry one opaque `fidelity` object in place of item-level `signature`/`phase`, threaded verbatim through Trace, replay and resume; malformed classification adapted to the new error types. - Model layer: a model is always referenced by an explicit `(provider, model_id)` pair. The provider is never inferred, guessed or defaulted -- both the catalog inference and the unique-match config resolution are gone, and CLI, SDK, server routes and run_subagent all require the complete pair. Catalog gains the Qwen Token Plan, Qwen Pay-As-You-Go and Fireworks AI gateways, plus an expanded OpenRouter group. - Web App: catalog preset sync and per-group speed test on the Models page, positional slash commands, a markdown renderer, skill-library update reminders, and a vertically centred draft page whose upward menus size themselves to the room available. - Public surfaces: restructured READMEs, the penguin.ooo landing site and blog, refreshed benchmark results for both suites, and the demo videos playing on the landing page. Includes the fixes from a full review of the branch: 23 confirmed findings, among them a provider-inference bug that could send one vendor's API key to another vendor's endpoint, and an Escape handler that destroyed the composer's contents unrecoverably. Verified on the branch head: pnpm test (1127 passing, 7 packages), pnpm typecheck and pnpm format:check clean, Playwright e2e 14/14.
107 lines
4.6 KiB
TypeScript
107 lines
4.6 KiB
TypeScript
/**
|
|
* work-summary.ts unit tests: the group header duration is the group's real wall-clock
|
|
* span — earliest segment start → latest segment end — including approval waits and the
|
|
* gaps between steps (the header answers "how long did this group take"; per-item cards
|
|
* keep the fine-grained settled durations). Parallel work counts once by construction.
|
|
* Items missing a start point fall back to direct accumulation on top of the span; the
|
|
* returned startMs is the earliest start stamp of ANY item (settled or not) — the anchor
|
|
* the header ticks from while the group is still running.
|
|
*/
|
|
import { describe, expect, it } from "vitest";
|
|
import type { ChatItem } from "../src/lib/omni/stream-model";
|
|
import { summarizeWork } from "../src/features/chat/work-summary";
|
|
|
|
let nextId = 1;
|
|
|
|
const thinking = (startedAtMs?: number, durationMs?: number): ChatItem => ({
|
|
kind: "thinking",
|
|
id: nextId++,
|
|
thinking: "",
|
|
streaming: false,
|
|
...(startedAtMs !== undefined ? { startedAtMs } : {}),
|
|
...(durationMs !== undefined ? { durationMs } : {}),
|
|
});
|
|
|
|
const tool = (
|
|
o: { argStart?: number; start?: number; approvalAt?: number; durationMs?: number } = {},
|
|
): ChatItem => ({
|
|
kind: "tool_call",
|
|
id: nextId++,
|
|
toolCallId: `call_${nextId}`,
|
|
name: "run_subagent",
|
|
argumentsText: "{}",
|
|
callStreaming: false,
|
|
callComplete: true,
|
|
output: "",
|
|
outputStreaming: false,
|
|
outputComplete: true,
|
|
...(o.argStart !== undefined ? { argStartedAtMs: o.argStart } : {}),
|
|
...(o.start !== undefined ? { callStartedAtMs: o.start } : {}),
|
|
...(o.approvalAt !== undefined ? { approvalAtMs: o.approvalAt } : {}),
|
|
...(o.durationMs !== undefined ? { durationMs: o.durationMs } : {}),
|
|
});
|
|
|
|
describe("summarizeWork", () => {
|
|
it("parallel work counts once: 15-way parallel over 9 minutes reports 9 minutes", () => {
|
|
const nine = 9 * 60_000;
|
|
const items = Array.from({ length: 15 }, () => tool({ start: 0, durationMs: nine }));
|
|
expect(summarizeWork(items)).toEqual({ steps: 15, durationMs: nine, startMs: 0 });
|
|
});
|
|
|
|
it("staggered parallel tools span first start → last end", () => {
|
|
const items = [
|
|
tool({ start: 0, durationMs: 60_000 }),
|
|
tool({ start: 10_000, durationMs: 60_000 }),
|
|
tool({ start: 20_000, durationMs: 70_000 }),
|
|
];
|
|
expect(summarizeWork(items)).toEqual({ steps: 3, durationMs: 90_000, startMs: 0 });
|
|
});
|
|
|
|
it("gaps between sequential steps count toward the span", () => {
|
|
const items = [
|
|
tool({ start: 0, durationMs: 10_000 }),
|
|
tool({ start: 15_000, durationMs: 10_000 }),
|
|
];
|
|
// [0,10s] then a 5s gap then [15s,25s]: the group took 25s of wall time.
|
|
expect(summarizeWork(items)).toEqual({ steps: 2, durationMs: 25_000, startMs: 0 });
|
|
});
|
|
|
|
it("thinking and tools share the same axis; thinking does not count as a step", () => {
|
|
const items = [thinking(0, 5_000), tool({ start: 5_000, durationMs: 10_000 })];
|
|
expect(summarizeWork(items)).toEqual({ steps: 1, durationMs: 15_000, startMs: 0 });
|
|
});
|
|
|
|
it("approval waits are included: the span runs from the call start, not the approval", () => {
|
|
const items = [
|
|
// Call ready at 0, human approves at 100s, execution 100-105s.
|
|
tool({ start: 0, approvalAt: 100_000, durationMs: 5_000 }),
|
|
tool({ start: 102_000, durationMs: 8_000 }),
|
|
];
|
|
// Span 0 → 110s: the 100s spent waiting for the human is part of how long the group took.
|
|
expect(summarizeWork(items)).toEqual({ steps: 2, durationMs: 110_000, startMs: 0 });
|
|
});
|
|
|
|
it("argument generation anchors the start; execution end anchors the end", () => {
|
|
const items = [
|
|
// A: arg generation 0-10s, approval wait 10-100s, execution 100-110s (durationMs = 10s + 10s).
|
|
tool({ argStart: 0, start: 10_000, approvalAt: 100_000, durationMs: 20_000 }),
|
|
// B: execution 110-120s.
|
|
tool({ start: 110_000, durationMs: 10_000 }),
|
|
];
|
|
expect(summarizeWork(items)).toEqual({ steps: 2, durationMs: 120_000, startMs: 0 });
|
|
});
|
|
|
|
it("items missing a start point fall back to direct accumulation; items without a duration only count as steps", () => {
|
|
const items = [tool({ start: 0, durationMs: 10_000 }), tool({ durationMs: 7_000 }), tool()];
|
|
expect(summarizeWork(items)).toEqual({ steps: 3, durationMs: 17_000, startMs: 0 });
|
|
});
|
|
|
|
it("a still-streaming first item already anchors startMs (live tick before anything settles)", () => {
|
|
expect(summarizeWork([thinking(1_000)])).toEqual({ steps: 0, durationMs: 0, startMs: 1_000 });
|
|
});
|
|
|
|
it("no timestamps at all: no startMs key", () => {
|
|
expect(summarizeWork([tool({ durationMs: 7_000 })])).toEqual({ steps: 1, durationMs: 7_000 });
|
|
});
|
|
});
|