import { extractMcpToolCallIdentity } from "./src/server/runtimeModel.ts";
import { acpMcpToolCallOutput } from "./src/server/adapter.ts";
import { compactDynamicToolOutput, htmlRenderFromToolItem } from "../shared/src/toolOutput.ts";
import { attachmentIdBelongsToThread, toSafeThreadAttachmentSegment } from "../shared/src/attachmentIds.ts";
const n = 12000; // ~3000 tokens
const inputs = ["mcp__" + "_a".repeat(n/2), "t3-code__" + "a.".repeat(n/2) + " — source file:", "a".repeat(n) + " — source file:" + "x".repeat(n), "mcp_".repeat(n/4), "t3code-".repeat(n/7)];
const time = (label: string, f: () => void) => { const t = performance.now(); for (let i = 0; i < 50; i++) f(); console.log(label, ((performance.now() - t) / 50).toFixed(3), "ms"); };
for (const s of inputs) {
  time("identity rawInput.toolName " + s.slice(0, 12), () => extractMcpToolCallIdentity({ toolCallId: "x", data: { rawInput: { toolName: s, tool_name: s, server_name: s }, meta: { "cognition.ai/inferenceToolName": s }, title: s } } as any));
}
time("okay", () => acpMcpToolCallOutput({ type: "MCP", output: { OkayOutput: "{".repeat(n) } }));
time("belongs", () => attachmentIdBelongsToThread("a-".repeat(n/2) + "-html", "a-".repeat(n/2)));
time("segment", () => toSafeThreadAttachmentSegment("-_".repeat(n/2) + "!"));
time("compact nested", () => compactDynamicToolOutput([{ type: "content", content: { type: "text", text: JSON.stringify({ type: "text", text: JSON.stringify({ type: "text", text: "[".repeat(n) }) }) } }]));
time("execute", () => htmlRenderFromToolItem({ toolName: "execute", output: JSON.stringify({ attachmentId: "x".repeat(n) + "-html", title: "t" }) }, "thread"));
