@redaksjon/protokoll-engine 0.1.3 → 0.1.4-dev.20260216151443.e1454c9

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 (163) hide show
  1. package/dist/agentic/executor.d.ts.map +1 -1
  2. package/dist/agentic/types.d.ts +4 -1
  3. package/dist/agentic/types.d.ts.map +1 -1
  4. package/dist/index.d.ts +2 -0
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +8 -5
  7. package/dist/index.js.map +1 -1
  8. package/dist/index10.js +4 -3
  9. package/dist/index10.js.map +1 -1
  10. package/dist/index11.js +2 -2
  11. package/dist/index12.js +3 -124
  12. package/dist/index12.js.map +1 -1
  13. package/dist/index13.js +101 -100
  14. package/dist/index13.js.map +1 -1
  15. package/dist/index14.js +109 -281
  16. package/dist/index14.js.map +1 -1
  17. package/dist/index15.js +285 -89
  18. package/dist/index15.js.map +1 -1
  19. package/dist/index16.js +97 -104
  20. package/dist/index16.js.map +1 -1
  21. package/dist/index17.js +18 -179
  22. package/dist/index17.js.map +1 -1
  23. package/dist/index18.js +102 -48
  24. package/dist/index18.js.map +1 -1
  25. package/dist/index19.js +182 -16
  26. package/dist/index19.js.map +1 -1
  27. package/dist/index2.js +3 -3
  28. package/dist/index20.js +48 -100
  29. package/dist/index20.js.map +1 -1
  30. package/dist/index21.js +16 -23
  31. package/dist/index21.js.map +1 -1
  32. package/dist/index22.js +98 -42
  33. package/dist/index22.js.map +1 -1
  34. package/dist/index23.js +19 -112
  35. package/dist/index23.js.map +1 -1
  36. package/dist/index24.js +42 -323
  37. package/dist/index24.js.map +1 -1
  38. package/dist/index25.js +114 -52
  39. package/dist/index25.js.map +1 -1
  40. package/dist/index26.js +339 -37
  41. package/dist/index26.js.map +1 -1
  42. package/dist/index27.js +51 -121
  43. package/dist/index27.js.map +1 -1
  44. package/dist/index28.js +36 -155
  45. package/dist/index28.js.map +1 -1
  46. package/dist/index29.js +114 -150
  47. package/dist/index29.js.map +1 -1
  48. package/dist/index3.js +2 -2
  49. package/dist/index30.js +171 -161
  50. package/dist/index30.js.map +1 -1
  51. package/dist/index31.js +141 -401
  52. package/dist/index31.js.map +1 -1
  53. package/dist/index32.js +158 -146
  54. package/dist/index32.js.map +1 -1
  55. package/dist/index33.js +425 -130
  56. package/dist/index33.js.map +1 -1
  57. package/dist/index34.js +145 -40
  58. package/dist/index34.js.map +1 -1
  59. package/dist/index35.js +159 -83
  60. package/dist/index35.js.map +1 -1
  61. package/dist/index36.js +46 -439
  62. package/dist/index36.js.map +1 -1
  63. package/dist/index37.js +91 -419
  64. package/dist/index37.js.map +1 -1
  65. package/dist/index38.js +447 -66
  66. package/dist/index38.js.map +1 -1
  67. package/dist/index39.js +424 -115
  68. package/dist/index39.js.map +1 -1
  69. package/dist/index4.js +2 -2
  70. package/dist/index40.js +78 -290
  71. package/dist/index40.js.map +1 -1
  72. package/dist/index41.js +112 -44
  73. package/dist/index41.js.map +1 -1
  74. package/dist/index42.js +115 -44
  75. package/dist/index42.js.map +1 -1
  76. package/dist/index43.js +295 -35
  77. package/dist/index43.js.map +1 -1
  78. package/dist/index44.js +270 -218
  79. package/dist/index44.js.map +1 -1
  80. package/dist/index45.js +131 -150
  81. package/dist/index45.js.map +1 -1
  82. package/dist/index46.js +117 -73
  83. package/dist/index46.js.map +1 -1
  84. package/dist/index47.js +45 -74
  85. package/dist/index47.js.map +1 -1
  86. package/dist/index48.js +48 -5
  87. package/dist/index48.js.map +1 -1
  88. package/dist/index49.js +33 -145
  89. package/dist/index49.js.map +1 -1
  90. package/dist/index5.js +3 -3
  91. package/dist/index50.js +216 -203
  92. package/dist/index50.js.map +1 -1
  93. package/dist/index51.js +153 -39
  94. package/dist/index51.js.map +1 -1
  95. package/dist/index52.js +74 -38
  96. package/dist/index52.js.map +1 -1
  97. package/dist/index53.js +74 -33
  98. package/dist/index53.js.map +1 -1
  99. package/dist/index54.js +149 -6
  100. package/dist/index54.js.map +1 -1
  101. package/dist/index55.js +224 -6
  102. package/dist/index55.js.map +1 -1
  103. package/dist/index56.js +42 -143
  104. package/dist/index56.js.map +1 -1
  105. package/dist/index57.js +43 -15
  106. package/dist/index57.js.map +1 -1
  107. package/dist/index58.js +35 -2
  108. package/dist/index58.js.map +1 -1
  109. package/dist/index59.js +5 -14
  110. package/dist/index59.js.map +1 -1
  111. package/dist/index6.js +4 -4
  112. package/dist/index6.js.map +1 -1
  113. package/dist/index60.js +6 -2
  114. package/dist/index60.js.map +1 -1
  115. package/dist/index61.js +6 -4
  116. package/dist/index61.js.map +1 -1
  117. package/dist/index62.js +151 -0
  118. package/dist/index62.js.map +1 -0
  119. package/dist/index63.js +17 -0
  120. package/dist/index63.js.map +1 -0
  121. package/dist/index64.js +4 -0
  122. package/dist/index64.js.map +1 -0
  123. package/dist/index65.js +17 -0
  124. package/dist/index65.js.map +1 -0
  125. package/dist/index66.js +4 -0
  126. package/dist/index66.js.map +1 -0
  127. package/dist/index67.js +6 -0
  128. package/dist/index67.js.map +1 -0
  129. package/dist/index7.js +2 -2
  130. package/dist/index8.js +1 -1
  131. package/dist/index9.js +4 -4
  132. package/dist/phases/simple-replace.d.ts +2 -1
  133. package/dist/phases/simple-replace.d.ts.map +1 -1
  134. package/dist/pipeline/orchestrator.d.ts.map +1 -1
  135. package/dist/pipeline/types.d.ts +3 -0
  136. package/dist/pipeline/types.d.ts.map +1 -1
  137. package/dist/routing/classifier.d.ts +2 -1
  138. package/dist/routing/classifier.d.ts.map +1 -1
  139. package/dist/routing/index.d.ts +2 -1
  140. package/dist/routing/index.d.ts.map +1 -1
  141. package/dist/routing/types.d.ts +1 -1
  142. package/dist/routing/types.d.ts.map +1 -1
  143. package/dist/transcript/index.d.ts +1 -0
  144. package/dist/transcript/index.d.ts.map +1 -1
  145. package/dist/transcript/operations.d.ts +14 -1
  146. package/dist/transcript/operations.d.ts.map +1 -1
  147. package/dist/transcript/upload-utils.d.ts +80 -0
  148. package/dist/transcript/upload-utils.d.ts.map +1 -0
  149. package/dist/util/enhancement-logger.d.ts +19 -0
  150. package/dist/util/enhancement-logger.d.ts.map +1 -0
  151. package/dist/util/metadata.d.ts +1 -0
  152. package/dist/util/metadata.d.ts.map +1 -1
  153. package/dist/weighting/builder.d.ts +126 -0
  154. package/dist/weighting/builder.d.ts.map +1 -0
  155. package/dist/weighting/index.d.ts +12 -0
  156. package/dist/weighting/index.d.ts.map +1 -0
  157. package/dist/weighting/prepositioning.d.ts +55 -0
  158. package/dist/weighting/prepositioning.d.ts.map +1 -0
  159. package/dist/weighting/provider.d.ts +78 -0
  160. package/dist/weighting/provider.d.ts.map +1 -0
  161. package/dist/weighting/types.d.ts +119 -0
  162. package/dist/weighting/types.d.ts.map +1 -0
  163. package/package.json +2 -2
