- 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. |
||
|---|---|---|
| .. | ||
| src | ||
| CHANGELOG.md | ||
| package.json | ||
| README.md | ||
| tsconfig.json | ||
| tsup.config.ts | ||
@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