import { definePlugin } from "../../utils/plugin-utils";
import { createPluginMethod } from "../../utils/plugin-utils";
import { RelayRequestSchema } from "./schemas";
import { logDeprecation } from "../../utils/logging";
/**
 * @deprecated Use `sdk.fetch(url, init?)` instead. This plugin now delegates
 * to the fetch plugin and is kept only for backward compatibility. It is
 * hidden from the CLI/MCP registries.
 */
export const requestPlugin = definePlugin((sdk) => createPluginMethod(sdk, {
    name: "request",
    packages: ["cli", "mcp"],
    categories: ["http", "deprecated"],
    returnType: "Response",
    inputSchema: RelayRequestSchema,
    handler: async ({ sdk, options }) => {
        logDeprecation("request() is deprecated. Use fetch() instead.");
        const { url, method, body, headers, connection, connectionId, authenticationId, callbackUrl, } = options;
        return sdk.fetch(url, {
            method,
            body: body,
            headers: headers,
            connection: connection ?? connectionId ?? authenticationId,
            callbackUrl,
        });
    },
}));
