@redaksjon/protokoll-engine 0.1.1-dev.0 → 0.1.3

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 (58) hide show
  1. package/dist/index25.js +5 -5
  2. package/dist/index31.js +1 -1
  3. package/dist/index31.js.map +1 -1
  4. package/dist/index32.js +2 -2
  5. package/dist/index33.js +4 -4
  6. package/dist/index34.js +1 -1
  7. package/dist/index36.js +0 -2
  8. package/dist/index36.js.map +1 -1
  9. package/dist/index42.js +43 -143
  10. package/dist/index42.js.map +1 -1
  11. package/dist/index43.js +34 -221
  12. package/dist/index43.js.map +1 -1
  13. package/dist/index44.js +233 -43
  14. package/dist/index44.js.map +1 -1
  15. package/dist/index45.js +156 -38
  16. package/dist/index45.js.map +1 -1
  17. package/dist/index46.js +75 -31
  18. package/dist/index46.js.map +1 -1
  19. package/dist/index47.js +73 -46
  20. package/dist/index47.js.map +1 -1
  21. package/dist/index48.js +5 -36
  22. package/dist/index48.js.map +1 -1
  23. package/dist/index49.js +134 -222
  24. package/dist/index49.js.map +1 -1
  25. package/dist/index50.js +201 -138
  26. package/dist/index50.js.map +1 -1
  27. package/dist/index51.js +42 -74
  28. package/dist/index51.js.map +1 -1
  29. package/dist/index52.js +40 -73
  30. package/dist/index52.js.map +1 -1
  31. package/dist/index53.js +33 -18
  32. package/dist/index53.js.map +1 -1
  33. package/dist/index54.js +2 -2
  34. package/dist/index55.js +2 -2
  35. package/dist/index56.js +147 -14
  36. package/dist/index56.js.map +1 -1
  37. package/dist/index57.js +15 -2
  38. package/dist/index57.js.map +1 -1
  39. package/dist/index58.js +2 -15
  40. package/dist/index58.js.map +1 -1
  41. package/dist/index59.js +15 -2
  42. package/dist/index59.js.map +1 -1
  43. package/dist/index60.js +2 -4
  44. package/dist/index60.js.map +1 -1
  45. package/dist/index61.js +6 -0
  46. package/dist/index61.js.map +1 -0
  47. package/dist/out/index.d.ts +23 -0
  48. package/dist/out/index.d.ts.map +1 -0
  49. package/dist/out/manager.d.ts +21 -0
  50. package/dist/out/manager.d.ts.map +1 -0
  51. package/dist/out/types.d.ts +35 -0
  52. package/dist/out/types.d.ts.map +1 -0
  53. package/dist/pipeline/types.d.ts +2 -10
  54. package/dist/pipeline/types.d.ts.map +1 -1
  55. package/dist/transcript/operations.d.ts.map +1 -1
  56. package/package.json +5 -6
  57. package/dist/output/index.d.ts +0 -15
  58. package/dist/output/index.d.ts.map +0 -1
