@redaksjon/protokoll-engine 0.1.17 → 0.1.18-dev.20260317145404.b103d5b
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index19.js +1 -1
- package/dist/index22.js +1 -1
- package/dist/index26.js +1 -1
- package/dist/index27.js +5 -5
- package/dist/index31.js +1 -1
- package/dist/index32.js +1 -1
- package/dist/index33.js +2 -2
- package/dist/index34.js +3 -3
- package/dist/index35.js +5 -5
- package/dist/index36.js +2 -2
- package/dist/index37.js +1 -1
- package/dist/index39.js +1 -1
- package/dist/index42.js +1 -1
- package/dist/index43.js +1 -1
- package/dist/index47.js +45 -4
- package/dist/index47.js.map +1 -1
- package/dist/index48.js +147 -45
- package/dist/index48.js.map +1 -1
- package/dist/index49.js +106 -31
- package/dist/index49.js.map +1 -1
- package/dist/index50.js +21 -198
- package/dist/index50.js.map +1 -1
- package/dist/index51.js +25 -29
- package/dist/index51.js.map +1 -1
- package/dist/index52.js +18 -26
- package/dist/index52.js.map +1 -1
- package/dist/index53.js +48 -34
- package/dist/index53.js.map +1 -1
- package/dist/index54.js +34 -46
- package/dist/index54.js.map +1 -1
- package/dist/index55.js +280 -35
- package/dist/index55.js.map +1 -1
- package/dist/index56.js +138 -259
- package/dist/index56.js.map +1 -1
- package/dist/index57.js +61 -143
- package/dist/index57.js.map +1 -1
- package/dist/index58.js +70 -73
- package/dist/index58.js.map +1 -1
- package/dist/index59.js +3 -73
- package/dist/index59.js.map +1 -1
- package/dist/index60.js +5 -148
- package/dist/index60.js.map +1 -1
- package/dist/index61.js +4 -4
- package/dist/index62.js +148 -5
- package/dist/index62.js.map +1 -1
- package/package.json +1 -1
package/dist/index19.js
CHANGED
package/dist/index22.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { create as create$1 } from './index13.js';
|
|
2
2
|
import { create as create$2 } from './index14.js';
|
|
3
3
|
import { MODEL_CAPABILITIES } from './index23.js';
|
|
4
|
-
import { getLogger } from './
|
|
4
|
+
import { getLogger } from './index47.js';
|
|
5
5
|
import * as path from 'node:path';
|
|
6
6
|
import * as os from 'node:os';
|
|
7
7
|
|
package/dist/index26.js
CHANGED
package/dist/index27.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ToolRegistry } from '@kjerneverk/riotprompt';
|
|
2
|
-
import { create as create$1 } from './
|
|
3
|
-
import { create as create$2 } from './
|
|
4
|
-
import { create as create$3 } from './
|
|
5
|
-
import { create as create$4 } from './
|
|
6
|
-
import { create as create$5 } from './
|
|
2
|
+
import { create as create$1 } from './index48.js';
|
|
3
|
+
import { create as create$2 } from './index49.js';
|
|
4
|
+
import { create as create$3 } from './index50.js';
|
|
5
|
+
import { create as create$4 } from './index51.js';
|
|
6
|
+
import { create as create$5 } from './index52.js';
|
|
7
7
|
|
|
8
8
|
const toRiotTool = (tool, category) => ({
|
|
9
9
|
name: tool.name,
|
package/dist/index31.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as readline from 'readline';
|
|
2
2
|
import * as fs from 'fs/promises';
|
|
3
3
|
import * as path from 'node:path';
|
|
4
|
-
import { getLogger } from './
|
|
4
|
+
import { getLogger } from './index47.js';
|
|
5
5
|
|
|
6
6
|
const print = console.log;
|
|
7
7
|
const createReadlineInterface = () => {
|
package/dist/index32.js
CHANGED
package/dist/index33.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import * as Context from '@redaksjon/context';
|
|
2
2
|
import { create as create$1 } from './index6.js';
|
|
3
|
-
import { create as create$2 } from './
|
|
3
|
+
import { create as create$2 } from './index59.js';
|
|
4
4
|
import { create as create$3 } from './index11.js';
|
|
5
5
|
import { create as create$4 } from './index3.js';
|
|
6
6
|
import { create as create$5 } from './index2.js';
|
|
7
7
|
import { create as create$8 } from './index5.js';
|
|
8
8
|
import { create as create$7 } from './index37.js';
|
|
9
9
|
import { create as create$6 } from './index35.js';
|
|
10
|
-
import { getLogger } from './
|
|
10
|
+
import { getLogger } from './index47.js';
|
|
11
11
|
import { randomUUID } from 'node:crypto';
|
|
12
12
|
import * as path from 'node:path';
|
|
13
13
|
import { extractTagsFromSignals, createRoutingMetadata } from './index15.js';
|
package/dist/index34.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { getLogger } from './
|
|
1
|
+
import { getLogger } from './index47.js';
|
|
2
2
|
import { create as create$1 } from './index13.js';
|
|
3
3
|
import { create as create$2 } from './index14.js';
|
|
4
|
-
import { transcribeAudio } from './
|
|
5
|
-
import { stringifyJSON } from './
|
|
4
|
+
import { transcribeAudio } from './index53.js';
|
|
5
|
+
import { stringifyJSON } from './index54.js';
|
|
6
6
|
import path__default from 'node:path';
|
|
7
7
|
import { create as create$4 } from './index5.js';
|
|
8
8
|
import { create as create$3 } from './index2.js';
|
package/dist/index35.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { getLogger } from './
|
|
1
|
+
import { getLogger } from './index47.js';
|
|
2
2
|
import { create as create$1 } from './index13.js';
|
|
3
|
-
import { create as create$2 } from './
|
|
4
|
-
import { create as create$3 } from './
|
|
5
|
-
import { create as create$4 } from './
|
|
6
|
-
import { stringifyJSON } from './
|
|
3
|
+
import { create as create$2 } from './index55.js';
|
|
4
|
+
import { create as create$3 } from './index56.js';
|
|
5
|
+
import { create as create$4 } from './index57.js';
|
|
6
|
+
import { stringifyJSON } from './index54.js';
|
|
7
7
|
import path from 'path';
|
|
8
8
|
|
|
9
9
|
const create = (config, contextInstance) => {
|
package/dist/index36.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { getLogger } from './
|
|
1
|
+
import { getLogger } from './index47.js';
|
|
2
2
|
import { create as create$3 } from './index14.js';
|
|
3
3
|
import { create as create$1 } from './index13.js';
|
|
4
|
-
import { create as create$2 } from './
|
|
4
|
+
import { create as create$2 } from './index58.js';
|
|
5
5
|
import { DEFAULT_INTERMEDIATE_DIRECTORY } from './index18.js';
|
|
6
6
|
import path__default from 'node:path';
|
|
7
7
|
|
package/dist/index37.js
CHANGED
package/dist/index39.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as fs from 'fs/promises';
|
|
2
2
|
import * as path from 'node:path';
|
|
3
|
-
import { getLogger } from './
|
|
3
|
+
import { getLogger } from './index47.js';
|
|
4
4
|
import { extractTimestampFromFilename, slugifyTitle } from './index38.js';
|
|
5
5
|
import { PklTranscript } from '@redaksjon/protokoll-format';
|
|
6
6
|
import { ensurePklExtension } from './index40.js';
|
package/dist/index42.js
CHANGED
package/dist/index43.js
CHANGED
package/dist/index47.js
CHANGED
|
@@ -1,8 +1,49 @@
|
|
|
1
|
-
import
|
|
1
|
+
import winston from 'winston';
|
|
2
|
+
import { DATE_FORMAT_YEAR_MONTH_DAY_HOURS_MINUTES_SECONDS, PROGRAM_NAME } from './index18.js';
|
|
2
3
|
|
|
3
|
-
const
|
|
4
|
-
|
|
4
|
+
const createLogger = (level = "info") => {
|
|
5
|
+
let format = winston.format.combine(
|
|
6
|
+
winston.format.timestamp({ format: DATE_FORMAT_YEAR_MONTH_DAY_HOURS_MINUTES_SECONDS }),
|
|
7
|
+
winston.format.errors({ stack: true }),
|
|
8
|
+
winston.format.splat(),
|
|
9
|
+
winston.format.json()
|
|
10
|
+
);
|
|
11
|
+
let transports = [
|
|
12
|
+
new winston.transports.Console({
|
|
13
|
+
format: winston.format.combine(
|
|
14
|
+
winston.format.colorize(),
|
|
15
|
+
winston.format.printf(({ timestamp, level: level2, message, ...meta }) => {
|
|
16
|
+
const metaStr = Object.keys(meta).length ? ` ${JSON.stringify(meta)}` : "";
|
|
17
|
+
return `${timestamp} ${level2}: ${message}${metaStr}`;
|
|
18
|
+
})
|
|
19
|
+
)
|
|
20
|
+
})
|
|
21
|
+
];
|
|
22
|
+
if (level === "info") {
|
|
23
|
+
format = winston.format.combine(
|
|
24
|
+
winston.format.errors({ stack: true }),
|
|
25
|
+
winston.format.splat()
|
|
26
|
+
);
|
|
27
|
+
transports = [
|
|
28
|
+
new winston.transports.Console({
|
|
29
|
+
format: winston.format.combine(
|
|
30
|
+
winston.format.colorize(),
|
|
31
|
+
winston.format.printf(({ level: level2, message }) => {
|
|
32
|
+
return `${level2}: ${message}`;
|
|
33
|
+
})
|
|
34
|
+
)
|
|
35
|
+
})
|
|
36
|
+
];
|
|
37
|
+
}
|
|
38
|
+
return winston.createLogger({
|
|
39
|
+
level,
|
|
40
|
+
format,
|
|
41
|
+
defaultMeta: { service: PROGRAM_NAME },
|
|
42
|
+
transports
|
|
43
|
+
});
|
|
5
44
|
};
|
|
45
|
+
let logger = createLogger();
|
|
46
|
+
const getLogger = () => logger;
|
|
6
47
|
|
|
7
|
-
export {
|
|
48
|
+
export { getLogger };
|
|
8
49
|
//# sourceMappingURL=index47.js.map
|
package/dist/index47.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index47.js","sources":["../src/
|
|
1
|
+
{"version":3,"file":"index47.js","sources":["../src/logging.ts"],"sourcesContent":["import winston from 'winston';\nimport { DATE_FORMAT_YEAR_MONTH_DAY_HOURS_MINUTES_SECONDS, PROGRAM_NAME } from './constants';\n\nexport interface LogContext {\n [key: string]: any;\n}\n\nconst createLogger = (level: string = 'info') => {\n\n let format = winston.format.combine(\n winston.format.timestamp({ format: DATE_FORMAT_YEAR_MONTH_DAY_HOURS_MINUTES_SECONDS }),\n winston.format.errors({ stack: true }),\n winston.format.splat(),\n winston.format.json()\n );\n\n let transports = [\n new winston.transports.Console({\n format: winston.format.combine(\n winston.format.colorize(),\n winston.format.printf(({ timestamp, level, message, ...meta }) => {\n const metaStr = Object.keys(meta).length ? ` ${JSON.stringify(meta)}` : '';\n return `${timestamp} ${level}: ${message}${metaStr}`;\n })\n )\n })\n ];\n\n if (level === 'info') {\n format = winston.format.combine(\n winston.format.errors({ stack: true }),\n winston.format.splat(),\n );\n\n transports = [\n new winston.transports.Console({\n format: winston.format.combine(\n winston.format.colorize(),\n winston.format.printf(({ level, message }) => {\n return `${level}: ${message}`;\n })\n )\n })\n ];\n }\n\n return winston.createLogger({\n level,\n format,\n defaultMeta: { service: PROGRAM_NAME },\n transports,\n });\n};\n\nlet logger = createLogger();\n\nexport const setLogLevel = (level: string) => {\n logger = createLogger(level);\n};\n\nexport const getLogger = () => logger; "],"names":["level"],"mappings":";;;AAOA,MAAM,YAAA,GAAe,CAAC,KAAA,GAAgB,MAAA,KAAW;AAE7C,EAAA,IAAI,MAAA,GAAS,QAAQ,MAAA,CAAO,OAAA;AAAA,IACxB,QAAQ,MAAA,CAAO,SAAA,CAAU,EAAE,MAAA,EAAQ,kDAAkD,CAAA;AAAA,IACrF,QAAQ,MAAA,CAAO,MAAA,CAAO,EAAE,KAAA,EAAO,MAAM,CAAA;AAAA,IACrC,OAAA,CAAQ,OAAO,KAAA,EAAM;AAAA,IACrB,OAAA,CAAQ,OAAO,IAAA;AAAK,GACxB;AAEA,EAAA,IAAI,UAAA,GAAa;AAAA,IACb,IAAI,OAAA,CAAQ,UAAA,CAAW,OAAA,CAAQ;AAAA,MAC3B,MAAA,EAAQ,QAAQ,MAAA,CAAO,OAAA;AAAA,QACnB,OAAA,CAAQ,OAAO,QAAA,EAAS;AAAA,QACxB,OAAA,CAAQ,MAAA,CAAO,MAAA,CAAO,CAAC,EAAE,SAAA,EAAW,KAAA,EAAAA,MAAAA,EAAO,OAAA,EAAS,GAAG,IAAA,EAAK,KAAM;AAC9D,UAAA,MAAM,OAAA,GAAU,MAAA,CAAO,IAAA,CAAK,IAAI,CAAA,CAAE,MAAA,GAAS,CAAA,CAAA,EAAI,IAAA,CAAK,SAAA,CAAU,IAAI,CAAC,CAAA,CAAA,GAAK,EAAA;AACxE,UAAA,OAAO,GAAG,SAAS,CAAA,CAAA,EAAIA,MAAK,CAAA,EAAA,EAAK,OAAO,GAAG,OAAO,CAAA,CAAA;AAAA,QACtD,CAAC;AAAA;AACL,KACH;AAAA,GACL;AAEA,EAAA,IAAI,UA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|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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}"`
|
|
36
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
|
+
};
|
|
37
147
|
}
|
|
38
|
-
|
|
39
|
-
level,
|
|
40
|
-
format,
|
|
41
|
-
defaultMeta: { service: PROGRAM_NAME },
|
|
42
|
-
transports
|
|
43
|
-
});
|
|
44
|
-
};
|
|
45
|
-
let logger = createLogger();
|
|
46
|
-
const getLogger = () => logger;
|
|
148
|
+
});
|
|
47
149
|
|
|
48
|
-
export {
|
|
150
|
+
export { create };
|
|
49
151
|
//# sourceMappingURL=index48.js.map
|
package/dist/index48.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index48.js","sources":["../src/logging.ts"],"sourcesContent":["import winston from 'winston';\nimport { DATE_FORMAT_YEAR_MONTH_DAY_HOURS_MINUTES_SECONDS, PROGRAM_NAME } from './constants';\n\nexport interface LogContext {\n [key: string]: any;\n}\n\nconst createLogger = (level: string = 'info') => {\n\n let format = winston.format.combine(\n winston.format.timestamp({ format: DATE_FORMAT_YEAR_MONTH_DAY_HOURS_MINUTES_SECONDS }),\n winston.format.errors({ stack: true }),\n winston.format.splat(),\n winston.format.json()\n );\n\n let transports = [\n new winston.transports.Console({\n format: winston.format.combine(\n winston.format.colorize(),\n winston.format.printf(({ timestamp, level, message, ...meta }) => {\n const metaStr = Object.keys(meta).length ? ` ${JSON.stringify(meta)}` : '';\n return `${timestamp} ${level}: ${message}${metaStr}`;\n })\n )\n })\n ];\n\n if (level === 'info') {\n format = winston.format.combine(\n winston.format.errors({ stack: true }),\n winston.format.splat(),\n );\n\n transports = [\n new winston.transports.Console({\n format: winston.format.combine(\n winston.format.colorize(),\n winston.format.printf(({ level, message }) => {\n return `${level}: ${message}`;\n })\n )\n })\n ];\n }\n\n return winston.createLogger({\n level,\n format,\n defaultMeta: { service: PROGRAM_NAME },\n transports,\n });\n};\n\nlet logger = createLogger();\n\nexport const setLogLevel = (level: string) => {\n logger = createLogger(level);\n};\n\nexport const getLogger = () => logger; "],"names":["level"],"mappings":";;;AAOA,MAAM,YAAA,GAAe,CAAC,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A,CAAQ;AAAA,QAC3B,MAAA,EAAQ,QAAQ,MAAA,CAAO,OAAA;AAAA,UACnB,OAAA,CAAQ,OAAO,QAAA,EAAS;AAAA,UACxB,OAAA,CAAQ,OAAO,MAAA,CAAO,CAAC,EAAE,KAAA,EAAAA,MAAAA,EAAO,SAAQ,KAAM;AAC1C,YAAA,OAAO,CAAA,EAAGA,MAAK,CAAA,EAAA,EAAK,OAAO,CAAA,CAAA;AAAA,UAC/B,CAAC;AAAA;AACL,OACH;AAAA,KACL;AAAA,EACJ;AAEA,EAAA,OAAO,QAAQ,YAAA,CAAa;AAAA,IACxB,KAAA;AAAA,IACA,MAAA;AAAA,IACA,WAAA,EAAa,EAAE,OAAA,EAAS,YAAA,EAAa;AAAA,IACrC;AAAA,GACH,CAAA;AACL,CAAA;AAEA,IAAI,SAAS,YAAA,EAAa;AAMnB,MAAM,YAAY,MAAM;;;;"}
|
|
1
|
+
{"version":3,"file":"index48.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,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