tpmjs/packages/tools/official/fetch-text
Ajax Davis 5c9f1a1d0a chore: update dependencies with compatibility fixes
- Update all packages to latest versions via pnpm update --latest
- Downgrade Prisma 7 to 6 (v7 requires schema migration)
- Downgrade Tailwind CSS 4 to 3 (v4 requires PostCSS migration)
- Downgrade Storybook 10 to 8 (addons not available in v10)
- Pin cheerio to 1.0.0-rc.12 via pnpm override (type exports changed)
- Fix AI SDK tool definitions: parameters -> inputSchema
- Fix cheerio types in extract-meta and table-extract tools
- Add explicit type annotations to tool execute functions
- Migrate biome config to v2.3.11 schema

All type-checks, tests, and builds pass.
2026-01-09 22:49:41 +10:00
..
src feat: add 55 new business tools and improve existing implementations 2026-01-01 19:23:32 +10:00
CHANGELOG.md chore: version packages 2025-12-31 23:54:47 +10:00
package.json chore: update dependencies with compatibility fixes 2026-01-09 22:49:41 +10:00
README.md feat: add 100+ official TPMJS tools 2025-12-31 22:55:56 +10:00
tsconfig.json feat: add 100+ official TPMJS tools 2025-12-31 22:55:56 +10:00
tsup.config.ts feat: add 100+ official TPMJS tools 2025-12-31 22:55:56 +10:00

@tpmjs/tools-fetch-text

Fetch a URL and return plain text content with metadata.

Installation

npm install @tpmjs/tools-fetch-text

Usage

import { fetchTextTool } from '@tpmjs/tools-fetch-text';

// Use with AI SDK
const result = await fetchTextTool.execute({
  url: 'https://example.com',
});

console.log(result.text); // Plain text content
console.log(result.contentType); // 'text/html; charset=utf-8'
console.log(result.contentLength); // 12345
console.log(result.metadata); // { fetchedAt, statusCode, redirected, finalUrl }

Features

  • Fetches any URL and returns plain text
  • Automatically strips HTML tags from HTML content
  • Decodes common HTML entities
  • 30 second timeout for requests
  • Returns metadata including content type, length, status code
  • Tracks redirects and provides final URL
  • Comprehensive error handling

Input

  • url (string, required): The URL to fetch (must be http or https)

Output

Returns a FetchTextResult object:

{
  text: string;           // Plain text content (HTML stripped if applicable)
  url: string;            // Original URL
  contentLength: number;  // Length of raw content in bytes
  contentType: string;    // Content-Type header value
  metadata: {
    fetchedAt: string;    // ISO timestamp of when content was fetched
    statusCode: number;   // HTTP status code
    redirected: boolean;  // Whether the request was redirected
    finalUrl: string;     // Final URL after redirects
  };
}

Requirements

  • Node.js 18+ (uses native fetch API)

License

MIT