import {
  log
} from "./chunk-Y4VZACTC.js";
import {
  TOOL_PARAMS
} from "./chunk-EMQMCXIC.js";
import {
  zodUrl
} from "./chunk-FB5CMO3J.js";

// src/operations/discover.ts
import { discoverOriginSchema, GuidanceMode } from "@agentcash/discovery";
import z from "zod";
var discoverResourcesSchema = z.object({
  url: zodUrl.describe(TOOL_PARAMS.discoverApiEndpoints.url),
  includeGuidance: z.boolean().optional().describe(TOOL_PARAMS.discoverApiEndpoints.includeGuidance)
});
async function discoverResources(surface, args) {
  const parsedArgs = discoverResourcesSchema.safeParse(args);
  if (!parsedArgs.success) {
    return {
      found: false,
      cause: "invalid_input",
      message: parsedArgs.error.message
    };
  }
  const { url, includeGuidance } = parsedArgs.data;
  const guidance = includeGuidance === true ? GuidanceMode.Always : includeGuidance === false ? GuidanceMode.Never : GuidanceMode.Auto;
  const result = await discoverOriginSchema({ target: url, guidance });
  if (!result.found) {
    log.error(`[discoverResources failed`, {
      surface,
      url,
      cause: result.cause,
      message: result.message
    });
    return result;
  }
  return {
    ...result,
    endpoints: result.endpoints.map((e) => ({ ...e }))
  };
}

export {
  discoverResourcesSchema,
  discoverResources
};
//# sourceMappingURL=chunk-HOGMCHWI.js.map