@steipete/summarize 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/CHANGELOG.md +24 -1
  2. package/README.md +34 -6
  3. package/dist/cli.cjs +4941 -790
  4. package/dist/cli.cjs.map +4 -4
  5. package/dist/esm/content/link-preview/client.js +6 -0
  6. package/dist/esm/content/link-preview/client.js.map +1 -1
  7. package/dist/esm/content/link-preview/transcript/index.js +6 -0
  8. package/dist/esm/content/link-preview/transcript/index.js.map +1 -1
  9. package/dist/esm/content/link-preview/transcript/providers/youtube/yt-dlp.js +213 -0
  10. package/dist/esm/content/link-preview/transcript/providers/youtube/yt-dlp.js.map +1 -0
  11. package/dist/esm/content/link-preview/transcript/providers/youtube.js +40 -2
  12. package/dist/esm/content/link-preview/transcript/providers/youtube.js.map +1 -1
  13. package/dist/esm/flags.js +2 -0
  14. package/dist/esm/flags.js.map +1 -1
  15. package/dist/esm/llm/generate-text.js +51 -14
  16. package/dist/esm/llm/generate-text.js.map +1 -1
  17. package/dist/esm/llm/html-to-markdown.js +3 -2
  18. package/dist/esm/llm/html-to-markdown.js.map +1 -1
  19. package/dist/esm/run.js +40 -9
  20. package/dist/esm/run.js.map +1 -1
  21. package/dist/esm/version.js +1 -1
  22. package/dist/types/content/link-preview/client.d.ts +3 -0
  23. package/dist/types/content/link-preview/content/types.d.ts +1 -1
  24. package/dist/types/content/link-preview/deps.d.ts +3 -0
  25. package/dist/types/content/link-preview/transcript/providers/youtube/yt-dlp.d.ts +15 -0
  26. package/dist/types/content/link-preview/transcript/types.d.ts +4 -0
  27. package/dist/types/flags.d.ts +1 -1
  28. package/dist/types/llm/generate-text.d.ts +8 -2
  29. package/dist/types/llm/html-to-markdown.d.ts +4 -1
  30. package/dist/types/version.d.ts +1 -1
  31. package/docs/youtube.md +5 -2
  32. package/package.json +5 -1
@@ -4,13 +4,17 @@ export type LlmApiKeys = {
4
4
  openaiApiKey: string | null;
5
5
  googleApiKey: string | null;
6
6
  anthropicApiKey: string | null;
7
+ openrouterApiKey: string | null;
8
+ };
9
+ export type OpenRouterOptions = {
10
+ providers: string[] | null;
7
11
  };
8
12
  export type LlmTokenUsage = {
9
13
  promptTokens: number | null;
10
14
  completionTokens: number | null;
11
15
  totalTokens: number | null;
12
16
  };
