Changelog, dev startup, README, AgentHub 0.4.0, model catalog, and landing site (#7)
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.
This commit is contained in:
@@ -22,6 +22,31 @@ const EXCERPT_MAX_CHARS = 2000;
|
||||
/** Cap on title length (fallback truncation for when the model occasionally ignores the constraint). */
|
||||
const TITLE_MAX_CHARS = 30;
|
||||
|
||||
/**
|
||||
* Special message markers that must never leak into a title. These are machine-inserted
|
||||
* XML-ish blocks (a skill invocation wraps the body in `<use_skills>…</use_skills>`, a
|
||||
* subagent handoff / scheduled task prepend their own blocks) — meaningful to the runtime,
|
||||
* noise in a title. The list is a fixed allowlist so ordinary angle-bracket text (e.g. a
|
||||
* user pasting `<div>`) is left untouched.
|
||||
*/
|
||||
const MARKER_TAGS = ["use_skills", "handoff_from", "scheduled_task"];
|
||||
|
||||
/**
|
||||
* Strips machine-inserted marker blocks (see MARKER_TAGS) from conversation text so titles are
|
||||
* built from the human-meaningful body only — both the material sent to the model and the
|
||||
* fallback derived from the raw first message. Removes the paired `<tag>…</tag>` block (any
|
||||
* inner content, across lines) and any stray unpaired `<tag>` / `</tag>` left behind.
|
||||
*/
|
||||
export function stripConversationMarkers(text: string): string {
|
||||
let out = text;
|
||||
for (const tag of MARKER_TAGS) {
|
||||
out = out
|
||||
.replace(new RegExp(`<${tag}>[\\s\\S]*?</${tag}>`, "g"), "")
|
||||
.replace(new RegExp(`</?${tag}>`, "g"), "");
|
||||
}
|
||||
return out.trim();
|
||||
}
|
||||
|
||||
export interface SessionTitleResult {
|
||||
/** The sanitized title; null when material is insufficient, the request fails, or the output is empty. */
|
||||
title: string | null;
|
||||
@@ -44,6 +69,7 @@ export function buildTitlePrompt(userExcerpt: string, assistantExcerpt: string):
|
||||
"- Write the title in the SAME language the user is using.",
|
||||
"- Keep it short: at most 6 words, or ~16 characters for CJK.",
|
||||
"- Output ONLY the title text — no quotes, no trailing punctuation, no explanation.",
|
||||
"- Answer immediately — do not think aloud or produce chain-of-thought.",
|
||||
"",
|
||||
"[User]",
|
||||
clip(userExcerpt),
|
||||
@@ -51,12 +77,15 @@ export function buildTitlePrompt(userExcerpt: string, assistantExcerpt: string):
|
||||
if (assistantExcerpt.trim()) {
|
||||
lines.push("", "[Assistant]", clip(assistantExcerpt));
|
||||
}
|
||||
// The trailing empty think block makes many reasoning models treat their thinking phase
|
||||
// as already closed, so the one-off request spends its budget on the title itself.
|
||||
lines.push("", "<think></think>");
|
||||
return lines.join("\n");
|
||||
}
|
||||
|
||||
/** Sanitizes model output into a title: strips leading/trailing quotes/brackets and trailing punctuation (until stable), collapses whitespace, and truncates if too long; returns null for an empty result. */
|
||||
/** Sanitizes model output into a title: strips any leaked marker blocks and leading/trailing quotes/brackets and trailing punctuation (until stable), collapses whitespace, and truncates if too long; returns null for an empty result. */
|
||||
export function sanitizeTitle(raw: string): string | null {
|
||||
let t = raw.replace(/\s+/g, " ").trim();
|
||||
let t = stripConversationMarkers(raw).replace(/\s+/g, " ").trim();
|
||||
// Stripping quotes can expose more punctuation underneath (or vice versa), so strip repeatedly until stable.
|
||||
for (let prev = ""; prev !== t;) {
|
||||
prev = t;
|
||||
@@ -81,10 +110,14 @@ export async function generateTitleWithLLM(
|
||||
llm: LLMInterface,
|
||||
args: { userText: string; assistantText: string; signal?: AbortSignal },
|
||||
): Promise<SessionTitleResult> {
|
||||
if (!args.userText.trim()) {
|
||||
// Strip machine markers before the model ever sees the material, so a skill-invocation
|
||||
// block (or handoff / scheduled-task marker) can't bleed into the generated title.
|
||||
const userMaterial = stripConversationMarkers(args.userText);
|
||||
const assistantMaterial = stripConversationMarkers(args.assistantText);
|
||||
if (!userMaterial.trim()) {
|
||||
return { title: null, usage: null };
|
||||
}
|
||||
const prompt = buildTitlePrompt(args.userText, args.assistantText);
|
||||
const prompt = buildTitlePrompt(userMaterial, assistantMaterial);
|
||||
const gen = llm.streamGenerate({
|
||||
newMessages: [userText(prompt)],
|
||||
...(args.signal ? { signal: args.signal } : {}),
|
||||
|
||||
Reference in New Issue
Block a user