@redaksjon/protokoll-engine 0.1.17 → 0.1.18-dev.20260320155436.f5c770c
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/index19.js +1 -1
- package/dist/index22.js +1 -1
- package/dist/index26.js +1 -1
- package/dist/index27.js +5 -5
- package/dist/index31.js +1 -1
- package/dist/index32.js +1 -1
- package/dist/index33.js +2 -2
- package/dist/index34.js +3 -3
- package/dist/index35.js +5 -5
- package/dist/index36.js +2 -2
- package/dist/index37.js +1 -1
- package/dist/index39.js +1 -1
- package/dist/index42.js +1 -1
- package/dist/index43.js +1 -1
- package/dist/index47.js +45 -4
- package/dist/index47.js.map +1 -1
- package/dist/index48.js +47 -45
- package/dist/index48.js.map +1 -1
- package/dist/index49.js +33 -145
- package/dist/index49.js.map +1 -1
- package/dist/index50.js +263 -205
- package/dist/index50.js.map +1 -1
- package/dist/index51.js +153 -39
- package/dist/index51.js.map +1 -1
- package/dist/index52.js +74 -38
- package/dist/index52.js.map +1 -1
- package/dist/index53.js +74 -33
- package/dist/index53.js.map +1 -1
- package/dist/index54.js +143 -43
- package/dist/index54.js.map +1 -1
- package/dist/index55.js +221 -34
- package/dist/index55.js.map +1 -1
- package/dist/index56.js +41 -276
- package/dist/index56.js.map +1 -1
- package/dist/index57.js +38 -156
- package/dist/index57.js.map +1 -1
- package/dist/index58.js +31 -75
- package/dist/index58.js.map +1 -1
- package/dist/index59.js +3 -73
- package/dist/index59.js.map +1 -1
- package/dist/index60.js +5 -148
- package/dist/index60.js.map +1 -1
- package/dist/index61.js +4 -4
- package/dist/index62.js +148 -5
- package/dist/index62.js.map +1 -1
- package/package.json +3 -3
package/dist/index58.js
CHANGED
|
@@ -1,81 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
}
|
|
43
|
-
return {
|
|
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);
|
|
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"
|
|
62
19
|
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
20
|
+
},
|
|
21
|
+
required: ["entityType", "name"]
|
|
22
|
+
},
|
|
23
|
+
execute: async (args) => {
|
|
67
24
|
return {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
|
31
|
+
}
|
|
72
32
|
};
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
applyReplacements,
|
|
76
|
-
applySingleReplacement
|
|
77
|
-
};
|
|
78
|
-
};
|
|
33
|
+
}
|
|
34
|
+
});
|
|
79
35
|
|
|
80
36
|
export { create };
|
|
81
37
|
//# sourceMappingURL=index58.js.map
|
package/dist/index58.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index58.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,IAAA,MAAM,KAAA,GAA0B,IAAA,CAAO;AACvC,IAAA,OAAO,IAAI,MAAA,CAAO,OAAA,EAAS,KAAK,CAAA;AAAA,EACpC,CAAA;AAKA,EAAA,MAAM,sBAAA,GAAyB,CAAC,IAAA,EAAc,OAAA,KAAkD;AAC5F,IAAA,MAAM,OAAA,GAAU,aAAA,CAAc,OAAA,CAAQ,UAAU,CAAA;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A,OACjD;AAAA,IACJ;AAEA,IAAA,OAAO;AAAA,MACH,IAAA,EAAM,UAAA;AAAA,MACN,KAAA;AAAA,MACA,WAAA;AAAA,MACA,iBAAiB,KAAA,GAAQ,CAAA,GAAI,CAAC,OAAO,IAAI;AAAC,KAC9C;AAAA,EACJ,CAAA;AAKA,EAAA,MAAM,iBAAA,GAAoB,CAAC,IAAA,EAAc,QAAA,KAAqD;AAC1F,IAAA,IAAI,UAAA,GAAa,IAAA;AACjB,IAAA,IAAI,UAAA,GAAa,CAAA;AACjB,IAAA,MAAM,iBAA0C,EAAC;AACjD,IAAA,MAAM,kBAAuC,EAAC;AAG9C,IAAA,KAAA,MAAW,WAAW,QAAA,EAAU;AAC5B,MAAA,MAAM,MAAA,GAAS,sBAAA,CAAuB,UAAA,EAAY,OAAO,CAAA;AAEzD,MAAA,IAAI,MAAA,CAAO,QAAQ,CAAA,EAAG;AAClB,QAAA,UAAA,GAAa,MAAA,CAAO,IAAA;AACpB,QAAA,UAAA,IAAc,MAAA,CAAO,KAAA;AACrB,QAAA,cAAA,CAAe,IAAA,CAAK,GAAG,MAAA,CAAO,WAAW,CAAA;AACzC,QAAA,eAAA,CAAgB,KAAK,OAAO,CAAA;AAAA,MAChC;AAAA,IACJ;AAEA,IAAA,MAAA,CAAO,KAAA;AAAA,MACH,WAAW,QAAA,CAAS,MAAM,mBAAmB,UAAU,CAAA,eAAA,EACnD,gBAAgB,MAAM,CAAA,sBAAA;AAAA,KAC9B;AAEA,IAAA,OAAO;AAAA,MACH,IAAA,EAAM,UAAA;AAAA,MACN,KAAA,EAAO,UAAA;AAAA,MACP,WAAA,EAAa,cAAA;AAAA,MACb;AAAA,KACJ;AAAA,EACJ,CAAA;AAEA,EAAA,OAAO;AAAA,IACH,iBAAA;AAAA,IACA;AAAA,GACJ;AACJ;;;;"}
|
|
1
|
+
{"version":3,"file":"index58.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;;;;"}
|
package/dist/index59.js
CHANGED
|
@@ -1,77 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import timezone from './index61.js';
|
|
3
|
-
import utc from './index62.js';
|
|
4
|
-
import 'moment-timezone';
|
|
1
|
+
import { create as create$1 } from './index62.js';
|
|
5
2
|
|
|
6
|
-
|
|
7
|
-
|
|
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}`);
|
|
23
|
-
}
|
|
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}`);
|
|
32
|
-
}
|
|
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 };
|
|
3
|
+
const create = (config) => {
|
|
4
|
+
return create$1(config);
|
|
75
5
|
};
|
|
76
6
|
|
|
77
7
|
export { create };
|
package/dist/index59.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index59.js","sources":["../src/
|
|
1
|
+
{"version":3,"file":"index59.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;;;;"}
|
package/dist/index60.js
CHANGED
|
@@ -1,151 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import { randomUUID } from 'node:crypto';
|
|
4
|
-
import { getLogger } from './index48.js';
|
|
5
|
-
import { PklTranscript } from '@redaksjon/protokoll-format';
|
|
1
|
+
import { getDefaultExportFromCjs } from './index67.js';
|
|
2
|
+
import { __require as requireTimezone } from './index63.js';
|
|
6
3
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const formatTimestamp = (date) => {
|
|
10
|
-
const pad = (n) => n.toString().padStart(2, "0");
|
|
11
|
-
const year = date.getFullYear().toString();
|
|
12
|
-
const month = pad(date.getMonth() + 1);
|
|
13
|
-
const day = pad(date.getDate());
|
|
14
|
-
const hours = pad(date.getHours());
|
|
15
|
-
const minutes = pad(date.getMinutes());
|
|
16
|
-
return `${year}-${month}-${day}-${hours}${minutes}`;
|
|
17
|
-
};
|
|
18
|
-
const createOutputPaths = (_audioFile, routedDestination, hash, date) => {
|
|
19
|
-
const timestamp = formatTimestamp(date);
|
|
20
|
-
const shortHash = hash.slice(0, 6);
|
|
21
|
-
const buildFilename = (type, ext) => `${timestamp}-${type}-${shortHash}${ext}`;
|
|
22
|
-
const intermediateDir = config.intermediateDir;
|
|
23
|
-
let finalPath = routedDestination;
|
|
24
|
-
if (finalPath.endsWith(".md")) {
|
|
25
|
-
finalPath = finalPath.replace(/\.md$/, ".pkl");
|
|
26
|
-
} else if (!finalPath.endsWith(".pkl")) {
|
|
27
|
-
finalPath = finalPath + ".pkl";
|
|
28
|
-
}
|
|
29
|
-
const finalDir = path.dirname(finalPath);
|
|
30
|
-
const finalBasename = path.basename(finalPath, ".pkl");
|
|
31
|
-
const rawTranscriptPath = path.join(finalDir, ".transcript", `${finalBasename}.json`);
|
|
32
|
-
return {
|
|
33
|
-
final: finalPath,
|
|
34
|
-
rawTranscript: rawTranscriptPath,
|
|
35
|
-
intermediate: {
|
|
36
|
-
transcript: path.join(intermediateDir, buildFilename("transcript", ".json")),
|
|
37
|
-
context: path.join(intermediateDir, buildFilename("context", ".json")),
|
|
38
|
-
request: path.join(intermediateDir, buildFilename("request", ".json")),
|
|
39
|
-
response: path.join(intermediateDir, buildFilename("response", ".json")),
|
|
40
|
-
reflection: path.join(intermediateDir, buildFilename("reflection", ".md")),
|
|
41
|
-
session: path.join(intermediateDir, buildFilename("session", ".json"))
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
};
|
|
45
|
-
const ensureDirectories = async (paths) => {
|
|
46
|
-
await fs.mkdir(path.dirname(paths.intermediate.transcript), { recursive: true });
|
|
47
|
-
await fs.mkdir(path.dirname(paths.final), { recursive: true });
|
|
48
|
-
await fs.mkdir(path.dirname(paths.rawTranscript), { recursive: true });
|
|
49
|
-
logger.debug("Ensured output directories", {
|
|
50
|
-
intermediate: path.dirname(paths.intermediate.transcript),
|
|
51
|
-
final: path.dirname(paths.final),
|
|
52
|
-
rawTranscript: path.dirname(paths.rawTranscript)
|
|
53
|
-
});
|
|
54
|
-
};
|
|
55
|
-
const writeIntermediate = async (paths, type, content) => {
|
|
56
|
-
const filePath = paths.intermediate[type];
|
|
57
|
-
if (!filePath) {
|
|
58
|
-
throw new Error(`Invalid intermediate type: ${type}`);
|
|
59
|
-
}
|
|
60
|
-
const contentStr = typeof content === "string" ? content : JSON.stringify(content, null, 2);
|
|
61
|
-
await fs.writeFile(filePath, contentStr, "utf-8");
|
|
62
|
-
logger.debug("Wrote intermediate file", { type, path: filePath });
|
|
63
|
-
return filePath;
|
|
64
|
-
};
|
|
65
|
-
const writeTranscript = async (paths, content, metadata) => {
|
|
66
|
-
const pklRouting = metadata?.routing ? {
|
|
67
|
-
destination: metadata.routing.destination,
|
|
68
|
-
confidence: metadata.routing.confidence,
|
|
69
|
-
signals: metadata.routing.signals?.map(
|
|
70
|
-
(s) => typeof s === "string" ? s : `${s.type}: ${s.value} (weight: ${s.weight})`
|
|
71
|
-
),
|
|
72
|
-
reasoning: metadata.routing.reasoning
|
|
73
|
-
} : void 0;
|
|
74
|
-
const pklMetadata = metadata ? {
|
|
75
|
-
id: metadata.id || randomUUID(),
|
|
76
|
-
// Use provided UUID or generate new one
|
|
77
|
-
title: metadata.title,
|
|
78
|
-
date: metadata.date,
|
|
79
|
-
recordingTime: metadata.recordingTime,
|
|
80
|
-
project: metadata.project,
|
|
81
|
-
projectId: metadata.projectId,
|
|
82
|
-
tags: metadata.tags || [],
|
|
83
|
-
duration: metadata.duration,
|
|
84
|
-
status: metadata.status || "initial",
|
|
85
|
-
entities: metadata.entities,
|
|
86
|
-
routing: pklRouting
|
|
87
|
-
} : {
|
|
88
|
-
id: randomUUID(),
|
|
89
|
-
title: "Untitled",
|
|
90
|
-
tags: [],
|
|
91
|
-
status: "initial"
|
|
92
|
-
};
|
|
93
|
-
const transcript = PklTranscript.create(paths.final, pklMetadata);
|
|
94
|
-
try {
|
|
95
|
-
transcript.updateContent(content);
|
|
96
|
-
logger.info("Wrote final transcript", { path: paths.final });
|
|
97
|
-
} finally {
|
|
98
|
-
transcript.close();
|
|
99
|
-
}
|
|
100
|
-
return paths.final;
|
|
101
|
-
};
|
|
102
|
-
const cleanIntermediates = async (paths) => {
|
|
103
|
-
if (config.keepIntermediates) {
|
|
104
|
-
logger.debug("Keeping intermediate files");
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
for (const [type, filePath] of Object.entries(paths.intermediate)) {
|
|
108
|
-
if (filePath) {
|
|
109
|
-
try {
|
|
110
|
-
await fs.unlink(filePath);
|
|
111
|
-
logger.debug("Removed intermediate file", { type, path: filePath });
|
|
112
|
-
} catch {
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
const writeRawTranscript = async (paths, data) => {
|
|
118
|
-
const filePath = paths.rawTranscript;
|
|
119
|
-
await fs.writeFile(filePath, JSON.stringify(data, null, 2), "utf-8");
|
|
120
|
-
logger.debug("Wrote raw transcript to .transcript/", { path: filePath });
|
|
121
|
-
return filePath;
|
|
122
|
-
};
|
|
123
|
-
const readRawTranscript = async (finalOutputPath) => {
|
|
124
|
-
const finalDir = path.dirname(finalOutputPath);
|
|
125
|
-
const ext = path.extname(finalOutputPath);
|
|
126
|
-
const finalBasename = path.basename(finalOutputPath, ext);
|
|
127
|
-
const rawTranscriptPath = path.join(finalDir, ".transcript", `${finalBasename}.json`);
|
|
128
|
-
try {
|
|
129
|
-
const content = await fs.readFile(rawTranscriptPath, "utf-8");
|
|
130
|
-
return JSON.parse(content);
|
|
131
|
-
} catch (error) {
|
|
132
|
-
if (error && typeof error === "object" && "code" in error && error.code === "ENOENT") {
|
|
133
|
-
logger.debug("No raw transcript found", { path: rawTranscriptPath });
|
|
134
|
-
return null;
|
|
135
|
-
}
|
|
136
|
-
throw error;
|
|
137
|
-
}
|
|
138
|
-
};
|
|
139
|
-
return {
|
|
140
|
-
createOutputPaths,
|
|
141
|
-
ensureDirectories,
|
|
142
|
-
writeIntermediate,
|
|
143
|
-
writeRawTranscript,
|
|
144
|
-
writeTranscript,
|
|
145
|
-
readRawTranscript,
|
|
146
|
-
cleanIntermediates
|
|
147
|
-
};
|
|
148
|
-
};
|
|
4
|
+
var timezoneExports = requireTimezone();
|
|
5
|
+
const timezone = /*@__PURE__*/getDefaultExportFromCjs(timezoneExports);
|
|
149
6
|
|
|
150
|
-
export {
|
|
7
|
+
export { timezone as default };
|
|
151
8
|
//# sourceMappingURL=index60.js.map
|
package/dist/index60.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index60.js","sources":["../src/out/manager.ts"],"sourcesContent":["/**\n * Output Manager\n *\n * Manages intermediate files and final output destinations.\n * Follows the kodrdriv pattern for debugging and intermediate file management.\n * \n * PKL-only implementation - all transcripts are stored in PKL format.\n */\n\nimport * as path from 'node:path';\nimport * as fs from 'node:fs/promises';\nimport { randomUUID } from 'node:crypto';\nimport { OutputConfig, IntermediateFiles, OutputPaths, RawTranscriptData } from './types';\nimport * as Logging from '../logging';\nimport * as Metadata from '../util/metadata';\nimport { PklTranscript } from '@redaksjon/protokoll-format';\n\nexport interface ManagerInstance {\n createOutputPaths(\n audioFile: string,\n routedDestination: string,\n hash: string,\n date: Date\n ): OutputPaths;\n \n ensureDirectories(paths: OutputPaths): Promise<void>;\n \n writeIntermediate(\n paths: OutputPaths,\n type: keyof IntermediateFiles,\n content: unknown\n ): Promise<string>;\n \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 \n writeTranscript(paths: OutputPaths, content: string, metadata?: Metadata.TranscriptMetadata): Promise<string>;\n \n cleanIntermediates(paths: OutputPaths): Promise<void>;\n \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}\n\nexport const create = (config: OutputConfig): ManagerInstance => {\n const logger = Logging.getLogger();\n \n const formatTimestamp = (date: Date): string => {\n // Format: YYYY-MM-DD-HHmm (full year, dashes for separation)\n const pad = (n: number) => n.toString().padStart(2, '0');\n const year = date.getFullYear().toString();\n const month = pad(date.getMonth() + 1);\n const day = pad(date.getDate());\n const hours = pad(date.getHours());\n const minutes = pad(date.getMinutes());\n return `${year}-${month}-${day}-${hours}${minutes}`;\n };\n \n const createOutputPaths = (\n _audioFile: string,\n routedDestination: string,\n hash: string,\n date: Date\n ): OutputPaths => {\n const timestamp = formatTimestamp(date);\n const shortHash = hash.slice(0, 6);\n // Hash at the end for easier filename correlation\n const buildFilename = (type: string, ext: string) => `${timestamp}-${type}-${shortHash}${ext}`;\n \n const intermediateDir = config.intermediateDir;\n \n // Ensure final path uses .pkl extension\n let finalPath = routedDestination;\n if (finalPath.endsWith('.md')) {\n finalPath = finalPath.replace(/\\.md$/, '.pkl');\n } else if (!finalPath.endsWith('.pkl')) {\n finalPath = finalPath + '.pkl';\n }\n\n // Generate raw transcript path in .transcript/ directory alongside final output\n // e.g., /notes/2026/1/14-meeting.pkl -> /notes/2026/1/.transcript/14-meeting.json\n const finalDir = path.dirname(finalPath);\n const finalBasename = path.basename(finalPath, '.pkl');\n const rawTranscriptPath = path.join(finalDir, '.transcript', `${finalBasename}.json`);\n\n return {\n final: finalPath,\n rawTranscript: rawTranscriptPath,\n intermediate: {\n transcript: path.join(intermediateDir, buildFilename('transcript', '.json')),\n context: path.join(intermediateDir, buildFilename('context', '.json')),\n request: path.join(intermediateDir, buildFilename('request', '.json')),\n response: path.join(intermediateDir, buildFilename('response', '.json')),\n reflection: path.join(intermediateDir, buildFilename('reflection', '.md')),\n session: path.join(intermediateDir, buildFilename('session', '.json')),\n },\n };\n };\n \n const ensureDirectories = async (paths: OutputPaths): Promise<void> => {\n // Ensure intermediate directory\n await fs.mkdir(path.dirname(paths.intermediate.transcript), { recursive: true });\n \n // Ensure final directory\n await fs.mkdir(path.dirname(paths.final), { recursive: true });\n \n // Ensure .transcript directory alongside final output\n await fs.mkdir(path.dirname(paths.rawTranscript), { recursive: true });\n \n logger.debug('Ensured output directories', {\n intermediate: path.dirname(paths.intermediate.transcript),\n final: path.dirname(paths.final),\n rawTranscript: path.dirname(paths.rawTranscript),\n });\n };\n \n const writeIntermediate = async (\n paths: OutputPaths,\n type: keyof IntermediateFiles,\n content: unknown\n ): Promise<string> => {\n const filePath = paths.intermediate[type];\n if (!filePath) {\n throw new Error(`Invalid intermediate type: ${type}`);\n }\n \n const contentStr = typeof content === 'string' \n ? content \n : JSON.stringify(content, null, 2);\n \n await fs.writeFile(filePath, contentStr, 'utf-8');\n logger.debug('Wrote intermediate file', { type, path: filePath });\n \n return filePath;\n };\n \n const writeTranscript = async (\n paths: OutputPaths,\n content: string,\n metadata?: Metadata.TranscriptMetadata\n ): Promise<string> => {\n // Create PKL transcript\n // Convert routing metadata to PKL format (signals are strings in PKL)\n const pklRouting = metadata?.routing ? {\n destination: metadata.routing.destination,\n confidence: metadata.routing.confidence,\n signals: metadata.routing.signals?.map(s => \n typeof s === 'string' ? s : `${s.type}: ${s.value} (weight: ${s.weight})`\n ),\n reasoning: metadata.routing.reasoning,\n } : undefined;\n \n const pklMetadata = metadata ? {\n id: metadata.id || randomUUID(), // Use provided UUID or generate new one\n title: metadata.title,\n date: metadata.date,\n recordingTime: metadata.recordingTime,\n project: metadata.project,\n projectId: metadata.projectId,\n tags: metadata.tags || [],\n duration: metadata.duration,\n status: metadata.status || 'initial' as const,\n entities: metadata.entities,\n routing: pklRouting,\n } : {\n id: randomUUID(),\n title: 'Untitled',\n tags: [],\n status: 'initial' as const,\n };\n \n // Compatibility cast: engine metadata can include newer statuses than\n // the currently installed protokoll-format type declarations.\n const transcript = PklTranscript.create(paths.final, pklMetadata as any);\n try {\n transcript.updateContent(content);\n logger.info('Wrote final transcript', { path: paths.final });\n } finally {\n transcript.close();\n }\n \n return paths.final;\n };\n \n const cleanIntermediates = async (paths: OutputPaths): Promise<void> => {\n if (config.keepIntermediates) {\n logger.debug('Keeping intermediate files');\n return;\n }\n \n for (const [type, filePath] of Object.entries(paths.intermediate)) {\n if (filePath) {\n try {\n await fs.unlink(filePath);\n logger.debug('Removed intermediate file', { type, path: filePath });\n } catch {\n // File might not exist, that's OK\n }\n }\n }\n };\n \n /**\n * Write the raw Whisper transcript to the .transcript/ directory.\n * This preserves the original transcription for compare/reanalyze workflows.\n */\n const writeRawTranscript = async (\n paths: OutputPaths,\n data: RawTranscriptData\n ): Promise<string> => {\n const filePath = paths.rawTranscript;\n \n await fs.writeFile(filePath, JSON.stringify(data, null, 2), 'utf-8');\n logger.debug('Wrote raw transcript to .transcript/', { path: filePath });\n \n return filePath;\n };\n \n /**\n * Read a previously stored raw transcript from the .transcript/ directory.\n * Calculates the path based on the final output path.\n * Returns null if no raw transcript exists.\n */\n const readRawTranscript = async (finalOutputPath: string): Promise<RawTranscriptData | null> => {\n const finalDir = path.dirname(finalOutputPath);\n const ext = path.extname(finalOutputPath);\n const finalBasename = path.basename(finalOutputPath, ext);\n const rawTranscriptPath = path.join(finalDir, '.transcript', `${finalBasename}.json`);\n \n try {\n const content = await fs.readFile(rawTranscriptPath, 'utf-8');\n return JSON.parse(content) as RawTranscriptData;\n } catch (error: unknown) {\n if (error && typeof error === 'object' && 'code' in error && error.code === 'ENOENT') {\n logger.debug('No raw transcript found', { path: rawTranscriptPath });\n return null;\n }\n throw error;\n }\n };\n \n return {\n createOutputPaths,\n ensureDirectories,\n writeIntermediate,\n writeRawTranscript,\n writeTranscript,\n readRawTranscript,\n cleanIntermediates,\n };\n};\n"],"names":["Logging.getLogger"],"mappings":";;;;;;AAkDO,MAAM,MAAA,GAAS,CAAC,MAAA,KAA0C;AAC7D,EAAA,MAAM,MAAA,GAASA,SAAQ,EAAU;AAEjC,EAAA,MAAM,eAAA,GAAkB,CAAC,IAAA,KAAuB;AAE5C,IAAA,MAAM,GAAA,GAAM,CAAC,CAAA,KAAc,CAAA,CAAE,UAAS,CAAE,QAAA,CAAS,GAAG,GAAG,CAAA;AACvD,IAAA,MAAM,IAAA,GAAO,IAAA,CAAK,WAAA,EAAY,CAAE,QAAA,EAAS;AACzC,IAAA,MAAM,KAAA,GAAQ,GAAA,CAAI,IAAA,CAAK,QAAA,KAAa,CAAC,CAAA;AACrC,IAAA,MAAM,GAAA,GAAM,GAAA,CAAI,IAAA,CAAK,OAAA,EAAS,CAAA;AAC9B,IAAA,MAAM,KAAA,GAAQ,GAAA,CAAI,IAAA,CAAK,QAAA,EAAU,CAAA;AACjC,IAAA,MAAM,OAAA,GAAU,GAAA,CAAI,IAAA,CAAK,UAAA,EAAY,CAAA;AACrC,IAAA,OAAO,CAAA,EAAG,IAAI,CAAA,CAAA,EAAI,KAAK,IAAI,GAAG,CAAA,CAAA,EAAI,KAAK,CAAA,EAAG,OAAO,CAAA,CAAA;AAAA,EACrD,CAAA;AAEA,EAAA,MAAM,iBAAA,GAAoB,CACtB,UAAA,EACA,iBAAA,EACA,MACA,IAAA,KACc;AACd,IAAA,MAAM,SAAA,GAAY,gBAAgB,IAAI,CAAA;AACtC,IAAA,MAAM,SAAA,GAAY,IAAA,CAAK,KAAA,CAAM,CAAA,EAAG,CAAC,CAAA;AAEjC,IAAA,MAAM,aAAA,GAAgB,CAAC,IAAA,EAAc,GAAA,KAAgB,CAAA,EAAG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1
|
+
{"version":3,"file":"index60.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
|
package/dist/index61.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { getDefaultExportFromCjs } from './index67.js';
|
|
2
|
-
import { __require as
|
|
2
|
+
import { __require as requireUtc } from './index65.js';
|
|
3
3
|
|
|
4
|
-
var
|
|
5
|
-
const
|
|
4
|
+
var utcExports = requireUtc();
|
|
5
|
+
const utc = /*@__PURE__*/getDefaultExportFromCjs(utcExports);
|
|
6
6
|
|
|
7
|
-
export {
|
|
7
|
+
export { utc as default };
|
|
8
8
|
//# sourceMappingURL=index61.js.map
|
package/dist/index62.js
CHANGED
|
@@ -1,8 +1,151 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import * as path from 'node:path';
|
|
2
|
+
import * as fs from 'node:fs/promises';
|
|
3
|
+
import { randomUUID } from 'node:crypto';
|
|
4
|
+
import { getLogger } from './index47.js';
|
|
5
|
+
import { PklTranscript } from '@redaksjon/protokoll-format';
|
|
3
6
|
|
|
4
|
-
|
|
5
|
-
const
|
|
7
|
+
const create = (config) => {
|
|
8
|
+
const logger = getLogger();
|
|
9
|
+
const formatTimestamp = (date) => {
|
|
10
|
+
const pad = (n) => n.toString().padStart(2, "0");
|
|
11
|
+
const year = date.getFullYear().toString();
|
|
12
|
+
const month = pad(date.getMonth() + 1);
|
|
13
|
+
const day = pad(date.getDate());
|
|
14
|
+
const hours = pad(date.getHours());
|
|
15
|
+
const minutes = pad(date.getMinutes());
|
|
16
|
+
return `${year}-${month}-${day}-${hours}${minutes}`;
|
|
17
|
+
};
|
|
18
|
+
const createOutputPaths = (_audioFile, routedDestination, hash, date) => {
|
|
19
|
+
const timestamp = formatTimestamp(date);
|
|
20
|
+
const shortHash = hash.slice(0, 6);
|
|
21
|
+
const buildFilename = (type, ext) => `${timestamp}-${type}-${shortHash}${ext}`;
|
|
22
|
+
const intermediateDir = config.intermediateDir;
|
|
23
|
+
let finalPath = routedDestination;
|
|
24
|
+
if (finalPath.endsWith(".md")) {
|
|
25
|
+
finalPath = finalPath.replace(/\.md$/, ".pkl");
|
|
26
|
+
} else if (!finalPath.endsWith(".pkl")) {
|
|
27
|
+
finalPath = finalPath + ".pkl";
|
|
28
|
+
}
|
|
29
|
+
const finalDir = path.dirname(finalPath);
|
|
30
|
+
const finalBasename = path.basename(finalPath, ".pkl");
|
|
31
|
+
const rawTranscriptPath = path.join(finalDir, ".transcript", `${finalBasename}.json`);
|
|
32
|
+
return {
|
|
33
|
+
final: finalPath,
|
|
34
|
+
rawTranscript: rawTranscriptPath,
|
|
35
|
+
intermediate: {
|
|
36
|
+
transcript: path.join(intermediateDir, buildFilename("transcript", ".json")),
|
|
37
|
+
context: path.join(intermediateDir, buildFilename("context", ".json")),
|
|
38
|
+
request: path.join(intermediateDir, buildFilename("request", ".json")),
|
|
39
|
+
response: path.join(intermediateDir, buildFilename("response", ".json")),
|
|
40
|
+
reflection: path.join(intermediateDir, buildFilename("reflection", ".md")),
|
|
41
|
+
session: path.join(intermediateDir, buildFilename("session", ".json"))
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
const ensureDirectories = async (paths) => {
|
|
46
|
+
await fs.mkdir(path.dirname(paths.intermediate.transcript), { recursive: true });
|
|
47
|
+
await fs.mkdir(path.dirname(paths.final), { recursive: true });
|
|
48
|
+
await fs.mkdir(path.dirname(paths.rawTranscript), { recursive: true });
|
|
49
|
+
logger.debug("Ensured output directories", {
|
|
50
|
+
intermediate: path.dirname(paths.intermediate.transcript),
|
|
51
|
+
final: path.dirname(paths.final),
|
|
52
|
+
rawTranscript: path.dirname(paths.rawTranscript)
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
const writeIntermediate = async (paths, type, content) => {
|
|
56
|
+
const filePath = paths.intermediate[type];
|
|
57
|
+
if (!filePath) {
|
|
58
|
+
throw new Error(`Invalid intermediate type: ${type}`);
|
|
59
|
+
}
|
|
60
|
+
const contentStr = typeof content === "string" ? content : JSON.stringify(content, null, 2);
|
|
61
|
+
await fs.writeFile(filePath, contentStr, "utf-8");
|
|
62
|
+
logger.debug("Wrote intermediate file", { type, path: filePath });
|
|
63
|
+
return filePath;
|
|
64
|
+
};
|
|
65
|
+
const writeTranscript = async (paths, content, metadata) => {
|
|
66
|
+
const pklRouting = metadata?.routing ? {
|
|
67
|
+
destination: metadata.routing.destination,
|
|
68
|
+
confidence: metadata.routing.confidence,
|
|
69
|
+
signals: metadata.routing.signals?.map(
|
|
70
|
+
(s) => typeof s === "string" ? s : `${s.type}: ${s.value} (weight: ${s.weight})`
|
|
71
|
+
),
|
|
72
|
+
reasoning: metadata.routing.reasoning
|
|
73
|
+
} : void 0;
|
|
74
|
+
const pklMetadata = metadata ? {
|
|
75
|
+
id: metadata.id || randomUUID(),
|
|
76
|
+
// Use provided UUID or generate new one
|
|
77
|
+
title: metadata.title,
|
|
78
|
+
date: metadata.date,
|
|
79
|
+
recordingTime: metadata.recordingTime,
|
|
80
|
+
project: metadata.project,
|
|
81
|
+
projectId: metadata.projectId,
|
|
82
|
+
tags: metadata.tags || [],
|
|
83
|
+
duration: metadata.duration,
|
|
84
|
+
status: metadata.status || "initial",
|
|
85
|
+
entities: metadata.entities,
|
|
86
|
+
routing: pklRouting
|
|
87
|
+
} : {
|
|
88
|
+
id: randomUUID(),
|
|
89
|
+
title: "Untitled",
|
|
90
|
+
tags: [],
|
|
91
|
+
status: "initial"
|
|
92
|
+
};
|
|
93
|
+
const transcript = PklTranscript.create(paths.final, pklMetadata);
|
|
94
|
+
try {
|
|
95
|
+
transcript.updateContent(content);
|
|
96
|
+
logger.info("Wrote final transcript", { path: paths.final });
|
|
97
|
+
} finally {
|
|
98
|
+
transcript.close();
|
|
99
|
+
}
|
|
100
|
+
return paths.final;
|
|
101
|
+
};
|
|
102
|
+
const cleanIntermediates = async (paths) => {
|
|
103
|
+
if (config.keepIntermediates) {
|
|
104
|
+
logger.debug("Keeping intermediate files");
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
for (const [type, filePath] of Object.entries(paths.intermediate)) {
|
|
108
|
+
if (filePath) {
|
|
109
|
+
try {
|
|
110
|
+
await fs.unlink(filePath);
|
|
111
|
+
logger.debug("Removed intermediate file", { type, path: filePath });
|
|
112
|
+
} catch {
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
const writeRawTranscript = async (paths, data) => {
|
|
118
|
+
const filePath = paths.rawTranscript;
|
|
119
|
+
await fs.writeFile(filePath, JSON.stringify(data, null, 2), "utf-8");
|
|
120
|
+
logger.debug("Wrote raw transcript to .transcript/", { path: filePath });
|
|
121
|
+
return filePath;
|
|
122
|
+
};
|
|
123
|
+
const readRawTranscript = async (finalOutputPath) => {
|
|
124
|
+
const finalDir = path.dirname(finalOutputPath);
|
|
125
|
+
const ext = path.extname(finalOutputPath);
|
|
126
|
+
const finalBasename = path.basename(finalOutputPath, ext);
|
|
127
|
+
const rawTranscriptPath = path.join(finalDir, ".transcript", `${finalBasename}.json`);
|
|
128
|
+
try {
|
|
129
|
+
const content = await fs.readFile(rawTranscriptPath, "utf-8");
|
|
130
|
+
return JSON.parse(content);
|
|
131
|
+
} catch (error) {
|
|
132
|
+
if (error && typeof error === "object" && "code" in error && error.code === "ENOENT") {
|
|
133
|
+
logger.debug("No raw transcript found", { path: rawTranscriptPath });
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
throw error;
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
return {
|
|
140
|
+
createOutputPaths,
|
|
141
|
+
ensureDirectories,
|
|
142
|
+
writeIntermediate,
|
|
143
|
+
writeRawTranscript,
|
|
144
|
+
writeTranscript,
|
|
145
|
+
readRawTranscript,
|
|
146
|
+
cleanIntermediates
|
|
147
|
+
};
|
|
148
|
+
};
|
|
6
149
|
|
|
7
|
-
export {
|
|
150
|
+
export { create };
|
|
8
151
|
//# sourceMappingURL=index62.js.map
|