@@ -0,0 +1,78 @@
1
+ import { WeightModel, EntityPrediction, PredictionContext } from './types';
2
+ /**
3
+ * WeightModelProvider
4
+ *
5
+ * Manages a weight model and provides entity prediction queries.
6
+ * Designed to be purely additive - when no model is available, returns empty results
7
+ * without breaking the enhancement pipeline.
8
+ */
9
+ export declare class WeightModelProvider {
10
+ private model;
11
+ constructor(model?: WeightModel | null);
12
+ /**
13
+ * Check if a weight model is available
14
+ *
15
+ * @returns true if model is loaded, false otherwise
16
+ */
17
+ isAvailable(): boolean;
18
+ /**
19
+ * Load a weight model into the provider
20
+ *
21
+ * @param model - Weight model to load
22
+ */
23
+ loadModel(model: WeightModel): void;
24
+ /**
25
+ * Clear the current model
26
+ */
27
+ clearModel(): void;
28
+ /**
29
+ * Get the current model (for inspection/debugging)
30
+ *
31
+ * @returns Current weight model or null
32
+ */
33
+ getModel(): WeightModel | null;
34
+ /**
35
+ * Predict likely entities based on known context
36
+ *
37
+ * Combines two signals:
38
+ * 1. Co-occurrence: entities that appear with the known entities
39
+ * 2. Project-specific: entities common in the given project (boosted by 1.5x)
40
+ *
41
+ * @param context - Prediction context with known entities and project
42
+ * @returns Array of entity predictions sorted by score (descending)
43
+ */
44
+ predictLikelyEntities(context: PredictionContext): EntityPrediction[];
45
+ /**
46
+ * Determine the primary source of a prediction
47
+ *
48
+ * @param entityId - Entity being predicted
49
+ * @param knownEntityIds - Known entities in context
50
+ * @param projectId - Project ID if known
51
+ * @returns Source type
52
+ */
53
+ private determineSource;
54
+ /**
55
+ * Get project-specific entity frequencies
56
+ *
57
+ * Returns a map of entity IDs to their frequency counts for a given project.
58
+ * Used by the routing classifier to boost project confidence when entities match.
59
+ *
60
+ * @param projectId - Project identifier
61
+ * @returns Entity frequency map or null if project not in model
62
+ */
63
+ getProjectFrequencies(projectId: string): Record<string, number> | null;
64
+ /**
65
+ * Get statistics about the current model
66
+ *
67
+ * @returns Model statistics or null if no model loaded
68
+ */
69
+ getStatistics(): {
70
+ transcriptCount: number;
71
+ entityCount: number;
72
+ cooccurrenceCount: number;
73
+ projectCount: number;
74
+ builtAt: string;
75
+ lastUpdatedAt: string;
76
+ } | null;
77
+ }
78
+ //# sourceMappingURL=provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/weighting/provider.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE3E;;;;;;GAMG;AACH,qBAAa,mBAAmB;IAC5B,OAAO,CAAC,KAAK,CAAqB;gBAEtB,KAAK,GAAE,WAAW,GAAG,IAAW;IAI5C;;;;OAIG;IACH,WAAW,IAAI,OAAO;IAItB;;;;OAIG;IACH,SAAS,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI;IAInC;;OAEG;IACH,UAAU,IAAI,IAAI;IAIlB;;;;OAIG;IACH,QAAQ,IAAI,WAAW,GAAG,IAAI;IAI9B;;;;;;;;;OASG;IACH,qBAAqB,CAAC,OAAO,EAAE,iBAAiB,GAAG,gBAAgB,EAAE;IA2DrE;;;;;;;OAOG;IACH,OAAO,CAAC,eAAe;IAsBvB;;;;;;;;OAQG;IACH,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI;IAOvE;;;;OAIG;IACH,aAAa,IAAI;QACb,eAAe,EAAE,MAAM,CAAC;QACxB,WAAW,EAAE,MAAM,CAAC;QACpB,iBAAiB,EAAE,MAAM,CAAC;QAC1B,YAAY,EAAE,MAAM,CAAC;QACrB,OAAO,EAAE,MAAM,CAAC;QAChB,aAAa,EAAE,MAAM,CAAC;KACzB,GAAG,IAAI;CAkBX"}
@@ -0,0 +1,119 @@
1
+ /**
2
+ * Weight Model Types
3
+ *
4
+ * Data structures for entity co-occurrence tracking and weight model management.
5
+ * The weight model tracks which entities appear together in transcripts to improve
6
+ * routing accuracy and LLM enhancement prepositioning.
7
+ */
8
+ /**
9
+ * Per-entity co-occurrence counts: entityId -> cooccurringEntityId -> count
10
+ *
11
+ * Example:
12
+ * {
13
+ * "protokoll": {
14
+ * "redaksjon": 47,
15
+ * "mcp": 31,
16
+ * "tim": 22
17
+ * },
18
+ * "tim": {
19
+ * "redaksjon": 58,
20
+ * "brennpunkt": 12
21
+ * }
22
+ * }
23
+ */
24
+ export interface EntityCooccurrence {
25
+ [entityId: string]: {
26
+ [cooccurringEntityId: string]: number;
27
+ };
28
+ }
29
+ /**
30
+ * Per-project entity frequency counts: projectId -> entityId -> count
31
+ *
32
+ * Example:
33
+ * {
34
+ * "redaksjon": {
35
+ * "protokoll": 47,
36
+ * "mcp": 29,
37
+ * "tim": 22
38
+ * }
39
+ * }
40
+ */
41
+ export interface ProjectEntityFrequency {
42
+ [projectId: string]: {
43
+ [entityId: string]: number;
44
+ };
45
+ }
46
+ /**
47
+ * Per-transcript snapshot of which entities were present.
48
+ * Keyed by transcript UUID. Used for incremental updates:
49
+ * when a transcript's entities change, subtract the old snapshot
50
+ * and add the new one.
51
+ *
52
+ * Example:
53
+ * {
54
+ * "a1b2c3d4-e5f6-7890-abcd-ef1234567890": {
55
+ * "entityIds": ["protokoll", "mcp", "tim", "redaksjon"],
56
+ * "projectId": "redaksjon"
57
+ * }
58
+ * }
59
+ */
60
+ export interface TranscriptEntitySnapshot {
61
+ [transcriptUuid: string]: {
62
+ entityIds: string[];
63
+ projectId?: string;
64
+ };
65
+ }
66
+ /**
67
+ * Complete weight model structure
68
+ */
69
+ export interface WeightModel {
70
+ /** Entity-to-entity co-occurrence matrix */
71
+ cooccurrence: EntityCooccurrence;
72
+ /** Project-specific entity frequencies */
73
+ byProject: ProjectEntityFrequency;
74
+ /** Tracks which transcripts contributed to the model, keyed by UUID */
75
+ transcriptSnapshots: TranscriptEntitySnapshot;
76
+ /** Model metadata */
77
+ metadata: {
78
+ builtAt: string;
79
+ lastUpdatedAt: string;
80
+ transcriptCount: number;
81
+ entityCount: number;
82
+ version: string;
83
+ };
84
+ }
85
+ /**
86
+ * Configuration for weight model building
87
+ */
88
+ export interface WeightModelConfig {
89
+ /** Maximum number of transcripts to scan (most recent) */
90
+ maxTranscripts: number;
91
+ /** Minimum co-occurrence count to include in output (noise filter) */
92
+ minCooccurrenceCount: number;
93
+ /** Path where the weight model JSON file should be written */
94
+ outputFilePath: string;
95
+ }
96
+ /**
97
+ * Entity prediction result for a given context
98
+ */
99
+ export interface EntityPrediction {
100
+ entityId: string;
101
+ entityName?: string;
102
+ entityType?: 'person' | 'project' | 'term' | 'company';
103
+ score: number;
104
+ source: 'cooccurrence' | 'project' | 'global';
105
+ }
106
+ /**
107
+ * Context for making entity predictions
108
+ */
109
+ export interface PredictionContext {
110
+ /** Known entity IDs in the current context */
111
+ knownEntityIds?: string[];
112
+ /** Project ID if known */
113
+ projectId?: string;
114
+ /** Maximum number of predictions to return */
115
+ maxPredictions?: number;
116
+ /** Minimum score threshold */
117
+ minScore?: number;
118
+ }
119
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/weighting/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH;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,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,cAAc,GAAG,SAAS,GAAG,QAAQ,CAAC;CAC/C;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,8CAA8C;IAC9C,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAE1B,0BAA0B;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,8CAA8C;IAC9C,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,8BAA8B;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redaksjon/protokoll-engine",
3
- "version": "0.1.3",
3
+ "version": "0.1.4-dev.20260216151443.e1454c9",
4
4
  "description": "Processing engine for Protokoll - transcription pipeline, agentic execution, routing, and LLM integration",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -47,7 +47,7 @@
47
47
  "@google/generative-ai": "^0.24.1",
48
48
  "@kjerneverk/riotprompt": "^1.0.6",
49
49
  "@redaksjon/context": "^0.0.7",
50
- "@redaksjon/protokoll-format": "^0.1.1",
50
+ "@redaksjon/protokoll-format": "^0.1.3",
51
51
  "@utilarium/cardigantime": "^0.0.26",
52
52
  "@utilarium/dreadcabinet": "^0.0.16",
53
53
  "dayjs": "^1.11.13",