Eidos

Installation Notice

The installation may currently fail. We recommend copying the code below and creating the extension manually in Eidos.

web fetcher

By: Mayne

Install Latest (v0.0.2)

Fetches web content as Markdown from a given URL using Jina AI

export const inputJSONSchema = {
  type: "object",
  properties: {
    url: {
      type: "string",
      description: "The URL of the webpage to fetch content from"
    }
  },
  required: ["url"]
};

export const outputJSONSchema = {
  type: "object",
  properties: {
    content: {
      type: "string",
      description: "The markdown content fetched from the URL"
    },
    success: {
      type: "boolean",
      description: "Whether the fetch operation was successful"
    },
    error: {
      type: "string",
      description: "Error message if the operation failed"
    }
  },
  required: ["content", "success"]
};

export const commands = [
  {
    name: "fetchWebContent",
    description: "Fetch web content as markdown from a given URL",
    inputJSONSchema,
    outputJSONSchema,
    asTableAction: false,
    asTool: true
  }
];

interface FetchResult {
  content: string;
  success: boolean;
  error?: string;
}

function isValidUrl(url: string): boolean {
  try {
    new URL(url);
    return true;
  } catch {
    return false;
  }
}

function normalizeUrl(url: string): string {
  if (!url.startsWith('http://') && !url.startsWith('https://')) {
    return `https://${url}`;
  }
  return url;
}

export async function fetchWebContent(
  input: Input<{ url: string }>,
  context: Context
): Promise<FetchResult> {
  const { url } = input;

  if (!url || typeof url !== 'string' || url.trim() === '') {
    const error = "URL is required and must be a non-empty string";
    await eidos.currentSpace.notify({
      title: "Invalid Input",
      description: error
    });
    return { content: "", success: false, error };
  }

  const normalizedUrl = normalizeUrl(url.trim());

  if (!isValidUrl(normalizedUrl)) {
    const error = `Invalid URL format: ${normalizedUrl}`;
    await eidos.currentSpace.notify({
      title: "Invalid URL",
      description: error
    });
    return { content: "", success: false, error };
  }

  try {
    const jinaUrl = `https://r.jina.ai/${normalizedUrl}`;

    const response = await fetch(jinaUrl, {
      method: 'GET',
      headers: {
        'Accept': 'text/plain',
        'User-Agent': 'Eidos-WebFetcher/1.0'
      }
    });

    if (!response.ok) {
      throw new Error(`HTTP ${response.status}: ${response.statusText}`);
    }

    const content = await response.text();

    if (!content || content.trim() === '') {
      const error = "Fetched content is empty";
      await eidos.currentSpace.notify({
        title: "Empty Content",
        description: `No content found at ${normalizedUrl}`
      });
      return { content: "", success: false, error };
    }

    return { content, success: true };

  } catch (error) {
    const errorMessage = error instanceof Error ? error.message : String(error);
    const fullError = `Failed to fetch content from ${normalizedUrl}: ${errorMessage}`;

    await eidos.currentSpace.notify({
      title: "Fetch Error",
      description: fullError
    });

    return { content: "", success: false, error: fullError };
  }
}

Information

Author
Mayne
Type
script
Latest Version
0.0.2
Last Updated
06/20/2025
Published
06/20/2025

Version History

  • v0.0.2 06/20/2025
  • v0.0.1 06/20/2025