import {
  getTraceById
} from "./chunk-CAY57CKF.js";
import "./chunk-KOO5733S.js";

// src/tools/get-trace.ts
async function handleGetTrace(params) {
  const format = params.format ?? "digest";
  const result = await getTraceById(params.traceId, format);
  if (format === "json") {
    return JSON.stringify(result, null, 2);
  }
  const lines = [];
  lines.push(`# Trace: ${params.traceId}
`);
  if (result.timestamps) {
    lines.push(`**Started**: ${result.timestamps.started_at}`);
    if (result.timestamps.updated_at)
      lines.push(`**Updated**: ${result.timestamps.updated_at}`);
  }
  if (result.metadata) {
    const meta = result.metadata;
    if (meta.user_id) lines.push(`**User**: ${meta.user_id}`);
    if (meta.thread_id) lines.push(`**Thread**: ${meta.thread_id}`);
    if (meta.customer_id) lines.push(`**Customer**: ${meta.customer_id}`);
    if (meta.labels?.length) lines.push(`**Labels**: ${meta.labels.join(", ")}`);
  }
  if (result.evaluations && result.evaluations.length > 0) {
    lines.push("\n## Evaluations");
    for (const evaluation of result.evaluations) {
      const status = evaluation.passed === true ? "PASSED" : evaluation.passed === false ? "FAILED" : "N/A";
      lines.push(
        `- **${evaluation.name || evaluation.evaluator_id}**: ${status}${evaluation.score != null ? ` (score: ${evaluation.score})` : ""}${evaluation.label ? ` [${evaluation.label}]` : ""}`
      );
    }
  }
  if (result.formatted_trace) {
    lines.push(`
## Trace Details
${result.formatted_trace}`);
  }
  lines.push(
    '\n> Tip: Use `get_trace` with `format: "json"` to get the full raw trace data.'
  );
  return lines.join("\n");
}
export {
  handleGetTrace
};
//# sourceMappingURL=get-trace-ZR7MIITH.js.map