@steipete/summarize-core 0.7.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.
- package/README.md +7 -0
- package/dist/esm/content/index.js +5 -0
- package/dist/esm/content/index.js.map +1 -0
- package/dist/esm/content/link-preview/client.js +28 -0
- package/dist/esm/content/link-preview/client.js.map +1 -0
- package/dist/esm/content/link-preview/content/article.js +155 -0
- package/dist/esm/content/link-preview/content/article.js.map +1 -0
- package/dist/esm/content/link-preview/content/cleaner.js +55 -0
- package/dist/esm/content/link-preview/content/cleaner.js.map +1 -0
- package/dist/esm/content/link-preview/content/constants.js +7 -0
- package/dist/esm/content/link-preview/content/constants.js.map +1 -0
- package/dist/esm/content/link-preview/content/fetcher.js +124 -0
- package/dist/esm/content/link-preview/content/fetcher.js.map +1 -0
- package/dist/esm/content/link-preview/content/firecrawl.js +86 -0
- package/dist/esm/content/link-preview/content/firecrawl.js.map +1 -0
- package/dist/esm/content/link-preview/content/html.js +162 -0
- package/dist/esm/content/link-preview/content/html.js.map +1 -0
- package/dist/esm/content/link-preview/content/index.js +345 -0
- package/dist/esm/content/link-preview/content/index.js.map +1 -0
- package/dist/esm/content/link-preview/content/jsonld.js +77 -0
- package/dist/esm/content/link-preview/content/jsonld.js.map +1 -0
- package/dist/esm/content/link-preview/content/parsers.js +77 -0
- package/dist/esm/content/link-preview/content/parsers.js.map +1 -0
- package/dist/esm/content/link-preview/content/podcast-utils.js +79 -0
- package/dist/esm/content/link-preview/content/podcast-utils.js.map +1 -0
- package/dist/esm/content/link-preview/content/readability.js +53 -0
- package/dist/esm/content/link-preview/content/readability.js.map +1 -0
- package/dist/esm/content/link-preview/content/twitter-utils.js +68 -0
- package/dist/esm/content/link-preview/content/twitter-utils.js.map +1 -0
- package/dist/esm/content/link-preview/content/types.js +4 -0
- package/dist/esm/content/link-preview/content/types.js.map +1 -0
- package/dist/esm/content/link-preview/content/utils.js +164 -0
- package/dist/esm/content/link-preview/content/utils.js.map +1 -0
- package/dist/esm/content/link-preview/content/video.js +96 -0
- package/dist/esm/content/link-preview/content/video.js.map +1 -0
- package/dist/esm/content/link-preview/content/youtube.js +82 -0
- package/dist/esm/content/link-preview/content/youtube.js.map +1 -0
- package/dist/esm/content/link-preview/deps.js +20 -0
- package/dist/esm/content/link-preview/deps.js.map +1 -0
- package/dist/esm/content/link-preview/fetch-with-timeout.js +35 -0
- package/dist/esm/content/link-preview/fetch-with-timeout.js.map +1 -0
- package/dist/esm/content/link-preview/types.js +2 -0
- package/dist/esm/content/link-preview/types.js.map +1 -0
- package/dist/esm/content/transcript/cache.js +79 -0
- package/dist/esm/content/transcript/cache.js.map +1 -0
- package/dist/esm/content/transcript/index.js +130 -0
- package/dist/esm/content/transcript/index.js.map +1 -0
- package/dist/esm/content/transcript/normalize.js +43 -0
- package/dist/esm/content/transcript/normalize.js.map +1 -0
- package/dist/esm/content/transcript/providers/generic.js +11 -0
- package/dist/esm/content/transcript/providers/generic.js.map +1 -0
- package/dist/esm/content/transcript/providers/podcast/apple-flow.js +222 -0
- package/dist/esm/content/transcript/providers/podcast/apple-flow.js.map +1 -0
- package/dist/esm/content/transcript/providers/podcast/apple.js +38 -0
- package/dist/esm/content/transcript/providers/podcast/apple.js.map +1 -0
- package/dist/esm/content/transcript/providers/podcast/constants.js +8 -0
- package/dist/esm/content/transcript/providers/podcast/constants.js.map +1 -0
- package/dist/esm/content/transcript/providers/podcast/flow-context.js +2 -0
- package/dist/esm/content/transcript/providers/podcast/flow-context.js.map +1 -0
- package/dist/esm/content/transcript/providers/podcast/itunes.js +134 -0
- package/dist/esm/content/transcript/providers/podcast/itunes.js.map +1 -0
- package/dist/esm/content/transcript/providers/podcast/json.js +34 -0
- package/dist/esm/content/transcript/providers/podcast/json.js.map +1 -0
- package/dist/esm/content/transcript/providers/podcast/media.js +345 -0
- package/dist/esm/content/transcript/providers/podcast/media.js.map +1 -0
- package/dist/esm/content/transcript/providers/podcast/results.js +28 -0
- package/dist/esm/content/transcript/providers/podcast/results.js.map +1 -0
- package/dist/esm/content/transcript/providers/podcast/rss.js +253 -0
- package/dist/esm/content/transcript/providers/podcast/rss.js.map +1 -0
- package/dist/esm/content/transcript/providers/podcast/spotify-flow.js +218 -0
- package/dist/esm/content/transcript/providers/podcast/spotify-flow.js.map +1 -0
- package/dist/esm/content/transcript/providers/podcast/spotify.js +113 -0
- package/dist/esm/content/transcript/providers/podcast/spotify.js.map +1 -0
- package/dist/esm/content/transcript/providers/podcast.js +222 -0
- package/dist/esm/content/transcript/providers/podcast.js.map +1 -0
- package/dist/esm/content/transcript/providers/youtube/api.js +257 -0
- package/dist/esm/content/transcript/providers/youtube/api.js.map +1 -0
- package/dist/esm/content/transcript/providers/youtube/apify.js +55 -0
- package/dist/esm/content/transcript/providers/youtube/apify.js.map +1 -0
- package/dist/esm/content/transcript/providers/youtube/captions.js +409 -0
- package/dist/esm/content/transcript/providers/youtube/captions.js.map +1 -0
- package/dist/esm/content/transcript/providers/youtube/yt-dlp.js +166 -0
- package/dist/esm/content/transcript/providers/youtube/yt-dlp.js.map +1 -0
- package/dist/esm/content/transcript/providers/youtube.js +173 -0
- package/dist/esm/content/transcript/providers/youtube.js.map +1 -0
- package/dist/esm/content/transcript/types.js +2 -0
- package/dist/esm/content/transcript/types.js.map +1 -0
- package/dist/esm/content/transcript/utils.js +259 -0
- package/dist/esm/content/transcript/utils.js.map +1 -0
- package/dist/esm/index.js +4 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/language.js +126 -0
- package/dist/esm/language.js.map +1 -0
- package/dist/esm/prompts/cli.js +20 -0
- package/dist/esm/prompts/cli.js.map +1 -0
- package/dist/esm/prompts/file.js +48 -0
- package/dist/esm/prompts/file.js.map +1 -0
- package/dist/esm/prompts/index.js +4 -0
- package/dist/esm/prompts/index.js.map +1 -0
- package/dist/esm/prompts/link-summary.js +116 -0
- package/dist/esm/prompts/link-summary.js.map +1 -0
- package/dist/esm/shared/contracts.js +2 -0
- package/dist/esm/shared/contracts.js.map +1 -0
- package/dist/esm/transcription/whisper/constants.js +8 -0
- package/dist/esm/transcription/whisper/constants.js.map +1 -0
- package/dist/esm/transcription/whisper/core.js +303 -0
- package/dist/esm/transcription/whisper/core.js.map +1 -0
- package/dist/esm/transcription/whisper/fal.js +41 -0
- package/dist/esm/transcription/whisper/fal.js.map +1 -0
- package/dist/esm/transcription/whisper/ffmpeg.js +179 -0
- package/dist/esm/transcription/whisper/ffmpeg.js.map +1 -0
- package/dist/esm/transcription/whisper/openai.js +47 -0
- package/dist/esm/transcription/whisper/openai.js.map +1 -0
- package/dist/esm/transcription/whisper/types.js +2 -0
- package/dist/esm/transcription/whisper/types.js.map +1 -0
- package/dist/esm/transcription/whisper/utils.js +63 -0
- package/dist/esm/transcription/whisper/utils.js.map +1 -0
- package/dist/esm/transcription/whisper/whisper-cpp.js +227 -0
- package/dist/esm/transcription/whisper/whisper-cpp.js.map +1 -0
- package/dist/esm/transcription/whisper.js +5 -0
- package/dist/esm/transcription/whisper.js.map +1 -0
- package/dist/types/content/index.d.ts +5 -0
- package/dist/types/content/link-preview/client.d.ts +18 -0
- package/dist/types/content/link-preview/content/article.d.ts +4 -0
- package/dist/types/content/link-preview/content/cleaner.d.ts +12 -0
- package/dist/types/content/link-preview/content/constants.d.ts +6 -0
- package/dist/types/content/link-preview/content/fetcher.d.ts +16 -0
- package/dist/types/content/link-preview/content/firecrawl.d.ts +14 -0
- package/dist/types/content/link-preview/content/html.d.ts +17 -0
- package/dist/types/content/link-preview/content/index.d.ts +4 -0
- package/dist/types/content/link-preview/content/jsonld.d.ts +6 -0
- package/dist/types/content/link-preview/content/parsers.d.ts +7 -0
- package/dist/types/content/link-preview/content/podcast-utils.d.ts +7 -0
- package/dist/types/content/link-preview/content/readability.d.ts +8 -0
- package/dist/types/content/link-preview/content/twitter-utils.d.ts +4 -0
- package/dist/types/content/link-preview/content/types.d.ts +61 -0
- package/dist/types/content/link-preview/content/utils.d.ts +17 -0
- package/dist/types/content/link-preview/content/video.d.ts +5 -0
- package/dist/types/content/link-preview/content/youtube.d.ts +1 -0
- package/dist/types/content/link-preview/deps.d.ts +167 -0
- package/dist/types/content/link-preview/fetch-with-timeout.d.ts +4 -0
- package/dist/types/content/link-preview/types.d.ts +37 -0
- package/dist/types/content/transcript/cache.d.ts +29 -0
- package/dist/types/content/transcript/index.d.ts +9 -0
- package/dist/types/content/transcript/normalize.d.ts +3 -0
- package/dist/types/content/transcript/providers/generic.d.ts +3 -0
- package/dist/types/content/transcript/providers/podcast/apple-flow.d.ts +4 -0
- package/dist/types/content/transcript/providers/podcast/apple.d.ts +6 -0
- package/dist/types/content/transcript/providers/podcast/constants.d.ts +7 -0
- package/dist/types/content/transcript/providers/podcast/flow-context.d.ts +11 -0
- package/dist/types/content/transcript/providers/podcast/itunes.d.ts +17 -0
- package/dist/types/content/transcript/providers/podcast/json.d.ts +8 -0
- package/dist/types/content/transcript/providers/podcast/media.d.ts +42 -0
- package/dist/types/content/transcript/providers/podcast/results.d.ts +10 -0
- package/dist/types/content/transcript/providers/podcast/rss.d.ts +22 -0
- package/dist/types/content/transcript/providers/podcast/spotify-flow.d.ts +3 -0
- package/dist/types/content/transcript/providers/podcast/spotify.d.ts +24 -0
- package/dist/types/content/transcript/providers/podcast.d.ts +20 -0
- package/dist/types/content/transcript/providers/youtube/api.d.ts +26 -0
- package/dist/types/content/transcript/providers/youtube/apify.d.ts +1 -0
- package/dist/types/content/transcript/providers/youtube/captions.d.ts +7 -0
- package/dist/types/content/transcript/providers/youtube/yt-dlp.d.ts +17 -0
- package/dist/types/content/transcript/providers/youtube.d.ts +3 -0
- package/dist/types/content/transcript/types.d.ts +30 -0
- package/dist/types/content/transcript/utils.d.ts +8 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/language.d.ts +25 -0
- package/dist/types/prompts/cli.d.ts +10 -0
- package/dist/types/prompts/file.d.ts +17 -0
- package/dist/types/prompts/index.d.ts +4 -0
- package/dist/types/prompts/link-summary.d.ts +29 -0
- package/dist/types/shared/contracts.d.ts +2 -0
- package/dist/types/transcription/whisper/constants.d.ts +7 -0
- package/dist/types/transcription/whisper/core.d.ts +20 -0
- package/dist/types/transcription/whisper/fal.d.ts +1 -0
- package/dist/types/transcription/whisper/ffmpeg.d.ts +16 -0
- package/dist/types/transcription/whisper/openai.d.ts +2 -0
- package/dist/types/transcription/whisper/types.d.ts +17 -0
- package/dist/types/transcription/whisper/utils.d.ts +5 -0
- package/dist/types/transcription/whisper/whisper-cpp.d.ts +9 -0
- package/dist/types/transcription/whisper.d.ts +5 -0
- package/package.json +54 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export interface YoutubeTranscriptConfig {
|
|
2
|
+
apiKey: string;
|
|
3
|
+
context: Record<string, unknown>;
|
|
4
|
+
params: string;
|
|
5
|
+
visitorData?: string | null;
|
|
6
|
+
clientName?: string | null;
|
|
7
|
+
clientVersion?: string | null;
|
|
8
|
+
pageCl?: number | null;
|
|
9
|
+
pageLabel?: string | null;
|
|
10
|
+
}
|
|
11
|
+
export declare const extractYoutubeiTranscriptConfig: (html: string) => YoutubeTranscriptConfig | null;
|
|
12
|
+
export declare const fetchTranscriptFromTranscriptEndpoint: (fetchImpl: typeof fetch, { config, originalUrl, }: {
|
|
13
|
+
config: YoutubeTranscriptConfig;
|
|
14
|
+
originalUrl: string;
|
|
15
|
+
}) => Promise<string | null>;
|
|
16
|
+
export declare const extractTranscriptFromTranscriptEndpoint: (data: unknown) => string | null;
|
|
17
|
+
export declare const extractYoutubeiBootstrap: (html: string) => {
|
|
18
|
+
apiKey: string | null;
|
|
19
|
+
context: Record<string, unknown>;
|
|
20
|
+
clientVersion: string | null;
|
|
21
|
+
clientName: string | null;
|
|
22
|
+
visitorData: string | null;
|
|
23
|
+
pageCl: number | null;
|
|
24
|
+
pageLabel: string | null;
|
|
25
|
+
xsrfToken: string | null;
|
|
26
|
+
} | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const fetchTranscriptWithApify: (fetchImpl: typeof fetch, apifyApiToken: string | null, url: string) => Promise<string | null>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
interface YoutubeTranscriptContext {
|
|
2
|
+
html: string;
|
|
3
|
+
originalUrl: string;
|
|
4
|
+
videoId: string;
|
|
5
|
+
}
|
|
6
|
+
export declare const fetchTranscriptFromCaptionTracks: (fetchImpl: typeof fetch, { html, originalUrl, videoId }: YoutubeTranscriptContext) => Promise<string | null>;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type TranscriptionProvider } from '../../../../transcription/whisper.js';
|
|
2
|
+
import type { LinkPreviewProgressEvent } from '../../../link-preview/deps.js';
|
|
3
|
+
type YtDlpTranscriptResult = {
|
|
4
|
+
text: string | null;
|
|
5
|
+
provider: TranscriptionProvider | null;
|
|
6
|
+
error: Error | null;
|
|
7
|
+
notes: string[];
|
|
8
|
+
};
|
|
9
|
+
type YtDlpRequest = {
|
|
10
|
+
ytDlpPath: string | null;
|
|
11
|
+
openaiApiKey: string | null;
|
|
12
|
+
falApiKey: string | null;
|
|
13
|
+
url: string;
|
|
14
|
+
onProgress?: ((event: LinkPreviewProgressEvent) => void) | null;
|
|
15
|
+
};
|
|
16
|
+
export declare const fetchTranscriptWithYtDlp: ({ ytDlpPath, openaiApiKey, falApiKey, url, onProgress, }: YtDlpRequest) => Promise<YtDlpTranscriptResult>;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ProviderContext, ProviderFetchOptions, ProviderResult } from '../types.js';
|
|
2
|
+
export declare const canHandle: ({ url }: ProviderContext) => boolean;
|
|
3
|
+
export declare const fetchTranscript: (context: ProviderContext, options: ProviderFetchOptions) => Promise<ProviderResult>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { YoutubeTranscriptMode } from '../link-preview/content/types.js';
|
|
2
|
+
import type { LinkPreviewProgressEvent, ScrapeWithFirecrawl } from '../link-preview/deps.js';
|
|
3
|
+
import type { TranscriptResolution, TranscriptSource } from '../link-preview/types.js';
|
|
4
|
+
export type TranscriptService = 'youtube' | 'podcast' | 'generic';
|
|
5
|
+
export interface ProviderContext {
|
|
6
|
+
url: string;
|
|
7
|
+
html: string | null;
|
|
8
|
+
resourceKey: string | null;
|
|
9
|
+
}
|
|
10
|
+
export interface ProviderFetchOptions {
|
|
11
|
+
fetch: typeof fetch;
|
|
12
|
+
scrapeWithFirecrawl?: ScrapeWithFirecrawl | null;
|
|
13
|
+
apifyApiToken: string | null;
|
|
14
|
+
youtubeTranscriptMode: YoutubeTranscriptMode;
|
|
15
|
+
ytDlpPath: string | null;
|
|
16
|
+
falApiKey: string | null;
|
|
17
|
+
openaiApiKey: string | null;
|
|
18
|
+
onProgress?: ((event: LinkPreviewProgressEvent) => void) | null;
|
|
19
|
+
}
|
|
20
|
+
export interface ProviderResult extends TranscriptResolution {
|
|
21
|
+
metadata?: Record<string, unknown>;
|
|
22
|
+
attemptedProviders: TranscriptSource[];
|
|
23
|
+
notes?: string | null;
|
|
24
|
+
}
|
|
25
|
+
export interface ProviderModule {
|
|
26
|
+
id: TranscriptService;
|
|
27
|
+
canHandle(context: ProviderContext): boolean;
|
|
28
|
+
fetchTranscript(context: ProviderContext, options: ProviderFetchOptions): Promise<ProviderResult>;
|
|
29
|
+
}
|
|
30
|
+
export type { TranscriptSource } from '../link-preview/types.js';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare function isRecord(value: unknown): value is Record<string, unknown>;
|
|
2
|
+
export declare const isYouTubeUrl: (rawUrl: string) => boolean;
|
|
3
|
+
export declare function isYouTubeVideoUrl(rawUrl: string): boolean;
|
|
4
|
+
export declare function extractYouTubeVideoId(rawUrl: string): string | null;
|
|
5
|
+
export declare function extractEmbeddedYouTubeUrlFromHtml(html: string, maxTextChars?: number, maxReadabilityChars?: number): Promise<string | null>;
|
|
6
|
+
export declare function sanitizeYoutubeJsonResponse(input: string): string;
|
|
7
|
+
export declare function decodeHtmlEntities(input: string): string;
|
|
8
|
+
export declare function extractYoutubeBootstrapConfig(html: string): Record<string, unknown> | null;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type OutputLanguage = {
|
|
2
|
+
kind: 'auto';
|
|
3
|
+
} | {
|
|
4
|
+
kind: 'fixed';
|
|
5
|
+
/**
|
|
6
|
+
* BCP-47-ish language tag (e.g. "en", "de", "en-US").
|
|
7
|
+
*
|
|
8
|
+
* Note: we keep this mostly user-provided; the model does the heavy lifting.
|
|
9
|
+
*/
|
|
10
|
+
tag: string;
|
|
11
|
+
/**
|
|
12
|
+
* Human-friendly label for prompts (e.g. "English", "German").
|
|
13
|
+
*/
|
|
14
|
+
label: string;
|
|
15
|
+
};
|
|
16
|
+
export declare function parseOutputLanguage(raw: string): OutputLanguage;
|
|
17
|
+
export declare function resolveOutputLanguage(raw: string | null | undefined): OutputLanguage;
|
|
18
|
+
export declare function formatOutputLanguageInstruction(language: OutputLanguage): string;
|
|
19
|
+
export declare function formatOutputLanguageForJson(language: OutputLanguage): {
|
|
20
|
+
mode: 'auto';
|
|
21
|
+
} | {
|
|
22
|
+
mode: 'fixed';
|
|
23
|
+
tag: string;
|
|
24
|
+
label: string;
|
|
25
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { OutputLanguage } from '../language.js';
|
|
2
|
+
import type { SummaryLengthTarget } from './link-summary.js';
|
|
3
|
+
export declare function buildPathSummaryPrompt({ kindLabel, filePath, filename, mediaType, outputLanguage, summaryLength, }: {
|
|
4
|
+
kindLabel: 'file' | 'image';
|
|
5
|
+
filePath: string;
|
|
6
|
+
filename: string | null;
|
|
7
|
+
mediaType: string | null;
|
|
8
|
+
summaryLength: SummaryLengthTarget;
|
|
9
|
+
outputLanguage?: OutputLanguage | null;
|
|
10
|
+
}): string;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { OutputLanguage } from '../language.js';
|
|
2
|
+
import type { SummaryLengthTarget } from './link-summary.js';
|
|
3
|
+
export declare function buildFileSummaryPrompt({ filename, mediaType, outputLanguage, summaryLength, contentLength, }: {
|
|
4
|
+
filename: string | null;
|
|
5
|
+
mediaType: string | null;
|
|
6
|
+
summaryLength: SummaryLengthTarget;
|
|
7
|
+
contentLength?: number | null;
|
|
8
|
+
outputLanguage?: OutputLanguage | null;
|
|
9
|
+
}): string;
|
|
10
|
+
export declare function buildFileTextSummaryPrompt({ filename, originalMediaType, contentMediaType, outputLanguage, summaryLength, contentLength, }: {
|
|
11
|
+
filename: string | null;
|
|
12
|
+
originalMediaType: string | null;
|
|
13
|
+
contentMediaType: string;
|
|
14
|
+
summaryLength: SummaryLengthTarget;
|
|
15
|
+
contentLength: number;
|
|
16
|
+
outputLanguage?: OutputLanguage | null;
|
|
17
|
+
}): string;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export type { SummaryLength } from '../shared/contracts.js';
|
|
2
|
+
export { buildPathSummaryPrompt } from './cli.js';
|
|
3
|
+
export { buildFileSummaryPrompt, buildFileTextSummaryPrompt } from './file.js';
|
|
4
|
+
export { buildLinkSummaryPrompt, estimateMaxCompletionTokensForCharacters, pickSummaryLengthForCharacters, type ShareContextEntry, SUMMARY_LENGTH_TO_TOKENS, type SummaryLengthTarget, } from './link-summary.js';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { OutputLanguage } from '../language.js';
|
|
2
|
+
import type { SummaryLength } from '../shared/contracts.js';
|
|
3
|
+
export declare const SUMMARY_LENGTH_TO_TOKENS: Record<SummaryLength, number>;
|
|
4
|
+
export type SummaryLengthTarget = SummaryLength | {
|
|
5
|
+
maxCharacters: number;
|
|
6
|
+
};
|
|
7
|
+
export declare function pickSummaryLengthForCharacters(maxCharacters: number): SummaryLength;
|
|
8
|
+
export declare function estimateMaxCompletionTokensForCharacters(maxCharacters: number): number;
|
|
9
|
+
export type ShareContextEntry = {
|
|
10
|
+
author: string;
|
|
11
|
+
handle?: string | null;
|
|
12
|
+
text: string;
|
|
13
|
+
likeCount?: number | null;
|
|
14
|
+
reshareCount?: number | null;
|
|
15
|
+
replyCount?: number | null;
|
|
16
|
+
timestamp?: string | null;
|
|
17
|
+
};
|
|
18
|
+
export declare function buildLinkSummaryPrompt({ url, title, siteName, description, content, truncated, hasTranscript, outputLanguage, summaryLength, shares, }: {
|
|
19
|
+
url: string;
|
|
20
|
+
title: string | null;
|
|
21
|
+
siteName: string | null;
|
|
22
|
+
description: string | null;
|
|
23
|
+
content: string;
|
|
24
|
+
truncated: boolean;
|
|
25
|
+
hasTranscript: boolean;
|
|
26
|
+
summaryLength: SummaryLengthTarget;
|
|
27
|
+
outputLanguage?: OutputLanguage | null;
|
|
28
|
+
shares: ShareContextEntry[];
|
|
29
|
+
}): string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const TRANSCRIPTION_TIMEOUT_MS = 600000;
|
|
2
|
+
export declare const MAX_ERROR_DETAIL_CHARS = 200;
|
|
3
|
+
export declare const MAX_OPENAI_UPLOAD_BYTES: number;
|
|
4
|
+
export declare const DEFAULT_SEGMENT_SECONDS = 600;
|
|
5
|
+
export declare const DISABLE_LOCAL_WHISPER_CPP_ENV = "SUMMARIZE_DISABLE_LOCAL_WHISPER_CPP";
|
|
6
|
+
export declare const WHISPER_CPP_MODEL_PATH_ENV = "SUMMARIZE_WHISPER_CPP_MODEL_PATH";
|
|
7
|
+
export declare const WHISPER_CPP_BINARY_ENV = "SUMMARIZE_WHISPER_CPP_BINARY";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { WhisperProgressEvent, WhisperTranscriptionResult } from './types.js';
|
|
2
|
+
export declare function transcribeMediaWithWhisper({ bytes, mediaType, filename, openaiApiKey, falApiKey, totalDurationSeconds, onProgress, }: {
|
|
3
|
+
bytes: Uint8Array;
|
|
4
|
+
mediaType: string;
|
|
5
|
+
filename: string | null;
|
|
6
|
+
openaiApiKey: string | null;
|
|
7
|
+
falApiKey: string | null;
|
|
8
|
+
totalDurationSeconds?: number | null;
|
|
9
|
+
onProgress?: ((event: WhisperProgressEvent) => void) | null;
|
|
10
|
+
}): Promise<WhisperTranscriptionResult>;
|
|
11
|
+
export declare function transcribeMediaFileWithWhisper({ filePath, mediaType, filename, openaiApiKey, falApiKey, segmentSeconds, totalDurationSeconds, onProgress, }: {
|
|
12
|
+
filePath: string;
|
|
13
|
+
mediaType: string;
|
|
14
|
+
filename: string | null;
|
|
15
|
+
openaiApiKey: string | null;
|
|
16
|
+
falApiKey: string | null;
|
|
17
|
+
segmentSeconds?: number;
|
|
18
|
+
totalDurationSeconds?: number | null;
|
|
19
|
+
onProgress?: ((event: WhisperProgressEvent) => void) | null;
|
|
20
|
+
}): Promise<WhisperTranscriptionResult>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function transcribeWithFal(bytes: Uint8Array, mediaType: string, apiKey: string): Promise<string | null>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare function isFfmpegAvailable(): Promise<boolean>;
|
|
2
|
+
export declare function probeMediaDurationSecondsWithFfprobe(filePath: string): Promise<number | null>;
|
|
3
|
+
export declare function runFfmpegSegment({ inputPath, outputPattern, segmentSeconds, }: {
|
|
4
|
+
inputPath: string;
|
|
5
|
+
outputPattern: string;
|
|
6
|
+
segmentSeconds: number;
|
|
7
|
+
}): Promise<void>;
|
|
8
|
+
export declare function runFfmpegTranscodeToMp3({ inputPath, outputPath, }: {
|
|
9
|
+
inputPath: string;
|
|
10
|
+
outputPath: string;
|
|
11
|
+
}): Promise<void>;
|
|
12
|
+
export declare function runFfmpegTranscodeToMp3Lenient({ inputPath, outputPath, }: {
|
|
13
|
+
inputPath: string;
|
|
14
|
+
outputPath: string;
|
|
15
|
+
}): Promise<void>;
|
|
16
|
+
export declare function transcodeBytesToMp3(bytes: Uint8Array): Promise<Uint8Array>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type TranscriptionProvider = 'openai' | 'fal' | 'whisper.cpp';
|
|
2
|
+
export type WhisperTranscriptionResult = {
|
|
3
|
+
text: string | null;
|
|
4
|
+
provider: TranscriptionProvider | null;
|
|
5
|
+
error: Error | null;
|
|
6
|
+
notes: string[];
|
|
7
|
+
};
|
|
8
|
+
export type WhisperProgressEvent = {
|
|
9
|
+
/** 1-based segment index (only when chunked via ffmpeg). */
|
|
10
|
+
partIndex: number | null;
|
|
11
|
+
/** Total number of segments (only when chunked via ffmpeg). */
|
|
12
|
+
parts: number | null;
|
|
13
|
+
/** Best-effort processed duration of the source media. */
|
|
14
|
+
processedDurationSeconds: number | null;
|
|
15
|
+
/** Best-effort total duration of the source media. */
|
|
16
|
+
totalDurationSeconds: number | null;
|
|
17
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function wrapError(prefix: string, error: unknown): Error;
|
|
2
|
+
export declare function toArrayBuffer(view: Uint8Array): ArrayBuffer;
|
|
3
|
+
export declare function ensureWhisperFilenameExtension(name: string, mediaType: string): string;
|
|
4
|
+
export declare function readFirstBytes(filePath: string, maxBytes: number): Promise<Uint8Array>;
|
|
5
|
+
export declare function formatBytes(bytes: number): string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { WhisperProgressEvent, WhisperTranscriptionResult } from './types.js';
|
|
2
|
+
export declare function isWhisperCppReady(): Promise<boolean>;
|
|
3
|
+
export declare function resolveWhisperCppModelNameForDisplay(): Promise<string | null>;
|
|
4
|
+
export declare function transcribeWithWhisperCppFile({ filePath, mediaType, totalDurationSeconds, onProgress, }: {
|
|
5
|
+
filePath: string;
|
|
6
|
+
mediaType: string;
|
|
7
|
+
totalDurationSeconds: number | null;
|
|
8
|
+
onProgress?: ((event: WhisperProgressEvent) => void) | null;
|
|
9
|
+
}): Promise<WhisperTranscriptionResult>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { MAX_OPENAI_UPLOAD_BYTES } from './whisper/constants.js';
|
|
2
|
+
export { transcribeMediaFileWithWhisper, transcribeMediaWithWhisper } from './whisper/core.js';
|
|
3
|
+
export { isFfmpegAvailable, probeMediaDurationSecondsWithFfprobe } from './whisper/ffmpeg.js';
|
|
4
|
+
export type { TranscriptionProvider, WhisperProgressEvent, WhisperTranscriptionResult, } from './whisper/types.js';
|
|
5
|
+
export { isWhisperCppReady, resolveWhisperCppModelNameForDisplay, } from './whisper/whisper-cpp.js';
|
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@steipete/summarize-core",
|
|
3
|
+
"version": "0.7.0",
|
|
4
|
+
"description": "Summarize core library (content extraction + prompts).",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/esm/index.js",
|
|
7
|
+
"module": "./dist/esm/index.js",
|
|
8
|
+
"types": "./dist/types/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/types/index.d.ts",
|
|
12
|
+
"import": "./dist/esm/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./content": {
|
|
15
|
+
"types": "./dist/types/content/index.d.ts",
|
|
16
|
+
"import": "./dist/esm/content/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./prompts": {
|
|
19
|
+
"types": "./dist/types/prompts/index.d.ts",
|
|
20
|
+
"import": "./dist/esm/prompts/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./language": {
|
|
23
|
+
"types": "./dist/types/language.d.ts",
|
|
24
|
+
"import": "./dist/esm/language.js"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist",
|
|
29
|
+
"README.md"
|
|
30
|
+
],
|
|
31
|
+
"packageManager": "pnpm@10.25.0+sha512.5e82639027af37cf832061bcc6d639c219634488e0f2baebe785028a793de7b525ffcd3f7ff574f5e9860654e098fe852ba8ac5dd5cefe1767d23a020a92f501",
|
|
32
|
+
"engines": {
|
|
33
|
+
"node": ">=22"
|
|
34
|
+
},
|
|
35
|
+
"scripts": {
|
|
36
|
+
"clean": "rm -rf dist",
|
|
37
|
+
"build": "pnpm clean && tsc -p tsconfig.build.json",
|
|
38
|
+
"typecheck": "tsc -p tsconfig.build.json --noEmit"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@fal-ai/client": "^1.2.1",
|
|
42
|
+
"@mozilla/readability": "0.6.0",
|
|
43
|
+
"cheerio": "^1.1.2",
|
|
44
|
+
"es-toolkit": "^1.43.0",
|
|
45
|
+
"jsdom": "27.3.0",
|
|
46
|
+
"sanitize-html": "^2.17.0"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@types/jsdom": "^27.0.0",
|
|
50
|
+
"@types/node": "^25.0.3",
|
|
51
|
+
"@types/sanitize-html": "^2.16.0",
|
|
52
|
+
"typescript": "^5.9.3"
|
|
53
|
+
}
|
|
54
|
+
}
|