@redaksjon/protokoll-engine 0.1.1-dev.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (240) hide show
  1. package/README.md +47 -0
  2. package/dist/agentic/executor.d.ts +21 -0
  3. package/dist/agentic/executor.d.ts.map +1 -0
  4. package/dist/agentic/index.d.ts +27 -0
  5. package/dist/agentic/index.d.ts.map +1 -0
  6. package/dist/agentic/registry.d.ts +11 -0
  7. package/dist/agentic/registry.d.ts.map +1 -0
  8. package/dist/agentic/tools/lookup-person.d.ts +3 -0
  9. package/dist/agentic/tools/lookup-person.d.ts.map +1 -0
  10. package/dist/agentic/tools/lookup-project.d.ts +3 -0
  11. package/dist/agentic/tools/lookup-project.d.ts.map +1 -0
  12. package/dist/agentic/tools/route-note.d.ts +3 -0
  13. package/dist/agentic/tools/route-note.d.ts.map +1 -0
  14. package/dist/agentic/tools/store-context.d.ts +3 -0
  15. package/dist/agentic/tools/store-context.d.ts.map +1 -0
  16. package/dist/agentic/tools/verify-spelling.d.ts +3 -0
  17. package/dist/agentic/tools/verify-spelling.d.ts.map +1 -0
  18. package/dist/agentic/types.d.ts +110 -0
  19. package/dist/agentic/types.d.ts.map +1 -0
  20. package/dist/constants.d.ts +98 -0
  21. package/dist/constants.d.ts.map +1 -0
  22. package/dist/feedback/analyzer.d.ts +13 -0
  23. package/dist/feedback/analyzer.d.ts.map +1 -0
  24. package/dist/feedback/decision-tracker.d.ts +14 -0
  25. package/dist/feedback/decision-tracker.d.ts.map +1 -0
  26. package/dist/feedback/handler.d.ts +14 -0
  27. package/dist/feedback/handler.d.ts.map +1 -0
  28. package/dist/feedback/index.d.ts +12 -0
  29. package/dist/feedback/index.d.ts.map +1 -0
  30. package/dist/feedback/types.d.ts +72 -0
  31. package/dist/feedback/types.d.ts.map +1 -0
  32. package/dist/index.d.ts +24 -0
  33. package/dist/index.d.ts.map +1 -0
  34. package/dist/index.js +32 -0
  35. package/dist/index.js.map +1 -0
  36. package/dist/index10.js +4 -0
  37. package/dist/index10.js.map +1 -0
  38. package/dist/index11.js +22 -0
  39. package/dist/index11.js.map +1 -0
  40. package/dist/index12.js +125 -0
  41. package/dist/index12.js.map +1 -0
  42. package/dist/index13.js +124 -0
  43. package/dist/index13.js.map +1 -0
  44. package/dist/index14.js +296 -0
  45. package/dist/index14.js.map +1 -0
  46. package/dist/index15.js +100 -0
  47. package/dist/index15.js.map +1 -0
  48. package/dist/index16.js +107 -0
  49. package/dist/index16.js.map +1 -0
  50. package/dist/index17.js +185 -0
  51. package/dist/index17.js.map +1 -0
  52. package/dist/index18.js +53 -0
  53. package/dist/index18.js.map +1 -0
  54. package/dist/index19.js +19 -0
  55. package/dist/index19.js.map +1 -0
  56. package/dist/index2.js +33 -0
  57. package/dist/index2.js.map +1 -0
  58. package/dist/index20.js +105 -0
  59. package/dist/index20.js.map +1 -0
  60. package/dist/index21.js +26 -0
  61. package/dist/index21.js.map +1 -0
  62. package/dist/index22.js +49 -0
  63. package/dist/index22.js.map +1 -0
  64. package/dist/index23.js +119 -0
  65. package/dist/index23.js.map +1 -0
  66. package/dist/index24.js +330 -0
  67. package/dist/index24.js.map +1 -0
  68. package/dist/index25.js +57 -0
  69. package/dist/index25.js.map +1 -0
  70. package/dist/index26.js +38 -0
  71. package/dist/index26.js.map +1 -0
  72. package/dist/index27.js +127 -0
  73. package/dist/index27.js.map +1 -0
  74. package/dist/index28.js +157 -0
  75. package/dist/index28.js.map +1 -0
  76. package/dist/index29.js +163 -0
  77. package/dist/index29.js.map +1 -0
  78. package/dist/index3.js +36 -0
  79. package/dist/index3.js.map +1 -0
  80. package/dist/index30.js +173 -0
  81. package/dist/index30.js.map +1 -0
  82. package/dist/index31.js +423 -0
  83. package/dist/index31.js.map +1 -0
  84. package/dist/index32.js +161 -0
  85. package/dist/index32.js.map +1 -0
  86. package/dist/index33.js +152 -0
  87. package/dist/index33.js.map +1 -0
  88. package/dist/index34.js +56 -0
  89. package/dist/index34.js.map +1 -0
  90. package/dist/index35.js +103 -0
  91. package/dist/index35.js.map +1 -0
  92. package/dist/index36.js +451 -0
  93. package/dist/index36.js.map +1 -0
  94. package/dist/index37.js +431 -0
  95. package/dist/index37.js.map +1 -0
  96. package/dist/index38.js +87 -0
  97. package/dist/index38.js.map +1 -0
  98. package/dist/index39.js +122 -0
  99. package/dist/index39.js.map +1 -0
  100. package/dist/index4.js +3 -0
  101. package/dist/index4.js.map +1 -0
  102. package/dist/index40.js +299 -0
  103. package/dist/index40.js.map +1 -0
  104. package/dist/index41.js +49 -0
  105. package/dist/index41.js.map +1 -0
  106. package/dist/index42.js +151 -0
  107. package/dist/index42.js.map +1 -0
  108. package/dist/index43.js +226 -0
  109. package/dist/index43.js.map +1 -0
  110. package/dist/index44.js +49 -0
  111. package/dist/index44.js.map +1 -0
  112. package/dist/index45.js +45 -0
  113. package/dist/index45.js.map +1 -0
  114. package/dist/index46.js +37 -0
  115. package/dist/index46.js.map +1 -0
  116. package/dist/index47.js +51 -0
  117. package/dist/index47.js.map +1 -0
  118. package/dist/index48.js +39 -0
  119. package/dist/index48.js.map +1 -0
  120. package/dist/index49.js +239 -0
  121. package/dist/index49.js.map +1 -0
  122. package/dist/index5.js +17 -0
  123. package/dist/index5.js.map +1 -0
  124. package/dist/index50.js +163 -0
  125. package/dist/index50.js.map +1 -0
  126. package/dist/index51.js +81 -0
  127. package/dist/index51.js.map +1 -0
  128. package/dist/index52.js +78 -0
  129. package/dist/index52.js.map +1 -0
  130. package/dist/index53.js +22 -0
  131. package/dist/index53.js.map +1 -0
  132. package/dist/index54.js +8 -0
  133. package/dist/index54.js.map +1 -0
  134. package/dist/index55.js +8 -0
  135. package/dist/index55.js.map +1 -0
  136. package/dist/index56.js +17 -0
  137. package/dist/index56.js.map +1 -0
  138. package/dist/index57.js +4 -0
  139. package/dist/index57.js.map +1 -0
  140. package/dist/index58.js +17 -0
  141. package/dist/index58.js.map +1 -0
  142. package/dist/index59.js +4 -0
  143. package/dist/index59.js.map +1 -0
  144. package/dist/index6.js +22 -0
  145. package/dist/index6.js.map +1 -0
  146. package/dist/index60.js +6 -0
  147. package/dist/index60.js.map +1 -0
  148. package/dist/index7.js +27 -0
  149. package/dist/index7.js.map +1 -0
  150. package/dist/index8.js +22 -0
  151. package/dist/index8.js.map +1 -0
  152. package/dist/index9.js +5 -0
  153. package/dist/index9.js.map +1 -0
  154. package/dist/logging.d.ts +7 -0
  155. package/dist/logging.d.ts.map +1 -0
  156. package/dist/output/index.d.ts +15 -0
  157. package/dist/output/index.d.ts.map +1 -0
  158. package/dist/phases/complete.d.ts +17 -0
  159. package/dist/phases/complete.d.ts.map +1 -0
  160. package/dist/phases/index.d.ts +5 -0
  161. package/dist/phases/index.d.ts.map +1 -0
  162. package/dist/phases/locate.d.ts +15 -0
  163. package/dist/phases/locate.d.ts.map +1 -0
  164. package/dist/phases/simple-replace.d.ts +72 -0
  165. package/dist/phases/simple-replace.d.ts.map +1 -0
  166. package/dist/phases/transcribe.d.ts +19 -0
  167. package/dist/phases/transcribe.d.ts.map +1 -0
  168. package/dist/pipeline/index.d.ts +10 -0
  169. package/dist/pipeline/index.d.ts.map +1 -0
  170. package/dist/pipeline/orchestrator.d.ts +13 -0
  171. package/dist/pipeline/orchestrator.d.ts.map +1 -0
  172. package/dist/pipeline/types.d.ts +58 -0
  173. package/dist/pipeline/types.d.ts.map +1 -0
  174. package/dist/prompt/index.d.ts +3 -0
  175. package/dist/prompt/index.d.ts.map +1 -0
  176. package/dist/prompt/templates.d.ts +40 -0
  177. package/dist/prompt/templates.d.ts.map +1 -0
  178. package/dist/prompt/transcribe.d.ts +42 -0
  179. package/dist/prompt/transcribe.d.ts.map +1 -0
  180. package/dist/reasoning/client.d.ts +42 -0
  181. package/dist/reasoning/client.d.ts.map +1 -0
  182. package/dist/reasoning/index.d.ts +17 -0
  183. package/dist/reasoning/index.d.ts.map +1 -0
  184. package/dist/reasoning/strategy.d.ts +12 -0
  185. package/dist/reasoning/strategy.d.ts.map +1 -0
  186. package/dist/reasoning/types.d.ts +58 -0
  187. package/dist/reasoning/types.d.ts.map +1 -0
  188. package/dist/reflection/collector.d.ts +18 -0
  189. package/dist/reflection/collector.d.ts.map +1 -0
  190. package/dist/reflection/index.d.ts +13 -0
  191. package/dist/reflection/index.d.ts.map +1 -0
  192. package/dist/reflection/reporter.d.ts +10 -0
  193. package/dist/reflection/reporter.d.ts.map +1 -0
  194. package/dist/reflection/types.d.ts +99 -0
  195. package/dist/reflection/types.d.ts.map +1 -0
  196. package/dist/routing/classifier.d.ts +8 -0
  197. package/dist/routing/classifier.d.ts.map +1 -0
  198. package/dist/routing/index.d.ts +12 -0
  199. package/dist/routing/index.d.ts.map +1 -0
  200. package/dist/routing/router.d.ts +8 -0
  201. package/dist/routing/router.d.ts.map +1 -0
  202. package/dist/routing/types.d.ts +68 -0
  203. package/dist/routing/types.d.ts.map +1 -0
  204. package/dist/transcript/feedback.d.ts +70 -0
  205. package/dist/transcript/feedback.d.ts.map +1 -0
  206. package/dist/transcript/index.d.ts +10 -0
  207. package/dist/transcript/index.d.ts.map +1 -0
  208. package/dist/transcript/operations.d.ts +152 -0
  209. package/dist/transcript/operations.d.ts.map +1 -0
  210. package/dist/transcript/pkl-utils.d.ts +66 -0
  211. package/dist/transcript/pkl-utils.d.ts.map +1 -0
  212. package/dist/transcription/index.d.ts +17 -0
  213. package/dist/transcription/index.d.ts.map +1 -0
  214. package/dist/transcription/service.d.ts +10 -0
  215. package/dist/transcription/service.d.ts.map +1 -0
  216. package/dist/transcription/types.d.ts +41 -0
  217. package/dist/transcription/types.d.ts.map +1 -0
  218. package/dist/types.d.ts +28 -0
  219. package/dist/types.d.ts.map +1 -0
  220. package/dist/util/collision-detector.d.ts +77 -0
  221. package/dist/util/collision-detector.d.ts.map +1 -0
  222. package/dist/util/dates.d.ts +57 -0
  223. package/dist/util/dates.d.ts.map +1 -0
  224. package/dist/util/general.d.ts +3 -0
  225. package/dist/util/general.d.ts.map +1 -0
  226. package/dist/util/media.d.ts +9 -0
  227. package/dist/util/media.d.ts.map +1 -0
  228. package/dist/util/metadata.d.ts +138 -0
  229. package/dist/util/metadata.d.ts.map +1 -0
  230. package/dist/util/openai.d.ts +22 -0
  231. package/dist/util/openai.d.ts.map +1 -0
  232. package/dist/util/sounds-like-database.d.ts +98 -0
  233. package/dist/util/sounds-like-database.d.ts.map +1 -0
  234. package/dist/util/storage.d.ts +35 -0
  235. package/dist/util/storage.d.ts.map +1 -0
  236. package/dist/util/text-replacer.d.ts +56 -0
  237. package/dist/util/text-replacer.d.ts.map +1 -0
  238. package/dist/utils/entityFinder.d.ts +29 -0
  239. package/dist/utils/entityFinder.d.ts.map +1 -0
  240. package/package.json +84 -0