package/dist/index46.js CHANGED
@@ -1,37 +1,81 @@
1
- const create = (_ctx) => ({
2
- name: "store_context",
3
- description: "Store new context information for future use. Use when you learn something new that should be remembered.",
4
- parameters: {
5
- type: "object",
6
- properties: {
7
- entityType: {
8
- type: "string",
9
- enum: ["person", "project", "company", "term"],
10
- description: "Type of entity to store"
11
- },
12
- name: {
13
- type: "string",
14
- description: "Name of the entity"
15
- },
16
- details: {
17
- type: "object",
18
- description: "Additional details about the entity"
19
- }
20
- },
21
- required: ["entityType", "name"]
22
- },
23
- execute: async (args) => {
1
+ import { getLogger } from './index41.js';
2
+
3
+ const create = (config) => {
4
+ const logger = getLogger();
5
+ const createPattern = (soundsLike) => {
6
+ const escaped = soundsLike.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
7
+ const pattern = `\\b${escaped}\\b` ;
8
+ const flags = "gi" ;
9
+ return new RegExp(pattern, flags);
10
+ };
11
+ const applySingleReplacement = (text, mapping) => {
12
+ const pattern = createPattern(mapping.soundsLike);
13
+ const occurrences = [];
14
+ let count = 0;
15
+ const replacements = [];
16
+ let match;
17
+ while ((match = pattern.exec(text)) !== null) {
18
+ const original = match[0];
19
+ let replacement = mapping.correctText;
20
+ replacements.push({
21
+ index: match.index,
22
+ length: original.length,
23
+ replacement
24
+ });
25
+ occurrences.push({
26
+ original,
27
+ replacement,
28
+ position: match.index,
29
+ mapping
30
+ });
31
+ count++;
32
+ }
33
+ let resultText = text;
34
+ for (let i = replacements.length - 1; i >= 0; i--) {
35
+ const { index, length, replacement } = replacements[i];
36
+ resultText = resultText.slice(0, index) + replacement + resultText.slice(index + length);
37
+ }
38
+ if (count > 0) {
39
+ logger.debug(
40
+ `Replaced "${mapping.soundsLike}" → "${mapping.correctText}" (${count} occurrence${count === 1 ? "" : "s"})`
41
+ );
42
+ }
24
43
  return {
25
- success: true,
26
- data: {
27
- stored: false,
28
- message: "Context storage requires --self-update flag. Information noted but not persisted.",
29
- entityType: args.entityType,
30
- name: args.name
44
+ text: resultText,
45
+ count,
46
+ occurrences,
47
+ appliedMappings: count > 0 ? [mapping] : []
48
+ };
49
+ };
50
+ const applyReplacements = (text, mappings) => {
51
+ let resultText = text;
52
+ let totalCount = 0;
53
+ const allOccurrences = [];
54
+ const appliedMappings = [];
55
+ for (const mapping of mappings) {
56
+ const result = applySingleReplacement(resultText, mapping);
57
+ if (result.count > 0) {
58
+ resultText = result.text;
59
+ totalCount += result.count;
60
+ allOccurrences.push(...result.occurrences);
61
+ appliedMappings.push(mapping);
31
62
  }
63
+ }
64
+ logger.debug(
65
+ `Applied ${mappings.length} mappings, made ${totalCount} replacements (${appliedMappings.length} mappings had matches)`
66
+ );
67
+ return {
68
+ text: resultText,
69
+ count: totalCount,
70
+ occurrences: allOccurrences,
71
+ appliedMappings
32
72
  };
33
- }
34
- });
73
+ };
74
+ return {
75
+ applyReplacements,
76
+ applySingleReplacement
77
+ };
78
+ };
35
79
 
36
80
  export { create };
37
81
  //# sourceMappingURL=index46.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index46.js","sources":["../src/agentic/tools/store-context.ts"],"sourcesContent":["/**\n * Store Context Tool\n * \n * Stores new context information for future use.\n */\n\nimport { TranscriptionTool, ToolContext, ToolResult } from '../types';\n\nexport const create = (_ctx: ToolContext): TranscriptionTool => ({\n name: 'store_context',\n description: 'Store new context information for future use. Use when you learn something new that should be remembered.',\n parameters: {\n type: 'object',\n properties: {\n entityType: {\n type: 'string',\n enum: ['person', 'project', 'company', 'term'],\n description: 'Type of entity to store',\n },\n name: {\n type: 'string',\n description: 'Name of the entity',\n },\n details: {\n type: 'object',\n description: 'Additional details about the entity',\n },\n },\n required: ['entityType', 'name'],\n },\n \n execute: async (args: { entityType: string; name: string; details?: any }): Promise<ToolResult> => {\n // This tool requires --self-update flag to actually persist\n // Otherwise it just acknowledges without saving\n \n return {\n success: true,\n data: {\n stored: false,\n message: 'Context storage requires --self-update flag. Information noted but not persisted.',\n entityType: args.entityType,\n name: args.name,\n },\n };\n },\n});\n\n"],"names":[],"mappings":"AAQO,MAAM,MAAA,GAAS,CAAC,IAAA,MAA0C;AAAA,EAC7D,IAAA,EAAM,eAAA;AAAA,EACN,WAAA,EAAa,2GAAA;AAAA,EACb,UAAA,EAAY;AAAA,IACR,IAAA,EAAM,QAAA;AAAA,IACN,UAAA,EAAY;AAAA,MACR,UAAA,EAAY;AAAA,QACR,IAAA,EAAM,QAAA;AAAA,QACN,IAAA,EAAM,CAAC,QAAA,EAAU,SAAA,EAAW,WAAW,MAAM,CAAA;AAAA,QAC7C,WAAA,EAAa;AAAA,OACjB;AAAA,MACA,IAAA,EAAM;AAAA,QACF,IAAA,EAAM,QAAA;AAAA,QACN,WAAA,EAAa;AAAA,OACjB;AAAA,MACA,OAAA,EAAS;AAAA,QACL,IAAA,EAAM,QAAA;AAAA,QACN,WAAA,EAAa;AAAA;AACjB,KACJ;AAAA,IACA,QAAA,EAAU,CAAC,YAAA,EAAc,MAAM;AAAA,GACnC;AAAA,EAEA,OAAA,EAAS,OAAO,IAAA,KAAmF;AAI/F,IAAA,OAAO;AAAA,MACH,OAAA,EAAS,IAAA;AAAA,MACT,IAAA,EAAM;AAAA,QACF,MAAA,EAAQ,KAAA;AAAA,QACR,OAAA,EAAS,mFAAA;AAAA,QACT,YAAY,IAAA,CAAK,UAAA;AAAA,QACjB,MAAM,IAAA,CAAK;AAAA;AACf,KACJ;AAAA,EACJ;AACJ,CAAA;;;;"}
1
+ {"version":3,"file":"index46.js","sources":["../src/util/text-replacer.ts"],"sourcesContent":["/**\n * Text Replacer\n *\n * Performs intelligent text replacements with case preservation and word boundary matching.\n * Core utility for the simple-replace phase.\n *\n * Part of the simple-replace optimization (Phase 2).\n */\n\nimport * as Logging from '@/logging';\nimport { SoundsLikeMapping } from './sounds-like-database';\n\n/**\n * Replacement result for a single occurrence\n */\nexport interface ReplacementOccurrence {\n /** Original text that was replaced */\n original: string;\n\n /** Replacement text */\n replacement: string;\n\n /** Position in the text where replacement occurred */\n position: number;\n\n /** The mapping that was used */\n mapping: SoundsLikeMapping;\n}\n\n/**\n * Result of applying replacements to text\n */\nexport interface ReplacementResult {\n /** The text after replacements */\n text: string;\n\n /** Number of replacements made */\n count: number;\n\n /** Detailed information about each replacement */\n occurrences: ReplacementOccurrence[];\n\n /** Mappings that were applied */\n appliedMappings: SoundsLikeMapping[];\n}\n\n/**\n * Configuration for text replacer\n */\nexport interface TextReplacerConfig {\n /** Preserve case of original text when replacing (default: true) */\n preserveCase?: boolean;\n\n /** Use word boundaries for matching (default: true) */\n useWordBoundaries?: boolean;\n\n /** Case-insensitive matching (default: true) */\n caseInsensitive?: boolean;\n}\n\n/**\n * Instance interface for text replacer\n */\nexport interface Instance {\n /**\n * Apply a set of replacements to text\n */\n applyReplacements(text: string, mappings: SoundsLikeMapping[]): ReplacementResult;\n\n /**\n * Apply a single replacement to text\n */\n applySingleReplacement(text: string, mapping: SoundsLikeMapping): ReplacementResult;\n}\n\n/**\n * Create a text replacer instance\n */\nexport const create = (config?: TextReplacerConfig): Instance => {\n const logger = Logging.getLogger();\n\n const preserveCase = config?.preserveCase ?? true;\n const useWordBoundaries = config?.useWordBoundaries ?? true;\n const caseInsensitive = config?.caseInsensitive ?? true;\n\n /**\n * Determine the case style of a string\n */\n const getCaseStyle = (text: string): 'upper' | 'lower' | 'title' | 'mixed' => {\n // Check for all uppercase first (includes single chars)\n if (text.length > 0 && text === text.toUpperCase() && text.toUpperCase() !== text.toLowerCase()) {\n return 'upper';\n }\n // Check for all lowercase\n if (text === text.toLowerCase()) {\n return 'lower';\n }\n // Check for title case (first char upper, or mixed case starting with upper)\n if (text[0] === text[0].toUpperCase()) {\n return 'title';\n }\n return 'mixed';\n };\n\n /**\n * Apply case style from original to replacement\n *\n * Case preservation means: make the replacement match the case pattern of the original\n * - \"protocol\" (lowercase) → \"protokoll\" (lowercase)\n * - \"Protocol\" (title) → \"Protokoll\" (title)\n * - \"PROTOCOL\" (upper) → \"PROTOKOLL\" (upper)\n */\n const applyCaseStyle = (replacement: string, originalCase: 'upper' | 'lower' | 'title' | 'mixed'): string => {\n switch (originalCase) {\n case 'upper':\n // ALL CAPS in original → ALL CAPS in replacement\n return replacement.toUpperCase();\n case 'lower':\n // all lowercase in original → all lowercase in replacement\n return replacement.toLowerCase();\n case 'title':\n // Title Case in original → Title Case in replacement (first char upper, rest as-is)\n return replacement.charAt(0).toUpperCase() + replacement.slice(1);\n case 'mixed':\n default:\n // Mixed case → preserve replacement's original case\n return replacement;\n }\n };\n\n /**\n * Create a regex pattern for matching\n */\n const createPattern = (soundsLike: string): RegExp => {\n // Escape special regex characters\n const escaped = soundsLike.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n\n // Add word boundaries if enabled\n const pattern = useWordBoundaries ? `\\\\b${escaped}\\\\b` : escaped;\n\n // Create regex with appropriate flags\n const flags = caseInsensitive ? 'gi' : 'g';\n return new RegExp(pattern, flags);\n };\n\n /**\n * Apply a single replacement to text\n */\n const applySingleReplacement = (text: string, mapping: SoundsLikeMapping): ReplacementResult => {\n const pattern = createPattern(mapping.soundsLike);\n const occurrences: ReplacementOccurrence[] = [];\n let count = 0;\n\n // Track positions to avoid double-replacement issues\n const replacements: { index: number; length: number; replacement: string }[] = [];\n\n // Find all matches\n let match: RegExpExecArray | null;\n while ((match = pattern.exec(text)) !== null) {\n const original = match[0];\n let replacement = mapping.correctText;\n\n // Preserve case if enabled\n if (preserveCase) {\n const caseStyle = getCaseStyle(original);\n replacement = applyCaseStyle(replacement, caseStyle);\n }\n\n replacements.push({\n index: match.index,\n length: original.length,\n replacement,\n });\n\n occurrences.push({\n original,\n replacement,\n position: match.index,\n mapping,\n });\n\n count++;\n }\n\n // Apply replacements in reverse order to preserve positions\n let resultText = text;\n for (let i = replacements.length - 1; i >= 0; i--) {\n const { index, length, replacement } = replacements[i];\n resultText = resultText.slice(0, index) + replacement + resultText.slice(index + length);\n }\n\n if (count > 0) {\n logger.debug(\n `Replaced \"${mapping.soundsLike}\" → \"${mapping.correctText}\" ` +\n `(${count} occurrence${count === 1 ? '' : 's'})`\n );\n }\n\n return {\n text: resultText,\n count,\n occurrences,\n appliedMappings: count > 0 ? [mapping] : [],\n };\n };\n\n /**\n * Apply multiple replacements to text\n */\n const applyReplacements = (text: string, mappings: SoundsLikeMapping[]): ReplacementResult => {\n let resultText = text;\n let totalCount = 0;\n const allOccurrences: ReplacementOccurrence[] = [];\n const appliedMappings: SoundsLikeMapping[] = [];\n\n // Apply each mapping sequentially\n for (const mapping of mappings) {\n const result = applySingleReplacement(resultText, mapping);\n\n if (result.count > 0) {\n resultText = result.text;\n totalCount += result.count;\n allOccurrences.push(...result.occurrences);\n appliedMappings.push(mapping);\n }\n }\n\n logger.debug(\n `Applied ${mappings.length} mappings, made ${totalCount} replacements ` +\n `(${appliedMappings.length} mappings had matches)`\n );\n\n return {\n text: resultText,\n count: totalCount,\n occurrences: allOccurrences,\n appliedMappings,\n };\n };\n\n return {\n applyReplacements,\n applySingleReplacement,\n };\n};\n"],"names":["Logging.getLogger"],"mappings":";;AA8EO,MAAM,MAAA,GAAS,CAAC,MAAA,KAA0C;AAC7D,EAAA,MAAM,MAAA,GAASA,SAAQ,EAAU;AAsDjC,EAAA,MAAM,aAAA,GAAgB,CAAC,UAAA,KAA+B;AAElD,IAAA,MAAM,OAAA,GAAU,UAAA,CAAW,OAAA,CAAQ,qBAAA,EAAuB,MAAM,CAAA;AAGhE,IAAA,MAAM,OAAA,GAA8B,CAAA,GAAA,EAAM,OAAO,CAAA,GAAA,CAAA,CAAQ;AAGzD,IA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UAAA;AAAA,MACP,WAAA,EAAa,cAAA;AAAA,MACb;AAAA,KACJ;AAAA,EACJ,CAAA;AAEA,EAAA,OAAO;AAAA,IACH,iBAAA;AAAA,IACA;AAAA,GACJ;AACJ;;;;"}
package/dist/index47.js CHANGED
@@ -1,51 +1,78 @@
1
- import { OpenAI } from 'openai';
2
- import { create } from './index12.js';
3
- import { getLogger } from './index41.js';
4
- import { DEFAULT_TRANSCRIPTION_MODEL } from './index16.js';
1
+ import dayjs from 'dayjs';
2
+ import timezone from './index54.js';
3
+ import utc from './index55.js';
4
+ import 'moment-timezone';
5
5
 
6
- class OpenAIError extends Error {
7
- constructor(message) {
8
- super(message);
9
- this.name = "OpenAIError";
10
- }
11
- }
12
- async function transcribeAudio(filePath, options = {}) {
13
- const logger = getLogger();
14
- const storage$1 = create({ log: logger.debug });
15
- try {
16
- const apiKey = process.env.OPENAI_API_KEY;
17
- if (!apiKey) {
18
- throw new OpenAIError("OPENAI_API_KEY environment variable is not set");
6
+ dayjs.extend(utc);
7
+ dayjs.extend(timezone);
8
+ const create = (parameters) => {
9
+ const { timezone: timezone2 } = parameters;
10
+ const now = () => {
11
+ return date(void 0);
12
+ };
13
+ const date = (date2) => {
14
+ let value;
15
+ try {
16
+ if (date2) {
17
+ value = dayjs.tz(date2, timezone2);
18
+ } else {
19
+ value = dayjs().tz(timezone2);
20
+ }
21
+ } catch (error) {
22
+ throw new Error(`Invalid date: ${date2}, error: ${error.message}`);
19
23
  }
20
- const openai = new OpenAI({
21
- apiKey
22
- });
23
- const model = options.model || DEFAULT_TRANSCRIPTION_MODEL;
24
- const fileName = filePath.split("/").pop() || filePath;
25
- logger.debug("Transcribing: %s (full path: %s)", fileName, filePath);
26
- const startTime = Date.now();
27
- const audioStream = await storage$1.readStream(filePath);
28
- const transcription = await openai.audio.transcriptions.create({
29
- model,
30
- file: audioStream,
31
- response_format: "json"
32
- });
33
- if (!transcription) {
34
- throw new OpenAIError("No transcription received from OpenAI");
24
+ return value.toDate();
25
+ };
26
+ const parse = (date2, format2) => {
27
+ let value;
28
+ try {
29
+ value = dayjs.tz(date2, format2, timezone2);
30
+ } catch (error) {
31
+ throw new Error(`Invalid date: ${date2}, expected format: ${format2}, error: ${error.message}`);
35
32
  }
36
- const duration = ((Date.now() - startTime) / 1e3).toFixed(1);
37
- logger.info("%s (%ss, %d chars)", model, duration, transcription.text?.length || 0);
38
- if (options.debug && options.debugFile) {
39
- await storage$1.writeFile(options.debugFile, JSON.stringify(transcription, null, 2), "utf8");
40
- logger.debug("Wrote debug file to %s", options.debugFile);
41
- }
42
- logger.debug("Received transcription from OpenAI: %s", transcription);
43
- return transcription;
44
- } catch (error) {
45
- logger.error("Error transcribing audio file: %s %s", error.message, error.stack);
46
- throw new OpenAIError(`Failed to transcribe audio: ${error.message}`);
47
- }
48
- }
33
+ return value.toDate();
34
+ };
35
+ const addDays = (date2, days) => {
36
+ return dayjs.tz(date2, timezone2).add(days, "day").toDate();
37
+ };
38
+ const addMonths = (date2, months) => {
39
+ return dayjs.tz(date2, timezone2).add(months, "month").toDate();
40
+ };
41
+ const addYears = (date2, years) => {
42
+ return dayjs.tz(date2, timezone2).add(years, "year").toDate();
43
+ };
44
+ const format = (date2, format2) => {
45
+ return dayjs.tz(date2, timezone2).format(format2);
46
+ };
47
+ const subDays = (date2, days) => {
48
+ return dayjs.tz(date2, timezone2).subtract(days, "day").toDate();
49
+ };
50
+ const subMonths = (date2, months) => {
51
+ return dayjs.tz(date2, timezone2).subtract(months, "month").toDate();
52
+ };
53
+ const subYears = (date2, years) => {
54
+ return dayjs.tz(date2, timezone2).subtract(years, "year").toDate();
55
+ };
56
+ const startOfMonth = (date2) => {
57
+ return dayjs.tz(date2, timezone2).startOf("month").toDate();
58
+ };
59
+ const endOfMonth = (date2) => {
60
+ return dayjs.tz(date2, timezone2).endOf("month").toDate();
61
+ };
62
+ const startOfYear = (date2) => {
63
+ return dayjs.tz(date2, timezone2).startOf("year").toDate();
64
+ };
65
+ const endOfYear = (date2) => {
66
+ return dayjs.tz(date2, timezone2).endOf("year").toDate();
67
+ };
68
+ const isBefore = (date2, other) => {
69
+ return dayjs.tz(date2, timezone2).isBefore(dayjs.tz(other, timezone2));
70
+ };
71
+ const isAfter = (date2, other) => {
72
+ return dayjs.tz(date2, timezone2).isAfter(dayjs.tz(other, timezone2));
73
+ };
74
+ return { now, date, parse, addDays, addMonths, addYears, format, subDays, subMonths, subYears, startOfMonth, endOfMonth, startOfYear, endOfYear, isBefore, isAfter };
75
+ };
49
76
 
50
- export { OpenAIError, transcribeAudio };
77
+ export { create };
51
78
  //# sourceMappingURL=index47.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index47.js","sources":["../src/util/openai.ts"],"sourcesContent":["import { OpenAI } from 'openai';\nimport { ChatCompletionCreateParamsNonStreaming, ChatCompletionMessageParam } from 'openai/resources/chat/completions';\nimport * as Storage from '@/util/storage';\nimport { getLogger } from '@/logging';\nimport { DEFAULT_MODEL, DEFAULT_TRANSCRIPTION_MODEL } from '@/constants';\n\nexport interface Transcription {\n text: string;\n}\n\nexport class OpenAIError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'OpenAIError';\n }\n}\n\n\nexport async function createCompletion(messages: ChatCompletionMessageParam[], options: { responseFormat?: any, model?: string, reasoningLevel?: 'none' | 'low' | 'medium' | 'high', maxTokens?: number, debug?: boolean, debugFile?: string, reason?: string } = {}): Promise<string | any> {\n const logger = getLogger();\n const storage = Storage.create({ log: logger.debug });\n try {\n const apiKey = process.env.OPENAI_API_KEY;\n if (!apiKey) {\n throw new OpenAIError('OPENAI_API_KEY environment variable is not set');\n }\n\n const openai = new OpenAI({\n apiKey: apiKey,\n });\n\n const model = options.model || DEFAULT_MODEL;\n \n // Check if model supports reasoning_effort\n const supportsReasoning = model.includes('gpt-5') || \n model.includes('o1') || model.includes('o3');\n const isReasoningCall = supportsReasoning && options.reasoningLevel && options.reasoningLevel !== 'none';\n \n logger.debug('Sending prompt to OpenAI: %j', messages);\n\n const startTime = Date.now();\n \n const requestParams: Record<string, unknown> = {\n model,\n messages,\n max_completion_tokens: options.maxTokens || 10000,\n response_format: options.responseFormat,\n };\n \n if (isReasoningCall) {\n requestParams.reasoning_effort = options.reasoningLevel;\n logger.debug('Using reasoning_effort: %s', options.reasoningLevel);\n }\n \n const completion = await openai.chat.completions.create(\n requestParams as unknown as ChatCompletionCreateParamsNonStreaming\n );\n const duration = ((Date.now() - startTime) / 1000).toFixed(1);\n\n // Log token usage with reason if provided\n const usage = completion.usage;\n const reasonSuffix = options.reason ? ` - ${options.reason}` : '';\n if (usage) {\n logger.info('%s (%ss, %d→%d tokens)%s', \n model, duration, usage.prompt_tokens, usage.completion_tokens, reasonSuffix);\n } else {\n logger.info('%s (%ss)%s', model, duration, reasonSuffix);\n }\n\n if (options.debug && options.debugFile) {\n await storage.writeFile(options.debugFile, JSON.stringify(completion, null, 2), 'utf8');\n logger.debug('Wrote debug file to %s', options.debugFile);\n }\n\n const response = completion.choices[0]?.message?.content?.trim();\n if (!response) {\n // Log the full completion object to help debug\n logger.error('Empty response from OpenAI. Full completion object: %j', completion);\n throw new OpenAIError('No response received from OpenAI');\n }\n\n logger.debug('Received response from OpenAI: %s', response);\n if (options.responseFormat) {\n return JSON.parse(response);\n } else {\n return response;\n }\n\n } catch (error: any) {\n logger.error('Error calling OpenAI API: %s %s', error.message, error.stack);\n throw new OpenAIError(`Failed to create completion: ${error.message}`);\n }\n}\n\nexport async function transcribeAudio(filePath: string, options: { model?: string, debug?: boolean, debugFile?: string } = {}): Promise<Transcription> {\n const logger = getLogger();\n const storage = Storage.create({ log: logger.debug });\n try {\n const apiKey = process.env.OPENAI_API_KEY;\n if (!apiKey) {\n throw new OpenAIError('OPENAI_API_KEY environment variable is not set');\n }\n\n const openai = new OpenAI({\n apiKey: apiKey,\n });\n\n const model = options.model || DEFAULT_TRANSCRIPTION_MODEL;\n const fileName = filePath.split('/').pop() || filePath;\n logger.debug('Transcribing: %s (full path: %s)', fileName, filePath);\n\n const startTime = Date.now();\n const audioStream = await storage.readStream(filePath);\n const transcription = await openai.audio.transcriptions.create({\n model,\n file: audioStream,\n response_format: \"json\",\n });\n \n if (!transcription) {\n throw new OpenAIError('No transcription received from OpenAI');\n }\n \n const duration = ((Date.now() - startTime) / 1000).toFixed(1);\n logger.info('%s (%ss, %d chars)', model, duration, transcription.text?.length || 0);\n\n if (options.debug && options.debugFile) {\n await storage.writeFile(options.debugFile, JSON.stringify(transcription, null, 2), 'utf8');\n logger.debug('Wrote debug file to %s', options.debugFile);\n }\n\n logger.debug('Received transcription from OpenAI: %s', transcription);\n return transcription;\n\n } catch (error: any) {\n logger.error('Error transcribing audio file: %s %s', error.message, error.stack);\n throw new OpenAIError(`Failed to transcribe audio: ${error.message}`);\n }\n}\n"],"names":["storage","Storage.create"],"mappings":";;;;;AAUO,MAAM,oBAAoB,KAAA,CAAM;AAAA,EACnC,YAAY,OAAA,EAAiB;AACzB,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,aAAA;AAAA,EAChB;AACJ;AA+EA,eAAsB,eAAA,CAAgB,QAAA,EAAkB,OAAA,GAAmE,EAAC,EAA2B;AACnJ,EAAA,MAAM,SAAS,SAAA,EAAU;AACzB,EAAA,MAAMA,YAAUC,MAAQ,CAAO,EAAE,GAAA,EAAK,MAAA,CAAO,OAAO,CAAA;AACpD,EAAA,IAAI;AACA,IAAA,MAAM,MAAA,GAAS,QAAQ,GAAA,CAAI,cAAA;AAC3B,IAAA,IAAI,CAAC,MAAA,EAAQ;AACT,MAAA,MAAM,IAAI,YAAY,gDAAgD,CAAA;AAAA,IAC1E;AAEA,IAAA,MAAM,MAAA,GAAS,IAAI,MAAA,CAAO;AAAA,MACtB;AAAA,KACH,CAAA;AAED,IAAA,MAAM,KAAA,GAAQ,QAAQ,KAAA,IAAS,2BAAA;AAC/B,IAAA,MAAM,WAAW,QAAA,CAAS,KAAA,CAAM,GAAG,CAAA,CAAE,KAAI,IAAK,QA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,CAAM,OAAO,CAAA,CAAE,CAAA;AAAA,EACxE;AACJ;;;;"}
1
+ {"version":3,"file":"index47.js","sources":["../src/util/dates.ts"],"sourcesContent":["// eslint-disable-next-line no-restricted-imports\nimport dayjs from 'dayjs';\nimport timezone from 'dayjs/plugin/timezone';\nimport utc from 'dayjs/plugin/utc';\n// eslint-disable-next-line no-restricted-imports\nimport moment from 'moment-timezone';\n\ndayjs.extend(utc);\ndayjs.extend(timezone);\n\n/**\n * Yes, wrapping dayjs is a bit annoying and might seem overly paranoid. However, I feel strongly\n * about not letting Dayjs instances leak into the rest of the codebase. Having Dayjs objects\n * floating around the application leads to inconsistent timezone handling, makes testing more\n * difficult, and creates subtle bugs that are hard to track down.\n * \n * By wrapping dayjs completely and only exposing plain JavaScript Date objects, we get several\n * key benefits:\n * 1. Consistent timezone handling through a single configuration point\n * 2. Simpler testing since we only need to mock this one library\n * 3. Type safety - the rest of the codebase only deals with standard Date objects\n * 4. No risk of dayjs method chains creating unexpected timezone shifts\n * \n * The Library interface gives us full control over all date operations while keeping the messy\n * details of timezone manipulation contained in one place. Yes it's more code, but the peace of\n * mind is worth it.\n */\nexport interface Utility {\n now: () => Date;\n date: (date: string | number | Date | null | undefined) => Date;\n parse: (date: string | number | Date | null | undefined, format: string) => Date;\n addDays: (date: Date, days: number) => Date;\n addMonths: (date: Date, months: number) => Date;\n addYears: (date: Date, years: number) => Date;\n format: (date: Date, format: string) => string;\n subDays: (date: Date, days: number) => Date;\n subMonths: (date: Date, months: number) => Date;\n subYears: (date: Date, years: number) => Date;\n startOfMonth: (date: Date) => Date;\n endOfMonth: (date: Date) => Date;\n startOfYear: (date: Date) => Date;\n endOfYear: (date: Date) => Date;\n isBefore: (date: Date, other: Date) => boolean;\n isAfter: (date: Date, other: Date) => boolean;\n}\n\nexport const create = (parameters: { timezone: string }) => {\n const { timezone } = parameters;\n const now = () => {\n return date(undefined);\n }\n\n const date = (date: string | number | Date | null | undefined) => {\n let value: dayjs.Dayjs;\n try {\n if (date) {\n value = dayjs.tz(date, timezone);\n } else {\n value = dayjs().tz(timezone);\n }\n } catch (error: any) {\n throw new Error(`Invalid date: ${date}, error: ${error.message}`);\n }\n\n return value.toDate();\n }\n\n const parse = (date: string | number | Date | null | undefined, format: string) => {\n let value: dayjs.Dayjs;\n try {\n value = dayjs.tz(date, format, timezone);\n } catch (error: any) {\n throw new Error(`Invalid date: ${date}, expected format: ${format}, error: ${error.message}`);\n }\n\n return value.toDate();\n }\n\n const addDays = (date: Date, days: number) => {\n return dayjs.tz(date, timezone).add(days, 'day').toDate();\n }\n\n const addMonths = (date: Date, months: number) => {\n return dayjs.tz(date, timezone).add(months, 'month').toDate();\n }\n\n const addYears = (date: Date, years: number) => {\n return dayjs.tz(date, timezone).add(years, 'year').toDate();\n }\n\n const format = (date: Date, format: string) => {\n return dayjs.tz(date, timezone).format(format);\n }\n\n const subDays = (date: Date, days: number) => {\n return dayjs.tz(date, timezone).subtract(days, 'day').toDate();\n }\n\n const subMonths = (date: Date, months: number) => {\n return dayjs.tz(date, timezone).subtract(months, 'month').toDate();\n }\n\n const subYears = (date: Date, years: number) => {\n return dayjs.tz(date, timezone).subtract(years, 'year').toDate();\n }\n\n const startOfMonth = (date: Date) => {\n return dayjs.tz(date, timezone).startOf('month').toDate();\n }\n\n const endOfMonth = (date: Date) => {\n return dayjs.tz(date, timezone).endOf('month').toDate();\n }\n\n const startOfYear = (date: Date) => {\n return dayjs.tz(date, timezone).startOf('year').toDate();\n }\n\n const endOfYear = (date: Date) => {\n return dayjs.tz(date, timezone).endOf('year').toDate();\n }\n\n const isBefore = (date: Date, other: Date) => {\n return dayjs.tz(date, timezone).isBefore(dayjs.tz(other, timezone));\n }\n\n const isAfter = (date: Date, other: Date) => {\n return dayjs.tz(date, timezone).isAfter(dayjs.tz(other, timezone));\n }\n\n return { now, date, parse, addDays, addMonths, addYears, format, subDays, subMonths, subYears, startOfMonth, endOfMonth, startOfYear, endOfYear, isBefore, isAfter };\n}\n\nexport const validT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QAAQ,KAAA,CAAM,EAAA,CAAG,KAAA,EAAOA,SAAQ,CAAC,CAAA;AAAA,EACrE,CAAA;AAEA,EAAA,OAAO,EAAE,GAAA,EAAK,IAAA,EAAM,KAAA,EAAO,OAAA,EAAS,WAAW,QAAA,EAAU,MAAA,EAAQ,OAAA,EAAS,SAAA,EAAW,UAAU,YAAA,EAAc,UAAA,EAAY,WAAA,EAAa,SAAA,EAAW,UAAU,OAAA,EAAQ;AACvK;;;;"}
package/dist/index48.js CHANGED
@@ -1,39 +1,8 @@
1
- const stringifyJSON = function(obj) {
2
- const arrOfKeyVals = [];
3
- const arrVals = [];
4
- let objKeys = [];
5
- if (typeof obj === "number" || typeof obj === "boolean" || obj === null)
6
- return "" + obj;
7
- else if (typeof obj === "string")
8
- return '"' + obj + '"';
9
- else if (Array.isArray(obj)) {
10
- if (obj[0] === void 0)
11
- return "[]";
12
- else {
13
- obj.forEach(function(el) {
14
- arrVals.push(stringifyJSON(el));
15
- });
16
- return "[" + arrVals + "]";
17
- }
18
- } else if (obj instanceof Object) {
19
- objKeys = Object.keys(obj);
20
- objKeys.forEach(function(key) {
21
- const keyOut = '"' + key + '":';
22
- const keyValOut = obj[key];
23
- if (keyValOut instanceof Function || keyValOut === void 0)
24
- arrOfKeyVals.push("");
25
- else if (typeof keyValOut === "string")
26
- arrOfKeyVals.push(keyOut + '"' + keyValOut + '"');
27
- else if (typeof keyValOut === "boolean" || typeof keyValOut === "number" || keyValOut === null)
28
- arrOfKeyVals.push(keyOut + keyValOut);
29
- else if (keyValOut instanceof Object) {
30
- arrOfKeyVals.push(keyOut + stringifyJSON(keyValOut));
31
- }
32
- });
33
- return "{" + arrOfKeyVals + "}";
34
- }
35
- return "";
1
+ import { create as create$1 } from './index56.js';
2
+
3
+ const create = (config) => {
4
+ return create$1(config);
36
5
  };
37
6
 
38
- export { stringifyJSON };
7
+ export { create };
39
8
  //# sourceMappingURL=index48.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index48.js","sources":["../src/util/general.ts"],"sourcesContent":["// Utility function for deep merging two objects.\nexport function deepMerge(target: any, source: any): any {\n for (const key in source) {\n if (Object.prototype.hasOwnProperty.call(source, key)) {\n // Block prototype-polluting keys\n if (key === '__proto__' || key === 'constructor') {\n continue;\n }\n if (source[key] && typeof source[key] === 'object' && !Array.isArray(source[key])) {\n if (!target[key]) {\n target[key] = {};\n }\n deepMerge(target[key], source[key]);\n } else {\n target[key] = source[key];\n }\n }\n }\n return target;\n}\n\n//Recursive implementation of jSON.stringify;\nexport const stringifyJSON = function (obj: any): string {\n\n const arrOfKeyVals: string[] = [];\n const arrVals: string[] = [];\n let objKeys: string[] = [];\n\n /*********CHECK FOR PRIMITIVE TYPES**********/\n if (typeof obj === 'number' || typeof obj === 'boolean' || obj === null)\n return '' + obj;\n else if (typeof obj === 'string')\n return '\"' + obj + '\"';\n\n /*********CHECK FOR ARRAY**********/\n else if (Array.isArray(obj)) {\n //check for empty array\n if (obj[0] === undefined)\n return '[]';\n else {\n obj.forEach(function (el) {\n arrVals.push(stringifyJSON(el));\n });\n return '[' + arrVals + ']';\n }\n }\n /*********CHECK FOR OBJECT**********/\n else if (obj instanceof Object) {\n //get object keys\n objKeys = Object.keys(obj);\n //set key output;\n objKeys.forEach(function (key) {\n const keyOut = '\"' + key + '\":';\n const keyValOut = obj[key];\n //skip functions and undefined properties\n if (keyValOut instanceof Function || keyValOut === undefined)\n arrOfKeyVals.push('');\n else if (typeof keyValOut === 'string')\n arrOfKeyVals.push(keyOut + '\"' + keyValOut + '\"');\n else if (typeof keyValOut === 'boolean' || typeof keyValOut === 'number' || keyValOut === null)\n arrOfKeyVals.push(keyOut + keyValOut);\n //check for nested objects, call recursively until no more objects\n else if (keyValOut instanceof Object) {\n arrOfKeyVals.push(keyOut + stringifyJSON(keyValOut));\n }\n });\n return '{' + arrOfKeyVals + '}';\n }\n return '';\n};"],"names":[],"mappings":"AAsBO,MAAM,aAAA,GAAgB,SAAU,GAAA,EAAkB;AAErD,EAAA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A;AACtF,QAAA,YAAA,CAAa,IAAA,CAAK,SAAS,SAAS,CAAA;AAAA,WAAA,IAE/B,qBAAqB,MAAA,EAAQ;AAClC,QAAA,YAAA,CAAa,IAAA,CAAK,MAAA,GAAS,aAAA,CAAc,SAAS,CAAC,CAAA;AAAA,MACvD;AAAA,IACJ,CAAC,CAAA;AACD,IAAA,OAAO,MAAM,YAAA,GAAe,GAAA;AAAA,EAChC;AACA,EAAA,OAAO,EAAA;AACX;;;;"}
1
+ {"version":3,"file":"index48.js","sources":["../src/out/index.ts"],"sourcesContent":["/**\n * Output Management System\n *\n * Main entry point for the output management system. Handles intermediate\n * files and final output destinations.\n */\n\nimport { OutputConfig, OutputPaths, IntermediateFiles, RawTranscriptData } from './types';\nimport * as Manager from './manager';\nimport * as Metadata from '../util/metadata';\n\nexport interface OutputInstance {\n createOutputPaths(\n audioFile: string,\n routedDestination: string,\n hash: string,\n date: Date\n ): OutputPaths;\n ensureDirectories(paths: OutputPaths): Promise<void>;\n writeIntermediate(\n paths: OutputPaths,\n type: keyof IntermediateFiles,\n content: unknown\n ): Promise<string>;\n /**\n * Write the raw Whisper transcript to the .transcript/ directory alongside final output.\n * This enables compare and reanalyze workflows.\n */\n writeRawTranscript(paths: OutputPaths, data: RawTranscriptData): Promise<string>;\n writeTranscript(paths: OutputPaths, content: string, metadata?: Metadata.TranscriptMetadata): Promise<string>;\n /**\n * Read a previously stored raw transcript from the .transcript/ directory.\n * Returns null if no raw transcript exists.\n */\n readRawTranscript(finalOutputPath: string): Promise<RawTranscriptData | null>;\n cleanIntermediates(paths: OutputPaths): Promise<void>;\n}\n\nexport const create = (config: OutputConfig): OutputInstance => {\n return Manager.create(config);\n};\n\nexport const DEFAULT_OUTPUT_CONFIG: OutputConfig = {\n intermediateDir: './output/protokoll',\n keepIntermediates: true,\n timestampFormat: 'YYMMDD-HHmm',\n};\n\n// Re-export types\nexport * from './types';\n"],"names":["Manager.create"],"mappings":";;AAsCO,MAAM,MAAA,GAAS,CAAC,MAAA,KAAyC;AAC5D,EAAA,OAAOA,SAAe,MAAM,CAAA;AAChC;;;;"}