@redaksjon/protokoll 0.0.8 → 0.0.10
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/.cursor/rules/definition-of-done.md +89 -0
- package/.cursor/rules/no-emoticons.md +43 -0
- package/LICENSE +1 -1
- package/README.md +928 -35
- package/dist/agentic/executor.js +315 -0
- package/dist/agentic/executor.js.map +1 -0
- package/dist/agentic/index.js +19 -0
- package/dist/agentic/index.js.map +1 -0
- package/dist/agentic/registry.js +41 -0
- package/dist/agentic/registry.js.map +1 -0
- package/dist/agentic/tools/lookup-person.js +66 -0
- package/dist/agentic/tools/lookup-person.js.map +1 -0
- package/dist/agentic/tools/lookup-project.js +93 -0
- package/dist/agentic/tools/lookup-project.js.map +1 -0
- package/dist/agentic/tools/route-note.js +45 -0
- package/dist/agentic/tools/route-note.js.map +1 -0
- package/dist/agentic/tools/store-context.js +51 -0
- package/dist/agentic/tools/store-context.js.map +1 -0
- package/dist/agentic/tools/verify-spelling.js +57 -0
- package/dist/agentic/tools/verify-spelling.js.map +1 -0
- package/dist/arguments.js +23 -6
- package/dist/arguments.js.map +1 -1
- package/dist/constants.js +13 -11
- package/dist/constants.js.map +1 -1
- package/dist/context/discovery.js +114 -0
- package/dist/context/discovery.js.map +1 -0
- package/dist/context/index.js +58 -0
- package/dist/context/index.js.map +1 -0
- package/dist/context/storage.js +131 -0
- package/dist/context/storage.js.map +1 -0
- package/dist/interactive/handler.js +223 -0
- package/dist/interactive/handler.js.map +1 -0
- package/dist/interactive/index.js +18 -0
- package/dist/interactive/index.js.map +1 -0
- package/dist/interactive/onboarding.js +28 -0
- package/dist/interactive/onboarding.js.map +1 -0
- package/dist/main.js +0 -0
- package/dist/output/index.js +8 -0
- package/dist/output/index.js.map +1 -0
- package/dist/output/manager.js +105 -0
- package/dist/output/manager.js.map +1 -0
- package/dist/phases/complete.js +107 -0
- package/dist/phases/complete.js.map +1 -0
- package/dist/phases/locate.js +14 -5
- package/dist/phases/locate.js.map +1 -1
- package/dist/pipeline/index.js +8 -0
- package/dist/pipeline/index.js.map +1 -0
- package/dist/pipeline/orchestrator.js +281 -0
- package/dist/pipeline/orchestrator.js.map +1 -0
- package/dist/prompt/instructions/transcribe.md +6 -6
- package/dist/prompt/personas/transcriber.md +5 -5
- package/dist/protokoll.js +38 -5
- package/dist/protokoll.js.map +1 -1
- package/dist/reasoning/client.js +150 -0
- package/dist/reasoning/client.js.map +1 -0
- package/dist/reasoning/index.js +36 -0
- package/dist/reasoning/index.js.map +1 -0
- package/dist/reasoning/strategy.js +60 -0
- package/dist/reasoning/strategy.js.map +1 -0
- package/dist/reflection/collector.js +124 -0
- package/dist/reflection/collector.js.map +1 -0
- package/dist/reflection/index.js +16 -0
- package/dist/reflection/index.js.map +1 -0
- package/dist/reflection/reporter.js +238 -0
- package/dist/reflection/reporter.js.map +1 -0
- package/dist/routing/classifier.js +201 -0
- package/dist/routing/classifier.js.map +1 -0
- package/dist/routing/index.js +27 -0
- package/dist/routing/index.js.map +1 -0
- package/dist/routing/router.js +153 -0
- package/dist/routing/router.js.map +1 -0
- package/dist/transcription/index.js +41 -0
- package/dist/transcription/index.js.map +1 -0
- package/dist/transcription/service.js +64 -0
- package/dist/transcription/service.js.map +1 -0
- package/dist/transcription/types.js +31 -0
- package/dist/transcription/types.js.map +1 -0
- package/dist/util/media.js +4 -4
- package/dist/util/media.js.map +1 -1
- package/dist/util/metadata.js +95 -0
- package/dist/util/metadata.js.map +1 -0
- package/dist/util/storage.js +2 -2
- package/dist/util/storage.js.map +1 -1
- package/docs/examples.md +224 -0
- package/docs/index.html +5 -3
- package/docs/package-lock.json +639 -332
- package/docs/package.json +5 -4
- package/docs/troubleshooting.md +257 -0
- package/docs/vite.config.js +9 -3
- package/eslint.config.mjs +1 -0
- package/guide/architecture.md +217 -0
- package/guide/configuration.md +199 -0
- package/guide/context-system.md +215 -0
- package/guide/development.md +273 -0
- package/guide/index.md +91 -0
- package/guide/interactive.md +199 -0
- package/guide/quickstart.md +138 -0
- package/guide/reasoning.md +193 -0
- package/guide/routing.md +222 -0
- package/package.json +10 -7
- package/tsconfig.tsbuildinfo +1 -1
- package/vitest.config.ts +27 -5
- package/dist/phases/transcribe.js +0 -149
- package/dist/phases/transcribe.js.map +0 -1
- package/dist/processor.js +0 -35
- package/dist/processor.js.map +0 -1
- package/dist/prompt/transcribe.js +0 -41
- package/dist/prompt/transcribe.js.map +0 -1
- package/dist/util/general.js +0 -39
- package/dist/util/general.js.map +0 -1
- package/dist/util/openai.js +0 -92
- package/dist/util/openai.js.map +0 -1
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
import { create as create$1 } from './registry.js';
|
|
2
|
+
import { getLogger } from '../logging.js';
|
|
3
|
+
|
|
4
|
+
const create = (reasoning, ctx)=>{
|
|
5
|
+
const logger = getLogger();
|
|
6
|
+
const registry = create$1(ctx);
|
|
7
|
+
const process = async (transcriptText)=>{
|
|
8
|
+
const state = {
|
|
9
|
+
originalText: transcriptText,
|
|
10
|
+
correctedText: transcriptText,
|
|
11
|
+
unknownEntities: [],
|
|
12
|
+
resolvedEntities: new Map(),
|
|
13
|
+
confidence: 0
|
|
14
|
+
};
|
|
15
|
+
const toolsUsed = [];
|
|
16
|
+
const contextChanges = [];
|
|
17
|
+
let iterations = 0;
|
|
18
|
+
let totalTokens = 0;
|
|
19
|
+
const maxIterations = 15;
|
|
20
|
+
// Conversation history for multi-turn
|
|
21
|
+
const conversationHistory = [];
|
|
22
|
+
// Build the system prompt
|
|
23
|
+
const systemPrompt = `You are an intelligent transcription assistant. Your job is to:
|
|
24
|
+
1. Analyze the transcript for names, projects, and companies
|
|
25
|
+
2. Use the available tools to verify spellings and gather context
|
|
26
|
+
3. Correct any misheard names or terms
|
|
27
|
+
4. Determine the appropriate destination for this note
|
|
28
|
+
5. Produce a clean, accurate Markdown transcript
|
|
29
|
+
|
|
30
|
+
CRITICAL RULES:
|
|
31
|
+
- This is NOT a summary. Preserve ALL content from the original transcript.
|
|
32
|
+
- Only fix obvious transcription errors like misheard names.
|
|
33
|
+
- When you have finished processing, output the COMPLETE corrected transcript as Markdown.
|
|
34
|
+
- Do NOT say you don't have the transcript - it's in the conversation history.
|
|
35
|
+
|
|
36
|
+
Available tools:
|
|
37
|
+
- lookup_person: Find information about people (use for any name that might be misspelled)
|
|
38
|
+
- lookup_project: Find project routing information
|
|
39
|
+
- verify_spelling: Ask user about unknown terms (if interactive mode)
|
|
40
|
+
- route_note: Determine where to file this note
|
|
41
|
+
- store_context: Remember new information for future use`;
|
|
42
|
+
// Add system message to history
|
|
43
|
+
conversationHistory.push({
|
|
44
|
+
role: 'system',
|
|
45
|
+
content: systemPrompt
|
|
46
|
+
});
|
|
47
|
+
// Add the initial user message with transcript
|
|
48
|
+
const initialPrompt = `Here is the raw transcript to process:
|
|
49
|
+
|
|
50
|
+
--- BEGIN TRANSCRIPT ---
|
|
51
|
+
${transcriptText}
|
|
52
|
+
--- END TRANSCRIPT ---
|
|
53
|
+
|
|
54
|
+
Please:
|
|
55
|
+
1. Identify any names, companies, or technical terms that might be misspelled
|
|
56
|
+
2. Use the lookup_person tool to verify spelling of any names you find
|
|
57
|
+
3. Use route_note to determine the destination
|
|
58
|
+
4. Then output the COMPLETE corrected transcript as clean Markdown
|
|
59
|
+
|
|
60
|
+
Remember: preserve ALL content, only fix transcription errors.`;
|
|
61
|
+
conversationHistory.push({
|
|
62
|
+
role: 'user',
|
|
63
|
+
content: initialPrompt
|
|
64
|
+
});
|
|
65
|
+
try {
|
|
66
|
+
var _response_toolCalls;
|
|
67
|
+
// Initial reasoning call
|
|
68
|
+
logger.debug('Starting agentic transcription - analyzing for names and routing...');
|
|
69
|
+
let response = await reasoning.complete({
|
|
70
|
+
systemPrompt,
|
|
71
|
+
prompt: initialPrompt,
|
|
72
|
+
tools: registry.getToolDefinitions(),
|
|
73
|
+
maxIterations
|
|
74
|
+
});
|
|
75
|
+
// Track token usage
|
|
76
|
+
if (response.usage) {
|
|
77
|
+
totalTokens += response.usage.totalTokens;
|
|
78
|
+
}
|
|
79
|
+
// Add assistant response to history
|
|
80
|
+
conversationHistory.push({
|
|
81
|
+
role: 'assistant',
|
|
82
|
+
content: response.content,
|
|
83
|
+
tool_calls: (_response_toolCalls = response.toolCalls) === null || _response_toolCalls === void 0 ? void 0 : _response_toolCalls.map((tc)=>({
|
|
84
|
+
id: tc.id,
|
|
85
|
+
name: tc.name,
|
|
86
|
+
arguments: tc.arguments
|
|
87
|
+
}))
|
|
88
|
+
});
|
|
89
|
+
// Iterative tool use loop
|
|
90
|
+
while(response.toolCalls && response.toolCalls.length > 0 && iterations < maxIterations){
|
|
91
|
+
var _response_toolCalls1;
|
|
92
|
+
iterations++;
|
|
93
|
+
logger.debug('Iteration %d: Processing %d tool calls...', iterations, response.toolCalls.length);
|
|
94
|
+
// Collect tool results
|
|
95
|
+
const toolResults = [];
|
|
96
|
+
// Execute each tool call
|
|
97
|
+
for (const toolCall of response.toolCalls){
|
|
98
|
+
logger.debug('Executing tool: %s', toolCall.name);
|
|
99
|
+
toolsUsed.push(toolCall.name);
|
|
100
|
+
try {
|
|
101
|
+
var _result_data, _result_data1;
|
|
102
|
+
const result = await registry.executeTool(toolCall.name, toolCall.arguments);
|
|
103
|
+
// Format result for the model
|
|
104
|
+
const resultStr = JSON.stringify(result.data || {
|
|
105
|
+
success: result.success,
|
|
106
|
+
message: result.error || 'OK'
|
|
107
|
+
});
|
|
108
|
+
toolResults.push({
|
|
109
|
+
id: toolCall.id,
|
|
110
|
+
name: toolCall.name,
|
|
111
|
+
result: resultStr
|
|
112
|
+
});
|
|
113
|
+
logger.debug('Tool %s result: %s', toolCall.name, result.success ? 'success' : 'failed');
|
|
114
|
+
// Handle results that need user input
|
|
115
|
+
if (result.needsUserInput && ctx.interactiveMode && ctx.interactiveInstance) {
|
|
116
|
+
var _result_data2, _result_data3, _result_data4, _result_data5;
|
|
117
|
+
logger.info('Interactive: %s requires clarification', toolCall.name);
|
|
118
|
+
const termName = String(toolCall.arguments.name || toolCall.arguments.term || '');
|
|
119
|
+
const clarification = await ctx.interactiveInstance.handleClarification({
|
|
120
|
+
type: ((_result_data2 = result.data) === null || _result_data2 === void 0 ? void 0 : _result_data2.clarificationType) || 'general',
|
|
121
|
+
term: ((_result_data3 = result.data) === null || _result_data3 === void 0 ? void 0 : _result_data3.term) || termName,
|
|
122
|
+
context: result.userPrompt || '',
|
|
123
|
+
suggestion: (_result_data4 = result.data) === null || _result_data4 === void 0 ? void 0 : _result_data4.suggestion,
|
|
124
|
+
options: (_result_data5 = result.data) === null || _result_data5 === void 0 ? void 0 : _result_data5.options
|
|
125
|
+
});
|
|
126
|
+
if (clarification.response) {
|
|
127
|
+
var _result_data6;
|
|
128
|
+
state.resolvedEntities.set(termName, clarification.response);
|
|
129
|
+
logger.info('Clarified: %s -> %s', termName, clarification.response);
|
|
130
|
+
// Handle new project creation
|
|
131
|
+
if (((_result_data6 = result.data) === null || _result_data6 === void 0 ? void 0 : _result_data6.clarificationType) === 'new_project' && clarification.response.trim()) {
|
|
132
|
+
const projectPath = clarification.response.trim();
|
|
133
|
+
// Only create if user provided a path (not just pressed Enter)
|
|
134
|
+
if (projectPath && projectPath !== termName) {
|
|
135
|
+
const projectId = termName.toLowerCase().replace(/\s+/g, '-');
|
|
136
|
+
const newProject = {
|
|
137
|
+
id: projectId,
|
|
138
|
+
name: termName,
|
|
139
|
+
type: 'project',
|
|
140
|
+
description: `Auto-created from transcript mentioning "${termName}"`,
|
|
141
|
+
classification: {
|
|
142
|
+
context_type: 'work',
|
|
143
|
+
explicit_phrases: [
|
|
144
|
+
termName.toLowerCase()
|
|
145
|
+
]
|
|
146
|
+
},
|
|
147
|
+
routing: {
|
|
148
|
+
destination: projectPath,
|
|
149
|
+
structure: 'month',
|
|
150
|
+
filename_options: [
|
|
151
|
+
'date',
|
|
152
|
+
'time',
|
|
153
|
+
'subject'
|
|
154
|
+
]
|
|
155
|
+
},
|
|
156
|
+
active: true
|
|
157
|
+
};
|
|
158
|
+
try {
|
|
159
|
+
await ctx.contextInstance.saveEntity(newProject);
|
|
160
|
+
logger.info('Created new project: %s -> %s', termName, projectPath);
|
|
161
|
+
// Record the context change
|
|
162
|
+
contextChanges.push({
|
|
163
|
+
entityType: 'project',
|
|
164
|
+
entityId: projectId,
|
|
165
|
+
entityName: termName,
|
|
166
|
+
action: 'created',
|
|
167
|
+
details: {
|
|
168
|
+
destination: projectPath,
|
|
169
|
+
routing: newProject.routing
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
// Update routing to use new project
|
|
173
|
+
state.routeDecision = {
|
|
174
|
+
projectId,
|
|
175
|
+
destination: {
|
|
176
|
+
path: projectPath,
|
|
177
|
+
structure: 'month'
|
|
178
|
+
},
|
|
179
|
+
confidence: 1.0,
|
|
180
|
+
signals: [
|
|
181
|
+
{
|
|
182
|
+
type: 'explicit_phrase',
|
|
183
|
+
value: termName,
|
|
184
|
+
weight: 1.0
|
|
185
|
+
}
|
|
186
|
+
],
|
|
187
|
+
reasoning: `User created new project "${termName}" routing to ${projectPath}`
|
|
188
|
+
};
|
|
189
|
+
} catch (error) {
|
|
190
|
+
logger.warn('Failed to save new project: %s', error);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
// Update state based on tool results
|
|
197
|
+
if ((_result_data = result.data) === null || _result_data === void 0 ? void 0 : _result_data.person) {
|
|
198
|
+
state.resolvedEntities.set(result.data.person.name, result.data.suggestion);
|
|
199
|
+
}
|
|
200
|
+
if ((_result_data1 = result.data) === null || _result_data1 === void 0 ? void 0 : _result_data1.destination) {
|
|
201
|
+
state.routeDecision = result.data;
|
|
202
|
+
}
|
|
203
|
+
} catch (error) {
|
|
204
|
+
logger.error('Tool execution failed', {
|
|
205
|
+
tool: toolCall.name,
|
|
206
|
+
error
|
|
207
|
+
});
|
|
208
|
+
toolResults.push({
|
|
209
|
+
id: toolCall.id,
|
|
210
|
+
name: toolCall.name,
|
|
211
|
+
result: JSON.stringify({
|
|
212
|
+
error: String(error)
|
|
213
|
+
})
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
// Add tool results to history
|
|
218
|
+
for (const tr of toolResults){
|
|
219
|
+
conversationHistory.push({
|
|
220
|
+
role: 'tool',
|
|
221
|
+
tool_call_id: tr.id,
|
|
222
|
+
content: tr.result
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
// Build continuation prompt with full context
|
|
226
|
+
const continuationPrompt = `Tool results received. Here's a reminder of your task:
|
|
227
|
+
|
|
228
|
+
ORIGINAL TRANSCRIPT (process this):
|
|
229
|
+
--- BEGIN TRANSCRIPT ---
|
|
230
|
+
${transcriptText}
|
|
231
|
+
--- END TRANSCRIPT ---
|
|
232
|
+
|
|
233
|
+
Corrections made so far: ${state.resolvedEntities.size > 0 ? Array.from(state.resolvedEntities.entries()).map(([k, v])=>`${k} -> ${v}`).join(', ') : 'none yet'}
|
|
234
|
+
|
|
235
|
+
Continue analyzing. If you need more information, use the tools.
|
|
236
|
+
When you're done with tool calls, output the COMPLETE corrected transcript as Markdown.
|
|
237
|
+
Do NOT summarize - include ALL original content with corrections applied.`;
|
|
238
|
+
conversationHistory.push({
|
|
239
|
+
role: 'user',
|
|
240
|
+
content: continuationPrompt
|
|
241
|
+
});
|
|
242
|
+
// Continue conversation with full context
|
|
243
|
+
response = await reasoning.complete({
|
|
244
|
+
systemPrompt,
|
|
245
|
+
prompt: continuationPrompt,
|
|
246
|
+
tools: registry.getToolDefinitions()
|
|
247
|
+
});
|
|
248
|
+
// Track token usage
|
|
249
|
+
if (response.usage) {
|
|
250
|
+
totalTokens += response.usage.totalTokens;
|
|
251
|
+
}
|
|
252
|
+
conversationHistory.push({
|
|
253
|
+
role: 'assistant',
|
|
254
|
+
content: response.content,
|
|
255
|
+
tool_calls: (_response_toolCalls1 = response.toolCalls) === null || _response_toolCalls1 === void 0 ? void 0 : _response_toolCalls1.map((tc)=>({
|
|
256
|
+
id: tc.id,
|
|
257
|
+
name: tc.name,
|
|
258
|
+
arguments: tc.arguments
|
|
259
|
+
}))
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
// Extract final corrected text
|
|
263
|
+
if (response.content && response.content.length > 50) {
|
|
264
|
+
state.correctedText = response.content;
|
|
265
|
+
state.confidence = 0.9;
|
|
266
|
+
logger.debug('Final transcript generated: %d characters', response.content.length);
|
|
267
|
+
} else {
|
|
268
|
+
// Model didn't produce content - ask for it explicitly
|
|
269
|
+
logger.debug('Model did not produce transcript, requesting explicitly...');
|
|
270
|
+
const finalRequest = `Please output the COMPLETE corrected transcript now.
|
|
271
|
+
|
|
272
|
+
ORIGINAL:
|
|
273
|
+
${transcriptText}
|
|
274
|
+
|
|
275
|
+
CORRECTIONS TO APPLY:
|
|
276
|
+
${state.resolvedEntities.size > 0 ? Array.from(state.resolvedEntities.entries()).map(([k, v])=>`- "${k}" should be "${v}"`).join('\n') : 'None identified'}
|
|
277
|
+
|
|
278
|
+
Output the full transcript as clean Markdown. Do NOT summarize.`;
|
|
279
|
+
const finalResponse = await reasoning.complete({
|
|
280
|
+
systemPrompt,
|
|
281
|
+
prompt: finalRequest
|
|
282
|
+
});
|
|
283
|
+
// Track token usage
|
|
284
|
+
if (finalResponse.usage) {
|
|
285
|
+
totalTokens += finalResponse.usage.totalTokens;
|
|
286
|
+
}
|
|
287
|
+
state.correctedText = finalResponse.content || transcriptText;
|
|
288
|
+
state.confidence = 0.8;
|
|
289
|
+
}
|
|
290
|
+
} catch (error) {
|
|
291
|
+
logger.error('Agentic processing failed', {
|
|
292
|
+
error
|
|
293
|
+
});
|
|
294
|
+
// Fall back to original text
|
|
295
|
+
state.correctedText = transcriptText;
|
|
296
|
+
state.confidence = 0.5;
|
|
297
|
+
}
|
|
298
|
+
return {
|
|
299
|
+
enhancedText: state.correctedText,
|
|
300
|
+
state,
|
|
301
|
+
toolsUsed: [
|
|
302
|
+
...new Set(toolsUsed)
|
|
303
|
+
],
|
|
304
|
+
iterations,
|
|
305
|
+
totalTokens: totalTokens > 0 ? totalTokens : undefined,
|
|
306
|
+
contextChanges: contextChanges.length > 0 ? contextChanges : undefined
|
|
307
|
+
};
|
|
308
|
+
};
|
|
309
|
+
return {
|
|
310
|
+
process
|
|
311
|
+
};
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
export { create };
|
|
315
|
+
//# sourceMappingURL=executor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.js","sources":["../../src/agentic/executor.ts"],"sourcesContent":["/**\n * Agentic Executor\n * \n * Executes the agentic transcription loop with tool calls.\n * Maintains conversation history for multi-turn tool usage.\n */\n\nimport { ToolContext, TranscriptionState } from './types';\nimport * as Registry from './registry';\nimport * as Reasoning from '../reasoning';\nimport * as Logging from '../logging';\n\nexport interface ContextChangeRecord {\n entityType: 'person' | 'project' | 'company' | 'term';\n entityId: string;\n entityName: string;\n action: 'created' | 'updated';\n details?: Record<string, unknown>;\n}\n\nexport interface ExecutorInstance {\n process(transcriptText: string): Promise<{\n enhancedText: string;\n state: TranscriptionState;\n toolsUsed: string[];\n iterations: number;\n totalTokens?: number;\n contextChanges?: ContextChangeRecord[];\n }>;\n}\n\n// Message types for conversation history\ninterface ConversationMessage {\n role: 'system' | 'user' | 'assistant' | 'tool';\n content: string;\n tool_call_id?: string;\n tool_calls?: Array<{ id: string; name: string; arguments: Record<string, unknown> }>;\n}\n\nexport const create = (\n reasoning: Reasoning.ReasoningInstance,\n ctx: ToolContext\n): ExecutorInstance => {\n const logger = Logging.getLogger();\n const registry = Registry.create(ctx);\n \n const process = async (transcriptText: string) => {\n const state: TranscriptionState = {\n originalText: transcriptText,\n correctedText: transcriptText,\n unknownEntities: [],\n resolvedEntities: new Map(),\n confidence: 0,\n };\n \n const toolsUsed: string[] = [];\n const contextChanges: ContextChangeRecord[] = [];\n let iterations = 0;\n let totalTokens = 0;\n const maxIterations = 15;\n \n // Conversation history for multi-turn\n const conversationHistory: ConversationMessage[] = [];\n \n // Build the system prompt\n const systemPrompt = `You are an intelligent transcription assistant. Your job is to:\n1. Analyze the transcript for names, projects, and companies\n2. Use the available tools to verify spellings and gather context\n3. Correct any misheard names or terms\n4. Determine the appropriate destination for this note\n5. Produce a clean, accurate Markdown transcript\n\nCRITICAL RULES:\n- This is NOT a summary. Preserve ALL content from the original transcript.\n- Only fix obvious transcription errors like misheard names.\n- When you have finished processing, output the COMPLETE corrected transcript as Markdown.\n- Do NOT say you don't have the transcript - it's in the conversation history.\n\nAvailable tools:\n- lookup_person: Find information about people (use for any name that might be misspelled)\n- lookup_project: Find project routing information \n- verify_spelling: Ask user about unknown terms (if interactive mode)\n- route_note: Determine where to file this note\n- store_context: Remember new information for future use`;\n\n // Add system message to history\n conversationHistory.push({ role: 'system', content: systemPrompt });\n \n // Add the initial user message with transcript\n const initialPrompt = `Here is the raw transcript to process:\n\n--- BEGIN TRANSCRIPT ---\n${transcriptText}\n--- END TRANSCRIPT ---\n\nPlease:\n1. Identify any names, companies, or technical terms that might be misspelled\n2. Use the lookup_person tool to verify spelling of any names you find\n3. Use route_note to determine the destination\n4. Then output the COMPLETE corrected transcript as clean Markdown\n\nRemember: preserve ALL content, only fix transcription errors.`;\n\n conversationHistory.push({ role: 'user', content: initialPrompt });\n\n try {\n // Initial reasoning call\n logger.debug('Starting agentic transcription - analyzing for names and routing...');\n let response = await reasoning.complete({\n systemPrompt,\n prompt: initialPrompt,\n tools: registry.getToolDefinitions(),\n maxIterations,\n });\n \n // Track token usage\n if (response.usage) {\n totalTokens += response.usage.totalTokens;\n }\n \n // Add assistant response to history\n conversationHistory.push({ \n role: 'assistant', \n content: response.content,\n tool_calls: response.toolCalls?.map(tc => ({\n id: tc.id,\n name: tc.name,\n arguments: tc.arguments,\n })),\n });\n \n // Iterative tool use loop\n while (response.toolCalls && response.toolCalls.length > 0 && iterations < maxIterations) {\n iterations++;\n logger.debug('Iteration %d: Processing %d tool calls...', iterations, response.toolCalls.length);\n \n // Collect tool results\n const toolResults: Array<{ id: string; name: string; result: string }> = [];\n \n // Execute each tool call\n for (const toolCall of response.toolCalls) {\n logger.debug('Executing tool: %s', toolCall.name);\n toolsUsed.push(toolCall.name);\n \n try {\n const result = await registry.executeTool(toolCall.name, toolCall.arguments);\n \n // Format result for the model\n const resultStr = JSON.stringify(result.data || { success: result.success, message: result.error || 'OK' });\n toolResults.push({ id: toolCall.id, name: toolCall.name, result: resultStr });\n \n logger.debug('Tool %s result: %s', toolCall.name, result.success ? 'success' : 'failed');\n \n // Handle results that need user input\n if (result.needsUserInput && ctx.interactiveMode && ctx.interactiveInstance) {\n logger.info('Interactive: %s requires clarification', toolCall.name);\n \n const termName = String(toolCall.arguments.name || toolCall.arguments.term || '');\n \n const clarification = await ctx.interactiveInstance.handleClarification({\n type: result.data?.clarificationType || 'general',\n term: result.data?.term || termName,\n context: result.userPrompt || '',\n suggestion: result.data?.suggestion,\n options: result.data?.options,\n });\n \n if (clarification.response) {\n state.resolvedEntities.set(termName, clarification.response);\n logger.info('Clarified: %s -> %s', termName, clarification.response);\n \n // Handle new project creation\n if (result.data?.clarificationType === 'new_project' && clarification.response.trim()) {\n const projectPath = clarification.response.trim();\n // Only create if user provided a path (not just pressed Enter)\n if (projectPath && projectPath !== termName) {\n const projectId = termName.toLowerCase().replace(/\\s+/g, '-');\n const newProject = {\n id: projectId,\n name: termName,\n type: 'project' as const,\n description: `Auto-created from transcript mentioning \"${termName}\"`,\n classification: {\n context_type: 'work' as const,\n explicit_phrases: [termName.toLowerCase()],\n },\n routing: {\n destination: projectPath,\n structure: 'month' as const,\n filename_options: ['date', 'time', 'subject'] as Array<'date' | 'time' | 'subject'>,\n },\n active: true,\n };\n \n try {\n await ctx.contextInstance.saveEntity(newProject);\n logger.info('Created new project: %s -> %s', termName, projectPath);\n \n // Record the context change\n contextChanges.push({\n entityType: 'project',\n entityId: projectId,\n entityName: termName,\n action: 'created',\n details: {\n destination: projectPath,\n routing: newProject.routing,\n },\n });\n \n // Update routing to use new project\n state.routeDecision = {\n projectId,\n destination: { path: projectPath, structure: 'month' },\n confidence: 1.0,\n signals: [{ type: 'explicit_phrase', value: termName, weight: 1.0 }],\n reasoning: `User created new project \"${termName}\" routing to ${projectPath}`,\n };\n } catch (error) {\n logger.warn('Failed to save new project: %s', error);\n }\n }\n }\n }\n }\n \n // Update state based on tool results\n if (result.data?.person) {\n state.resolvedEntities.set(result.data.person.name, result.data.suggestion);\n }\n if (result.data?.destination) {\n state.routeDecision = result.data;\n }\n \n } catch (error) {\n logger.error('Tool execution failed', { tool: toolCall.name, error });\n toolResults.push({ \n id: toolCall.id, \n name: toolCall.name, \n result: JSON.stringify({ error: String(error) }) \n });\n }\n }\n \n // Add tool results to history\n for (const tr of toolResults) {\n conversationHistory.push({\n role: 'tool',\n tool_call_id: tr.id,\n content: tr.result,\n });\n }\n \n // Build continuation prompt with full context\n const continuationPrompt = `Tool results received. Here's a reminder of your task:\n\nORIGINAL TRANSCRIPT (process this):\n--- BEGIN TRANSCRIPT ---\n${transcriptText}\n--- END TRANSCRIPT ---\n\nCorrections made so far: ${state.resolvedEntities.size > 0 ? Array.from(state.resolvedEntities.entries()).map(([k, v]) => `${k} -> ${v}`).join(', ') : 'none yet'}\n\nContinue analyzing. If you need more information, use the tools. \nWhen you're done with tool calls, output the COMPLETE corrected transcript as Markdown.\nDo NOT summarize - include ALL original content with corrections applied.`;\n\n conversationHistory.push({ role: 'user', content: continuationPrompt });\n \n // Continue conversation with full context\n response = await reasoning.complete({\n systemPrompt,\n prompt: continuationPrompt,\n tools: registry.getToolDefinitions(),\n });\n \n // Track token usage\n if (response.usage) {\n totalTokens += response.usage.totalTokens;\n }\n \n conversationHistory.push({ \n role: 'assistant', \n content: response.content,\n tool_calls: response.toolCalls?.map(tc => ({\n id: tc.id,\n name: tc.name,\n arguments: tc.arguments,\n })),\n });\n }\n \n // Extract final corrected text\n if (response.content && response.content.length > 50) {\n state.correctedText = response.content;\n state.confidence = 0.9;\n logger.debug('Final transcript generated: %d characters', response.content.length);\n } else {\n // Model didn't produce content - ask for it explicitly\n logger.debug('Model did not produce transcript, requesting explicitly...');\n \n const finalRequest = `Please output the COMPLETE corrected transcript now.\n\nORIGINAL:\n${transcriptText}\n\nCORRECTIONS TO APPLY:\n${state.resolvedEntities.size > 0 ? Array.from(state.resolvedEntities.entries()).map(([k, v]) => `- \"${k}\" should be \"${v}\"`).join('\\n') : 'None identified'}\n\nOutput the full transcript as clean Markdown. Do NOT summarize.`;\n\n const finalResponse = await reasoning.complete({\n systemPrompt,\n prompt: finalRequest,\n });\n \n // Track token usage\n if (finalResponse.usage) {\n totalTokens += finalResponse.usage.totalTokens;\n }\n \n state.correctedText = finalResponse.content || transcriptText;\n state.confidence = 0.8;\n }\n \n } catch (error) {\n logger.error('Agentic processing failed', { error });\n // Fall back to original text\n state.correctedText = transcriptText;\n state.confidence = 0.5;\n }\n \n return {\n enhancedText: state.correctedText,\n state,\n toolsUsed: [...new Set(toolsUsed)],\n iterations,\n totalTokens: totalTokens > 0 ? totalTokens : undefined,\n contextChanges: contextChanges.length > 0 ? contextChanges : undefined,\n };\n };\n \n return { process };\n};\n\n"],"names":["create","reasoning","ctx","logger","Logging","registry","Registry","process","transcriptText","state","originalText","correctedText","unknownEntities","resolvedEntities","Map","confidence","toolsUsed","contextChanges","iterations","totalTokens","maxIterations","conversationHistory","systemPrompt","push","role","content","initialPrompt","response","debug","complete","prompt","tools","getToolDefinitions","usage","tool_calls","toolCalls","map","tc","id","name","arguments","length","toolResults","toolCall","result","executeTool","resultStr","JSON","stringify","data","success","message","error","needsUserInput","interactiveMode","interactiveInstance","info","termName","String","term","clarification","handleClarification","type","clarificationType","context","userPrompt","suggestion","options","set","trim","projectPath","projectId","toLowerCase","replace","newProject","description","classification","context_type","explicit_phrases","routing","destination","structure","filename_options","active","contextInstance","saveEntity","entityType","entityId","entityName","action","details","routeDecision","path","signals","value","weight","warn","person","tool","tr","tool_call_id","continuationPrompt","size","Array","from","entries","k","v","join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
+
|
|
4
|
+
/**
|
|
5
|
+
* Create an agentic executor from a ToolContext
|
|
6
|
+
* This is the primary factory method - always agentic, no flags needed
|
|
7
|
+
*/ const create = (reasoning, toolContext)=>{
|
|
8
|
+
const executor = create$1(reasoning, toolContext);
|
|
9
|
+
return {
|
|
10
|
+
process: (transcriptText)=>executor.process(transcriptText),
|
|
11
|
+
getAvailableTools: ()=>{
|
|
12
|
+
const registry = create$2(toolContext);
|
|
13
|
+
return registry.getTools().map((t)=>t.name);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export { create };
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/agentic/index.ts"],"sourcesContent":["/**\n * Agentic Transcription System\n * \n * Main entry point for the agentic transcription system. Provides tool-based\n * enhancement of transcripts using reasoning models.\n * \n * The agentic approach means the model queries context via tools rather than\n * receiving all context upfront in the prompt. This allows for:\n * - Smaller prompt sizes\n * - More targeted context retrieval \n * - Better handling of large context sets\n */\n\nimport { ToolContext, TranscriptionState } from './types';\nimport * as Executor from './executor';\nimport * as Registry from './registry';\nimport * as Reasoning from '../reasoning';\n\nexport interface ContextChangeRecord {\n entityType: 'person' | 'project' | 'company' | 'term';\n entityId: string;\n entityName: string;\n action: 'created' | 'updated';\n details?: Record<string, unknown>;\n}\n\nexport interface AgenticInstance {\n process(transcriptText: string): Promise<{\n enhancedText: string;\n state: TranscriptionState;\n toolsUsed: string[];\n iterations: number;\n totalTokens?: number;\n contextChanges?: ContextChangeRecord[];\n }>;\n getAvailableTools(): string[];\n}\n\n/**\n * Create an agentic executor from a ToolContext\n * This is the primary factory method - always agentic, no flags needed\n */\nexport const create = (\n reasoning: Reasoning.ReasoningInstance,\n toolContext: ToolContext\n): AgenticInstance => {\n const executor = Executor.create(reasoning, toolContext);\n \n return {\n process: (transcriptText: string) => executor.process(transcriptText),\n \n getAvailableTools: () => {\n const registry = Registry.create(toolContext);\n return registry.getTools().map(t => t.name);\n },\n };\n};\n\n// Re-export types\nexport * from './types';\n\n"],"names":["create","reasoning","toolContext","executor","Executor","process","transcriptText","getAvailableTools","registry","Registry","getTools","map","t","name"],"mappings":";;;AAsCA;;;AAGC,IACM,MAAMA,MAAAA,GAAS,CAClBC,SAAAA,EACAC,WAAAA,GAAAA;AAEA,IAAA,MAAMC,QAAAA,GAAWC,QAAe,CAACH,SAAAA,EAAWC,WAAAA,CAAAA;IAE5C,OAAO;AACHG,QAAAA,OAAAA,EAAS,CAACC,cAAAA,GAA2BH,QAAAA,CAASE,OAAO,CAACC,cAAAA,CAAAA;QAEtDC,iBAAAA,EAAmB,IAAA;YACf,MAAMC,QAAAA,GAAWC,QAAe,CAACP,WAAAA,CAAAA;YACjC,OAAOM,QAAAA,CAASE,QAAQ,EAAA,CAAGC,GAAG,CAACC,CAAAA,CAAAA,GAAKA,EAAEC,IAAI,CAAA;AAC9C,QAAA;AACJ,KAAA;AACJ;;;;"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { create as create$1 } from './tools/lookup-person.js';
|
|
2
|
+
import { create as create$2 } from './tools/lookup-project.js';
|
|
3
|
+
import { create as create$3 } from './tools/verify-spelling.js';
|
|
4
|
+
import { create as create$4 } from './tools/route-note.js';
|
|
5
|
+
import { create as create$5 } from './tools/store-context.js';
|
|
6
|
+
|
|
7
|
+
const create = (ctx)=>{
|
|
8
|
+
const tools = [
|
|
9
|
+
create$1(ctx),
|
|
10
|
+
create$2(ctx),
|
|
11
|
+
create$3(ctx),
|
|
12
|
+
create$4(ctx),
|
|
13
|
+
create$5()
|
|
14
|
+
];
|
|
15
|
+
const toolMap = new Map(tools.map((t)=>[
|
|
16
|
+
t.name,
|
|
17
|
+
t
|
|
18
|
+
]));
|
|
19
|
+
return {
|
|
20
|
+
getTools: ()=>tools,
|
|
21
|
+
// Return flat tool definitions - reasoning client handles OpenAI formatting
|
|
22
|
+
getToolDefinitions: ()=>tools.map((tool)=>({
|
|
23
|
+
name: tool.name,
|
|
24
|
+
description: tool.description,
|
|
25
|
+
parameters: tool.parameters
|
|
26
|
+
})),
|
|
27
|
+
executeTool: async (name, args)=>{
|
|
28
|
+
const tool = toolMap.get(name);
|
|
29
|
+
if (!tool) {
|
|
30
|
+
return {
|
|
31
|
+
success: false,
|
|
32
|
+
error: `Unknown tool: ${name}`
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
return tool.execute(args);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export { create };
|
|
41
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sources":["../../src/agentic/registry.ts"],"sourcesContent":["/**\n * Tool Registry\n * \n * Manages available tools for agentic transcription.\n */\n\nimport { TranscriptionTool, ToolContext, ToolResult } from './types';\nimport * as LookupPerson from './tools/lookup-person';\nimport * as LookupProject from './tools/lookup-project';\nimport * as VerifySpelling from './tools/verify-spelling';\nimport * as RouteNote from './tools/route-note';\nimport * as StoreContext from './tools/store-context';\n\nexport interface RegistryInstance {\n getTools(): TranscriptionTool[];\n \n getToolDefinitions(): any[]; // For LLM API format\n \n executeTool(name: string, args: any): Promise<ToolResult>;\n}\n\nexport const create = (ctx: ToolContext): RegistryInstance => {\n const tools: TranscriptionTool[] = [\n LookupPerson.create(ctx),\n LookupProject.create(ctx),\n VerifySpelling.create(ctx),\n RouteNote.create(ctx),\n StoreContext.create(ctx),\n ];\n \n const toolMap = new Map(tools.map(t => [t.name, t]));\n \n return {\n getTools: () => tools,\n \n // Return flat tool definitions - reasoning client handles OpenAI formatting\n getToolDefinitions: () => tools.map(tool => ({\n name: tool.name,\n description: tool.description,\n parameters: tool.parameters,\n })),\n \n \n executeTool: async (name: string, args: any): Promise<ToolResult> => {\n const tool = toolMap.get(name);\n if (!tool) {\n return {\n success: false,\n error: `Unknown tool: ${name}`,\n };\n }\n return tool.execute(args);\n },\n };\n};\n\n"],"names":["create","ctx","tools","LookupPerson","LookupProject","VerifySpelling","RouteNote","StoreContext","toolMap","Map","map","t","name","getTools","getToolDefinitions","tool","description","parameters","executeTool","args","get","success","error","execute"],"mappings":";;;;;;AAqBO,MAAMA,SAAS,CAACC,GAAAA,GAAAA;AACnB,IAAA,MAAMC,KAAAA,GAA6B;AAC/BC,QAAAA,QAAmB,CAACF,GAAAA,CAAAA;AACpBG,QAAAA,QAAoB,CAACH,GAAAA,CAAAA;AACrBI,QAAAA,QAAqB,CAACJ,GAAAA,CAAAA;AACtBK,QAAAA,QAAgB,CAACL,GAAAA,CAAAA;AACjBM,QAAAA,QAAmB,CAACN;AACvB,KAAA;AAED,IAAA,MAAMO,UAAU,IAAIC,GAAAA,CAAIP,MAAMQ,GAAG,CAACC,CAAAA,CAAAA,GAAK;AAACA,YAAAA,CAAAA,CAAEC,IAAI;AAAED,YAAAA;AAAE,SAAA,CAAA,CAAA;IAElD,OAAO;AACHE,QAAAA,QAAAA,EAAU,IAAMX,KAAAA;;AAGhBY,QAAAA,kBAAAA,EAAoB,IAAMZ,KAAAA,CAAMQ,GAAG,CAACK,CAAAA,QAAS;AACzCH,oBAAAA,IAAAA,EAAMG,KAAKH,IAAI;AACfI,oBAAAA,WAAAA,EAAaD,KAAKC,WAAW;AAC7BC,oBAAAA,UAAAA,EAAYF,KAAKE;iBACrB,CAAA,CAAA;AAGAC,QAAAA,WAAAA,EAAa,OAAON,IAAAA,EAAcO,IAAAA,GAAAA;YAC9B,MAAMJ,IAAAA,GAAOP,OAAAA,CAAQY,GAAG,CAACR,IAAAA,CAAAA;AACzB,YAAA,IAAI,CAACG,IAAAA,EAAM;gBACP,OAAO;oBACHM,OAAAA,EAAS,KAAA;oBACTC,KAAAA,EAAO,CAAC,cAAc,EAAEV,IAAAA,CAAAA;AAC5B,iBAAA;AACJ,YAAA;YACA,OAAOG,IAAAA,CAAKQ,OAAO,CAACJ,IAAAA,CAAAA;AACxB,QAAA;AACJ,KAAA;AACJ;;;;"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lookup Person Tool
|
|
3
|
+
*
|
|
4
|
+
* Looks up information about a person mentioned in the transcript.
|
|
5
|
+
*/ const create = (ctx)=>({
|
|
6
|
+
name: 'lookup_person',
|
|
7
|
+
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.',
|
|
8
|
+
parameters: {
|
|
9
|
+
type: 'object',
|
|
10
|
+
properties: {
|
|
11
|
+
name: {
|
|
12
|
+
type: 'string',
|
|
13
|
+
description: 'The name to look up (as heard in transcript)'
|
|
14
|
+
},
|
|
15
|
+
phonetic: {
|
|
16
|
+
type: 'string',
|
|
17
|
+
description: 'How the name sounds (for alias matching)'
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
required: [
|
|
21
|
+
'name'
|
|
22
|
+
]
|
|
23
|
+
},
|
|
24
|
+
execute: async (args)=>{
|
|
25
|
+
const context = ctx.contextInstance;
|
|
26
|
+
// Try direct name search
|
|
27
|
+
const people = context.search(args.name);
|
|
28
|
+
const personMatches = people.filter((e)=>e.type === 'person');
|
|
29
|
+
if (personMatches.length > 0) {
|
|
30
|
+
return {
|
|
31
|
+
success: true,
|
|
32
|
+
data: {
|
|
33
|
+
found: true,
|
|
34
|
+
person: personMatches[0],
|
|
35
|
+
suggestion: `Use "${personMatches[0].name}" for correct spelling`
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
// Try phonetic match (sounds_like)
|
|
40
|
+
if (args.phonetic) {
|
|
41
|
+
const person = context.findBySoundsLike(args.phonetic);
|
|
42
|
+
if (person) {
|
|
43
|
+
return {
|
|
44
|
+
success: true,
|
|
45
|
+
data: {
|
|
46
|
+
found: true,
|
|
47
|
+
person,
|
|
48
|
+
suggestion: `"${args.phonetic}" likely refers to "${person.name}"`
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
// Not found
|
|
54
|
+
return {
|
|
55
|
+
success: true,
|
|
56
|
+
data: {
|
|
57
|
+
found: false,
|
|
58
|
+
needsVerification: true,
|
|
59
|
+
message: `Unknown person: "${args.name}". Consider asking for clarification.`
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
export { create };
|
|
66
|
+
//# sourceMappingURL=lookup-person.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lookup-person.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\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 // 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\n return {\n success: true,\n data: {\n found: false,\n needsVerification: true,\n message: `Unknown person: \"${args.name}\". Consider asking for clarification.`,\n },\n };\n },\n});\n\n"],"names":["create","ctx","name","description","parameters","type","properties","phonetic","required","execute","args","context","contextInstance","people","search","personMatches","filter","e","length","success","data","found","person","suggestion","findBySoundsLike","needsVerification","message"],"mappings":"AAAA;;;;AAIC,IAIM,MAAMA,MAAAA,GAAS,CAACC,OAAyC;QAC5DC,IAAAA,EAAM,eAAA;QACNC,WAAAA,EAAa,4JAAA;QACbC,UAAAA,EAAY;YACRC,IAAAA,EAAM,QAAA;YACNC,UAAAA,EAAY;gBACRJ,IAAAA,EAAM;oBACFG,IAAAA,EAAM,QAAA;oBACNF,WAAAA,EAAa;AACjB,iBAAA;gBACAI,QAAAA,EAAU;oBACNF,IAAAA,EAAM,QAAA;oBACNF,WAAAA,EAAa;AACjB;AACJ,aAAA;YACAK,QAAAA,EAAU;AAAC,gBAAA;AAAO;AACtB,SAAA;AACAC,QAAAA,OAAAA,EAAS,OAAOC,IAAAA,GAAAA;YACZ,MAAMC,OAAAA,GAAUV,IAAIW,eAAe;;AAGnC,YAAA,MAAMC,MAAAA,GAASF,OAAAA,CAAQG,MAAM,CAACJ,KAAKR,IAAI,CAAA;YACvC,MAAMa,aAAAA,GAAgBF,OAAOG,MAAM,CAACC,CAAAA,CAAAA,GAAKA,CAAAA,CAAEZ,IAAI,KAAK,QAAA,CAAA;YAEpD,IAAIU,aAAAA,CAAcG,MAAM,GAAG,CAAA,EAAG;gBAC1B,OAAO;oBACHC,OAAAA,EAAS,IAAA;oBACTC,IAAAA,EAAM;wBACFC,KAAAA,EAAO,IAAA;wBACPC,MAAAA,EAAQP,aAAa,CAAC,CAAA,CAAE;wBACxBQ,UAAAA,EAAY,CAAC,KAAK,EAAER,aAAa,CAAC,EAAE,CAACb,IAAI,CAAC,sBAAsB;AACpE;AACJ,iBAAA;AACJ,YAAA;;YAGA,IAAIQ,IAAAA,CAAKH,QAAQ,EAAE;AACf,gBAAA,MAAMe,MAAAA,GAASX,OAAAA,CAAQa,gBAAgB,CAACd,KAAKH,QAAQ,CAAA;AACrD,gBAAA,IAAIe,MAAAA,EAAQ;oBACR,OAAO;wBACHH,OAAAA,EAAS,IAAA;wBACTC,IAAAA,EAAM;4BACFC,KAAAA,EAAO,IAAA;AACPC,4BAAAA,MAAAA;AACAC,4BAAAA,UAAAA,EAAY,CAAC,CAAC,EAAEb,IAAAA,CAAKH,QAAQ,CAAC,oBAAoB,EAAEe,MAAAA,CAAOpB,IAAI,CAAC,CAAC;AACrE;AACJ,qBAAA;AACJ,gBAAA;AACJ,YAAA;;YAGA,OAAO;gBACHiB,OAAAA,EAAS,IAAA;gBACTC,IAAAA,EAAM;oBACFC,KAAAA,EAAO,KAAA;oBACPI,iBAAAA,EAAmB,IAAA;AACnBC,oBAAAA,OAAAA,EAAS,CAAC,iBAAiB,EAAEhB,KAAKR,IAAI,CAAC,qCAAqC;AAChF;AACJ,aAAA;AACJ,QAAA;AACJ,KAAA;;;;"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lookup Project Tool
|
|
3
|
+
*
|
|
4
|
+
* Looks up project information for routing and context.
|
|
5
|
+
* In interactive mode, prompts to create unknown projects.
|
|
6
|
+
*/ const create = (ctx)=>({
|
|
7
|
+
name: 'lookup_project',
|
|
8
|
+
description: 'Look up project information for routing and context. Use when you need to determine where this note should be filed.',
|
|
9
|
+
parameters: {
|
|
10
|
+
type: 'object',
|
|
11
|
+
properties: {
|
|
12
|
+
name: {
|
|
13
|
+
type: 'string',
|
|
14
|
+
description: 'The project name or identifier'
|
|
15
|
+
},
|
|
16
|
+
triggerPhrase: {
|
|
17
|
+
type: 'string',
|
|
18
|
+
description: 'A phrase from the transcript that might indicate the project'
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
required: [
|
|
22
|
+
'name'
|
|
23
|
+
]
|
|
24
|
+
},
|
|
25
|
+
execute: async (args)=>{
|
|
26
|
+
const context = ctx.contextInstance;
|
|
27
|
+
// Look up project by name
|
|
28
|
+
const projects = context.search(args.name);
|
|
29
|
+
const projectMatches = projects.filter((e)=>e.type === 'project');
|
|
30
|
+
if (projectMatches.length > 0) {
|
|
31
|
+
const project = projectMatches[0];
|
|
32
|
+
return {
|
|
33
|
+
success: true,
|
|
34
|
+
data: {
|
|
35
|
+
found: true,
|
|
36
|
+
project
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
// Try getting all projects and matching trigger phrases
|
|
41
|
+
if (args.triggerPhrase) {
|
|
42
|
+
const allProjects = context.getAllProjects();
|
|
43
|
+
for (const project of allProjects){
|
|
44
|
+
var _ref;
|
|
45
|
+
var _project_classification;
|
|
46
|
+
const phrases = (_ref = (_project_classification = project.classification) === null || _project_classification === void 0 ? void 0 : _project_classification.explicit_phrases) !== null && _ref !== void 0 ? _ref : [];
|
|
47
|
+
if (phrases.some((p)=>{
|
|
48
|
+
var _args_triggerPhrase;
|
|
49
|
+
return (_args_triggerPhrase = args.triggerPhrase) === null || _args_triggerPhrase === void 0 ? void 0 : _args_triggerPhrase.toLowerCase().includes(p.toLowerCase());
|
|
50
|
+
})) {
|
|
51
|
+
return {
|
|
52
|
+
success: true,
|
|
53
|
+
data: {
|
|
54
|
+
found: true,
|
|
55
|
+
project,
|
|
56
|
+
matchedTrigger: args.triggerPhrase
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
// Project not found - in interactive mode, ask about creating it
|
|
63
|
+
if (ctx.interactiveMode) {
|
|
64
|
+
return {
|
|
65
|
+
success: true,
|
|
66
|
+
needsUserInput: true,
|
|
67
|
+
userPrompt: `Unknown project: "${args.name}"
|
|
68
|
+
${args.triggerPhrase ? `Trigger phrase: "${args.triggerPhrase}"` : ''}
|
|
69
|
+
|
|
70
|
+
Is "${args.name}" a new project? If yes, where should notes about it be stored?
|
|
71
|
+
Enter a path (e.g., ~/notes/projects/wagner) or press Enter to use default routing:`,
|
|
72
|
+
data: {
|
|
73
|
+
found: false,
|
|
74
|
+
clarificationType: 'new_project',
|
|
75
|
+
term: args.name,
|
|
76
|
+
triggerPhrase: args.triggerPhrase,
|
|
77
|
+
message: `Project "${args.name}" not found. Asking user if this is a new project.`
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
// Non-interactive mode - just use default
|
|
82
|
+
return {
|
|
83
|
+
success: true,
|
|
84
|
+
data: {
|
|
85
|
+
found: false,
|
|
86
|
+
message: `No project found for "${args.name}". Will use default routing.`
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
export { create };
|
|
93
|
+
//# sourceMappingURL=lookup-project.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lookup-project.js","sources":["../../../src/agentic/tools/lookup-project.ts"],"sourcesContent":["/**\n * Lookup Project Tool\n * \n * Looks up project information for routing and context.\n * In interactive mode, prompts to create unknown projects.\n */\n\nimport { TranscriptionTool, ToolContext, ToolResult } from '../types';\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 // Look up project by name\n const projects = context.search(args.name);\n const projectMatches = projects.filter(e => e.type === 'project');\n \n if (projectMatches.length > 0) {\n const project = projectMatches[0];\n return {\n success: true,\n data: {\n found: true,\n project,\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 - in interactive mode, ask about creating it\n if (ctx.interactiveMode) {\n return {\n success: true,\n needsUserInput: true,\n userPrompt: `Unknown project: \"${args.name}\"\n${args.triggerPhrase ? `Trigger phrase: \"${args.triggerPhrase}\"` : ''}\n\nIs \"${args.name}\" a new project? If yes, where should notes about it be stored?\nEnter a path (e.g., ~/notes/projects/wagner) or press Enter to use default routing:`,\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 },\n };\n }\n \n // Non-interactive mode - just use default\n return {\n success: true,\n data: {\n found: false,\n message: `No project found for \"${args.name}\". Will use default routing.`,\n },\n };\n },\n});\n\n"],"names":["create","ctx","name","description","parameters","type","properties","triggerPhrase","required","execute","args","context","contextInstance","projects","search","projectMatches","filter","e","length","project","success","data","found","allProjects","getAllProjects","phrases","classification","explicit_phrases","some","p","toLowerCase","includes","matchedTrigger","interactiveMode","needsUserInput","userPrompt","clarificationType","term","message"],"mappings":"AAAA;;;;;AAKC,IAIM,MAAMA,MAAAA,GAAS,CAACC,OAAyC;QAC5DC,IAAAA,EAAM,gBAAA;QACNC,WAAAA,EAAa,sHAAA;QACbC,UAAAA,EAAY;YACRC,IAAAA,EAAM,QAAA;YACNC,UAAAA,EAAY;gBACRJ,IAAAA,EAAM;oBACFG,IAAAA,EAAM,QAAA;oBACNF,WAAAA,EAAa;AACjB,iBAAA;gBACAI,aAAAA,EAAe;oBACXF,IAAAA,EAAM,QAAA;oBACNF,WAAAA,EAAa;AACjB;AACJ,aAAA;YACAK,QAAAA,EAAU;AAAC,gBAAA;AAAO;AACtB,SAAA;AACAC,QAAAA,OAAAA,EAAS,OAAOC,IAAAA,GAAAA;YACZ,MAAMC,OAAAA,GAAUV,IAAIW,eAAe;;AAGnC,YAAA,MAAMC,QAAAA,GAAWF,OAAAA,CAAQG,MAAM,CAACJ,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