@@ -0,0 +1,151 @@
1
+ function extractNameContext(transcript, name) {
2
+ const lowerTranscript = transcript.toLowerCase();
3
+ const lowerName = name.toLowerCase();
4
+ const index = lowerTranscript.indexOf(lowerName);
5
+ if (index === -1) {
6
+ return null;
7
+ }
8
+ const sentenceBoundary = /[.!?]/;
9
+ let startIndex = 0;
10
+ let boundariesFound = 0;
11
+ for (let i = index - 1; i >= 0; i--) {
12
+ if (sentenceBoundary.test(transcript[i])) {
13
+ boundariesFound++;
14
+ if (boundariesFound === 2) {
15
+ startIndex = i + 1;
16
+ break;
17
+ }
18
+ }
19
+ }
20
+ let endIndex = transcript.length;
21
+ boundariesFound = 0;
22
+ for (let i = index + name.length; i < transcript.length; i++) {
23
+ if (sentenceBoundary.test(transcript[i])) {
24
+ boundariesFound++;
25
+ if (boundariesFound === 2) {
26
+ endIndex = i + 1;
27
+ break;
28
+ }
29
+ }
30
+ }
31
+ let context = transcript.substring(startIndex, endIndex).trim();
32
+ if (context.length > 300) {
33
+ const midPoint = context.indexOf(name);
34
+ if (midPoint !== -1) {
35
+ let sentenceStart = midPoint;
36
+ let sentenceEnd = midPoint + name.length;
37
+ for (let i = midPoint - 1; i >= 0; i--) {
38
+ if (sentenceBoundary.test(context[i])) {
39
+ sentenceStart = i + 1;
40
+ break;
41
+ }
42
+ }
43
+ for (let i = midPoint + name.length; i < context.length; i++) {
44
+ if (sentenceBoundary.test(context[i])) {
45
+ sentenceEnd = i + 1;
46
+ break;
47
+ }
48
+ }
49
+ context = context.substring(sentenceStart, sentenceEnd).trim();
50
+ } else {
51
+ context = context.substring(0, 300) + "...";
52
+ }
53
+ }
54
+ return context;
55
+ }
56
+ const create = (ctx) => ({
57
+ name: "lookup_person",
58
+ description: "Look up information about a person mentioned in the transcript. Use when you encounter a name that might need spelling verification or additional context.",
59
+ parameters: {
60
+ type: "object",
61
+ properties: {
62
+ name: {
63
+ type: "string",
64
+ description: "The name to look up (as heard in transcript)"
65
+ },
66
+ phonetic: {
67
+ type: "string",
68
+ description: "How the name sounds (for alias matching)"
69
+ }
70
+ },
71
+ required: ["name"]
72
+ },
73
+ execute: async (args) => {
74
+ const context = ctx.contextInstance;
75
+ if (ctx.resolvedEntities?.has(args.name)) {
76
+ const resolvedName = ctx.resolvedEntities.get(args.name);
77
+ return {
78
+ success: true,
79
+ data: {
80
+ found: true,
81
+ suggestion: `Already resolved: use "${resolvedName}"`,
82
+ cached: true
83
+ }
84
+ };
85
+ }
86
+ const people = context.search(args.name);
87
+ const personMatches = people.filter((e) => e.type === "person");
88
+ if (personMatches.length > 0) {
89
+ return {
90
+ success: true,
91
+ data: {
92
+ found: true,
93
+ person: personMatches[0],
94
+ suggestion: `Use "${personMatches[0].name}" for correct spelling`
95
+ }
96
+ };
97
+ }
98
+ if (args.phonetic) {
99
+ const person = context.findBySoundsLike(args.phonetic);
100
+ if (person) {
101
+ return {
102
+ success: true,
103
+ data: {
104
+ found: true,
105
+ person,
106
+ suggestion: `"${args.phonetic}" likely refers to "${person.name}"`
107
+ }
108
+ };
109
+ }
110
+ }
111
+ const allProjects = context.getAllProjects();
112
+ const projectOptions = allProjects.filter((p) => p.active !== false).map((p) => `${p.name}${p.description ? ` - ${p.description}` : ""}`);
113
+ const fileName = ctx.sourceFile.split("/").pop() || ctx.sourceFile;
114
+ const fileDate = ctx.audioDate.toLocaleString("en-US", {
115
+ weekday: "short",
116
+ year: "numeric",
117
+ month: "short",
118
+ day: "numeric",
119
+ hour: "2-digit",
120
+ minute: "2-digit"
121
+ });
122
+ const transcriptContext = extractNameContext(ctx.transcriptText, args.name);
123
+ const promptLines = [
124
+ `File: ${fileName}`,
125
+ `Date: ${fileDate}`,
126
+ "",
127
+ `Unknown person mentioned: "${args.name}"`
128
+ ];
129
+ if (transcriptContext) {
130
+ promptLines.push("");
131
+ promptLines.push("Context from transcript:");
132
+ promptLines.push(`"${transcriptContext}"`);
133
+ }
134
+ return {
135
+ success: true,
136
+ needsUserInput: true,
137
+ userPrompt: promptLines.join("\n"),
138
+ data: {
139
+ found: false,
140
+ clarificationType: "new_person",
141
+ term: args.name,
142
+ message: `Person "${args.name}" not found. Asking user for details.`,
143
+ knownProjects: allProjects.filter((p) => p.active !== false),
144
+ options: projectOptions
145
+ }
146
+ };
147
+ }
148
+ });
149
+
150
+ export { create };
151
+ //# sourceMappingURL=index42.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index42.js","sources":["../src/agentic/tools/lookup-person.ts"],"sourcesContent":["/**\n * Lookup Person Tool\n * \n * Looks up information about a person mentioned in the transcript.\n */\n\nimport { TranscriptionTool, ToolContext, ToolResult } from '../types';\n\n/**\n * Extract context from transcript around where a name is mentioned.\n * Returns approximately one sentence before and after the name mention.\n */\nfunction extractNameContext(transcript: string, name: string): string | null {\n // Case-insensitive search for the name\n const lowerTranscript = transcript.toLowerCase();\n const lowerName = name.toLowerCase();\n const index = lowerTranscript.indexOf(lowerName);\n \n if (index === -1) {\n return null;\n }\n \n // Define strong sentence boundaries (., !, ?)\n const sentenceBoundary = /[.!?]/;\n \n // Look backwards for the start (find the sentence boundary 1 sentence before)\n let startIndex = 0;\n let boundariesFound = 0;\n for (let i = index - 1; i >= 0; i--) {\n if (sentenceBoundary.test(transcript[i])) {\n boundariesFound++;\n // After finding first boundary (end of current sentence), \n // keep looking for the second (end of previous sentence)\n if (boundariesFound === 2) {\n // Start after this boundary\n startIndex = i + 1;\n break;\n }\n }\n }\n \n // Look forwards for the end (find sentence boundary 1 sentence after)\n let endIndex = transcript.length;\n boundariesFound = 0;\n for (let i = index + name.length; i < transcript.length; i++) {\n if (sentenceBoundary.test(transcript[i])) {\n boundariesFound++;\n // After finding first boundary (end of current sentence),\n // keep looking for the second (end of next sentence)\n if (boundariesFound === 2) {\n // Include this boundary\n endIndex = i + 1;\n break;\n }\n }\n }\n \n // Extract and clean up the context\n let context = transcript.substring(startIndex, endIndex).trim();\n \n // Limit length to avoid overwhelming the prompt (max ~300 chars)\n if (context.length > 300) {\n // Try to cut at a sentence boundary\n const midPoint = context.indexOf(name);\n if (midPoint !== -1) {\n // Keep the sentence with the name, trim around it\n let sentenceStart = midPoint;\n let sentenceEnd = midPoint + name.length;\n \n // Find sentence start\n for (let i = midPoint - 1; i >= 0; i--) {\n if (sentenceBoundary.test(context[i])) {\n sentenceStart = i + 1;\n break;\n }\n }\n \n // Find sentence end\n for (let i = midPoint + name.length; i < context.length; i++) {\n if (sentenceBoundary.test(context[i])) {\n sentenceEnd = i + 1;\n break;\n }\n }\n \n context = context.substring(sentenceStart, sentenceEnd).trim();\n } else {\n // Just truncate if name not found in extracted context\n context = context.substring(0, 300) + '...';\n }\n }\n \n return context;\n}\n\nexport const create = (ctx: ToolContext): TranscriptionTool => ({\n name: 'lookup_person',\n description: 'Look up information about a person mentioned in the transcript. Use when you encounter a name that might need spelling verification or additional context.',\n parameters: {\n type: 'object',\n properties: {\n name: {\n type: 'string',\n description: 'The name to look up (as heard in transcript)',\n },\n phonetic: {\n type: 'string',\n description: 'How the name sounds (for alias matching)',\n },\n },\n required: ['name'],\n },\n execute: async (args: { name: string; phonetic?: string }): Promise<ToolResult> => {\n const context = ctx.contextInstance;\n \n // First, check if this person was already resolved in this session\n if (ctx.resolvedEntities?.has(args.name)) {\n const resolvedName = ctx.resolvedEntities.get(args.name);\n return {\n success: true,\n data: {\n found: true,\n suggestion: `Already resolved: use \"${resolvedName}\"`,\n cached: true,\n },\n };\n }\n \n // Try direct name search\n const people = context.search(args.name);\n const personMatches = people.filter(e => e.type === 'person');\n \n if (personMatches.length > 0) {\n return {\n success: true,\n data: {\n found: true,\n person: personMatches[0],\n suggestion: `Use \"${personMatches[0].name}\" for correct spelling`,\n },\n };\n }\n \n // Try phonetic match (sounds_like)\n if (args.phonetic) {\n const person = context.findBySoundsLike(args.phonetic);\n if (person) {\n return {\n success: true,\n data: {\n found: true,\n person,\n suggestion: `\"${args.phonetic}\" likely refers to \"${person.name}\"`,\n },\n };\n }\n }\n \n // Not found - always signal that we need user input\n // The executor will decide whether to actually prompt based on handler availability\n const allProjects = context.getAllProjects();\n const projectOptions = allProjects\n .filter(p => p.active !== false)\n .map(p => `${p.name}${p.description ? ` - ${p.description}` : ''}`);\n \n // Extract filename from sourceFile path for cleaner display\n const fileName = ctx.sourceFile.split('/').pop() || ctx.sourceFile;\n const fileDate = ctx.audioDate.toLocaleString('en-US', {\n weekday: 'short',\n year: 'numeric',\n month: 'short',\n day: 'numeric',\n hour: '2-digit',\n minute: '2-digit',\n });\n \n // Find context from transcript where the name is mentioned\n const transcriptContext = extractNameContext(ctx.transcriptText, args.name);\n \n const promptLines = [\n `File: ${fileName}`,\n `Date: ${fileDate}`,\n '',\n `Unknown person mentioned: \"${args.name}\"`,\n ];\n \n if (transcriptContext) {\n promptLines.push('');\n promptLines.push('Context from transcript:');\n promptLines.push(`\"${transcriptContext}\"`);\n }\n \n return {\n success: true,\n needsUserInput: true,\n userPrompt: promptLines.join('\\n'),\n data: {\n found: false,\n clarificationType: 'new_person',\n term: args.name,\n message: `Person \"${args.name}\" not found. Asking user for details.`,\n knownProjects: allProjects.filter(p => p.active !== false),\n options: projectOptions,\n },\n };\n },\n});\n\n"],"names":[],"mappings":"AAYA,SAAS,kBAAA,CAAmB,YAAoB,IAAA,EAA6B;AAEzE,EAAA,MAAM,eAAA,GAAkB,WAAW,W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AA,EAAmB;AACnB,MAAA,WAAA,CAAY,KAAK,EAAE,CAAA;AACnB,MAAA,WAAA,CAAY,KAAK,0BAA0B,CAAA;AAC3C,MAAA,WAAA,CAAY,IAAA,CAAK,CAAA,CAAA,EAAI,iBAAiB,CAAA,CAAA,CAAG,CAAA;AAAA,IAC7C;AAEA,IAAA,OAAO;AAAA,MACH,OAAA,EAAS,IAAA;AAAA,MACT,cAAA,EAAgB,IAAA;AAAA,MAChB,UAAA,EAAY,WAAA,CAAY,IAAA,CAAK,IAAI,CAAA;AAAA,MACjC,IAAA,EAAM;AAAA,QACF,KAAA,EAAO,KAAA;AAAA,QACP,iBAAA,EAAmB,YAAA;AAAA,QACnB,MAAM,IAAA,CAAK,IAAA;AAAA,QACX,OAAA,EAAS,CAAA,QAAA,EAAW,IAAA,CAAK,IAAI,CAAA,qCAAA,CAAA;AAAA,QAC7B,eAAe,WAAA,CAAY,MAAA,CAAO,CAAA,CAAA,KAAK,CAAA,CAAE,WAAW,KAAK,CAAA;AAAA,QACzD,OAAA,EAAS;AAAA;AACb,KACJ;AAAA,EACJ;AACJ,CAAA;;;;"}
@@ -0,0 +1,226 @@
1
+ function extractTermContext(transcript, term) {
2
+ const lowerTranscript = transcript.toLowerCase();
3
+ const lowerTerm = term.toLowerCase();
4
+ const index = lowerTranscript.indexOf(lowerTerm);
5
+ if (index === -1) {
6
+ return null;
7
+ }
8
+ const sentenceBoundary = /[.!?]/;
9
+ let startIndex = 0;
10
+ let boundariesFound = 0;
11
+ for (let i = index - 1; i >= 0; i--) {
12
+ if (sentenceBoundary.test(transcript[i])) {
13
+ boundariesFound++;
14
+ if (boundariesFound === 2) {
15
+ startIndex = i + 1;
16
+ break;
17
+ }
18
+ }
19
+ }
20
+ let endIndex = transcript.length;
21
+ boundariesFound = 0;
22
+ for (let i = index + term.length; i < transcript.length; i++) {
23
+ if (sentenceBoundary.test(transcript[i])) {
24
+ boundariesFound++;
25
+ if (boundariesFound === 2) {
26
+ endIndex = i + 1;
27
+ break;
28
+ }
29
+ }
30
+ }
31
+ let context = transcript.substring(startIndex, endIndex).trim();
32
+ if (context.length > 300) {
33
+ const midPoint = context.indexOf(term);
34
+ if (midPoint !== -1) {
35
+ let sentenceStart = midPoint;
36
+ let sentenceEnd = midPoint + term.length;
37
+ for (let i = midPoint - 1; i >= 0; i--) {
38
+ if (sentenceBoundary.test(context[i])) {
39
+ sentenceStart = i + 1;
40
+ break;
41
+ }
42
+ }
43
+ for (let i = midPoint + term.length; i < context.length; i++) {
44
+ if (sentenceBoundary.test(context[i])) {
45
+ sentenceEnd = i + 1;
46
+ break;
47
+ }
48
+ }
49
+ context = context.substring(sentenceStart, sentenceEnd).trim();
50
+ } else {
51
+ context = context.substring(0, 300) + "...";
52
+ }
53
+ }
54
+ return context;
55
+ }
56
+ const create = (ctx) => ({
57
+ name: "lookup_project",
58
+ description: "Look up project information for routing and context. Use when you need to determine where this note should be filed.",
59
+ parameters: {
60
+ type: "object",
61
+ properties: {
62
+ name: {
63
+ type: "string",
64
+ description: "The project name or identifier"
65
+ },
66
+ triggerPhrase: {
67
+ type: "string",
68
+ description: "A phrase from the transcript that might indicate the project"
69
+ }
70
+ },
71
+ required: ["name"]
72
+ },
73
+ execute: async (args) => {
74
+ const context = ctx.contextInstance;
75
+ if (ctx.resolvedEntities?.has(args.name)) {
76
+ const resolvedName = ctx.resolvedEntities.get(args.name);
77
+ return {
78
+ success: true,
79
+ data: {
80
+ found: true,
81
+ suggestion: `Already resolved: use "${resolvedName}"`,
82
+ cached: true
83
+ }
84
+ };
85
+ }
86
+ if (context.isIgnored(args.name)) {
87
+ return {
88
+ success: true,
89
+ data: {
90
+ found: false,
91
+ ignored: true,
92
+ message: `"${args.name}" is on the ignore list - skipping without prompting`
93
+ }
94
+ };
95
+ }
96
+ let contextProjectId;
97
+ if (ctx.routingInstance) {
98
+ const allProjects2 = context.getAllProjects();
99
+ const activeProject = allProjects2.find((p) => p.active !== false);
100
+ contextProjectId = activeProject?.id;
101
+ }
102
+ const searchResults = context.searchWithContext(args.name, contextProjectId);
103
+ const projectMatches = searchResults.filter((e) => e.type === "project");
104
+ const termMatches = searchResults.filter((e) => e.type === "term");
105
+ if (projectMatches.length > 0) {
106
+ const project = projectMatches[0];
107
+ return {
108
+ success: true,
109
+ data: {
110
+ found: true,
111
+ project,
112
+ matchedVia: "context_aware_search"
113
+ }
114
+ };
115
+ }
116
+ if (termMatches.length > 0) {
117
+ const term = termMatches[0];
118
+ const termProjects = term.projects || [];
119
+ if (termProjects.length > 0) {
120
+ const allProjects2 = context.getAllProjects();
121
+ const associatedProject = allProjects2.find((p) => p.id === termProjects[0]);
122
+ if (associatedProject) {
123
+ return {
124
+ success: true,
125
+ data: {
126
+ found: true,
127
+ project: associatedProject,
128
+ matchedVia: "term",
129
+ termName: term.name
130
+ }
131
+ };
132
+ }
133
+ }
134
+ }
135
+ const soundsLikeMatch = context.findBySoundsLike(args.name);
136
+ if (soundsLikeMatch) {
137
+ if (soundsLikeMatch.type === "project") {
138
+ return {
139
+ success: true,
140
+ data: {
141
+ found: true,
142
+ project: soundsLikeMatch,
143
+ matchedVia: "sounds_like"
144
+ }
145
+ };
146
+ } else if (soundsLikeMatch.type === "term") {
147
+ const termProjects = soundsLikeMatch.projects || [];
148
+ if (termProjects.length > 0) {
149
+ const allProjects2 = context.getAllProjects();
150
+ const associatedProject = allProjects2.find((p) => p.id === termProjects[0]);
151
+ if (associatedProject) {
152
+ return {
153
+ success: true,
154
+ data: {
155
+ found: true,
156
+ project: associatedProject,
157
+ matchedVia: "term_sounds_like",
158
+ termName: soundsLikeMatch.name
159
+ }
160
+ };
161
+ }
162
+ }
163
+ }
164
+ }
165
+ if (args.triggerPhrase) {
166
+ const allProjects2 = context.getAllProjects();
167
+ for (const project of allProjects2) {
168
+ const phrases = project.classification?.explicit_phrases ?? [];
169
+ if (phrases.some((p) => args.triggerPhrase?.toLowerCase().includes(p.toLowerCase()))) {
170
+ return {
171
+ success: true,
172
+ data: {
173
+ found: true,
174
+ project,
175
+ matchedTrigger: args.triggerPhrase
176
+ }
177
+ };
178
+ }
179
+ }
180
+ }
181
+ const allProjects = context.getAllProjects();
182
+ const projectOptions = allProjects.filter((p) => p.active !== false).map((p) => `${p.name}${p.description ? ` - ${p.description}` : ""}`);
183
+ const fileName = ctx.sourceFile.split("/").pop() || ctx.sourceFile;
184
+ const fileDate = ctx.audioDate.toLocaleString("en-US", {
185
+ weekday: "short",
186
+ year: "numeric",
187
+ month: "short",
188
+ day: "numeric",
189
+ hour: "2-digit",
190
+ minute: "2-digit"
191
+ });
192
+ const transcriptContext = extractTermContext(ctx.transcriptText, args.name);
193
+ const contextLines = [
194
+ `File: ${fileName}`,
195
+ `Date: ${fileDate}`,
196
+ "",
197
+ `Unknown project/term: "${args.name}"`
198
+ ];
199
+ if (transcriptContext) {
200
+ contextLines.push("");
201
+ contextLines.push("Context from transcript:");
202
+ contextLines.push(`"${transcriptContext}"`);
203
+ } else if (args.triggerPhrase) {
204
+ contextLines.push("");
205
+ contextLines.push("Context from transcript:");
206
+ contextLines.push(`"${args.triggerPhrase}"`);
207
+ }
208
+ return {
209
+ success: true,
210
+ needsUserInput: true,
211
+ userPrompt: contextLines.join("\n"),
212
+ data: {
213
+ found: false,
214
+ clarificationType: "new_project",
215
+ term: args.name,
216
+ triggerPhrase: args.triggerPhrase,
217
+ message: `Project "${args.name}" not found. Asking user if this is a new project.`,
218
+ knownProjects: allProjects.filter((p) => p.active !== false),
219
+ options: projectOptions
220
+ }
221
+ };
222
+ }
223
+ });
224
+
225
+ export { create };
226
+ //# sourceMappingURL=index43.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index43.js","sources":["../src/agentic/tools/lookup-project.ts"],"sourcesContent":["/**\n * Lookup Project Tool\n * \n * Looks up project information for routing and context.\n * Prompts to create unknown projects when user input is available.\n */\n\nimport { TranscriptionTool, ToolContext, ToolResult } from '../types';\n\n/**\n * Extract context from transcript around where a term is mentioned.\n * Returns approximately one sentence before and after the term mention.\n */\nfunction extractTermContext(transcript: string, term: string): string | null {\n // Case-insensitive search for the term\n const lowerTranscript = transcript.toLowerCase();\n const lowerTerm = term.toLowerCase();\n const index = lowerTranscript.indexOf(lowerTerm);\n \n if (index === -1) {\n return null;\n }\n \n // Define strong sentence boundaries (., !, ?)\n const sentenceBoundary = /[.!?]/;\n \n // Look backwards for the start (find the sentence boundary 1 sentence before)\n let startIndex = 0;\n let boundariesFound = 0;\n for (let i = index - 1; i >= 0; i--) {\n if (sentenceBoundary.test(transcript[i])) {\n boundariesFound++;\n // After finding first boundary (end of current sentence), \n // keep looking for the second (end of previous sentence)\n if (boundariesFound === 2) {\n // Start after this boundary\n startIndex = i + 1;\n break;\n }\n }\n }\n \n // Look forwards for the end (find sentence boundary 1 sentence after)\n let endIndex = transcript.length;\n boundariesFound = 0;\n for (let i = index + term.length; i < transcript.length; i++) {\n if (sentenceBoundary.test(transcript[i])) {\n boundariesFound++;\n // After finding first boundary (end of current sentence),\n // keep looking for the second (end of next sentence)\n if (boundariesFound === 2) {\n // Include this boundary\n endIndex = i + 1;\n break;\n }\n }\n }\n \n // Extract and clean up the context\n let context = transcript.substring(startIndex, endIndex).trim();\n \n // Limit length to avoid overwhelming the prompt (max ~300 chars)\n if (context.length > 300) {\n // Try to cut at a sentence boundary\n const midPoint = context.indexOf(term);\n if (midPoint !== -1) {\n // Keep the sentence with the term, trim around it\n let sentenceStart = midPoint;\n let sentenceEnd = midPoint + term.length;\n \n // Find sentence start\n for (let i = midPoint - 1; i >= 0; i--) {\n if (sentenceBoundary.test(context[i])) {\n sentenceStart = i + 1;\n break;\n }\n }\n \n // Find sentence end\n for (let i = midPoint + term.length; i < context.length; i++) {\n if (sentenceBoundary.test(context[i])) {\n sentenceEnd = i + 1;\n break;\n }\n }\n \n context = context.substring(sentenceStart, sentenceEnd).trim();\n } else {\n // Just truncate if term not found in extracted context\n context = context.substring(0, 300) + '...';\n }\n }\n \n return context;\n}\n\nexport const create = (ctx: ToolContext): TranscriptionTool => ({\n name: 'lookup_project',\n description: 'Look up project information for routing and context. Use when you need to determine where this note should be filed.',\n parameters: {\n type: 'object',\n properties: {\n name: {\n type: 'string',\n description: 'The project name or identifier',\n },\n triggerPhrase: {\n type: 'string',\n description: 'A phrase from the transcript that might indicate the project',\n },\n },\n required: ['name'],\n },\n execute: async (args: { name: string; triggerPhrase?: string }): Promise<ToolResult> => {\n const context = ctx.contextInstance;\n \n // First, check if this project/term was already resolved in this session\n if (ctx.resolvedEntities?.has(args.name)) {\n const resolvedName = ctx.resolvedEntities.get(args.name);\n return {\n success: true,\n data: {\n found: true,\n suggestion: `Already resolved: use \"${resolvedName}\"`,\n cached: true,\n },\n };\n }\n \n // Check if this term is on the ignore list\n if (context.isIgnored(args.name)) {\n return {\n success: true,\n data: {\n found: false,\n ignored: true,\n message: `\"${args.name}\" is on the ignore list - skipping without prompting`,\n },\n };\n }\n \n // Try to determine context from routing instance if available\n let contextProjectId: string | undefined;\n if (ctx.routingInstance) {\n const allProjects = context.getAllProjects();\n // Use the first active project as a context hint (could be improved)\n const activeProject = allProjects.find(p => p.active !== false);\n contextProjectId = activeProject?.id;\n }\n \n // Use context-aware search (prefers related projects)\n const searchResults = context.searchWithContext(args.name, contextProjectId);\n const projectMatches = searchResults.filter(e => e.type === 'project');\n const termMatches = searchResults.filter(e => e.type === 'term');\n \n if (projectMatches.length > 0) {\n const project = projectMatches[0];\n return {\n success: true,\n data: {\n found: true,\n project,\n matchedVia: 'context_aware_search',\n },\n };\n }\n \n // Check if we found a term that's associated with projects\n if (termMatches.length > 0) {\n const term = termMatches[0];\n const termProjects = term.projects || [];\n \n if (termProjects.length > 0) {\n // Get the first associated project\n const allProjects = context.getAllProjects();\n const associatedProject = allProjects.find(p => p.id === termProjects[0]);\n \n if (associatedProject) {\n return {\n success: true,\n data: {\n found: true,\n project: associatedProject,\n matchedVia: 'term',\n termName: term.name,\n },\n };\n }\n }\n }\n \n // Try findBySoundsLike as a fallback for exact phonetic matches\n const soundsLikeMatch = context.findBySoundsLike(args.name);\n if (soundsLikeMatch) {\n if (soundsLikeMatch.type === 'project') {\n return {\n success: true,\n data: {\n found: true,\n project: soundsLikeMatch,\n matchedVia: 'sounds_like',\n },\n };\n } else if (soundsLikeMatch.type === 'term') {\n const termProjects = soundsLikeMatch.projects || [];\n \n if (termProjects.length > 0) {\n const allProjects = context.getAllProjects();\n const associatedProject = allProjects.find(p => p.id === termProjects[0]);\n \n if (associatedProject) {\n return {\n success: true,\n data: {\n found: true,\n project: associatedProject,\n matchedVia: 'term_sounds_like',\n termName: soundsLikeMatch.name,\n },\n };\n }\n }\n }\n }\n \n // Try getting all projects and matching trigger phrases\n if (args.triggerPhrase) {\n const allProjects = context.getAllProjects();\n for (const project of allProjects) {\n const phrases = project.classification?.explicit_phrases ?? [];\n if (phrases.some(p => args.triggerPhrase?.toLowerCase().includes(p.toLowerCase()))) {\n return {\n success: true,\n data: {\n found: true,\n project,\n matchedTrigger: args.triggerPhrase,\n },\n };\n }\n }\n }\n \n // Project not found - always signal that we need user input\n // The executor will decide whether to actually prompt based on handler availability\n const allProjects = context.getAllProjects();\n const projectOptions = allProjects\n .filter(p => p.active !== false)\n .map(p => `${p.name}${p.description ? ` - ${p.description}` : ''}`);\n \n // Extract filename from sourceFile path for cleaner display\n const fileName = ctx.sourceFile.split('/').pop() || ctx.sourceFile;\n const fileDate = ctx.audioDate.toLocaleString('en-US', {\n weekday: 'short',\n year: 'numeric',\n month: 'short',\n day: 'numeric',\n hour: '2-digit',\n minute: '2-digit',\n });\n \n // Find context from transcript where the project/term is mentioned\n const transcriptContext = extractTermContext(ctx.transcriptText, args.name);\n \n const contextLines = [\n `File: ${fileName}`,\n `Date: ${fileDate}`,\n '',\n `Unknown project/term: \"${args.name}\"`,\n ];\n \n if (transcriptContext) {\n contextLines.push('');\n contextLines.push('Context from transcript:');\n contextLines.push(`\"${transcriptContext}\"`);\n } else if (args.triggerPhrase) {\n contextLines.push('');\n contextLines.push('Context from transcript:');\n contextLines.push(`\"${args.triggerPhrase}\"`);\n }\n \n return {\n success: true,\n needsUserInput: true,\n userPrompt: contextLines.join('\\n'),\n data: {\n found: false,\n clarificationType: 'new_project',\n term: args.name,\n triggerPhrase: args.triggerPhrase,\n message: `Project \"${args.name}\" not found. Asking user if this is a new project.`,\n knownProjects: allProjects.filter(p => p.active !== false),\n options: projectOptions,\n },\n };\n },\n});\n\n"],"names":["allProjects"],"mappings":"AAaA,SAAS,kBAAA,CAAmB,YAAoB,IAAA,EAA6B;AAEzE,EAAA,MAAM,eAAA,GAAkB,WAAW,WAAA,EAAY;AAC/C,EAAA,MAAM,SAAA,GAAY,KAAK,WAAA,EAAY;AACnC,EAAA,MAAM,KAAA,GAAQ,eAAA,CAAgB,OAAA,CAAQ,SAAS,CAAA;AAE/C,EAAA,IAAI,UAAU,EAAA,EAAI;AACd,IAAA,OAAO,IAAA;AAAA,EACX;AAGA,EAAA,MAAM,gBAAA,GAAmB,OAAA;AAGzB,EAAA,IAAI,UAAA,GAAa,CAAA;AACjB,EAAA,IAAI,eAAA,GAAkB,CAAA;AACtB,EAAA,KAAA,IAAS,CAAA,GAAI,KAAA,GAAQ,CAAA,EAAG,CAAA,IAAK,GAAG,CAAA,EAAA,EAAK;AACjC,IAAA,IAAI,gBAAA,CAAiB,IAAA,CAAK,UAAA,CAAW,CAAC,CAAC,CAAA,EAAG;AACtC,MAAA,eAAA,EAAA;AAGA,MAAA,IAAI,oBAAoB,CAAA,EAAG;AAEvB,QAAA,UAAA,GAAa,CAAA,GAAI,CAAA;AACjB,QAAA;AAAA,MACJ;AAAA,IACJ;AAAA,EACJ;AAGA,EAAA,IAAI,WAAW,UAAA,CAAW,MAAA;AAC1B,EAAA,eAAA,GAAkB,CAAA;AAClB,EAAA,KAAA,IAAS,IAAI,KAAA,GAAQ,IAAA,CAAK,QAAQ,CAAA,GAAI,UAAA,CAAW,QAAQ,CAAA,EAAA,EAAK;AAC1D,IAAA,IAAI,gBAAA,CAAiB,IAAA,CAAK,UAAA,C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,OAAA,EAAS;AAAA;AACb,KACJ;AAAA,EACJ;AACJ,CAAA;;;;"}
@@ -0,0 +1,49 @@
1
+ const create = (ctx) => ({
2
+ name: "verify_spelling",
3
+ description: "Request user verification for an unknown name or term. Use when you encounter something that needs human confirmation.",
4
+ parameters: {
5
+ type: "object",
6
+ properties: {
7
+ term: {
8
+ type: "string",
9
+ description: "The term that needs verification"
10
+ },
11
+ context: {
12
+ type: "string",
13
+ description: "Context around where this term appears"
14
+ },
15
+ suggestedSpelling: {
16
+ type: "string",
17
+ description: "Your best guess at the correct spelling"
18
+ }
19
+ },
20
+ required: ["term"]
21
+ },
22
+ execute: async (args) => {
23
+ if (!ctx.interactiveMode) {
24
+ return {
25
+ success: true,
26
+ data: {
27
+ verified: false,
28
+ useSuggestion: true,
29
+ spelling: args.suggestedSpelling || args.term,
30
+ message: "Non-interactive mode: using best guess"
31
+ }
32
+ };
33
+ }
34
+ return {
35
+ success: true,
36
+ needsUserInput: true,
37
+ userPrompt: `Unknown term: "${args.term}"${args.context ? ` (context: "${args.context}")` : ""}
38
+ ${args.suggestedSpelling ? `Suggested spelling: "${args.suggestedSpelling}"` : ""}
39
+ Please provide the correct spelling:`,
40
+ data: {
41
+ term: args.term,
42
+ suggestedSpelling: args.suggestedSpelling
43
+ }
44
+ };
45
+ }
46
+ });
47
+
48
+ export { create };
49
+ //# sourceMappingURL=index44.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index44.js","sources":["../src/agentic/tools/verify-spelling.ts"],"sourcesContent":["/**\n * Verify Spelling Tool\n * \n * Requests user verification for an unknown name or term.\n */\n\nimport { TranscriptionTool, ToolContext, ToolResult } from '../types';\n\nexport const create = (ctx: ToolContext): TranscriptionTool => ({\n name: 'verify_spelling',\n description: 'Request user verification for an unknown name or term. Use when you encounter something that needs human confirmation.',\n parameters: {\n type: 'object',\n properties: {\n term: {\n type: 'string',\n description: 'The term that needs verification',\n },\n context: {\n type: 'string',\n description: 'Context around where this term appears',\n },\n suggestedSpelling: {\n type: 'string',\n description: 'Your best guess at the correct spelling',\n },\n },\n required: ['term'],\n },\n execute: async (args: { term: string; context?: string; suggestedSpelling?: string }): Promise<ToolResult> => {\n if (!ctx.interactiveMode) {\n // In batch mode, return best guess\n return {\n success: true,\n data: {\n verified: false,\n useSuggestion: true,\n spelling: args.suggestedSpelling || args.term,\n message: 'Non-interactive mode: using best guess',\n },\n };\n }\n \n // In interactive mode, mark for user input\n return {\n success: true,\n needsUserInput: true,\n userPrompt: `Unknown term: \"${args.term}\"${args.context ? ` (context: \"${args.context}\")` : ''}\n${args.suggestedSpelling ? `Suggested spelling: \"${args.suggestedSpelling}\"` : ''}\nPlease provide the correct spelling:`,\n data: {\n term: args.term,\n suggestedSpelling: args.suggestedSpelling,\n },\n };\n },\n});\n\n"],"names":[],"mappings":"AAQO,MAAM,MAAA,GAAS,CAAC,GAAA,MAAyC;AAAA,EAC5D,IAAA,EAAM,iBAAA;AAAA,EACN,WAAA,EAAa,wHAAA;AAAA,EACb,UAAA,EAAY;AAAA,IACR,IAAA,EAAM,QAAA;AAAA,IACN,UAAA,EAAY;AAAA,MACR,IAAA,EAAM;AAAA,QACF,IAAA,EAAM,QAAA;AAAA,QACN,WAAA,EAAa;AAAA,OACjB;AAAA,MACA,OAAA,EAAS;AAAA,QACL,IAAA,EAAM,QAAA;AAAA,QACN,WAAA,EAAa;AAAA,OACjB;AAAA,MACA,iBAAA,EAAmB;AAAA,QACf,IAAA,EAAM,QAAA;AAAA,QACN,WAAA,EAAa;AAAA;AACjB,KACJ;AAAA,IACA,QAAA,EAAU,CAAC,MAAM;AAAA,GACrB;AAAA,EACA,OAAA,EAAS,OAAO,IAAA,KAA8F;AAC1G,IAAA,IAAI,CAAC,IAAI,eAAA,EAAiB;AAEtB,MAAA,OAAO;AAAA,QACH,OAAA,EAAS,IAAA;AAAA,QACT,IAAA,EAAM;AAAA,UACF,QAAA,EAAU,KAAA;AAAA,UACV,aAAA,EAAe,IAAA;AAAA,UACf,QAAA,EAAU,IAAA,CAAK,iBAAA,IAAqB,IAAA,CAAK,IAAA;AAAA,UACzC,OAAA,EAAS;AAAA;AACb,OACJ;AAAA,IACJ;AAGA,IAAA,OAAO;AAAA,MACH,OAAA,EAAS,IAAA;AAAA,MACT,cAAA,EAAgB,IAAA;AAAA,MAChB,UAAA,EAAY,CAAA,eAAA,EAAkB,IAAA,CAAK,IAAI,CAAA,CAAA,EAAI,IAAA,CAAK,OAAA,GAAU,CAAA,YAAA,EAAe,IAAA,CAAK,OAAO,CAAA,EAAA,CAAA,GAAO,EAAE;AAAA,EACxG,KAAK,iBAAA,GAAoB,CAAA,qBAAA,EAAwB,IAAA,CAAK,iBAAiB,MAAM,EAAE;AAAA,oCAAA,CAAA;AAAA,MAErE,IAAA,EAAM;AAAA,QACF,MAAM,IAAA,CAAK,IAAA;AAAA,QACX,mBAAmB,IAAA,CAAK;AAAA;AAC5B,KACJ;AAAA,EACJ;AACJ,CAAA;;;;"}
@@ -0,0 +1,45 @@
1
+ const create = (ctx) => ({
2
+ name: "route_note",
3
+ description: "Determine the destination for this note based on content analysis.",
4
+ parameters: {
5
+ type: "object",
6
+ properties: {
7
+ projectHint: {
8
+ type: "string",
9
+ description: "The detected project name or hint"
10
+ },
11
+ contentSummary: {
12
+ type: "string",
13
+ description: "Brief summary of what the note is about"
14
+ }
15
+ }
16
+ },
17
+ execute: async (args) => {
18
+ const routing = ctx.routingInstance;
19
+ const routingContext = {
20
+ transcriptText: ctx.transcriptText,
21
+ audioDate: ctx.audioDate,
22
+ sourceFile: ctx.sourceFile
23
+ };
24
+ const decision = routing.route(routingContext);
25
+ const outputPath = routing.buildOutputPath(decision, routingContext);
26
+ return {
27
+ success: true,
28
+ data: {
29
+ projectId: decision.projectId,
30
+ // Return the routing decision (base path + structure), NOT the built output path
31
+ // The orchestrator will call buildOutputPath() later
32
+ routingDecision: decision,
33
+ // Also include the built path for informational purposes
34
+ outputPath,
35
+ confidence: decision.confidence,
36
+ reasoning: decision.reasoning,
37
+ projectHint: args.projectHint,
38
+ contentSummary: args.contentSummary
39
+ }
40
+ };
41
+ }
42
+ });
43
+
44
+ export { create };
45
+ //# sourceMappingURL=index45.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index45.js","sources":["../src/agentic/tools/route-note.ts"],"sourcesContent":["/**\n * Route Note Tool\n * \n * Determines the destination for a note based on content analysis.\n */\n\nimport { TranscriptionTool, ToolContext, ToolResult } from '../types';\n\nexport const create = (ctx: ToolContext): TranscriptionTool => ({\n name: 'route_note',\n description: 'Determine the destination for this note based on content analysis.',\n parameters: {\n type: 'object',\n properties: {\n projectHint: {\n type: 'string',\n description: 'The detected project name or hint',\n },\n contentSummary: {\n type: 'string',\n description: 'Brief summary of what the note is about',\n },\n },\n },\n execute: async (args: { projectHint?: string; contentSummary?: string }): Promise<ToolResult> => {\n const routing = ctx.routingInstance;\n \n const routingContext = {\n transcriptText: ctx.transcriptText,\n audioDate: ctx.audioDate,\n sourceFile: ctx.sourceFile,\n };\n \n const decision = routing.route(routingContext);\n const outputPath = routing.buildOutputPath(decision, routingContext);\n \n return {\n success: true,\n data: {\n projectId: decision.projectId,\n // Return the routing decision (base path + structure), NOT the built output path\n // The orchestrator will call buildOutputPath() later\n routingDecision: decision,\n // Also include the built path for informational purposes\n outputPath: outputPath,\n confidence: decision.confidence,\n reasoning: decision.reasoning,\n projectHint: args.projectHint,\n contentSummary: args.contentSummary,\n },\n };\n },\n});\n\n"],"names":[],"mappings":"AAQO,MAAM,MAAA,GAAS,CAAC,GAAA,MAAyC;AAAA,EAC5D,IAAA,EAAM,YAAA;AAAA,EACN,WAAA,EAAa,oEAAA;AAAA,EACb,UAAA,EAAY;AAAA,IACR,IAAA,EAAM,QAAA;AAAA,IACN,UAAA,EAAY;AAAA,MACR,WAAA,EAAa;AAAA,QACT,IAAA,EAAM,QAAA;AAAA,QACN,WAAA,EAAa;AAAA,OACjB;AAAA,MACA,cAAA,EAAgB;AAAA,QACZ,IAAA,EAAM,QAAA;AAAA,QACN,WAAA,EAAa;AAAA;AACjB;AACJ,GACJ;AAAA,EACA,OAAA,EAAS,OAAO,IAAA,KAAiF;AAC7F,IAAA,MAAM,UAAU,GAAA,CAAI,eAAA;AAEpB,IAAA,MAAM,cAAA,GAAiB;AAAA,MACnB,gBAAgB,GAAA,CAAI,cAAA;AAAA,MACpB,WAAW,GAAA,CAAI,SAAA;AAAA,MACf,YAAY,GAAA,CAAI;AAAA,KACpB;AAEA,IAAA,MAAM,QAAA,GAAW,OAAA,CAAQ,KAAA,CAAM,cAAc,CAAA;AAC7C,IAAA,MAAM,UAAA,GAAa,OAAA,CAAQ,eAAA,CAAgB,QAAA,EAAU,cAAc,CAAA;AAEnE,IAAA,OAAO;AAAA,MACH,OAAA,EAAS,IAAA;AAAA,MACT,IAAA,EAAM;AAAA,QACF,WAAW,QAAA,CAAS,SAAA;AAAA;AAAA;AAAA,QAGpB,eAAA,EAAiB,QAAA;AAAA;AAAA,QAEjB,UAAA;AAAA,QACA,YAAY,QAAA,CAAS,UAAA;AAAA,QACrB,WAAW,QAAA,CAAS,SAAA;AAAA,QACpB,aAAa,IAAA,CAAK,WAAA;AAAA,QAClB,gBAAgB,IAAA,CAAK;AAAA;AACzB,KACJ;AAAA,EACJ;AACJ,CAAA;;;;"}
@@ -0,0 +1,37 @@
1
+ const create = (_ctx) => ({
2
+ name: "store_context",
3
+ description: "Store new context information for future use. Use when you learn something new that should be remembered.",
4
+ parameters: {
5
+ type: "object",
6
+ properties: {
7
+ entityType: {
8
+ type: "string",
9
+ enum: ["person", "project", "company", "term"],
10
+ description: "Type of entity to store"
11
+ },
12
+ name: {
13
+ type: "string",
14
+ description: "Name of the entity"
15
+ },
16
+ details: {
17
+ type: "object",
18
+ description: "Additional details about the entity"
19
+ }
20
+ },
21
+ required: ["entityType", "name"]
22
+ },
23
+ execute: async (args) => {
24
+ return {
25
+ success: true,
26
+ data: {
27
+ stored: false,
28
+ message: "Context storage requires --self-update flag. Information noted but not persisted.",
29
+ entityType: args.entityType,
30
+ name: args.name
31
+ }
32
+ };
33
+ }
34
+ });
35
+
36
+ export { create };
37
+ //# sourceMappingURL=index46.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index46.js","sources":["../src/agentic/tools/store-context.ts"],"sourcesContent":["/**\n * Store Context Tool\n * \n * Stores new context information for future use.\n */\n\nimport { TranscriptionTool, ToolContext, ToolResult } from '../types';\n\nexport const create = (_ctx: ToolContext): TranscriptionTool => ({\n name: 'store_context',\n description: 'Store new context information for future use. Use when you learn something new that should be remembered.',\n parameters: {\n type: 'object',\n properties: {\n entityType: {\n type: 'string',\n enum: ['person', 'project', 'company', 'term'],\n description: 'Type of entity to store',\n },\n name: {\n type: 'string',\n description: 'Name of the entity',\n },\n details: {\n type: 'object',\n description: 'Additional details about the entity',\n },\n },\n required: ['entityType', 'name'],\n },\n \n execute: async (args: { entityType: string; name: string; details?: any }): Promise<ToolResult> => {\n // This tool requires --self-update flag to actually persist\n // Otherwise it just acknowledges without saving\n \n return {\n success: true,\n data: {\n stored: false,\n message: 'Context storage requires --self-update flag. Information noted but not persisted.',\n entityType: args.entityType,\n name: args.name,\n },\n };\n },\n});\n\n"],"names":[],"mappings":"AAQO,MAAM,MAAA,GAAS,CAAC,IAAA,MAA0C;AAAA,EAC7D,IAAA,EAAM,eAAA;AAAA,EACN,WAAA,EAAa,2GAAA;AAAA,EACb,UAAA,EAAY;AAAA,IACR,IAAA,EAAM,QAAA;AAAA,IACN,UAAA,EAAY;AAAA,MACR,UAAA,EAAY;AAAA,QACR,IAAA,EAAM,QAAA;AAAA,QACN,IAAA,EAAM,CAAC,QAAA,EAAU,SAAA,EAAW,WAAW,MAAM,CAAA;AAAA,QAC7C,WAAA,EAAa;AAAA,OACjB;AAAA,MACA,IAAA,EAAM;AAAA,QACF,IAAA,EAAM,QAAA;AAAA,QACN,WAAA,EAAa;AAAA,OACjB;AAAA,MACA,OAAA,EAAS;AAAA,QACL,IAAA,EAAM,QAAA;AAAA,QACN,WAAA,EAAa;AAAA;AACjB,KACJ;AAAA,IACA,QAAA,EAAU,CAAC,YAAA,EAAc,MAAM;AAAA,GACnC;AAAA,EAEA,OAAA,EAAS,OAAO,IAAA,KAAmF;AAI/F,IAAA,OAAO;AAAA,MACH,OAAA,EAAS,IAAA;AAAA,MACT,IAAA,EAAM;AAAA,QACF,MAAA,EAAQ,KAAA;AAAA,QACR,OAAA,EAAS,mFAAA;AAAA,QACT,YAAY,IAAA,CAAK,UAAA;AAAA,QACjB,MAAM,IAAA,CAAK;AAAA;AACf,KACJ;AAAA,EACJ;AACJ,CAAA;;;;"}
@@ -0,0 +1,51 @@
1
+ import { OpenAI } from 'openai';
2
+ import { create } from './index12.js';
3
+ import { getLogger } from './index41.js';
4
+ import { DEFAULT_TRANSCRIPTION_MODEL } from './index16.js';
5
+
6
+ class OpenAIError extends Error {
7
+ constructor(message) {
8
+ super(message);
9
+ this.name = "OpenAIError";
10
+ }
11
+ }
12
+ async function transcribeAudio(filePath, options = {}) {
13
+ const logger = getLogger();
14
+ const storage$1 = create({ log: logger.debug });
15
+ try {
16
+ const apiKey = process.env.OPENAI_API_KEY;
17
+ if (!apiKey) {
18
+ throw new OpenAIError("OPENAI_API_KEY environment variable is not set");
19
+ }
20
+ const openai = new OpenAI({
21
+ apiKey
22
+ });
23
+ const model = options.model || DEFAULT_TRANSCRIPTION_MODEL;
24
+ const fileName = filePath.split("/").pop() || filePath;
25
+ logger.debug("Transcribing: %s (full path: %s)", fileName, filePath);
26
+ const startTime = Date.now();
27
+ const audioStream = await storage$1.readStream(filePath);
28
+ const transcription = await openai.audio.transcriptions.create({
29
+ model,
30
+ file: audioStream,
31
+ response_format: "json"
32
+ });
33
+ if (!transcription) {
34
+ throw new OpenAIError("No transcription received from OpenAI");
35
+ }
36
+ const duration = ((Date.now() - startTime) / 1e3).toFixed(1);
37
+ logger.info("%s (%ss, %d chars)", model, duration, transcription.text?.length || 0);
38
+ if (options.debug && options.debugFile) {
39
+ await storage$1.writeFile(options.debugFile, JSON.stringify(transcription, null, 2), "utf8");
40
+ logger.debug("Wrote debug file to %s", options.debugFile);
41
+ }
42
+ logger.debug("Received transcription from OpenAI: %s", transcription);
43
+ return transcription;
44
+ } catch (error) {
45
+ logger.error("Error transcribing audio file: %s %s", error.message, error.stack);
46
+ throw new OpenAIError(`Failed to transcribe audio: ${error.message}`);
47
+ }
48
+ }
49
+
50
+ export { OpenAIError, transcribeAudio };
51
+ //# sourceMappingURL=index47.js.map