@redaksjon/protokoll-engine 0.1.10 → 0.1.11-dev.20260301221841.afe8256

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 (45) hide show
  1. package/dist/index17.js.map +1 -1
  2. package/dist/index33.js +6 -2
  3. package/dist/index33.js.map +1 -1
  4. package/dist/index34.js +2 -2
  5. package/dist/index35.js +4 -4
  6. package/dist/index36.js +1 -1
  7. package/dist/index38.js.map +1 -1
  8. package/dist/index40.js.map +1 -1
  9. package/dist/index41.js.map +1 -1
  10. package/dist/index44.js.map +1 -1
  11. package/dist/index46.js.map +1 -1
  12. package/dist/index53.js +48 -5
  13. package/dist/index53.js.map +1 -1
  14. package/dist/index54.js +34 -46
  15. package/dist/index54.js.map +1 -1
  16. package/dist/index55.js +280 -35
  17. package/dist/index55.js.map +1 -1
  18. package/dist/index56.js +137 -258
  19. package/dist/index56.js.map +1 -1
  20. package/dist/index57.js +60 -142
  21. package/dist/index57.js.map +1 -1
  22. package/dist/index58.js +70 -73
  23. package/dist/index58.js.map +1 -1
  24. package/dist/index59.js +3 -73
  25. package/dist/index59.js.map +1 -1
  26. package/dist/index60.js +5 -148
  27. package/dist/index60.js.map +1 -1
  28. package/dist/index61.js +4 -4
  29. package/dist/index62.js +148 -5
  30. package/dist/index62.js.map +1 -1
  31. package/dist/pipeline/orchestrator.d.ts.map +1 -1
  32. package/dist/pipeline/types.d.ts +7 -0
  33. package/dist/pipeline/types.d.ts.map +1 -1
  34. package/dist/transcript/operations.d.ts +4 -2
  35. package/dist/transcript/operations.d.ts.map +1 -1
  36. package/dist/transcript/pkl-utils.d.ts +24 -1
  37. package/dist/transcript/pkl-utils.d.ts.map +1 -1
  38. package/dist/transcript/upload-utils.d.ts +17 -1
  39. package/dist/transcript/upload-utils.d.ts.map +1 -1
  40. package/dist/util/enhancement-logger.d.ts +22 -1
  41. package/dist/util/enhancement-logger.d.ts.map +1 -1
  42. package/dist/weighting/builder.d.ts.map +1 -1
  43. package/dist/weighting/prepositioning.d.ts +6 -1
  44. package/dist/weighting/prepositioning.d.ts.map +1 -1
  45. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"index17.js","sources":["../src/util/enhancement-logger.ts"],"sourcesContent":["/**\n * Enhancement Logger\n * \n * Utility for logging enhancement pipeline steps to the enhancement_log table.\n * Provides a simple interface that can be passed to pipeline phases.\n */\n\nimport type { EnhancementLogManager, EntityReference } from '@redaksjon/protokoll-format';\n\nexport interface EnhancementLogger {\n logStep(\n phase: 'transcribe' | 'enhance' | 'simple-replace',\n action: string,\n details?: Record<string, unknown>,\n entities?: EntityReference[]\n ): void;\n \n logSteps(steps: Array<{\n phase: 'transcribe' | 'enhance' | 'simple-replace';\n action: string;\n details?: Record<string, unknown>;\n entities?: EntityReference[];\n }>): void;\n}\n\n/**\n * Create an enhancement logger from an EnhancementLogManager\n */\nexport function createEnhancementLogger(manager: EnhancementLogManager): EnhancementLogger {\n return {\n logStep(phase, action, details, entities) {\n manager.logStep(new Date(), phase, action, details, entities);\n },\n \n logSteps(steps) {\n manager.logSteps(steps.map(step => ({\n ...step,\n timestamp: new Date(),\n })));\n },\n };\n}\n\n/**\n * Create a no-op logger for when enhancement logging is not available\n */\nexport function createNoOpLogger(): EnhancementLogger {\n return {\n logStep() {\n // No-op\n },\n logSteps() {\n // No-op\n },\n };\n}\n"],"names":[],"mappings":"AA4BO,SAAS,wBAAwB,OAAA,EAAmD;AACvF,EAAA,OAAO;AAAA,IACH,OAAA,CAAQ,KAAA,EAAO,MAAA,EAAQ,OAAA,EAAS,QAAA,EAAU;AACtC,MAAA,OAAA,CAAQ,wBAAQ,IAAI,IAAA,IAAQ,KAAA,EAAO,MAAA,EAAQ,SAAS,QAAQ,CAAA;AAAA,IAChE,CAAA;AAAA,IAEA,SAAS,KAAA,EAAO;AACZ,MAAA,OAAA,CAAQ,QAAA,CAAS,KAAA,CAAM,GAAA,CAAI,CAAA,IAAA,MAAS;AAAA,QAChC,GAAG,IAAA;AAAA,QACH,SAAA,sBAAe,IAAA;AAAK,QACtB,CAAC,CAAA;AAAA,IACP;AAAA,GACJ;AACJ;AAKO,SAAS,gBAAA,GAAsC;AAClD,EAAA,OAAO;AAAA,IACH,OAAA,GAAU;AAAA,IAEV,CAAA;AAAA,IACA,QAAA,GAAW;AAAA,IAEX;AAAA,GACJ;AACJ;;;;"}
1
+ {"version":3,"file":"index17.js","sources":["../src/util/enhancement-logger.ts"],"sourcesContent":["/**\n * Enhancement Logger\n * \n * Utility for logging enhancement pipeline steps to the enhancement_log table.\n * Provides a simple interface that can be passed to pipeline phases.\n */\n\ntype EntityReference = { id: string; name?: string; type?: string };\n\ninterface EnhancementLogManager {\n logStep(\n timestamp: Date,\n phase: 'transcribe' | 'enhance' | 'simple-replace',\n action: string,\n details?: Record<string, unknown>,\n entities?: EntityReference[]\n ): void;\n logSteps(steps: Array<{\n timestamp: Date;\n phase: 'transcribe' | 'enhance' | 'simple-replace';\n action: string;\n details?: Record<string, unknown>;\n entities?: EntityReference[];\n }>): void;\n}\n\nexport interface EnhancementLogger {\n logStep(\n phase: 'transcribe' | 'enhance' | 'simple-replace',\n action: string,\n details?: Record<string, unknown>,\n entities?: EntityReference[]\n ): void;\n \n logSteps(steps: Array<{\n phase: 'transcribe' | 'enhance' | 'simple-replace';\n action: string;\n details?: Record<string, unknown>;\n entities?: EntityReference[];\n }>): void;\n}\n\n/**\n * Create an enhancement logger from an EnhancementLogManager\n */\nexport function createEnhancementLogger(manager: EnhancementLogManager): EnhancementLogger {\n return {\n logStep(phase, action, details, entities) {\n manager.logStep(new Date(), phase, action, details, entities);\n },\n \n logSteps(steps) {\n manager.logSteps(steps.map(step => ({\n ...step,\n timestamp: new Date(),\n })));\n },\n };\n}\n\n/**\n * Create a no-op logger for when enhancement logging is not available\n */\nexport function createNoOpLogger(): EnhancementLogger {\n return {\n logStep() {\n // No-op\n },\n logSteps() {\n // No-op\n },\n };\n}\n"],"names":[],"mappings":"AA6CO,SAAS,wBAAwB,OAAA,EAAmD;AACvF,EAAA,OAAO;AAAA,IACH,OAAA,CAAQ,KAAA,EAAO,MAAA,EAAQ,OAAA,EAAS,QAAA,EAAU;AACtC,MAAA,OAAA,CAAQ,wBAAQ,IAAI,IAAA,IAAQ,KAAA,EAAO,MAAA,EAAQ,SAAS,QAAQ,CAAA;AAAA,IAChE,CAAA;AAAA,IAEA,SAAS,KAAA,EAAO;AACZ,MAAA,OAAA,CAAQ,QAAA,CAAS,KAAA,CAAM,GAAA,CAAI,CAAA,IAAA,MAAS;AAAA,QAChC,GAAG,IAAA;AAAA,QACH,SAAA,sBAAe,IAAA;AAAK,QACtB,CAAC,CAAA;AAAA,IACP;AAAA,GACJ;AACJ;AAKO,SAAS,gBAAA,GAAsC;AAClD,EAAA,OAAO;AAAA,IACH,OAAA,GAAU;AAAA,IAEV,CAAA;AAAA,IACA,QAAA,GAAW;AAAA,IAEX;AAAA,GACJ;AACJ;;;;"}
package/dist/index33.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as Context from '@redaksjon/context';
2
2
  import { create as create$1 } from './index6.js';
3
- import { create as create$2 } from './index53.js';
3
+ import { create as create$2 } from './index59.js';
4
4
  import { create as create$3 } from './index11.js';
5
5
  import { create as create$4 } from './index3.js';
6
6
  import { create as create$5 } from './index2.js';
