@c3-oss/prosa 0.3.1 → 0.5.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/dist/index.d.ts CHANGED
@@ -38,6 +38,11 @@ declare function initBundle(rootPath: string): Promise<Bundle>;
38
38
  * than the current code expects.
39
39
  */
40
40
  declare function openBundle(rootPath: string): Promise<Bundle>;
41
+ /**
42
+ * Open an existing bundle or transparently initialize one if the store path is
43
+ * missing or has not been initialized yet.
44
+ */
45
+ declare function openOrInitBundle(rootPath: string): Promise<Bundle>;
41
46
  declare function closeBundle(bundle: Bundle): void;
42
47
 
43
48
  declare function runMigrations(db: Db): {
@@ -46,7 +51,7 @@ declare function runMigrations(db: Db): {
46
51
  declare function currentSchemaVersion(db: Db): number;
47
52
 
48
53
  declare const PROSA_PARSER_VERSION = "0.1.0";
49
- declare const PROSA_SCHEMA_VERSION = 2;
54
+ declare const PROSA_SCHEMA_VERSION = 4;
50
55
 
51
56
  type Compression = 'zstd' | 'none';
52
57
 
@@ -233,6 +238,8 @@ interface SearchIndexStatus {
233
238
  indexed_doc_count: number;
234
239
  updated_at: string;
235
240
  error_message: string | null;
241
+ last_indexed_rowid: number | null;
242
+ schema_fingerprint: string | null;
236
243
  }
237
244
  declare function enableFts5Triggers(bundle: Bundle): void;
238
245
  declare function disableFts5Triggers(bundle: Bundle): void;
@@ -240,10 +247,17 @@ declare function getSearchIndexStatuses(bundle: Bundle): SearchIndexStatus[];
240
247
  declare function getSearchIndexStatus(bundle: Bundle, engine: SearchEngine): SearchIndexStatus | null;
241
248
  declare function markIndexesAfterImport(bundle: Bundle, options: {
242
249
  changed: boolean;
243
- fts5Deferred: boolean;
244
250
  }): void;
245
251
  declare function rebuildFts5Index(bundle: Bundle): SearchIndexStatus;
246
- declare function rebuildTantivyIndex(bundle: Bundle): Promise<SearchIndexStatus>;
252
+ interface RebuildTantivyOptions {
253
+ /**
254
+ * Force a full re-index even when an incremental run would be valid.
255
+ * Surfaced by the `--overwrite` flag on `prosa index tantivy` and on
256
+ * `prosa compile`.
257
+ */
258
+ overwrite?: boolean;
259
+ }
260
+ declare function rebuildTantivyIndex(bundle: Bundle, options?: RebuildTantivyOptions): Promise<SearchIndexStatus>;
247
261
 
248
262
  interface SearchHit {
249
263
  doc_id: string;
@@ -306,6 +320,7 @@ interface CompileImportSummary {
306
320
  importedAny: boolean;
307
321
  tantivy: TantivyCompileSummary | null;
308
322
  tantivyError: string | null;
323
+ fts5Error: string | null;
309
324
  }
310
325
  interface ParquetCompileSummary {
311
326
  outDir: string;
@@ -320,8 +335,14 @@ declare function resolveCompilePath(p: string): string;
320
335
  declare function runCompileImports(options: {
321
336
  bundle: Bundle;
322
337
  providers: CompileProviderConfig[];
323
- deferIndex: boolean;
324
338
  sessionsPath?: string;
339
+ /**
340
+ * Force a full rebuild of derived indexes after import. Tantivy is the
341
+ * only sidecar with an incremental path today, so this currently flips
342
+ * Tantivy to a from-scratch rebuild; FTS5 and Parquet are always
343
+ * full-rewrite. Surfaced by `prosa compile … --overwrite`.
344
+ */
345
+ overwrite?: boolean;
325
346
  logger?: CompileLogger;
326
347
  onProviderComplete?: (summary: ProviderCompileSummary) => void;
327
348
  onTantivyComplete?: (summary: TantivyCompileSummary) => void;
@@ -331,15 +352,10 @@ declare function exportCompileParquet(options: {
331
352
  logger?: CompileLogger;
332
353
  }): Promise<ParquetCompileSummary>;
333
354
 
334
- /**
335
- * Render a session into Markdown. Big tool outputs aren't dumped inline:
336
- * we show a preview line plus a `[object: blake3:…]` reference, leaving the
337
- * raw bytes in the CAS for downstream tools.
338
- */
339
- declare function exportSessionMarkdown(bundle: Bundle, sessionId: string): Promise<string>;
340
-
341
355
  declare const PARQUET_TABLES: readonly ["objects", "source_files", "import_batches", "raw_records", "import_errors", "uncertainties", "projects", "sessions", "turns", "events", "messages", "content_blocks", "tool_calls", "tool_results", "artifacts", "edges", "search_docs"];
356
+ declare const ANALYTICS_VIEWS: readonly ["session_facts", "tool_usage_facts", "error_facts", "model_usage", "project_activity"];
342
357
  type ParquetTable = (typeof PARQUET_TABLES)[number];
358
+ type AnalyticsView = (typeof ANALYTICS_VIEWS)[number];
343
359
  interface ParquetExportOptions {
344
360
  bundlePath: string;
345
361
  outDir?: string;
@@ -361,6 +377,71 @@ interface DuckDbQueryResult {
361
377
  declare function exportBundleParquet(options: ParquetExportOptions): Promise<ParquetExportResult>;
362
378
  declare function queryDuckDbParquet(options: DuckDbQueryOptions): Promise<DuckDbQueryResult>;
363
379
 
380
+ declare const ANALYTICS_REPORTS: readonly ["sessions", "tools", "errors", "models", "projects"];
381
+ type AnalyticsReport = (typeof ANALYTICS_REPORTS)[number];
382
+ type AnalyticsDialect = 'sqlite' | 'duckdb';
383
+ interface AnalyticsReportFilters {
384
+ source?: string;
385
+ since?: string;
386
+ until?: string;
387
+ limit?: number;
388
+ toolName?: string;
389
+ canonicalType?: string;
390
+ errorsOnly?: boolean;
391
+ category?: string;
392
+ model?: string;
393
+ project?: string;
394
+ sessionId?: string;
395
+ sourcePathSubstring?: string;
396
+ }
397
+ interface AnalyticsReportOptions {
398
+ parquetDir: string;
399
+ report: AnalyticsReport;
400
+ filters?: AnalyticsReportFilters;
401
+ }
402
+ interface AnalyticsBundleReportOptions {
403
+ bundle: Bundle;
404
+ report: AnalyticsReport;
405
+ filters?: AnalyticsReportFilters;
406
+ }
407
+ declare function runAnalyticsReport(options: AnalyticsReportOptions): Promise<DuckDbQueryResult>;
408
+ declare function runAnalyticsReportFromBundle(options: AnalyticsBundleReportOptions): DuckDbQueryResult;
409
+
410
+ type ToolCallEntity = 'tool_call' | 'artifact';
411
+ interface ToolCallEvidence {
412
+ entity_type: ToolCallEntity;
413
+ session_id: string | null;
414
+ tool_call_id: string | null;
415
+ artifact_id: string | null;
416
+ tool_name: string | null;
417
+ canonical_tool_type: string | null;
418
+ command: string | null;
419
+ path: string | null;
420
+ status: string | null;
421
+ timestamp_start: string | null;
422
+ is_error: 0 | 1 | null;
423
+ exit_code: number | null;
424
+ preview: string | null;
425
+ }
426
+ interface ToolCallFilters {
427
+ sessionId?: string;
428
+ toolName?: string;
429
+ canonicalType?: string;
430
+ pathSubstring?: string;
431
+ errorsOnly?: boolean;
432
+ sinceIso?: string;
433
+ untilIso?: string;
434
+ limit?: number;
435
+ }
436
+ declare function listToolCalls(bundle: Bundle, filters?: ToolCallFilters): ToolCallEvidence[];
437
+
438
+ /**
439
+ * Render a session into Markdown. Big tool outputs aren't dumped inline:
440
+ * we show a preview line plus a `[object: blake3:…]` reference, leaving the
441
+ * raw bytes in the CAS for downstream tools.
442
+ */
443
+ declare function exportSessionMarkdown(bundle: Bundle, sessionId: string): Promise<string>;
444
+
364
445
  interface CompileResult$3 {
365
446
  batch: ImportBatch;
366
447
  counts: ImportCounts;
@@ -385,4 +466,4 @@ interface CompileResult {
385
466
  }
386
467
  declare function compileCursor(bundle: Bundle, root: string, options?: CompileOptions): Promise<CompileResult>;
387
468
 
388
- export { type Bundle, type BundleManifest, COMPILE_PROVIDERS, type CanonicalToolType, type CompileResult$2 as ClaudeCompileResult, type CompileResult$3 as CodexCompileResult, type CompileImportSummary, type CompileLogger, type CompileOptions, type CompileProviderConfig, type Confidence, type CompileResult as CursorCompileResult, type DuckDbQueryOptions, type DuckDbQueryResult, type EdgeType, type CompileResult$1 as GeminiCompileResult, type ImportBatch, type ImportCounts, type MessageRole, type ObjectId, type ObjectMeta, PARQUET_TABLES, PROSA_PARSER_VERSION, PROSA_SCHEMA_VERSION, type ParquetCompileSummary, type ParquetExportOptions, type ParquetExportResult, type ParquetTable, type ProviderCompileSummary, type RegisterResult, type SearchEngine, type SearchHit, type SearchIndexStatus, type SearchOptions, type SessionDetail, type SessionDetailEvent, type SessionListFilters, type SessionRow, type SessionRowFull, type SourceFileRow, type SourceTool, type TantivyCompileSummary, type ToolCallStatus, closeBundle, compileClaude, compileCodex, compileCursor, compileGemini, countSessions, currentSchemaVersion, defaultBundlePath, disableFts5Triggers, emptyCounts, enableFts5Triggers, exportBundleParquet, exportCompileParquet, exportSessionMarkdown, finishBatch, getBytes, getCompileProvider, getJson, getObjectMeta, getSearchIndexStatus, getSearchIndexStatuses, getSession, getText, initBundle, listSessions, markIndexesAfterImport, openBundle, putBytes, putJson, putText, queryDuckDbParquet, rebuildFts5Index, rebuildTantivyIndex, recordError, registerSourceFile, resolveCompilePath, runCompileImports, runMigrations, searchFullText, startBatch };
469
+ export { ANALYTICS_REPORTS, ANALYTICS_VIEWS, type AnalyticsBundleReportOptions, type AnalyticsDialect, type AnalyticsReport, type AnalyticsReportFilters, type AnalyticsReportOptions, type AnalyticsView, type Bundle, type BundleManifest, COMPILE_PROVIDERS, type CanonicalToolType, type CompileResult$2 as ClaudeCompileResult, type CompileResult$3 as CodexCompileResult, type CompileImportSummary, type CompileLogger, type CompileOptions, type CompileProviderConfig, type Confidence, type CompileResult as CursorCompileResult, type DuckDbQueryOptions, type DuckDbQueryResult, type EdgeType, type CompileResult$1 as GeminiCompileResult, type ImportBatch, type ImportCounts, type MessageRole, type ObjectId, type ObjectMeta, PARQUET_TABLES, PROSA_PARSER_VERSION, PROSA_SCHEMA_VERSION, type ParquetCompileSummary, type ParquetExportOptions, type ParquetExportResult, type ParquetTable, type ProviderCompileSummary, type RegisterResult, type SearchEngine, type SearchHit, type SearchIndexStatus, type SearchOptions, type SessionDetail, type SessionDetailEvent, type SessionListFilters, type SessionRow, type SessionRowFull, type SourceFileRow, type SourceTool, type TantivyCompileSummary, type ToolCallEntity, type ToolCallEvidence, type ToolCallFilters, type ToolCallStatus, closeBundle, compileClaude, compileCodex, compileCursor, compileGemini, countSessions, currentSchemaVersion, defaultBundlePath, disableFts5Triggers, emptyCounts, enableFts5Triggers, exportBundleParquet, exportCompileParquet, exportSessionMarkdown, finishBatch, getBytes, getCompileProvider, getJson, getObjectMeta, getSearchIndexStatus, getSearchIndexStatuses, getSession, getText, initBundle, listSessions, listToolCalls, markIndexesAfterImport, openBundle, openOrInitBundle, putBytes, putJson, putText, queryDuckDbParquet, rebuildFts5Index, rebuildTantivyIndex, recordError, registerSourceFile, resolveCompilePath, runAnalyticsReport, runAnalyticsReportFromBundle, runCompileImports, runMigrations, searchFullText, startBatch };