@redaksjon/protokoll-engine 0.1.15 → 0.1.16-dev.20260316055955.5771fbb
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agentic/executor.d.ts.map +1 -1
- package/dist/index19.js +22 -2
- package/dist/index19.js.map +1 -1
- package/dist/index22.js +1 -1
- package/dist/index26.js +3 -2
- package/dist/index26.js.map +1 -1
- package/dist/index27.js +5 -5
- package/dist/index31.js +1 -1
- package/dist/index32.js +1 -1
- package/dist/index33.js +2 -2
- package/dist/index34.js +3 -3
- package/dist/index35.js +5 -5
- package/dist/index36.js +2 -2
- package/dist/index37.js +1 -1
- package/dist/index39.js +1 -1
- package/dist/index42.js +1 -1
- package/dist/index43.js +1 -1
- package/dist/index47.js +4 -45
- package/dist/index47.js.map +1 -1
- package/dist/index48.js +45 -47
- package/dist/index48.js.map +1 -1
- package/dist/index49.js +46 -34
- package/dist/index49.js.map +1 -1
- package/dist/index50.js +35 -280
- package/dist/index50.js.map +1 -1
- package/dist/index51.js +259 -138
- package/dist/index51.js.map +1 -1
- package/dist/index52.js +143 -61
- package/dist/index52.js.map +1 -1
- package/dist/index53.js +73 -70
- package/dist/index53.js.map +1 -1
- package/dist/index54.js +72 -145
- package/dist/index54.js.map +1 -1
- package/dist/index55.js +31 -106
- package/dist/index55.js.map +1 -1
- package/dist/index56.js +198 -21
- package/dist/index56.js.map +1 -1
- package/dist/index57.js +29 -25
- package/dist/index57.js.map +1 -1
- package/dist/index58.js +26 -18
- package/dist/index58.js.map +1 -1
- package/dist/index59.js +34 -5
- package/dist/index59.js.map +1 -1
- package/dist/index60.js +148 -5
- package/dist/index60.js.map +1 -1
- package/dist/index61.js +4 -4
- package/dist/index62.js +5 -148
- package/dist/index62.js.map +1 -1
- package/dist/reasoning/client.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index54.js
CHANGED
|
@@ -1,151 +1,78 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
};
|
|
1
|
+
import dayjs from 'dayjs';
|
|
2
|
+
import timezone from './index61.js';
|
|
3
|
+
import utc from './index62.js';
|
|
4
|
+
import 'moment-timezone';
|
|
5
|
+
|
|
6
|
+
dayjs.extend(utc);
|
|
7
|
+
dayjs.extend(timezone);
|
|
8
|
+
const create = (parameters) => {
|
|
9
|
+
const { timezone: timezone2 } = parameters;
|
|
10
|
+
const now = () => {
|
|
11
|
+
return date(void 0);
|
|
12
|
+
};
|
|
13
|
+
const date = (date2) => {
|
|
14
|
+
let value;
|
|
15
|
+
try {
|
|
16
|
+
if (date2) {
|
|
17
|
+
value = dayjs.tz(date2, timezone2);
|
|
18
|
+
} else {
|
|
19
|
+
value = dayjs().tz(timezone2);
|
|
109
20
|
}
|
|
21
|
+
} catch (error) {
|
|
22
|
+
throw new Error(`Invalid date: ${date2}, error: ${error.message}`);
|
|
110
23
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
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}"`);
|
|
24
|
+
return value.toDate();
|
|
25
|
+
};
|
|
26
|
+
const parse = (date2, format2) => {
|
|
27
|
+
let value;
|
|
28
|
+
try {
|
|
29
|
+
value = dayjs.tz(date2, format2, timezone2);
|
|
30
|
+
} catch (error) {
|
|
31
|
+
throw new Error(`Invalid date: ${date2}, expected format: ${format2}, error: ${error.message}`);
|
|
133
32
|
}
|
|
134
|
-
return
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}
|
|
148
|
-
|
|
33
|
+
return value.toDate();
|
|
34
|
+
};
|
|
35
|
+
const addDays = (date2, days) => {
|
|
36
|
+
return dayjs.tz(date2, timezone2).add(days, "day").toDate();
|
|
37
|
+
};
|
|
38
|
+
const addMonths = (date2, months) => {
|
|
39
|
+
return dayjs.tz(date2, timezone2).add(months, "month").toDate();
|
|
40
|
+
};
|
|
41
|
+
const addYears = (date2, years) => {
|
|
42
|
+
return dayjs.tz(date2, timezone2).add(years, "year").toDate();
|
|
43
|
+
};
|
|
44
|
+
const format = (date2, format2) => {
|
|
45
|
+
return dayjs.tz(date2, timezone2).format(format2);
|
|
46
|
+
};
|
|
47
|
+
const subDays = (date2, days) => {
|
|
48
|
+
return dayjs.tz(date2, timezone2).subtract(days, "day").toDate();
|
|
49
|
+
};
|
|
50
|
+
const subMonths = (date2, months) => {
|
|
51
|
+
return dayjs.tz(date2, timezone2).subtract(months, "month").toDate();
|
|
52
|
+
};
|
|
53
|
+
const subYears = (date2, years) => {
|
|
54
|
+
return dayjs.tz(date2, timezone2).subtract(years, "year").toDate();
|
|
55
|
+
};
|
|
56
|
+
const startOfMonth = (date2) => {
|
|
57
|
+
return dayjs.tz(date2, timezone2).startOf("month").toDate();
|
|
58
|
+
};
|
|
59
|
+
const endOfMonth = (date2) => {
|
|
60
|
+
return dayjs.tz(date2, timezone2).endOf("month").toDate();
|
|
61
|
+
};
|
|
62
|
+
const startOfYear = (date2) => {
|
|
63
|
+
return dayjs.tz(date2, timezone2).startOf("year").toDate();
|
|
64
|
+
};
|
|
65
|
+
const endOfYear = (date2) => {
|
|
66
|
+
return dayjs.tz(date2, timezone2).endOf("year").toDate();
|
|
67
|
+
};
|
|
68
|
+
const isBefore = (date2, other) => {
|
|
69
|
+
return dayjs.tz(date2, timezone2).isBefore(dayjs.tz(other, timezone2));
|
|
70
|
+
};
|
|
71
|
+
const isAfter = (date2, other) => {
|
|
72
|
+
return dayjs.tz(date2, timezone2).isAfter(dayjs.tz(other, timezone2));
|
|
73
|
+
};
|
|
74
|
+
return { now, date, parse, addDays, addMonths, addYears, format, subDays, subMonths, subYears, startOfMonth, endOfMonth, startOfYear, endOfYear, isBefore, isAfter };
|
|
75
|
+
};
|
|
149
76
|
|
|
150
77
|
export { create };
|
|
151
78
|
//# sourceMappingURL=index54.js.map
|
package/dist/index54.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index54.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,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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AA,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;;;;"}
|
|
1
|
+
{"version":3,"file":"index54.js","sources":["../src/util/dates.ts"],"sourcesContent":["// eslint-disable-next-line no-restricted-imports\nimport dayjs from 'dayjs';\nimport timezone from 'dayjs/plugin/timezone';\nimport utc from 'dayjs/plugin/utc';\n// eslint-disable-next-line no-restricted-imports\nimport moment from 'moment-timezone';\n\ndayjs.extend(utc);\ndayjs.extend(timezone);\n\n/**\n * Yes, wrapping dayjs is a bit annoying and might seem overly paranoid. However, I feel strongly\n * about not letting Dayjs instances leak into the rest of the codebase. Having Dayjs objects\n * floating around the application leads to inconsistent timezone handling, makes testing more\n * difficult, and creates subtle bugs that are hard to track down.\n * \n * By wrapping dayjs completely and only exposing plain JavaScript Date objects, we get several\n * key benefits:\n * 1. Consistent timezone handling through a single configuration point\n * 2. Simpler testing since we only need to mock this one library\n * 3. Type safety - the rest of the codebase only deals with standard Date objects\n * 4. No risk of dayjs method chains creating unexpected timezone shifts\n * \n * The Library interface gives us full control over all date operations while keeping the messy\n * details of timezone manipulation contained in one place. Yes it's more code, but the peace of\n * mind is worth it.\n */\nexport interface Utility {\n now: () => Date;\n date: (date: string | number | Date | null | undefined) => Date;\n parse: (date: string | number | Date | null | undefined, format: string) => Date;\n addDays: (date: Date, days: number) => Date;\n addMonths: (date: Date, months: number) => Date;\n addYears: (date: Date, years: number) => Date;\n format: (date: Date, format: string) => string;\n subDays: (date: Date, days: number) => Date;\n subMonths: (date: Date, months: number) => Date;\n subYears: (date: Date, years: number) => Date;\n startOfMonth: (date: Date) => Date;\n endOfMonth: (date: Date) => Date;\n startOfYear: (date: Date) => Date;\n endOfYear: (date: Date) => Date;\n isBefore: (date: Date, other: Date) => boolean;\n isAfter: (date: Date, other: Date) => boolean;\n}\n\nexport const create = (parameters: { timezone: string }) => {\n const { timezone } = parameters;\n const now = () => {\n return date(undefined);\n }\n\n const date = (date: string | number | Date | null | undefined) => {\n let value: dayjs.Dayjs;\n try {\n if (date) {\n value = dayjs.tz(date, timezone);\n } else {\n value = dayjs().tz(timezone);\n }\n } catch (error: any) {\n throw new Error(`Invalid date: ${date}, error: ${error.message}`);\n }\n\n return value.toDate();\n }\n\n const parse = (date: string | number | Date | null | undefined, format: string) => {\n let value: dayjs.Dayjs;\n try {\n value = dayjs.tz(date, format, timezone);\n } catch (error: any) {\n throw new Error(`Invalid date: ${date}, expected format: ${format}, error: ${error.message}`);\n }\n\n return value.toDate();\n }\n\n const addDays = (date: Date, days: number) => {\n return dayjs.tz(date, timezone).add(days, 'day').toDate();\n }\n\n const addMonths = (date: Date, months: number) => {\n return dayjs.tz(date, timezone).add(months, 'month').toDate();\n }\n\n const addYears = (date: Date, years: number) => {\n return dayjs.tz(date, timezone).add(years, 'year').toDate();\n }\n\n const format = (date: Date, format: string) => {\n return dayjs.tz(date, timezone).format(format);\n }\n\n const subDays = (date: Date, days: number) => {\n return dayjs.tz(date, timezone).subtract(days, 'day').toDate();\n }\n\n const subMonths = (date: Date, months: number) => {\n return dayjs.tz(date, timezone).subtract(months, 'month').toDate();\n }\n\n const subYears = (date: Date, years: number) => {\n return dayjs.tz(date, timezone).subtract(years, 'year').toDate();\n }\n\n const startOfMonth = (date: Date) => {\n return dayjs.tz(date, timezone).startOf('month').toDate();\n }\n\n const endOfMonth = (date: Date) => {\n return dayjs.tz(date, timezone).endOf('month').toDate();\n }\n\n const startOfYear = (date: Date) => {\n return dayjs.tz(date, timezone).startOf('year').toDate();\n }\n\n const endOfYear = (date: Date) => {\n return dayjs.tz(date, timezone).endOf('year').toDate();\n }\n\n const isBefore = (date: Date, other: Date) => {\n return dayjs.tz(date, timezone).isBefore(dayjs.tz(other, timezone));\n }\n\n const isAfter = (date: Date, other: Date) => {\n return dayjs.tz(date, timezone).isAfter(dayjs.tz(other, timezone));\n }\n\n return { now, date, parse, addDays, addMonths, addYears, format, subDays, subMonths, subYears, startOfMonth, endOfMonth, startOfYear, endOfYear, isBefore, isAfter };\n}\n\nexport const validTimezones = () => {\n return moment.tz.names();\n}\n"],"names":["timezone","date","format"],"mappings":";;;;;AAOA,KAAA,CAAM,OAAO,GAAG,CAAA;AAChB,KAAA,CAAM,OAAO,QAAQ,CAAA;AAsCd,MAAM,MAAA,GAAS,CAAC,UAAA,KAAqC;AACxD,EAAA,MAAM,EAAE,QAAA,EAAAA,SAAAA,EAAS,GAAI,UAAA;AACrB,EAAA,MAAM,MAAM,MAAM;AACd,IAAA,OAAO,KAAK,MAAS,CAAA;AAAA,EACzB,CAAA;AAEA,EAAA,MAAM,IAAA,GAAO,CAACC,KAAAA,KAAoD;AAC9D,IAAA,IAAI,KAAA;AACJ,IAAA,IAAI;AACA,MAAA,IAAIA,KAAAA,EAAM;AACN,QAAA,KAAA,GAAQ,KAAA,CAAM,EAAA,CAAGA,KAAAA,EAAMD,SAAQ,CAAA;AAAA,MACnC,CAAA,MAAO;AACH,QAAA,KAAA,GAAQ,KAAA,EAAM,CAAE,EAAA,CAAGA,SAAQ,CAAA;AAAA,MAC/B;AAAA,IACJ,SAAS,KAAA,EAAY;AACjB,MAAA,MAAM,IAAI,KAAA,CAAM,CAAA,cAAA,EAAiBC,KAAI,CAAA,SAAA,EAAY,KAAA,CAAM,OAAO,CAAA,CAAE,CAAA;AAAA,IACpE;AAEA,IAAA,OAAO,MAAM,MAAA,EAAO;AAAA,EACxB,CAAA;AAEA,EAAA,MAAM,KAAA,GAAQ,CAACA,KAAAA,EAAiDC,OAAAA,KAAmB;AAC/E,IAAA,IAAI,KAAA;AACJ,IAAA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,OAAO,KAAA,CAAM,EAAA,CAAGA,KAAAA,EAAMD,SAAQ,CAAA,CAAE,SAAS,KAAA,CAAM,EAAA,CAAG,KAAA,EAAOA,SAAQ,CAAC,CAAA;AAAA,EACtE,CAAA;AAEA,EAAA,MAAM,OAAA,GAAU,CAACC,KAAAA,EAAY,KAAA,KAAgB;AACzC,IAAA,OAAO,KAAA,CAAM,EAAA,CAAGA,KAAAA,EAAMD,SAAQ,CAAA,CAAE,QAAQ,KAAA,CAAM,EAAA,CAAG,KAAA,EAAOA,SAAQ,CAAC,CAAA;AAAA,EACrE,CAAA;AAEA,EAAA,OAAO,EAAE,GAAA,EAAK,IAAA,EAAM,KAAA,EAAO,OAAA,EAAS,WAAW,QAAA,EAAU,MAAA,EAAQ,OAAA,EAAS,SAAA,EAAW,UAAU,YAAA,EAAc,UAAA,EAAY,WAAA,EAAa,SAAA,EAAW,UAAU,OAAA,EAAQ;AACvK;;;;"}
|
package/dist/index55.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
function
|
|
1
|
+
function extractNameContext(transcript, name) {
|
|
2
2
|
const lowerTranscript = transcript.toLowerCase();
|
|
3
|
-
const
|
|
4
|
-
const index = lowerTranscript.indexOf(
|
|
3
|
+
const lowerName = name.toLowerCase();
|
|
4
|
+
const index = lowerTranscript.indexOf(lowerName);
|
|
5
5
|
if (index === -1) {
|
|
6
6
|
return null;
|
|
7
7
|
}
|
|
@@ -19,7 +19,7 @@ function extractTermContext(transcript, term) {
|
|
|
19
19
|
}
|
|
20
20
|
let endIndex = transcript.length;
|
|
21
21
|
boundariesFound = 0;
|
|
22
|
-
for (let i = index +
|
|
22
|
+
for (let i = index + name.length; i < transcript.length; i++) {
|
|
23
23
|
if (sentenceBoundary.test(transcript[i])) {
|
|
24
24
|
boundariesFound++;
|
|
25
25
|
if (boundariesFound === 2) {
|
|
@@ -30,17 +30,17 @@ function extractTermContext(transcript, term) {
|
|
|
30
30
|
}
|
|
31
31
|
let context = transcript.substring(startIndex, endIndex).trim();
|
|
32
32
|
if (context.length > 300) {
|
|
33
|
-
const midPoint = context.indexOf(
|
|
33
|
+
const midPoint = context.indexOf(name);
|
|
34
34
|
if (midPoint !== -1) {
|
|
35
35
|
let sentenceStart = midPoint;
|
|
36
|
-
let sentenceEnd = midPoint +
|
|
36
|
+
let sentenceEnd = midPoint + name.length;
|
|
37
37
|
for (let i = midPoint - 1; i >= 0; i--) {
|
|
38
38
|
if (sentenceBoundary.test(context[i])) {
|
|
39
39
|
sentenceStart = i + 1;
|
|
40
40
|
break;
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
-
for (let i = midPoint +
|
|
43
|
+
for (let i = midPoint + name.length; i < context.length; i++) {
|
|
44
44
|
if (sentenceBoundary.test(context[i])) {
|
|
45
45
|
sentenceEnd = i + 1;
|
|
46
46
|
break;
|
|
@@ -54,18 +54,18 @@ function extractTermContext(transcript, term) {
|
|
|
54
54
|
return context;
|
|
55
55
|
}
|
|
56
56
|
const create = (ctx) => ({
|
|
57
|
-
name: "
|
|
58
|
-
description: "Look up
|
|
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
59
|
parameters: {
|
|
60
60
|
type: "object",
|
|
61
61
|
properties: {
|
|
62
62
|
name: {
|
|
63
63
|
type: "string",
|
|
64
|
-
description: "The
|
|
64
|
+
description: "The name to look up (as heard in transcript)"
|
|
65
65
|
},
|
|
66
|
-
|
|
66
|
+
phonetic: {
|
|
67
67
|
type: "string",
|
|
68
|
-
description: "
|
|
68
|
+
description: "How the name sounds (for alias matching)"
|
|
69
69
|
}
|
|
70
70
|
},
|
|
71
71
|
required: ["name"]
|
|
@@ -83,99 +83,29 @@ const create = (ctx) => ({
|
|
|
83
83
|
}
|
|
84
84
|
};
|
|
85
85
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
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];
|
|
86
|
+
const people = context.search(args.name);
|
|
87
|
+
const personMatches = people.filter((e) => e.type === "person");
|
|
88
|
+
if (personMatches.length > 0) {
|
|
107
89
|
return {
|
|
108
90
|
success: true,
|
|
109
91
|
data: {
|
|
110
92
|
found: true,
|
|
111
|
-
|
|
112
|
-
|
|
93
|
+
person: personMatches[0],
|
|
94
|
+
suggestion: `Use "${personMatches[0].name}" for correct spelling`
|
|
113
95
|
}
|
|
114
96
|
};
|
|
115
97
|
}
|
|
116
|
-
if (
|
|
117
|
-
const
|
|
118
|
-
|
|
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") {
|
|
98
|
+
if (args.phonetic) {
|
|
99
|
+
const person = context.findBySoundsLike(args.phonetic);
|
|
100
|
+
if (person) {
|
|
138
101
|
return {
|
|
139
102
|
success: true,
|
|
140
103
|
data: {
|
|
141
104
|
found: true,
|
|
142
|
-
|
|
143
|
-
|
|
105
|
+
person,
|
|
106
|
+
suggestion: `"${args.phonetic}" likely refers to "${person.name}"`
|
|
144
107
|
}
|
|
145
108
|
};
|
|
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
109
|
}
|
|
180
110
|
}
|
|
181
111
|
const allProjects = context.getAllProjects();
|
|
@@ -189,32 +119,27 @@ const create = (ctx) => ({
|
|
|
189
119
|
hour: "2-digit",
|
|
190
120
|
minute: "2-digit"
|
|
191
121
|
});
|
|
192
|
-
const transcriptContext =
|
|
193
|
-
const
|
|
122
|
+
const transcriptContext = extractNameContext(ctx.transcriptText, args.name);
|
|
123
|
+
const promptLines = [
|
|
194
124
|
`File: ${fileName}`,
|
|
195
125
|
`Date: ${fileDate}`,
|
|
196
126
|
"",
|
|
197
|
-
`Unknown
|
|
127
|
+
`Unknown person mentioned: "${args.name}"`
|
|
198
128
|
];
|
|
199
129
|
if (transcriptContext) {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
} else if (args.triggerPhrase) {
|
|
204
|
-
contextLines.push("");
|
|
205
|
-
contextLines.push("Context from transcript:");
|
|
206
|
-
contextLines.push(`"${args.triggerPhrase}"`);
|
|
130
|
+
promptLines.push("");
|
|
131
|
+
promptLines.push("Context from transcript:");
|
|
132
|
+
promptLines.push(`"${transcriptContext}"`);
|
|
207
133
|
}
|
|
208
134
|
return {
|
|
209
135
|
success: true,
|
|
210
136
|
needsUserInput: true,
|
|
211
|
-
userPrompt:
|
|
137
|
+
userPrompt: promptLines.join("\n"),
|
|
212
138
|
data: {
|
|
213
139
|
found: false,
|
|
214
|
-
clarificationType: "
|
|
140
|
+
clarificationType: "new_person",
|
|
215
141
|
term: args.name,
|
|
216
|
-
|
|
217
|
-
message: `Project "${args.name}" not found. Asking user if this is a new project.`,
|
|
142
|
+
message: `Person "${args.name}" not found. Asking user for details.`,
|
|
218
143
|
knownProjects: allProjects.filter((p) => p.active !== false),
|
|
219
144
|
options: projectOptions
|
|
220
145
|
}
|
package/dist/index55.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index55.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,CAA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AAA,QACzD,OAAA,EAAS;AAAA;AACb,KACJ;AAAA,EACJ;AACJ,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"index55.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,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,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