@@ -16,7 +16,7 @@ const create = async (config) => {
16
16
  const logger = getLogger();
17
17
  const currentWorkingDir = globalThis.process.cwd();
18
18
  logger.debug("Initializing intelligent transcription pipeline...");
19
- const context = await Context.create({
19
+ const context = config.contextInstance ?? await Context.create({
20
20
  startingDir: config.contextDirectory || currentWorkingDir,
21
21
  contextDirectories: config.contextDirectories
22
22
  });
@@ -352,24 +352,28 @@ ${textSample}`
352
352
  companies: []
353
353
  };
354
354
  for (const personId of refs.people) {
355
+ if (!personId) continue;
355
356
  const person = context.getPerson(personId);
356
357
  if (person) {
357
358
  entities.people.push({ id: person.id, name: person.name, type: "person" });
358
359
  }
359
360
  }
360
361
  for (const projectId of refs.projects) {
362
+ if (!projectId) continue;
361
363
  const project = context.getProject(projectId);
362
364
  if (project) {
363
365
  entities.projects.push({ id: project.id, name: project.name, type: "project" });
364
366
  }
365
367
  }
366
368
  for (const termId of refs.terms) {
369
+ if (!termId) continue;
367
370
  const term = context.getTerm(termId);
368
371
  if (term) {
369
372
  entities.terms.push({ id: term.id, name: term.name, type: "term" });
370
373
  }
371
374
  }
372
375
  for (const companyId of refs.companies) {
376
+ if (!companyId) continue;
373
377
  const company = context.getCompany(companyId);
374
378
  if (company) {
375
379
  entities.companies.push({ id: company.id, name: company.name, type: "company" });
@@ -1 +1 @@
1
- {"version":3,"file":"index33.js","sources":["../src/pipeline/orchestrator.ts"],"sourcesContent":["/**\n * Pipeline Orchestrator\n *\n * Orchestrates the intelligent transcription pipeline, coordinating\n * all the modules: context, routing, transcription, reasoning,\n * agentic tools, interactive mode, output management, and reflection.\n * \n * THIS IS THE MAIN PROCESSING FLOW - NOT DEAD CODE!\n */\n\nimport { PipelineConfig, PipelineInput, PipelineResult, PipelineState } from './types';\nimport * as Context from '@redaksjon/context';\nimport * as Routing from '../routing';\nimport * as Output from '../out';\nimport * as Reflection from '../reflection';\nimport * as Transcription from '../transcription';\nimport * as Reasoning from '../reasoning';\nimport * as Agentic from '../agentic';\nimport * as CompletePhase from '../phases/complete';\nimport * as SimpleReplace from '../phases/simple-replace';\nimport * as Logging from '../logging';\nimport { randomUUID } from 'node:crypto';\nimport * as path from 'node:path';\nimport * as Metadata from '../util/metadata';\n\nexport interface OrchestratorInstance {\n process(input: PipelineInput): Promise<PipelineResult>;\n}\n\nexport interface OrchestratorConfig extends PipelineConfig {\n outputDirectory: string;\n outputStructure: string;\n outputFilenameOptions: string[];\n maxAudioSize: number;\n tempDirectory: string;\n}\n\nexport const create = async (config: OrchestratorConfig): Promise<OrchestratorInstance> => {\n const logger = Logging.getLogger();\n const currentWorkingDir = globalThis.process.cwd();\n \n logger.debug('Initializing intelligent transcription pipeline...');\n \n // Initialize context system (async)\n // Use explicit contextDirectories from config if provided (from protokoll-config.yaml)\n const context = await Context.create({\n startingDir: config.contextDirectory || currentWorkingDir,\n contextDirectories: config.contextDirectories,\n });\n logger.debug('Context system initialized - ready to query entities via tools');\n \n // Default routing configuration (used as fallback for projects without custom destination)\n const defaultPath = config.outputDirectory || '~/notes';\n const defaultStructure = (config.outputStructure || 'month') as Routing.FilesystemStructure;\n const defaultFilenameOptions = (config.outputFilenameOptions || ['date', 'time', 'subject']) as Routing.FilenameOption[];\n\n // Convert context projects to routing format\n // Projects without a destination inherit from the global default\n const contextProjects = context.getAllProjects();\n const routingProjects: Routing.ProjectRoute[] = contextProjects\n .filter(project => project.active !== false)\n .map(project => ({\n projectId: project.id,\n destination: {\n path: project.routing?.destination || defaultPath,\n structure: project.routing?.structure || defaultStructure,\n filename_options: project.routing?.filename_options || defaultFilenameOptions,\n createDirectories: true,\n },\n classification: project.classification,\n active: project.active,\n auto_tags: project.routing?.auto_tags,\n }));\n \n logger.debug('Loaded %d projects from context for routing', routingProjects.length);\n \n // Initialize routing with config-based defaults\n const routingConfig: Routing.RoutingConfig = {\n default: {\n path: defaultPath,\n structure: defaultStructure,\n filename_options: defaultFilenameOptions,\n createDirectories: true,\n },\n projects: routingProjects,\n conflict_resolution: 'primary',\n };\n \n const routing = Routing.create(routingConfig, context, config.weightModelProvider);\n logger.debug('Routing system initialized');\n \n // Interactive moved to protokoll-cli\n // const interactive = Interactive.create(\n // { enabled: config.interactive, defaultToSuggestion: true, silent: config.silent },\n // context\n // );\n \n const output = Output.create({\n intermediateDir: config.intermediateDir || './output/protokoll',\n keepIntermediates: config.keepIntermediates ?? true,\n timestampFormat: 'YYMMDD-HHmm',\n });\n logger.debug('Output manager initialized');\n \n const reflection = config.selfReflection \n ? Reflection.create({\n enabled: true,\n format: 'markdown',\n includeConversation: false,\n includeOutput: true,\n })\n : null;\n if (reflection) {\n logger.debug('Self-reflection system enabled');\n }\n \n // Initialize transcription service\n const transcription = Transcription.create({\n defaultModel: config.transcriptionModel as Transcription.TranscriptionModel,\n });\n logger.debug('Transcription service initialized with model: %s', config.transcriptionModel);\n \n // Initialize reasoning for agentic processing\n const reasoning = Reasoning.create({ \n model: config.model,\n reasoningLevel: config.reasoningLevel,\n });\n logger.debug('Reasoning system initialized with model: %s, reasoning level: %s', config.model, config.reasoningLevel || 'medium');\n\n // Initialize simple-replace phase for pre-LLM entity correction via sounds_like\n const simpleReplace = SimpleReplace.create({ debug: config.debug }, context);\n logger.debug('Simple-replace phase initialized with context instance');\n\n // Initialize complete phase for moving files to processed directory\n // Pass outputStructure so processed files use the same directory structure as output\n const complete = config.processedDirectory \n ? CompletePhase.create({\n processedDirectory: config.processedDirectory,\n outputStructure: config.outputStructure as CompletePhase.FilesystemStructure,\n dryRun: config.dryRun,\n })\n : null;\n if (complete) {\n logger.debug('Complete phase initialized with processed directory: %s', config.processedDirectory);\n }\n \n // Helper to extract a human-readable title from the output path\n const extractTitleFromPath = (outputPath: string): string | undefined => {\n const filename = outputPath.split('/').pop()?.replace(/\\.(md|pkl)$/, '');\n if (!filename) return undefined;\n \n // Remove date prefix (e.g., \"27-0716-\" from \"27-0716-meeting-notes\")\n const withoutDate = filename.replace(/^\\d{2}-\\d{4}-/, '');\n if (!withoutDate) return undefined;\n \n // Convert kebab-case to Title Case\n return withoutDate\n .split('-')\n .map(word => word.charAt(0).toUpperCase() + word.slice(1))\n .join(' ');\n };\n \n // Helper to check if a title is meaningful (not just numbers/timestamps)\n const isMeaningfulTitle = (title: string | undefined): boolean => {\n if (!title) return false;\n // Reject UUID-like strings (hex characters separated by dashes, e.g. filenames from recordings)\n const uuidPattern = /^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$/i;\n if (uuidPattern.test(title.trim())) return false;\n // Also reject if the title starts with a UUID segment pattern (Title Case converted UUID)\n const uuidSegmentPattern = /^[0-9a-f]{8}\\s[0-9a-f]{4}\\s/i;\n if (uuidSegmentPattern.test(title.trim())) return false;\n // Check if title is mostly numbers (timestamp-like) or very short fragments\n const stripped = title.replace(/\\s+/g, '');\n const numberRatio = (stripped.match(/\\d/g) || []).length / stripped.length;\n // Reject if: mostly numbers, too short, or common bad patterns\n if (numberRatio > 0.5) return false;\n if (stripped.length < 3) return false;\n // Reject titles that are just common words without context\n const badPatterns = /^(i|i have|i am|the|a|an|um|uh|so|well|okay|oh|hey|hi)$/i;\n if (badPatterns.test(title.trim())) return false;\n return true;\n };\n \n // Generate a meaningful title from transcript content using LLM\n const generateTitleFromContent = async (transcriptText: string, fallbackTitle?: string): Promise<string> => {\n try {\n // Use first ~2000 chars for title generation (enough context, not too expensive)\n const textSample = transcriptText.slice(0, 2000);\n \n const response = await reasoning.complete({\n systemPrompt: `You are a title generator. Given a transcript, generate a concise, descriptive title (3-8 words) that captures the main topic or theme.\n\nRules:\n- Output ONLY the title, nothing else\n- No quotes around the title\n- Use Title Case\n- Be specific - avoid generic titles like \"Meeting Notes\" or \"Discussion\"\n- Focus on the main subject matter\n- If there are multiple topics, pick the most prominent one`,\n prompt: `Generate a title for this transcript:\\n\\n${textSample}`,\n });\n \n // Clean up the response - remove quotes, trim whitespace\n const title = response.content\n .trim()\n .replace(/^[\"']|[\"']$/g, '') // Remove surrounding quotes\n .replace(/^#\\s*/, '') // Remove markdown heading prefix\n .trim();\n \n // Validate the generated title\n if (title && title.length > 0 && title.length < 100) {\n logger.debug('Generated title from content: %s', title);\n return title;\n }\n \n logger.debug('Generated title was invalid, using fallback');\n return fallbackTitle || 'Untitled';\n } catch (error) {\n logger.warn('Title generation failed, using fallback', { error });\n return fallbackTitle || 'Untitled';\n }\n };\n\n const processInput = async (input: PipelineInput): Promise<PipelineResult> => {\n const startTime = Date.now();\n \n // Format progress prefix for log messages\n const progressPrefix = input.progress \n ? `[${input.progress.current}/${input.progress.total}]` \n : '';\n const log = (level: 'info' | 'debug', message: string, ...args: unknown[]) => {\n const prefixedMessage = progressPrefix ? `${progressPrefix} ${message}` : message;\n if (level === 'info') {\n logger.info(prefixedMessage, ...args);\n } else {\n logger.debug(prefixedMessage, ...args);\n }\n };\n \n log('info', 'Processing: %s (hash: %s)', input.audioFile, input.hash);\n \n // Initialize state\n const state: PipelineState = {\n input,\n startTime: new Date(),\n };\n \n // Start reflection collection if enabled\n if (reflection) {\n reflection.collector.start();\n }\n \n // Start interactive session if enabled\n // Interactive moved to protokoll-cli\n // if (config.interactive) {\n // interactive.startSession();\n // log('debug', 'Interactive session started');\n // }\n \n try {\n // Step 1: Check onboarding needs (moved to protokoll-cli)\n log('debug', 'Checking onboarding state...');\n // const onboardingState = interactive.checkNeedsOnboarding();\n const onboardingState = { needsOnboarding: false }; // Stub\n if (onboardingState.needsOnboarding) {\n log('debug', 'First-run detected - onboarding may be triggered');\n }\n \n // Step 2: Raw transcription using Transcription module\n log('info', 'Transcribing audio...');\n const whisperStart = Date.now();\n \n const transcriptionResult = await transcription.transcribe(input.audioFile, {\n model: config.transcriptionModel as Transcription.TranscriptionModel,\n });\n state.rawTranscript = transcriptionResult.text;\n \n const whisperDuration = Date.now() - whisperStart;\n log('info', 'Transcription: %d chars in %.1fs', \n state.rawTranscript.length, whisperDuration / 1000);\n \n if (reflection) {\n reflection.collector.recordWhisper(whisperDuration);\n }\n \n // Step 3: Route detection\n log('debug', 'Determining routing destination...');\n const routingContext: Routing.RoutingContext = {\n transcriptText: state.rawTranscript || '',\n audioDate: input.creation,\n sourceFile: input.audioFile,\n hash: input.hash,\n };\n \n const routeResult = routing.route(routingContext);\n \n log('debug', 'Routing decision: project=%s, confidence=%.2f', \n routeResult.projectId || 'default', routeResult.confidence);\n \n // Record routing decision in reflection\n if (reflection) {\n reflection.collector.recordRoutingDecision({\n projectId: routeResult.projectId,\n destination: routeResult.destination.path,\n confidence: routeResult.confidence,\n reasoning: routeResult.reasoning,\n signals: routeResult.signals.map(s => ({\n type: s.type,\n value: s.value,\n weight: s.weight,\n })),\n alternativesConsidered: routeResult.alternateMatches?.map(alt => ({\n projectId: alt.projectId,\n confidence: alt.confidence,\n whyNotChosen: `Lower confidence (${(alt.confidence * 100).toFixed(1)}%)`,\n })),\n });\n }\n \n // Build output path\n const outputPath = routing.buildOutputPath(routeResult, routingContext);\n log('debug', 'Output path: %s', outputPath);\n \n // Step 4: Create output paths using Output module\n log('debug', 'Setting up output directories...');\n const paths = output.createOutputPaths(\n input.audioFile,\n outputPath,\n input.hash,\n input.creation\n );\n \n await output.ensureDirectories(paths);\n \n // Write raw transcript to intermediate (for debugging)\n await output.writeIntermediate(paths, 'transcript', {\n text: state.rawTranscript,\n model: config.transcriptionModel,\n duration: whisperDuration,\n });\n\n // Step 4b: Simple-replace phase — sounds_like entity correction before LLM\n // Matches entity names (projects, people, terms) using sounds_like mappings,\n // corrects them in the transcript text, and tracks which entities were found.\n log('debug', 'Running simple-replace (sounds_like entity matching)...');\n // Derive the intermediate directory from an existing intermediate file path\n const intermediateDir = path.dirname(paths.intermediate.transcript);\n const simpleReplaceResult = await simpleReplace.replace(\n state.rawTranscript || '',\n {\n project: routeResult.projectId ?? undefined,\n confidence: routeResult.confidence,\n },\n intermediateDir,\n input.hash\n );\n\n if (simpleReplaceResult.replacementsMade) {\n log('info',\n 'Simple-replace: %d correction(s) applied (%d Tier-1, %d Tier-2)',\n simpleReplaceResult.stats.totalReplacements,\n simpleReplaceResult.stats.tier1Replacements,\n simpleReplaceResult.stats.tier2Replacements\n );\n // Write the corrected text to intermediate for inspection\n await output.writeIntermediate(paths, 'session', {\n simpleReplace: {\n replacementsMade: true,\n stats: simpleReplaceResult.stats,\n },\n });\n } else {\n log('debug', 'Simple-replace: no replacements made');\n }\n\n // Notify caller (e.g. worker) so it can write to the PKL enhancement log\n input.onSimpleReplaceComplete?.(simpleReplaceResult.stats);\n\n // Collect pre-identified entities from simple-replace applied mappings\n const preIdentifiedEntities: Agentic.ToolContext['preIdentifiedEntities'] = {\n people: new Set<string>(),\n projects: new Set<string>(),\n terms: new Set<string>(),\n companies: new Set<string>(),\n };\n for (const mapping of simpleReplaceResult.stats.appliedMappings) {\n if (!mapping.entityId || !mapping.entityType) continue;\n if (mapping.entityType === 'person') preIdentifiedEntities.people.add(mapping.entityId);\n else if (mapping.entityType === 'project') preIdentifiedEntities.projects.add(mapping.entityId);\n else if (mapping.entityType === 'term') preIdentifiedEntities.terms.add(mapping.entityId);\n else if (mapping.entityType === 'company') preIdentifiedEntities.companies.add(mapping.entityId);\n }\n \n // Step 5: Agentic enhancement using real executor\n // The LLM receives the already-corrected text (simple-replace output)\n // and is told which entities were pre-matched so it doesn't re-lookup them.\n log('info', 'Enhancing with %s...', config.model);\n \n const agenticStart = Date.now();\n const toolContext: Agentic.ToolContext = {\n transcriptText: simpleReplaceResult.text,\n audioDate: input.creation,\n sourceFile: input.audioFile,\n contextInstance: context,\n routingInstance: routing,\n preIdentifiedEntities,\n interactiveMode: config.interactive,\n // Interactive moved to protokoll-cli\n // interactiveInstance: interactive,\n weightModelProvider: config.weightModelProvider,\n onToolCallStart: input.onToolCallStart,\n onToolCallComplete: input.onToolCallComplete,\n };\n \n const executor = Agentic.create(reasoning, toolContext);\n const agenticResult = await executor.process(simpleReplaceResult.text);\n \n state.enhancedText = agenticResult.enhancedText;\n const toolsUsed = agenticResult.toolsUsed;\n const agenticDuration = Date.now() - agenticStart;\n \n // Record tool calls in reflection\n if (reflection) {\n for (const tool of toolsUsed) {\n reflection.collector.recordToolCall(tool, agenticDuration / toolsUsed.length, true);\n }\n reflection.collector.recordCorrection(state.rawTranscript || '', state.enhancedText);\n // Record token usage from agentic result\n if (agenticResult.totalTokens) {\n reflection.collector.recordModelResponse(config.model, agenticResult.totalTokens);\n }\n // Record context changes (new projects, entities created)\n if (agenticResult.contextChanges) {\n for (const change of agenticResult.contextChanges) {\n reflection.collector.recordContextChange(change);\n }\n }\n }\n \n // Write agentic session to intermediate\n await output.writeIntermediate(paths, 'session', {\n iterations: agenticResult.iterations,\n toolsUsed: agenticResult.toolsUsed,\n state: agenticResult.state,\n });\n \n // Step 5b: Check if agentic processing found a different route\n // (e.g., via lookup_project tool finding a project with custom destination)\n if (agenticResult.state.routeDecision?.destination?.path) {\n const agenticRoute = agenticResult.state.routeDecision;\n log('debug', 'Agentic processing found route: %s -> %s', \n agenticRoute.projectId || 'unknown', \n agenticRoute.destination.path\n );\n \n // Update routeResult with the agentic decision\n routeResult.projectId = agenticRoute.projectId || routeResult.projectId;\n routeResult.destination = {\n ...routeResult.destination,\n path: agenticRoute.destination.path,\n structure: agenticRoute.destination.structure || routeResult.destination.structure,\n };\n routeResult.confidence = agenticRoute.confidence || routeResult.confidence;\n routeResult.reasoning = agenticRoute.reasoning || routeResult.reasoning;\n if (agenticRoute.signals) {\n routeResult.signals = agenticRoute.signals;\n }\n \n // Rebuild output path with the new destination\n const newOutputPath = routing.buildOutputPath(routeResult, routingContext);\n log('debug', 'Updated output path: %s -> %s', outputPath, newOutputPath);\n \n // Recreate output paths with new destination\n const newPaths = output.createOutputPaths(\n input.audioFile,\n newOutputPath,\n input.hash,\n input.creation\n );\n await output.ensureDirectories(newPaths);\n \n // Update paths reference (reassign properties since paths is const)\n Object.assign(paths, newPaths);\n }\n\n // Step 5c: Write raw transcript to .transcript/ directory alongside final output\n // This is done AFTER the route is finalized so it goes to the correct location\n // Enables compare and reanalyze workflows\n log('debug', 'Writing raw transcript to .transcript/ directory...');\n await output.writeRawTranscript(paths, {\n text: state.rawTranscript,\n model: config.transcriptionModel,\n duration: whisperDuration,\n audioFile: input.audioFile,\n audioHash: input.hash,\n transcribedAt: new Date().toISOString(),\n });\n\n // Step 6: Write final output using Output module with metadata\n log('debug', 'Writing final transcript...');\n let finalTitle: string | undefined;\n let finalEntities: Metadata.TranscriptMetadata['entities'] | undefined;\n if (state.enhancedText) {\n // Build entity metadata from referenced entities\n const buildEntityReferences = (): Metadata.TranscriptMetadata['entities'] => {\n const refs = agenticResult.state.referencedEntities;\n if (!refs) return undefined;\n \n const entities: NonNullable<Metadata.TranscriptMetadata['entities']> = {\n people: [],\n projects: [],\n terms: [],\n companies: [],\n };\n \n // Convert sets of IDs to EntityReference arrays\n for (const personId of refs.people) {\n const person = context.getPerson(personId);\n if (person) {\n entities.people!.push({ id: person.id, name: person.name, type: 'person' });\n }\n }\n \n for (const projectId of refs.projects) {\n const project = context.getProject(projectId);\n if (project) {\n entities.projects!.push({ id: project.id, name: project.name, type: 'project' });\n }\n }\n \n for (const termId of refs.terms) {\n const term = context.getTerm(termId);\n if (term) {\n entities.terms!.push({ id: term.id, name: term.name, type: 'term' });\n }\n }\n \n for (const companyId of refs.companies) {\n const company = context.getCompany(companyId);\n if (company) {\n entities.companies!.push({ id: company.id, name: company.name, type: 'company' });\n }\n }\n \n // Only return if we found any entities\n const hasEntities = \n entities.people!.length > 0 ||\n entities.projects!.length > 0 ||\n entities.terms!.length > 0 ||\n entities.companies!.length > 0;\n \n return hasEntities ? entities : undefined;\n };\n \n // Generate title - prefer path-derived title if meaningful, otherwise use LLM\n const pathTitle = extractTitleFromPath(paths.final);\n let title: string;\n if (isMeaningfulTitle(pathTitle)) {\n title = pathTitle!;\n } else {\n log('debug', 'Path-derived title not meaningful (%s), generating from content...', pathTitle || 'empty');\n title = await generateTitleFromContent(state.enhancedText, pathTitle);\n log('info', 'Generated title: %s', title);\n \n // Rebuild output path with the generated title as the subject\n // This ensures the filename matches the title\n const contextWithTitle: Routing.RoutingContext = {\n ...routingContext,\n subjectOverride: title,\n };\n const newOutputPath = routing.buildOutputPath(routeResult, contextWithTitle);\n \n if (newOutputPath !== paths.final) {\n log('debug', 'Updating output path with generated title: %s -> %s', paths.final, newOutputPath);\n \n // Recreate output paths with the new filename\n const newPaths = output.createOutputPaths(\n input.audioFile,\n newOutputPath,\n input.hash,\n input.creation\n );\n await output.ensureDirectories(newPaths);\n \n // Update paths reference\n Object.assign(paths, newPaths);\n }\n }\n \n // Generate UUID for this transcript\n const transcriptUuid = randomUUID();\n \n // Build metadata from routing decision and input\n const transcriptMetadata: Metadata.TranscriptMetadata = {\n id: transcriptUuid,\n title,\n projectId: routeResult.projectId || undefined,\n project: routeResult.projectId ? (context.getProject(routeResult.projectId)?.name || undefined) : undefined,\n date: input.creation,\n routing: Metadata.createRoutingMetadata(routeResult),\n tags: Metadata.extractTagsFromSignals(routeResult.signals),\n confidence: routeResult.confidence,\n entities: buildEntityReferences(),\n };\n \n await output.writeTranscript(paths, state.enhancedText, transcriptMetadata);\n finalTitle = title;\n finalEntities = transcriptMetadata.entities;\n \n // Notify weight model of entity updates (if callback provided)\n if (config.onTranscriptEntitiesUpdated && transcriptMetadata.entities) {\n const allEntityIds: string[] = [];\n if (transcriptMetadata.entities.people) {\n allEntityIds.push(...transcriptMetadata.entities.people.map(e => e.id));\n }\n if (transcriptMetadata.entities.projects) {\n allEntityIds.push(...transcriptMetadata.entities.projects.map(e => e.id));\n }\n if (transcriptMetadata.entities.terms) {\n allEntityIds.push(...transcriptMetadata.entities.terms.map(e => e.id));\n }\n if (transcriptMetadata.entities.companies) {\n allEntityIds.push(...transcriptMetadata.entities.companies.map(e => e.id));\n }\n \n config.onTranscriptEntitiesUpdated(\n transcriptUuid,\n allEntityIds,\n routeResult.projectId || undefined\n );\n }\n }\n \n // Step 7: Generate reflection report\n log('debug', 'Generating reflection report...');\n let reflectionReport: Reflection.ReflectionReport | undefined;\n if (reflection) {\n reflectionReport = reflection.generate(\n input.audioFile,\n paths.final,\n undefined,\n state.enhancedText\n );\n \n if (paths.intermediate.reflection) {\n await reflection.save(reflectionReport, paths.intermediate.reflection);\n }\n }\n \n // Step 8: End interactive session (moved to protokoll-cli)\n log('debug', 'Finalizing session...');\n // let session: Interactive.InteractiveSession | undefined;\n // if (config.interactive) {\n // session = interactive.endSession();\n // log('debug', 'Interactive session ended: %d clarifications', session.responses.length);\n // // Save session if path available\n // if (paths.intermediate.session) {\n // await output.writeIntermediate(paths, 'session', session);\n // }\n // }\n \n // Step 9: Cleanup if needed\n if (!config.keepIntermediates && !config.debug) {\n await output.cleanIntermediates(paths);\n }\n\n // Step 10: Move audio file to processed directory\n let processedAudioPath: string | undefined;\n if (complete) {\n // Extract subject from output path for naming\n const subject = paths.final.split('/').pop()?.replace('.md', '') || undefined;\n processedAudioPath = await complete.complete(\n input.audioFile, \n input.hash, \n input.creation,\n subject\n );\n }\n \n const processingTime = Date.now() - startTime;\n \n // Compact summary output\n log('info', 'Enhancement: %d iterations, %d tools, %.1fs', \n agenticResult.iterations, toolsUsed.length, agenticDuration / 1000);\n if (agenticResult.totalTokens) {\n log('info', 'Tokens: %d total', agenticResult.totalTokens);\n }\n log('info', 'Output: %s (%.1fs total)', paths.final, processingTime / 1000);\n \n return {\n outputPath: paths.final,\n enhancedText: state.enhancedText || '',\n rawTranscript: state.rawTranscript || '',\n title: finalTitle || '',\n routedProject: routeResult.projectId,\n routedProjectName: routeResult.projectId ? (context.getProject(routeResult.projectId)?.name || null) : null,\n routingConfidence: routeResult.confidence,\n entities: finalEntities,\n processingTime,\n toolsUsed,\n correctionsApplied: agenticResult.state.resolvedEntities.size,\n processedAudioPath,\n reflection: reflectionReport,\n // session, // Interactive moved to protokoll-cli\n intermediatePaths: paths,\n };\n \n } catch (error) {\n logger.error('Pipeline error', { error });\n throw error;\n }\n };\n \n return { process: processInput };\n};\n"],"names":["Logging.getLogger","Routing.create","Output.create","Reflection.create","Transcription.create","Reasoning.create","SimpleReplace.create","CompletePhase.create","Agentic.create","Metadata.createRoutingMetadata","Metadata.extractTagsFromSignals"],"mappings":";;;;;;;;;;;;;;AAqCO,MAAM,MAAA,GAAS,OAAO,MAAA,KAA8D;AACvF,EAAA,MAAM,MAAA,GAASA,SAAQ,EAAU;AACjC,EAAA,MAAM,iBAAA,GAAoB,UAAA,CAAW,OAAA,CAAQ,GAAA,EAAI;AAEjD,EAAA,MAAA,CAAO,MAAM,oDAAoD,CAAA;AAIjE,EAAA,MAAM,OAAA,GAAU,MAAM,OAAA,CAAQ,MAAA,CAAO;AAAA,IACjC,WAAA,EAAa,OAAO,gBAAA,IAAoB,iBAAA;AAAA,IACxC,oBAAoB,MAAA,CAAO;A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e,MAAM,aAAA,IAAiB,EAAA;AAAA,QACtC,OAAO,UAAA,IAAc,EAAA;AAAA,QACrB,eAAe,WAAA,CAAY,SAAA;AAAA,QAC3B,iBAAA,EAAmB,YAAY,SAAA,GAAa,OAAA,CAAQ,WAAW,WAAA,CAAY,SAAS,CAAA,EAAG,IAAA,IAAQ,IAAA,GAAQ,IAAA;AAAA,QACvG,mBAAmB,WAAA,CAAY,UAAA;AAAA,QAC/B,QAAA,EAAU,aAAA;AAAA,QACV,cAAA;AAAA,QACA,SAAA;AAAA,QACA,kBAAA,EAAoB,aAAA,CAAc,KAAA,CAAM,gBAAA,CAAiB,IAAA;AAAA,QACzD,kBAAA;AAAA,QACA,UAAA,EAAY,gBAAA;AAAA;AAAA,QAEZ,iBAAA,EAAmB;AAAA,OACvB;AAAA,IAEJ,SAAS,KAAA,EAAO;AACZ,MAAA,MAAA,CAAO,KAAA,CAAM,gBAAA,EAAkB,EAAE,KAAA,EAAO,CAAA;AACxC,MAAA,MAAM,KAAA;AAAA,IACV;AAAA,EACJ,CAAA;AAEA,EAAA,OAAO,EAAE,SAAS,YAAA,EAAa;AACnC;;;;"}
1
+ {"version":3,"file":"index33.js","sources":["../src/pipeline/orchestrator.ts"],"sourcesContent":["/**\n * Pipeline Orchestrator\n *\n * Orchestrates the intelligent transcription pipeline, coordinating\n * all the modules: context, routing, transcription, reasoning,\n * agentic tools, interactive mode, output management, and reflection.\n * \n * THIS IS THE MAIN PROCESSING FLOW - NOT DEAD CODE!\n */\n\nimport { PipelineConfig, PipelineInput, PipelineResult, PipelineState } from './types';\nimport * as Context from '@redaksjon/context';\nimport * as Routing from '../routing';\nimport * as Output from '../out';\nimport * as Reflection from '../reflection';\nimport * as Transcription from '../transcription';\nimport * as Reasoning from '../reasoning';\nimport * as Agentic from '../agentic';\nimport * as CompletePhase from '../phases/complete';\nimport * as SimpleReplace from '../phases/simple-replace';\nimport * as Logging from '../logging';\nimport { randomUUID } from 'node:crypto';\nimport * as path from 'node:path';\nimport * as Metadata from '../util/metadata';\n\nexport interface OrchestratorInstance {\n process(input: PipelineInput): Promise<PipelineResult>;\n}\n\nexport interface OrchestratorConfig extends PipelineConfig {\n outputDirectory: string;\n outputStructure: string;\n outputFilenameOptions: string[];\n maxAudioSize: number;\n tempDirectory: string;\n}\n\nexport const create = async (config: OrchestratorConfig): Promise<OrchestratorInstance> => {\n const logger = Logging.getLogger();\n const currentWorkingDir = globalThis.process.cwd();\n \n logger.debug('Initializing intelligent transcription pipeline...');\n \n // Initialize context system (async)\n // Prefer a pre-loaded context instance (required for GCS-backed storage);\n // otherwise create one from contextDirectory/contextDirectories.\n const context = config.contextInstance ?? await Context.create({\n startingDir: config.contextDirectory || currentWorkingDir,\n contextDirectories: config.contextDirectories,\n });\n logger.debug('Context system initialized - ready to query entities via tools');\n \n // Default routing configuration (used as fallback for projects without custom destination)\n const defaultPath = config.outputDirectory || '~/notes';\n const defaultStructure = (config.outputStructure || 'month') as Routing.FilesystemStructure;\n const defaultFilenameOptions = (config.outputFilenameOptions || ['date', 'time', 'subject']) as Routing.FilenameOption[];\n\n // Convert context projects to routing format\n // Projects without a destination inherit from the global default\n const contextProjects = context.getAllProjects();\n const routingProjects: Routing.ProjectRoute[] = contextProjects\n .filter(project => project.active !== false)\n .map(project => ({\n projectId: project.id,\n destination: {\n path: project.routing?.destination || defaultPath,\n structure: project.routing?.structure || defaultStructure,\n filename_options: project.routing?.filename_options || defaultFilenameOptions,\n createDirectories: true,\n },\n classification: project.classification,\n active: project.active,\n auto_tags: project.routing?.auto_tags,\n }));\n \n logger.debug('Loaded %d projects from context for routing', routingProjects.length);\n \n // Initialize routing with config-based defaults\n const routingConfig: Routing.RoutingConfig = {\n default: {\n path: defaultPath,\n structure: defaultStructure,\n filename_options: defaultFilenameOptions,\n createDirectories: true,\n },\n projects: routingProjects,\n conflict_resolution: 'primary',\n };\n \n const routing = Routing.create(routingConfig, context, config.weightModelProvider);\n logger.debug('Routing system initialized');\n \n // Interactive moved to protokoll-cli\n // const interactive = Interactive.create(\n // { enabled: config.interactive, defaultToSuggestion: true, silent: config.silent },\n // context\n // );\n \n const output = Output.create({\n intermediateDir: config.intermediateDir || './output/protokoll',\n keepIntermediates: config.keepIntermediates ?? true,\n timestampFormat: 'YYMMDD-HHmm',\n });\n logger.debug('Output manager initialized');\n \n const reflection = config.selfReflection \n ? Reflection.create({\n enabled: true,\n format: 'markdown',\n includeConversation: false,\n includeOutput: true,\n })\n : null;\n if (reflection) {\n logger.debug('Self-reflection system enabled');\n }\n \n // Initialize transcription service\n const transcription = Transcription.create({\n defaultModel: config.transcriptionModel as Transcription.TranscriptionModel,\n });\n logger.debug('Transcription service initialized with model: %s', config.transcriptionModel);\n \n // Initialize reasoning for agentic processing\n const reasoning = Reasoning.create({ \n model: config.model,\n reasoningLevel: config.reasoningLevel,\n });\n logger.debug('Reasoning system initialized with model: %s, reasoning level: %s', config.model, config.reasoningLevel || 'medium');\n\n // Initialize simple-replace phase for pre-LLM entity correction via sounds_like\n const simpleReplace = SimpleReplace.create({ debug: config.debug }, context);\n logger.debug('Simple-replace phase initialized with context instance');\n\n // Initialize complete phase for moving files to processed directory\n // Pass outputStructure so processed files use the same directory structure as output\n const complete = config.processedDirectory \n ? CompletePhase.create({\n processedDirectory: config.processedDirectory,\n outputStructure: config.outputStructure as CompletePhase.FilesystemStructure,\n dryRun: config.dryRun,\n })\n : null;\n if (complete) {\n logger.debug('Complete phase initialized with processed directory: %s', config.processedDirectory);\n }\n \n // Helper to extract a human-readable title from the output path\n const extractTitleFromPath = (outputPath: string): string | undefined => {\n const filename = outputPath.split('/').pop()?.replace(/\\.(md|pkl)$/, '');\n if (!filename) return undefined;\n \n // Remove date prefix (e.g., \"27-0716-\" from \"27-0716-meeting-notes\")\n const withoutDate = filename.replace(/^\\d{2}-\\d{4}-/, '');\n if (!withoutDate) return undefined;\n \n // Convert kebab-case to Title Case\n return withoutDate\n .split('-')\n .map(word => word.charAt(0).toUpperCase() + word.slice(1))\n .join(' ');\n };\n \n // Helper to check if a title is meaningful (not just numbers/timestamps)\n const isMeaningfulTitle = (title: string | undefined): boolean => {\n if (!title) return false;\n // Reject UUID-like strings (hex characters separated by dashes, e.g. filenames from recordings)\n const uuidPattern = /^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$/i;\n if (uuidPattern.test(title.trim())) return false;\n // Also reject if the title starts with a UUID segment pattern (Title Case converted UUID)\n const uuidSegmentPattern = /^[0-9a-f]{8}\\s[0-9a-f]{4}\\s/i;\n if (uuidSegmentPattern.test(title.trim())) return false;\n // Check if title is mostly numbers (timestamp-like) or very short fragments\n const stripped = title.replace(/\\s+/g, '');\n const numberRatio = (stripped.match(/\\d/g) || []).length / stripped.length;\n // Reject if: mostly numbers, too short, or common bad patterns\n if (numberRatio > 0.5) return false;\n if (stripped.length < 3) return false;\n // Reject titles that are just common words without context\n const badPatterns = /^(i|i have|i am|the|a|an|um|uh|so|well|okay|oh|hey|hi)$/i;\n if (badPatterns.test(title.trim())) return false;\n return true;\n };\n \n // Generate a meaningful title from transcript content using LLM\n const generateTitleFromContent = async (transcriptText: string, fallbackTitle?: string): Promise<string> => {\n try {\n // Use first ~2000 chars for title generation (enough context, not too expensive)\n const textSample = transcriptText.slice(0, 2000);\n \n const response = await reasoning.complete({\n systemPrompt: `You are a title generator. Given a transcript, generate a concise, descriptive title (3-8 words) that captures the main topic or theme.\n\nRules:\n- Output ONLY the title, nothing else\n- No quotes around the title\n- Use Title Case\n- Be specific - avoid generic titles like \"Meeting Notes\" or \"Discussion\"\n- Focus on the main subject matter\n- If there are multiple topics, pick the most prominent one`,\n prompt: `Generate a title for this transcript:\\n\\n${textSample}`,\n });\n \n // Clean up the response - remove quotes, trim whitespace\n const title = response.content\n .trim()\n .replace(/^[\"']|[\"']$/g, '') // Remove surrounding quotes\n .replace(/^#\\s*/, '') // Remove markdown heading prefix\n .trim();\n \n // Validate the generated title\n if (title && title.length > 0 && title.length < 100) {\n logger.debug('Generated title from content: %s', title);\n return title;\n }\n \n logger.debug('Generated title was invalid, using fallback');\n return fallbackTitle || 'Untitled';\n } catch (error) {\n logger.warn('Title generation failed, using fallback', { error });\n return fallbackTitle || 'Untitled';\n }\n };\n\n const processInput = async (input: PipelineInput): Promise<PipelineResult> => {\n const startTime = Date.now();\n \n // Format progress prefix for log messages\n const progressPrefix = input.progress \n ? `[${input.progress.current}/${input.progress.total}]` \n : '';\n const log = (level: 'info' | 'debug', message: string, ...args: unknown[]) => {\n const prefixedMessage = progressPrefix ? `${progressPrefix} ${message}` : message;\n if (level === 'info') {\n logger.info(prefixedMessage, ...args);\n } else {\n logger.debug(prefixedMessage, ...args);\n }\n };\n \n log('info', 'Processing: %s (hash: %s)', input.audioFile, input.hash);\n \n // Initialize state\n const state: PipelineState = {\n input,\n startTime: new Date(),\n };\n \n // Start reflection collection if enabled\n if (reflection) {\n reflection.collector.start();\n }\n \n // Start interactive session if enabled\n // Interactive moved to protokoll-cli\n // if (config.interactive) {\n // interactive.startSession();\n // log('debug', 'Interactive session started');\n // }\n \n try {\n // Step 1: Check onboarding needs (moved to protokoll-cli)\n log('debug', 'Checking onboarding state...');\n // const onboardingState = interactive.checkNeedsOnboarding();\n const onboardingState = { needsOnboarding: false }; // Stub\n if (onboardingState.needsOnboarding) {\n log('debug', 'First-run detected - onboarding may be triggered');\n }\n \n // Step 2: Raw transcription using Transcription module\n log('info', 'Transcribing audio...');\n const whisperStart = Date.now();\n \n const transcriptionResult = await transcription.transcribe(input.audioFile, {\n model: config.transcriptionModel as Transcription.TranscriptionModel,\n });\n state.rawTranscript = transcriptionResult.text;\n \n const whisperDuration = Date.now() - whisperStart;\n log('info', 'Transcription: %d chars in %.1fs', \n state.rawTranscript.length, whisperDuration / 1000);\n \n if (reflection) {\n reflection.collector.recordWhisper(whisperDuration);\n }\n \n // Step 3: Route detection\n log('debug', 'Determining routing destination...');\n const routingContext: Routing.RoutingContext = {\n transcriptText: state.rawTranscript || '',\n audioDate: input.creation,\n sourceFile: input.audioFile,\n hash: input.hash,\n };\n \n const routeResult = routing.route(routingContext);\n \n log('debug', 'Routing decision: project=%s, confidence=%.2f', \n routeResult.projectId || 'default', routeResult.confidence);\n \n // Record routing decision in reflection\n if (reflection) {\n reflection.collector.recordRoutingDecision({\n projectId: routeResult.projectId,\n destination: routeResult.destination.path,\n confidence: routeResult.confidence,\n reasoning: routeResult.reasoning,\n signals: routeResult.signals.map(s => ({\n type: s.type,\n value: s.value,\n weight: s.weight,\n })),\n alternativesConsidered: routeResult.alternateMatches?.map(alt => ({\n projectId: alt.projectId,\n confidence: alt.confidence,\n whyNotChosen: `Lower confidence (${(alt.confidence * 100).toFixed(1)}%)`,\n })),\n });\n }\n \n // Build output path\n const outputPath = routing.buildOutputPath(routeResult, routingContext);\n log('debug', 'Output path: %s', outputPath);\n \n // Step 4: Create output paths using Output module\n log('debug', 'Setting up output directories...');\n const paths = output.createOutputPaths(\n input.audioFile,\n outputPath,\n input.hash,\n input.creation\n );\n \n await output.ensureDirectories(paths);\n \n // Write raw transcript to intermediate (for debugging)\n await output.writeIntermediate(paths, 'transcript', {\n text: state.rawTranscript,\n model: config.transcriptionModel,\n duration: whisperDuration,\n });\n\n // Step 4b: Simple-replace phase — sounds_like entity correction before LLM\n // Matches entity names (projects, people, terms) using sounds_like mappings,\n // corrects them in the transcript text, and tracks which entities were found.\n log('debug', 'Running simple-replace (sounds_like entity matching)...');\n // Derive the intermediate directory from an existing intermediate file path\n const intermediateDir = path.dirname(paths.intermediate.transcript);\n const simpleReplaceResult = await simpleReplace.replace(\n state.rawTranscript || '',\n {\n project: routeResult.projectId ?? undefined,\n confidence: routeResult.confidence,\n },\n intermediateDir,\n input.hash\n );\n\n if (simpleReplaceResult.replacementsMade) {\n log('info',\n 'Simple-replace: %d correction(s) applied (%d Tier-1, %d Tier-2)',\n simpleReplaceResult.stats.totalReplacements,\n simpleReplaceResult.stats.tier1Replacements,\n simpleReplaceResult.stats.tier2Replacements\n );\n // Write the corrected text to intermediate for inspection\n await output.writeIntermediate(paths, 'session', {\n simpleReplace: {\n replacementsMade: true,\n stats: simpleReplaceResult.stats,\n },\n });\n } else {\n log('debug', 'Simple-replace: no replacements made');\n }\n\n // Notify caller (e.g. worker) so it can write to the PKL enhancement log\n input.onSimpleReplaceComplete?.(simpleReplaceResult.stats);\n\n // Collect pre-identified entities from simple-replace applied mappings\n const preIdentifiedEntities: Agentic.ToolContext['preIdentifiedEntities'] = {\n people: new Set<string>(),\n projects: new Set<string>(),\n terms: new Set<string>(),\n companies: new Set<string>(),\n };\n for (const mapping of simpleReplaceResult.stats.appliedMappings) {\n if (!mapping.entityId || !mapping.entityType) continue;\n if (mapping.entityType === 'person') preIdentifiedEntities.people.add(mapping.entityId);\n else if (mapping.entityType === 'project') preIdentifiedEntities.projects.add(mapping.entityId);\n else if (mapping.entityType === 'term') preIdentifiedEntities.terms.add(mapping.entityId);\n else if (mapping.entityType === 'company') preIdentifiedEntities.companies.add(mapping.entityId);\n }\n \n // Step 5: Agentic enhancement using real executor\n // The LLM receives the already-corrected text (simple-replace output)\n // and is told which entities were pre-matched so it doesn't re-lookup them.\n log('info', 'Enhancing with %s...', config.model);\n \n const agenticStart = Date.now();\n const toolContext: Agentic.ToolContext = {\n transcriptText: simpleReplaceResult.text,\n audioDate: input.creation,\n sourceFile: input.audioFile,\n contextInstance: context,\n routingInstance: routing,\n preIdentifiedEntities,\n interactiveMode: config.interactive,\n // Interactive moved to protokoll-cli\n // interactiveInstance: interactive,\n weightModelProvider: config.weightModelProvider,\n onToolCallStart: input.onToolCallStart,\n onToolCallComplete: input.onToolCallComplete,\n };\n \n const executor = Agentic.create(reasoning, toolContext);\n const agenticResult = await executor.process(simpleReplaceResult.text);\n \n state.enhancedText = agenticResult.enhancedText;\n const toolsUsed = agenticResult.toolsUsed;\n const agenticDuration = Date.now() - agenticStart;\n \n // Record tool calls in reflection\n if (reflection) {\n for (const tool of toolsUsed) {\n reflection.collector.recordToolCall(tool, agenticDuration / toolsUsed.length, true);\n }\n reflection.collector.recordCorrection(state.rawTranscript || '', state.enhancedText);\n // Record token usage from agentic result\n if (agenticResult.totalTokens) {\n reflection.collector.recordModelResponse(config.model, agenticResult.totalTokens);\n }\n // Record context changes (new projects, entities created)\n if (agenticResult.contextChanges) {\n for (const change of agenticResult.contextChanges) {\n reflection.collector.recordContextChange(change);\n }\n }\n }\n \n // Write agentic session to intermediate\n await output.writeIntermediate(paths, 'session', {\n iterations: agenticResult.iterations,\n toolsUsed: agenticResult.toolsUsed,\n state: agenticResult.state,\n });\n \n // Step 5b: Check if agentic processing found a different route\n // (e.g., via lookup_project tool finding a project with custom destination)\n if (agenticResult.state.routeDecision?.destination?.path) {\n const agenticRoute = agenticResult.state.routeDecision;\n log('debug', 'Agentic processing found route: %s -> %s', \n agenticRoute.projectId || 'unknown', \n agenticRoute.destination.path\n );\n \n // Update routeResult with the agentic decision\n routeResult.projectId = agenticRoute.projectId || routeResult.projectId;\n routeResult.destination = {\n ...routeResult.destination,\n path: agenticRoute.destination.path,\n structure: agenticRoute.destination.structure || routeResult.destination.structure,\n };\n routeResult.confidence = agenticRoute.confidence || routeResult.confidence;\n routeResult.reasoning = agenticRoute.reasoning || routeResult.reasoning;\n if (agenticRoute.signals) {\n routeResult.signals = agenticRoute.signals;\n }\n \n // Rebuild output path with the new destination\n const newOutputPath = routing.buildOutputPath(routeResult, routingContext);\n log('debug', 'Updated output path: %s -> %s', outputPath, newOutputPath);\n \n // Recreate output paths with new destination\n const newPaths = output.createOutputPaths(\n input.audioFile,\n newOutputPath,\n input.hash,\n input.creation\n );\n await output.ensureDirectories(newPaths);\n \n // Update paths reference (reassign properties since paths is const)\n Object.assign(paths, newPaths);\n }\n\n // Step 5c: Write raw transcript to .transcript/ directory alongside final output\n // This is done AFTER the route is finalized so it goes to the correct location\n // Enables compare and reanalyze workflows\n log('debug', 'Writing raw transcript to .transcript/ directory...');\n await output.writeRawTranscript(paths, {\n text: state.rawTranscript,\n model: config.transcriptionModel,\n duration: whisperDuration,\n audioFile: input.audioFile,\n audioHash: input.hash,\n transcribedAt: new Date().toISOString(),\n });\n\n // Step 6: Write final output using Output module with metadata\n log('debug', 'Writing final transcript...');\n let finalTitle: string | undefined;\n let finalEntities: Metadata.TranscriptMetadata['entities'] | undefined;\n if (state.enhancedText) {\n // Build entity metadata from referenced entities\n const buildEntityReferences = (): Metadata.TranscriptMetadata['entities'] => {\n const refs = agenticResult.state.referencedEntities;\n if (!refs) return undefined;\n \n const entities: NonNullable<Metadata.TranscriptMetadata['entities']> = {\n people: [],\n projects: [],\n terms: [],\n companies: [],\n };\n \n for (const personId of refs.people) {\n if (!personId) continue;\n const person = context.getPerson(personId);\n if (person) {\n entities.people!.push({ id: person.id, name: person.name, type: 'person' });\n }\n }\n \n for (const projectId of refs.projects) {\n if (!projectId) continue;\n const project = context.getProject(projectId);\n if (project) {\n entities.projects!.push({ id: project.id, name: project.name, type: 'project' });\n }\n }\n \n for (const termId of refs.terms) {\n if (!termId) continue;\n const term = context.getTerm(termId);\n if (term) {\n entities.terms!.push({ id: term.id, name: term.name, type: 'term' });\n }\n }\n \n for (const companyId of refs.companies) {\n if (!companyId) continue;\n const company = context.getCompany(companyId);\n if (company) {\n entities.companies!.push({ id: company.id, name: company.name, type: 'company' });\n }\n }\n \n // Only return if we found any entities\n const hasEntities = \n entities.people!.length > 0 ||\n entities.projects!.length > 0 ||\n entities.terms!.length > 0 ||\n entities.companies!.length > 0;\n \n return hasEntities ? entities : undefined;\n };\n \n // Generate title - prefer path-derived title if meaningful, otherwise use LLM\n const pathTitle = extractTitleFromPath(paths.final);\n let title: string;\n if (isMeaningfulTitle(pathTitle)) {\n title = pathTitle!;\n } else {\n log('debug', 'Path-derived title not meaningful (%s), generating from content...', pathTitle || 'empty');\n title = await generateTitleFromContent(state.enhancedText, pathTitle);\n log('info', 'Generated title: %s', title);\n \n // Rebuild output path with the generated title as the subject\n // This ensures the filename matches the title\n const contextWithTitle: Routing.RoutingContext = {\n ...routingContext,\n subjectOverride: title,\n };\n const newOutputPath = routing.buildOutputPath(routeResult, contextWithTitle);\n \n if (newOutputPath !== paths.final) {\n log('debug', 'Updating output path with generated title: %s -> %s', paths.final, newOutputPath);\n \n // Recreate output paths with the new filename\n const newPaths = output.createOutputPaths(\n input.audioFile,\n newOutputPath,\n input.hash,\n input.creation\n );\n await output.ensureDirectories(newPaths);\n \n // Update paths reference\n Object.assign(paths, newPaths);\n }\n }\n \n // Generate UUID for this transcript\n const transcriptUuid = randomUUID();\n \n // Build metadata from routing decision and input\n const transcriptMetadata: Metadata.TranscriptMetadata = {\n id: transcriptUuid,\n title,\n projectId: routeResult.projectId || undefined,\n project: routeResult.projectId ? (context.getProject(routeResult.projectId)?.name || undefined) : undefined,\n date: input.creation,\n routing: Metadata.createRoutingMetadata(routeResult),\n tags: Metadata.extractTagsFromSignals(routeResult.signals),\n confidence: routeResult.confidence,\n entities: buildEntityReferences(),\n };\n \n await output.writeTranscript(paths, state.enhancedText, transcriptMetadata);\n finalTitle = title;\n finalEntities = transcriptMetadata.entities;\n \n // Notify weight model of entity updates (if callback provided)\n if (config.onTranscriptEntitiesUpdated && transcriptMetadata.entities) {\n const allEntityIds: string[] = [];\n if (transcriptMetadata.entities.people) {\n allEntityIds.push(...transcriptMetadata.entities.people.map(e => e.id));\n }\n if (transcriptMetadata.entities.projects) {\n allEntityIds.push(...transcriptMetadata.entities.projects.map(e => e.id));\n }\n if (transcriptMetadata.entities.terms) {\n allEntityIds.push(...transcriptMetadata.entities.terms.map(e => e.id));\n }\n if (transcriptMetadata.entities.companies) {\n allEntityIds.push(...transcriptMetadata.entities.companies.map(e => e.id));\n }\n \n config.onTranscriptEntitiesUpdated(\n transcriptUuid,\n allEntityIds,\n routeResult.projectId || undefined\n );\n }\n }\n \n // Step 7: Generate reflection report\n log('debug', 'Generating reflection report...');\n let reflectionReport: Reflection.ReflectionReport | undefined;\n if (reflection) {\n reflectionReport = reflection.generate(\n input.audioFile,\n paths.final,\n undefined,\n state.enhancedText\n );\n \n if (paths.intermediate.reflection) {\n await reflection.save(reflectionReport, paths.intermediate.reflection);\n }\n }\n \n // Step 8: End interactive session (moved to protokoll-cli)\n log('debug', 'Finalizing session...');\n // let session: Interactive.InteractiveSession | undefined;\n // if (config.interactive) {\n // session = interactive.endSession();\n // log('debug', 'Interactive session ended: %d clarifications', session.responses.length);\n // // Save session if path available\n // if (paths.intermediate.session) {\n // await output.writeIntermediate(paths, 'session', session);\n // }\n // }\n \n // Step 9: Cleanup if needed\n if (!config.keepIntermediates && !config.debug) {\n await output.cleanIntermediates(paths);\n }\n\n // Step 10: Move audio file to processed directory\n let processedAudioPath: string | undefined;\n if (complete) {\n // Extract subject from output path for naming\n const subject = paths.final.split('/').pop()?.replace('.md', '') || undefined;\n processedAudioPath = await complete.complete(\n input.audioFile, \n input.hash, \n input.creation,\n subject\n );\n }\n \n const processingTime = Date.now() - startTime;\n \n // Compact summary output\n log('info', 'Enhancement: %d iterations, %d tools, %.1fs', \n agenticResult.iterations, toolsUsed.length, agenticDuration / 1000);\n if (agenticResult.totalTokens) {\n log('info', 'Tokens: %d total', agenticResult.totalTokens);\n }\n log('info', 'Output: %s (%.1fs total)', paths.final, processingTime / 1000);\n \n return {\n outputPath: paths.final,\n enhancedText: state.enhancedText || '',\n rawTranscript: state.rawTranscript || '',\n title: finalTitle || '',\n routedProject: routeResult.projectId,\n routedProjectName: routeResult.projectId ? (context.getProject(routeResult.projectId)?.name || null) : null,\n routingConfidence: routeResult.confidence,\n entities: finalEntities,\n processingTime,\n toolsUsed,\n correctionsApplied: agenticResult.state.resolvedEntities.size,\n processedAudioPath,\n reflection: reflectionReport,\n // session, // Interactive moved to protokoll-cli\n intermediatePaths: paths,\n };\n \n } catch (error) {\n logger.error('Pipeline error', { error });\n throw error;\n }\n };\n \n return { process: processInput };\n};\n"],"names":["Logging.getLogger","Routing.create","Output.create","Reflection.create","Transcription.create","Reasoning.create","SimpleReplace.create","CompletePhase.create","Agentic.create","Metadata.createRoutingMetadata","Metadata.extractTags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AAA,EAAa;AACnC;;;;"}
package/dist/index34.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { getLogger } from './index47.js';
2
2
  import { create as create$1 } from './index13.js';
3
3
  import { create as create$2 } from './index14.js';
4
- import { transcribeAudio } from './index54.js';
5
- import { stringifyJSON } from './index55.js';
4
+ import { transcribeAudio } from './index53.js';
5
+ import { stringifyJSON } from './index54.js';
6
6
  import path__default from 'node:path';
7
7
  import { create as create$4 } from './index5.js';
8
8
  import { create as create$3 } from './index2.js';
package/dist/index35.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import { getLogger } from './index47.js';
2
2
  import { create as create$1 } from './index13.js';
3
- import { create as create$2 } from './index56.js';
4
- import { create as create$3 } from './index57.js';
5
- import { create as create$4 } from './index58.js';
6
- import { stringifyJSON } from './index55.js';
3
+ import { create as create$2 } from './index55.js';
4
+ import { create as create$3 } from './index56.js';
5
+ import { create as create$4 } from './index57.js';
6
+ import { stringifyJSON } from './index54.js';
7
7
  import path from 'path';
8
8
 
9
9
  const create = (config, contextInstance) => {
package/dist/index36.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { getLogger } from './index47.js';
2
2
  import { create as create$3 } from './index14.js';
3
3
  import { create as create$1 } from './index13.js';
4
- import { create as create$2 } from './index59.js';
4
+ import { create as create$2 } from './index58.js';
5
5
  import { DEFAULT_INTERMEDIATE_DIRECTORY } from './index18.js';
6
6
  import path__default from 'node:path';
7
7
 
@@ -1 +1 @@
1
- {"version":3,"file":"index38.js","sources":["../src/transcript/operations.ts"],"sourcesContent":["/**\n * Transcript Operations\n * \n * Core business logic for transcript parsing, listing, editing, and combining.\n * PKL-only implementation - all transcripts are stored in PKL format.\n */\n\nimport * as fs from 'fs/promises';\nimport * as path from 'node:path';\nimport { glob } from 'glob';\nimport * as Context from '@redaksjon/context';\nimport * as Routing from '../routing';\nimport { Project } from '@redaksjon/context';\nimport { findProjectResilient } from '../utils/entityFinder';\nimport { \n PklTranscript, \n listTranscripts as listTranscriptsFromStorage,\n type TranscriptMetadata as PklMetadata,\n type ListTranscriptsOptions as StorageListOptions,\n} from '@redaksjon/protokoll-format';\nimport { ensurePklExtension } from './pkl-utils';\n\n/** UUID v4 pattern — used to detect corrupted project fields */\nconst UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n\nfunction looksLikeUuid(value: string): boolean {\n return UUID_PATTERN.test(value);\n}\n\n/**\n * Parsed transcript structure\n */\nexport interface ParsedTranscript {\n filePath: string;\n title?: string;\n metadata: TranscriptMetadata;\n content: string;\n rawText: string;\n}\n\nexport interface TranscriptMetadata {\n date?: string;\n time?: string;\n project?: string;\n projectId?: string;\n destination?: string;\n confidence?: string;\n signals?: string[];\n reasoning?: string;\n tags?: string[];\n duration?: string;\n}\n\n/**\n * Check if input looks like a UUID (8+ hex chars)\n */\nexport function isUuidInput(input: string): boolean {\n return /^[a-f0-9]{8}/.test(input);\n}\n\n/**\n * Find transcript by UUID using glob scan\n * TODO: Replace with index-based lookup for better performance with large collections\n * \n * @param uuid - Full UUID or 8-character prefix\n * @param searchDirectories - Directories to search in\n * @returns Absolute path to transcript file, or null if not found\n */\nexport async function findTranscriptByUuid(\n uuid: string,\n searchDirectories: string[]\n): Promise<string | null> {\n const prefix = uuid.substring(0, 8); // Support both full UUID and prefix\n const pattern = `${prefix}-*.pkl`;\n \n for (const dir of searchDirectories) {\n const matches = await glob(pattern, { cwd: dir, absolute: true });\n if (matches.length > 0) {\n // Return first match - UUIDs should be unique\n return matches[0];\n }\n }\n \n return null;\n}\n\n/**\n * Parse a transcript file into its components\n * PKL-only implementation\n * \n * @param filePathOrUuid - File path or UUID to parse\n * @param searchDirectories - Optional directories to search if UUID is provided\n */\nexport const parseTranscript = async (\n filePathOrUuid: string,\n searchDirectories?: string[]\n): Promise<ParsedTranscript> => {\n let resolvedPath: string;\n \n // Check if input is a UUID\n if (isUuidInput(filePathOrUuid)) {\n if (!searchDirectories || searchDirectories.length === 0) {\n throw new Error('Search directories required for UUID lookup');\n }\n const foundPath = await findTranscriptByUuid(filePathOrUuid, searchDirectories);\n if (!foundPath) {\n throw new Error(`Transcript not found for UUID: ${filePathOrUuid}`);\n }\n resolvedPath = foundPath;\n } else {\n // Existing path-based logic\n resolvedPath = ensurePklExtension(filePathOrUuid);\n }\n \n const transcript = PklTranscript.open(resolvedPath, { readOnly: true });\n \n try {\n const pklMetadata = transcript.metadata;\n const content = transcript.content;\n \n const result: ParsedTranscript = {\n filePath: resolvedPath,\n title: pklMetadata.title,\n metadata: {\n date: pklMetadata.date instanceof Date \n ? pklMetadata.date.toISOString().split('T')[0] \n : undefined,\n time: pklMetadata.recordingTime,\n project: pklMetadata.project,\n projectId: pklMetadata.projectId,\n destination: pklMetadata.routing?.destination,\n confidence: pklMetadata.routing?.confidence?.toString(),\n signals: pklMetadata.routing?.signals,\n reasoning: pklMetadata.routing?.reasoning,\n tags: pklMetadata.tags,\n duration: pklMetadata.duration,\n },\n content,\n rawText: content, // For PKL files, content is the enhanced text\n };\n \n return result;\n } finally {\n transcript.close();\n }\n};\n\n/**\n * Extract the timestamp from a transcript filename\n */\nexport const extractTimestampFromFilename = (filePath: string): { day: number; hour: number; minute: number } | null => {\n const ext = path.extname(filePath);\n const basename = path.basename(filePath, ext);\n const match = basename.match(/^(\\d{1,2})-(\\d{2})(\\d{2})/);\n \n if (match) {\n return {\n day: parseInt(match[1], 10),\n hour: parseInt(match[2], 10),\n minute: parseInt(match[3], 10),\n };\n }\n \n return null;\n};\n\n/**\n * Slugify a title for use in filenames\n */\nexport const slugifyTitle = (title: string): string => {\n return title\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/--+/g, '-')\n .replace(/^-|-$/g, '')\n .slice(0, 50);\n};\n\n/**\n * Parse duration string to seconds\n */\nconst parseDuration = (duration: string): number => {\n const match = duration.match(/(\\d+):(\\d+)/);\n if (match) {\n const [, minutes, seconds] = match;\n return parseInt(minutes, 10) * 60 + parseInt(seconds, 10);\n }\n return 0;\n};\n\n/**\n * Format seconds as duration string\n */\nconst formatDuration = (seconds: number): string => {\n const minutes = Math.floor(seconds / 60);\n const secs = seconds % 60;\n return `${minutes}:${secs.toString().padStart(2, '0')}`;\n};\n\n/**\n * Expand ~ in paths\n */\nconst expandPath = (p: string): string => {\n if (p.startsWith('~')) {\n return path.join(process.env.HOME || '', p.slice(1));\n }\n return p;\n};\n\n/**\n * Extract date from metadata\n */\nconst extractDateFromMetadata = (metadata: TranscriptMetadata, filePath: string): Date => {\n if (metadata.date) {\n return new Date(metadata.date);\n }\n const timestamp = extractTimestampFromFilename(filePath);\n if (timestamp) {\n const now = new Date();\n return new Date(now.getFullYear(), now.getMonth(), timestamp.day, timestamp.hour, timestamp.minute);\n }\n return new Date();\n};\n\n/**\n * Build routing config from context and project\n */\nconst buildRoutingConfig = (\n context: Context.ContextInstance,\n _targetProject: Project\n): Routing.RoutingConfig => {\n const config = context.getConfig();\n const defaultPath = expandPath((config.outputDirectory as string) || '~/notes');\n \n const resolveRoutingPath = (routingPath: string | undefined): string => {\n if (!routingPath) {\n return defaultPath;\n }\n const expanded = expandPath(routingPath);\n if (!expanded.startsWith('/') && !expanded.match(/^[A-Za-z]:/)) {\n return path.resolve(defaultPath, expanded);\n }\n return expanded;\n };\n\n return {\n default: {\n path: resolveRoutingPath(undefined),\n structure: 'month',\n filename_options: ['date', 'time', 'subject'],\n },\n projects: context.getAllProjects()\n .filter(p => p.active !== false)\n .map(p => ({\n projectId: p.id,\n destination: {\n path: resolveRoutingPath(p.routing?.destination),\n structure: p.routing?.structure || 'month',\n filename_options: p.routing?.filename_options || ['date', 'time', 'subject'],\n },\n classification: p.classification,\n active: p.active,\n })),\n conflict_resolution: 'primary' as const,\n };\n};\n\n/**\n * Combine multiple transcripts into a single document\n * PKL-only implementation\n */\nexport const combineTranscripts = async (\n filePaths: string[],\n options: {\n projectId?: string;\n title?: string;\n dryRun?: boolean;\n verbose?: boolean;\n contextDirectory?: string;\n /** Explicit context directories (from protokoll-config.yaml) */\n contextDirectories?: string[];\n } = {}\n): Promise<{ outputPath: string; content: string }> => {\n if (filePaths.length === 0) {\n throw new Error('No transcript files provided');\n }\n \n const transcripts: ParsedTranscript[] = [];\n for (const filePath of filePaths) {\n try {\n const parsed = await parseTranscript(filePath);\n transcripts.push(parsed);\n } catch (error) {\n throw new Error(`Failed to parse transcript: ${filePath} - ${error}`);\n }\n }\n \n transcripts.sort((a, b) => {\n const aName = path.basename(a.filePath);\n const bName = path.basename(b.filePath);\n return aName.localeCompare(bName);\n });\n \n const firstTranscript = transcripts[0];\n const baseMetadata = { ...firstTranscript.metadata };\n \n // Use explicit contextDirectories from options if provided (from protokoll-config.yaml)\n const context = await Context.create({\n startingDir: options.contextDirectory || path.dirname(firstTranscript.filePath),\n contextDirectories: options.contextDirectories,\n });\n let targetProject: Project | undefined;\n \n if (options.projectId) {\n targetProject = findProjectResilient(context, options.projectId);\n baseMetadata.project = targetProject.name;\n baseMetadata.projectId = targetProject.id;\n \n if (targetProject.routing?.destination) {\n const config = context.getConfig();\n const defaultPath = expandPath((config.outputDirectory as string) || '~/notes');\n const routingPath = expandPath(targetProject.routing.destination);\n const resolvedPath = !routingPath.startsWith('/') && !routingPath.match(/^[A-Za-z]:/)\n ? path.resolve(defaultPath, routingPath)\n : routingPath;\n baseMetadata.destination = resolvedPath;\n }\n }\n \n let totalSeconds = 0;\n let hasDuration = false;\n for (const t of transcripts) {\n if (t.metadata.duration) {\n hasDuration = true;\n totalSeconds += parseDuration(t.metadata.duration);\n }\n }\n if (hasDuration && totalSeconds > 0) {\n baseMetadata.duration = formatDuration(totalSeconds);\n }\n \n const allTags = new Set<string>();\n for (const t of transcripts) {\n if (t.metadata.tags) {\n for (const tag of t.metadata.tags) {\n allTags.add(tag);\n }\n }\n }\n if (allTags.size > 0) {\n baseMetadata.tags = Array.from(allTags).sort();\n }\n \n const combinedTitle = options.title \n ? options.title\n : (firstTranscript.title \n ? `${firstTranscript.title} (Combined)`\n : 'Combined Transcript');\n \n // Build combined content\n const contentParts: string[] = [];\n for (let i = 0; i < transcripts.length; i++) {\n const t = transcripts[i];\n const sectionTitle = t.title || `Part ${i + 1}`;\n const sourceFile = path.basename(t.filePath);\n \n contentParts.push(`## ${sectionTitle}`);\n contentParts.push(`*Source: ${sourceFile}*`);\n contentParts.push('');\n contentParts.push(t.content);\n contentParts.push('');\n }\n \n const combinedContent = contentParts.join('\\n');\n \n // Determine output path\n let outputPath: string;\n \n if (targetProject?.routing?.destination) {\n const routingConfig = buildRoutingConfig(context, targetProject);\n const routing = Routing.create(routingConfig, context, undefined);\n \n const audioDate = extractDateFromMetadata(baseMetadata, firstTranscript.filePath);\n \n const routingContext: Routing.RoutingContext = {\n transcriptText: combinedContent,\n audioDate,\n sourceFile: firstTranscript.filePath,\n };\n \n const decision = routing.route(routingContext);\n outputPath = routing.buildOutputPath(decision, routingContext);\n // Ensure .pkl extension\n outputPath = outputPath.replace(/\\.md$/, '.pkl');\n } else {\n const firstDir = path.dirname(firstTranscript.filePath);\n const timestamp = extractTimestampFromFilename(firstTranscript.filePath);\n \n const filenameSuffix = options.title \n ? slugifyTitle(options.title)\n : 'combined';\n \n if (timestamp) {\n const day = timestamp.day.toString().padStart(2, '0');\n const hour = timestamp.hour.toString().padStart(2, '0');\n const minute = timestamp.minute.toString().padStart(2, '0');\n outputPath = path.join(firstDir, `${day}-${hour}${minute}-${filenameSuffix}.pkl`);\n } else {\n outputPath = path.join(firstDir, `${filenameSuffix}.pkl`);\n }\n }\n \n // Create the combined PKL transcript\n if (!options.dryRun) {\n const initialMetadata: PklMetadata = {\n id: '', // Will be auto-generated by PklTranscript.create()\n title: combinedTitle,\n date: baseMetadata.date ? new Date(baseMetadata.date) : undefined,\n recordingTime: baseMetadata.time,\n project: targetProject?.name || baseMetadata.project,\n projectId: targetProject?.id || baseMetadata.projectId,\n tags: baseMetadata.tags || [],\n duration: baseMetadata.duration,\n status: 'enhanced',\n };\n \n if (targetProject) {\n initialMetadata.entities = {\n people: [],\n projects: [{\n id: targetProject.id,\n name: targetProject.name,\n type: 'project',\n }],\n terms: [],\n companies: [],\n };\n }\n \n const newTranscript = PklTranscript.create(outputPath, initialMetadata);\n try {\n newTranscript.updateContent(combinedContent);\n } finally {\n newTranscript.close();\n }\n }\n \n return { outputPath, content: combinedContent };\n};\n\n/**\n * Edit transcript metadata and content\n * PKL-only implementation\n */\nexport const editTranscript = async (\n filePath: string,\n options: {\n title?: string;\n projectId?: string;\n tagsToAdd?: string[];\n tagsToRemove?: string[];\n dryRun?: boolean;\n verbose?: boolean;\n contextDirectory?: string;\n /** Explicit context directories (from protokoll-config.yaml) */\n contextDirectories?: string[];\n }\n): Promise<{ outputPath: string; content: string }> => {\n const pklPath = ensurePklExtension(filePath);\n const transcript = PklTranscript.open(pklPath, { readOnly: false });\n \n try {\n const pklMetadata = transcript.metadata;\n const content = transcript.content;\n \n // Use explicit contextDirectories from options if provided (from protokoll-config.yaml)\n const context = await Context.create({\n startingDir: options.contextDirectory || path.dirname(pklPath),\n contextDirectories: options.contextDirectories,\n });\n let targetProject: Project | undefined;\n \n if (options.projectId) {\n targetProject = findProjectResilient(context, options.projectId);\n }\n \n const newTitle = options.title || pklMetadata.title || 'Untitled';\n \n // Build updated metadata\n const updatedMetadata: Partial<PklMetadata> = {};\n \n if (options.title) {\n updatedMetadata.title = newTitle;\n }\n \n if (targetProject) {\n updatedMetadata.project = targetProject.name;\n updatedMetadata.projectId = targetProject.id;\n \n // Update entities with the project\n const existingEntities = pklMetadata.entities || { people: [], projects: [], terms: [], companies: [] };\n updatedMetadata.entities = {\n people: existingEntities.people || [],\n projects: [{\n id: targetProject.id,\n name: targetProject.name,\n type: 'project',\n }],\n terms: existingEntities.terms || [],\n companies: existingEntities.companies || [],\n };\n }\n \n // Handle tag updates\n if (options.tagsToAdd || options.tagsToRemove) {\n const currentTags = new Set(pklMetadata.tags || []);\n \n if (options.tagsToRemove) {\n for (const tag of options.tagsToRemove) {\n currentTags.delete(tag);\n }\n }\n \n if (options.tagsToAdd) {\n for (const tag of options.tagsToAdd) {\n currentTags.add(tag);\n }\n }\n \n updatedMetadata.tags = Array.from(currentTags).sort();\n }\n \n // Determine output path\n let outputPath = pklPath;\n \n if (targetProject?.routing?.destination || options.title) {\n if (targetProject?.routing?.destination) {\n const routingConfig = buildRoutingConfig(context, targetProject);\n const routing = Routing.create(routingConfig, context, undefined);\n \n const audioDate = pklMetadata.date instanceof Date ? pklMetadata.date : new Date();\n \n const routingContext: Routing.RoutingContext = {\n transcriptText: content,\n audioDate,\n sourceFile: pklPath,\n };\n \n const decision = routing.route(routingContext);\n \n if (options.title) {\n const basePath = path.dirname(routing.buildOutputPath(decision, routingContext));\n const timestamp = extractTimestampFromFilename(pklPath);\n const sluggedTitle = slugifyTitle(options.title);\n \n if (timestamp) {\n const day = timestamp.day.toString().padStart(2, '0');\n const hour = timestamp.hour.toString().padStart(2, '0');\n const minute = timestamp.minute.toString().padStart(2, '0');\n outputPath = path.join(basePath, `${day}-${hour}${minute}-${sluggedTitle}.pkl`);\n } else {\n outputPath = path.join(basePath, `${sluggedTitle}.pkl`);\n }\n } else {\n outputPath = routing.buildOutputPath(decision, routingContext);\n outputPath = outputPath.replace(/\\.md$/, '.pkl');\n }\n } else if (options.title) {\n const dir = path.dirname(pklPath);\n const timestamp = extractTimestampFromFilename(pklPath);\n const sluggedTitle = slugifyTitle(options.title);\n \n if (timestamp) {\n const day = timestamp.day.toString().padStart(2, '0');\n const hour = timestamp.hour.toString().padStart(2, '0');\n const minute = timestamp.minute.toString().padStart(2, '0');\n outputPath = path.join(dir, `${day}-${hour}${minute}-${sluggedTitle}.pkl`);\n } else {\n outputPath = path.join(dir, `${sluggedTitle}.pkl`);\n }\n }\n }\n \n // Apply updates\n if (!options.dryRun) {\n if (Object.keys(updatedMetadata).length > 0) {\n transcript.updateMetadata(updatedMetadata);\n }\n \n // If output path changed, we need to move the file\n if (outputPath !== pklPath) {\n // Close current transcript\n transcript.close();\n \n // Create directory if needed\n await fs.mkdir(path.dirname(outputPath), { recursive: true });\n \n // Copy to new location\n await fs.copyFile(pklPath, outputPath);\n \n // Delete old file\n await fs.unlink(pklPath);\n }\n }\n \n return { outputPath, content };\n } finally {\n // Only close if not already closed (due to move operation)\n try {\n transcript.close();\n } catch {\n // Already closed\n }\n }\n};\n\n/**\n * Transcript list item\n */\nexport interface TranscriptListItem {\n path: string;\n filename: string;\n uuid: string; // UUID identifier for this transcript\n date: string;\n time?: string;\n title: string;\n hasRawTranscript: boolean;\n createdAt: Date;\n status?: import('@redaksjon/protokoll-format').TranscriptStatus;\n openTasksCount?: number;\n contentSize?: number;\n entities?: {\n people?: Array<{ id: string; name: string }>;\n projects?: Array<{ id: string; name: string }>;\n terms?: Array<{ id: string; name: string }>;\n companies?: Array<{ id: string; name: string }>;\n };\n}\n\nexport interface ListTranscriptsOptions {\n directory: string;\n limit?: number;\n offset?: number;\n sortBy?: 'date' | 'filename' | 'title';\n startDate?: string;\n endDate?: string;\n search?: string;\n projectId?: string;\n /** Project name - used as fallback when projectId is also set (matches transcripts with project name but no projectId) */\n project?: string;\n}\n\nexport interface ListTranscriptsResult {\n transcripts: TranscriptListItem[];\n total: number;\n hasMore: boolean;\n limit: number;\n offset: number;\n}\n\n/**\n * List transcripts with filtering and pagination\n * Uses the protokoll-format storage API\n */\nexport const listTranscripts = async (options: ListTranscriptsOptions): Promise<ListTranscriptsResult> => {\n const {\n directory,\n limit = 50,\n offset = 0,\n sortBy = 'date',\n startDate,\n endDate,\n search,\n projectId,\n project,\n } = options;\n \n // Use the storage API from protokoll-format\n // Pass projectId for UUID-based filtering; project (name) as fallback for transcripts without projectId\n const storageOptions: StorageListOptions = {\n directory,\n limit,\n offset,\n sortBy,\n search,\n projectId,\n project,\n startDate,\n endDate,\n };\n \n const result = await listTranscriptsFromStorage(storageOptions);\n \n // Convert storage result to operations result format\n const transcripts: TranscriptListItem[] = result.transcripts.map(item => {\n let uuid = '';\n let entities: TranscriptListItem['entities'];\n try {\n const transcript = PklTranscript.open(item.filePath, { readOnly: true });\n const meta = transcript.metadata;\n uuid = meta.id;\n const mappedProjects = meta.entities?.projects?.map(e => ({ id: e.id, name: e.name }));\n // If entities.projects is missing/empty but the scalar project field is set,\n // synthesise a project entry so the list view can display it correctly.\n const projectEntries = (mappedProjects && mappedProjects.length > 0)\n ? mappedProjects\n : (item.project && !looksLikeUuid(item.project))\n ? [{ id: meta.projectId || item.project, name: item.project }]\n : undefined;\n\n if (meta.entities || projectEntries) {\n entities = {\n people: meta.entities?.people?.map(e => ({ id: e.id, name: e.name })),\n projects: projectEntries,\n terms: meta.entities?.terms?.map(e => ({ id: e.id, name: e.name })),\n companies: meta.entities?.companies?.map(e => ({ id: e.id, name: e.name })),\n };\n }\n transcript.close();\n } catch {\n uuid = '';\n if (item.project && !looksLikeUuid(item.project)) {\n entities = {\n projects: [{ id: item.project, name: item.project }],\n };\n }\n }\n \n return {\n path: item.filePath,\n filename: path.basename(item.filePath),\n uuid,\n date: item.date instanceof Date ? item.date.toISOString().split('T')[0] : '',\n time: undefined,\n title: item.title,\n hasRawTranscript: false,\n createdAt: item.date || new Date(),\n status: item.status,\n openTasksCount: undefined,\n contentSize: item.contentPreview?.length,\n entities,\n };\n });\n \n return {\n transcripts,\n total: result.total,\n hasMore: result.hasMore,\n limit,\n offset,\n };\n};\n\n/**\n * Validate status transitions for transcript lifecycle\n * \n * Ensures status changes follow valid workflow:\n * - Upload workflow: uploaded → transcribing → initial → enhanced → reviewed → closed\n * - Error can occur at any point\n * - Error status allows retry (back to uploaded or transcribing)\n * \n * @param from - Current status\n * @param to - Desired status\n * @returns true if transition is valid, false otherwise\n */\nexport function isValidStatusTransition(\n from: import('@redaksjon/protokoll-format').TranscriptStatus | undefined,\n to: import('@redaksjon/protokoll-format').TranscriptStatus\n): boolean {\n // If no current status, any status is valid (initial creation)\n if (!from) {\n return true;\n }\n \n // Define valid transitions for each status\n const validTransitions: Record<\n import('@redaksjon/protokoll-format').TranscriptStatus,\n import('@redaksjon/protokoll-format').TranscriptStatus[]\n > = {\n 'uploaded': ['transcribing', 'error'],\n 'transcribing': ['initial', 'error'],\n 'error': ['uploaded', 'transcribing'], // Allow retry\n 'initial': ['enhanced', 'in_progress', 'error'],\n 'enhanced': ['reviewed', 'in_progress', 'error'],\n 'reviewed': ['closed', 'in_progress', 'error'],\n 'in_progress': ['initial', 'enhanced', 'reviewed', 'closed', 'error'],\n 'closed': ['archived', 'in_progress', 'error'],\n 'archived': ['closed', 'error'], // Allow un-archiving\n };\n \n return validTransitions[from]?.includes(to) ?? false;\n}\n"],"names":["Routing.create","listTranscriptsFromStorage"],"mappings":";;;;;;;;;AAuBA,MAAM,YAAA,GAAe,iEAAA;AAErB,SAAS,cAAc,KAAA,EAAwB;AAC3C,EAAA,OAAO,YAAA,CAAa,KAAK,KAAK,CAAA;AAClC;AA6BO,SAAS,YAAY,KAAA,EAAwB;AAChD,EAAA,OAAO,cAAA,CAAe,KAAK,KAAK,CAAA;AACpC;AAUA,eAAsB,oBAAA,CAClB,MACA,iBAAA,EACsB;AACtB,EAAA,MAAM,MAAA,GAAS,IAAA,CAAK,SAAA,CAAU,CAAA,EAAG,CAAC,CAAA;AAClC,EAAA,MAAM,OAAA,GAAU,GAAG,MAAM,CAAA,MAAA,CAAA;AAEzB,EAAA,KAAA,MAAW,OAAO,iBAAA,EAAmB;AACjC,IAAA,MAAM,OAAA,GAAU,MAAM,IAAA,CAAK,OAAA,EAAS,EAAE,GAAA,EAAK,GAAA,EAAK,QAAA,EAAU,IAAA,EAAM,CAAA;AAChE,IAAA,IAAI,OAAA,CAAQ,SAAS,CAAA,EAAG;AAEpB,MAAA,OAAO,QAAQ,CAAC,CAAA;AAAA,IACpB;AAAA,EACJ;AAEA,EAAA,OAAO,IAAA;AACX;AASO,MAAM,eAAA,GAAkB,OAC3B,cAAA,EACA,iBAAA,KAC4B;AAC5B,EAAA,IAAI,YAAA;AAGJ,EAAA,IAAI,WAAA,CAAY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SAAS,MAAA,CAAO,OAAA;AAAA,IAChB,KAAA;AAAA,IACA;AAAA,GACJ;AACJ;AAcO,SAAS,uBAAA,CACZ,MACA,EAAA,EACO;AAEP,EAAA,IAAI,CAAC,IAAA,EAAM;AACP,IAAA,OAAO,IAAA;AAAA,EACX;AAGA,EAAA,MAAM,gBAAA,GAGF;AAAA,IACA,UAAA,EAAY,CAAC,cAAA,EAAgB,OAAO,CAAA;AAAA,IACpC,cAAA,EAAgB,CAAC,SAAA,EAAW,OAAO,CAAA;AAAA,IACnC,OAAA,EAAS,CAAC,UAAA,EAAY,cAAc,CAAA;AAAA;AAAA,IACpC,SAAA,EAAW,CAAC,UAAA,EAAY,aAAA,EAAe,OAAO,CAAA;AAAA,IAC9C,UAAA,EAAY,CAAC,UAAA,EAAY,aAAA,EAAe,OAAO,CAAA;AAAA,IAC/C,UAAA,EAAY,CAAC,QAAA,EAAU,aAAA,EAAe,OAAO,CAAA;AAAA,IAC7C,eAAe,CAAC,SAAA,EAAW,UAAA,EAAY,UAAA,EAAY,UAAU,OAAO,CAAA;AAAA,IACpE,QAAA,EAAU,CAAC,UAAA,EAAY,aAAA,EAAe,OAAO,CAAA;AAAA,IAC7C,UAAA,EAAY,CAAC,QAAA,EAAU,OAAO;AAAA;AAAA,GAClC;AAEA,EAAA,OAAO,gBAAA,CAAiB,IAAI,CAAA,EAAG,QAAA,CAAS,EAAE,CAAA,IAAK,KAAA;AACnD;;;;"}
1
+ {"version":3,"file":"index38.js","sources":["../src/transcript/operations.ts"],"sourcesContent":["/**\n * Transcript Operations\n * \n * Core business logic for transcript parsing, listing, editing, and combining.\n * PKL-only implementation - all transcripts are stored in PKL format.\n */\n\nimport * as fs from 'fs/promises';\nimport * as path from 'node:path';\nimport { glob } from 'glob';\nimport * as Context from '@redaksjon/context';\nimport * as Routing from '../routing';\nimport { Project } from '@redaksjon/context';\nimport { findProjectResilient } from '../utils/entityFinder';\nimport { \n PklTranscript, \n listTranscripts as listTranscriptsFromStorage,\n} from '@redaksjon/protokoll-format';\nimport { ensurePklExtension } from './pkl-utils';\n\ntype PklMetadata = {\n id: string;\n title?: string;\n date?: Date;\n recordingTime?: string;\n project?: string;\n projectId?: string;\n tags?: string[];\n duration?: string;\n status?: TranscriptStatus;\n routing?: {\n destination?: string;\n confidence?: number;\n signals?: string[];\n reasoning?: string;\n };\n entities?: {\n people?: Array<{ id: string; name: string; type: EntityType }>;\n projects?: Array<{ id: string; name: string; type: EntityType }>;\n terms?: Array<{ id: string; name: string; type: EntityType }>;\n companies?: Array<{ id: string; name: string; type: EntityType }>;\n };\n};\n\ntype TranscriptStatus =\n | 'uploaded'\n | 'transcribing'\n | 'error'\n | 'initial'\n | 'enhanced'\n | 'reviewed'\n | 'in_progress'\n | 'closed'\n | 'archived';\n\ntype EntityType = 'person' | 'project' | 'term' | 'company';\n\n/** UUID v4 pattern — used to detect corrupted project fields */\nconst UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n\nfunction looksLikeUuid(value: string): boolean {\n return UUID_PATTERN.test(value);\n}\n\n/**\n * Parsed transcript structure\n */\nexport interface ParsedTranscript {\n filePath: string;\n title?: string;\n metadata: TranscriptMetadata;\n content: string;\n rawText: string;\n}\n\nexport interface TranscriptMetadata {\n date?: string;\n time?: string;\n project?: string;\n projectId?: string;\n destination?: string;\n confidence?: string;\n signals?: string[];\n reasoning?: string;\n tags?: string[];\n duration?: string;\n}\n\n/**\n * Check if input looks like a UUID (8+ hex chars)\n */\nexport function isUuidInput(input: string): boolean {\n return /^[a-f0-9]{8}/.test(input);\n}\n\n/**\n * Find transcript by UUID using glob scan\n * TODO: Replace with index-based lookup for better performance with large collections\n * \n * @param uuid - Full UUID or 8-character prefix\n * @param searchDirectories - Directories to search in\n * @returns Absolute path to transcript file, or null if not found\n */\nexport async function findTranscriptByUuid(\n uuid: string,\n searchDirectories: string[]\n): Promise<string | null> {\n const prefix = uuid.substring(0, 8); // Support both full UUID and prefix\n const pattern = `${prefix}-*.pkl`;\n \n for (const dir of searchDirectories) {\n const matches = await glob(pattern, { cwd: dir, absolute: true });\n if (matches.length > 0) {\n // Return first match - UUIDs should be unique\n return matches[0];\n }\n }\n \n return null;\n}\n\n/**\n * Parse a transcript file into its components\n * PKL-only implementation\n * \n * @param filePathOrUuid - File path or UUID to parse\n * @param searchDirectories - Optional directories to search if UUID is provided\n */\nexport const parseTranscript = async (\n filePathOrUuid: string,\n searchDirectories?: string[]\n): Promise<ParsedTranscript> => {\n let resolvedPath: string;\n \n // Check if input is a UUID\n if (isUuidInput(filePathOrUuid)) {\n if (!searchDirectories || searchDirectories.length === 0) {\n throw new Error('Search directories required for UUID lookup');\n }\n const foundPath = await findTranscriptByUuid(filePathOrUuid, searchDirectories);\n if (!foundPath) {\n throw new Error(`Transcript not found for UUID: ${filePathOrUuid}`);\n }\n resolvedPath = foundPath;\n } else {\n // Existing path-based logic\n resolvedPath = ensurePklExtension(filePathOrUuid);\n }\n \n const transcript = PklTranscript.open(resolvedPath, { readOnly: true });\n \n try {\n const pklMetadata = transcript.metadata as PklMetadata;\n const content = transcript.content;\n \n const result: ParsedTranscript = {\n filePath: resolvedPath,\n title: pklMetadata.title,\n metadata: {\n date: pklMetadata.date instanceof Date \n ? pklMetadata.date.toISOString().split('T')[0] \n : undefined,\n time: pklMetadata.recordingTime,\n project: pklMetadata.project,\n projectId: pklMetadata.projectId,\n destination: pklMetadata.routing?.destination,\n confidence: pklMetadata.routing?.confidence?.toString(),\n signals: pklMetadata.routing?.signals,\n reasoning: pklMetadata.routing?.reasoning,\n tags: pklMetadata.tags,\n duration: pklMetadata.duration,\n },\n content,\n rawText: content, // For PKL files, content is the enhanced text\n };\n \n return result;\n } finally {\n transcript.close();\n }\n};\n\n/**\n * Extract the timestamp from a transcript filename\n */\nexport const extractTimestampFromFilename = (filePath: string): { day: number; hour: number; minute: number } | null => {\n const ext = path.extname(filePath);\n const basename = path.basename(filePath, ext);\n const match = basename.match(/^(\\d{1,2})-(\\d{2})(\\d{2})/);\n \n if (match) {\n return {\n day: parseInt(match[1], 10),\n hour: parseInt(match[2], 10),\n minute: parseInt(match[3], 10),\n };\n }\n \n return null;\n};\n\n/**\n * Slugify a title for use in filenames\n */\nexport const slugifyTitle = (title: string): string => {\n return title\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/--+/g, '-')\n .replace(/^-|-$/g, '')\n .slice(0, 50);\n};\n\n/**\n * Parse duration string to seconds\n */\nconst parseDuration = (duration: string): number => {\n const match = duration.match(/(\\d+):(\\d+)/);\n if (match) {\n const [, minutes, seconds] = match;\n return parseInt(minutes, 10) * 60 + parseInt(seconds, 10);\n }\n return 0;\n};\n\n/**\n * Format seconds as duration string\n */\nconst formatDuration = (seconds: number): string => {\n const minutes = Math.floor(seconds / 60);\n const secs = seconds % 60;\n return `${minutes}:${secs.toString().padStart(2, '0')}`;\n};\n\n/**\n * Expand ~ in paths\n */\nconst expandPath = (p: string): string => {\n if (p.startsWith('~')) {\n return path.join(process.env.HOME || '', p.slice(1));\n }\n return p;\n};\n\n/**\n * Extract date from metadata\n */\nconst extractDateFromMetadata = (metadata: TranscriptMetadata, filePath: string): Date => {\n if (metadata.date) {\n return new Date(metadata.date);\n }\n const timestamp = extractTimestampFromFilename(filePath);\n if (timestamp) {\n const now = new Date();\n return new Date(now.getFullYear(), now.getMonth(), timestamp.day, timestamp.hour, timestamp.minute);\n }\n return new Date();\n};\n\n/**\n * Build routing config from context and project\n */\nconst buildRoutingConfig = (\n context: Context.ContextInstance,\n _targetProject: Project\n): Routing.RoutingConfig => {\n const config = context.getConfig();\n const defaultPath = expandPath((config.outputDirectory as string) || '~/notes');\n \n const resolveRoutingPath = (routingPath: string | undefined): string => {\n if (!routingPath) {\n return defaultPath;\n }\n const expanded = expandPath(routingPath);\n if (!expanded.startsWith('/') && !expanded.match(/^[A-Za-z]:/)) {\n return path.resolve(defaultPath, expanded);\n }\n return expanded;\n };\n\n return {\n default: {\n path: resolveRoutingPath(undefined),\n structure: 'month',\n filename_options: ['date', 'time', 'subject'],\n },\n projects: context.getAllProjects()\n .filter(p => p.active !== false)\n .map(p => ({\n projectId: p.id,\n destination: {\n path: resolveRoutingPath(p.routing?.destination),\n structure: p.routing?.structure || 'month',\n filename_options: p.routing?.filename_options || ['date', 'time', 'subject'],\n },\n classification: p.classification,\n active: p.active,\n })),\n conflict_resolution: 'primary' as const,\n };\n};\n\n/**\n * Combine multiple transcripts into a single document\n * PKL-only implementation\n */\nexport const combineTranscripts = async (\n filePaths: string[],\n options: {\n projectId?: string;\n title?: string;\n dryRun?: boolean;\n verbose?: boolean;\n contextDirectory?: string;\n /** Explicit context directories (from protokoll-config.yaml) */\n contextDirectories?: string[];\n } = {}\n): Promise<{ outputPath: string; content: string }> => {\n if (filePaths.length === 0) {\n throw new Error('No transcript files provided');\n }\n \n const transcripts: ParsedTranscript[] = [];\n for (const filePath of filePaths) {\n try {\n const parsed = await parseTranscript(filePath);\n transcripts.push(parsed);\n } catch (error) {\n throw new Error(`Failed to parse transcript: ${filePath} - ${error}`);\n }\n }\n \n transcripts.sort((a, b) => {\n const aName = path.basename(a.filePath);\n const bName = path.basename(b.filePath);\n return aName.localeCompare(bName);\n });\n \n const firstTranscript = transcripts[0];\n const baseMetadata = { ...firstTranscript.metadata };\n \n // Use explicit contextDirectories from options if provided (from protokoll-config.yaml)\n const context = await Context.create({\n startingDir: options.contextDirectory || path.dirname(firstTranscript.filePath),\n contextDirectories: options.contextDirectories,\n });\n let targetProject: Project | undefined;\n \n if (options.projectId) {\n targetProject = findProjectResilient(context, options.projectId);\n baseMetadata.project = targetProject.name;\n baseMetadata.projectId = targetProject.id;\n \n if (targetProject.routing?.destination) {\n const config = context.getConfig();\n const defaultPath = expandPath((config.outputDirectory as string) || '~/notes');\n const routingPath = expandPath(targetProject.routing.destination);\n const resolvedPath = !routingPath.startsWith('/') && !routingPath.match(/^[A-Za-z]:/)\n ? path.resolve(defaultPath, routingPath)\n : routingPath;\n baseMetadata.destination = resolvedPath;\n }\n }\n \n let totalSeconds = 0;\n let hasDuration = false;\n for (const t of transcripts) {\n if (t.metadata.duration) {\n hasDuration = true;\n totalSeconds += parseDuration(t.metadata.duration);\n }\n }\n if (hasDuration && totalSeconds > 0) {\n baseMetadata.duration = formatDuration(totalSeconds);\n }\n \n const allTags = new Set<string>();\n for (const t of transcripts) {\n if (t.metadata.tags) {\n for (const tag of t.metadata.tags) {\n allTags.add(tag);\n }\n }\n }\n if (allTags.size > 0) {\n baseMetadata.tags = Array.from(allTags).sort();\n }\n \n const combinedTitle = options.title \n ? options.title\n : (firstTranscript.title \n ? `${firstTranscript.title} (Combined)`\n : 'Combined Transcript');\n \n // Build combined content\n const contentParts: string[] = [];\n for (let i = 0; i < transcripts.length; i++) {\n const t = transcripts[i];\n const sectionTitle = t.title || `Part ${i + 1}`;\n const sourceFile = path.basename(t.filePath);\n \n contentParts.push(`## ${sectionTitle}`);\n contentParts.push(`*Source: ${sourceFile}*`);\n contentParts.push('');\n contentParts.push(t.content);\n contentParts.push('');\n }\n \n const combinedContent = contentParts.join('\\n');\n \n // Determine output path\n let outputPath: string;\n \n if (targetProject?.routing?.destination) {\n const routingConfig = buildRoutingConfig(context, targetProject);\n const routing = Routing.create(routingConfig, context, undefined);\n \n const audioDate = extractDateFromMetadata(baseMetadata, firstTranscript.filePath);\n \n const routingContext: Routing.RoutingContext = {\n transcriptText: combinedContent,\n audioDate,\n sourceFile: firstTranscript.filePath,\n };\n \n const decision = routing.route(routingContext);\n outputPath = routing.buildOutputPath(decision, routingContext);\n // Ensure .pkl extension\n outputPath = outputPath.replace(/\\.md$/, '.pkl');\n } else {\n const firstDir = path.dirname(firstTranscript.filePath);\n const timestamp = extractTimestampFromFilename(firstTranscript.filePath);\n \n const filenameSuffix = options.title \n ? slugifyTitle(options.title)\n : 'combined';\n \n if (timestamp) {\n const day = timestamp.day.toString().padStart(2, '0');\n const hour = timestamp.hour.toString().padStart(2, '0');\n const minute = timestamp.minute.toString().padStart(2, '0');\n outputPath = path.join(firstDir, `${day}-${hour}${minute}-${filenameSuffix}.pkl`);\n } else {\n outputPath = path.join(firstDir, `${filenameSuffix}.pkl`);\n }\n }\n \n // Create the combined PKL transcript\n if (!options.dryRun) {\n const initialMetadata: PklMetadata = {\n id: '', // Will be auto-generated by PklTranscript.create()\n title: combinedTitle,\n date: baseMetadata.date ? new Date(baseMetadata.date) : undefined,\n recordingTime: baseMetadata.time,\n project: targetProject?.name || baseMetadata.project,\n projectId: targetProject?.id || baseMetadata.projectId,\n tags: baseMetadata.tags || [],\n duration: baseMetadata.duration,\n status: 'enhanced',\n };\n \n if (targetProject) {\n initialMetadata.entities = {\n people: [],\n projects: [{\n id: targetProject.id,\n name: targetProject.name,\n type: 'project',\n }],\n terms: [],\n companies: [],\n };\n }\n \n const newTranscript = PklTranscript.create(outputPath, initialMetadata);\n try {\n newTranscript.updateContent(combinedContent);\n } finally {\n newTranscript.close();\n }\n }\n \n return { outputPath, content: combinedContent };\n};\n\n/**\n * Edit transcript metadata and content\n * PKL-only implementation\n */\nexport const editTranscript = async (\n filePath: string,\n options: {\n title?: string;\n projectId?: string;\n tagsToAdd?: string[];\n tagsToRemove?: string[];\n dryRun?: boolean;\n verbose?: boolean;\n contextDirectory?: string;\n /** Explicit context directories (from protokoll-config.yaml) */\n contextDirectories?: string[];\n }\n): Promise<{ outputPath: string; content: string }> => {\n const pklPath = ensurePklExtension(filePath);\n const transcript = PklTranscript.open(pklPath, { readOnly: false });\n \n try {\n const pklMetadata = transcript.metadata as PklMetadata;\n const content = transcript.content;\n \n // Use explicit contextDirectories from options if provided (from protokoll-config.yaml)\n const context = await Context.create({\n startingDir: options.contextDirectory || path.dirname(pklPath),\n contextDirectories: options.contextDirectories,\n });\n let targetProject: Project | undefined;\n \n if (options.projectId) {\n targetProject = findProjectResilient(context, options.projectId);\n }\n \n const newTitle = options.title || pklMetadata.title || 'Untitled';\n \n // Build updated metadata\n const updatedMetadata: Partial<PklMetadata> = {};\n \n if (options.title) {\n updatedMetadata.title = newTitle;\n }\n \n if (targetProject) {\n updatedMetadata.project = targetProject.name;\n updatedMetadata.projectId = targetProject.id;\n \n // Update entities with the project\n const existingEntities = pklMetadata.entities || { people: [], projects: [], terms: [], companies: [] };\n updatedMetadata.entities = {\n people: existingEntities.people || [],\n projects: [{\n id: targetProject.id,\n name: targetProject.name,\n type: 'project',\n }],\n terms: existingEntities.terms || [],\n companies: existingEntities.companies || [],\n };\n }\n \n // Handle tag updates\n if (options.tagsToAdd || options.tagsToRemove) {\n const currentTags = new Set(pklMetadata.tags || []);\n \n if (options.tagsToRemove) {\n for (const tag of options.tagsToRemove) {\n currentTags.delete(tag);\n }\n }\n \n if (options.tagsToAdd) {\n for (const tag of options.tagsToAdd) {\n currentTags.add(tag);\n }\n }\n \n updatedMetadata.tags = Array.from(currentTags).sort();\n }\n \n // Determine output path\n let outputPath = pklPath;\n \n if (targetProject?.routing?.destination || options.title) {\n if (targetProject?.routing?.destination) {\n const routingConfig = buildRoutingConfig(context, targetProject);\n const routing = Routing.create(routingConfig, context, undefined);\n \n const audioDate = pklMetadata.date instanceof Date ? pklMetadata.date : new Date();\n \n const routingContext: Routing.RoutingContext = {\n transcriptText: content,\n audioDate,\n sourceFile: pklPath,\n };\n \n const decision = routing.route(routingContext);\n \n if (options.title) {\n const basePath = path.dirname(routing.buildOutputPath(decision, routingContext));\n const timestamp = extractTimestampFromFilename(pklPath);\n const sluggedTitle = slugifyTitle(options.title);\n \n if (timestamp) {\n const day = timestamp.day.toString().padStart(2, '0');\n const hour = timestamp.hour.toString().padStart(2, '0');\n const minute = timestamp.minute.toString().padStart(2, '0');\n outputPath = path.join(basePath, `${day}-${hour}${minute}-${sluggedTitle}.pkl`);\n } else {\n outputPath = path.join(basePath, `${sluggedTitle}.pkl`);\n }\n } else {\n outputPath = routing.buildOutputPath(decision, routingContext);\n outputPath = outputPath.replace(/\\.md$/, '.pkl');\n }\n } else if (options.title) {\n const dir = path.dirname(pklPath);\n const timestamp = extractTimestampFromFilename(pklPath);\n const sluggedTitle = slugifyTitle(options.title);\n \n if (timestamp) {\n const day = timestamp.day.toString().padStart(2, '0');\n const hour = timestamp.hour.toString().padStart(2, '0');\n const minute = timestamp.minute.toString().padStart(2, '0');\n outputPath = path.join(dir, `${day}-${hour}${minute}-${sluggedTitle}.pkl`);\n } else {\n outputPath = path.join(dir, `${sluggedTitle}.pkl`);\n }\n }\n }\n \n // Apply updates\n if (!options.dryRun) {\n if (Object.keys(updatedMetadata).length > 0) {\n transcript.updateMetadata(updatedMetadata);\n }\n \n // If output path changed, we need to move the file\n if (outputPath !== pklPath) {\n // Close current transcript\n transcript.close();\n \n // Create directory if needed\n await fs.mkdir(path.dirname(outputPath), { recursive: true });\n \n // Copy to new location\n await fs.copyFile(pklPath, outputPath);\n \n // Delete old file\n await fs.unlink(pklPath);\n }\n }\n \n return { outputPath, content };\n } finally {\n // Only close if not already closed (due to move operation)\n try {\n transcript.close();\n } catch {\n // Already closed\n }\n }\n};\n\n/**\n * Transcript list item\n */\nexport interface TranscriptListItem {\n path: string;\n filename: string;\n uuid: string; // UUID identifier for this transcript\n date: string;\n time?: string;\n title: string;\n hasRawTranscript: boolean;\n createdAt: Date;\n status?: TranscriptStatus;\n openTasksCount?: number;\n contentSize?: number;\n entities?: {\n people?: Array<{ id: string; name: string }>;\n projects?: Array<{ id: string; name: string }>;\n terms?: Array<{ id: string; name: string }>;\n companies?: Array<{ id: string; name: string }>;\n };\n}\n\nexport interface ListTranscriptsOptions {\n directory: string;\n limit?: number;\n offset?: number;\n sortBy?: 'date' | 'filename' | 'title';\n startDate?: string;\n endDate?: string;\n search?: string;\n projectId?: string;\n /** Project name - used as fallback when projectId is also set (matches transcripts with project name but no projectId) */\n project?: string;\n}\n\nexport interface ListTranscriptsResult {\n transcripts: TranscriptListItem[];\n total: number;\n hasMore: boolean;\n limit: number;\n offset: number;\n}\n\n/**\n * List transcripts with filtering and pagination\n * Uses the protokoll-format storage API\n */\nexport const listTranscripts = async (options: ListTranscriptsOptions): Promise<ListTranscriptsResult> => {\n const {\n directory,\n limit = 50,\n offset = 0,\n sortBy = 'date',\n startDate,\n endDate,\n search,\n projectId,\n project,\n } = options;\n \n // Use the storage API from protokoll-format\n // Pass projectId for UUID-based filtering; project (name) as fallback for transcripts without projectId\n const storageOptions = {\n directory,\n limit,\n offset,\n sortBy,\n search,\n projectId,\n project,\n startDate,\n endDate,\n };\n \n const result = await listTranscriptsFromStorage(storageOptions);\n \n // Convert storage result to operations result format\n const transcripts: TranscriptListItem[] = result.transcripts.map(item => {\n let uuid = '';\n let entities: TranscriptListItem['entities'];\n try {\n const transcript = PklTranscript.open(item.filePath, { readOnly: true });\n const meta = transcript.metadata as PklMetadata;\n uuid = meta.id;\n const mappedProjects = meta.entities?.projects?.map((e: { id: string; name: string }) => ({ id: e.id, name: e.name }));\n // If entities.projects is missing/empty but the scalar project field is set,\n // synthesise a project entry so the list view can display it correctly.\n const projectEntries = (mappedProjects && mappedProjects.length > 0)\n ? mappedProjects\n : (item.project && !looksLikeUuid(item.project))\n ? [{ id: meta.projectId || item.project, name: item.project }]\n : undefined;\n\n if (meta.entities || projectEntries) {\n entities = {\n people: meta.entities?.people?.map((e: { id: string; name: string }) => ({ id: e.id, name: e.name })),\n projects: projectEntries,\n terms: meta.entities?.terms?.map((e: { id: string; name: string }) => ({ id: e.id, name: e.name })),\n companies: meta.entities?.companies?.map((e: { id: string; name: string }) => ({ id: e.id, name: e.name })),\n };\n }\n transcript.close();\n } catch {\n uuid = '';\n if (item.project && !looksLikeUuid(item.project)) {\n entities = {\n projects: [{ id: item.project, name: item.project }],\n };\n }\n }\n \n return {\n path: item.filePath,\n filename: path.basename(item.filePath),\n uuid,\n date: item.date instanceof Date ? item.date.toISOString().split('T')[0] : '',\n time: undefined,\n title: item.title,\n hasRawTranscript: false,\n createdAt: item.date || new Date(),\n status: item.status,\n openTasksCount: undefined,\n contentSize: item.contentPreview?.length,\n entities,\n };\n });\n \n return {\n transcripts,\n total: result.total,\n hasMore: result.hasMore,\n limit,\n offset,\n };\n};\n\n/**\n * Validate status transitions for transcript lifecycle\n * \n * Ensures status changes follow valid workflow:\n * - Upload workflow: uploaded → transcribing → initial → enhanced → reviewed → closed\n * - Error can occur at any point\n * - Error status allows retry (back to uploaded or transcribing)\n * \n * @param from - Current status\n * @param to - Desired status\n * @returns true if transition is valid, false otherwise\n */\nexport function isValidStatusTransition(\n from: TranscriptStatus | undefined,\n to: TranscriptStatus\n): boolean {\n // If no current status, any status is valid (initial creation)\n if (!from) {\n return true;\n }\n \n // Define valid transitions for each status\n const validTransitions: Record<\n TranscriptStatus,\n TranscriptStatus[]\n > = {\n 'uploaded': ['transcribing', 'error'],\n 'transcribing': ['initial', 'error'],\n 'error': ['uploaded', 'transcribing'], // Allow retry\n 'initial': ['enhanced', 'in_progress', 'error'],\n 'enhanced': ['reviewed', 'in_progress', 'error'],\n 'reviewed': ['closed', 'in_progress', 'error'],\n 'in_progress': ['initial', 'enhanced', 'reviewed', 'closed', 'error'],\n 'closed': ['archived', 'in_progress', 'error'],\n 'archived': ['closed', 'error'], // Allow un-archiving\n };\n \n return validTransitions[from]?.includes(to) ?? false;\n}\n"],"names":["Routing.create","listTranscriptsFromStorage"],"mappings":";;;;;;;;;AA0DA,MAAM,YAAA,GAAe,iEAAA;AAErB,SAAS,cAAc,KAAA,EAAwB;AAC3C,EAAA,OAAO,YAAA,CAAa,KAAK,KAAK,CAAA;AAClC;AA6BO,SAAS,YAAY,KAAA,EAAwB;AAChD,EAAA,OAAO,cAAA,CAAe,KAAK,KAAK,CAAA;AACpC;AAUA,eAAsB,oBAAA,CAClB,MACA,iBAAA,EACsB;AACtB,EAAA,MAAM,MAAA,GAAS,IAAA,CAAK,SAAA,CAAU,CAAA,EAAG,CAAC,CAAA;AAClC,EAAA,MAAM,OAAA,GAAU,GAAG,MAAM,CAAA,MAAA,CAAA;AAEzB,EAAA,KAAA,MAAW,OAAO,iBAA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