From ed03d9071aba04b76d62d5455a8bd09898255fcf Mon Sep 17 00:00:00 2001 From: tmustier Date: Tue, 24 Mar 2026 19:23:50 +0000 Subject: [PATCH] fix: remove dead activity tracker summarizers --- extensions/teams/activity-tracker.ts | 128 --------------------------- 1 file changed, 128 deletions(-) diff --git a/extensions/teams/activity-tracker.ts b/extensions/teams/activity-tracker.ts index d7e00f4..754dabf 100644 --- a/extensions/teams/activity-tracker.ts +++ b/extensions/teams/activity-tracker.ts @@ -15,134 +15,6 @@ export type TranscriptEntry = | { kind: "turn_end"; turnNumber: number; tokens: number; timestamp: number }; const MAX_TRANSCRIPT = 200; -const MAX_SUMMARY_LENGTH = 120; - -// ── Tool content summarization ── - -function truncateSummary(text: string): string { - if (text.length <= MAX_SUMMARY_LENGTH) return text; - return `${text.slice(0, MAX_SUMMARY_LENGTH - 1)}…`; -} - -function summarizeToolArgs(toolName: string, args: unknown): string { - if (!isRecord(args)) return ""; - const key = toolName.toLowerCase(); - - if (key === "read" || key === "write") { - const path = typeof args.path === "string" ? args.path : null; - if (!path) return ""; - return truncateSummary(path); - } - - if (key === "edit") { - const path = typeof args.path === "string" ? args.path : null; - if (!path) return ""; - return truncateSummary(path); - } - - if (key === "bash") { - const cmd = typeof args.command === "string" ? args.command : null; - if (!cmd) return ""; - return truncateSummary(cmd.replace(/\s+/g, " ").trim()); - } - - if (key === "grep" || key === "glob") { - const pattern = typeof args.pattern === "string" ? args.pattern : null; - const path = typeof args.path === "string" ? args.path : null; - const parts: string[] = []; - if (pattern) parts.push(pattern); - if (path) parts.push(`in ${path}`); - return truncateSummary(parts.join(" ")); - } - - if (key === "webfetch" || key === "websearch") { - const url = typeof args.url === "string" ? args.url : null; - const query = typeof args.query === "string" ? args.query : null; - return truncateSummary(url ?? query ?? ""); - } - - if (key === "team_message") { - const recipient = typeof args.recipient === "string" ? args.recipient : null; - const message = typeof args.message === "string" ? args.message : null; - if (recipient && message) return truncateSummary(`→ ${recipient}: ${message.replace(/\s+/g, " ").trim()}`); - if (message) return truncateSummary(message.replace(/\s+/g, " ").trim()); - return recipient ? truncateSummary(`→ ${recipient}`) : ""; - } - - if (key === "task" || key === "teams") { - const action = typeof args.action === "string" ? args.action : null; - return action ? truncateSummary(action) : ""; - } - - // Fallback: try to find a meaningful first-string arg - for (const v of Object.values(args)) { - if (typeof v === "string" && v.length > 0) return truncateSummary(v); - } - return ""; -} - -/** - * Extract the first text content from a ToolResultMessage-shaped result. - * The agent-loop emits `{ content: [{type: "text", text: "..."}], ... }`. - */ -function extractContentText(result: Record): string | null { - const content = result.content; - if (!Array.isArray(content)) return null; - for (const item of content) { - if (isRecord(item) && item.type === "text" && typeof item.text === "string") { - return item.text; - } - } - return null; -} - -function summarizeToolResult(toolName: string, result: unknown, isError: boolean): string { - if (isError) { - if (typeof result === "string") return truncateSummary(result.replace(/\s+/g, " ").trim()); - if (isRecord(result)) { - // Try content array first (ToolResultMessage shape) - const contentText = extractContentText(result); - if (contentText !== null) { - const trimmed = contentText.replace(/\s+/g, " ").trim(); - return trimmed.length > 0 ? truncateSummary(trimmed) : "error"; - } - const msg = typeof result.message === "string" - ? result.message - : typeof result.error === "string" - ? result.error - : null; - if (msg) return truncateSummary(msg.replace(/\s+/g, " ").trim()); - } - return "error"; - } - - if (typeof result === "string") { - const compact = result.replace(/\s+/g, " ").trim(); - if (compact.length === 0) return "(empty)"; - return truncateSummary(compact); - } - - if (isRecord(result)) { - // Try content array first (ToolResultMessage shape from agent-loop) - const contentText = extractContentText(result); - if (contentText !== null) { - const compact = contentText.replace(/\s+/g, " ").trim(); - if (compact.length === 0) return "(empty)"; - return truncateSummary(compact); - } - // Fallback: check for common structured result shapes - const status = typeof result.status === "string" ? result.status : null; - if (status) return truncateSummary(status); - const output = typeof result.output === "string" ? result.output : null; - if (output) return truncateSummary(output.replace(/\s+/g, " ").trim()); - } - - if (Array.isArray(result)) { - return `${String(result.length)} items`; - } - - return ""; -} export class TranscriptLog { private entries: TranscriptEntry[] = [];