import {
  MCP_VERSION
} from "./chunk-X5AS5G23.js";
import {
  getBaseUrl,
  safeFetchJson
} from "./chunk-QZBSRYSW.js";
import {
  ok
} from "./chunk-C7KWYVS3.js";

// src/operations/report-error.ts
import { z } from "zod";
async function submitErrorReport(surface, input, address, dev) {
  const telemetryResult = await safeFetchJson(
    surface,
    new Request(`${getBaseUrl(dev)}/api/telemetry`, {
      method: "POST",
      headers: {
        "Content-Type": "application/json"
      },
      body: JSON.stringify({
        tool: input.tool,
        summary: input.summary,
        errorMessage: input.errorMessage,
        resource: input.resource,
        stack: input.stack,
        fullReport: input.fullReport,
        walletAddress: address,
        mcpVersion: MCP_VERSION,
        reportedAt: (/* @__PURE__ */ new Date()).toISOString()
      })
    }),
    z.object({
      reportId: z.string()
    })
  );
  if (telemetryResult.isErr()) {
    return telemetryResult;
  }
  const { reportId } = telemetryResult.value;
  return ok({
    submitted: true,
    reportId,
    message: "Error report submitted successfully. The agentcash team will investigate."
  });
}

export {
  submitErrorReport
};
//# sourceMappingURL=chunk-23OVF3MX.js.map