13
- export declare function generateTextWithModelId({ modelId, apiKeys, system, prompt, temperature, maxOutputTokens, timeoutMs, fetchImpl, }: {
17
+ export declare function generateTextWithModelId({ modelId, apiKeys, system, prompt, temperature, maxOutputTokens, timeoutMs, fetchImpl, openrouter, }: {
14
18
  modelId: string;
15
19
  apiKeys: LlmApiKeys;
16
20
  system?: string;
@@ -19,13 +23,14 @@ export declare function generateTextWithModelId({ modelId, apiKeys, system, prom
19
23
  maxOutputTokens?: number;
20
24
  timeoutMs: number;
21
25
  fetchImpl: typeof fetch;
26
+ openrouter?: OpenRouterOptions;
22
27
  }): Promise<{
23
28
  text: string;
24
29
  canonicalModelId: string;
25
30
  provider: 'xai' | 'openai' | 'google' | 'anthropic';
26
31
  usage: LlmTokenUsage | null;
27
32
  }>;
28
- export declare function streamTextWithModelId({ modelId, apiKeys, system, prompt, temperature, maxOutputTokens, timeoutMs, fetchImpl, }: {
33
+ export declare function streamTextWithModelId({ modelId, apiKeys, system, prompt, temperature, maxOutputTokens, timeoutMs, fetchImpl, openrouter, }: {
29
34
  modelId: string;
30
35
  apiKeys: LlmApiKeys;
31
36
  system?: string;
@@ -34,6 +39,7 @@ export declare function streamTextWithModelId({ modelId, apiKeys, system, prompt
34
39
  maxOutputTokens?: number;
35
40
  timeoutMs: number;
36
41
  fetchImpl: typeof fetch;
42
+ openrouter?: OpenRouterOptions;
37
43
  }): Promise<{
38
44
  textStream: AsyncIterable<string>;
39
45
  canonicalModelId: string;
@@ -1,12 +1,15 @@
1
1
  import type { ConvertHtmlToMarkdown } from '../content/link-preview/deps.js';
2
2
  import type { LlmTokenUsage } from './generate-text.js';
3
- export declare function createHtmlToMarkdownConverter({ modelId, xaiApiKey, googleApiKey, openaiApiKey, anthropicApiKey, fetchImpl, onUsage, }: {
3
+ import { type OpenRouterOptions } from './generate-text.js';
4
+ export declare function createHtmlToMarkdownConverter({ modelId, xaiApiKey, googleApiKey, openaiApiKey, anthropicApiKey, openrouterApiKey, openrouter, fetchImpl, onUsage, }: {
4
5
  modelId: string;
5
6
  xaiApiKey: string | null;
6
7
  googleApiKey: string | null;
7
8
  openaiApiKey: string | null;
8
9
  fetchImpl: typeof fetch;
9
10
  anthropicApiKey: string | null;
11
+ openrouterApiKey: string | null;
12
+ openrouter?: OpenRouterOptions;
10
13
  onUsage?: (usage: {
11
14
  model: string;
12
15
  provider: 'xai' | 'openai' | 'google' | 'anthropic';
@@ -1,2 +1,2 @@
1
- export declare const FALLBACK_VERSION = "0.2.0";
1
+ export declare const FALLBACK_VERSION = "0.3.0";
2
2
  export declare function resolvePackageVersion(importMetaUrl?: string): string;
package/docs/youtube.md CHANGED
@@ -2,11 +2,12 @@
2
2
 
3
3
  YouTube URLs use transcript-first extraction.
4
4
 
5
- ## `--youtube auto|web|apify`
5
+ ## `--youtube auto|web|apify|yt-dlp`
6
6
 
7
- - `auto` (default): try `youtubei` → `captionTracks` → Apify (if token exists)
7
+ - `auto` (default): try `youtubei` → `captionTracks` → Apify (if token exists) → `yt-dlp` (if configured)
8
8
  - `web`: try `youtubei` → `captionTracks` only
9
9
  - `apify`: Apify only
10
+ - `yt-dlp`: download audio + transcribe (OpenAI Whisper preferred; FAL fallback)
10
11
 
11
12
  ## `youtubei` vs `captionTracks`
12
13
 
@@ -24,6 +25,8 @@ YouTube URLs use transcript-first extraction.
24
25
  - If no transcript is available, we still extract `ytInitialPlayerResponse.videoDetails.shortDescription` so YouTube links can still summarize meaningfully.
25
26
  - Apify is an optional fallback (needs `APIFY_API_TOKEN`).
26
27
  - By default, we use the actor id `faVsWy9VTSNVIhWpR` (Pinto Studio’s “Youtube Transcript Scraper”).
28
+ - `yt-dlp` requires `YT_DLP_PATH` and either `OPENAI_API_KEY` (preferred) or `FAL_KEY`.
29
+ - If OpenAI transcription fails and `FAL_KEY` is set, we fall back to FAL automatically.
27
30
 
28
31
  ## Example
29
32
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steipete/summarize",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Link → clean text → summary.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -30,7 +30,11 @@
30
30
  "README.md",
31
31
  "LICENSE"
32
32
  ],
33
+ "engines": {
34
+ "node": ">=22"
35
+ },
33
36
  "dependencies": {
37
+ "@fal-ai/client": "^1.2.1",
34
38
  "cheerio": "^1.1.2",
35
39
  "es-toolkit": "^1.43.0",
36
40
  "gpt-tokenizer": "^3.4.0",