/** * SmartSummarization -- extractive summarisation, digests and categorisation * over text the caller supplies. * * WHAT WAS HERE: every one of the eight operations this tool publishes * returned `{ success: true, data: { result: " completed * successfully" } }` with a hard-coded `confidence: 0.85`, having read none of * its input and computed nothing. The tool was wired into the server, listed * in tools/list and carried no test. That is the worst defect class in this * repository: not a wrong answer, which a caller can notice, but a fabricated * one that is indistinguishable from a real result. * * TWO CONSEQUENCES FOR THE SHAPE OF THIS FILE: * * 1. `confidence` is gone from the result. The old value was not a measurement * of anything, and no honest number belongs in its place: an extractive * summary is not a probabilistic claim. Each operation instead returns the * figures it actually computed -- scores, shares, counts -- which a caller * can check against their own text. * * 2. An operation whose inputs are absent REFUSES, naming the missing key. * Defaulting is how the fabrication came to exist: once a missing input has * a stand-in, a call with no input at all still returns success. * * Nothing here generates prose. Summaries select sentences the caller wrote. * This package has no language model, and inventing a sentence would be the * same defect in a new costume. */ import type { CacheEngine } from '../../core/cache-engine.js'; import type { TokenCounter } from '../../core/token-counter.js'; import type { MetricsCollector } from '../../core/metrics.js'; import { type Category } from './text-core.js'; import { EXPORT_FORMATS, type ExportFormat } from './render-core.js'; /** * The operations, in one place: the TS union and the published enum are both * derived from this array, so they cannot drift apart. */ export declare const SMART_SUMMARIZATION_OPERATIONS: readonly ["summarize", "create-digest", "compare-periods", "extract-insights", "highlight-changes", "categorize", "schedule", "export"]; export type SmartSummarizationOperation = (typeof SMART_SUMMARIZATION_OPERATIONS)[number]; export { EXPORT_FORMATS, type ExportFormat }; /** * Defaults, collected so every one of them is visible at once. Each is a * presentation choice -- how many sentences, how many terms -- never a * stand-in for a missing input. */ export declare const SMART_SUMMARIZATION_DEFAULTS: Readonly<{ sentenceCount: 3; sentencesPerDocument: 1; termLimit: 10; occurrences: 5; contextLines: 3; }>; /** One document in a digest. */ export interface SummarizationDocument { title?: string; text: string; } /** One timestamped item `schedule` buckets into digest windows. */ export interface ScheduleItem { /** ISO 8601 timestamp. */ at: string; text?: string; } export interface SmartSummarizationOptions { operation: SmartSummarizationOperation; /** summarize, extract-insights, categorize. */ text?: string; /** create-digest. */ documents?: SummarizationDocument[]; /** compare-periods, highlight-changes. */ before?: string; after?: string; /** categorize. */ categories?: Category[]; /** extract-insights: other documents the key terms are scored against. */ corpus?: string[]; /** schedule. */ items?: ScheduleItem[]; intervalHours?: number; startAt?: string; occurrences?: number; /** export. */ format?: ExportFormat; payload?: unknown; /** Presentation. */ sentenceCount?: number; sentencesPerDocument?: number; termLimit?: number; contextLines?: number; useCache?: boolean; } export interface SmartSummarizationResult { success: boolean; operation: string; data: Record; metadata: { tokensUsed: number; tokensSaved: number; cacheHit: boolean; processingTime: number; }; } export declare class SmartSummarization { private cache; private tokenCounter; private metricsCollector; constructor(cache: CacheEngine, tokenCounter: TokenCounter, metricsCollector: MetricsCollector); run(options: SmartSummarizationOptions): Promise; /** * One branch per published operation, each naming the operation it performs. * No fall-through: a value added to the published enum without an * implementation here reaches the default and is refused, instead of being * silently serviced as whichever branch happened to be last. */ private compute; private summarizeOne; private createDigest; private comparePeriods; private extractInsights; private highlightChanges; private categorizeText; /** * Buckets timestamped items into fixed digest windows and reports the next * window after the last item. Real arithmetic over the caller's own * timestamps; nothing is enqueued, because this package runs no job store * and reporting a scheduled job that does not exist would be a fabrication. */ private schedule; private exportPayload; } export declare const SMARTSUMMARIZATIONTOOL: { readonly name: "smart-summarization"; readonly description: "Extractive summarisation, digests, period comparison and categorisation over text you supply. Selects sentences from the input; never generates prose."; readonly inputSchema: { readonly type: "object"; readonly properties: { readonly operation: { readonly type: "string"; readonly enum: readonly ["summarize", "create-digest", "compare-periods", "extract-insights", "highlight-changes", "categorize", "schedule", "export"]; readonly description: "Operation to perform"; }; readonly text: { readonly type: "string"; readonly minLength: 1; readonly description: "The text to work on. Required by summarize, extract-insights and categorize."; }; readonly documents: { readonly type: "array"; readonly minItems: 1; readonly description: "Documents to digest. Required by create-digest."; readonly items: { readonly type: "object"; readonly properties: { readonly title: { readonly type: "string"; readonly description: "Shown in the digest entry"; }; readonly text: { readonly type: "string"; readonly minLength: 1; readonly description: "Document body"; }; }; readonly required: readonly ["text"]; }; }; readonly before: { readonly type: "string"; readonly description: "Earlier text. Required by compare-periods and highlight-changes."; }; readonly after: { readonly type: "string"; readonly description: "Later text. Required by compare-periods and highlight-changes."; }; readonly categories: { readonly type: "array"; readonly minItems: 1; readonly description: "Your taxonomy. Required by categorize; there is no built-in one."; readonly items: { readonly type: "object"; readonly properties: { readonly name: { readonly type: "string"; readonly minLength: 1; readonly description: "Category name"; }; readonly terms: { readonly type: "array"; readonly minItems: 1; readonly items: { readonly type: "string"; readonly minLength: 1; }; readonly description: "Terms evidencing the category, matched whole"; }; }; readonly required: readonly ["name", "terms"]; }; }; readonly corpus: { readonly type: "array"; readonly items: { readonly type: "string"; }; readonly description: "Other documents to score key terms against (extract-insights)"; }; readonly items: { readonly type: "array"; readonly minItems: 1; readonly description: "Timestamped items to bucket. Required by schedule."; readonly items: { readonly type: "object"; readonly properties: { readonly at: { readonly type: "string"; readonly minLength: 1; readonly description: "ISO 8601 instant"; }; readonly text: { readonly type: "string"; readonly description: "Item body"; }; }; readonly required: readonly ["at"]; }; }; readonly intervalHours: { readonly type: "number"; readonly exclusiveMinimum: 0; readonly description: "Digest window length in hours. Required by schedule."; }; readonly startAt: { readonly type: "string"; readonly minLength: 1; readonly description: "ISO 8601 instant the first window opens; defaults to the earliest item"; }; readonly occurrences: { readonly type: "integer"; readonly minimum: 1; readonly description: "How many upcoming windows to report (schedule)"; }; readonly format: { readonly type: "string"; readonly enum: readonly ["markdown", "json", "csv"]; readonly description: "Output format. Required by export."; }; readonly payload: { readonly description: "The data to render. Required by export; csv and markdown need an object or an array of objects."; }; readonly sentenceCount: { readonly type: "integer"; readonly minimum: 1; readonly description: "Sentences to select (summarize)"; }; readonly sentencesPerDocument: { readonly type: "integer"; readonly minimum: 1; readonly description: "Sentences per digest entry (create-digest)"; }; readonly termLimit: { readonly type: "integer"; readonly minimum: 1; readonly description: "How many terms to return"; }; readonly contextLines: { readonly type: "integer"; readonly minimum: 1; readonly description: "Unified-diff context lines (highlight-changes)"; }; readonly useCache: { readonly type: "boolean"; readonly default: true; readonly description: "Enable caching"; }; }; readonly required: readonly ["operation"]; readonly anyOf: readonly [{ readonly properties: { readonly operation: { readonly const: "summarize"; }; }; readonly required: readonly ["operation", "text"]; }, { readonly properties: { readonly operation: { readonly const: "create-digest"; }; }; readonly required: readonly ["operation", "documents"]; }, { readonly properties: { readonly operation: { readonly const: "compare-periods"; }; }; readonly required: readonly ["operation", "before", "after"]; }, { readonly properties: { readonly operation: { readonly const: "extract-insights"; }; }; readonly required: readonly ["operation", "text"]; }, { readonly properties: { readonly operation: { readonly const: "highlight-changes"; }; }; readonly required: readonly ["operation", "before", "after"]; }, { readonly properties: { readonly operation: { readonly const: "categorize"; }; }; readonly required: readonly ["operation", "text", "categories"]; }, { readonly properties: { readonly operation: { readonly const: "schedule"; }; }; readonly required: readonly ["operation", "items", "intervalHours"]; }, { readonly properties: { readonly operation: { readonly const: "export"; }; }; readonly required: readonly ["operation", "format", "payload"]; }]; }; }; export declare function runSmartSummarization(options: SmartSummarizationOptions): Promise; //# sourceMappingURL=smart-summarization.d.ts.map