@minded-ai/mindedjs 1.0.120 → 1.0.122-beta-1
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/agent.d.ts +4 -1
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +70 -10
- package/dist/agent.js.map +1 -1
- package/dist/browserTask/README.md +419 -0
- package/dist/browserTask/browserAgent.py +632 -0
- package/dist/browserTask/captcha_isolated.png +0 -0
- package/dist/browserTask/executeBrowserTask.ts +79 -0
- package/dist/browserTask/requirements.txt +8 -0
- package/dist/browserTask/setup.sh +144 -0
- package/dist/cli/index.js +14 -14
- package/dist/cli/index.js.map +1 -1
- package/dist/edges/createLogicalRouter.js +1 -1
- package/dist/edges/createLogicalRouter.js.map +1 -1
- package/dist/edges/createPromptRouter.d.ts.map +1 -1
- package/dist/edges/createPromptRouter.js +0 -7
- package/dist/edges/createPromptRouter.js.map +1 -1
- package/dist/edges/edgeFactory.js +2 -2
- package/dist/edges/edgeFactory.js.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- package/dist/internalTools/retell.js +17 -7
- package/dist/internalTools/retell.js.map +1 -1
- package/dist/internalTools/sendPlaceholderMessage.js +17 -7
- package/dist/internalTools/sendPlaceholderMessage.js.map +1 -1
- package/dist/internalTools/voice/escalateVoiceCall.d.ts +2 -0
- package/dist/internalTools/voice/escalateVoiceCall.d.ts.map +1 -0
- package/dist/internalTools/voice/escalateVoiceCall.js +42 -0
- package/dist/internalTools/voice/escalateVoiceCall.js.map +1 -0
- package/dist/internalTools/voice/retell.d.ts +12 -0
- package/dist/internalTools/voice/retell.d.ts.map +1 -0
- package/dist/internalTools/voice/retell.js +44 -0
- package/dist/internalTools/voice/retell.js.map +1 -0
- package/dist/internalTools/voice/sendPlaceholderMessage.d.ts +14 -0
- package/dist/internalTools/voice/sendPlaceholderMessage.d.ts.map +1 -0
- package/dist/internalTools/voice/sendPlaceholderMessage.js +51 -0
- package/dist/internalTools/voice/sendPlaceholderMessage.js.map +1 -0
- package/dist/interrupts/BaseInterruptSessionManager.d.ts +52 -0
- package/dist/interrupts/BaseInterruptSessionManager.d.ts.map +1 -0
- package/dist/interrupts/BaseInterruptSessionManager.js +40 -0
- package/dist/interrupts/BaseInterruptSessionManager.js.map +1 -0
- package/dist/interrupts/MemoryInterruptSessionManager.d.ts +14 -0
- package/dist/interrupts/MemoryInterruptSessionManager.d.ts.map +1 -0
- package/dist/interrupts/MemoryInterruptSessionManager.js +60 -0
- package/dist/interrupts/MemoryInterruptSessionManager.js.map +1 -0
- package/dist/interrupts/MindedInterruptSessionManager.d.ts +13 -0
- package/dist/interrupts/MindedInterruptSessionManager.d.ts.map +1 -0
- package/dist/interrupts/MindedInterruptSessionManager.js +151 -0
- package/dist/interrupts/MindedInterruptSessionManager.js.map +1 -0
- package/dist/interrupts/interruptSessionManagerFactory.d.ts +3 -0
- package/dist/interrupts/interruptSessionManagerFactory.d.ts.map +1 -0
- package/dist/interrupts/interruptSessionManagerFactory.js +46 -0
- package/dist/interrupts/interruptSessionManagerFactory.js.map +1 -0
- package/dist/nodes/addAppToolNode.d.ts.map +1 -1
- package/dist/nodes/addAppToolNode.js +7 -13
- package/dist/nodes/addAppToolNode.js.map +1 -1
- package/dist/nodes/addBrowserTaskNode.d.ts.map +1 -1
- package/dist/nodes/addBrowserTaskNode.js +7 -74
- package/dist/nodes/addBrowserTaskNode.js.map +1 -1
- package/dist/nodes/addHumanInTheLoopNode.d.ts.map +1 -1
- package/dist/nodes/addHumanInTheLoopNode.js +2 -1
- package/dist/nodes/addHumanInTheLoopNode.js.map +1 -1
- package/dist/nodes/addJumpToNode.js +2 -2
- package/dist/nodes/addJumpToNode.js.map +1 -1
- package/dist/nodes/addPromptNode.d.ts.map +1 -1
- package/dist/nodes/addPromptNode.js +96 -13
- package/dist/nodes/addPromptNode.js.map +1 -1
- package/dist/nodes/addToolNode.d.ts.map +1 -1
- package/dist/nodes/addToolNode.js +12 -13
- package/dist/nodes/addToolNode.js.map +1 -1
- package/dist/nodes/addToolRunNode.d.ts.map +1 -1
- package/dist/nodes/addToolRunNode.js +4 -0
- package/dist/nodes/addToolRunNode.js.map +1 -1
- package/dist/nodes/compilePrompt.d.ts +5 -0
- package/dist/nodes/compilePrompt.d.ts.map +1 -0
- package/dist/nodes/compilePrompt.js +64 -0
- package/dist/nodes/compilePrompt.js.map +1 -0
- package/dist/platform/mindedConnection.js +12 -12
- package/dist/platform/mindedConnection.js.map +1 -1
- package/dist/platform/mindedConnectionTypes.d.ts +151 -1
- package/dist/platform/mindedConnectionTypes.d.ts.map +1 -1
- package/dist/platform/mindedConnectionTypes.js +9 -0
- package/dist/platform/mindedConnectionTypes.js.map +1 -1
- package/dist/playbooks/playbooks.d.ts +2 -2
- package/dist/playbooks/playbooks.d.ts.map +1 -1
- package/dist/playbooks/playbooks.js +37 -45
- package/dist/playbooks/playbooks.js.map +1 -1
- package/dist/types/Agent.types.d.ts +2 -0
- package/dist/types/Agent.types.d.ts.map +1 -1
- package/dist/types/Agent.types.js.map +1 -1
- package/dist/types/LangGraph.types.d.ts +2 -2
- package/dist/types/LangGraph.types.d.ts.map +1 -1
- package/dist/types/LangGraph.types.js +3 -1
- package/dist/types/LangGraph.types.js.map +1 -1
- package/dist/voice/voiceSession.d.ts +0 -1
- package/dist/voice/voiceSession.d.ts.map +1 -1
- package/dist/voice/voiceSession.js +9 -13
- package/dist/voice/voiceSession.js.map +1 -1
- package/docs/low-code-editor/nodes.md +21 -12
- package/docs/low-code-editor/playbooks.md +50 -32
- package/package.json +2 -2
- package/src/agent.ts +87 -13
- package/src/cli/index.ts +14 -14
- package/src/edges/createLogicalRouter.ts +1 -1
- package/src/edges/createPromptRouter.ts +5 -12
- package/src/edges/edgeFactory.ts +2 -2
- package/src/index.ts +4 -3
- package/src/internalTools/voice/escalateVoiceCall.ts +15 -0
- package/src/internalTools/{retell.ts → voice/retell.ts} +2 -2
- package/src/internalTools/{sendPlaceholderMessage.ts → voice/sendPlaceholderMessage.ts} +2 -2
- package/src/interrupts/BaseInterruptSessionManager.ts +96 -0
- package/src/interrupts/MemoryInterruptSessionManager.ts +63 -0
- package/src/interrupts/MindedInterruptSessionManager.ts +162 -0
- package/src/interrupts/interruptSessionManagerFactory.ts +20 -0
- package/src/nodes/addAppToolNode.ts +10 -13
- package/src/nodes/addBrowserTaskNode.ts +7 -56
- package/src/nodes/addHumanInTheLoopNode.ts +2 -1
- package/src/nodes/addJumpToNode.ts +2 -2
- package/src/nodes/addPromptNode.ts +104 -18
- package/src/nodes/addToolNode.ts +12 -14
- package/src/nodes/addToolRunNode.ts +4 -1
- package/src/nodes/compilePrompt.ts +41 -0
- package/src/platform/mindedConnection.ts +12 -12
- package/src/platform/mindedConnectionTypes.ts +187 -0
- package/src/playbooks/playbooks.ts +38 -48
- package/src/types/Agent.types.ts +2 -0
- package/src/types/LangGraph.types.ts +3 -1
- package/src/voice/voiceSession.ts +9 -14
|
@@ -100,33 +100,33 @@ const connect = async (token: string): Promise<void> => {
|
|
|
100
100
|
|
|
101
101
|
const checkReady = () => {
|
|
102
102
|
if (connected && ready) {
|
|
103
|
-
logger.info('\x1b[32mConnection with Minded platform is ready!\x1b[0m');
|
|
104
|
-
logger.info('\x1b[32mPress Ctrl+C to exit...');
|
|
103
|
+
logger.info({ msg: '\x1b[32mConnection with Minded platform is ready!\x1b[0m' });
|
|
104
|
+
logger.info({ msg: '\x1b[32mPress Ctrl+C to exit...' });
|
|
105
105
|
resolve();
|
|
106
106
|
}
|
|
107
107
|
};
|
|
108
108
|
|
|
109
109
|
// Connection event handlers
|
|
110
110
|
socket.on('connect', () => {
|
|
111
|
-
logger.info('Socket connected, waiting for server setup...');
|
|
111
|
+
logger.info({ msg: 'Socket connected, waiting for server setup...' });
|
|
112
112
|
connected = true;
|
|
113
113
|
checkReady();
|
|
114
114
|
});
|
|
115
115
|
|
|
116
116
|
// Listen for ready event from server
|
|
117
117
|
socket.on('sdk-socket-ready', (data: { agentId: string; orgName: string }) => {
|
|
118
|
-
logger.info('Server ready signal received', data);
|
|
118
|
+
logger.info({ msg: 'Server ready signal received', data });
|
|
119
119
|
ready = true;
|
|
120
120
|
checkReady();
|
|
121
121
|
});
|
|
122
122
|
|
|
123
123
|
socket.on('connect_error', () => {
|
|
124
|
-
logger.error('Failed to connect to minded platform');
|
|
124
|
+
logger.error({ msg: 'Failed to connect to minded platform' });
|
|
125
125
|
reject(new Error('Failed to connect to minded platform'));
|
|
126
126
|
});
|
|
127
127
|
|
|
128
128
|
socket.on('disconnect', () => {
|
|
129
|
-
logger.info('Disconnected from local debugging socket');
|
|
129
|
+
logger.info({ msg: 'Disconnected from local debugging socket' });
|
|
130
130
|
connected = false;
|
|
131
131
|
ready = false;
|
|
132
132
|
});
|
|
@@ -136,7 +136,7 @@ const connect = async (token: string): Promise<void> => {
|
|
|
136
136
|
logger.error({ msg: 'Server error:', error });
|
|
137
137
|
|
|
138
138
|
if (error.message.includes('Invalid token')) {
|
|
139
|
-
logger.info('Invalid token');
|
|
139
|
+
logger.info({ msg: 'Invalid token' });
|
|
140
140
|
|
|
141
141
|
// Disconnect current socket
|
|
142
142
|
if (socket?.connected) {
|
|
@@ -158,14 +158,14 @@ const connect = async (token: string): Promise<void> => {
|
|
|
158
158
|
}
|
|
159
159
|
});
|
|
160
160
|
} else {
|
|
161
|
-
console.warn({
|
|
161
|
+
console.warn({ msg: 'No listeners found for event', event });
|
|
162
162
|
}
|
|
163
163
|
});
|
|
164
164
|
|
|
165
165
|
// Handle process termination
|
|
166
166
|
process.on('SIGINT', () => {
|
|
167
167
|
if (socket?.connected) {
|
|
168
|
-
logger.info('\nDisconnecting...');
|
|
168
|
+
logger.info({ msg: '\nDisconnecting...' });
|
|
169
169
|
socket.disconnect();
|
|
170
170
|
}
|
|
171
171
|
process.exit(0);
|
|
@@ -183,17 +183,17 @@ export const start = async (): Promise<void> => {
|
|
|
183
183
|
|
|
184
184
|
export const disconnect = () => {
|
|
185
185
|
if (!socket) {
|
|
186
|
-
logger.warn('No socket connection to disconnect');
|
|
186
|
+
logger.warn({ msg: 'No socket connection to disconnect' });
|
|
187
187
|
return;
|
|
188
188
|
}
|
|
189
189
|
|
|
190
190
|
if (socket.connected) {
|
|
191
|
-
logger.info('Disconnecting from Minded platform...');
|
|
191
|
+
logger.info({ msg: 'Disconnecting from Minded platform...' });
|
|
192
192
|
socket.disconnect();
|
|
193
193
|
return;
|
|
194
194
|
}
|
|
195
195
|
|
|
196
|
-
logger.warn('Socket is already disconnected');
|
|
196
|
+
logger.warn({ msg: 'Socket is already disconnected' });
|
|
197
197
|
};
|
|
198
198
|
|
|
199
199
|
export const mindedConnection = {
|
|
@@ -42,6 +42,15 @@ export enum mindedConnectionSocketMessageType {
|
|
|
42
42
|
SDK_VERSION_MISMATCH = 'sdk-version-mismatch', // Browser Task
|
|
43
43
|
CREATE_BROWSER_SESSION = 'create-browser-session',
|
|
44
44
|
INVOKE_BROWSER_TASK = 'invoke-browser-task',
|
|
45
|
+
// Interrupt Session Management
|
|
46
|
+
INTERRUPT_SESSION_IS_PROCESSED = 'interrupt-session-is-processed',
|
|
47
|
+
INTERRUPT_SESSION_LOCK = 'interrupt-session-lock',
|
|
48
|
+
INTERRUPT_SESSION_RELEASE = 'interrupt-session-release',
|
|
49
|
+
INTERRUPT_SESSION_ENQUEUE = 'interrupt-session-enqueue',
|
|
50
|
+
INTERRUPT_SESSION_DEQUEUE_ALL = 'interrupt-session-dequeue-all',
|
|
51
|
+
INTERRUPT_SESSION_DEQUEUE = 'interrupt-session-dequeue',
|
|
52
|
+
INTERRUPT_SESSION_HAS_MESSAGES = 'interrupt-session-has-messages',
|
|
53
|
+
INTERRUPT_SESSION_GET_MESSAGES = 'interrupt-session-get-messages',
|
|
45
54
|
}
|
|
46
55
|
|
|
47
56
|
export type mindedConnectionSocketMessageTypeMap = {
|
|
@@ -73,6 +82,15 @@ export type mindedConnectionSocketMessageTypeMap = {
|
|
|
73
82
|
[mindedConnectionSocketMessageType.UPDATE_STATE]: UpdateStateRequest;
|
|
74
83
|
[mindedConnectionSocketMessageType.CREATE_BROWSER_SESSION]: CreateBrowserSessionRequest;
|
|
75
84
|
[mindedConnectionSocketMessageType.INVOKE_BROWSER_TASK]: InvokeBrowserTaskRequest;
|
|
85
|
+
// Interrupt Session Management
|
|
86
|
+
[mindedConnectionSocketMessageType.INTERRUPT_SESSION_IS_PROCESSED]: InterruptSessionIsProcessedRequest;
|
|
87
|
+
[mindedConnectionSocketMessageType.INTERRUPT_SESSION_LOCK]: InterruptSessionLockRequest;
|
|
88
|
+
[mindedConnectionSocketMessageType.INTERRUPT_SESSION_RELEASE]: InterruptSessionReleaseRequest;
|
|
89
|
+
[mindedConnectionSocketMessageType.INTERRUPT_SESSION_ENQUEUE]: InterruptSessionEnqueueRequest;
|
|
90
|
+
[mindedConnectionSocketMessageType.INTERRUPT_SESSION_DEQUEUE_ALL]: InterruptSessionDequeueAllRequest;
|
|
91
|
+
[mindedConnectionSocketMessageType.INTERRUPT_SESSION_DEQUEUE]: InterruptSessionDequeueRequest;
|
|
92
|
+
[mindedConnectionSocketMessageType.INTERRUPT_SESSION_HAS_MESSAGES]: InterruptSessionHasMessagesRequest;
|
|
93
|
+
[mindedConnectionSocketMessageType.INTERRUPT_SESSION_GET_MESSAGES]: InterruptSessionGetMessagesRequest;
|
|
76
94
|
};
|
|
77
95
|
|
|
78
96
|
export interface BasemindedConnectionSocketMessage {
|
|
@@ -206,6 +224,175 @@ export interface TimerTriggerRequest extends BasemindedConnectionSocketMessage {
|
|
|
206
224
|
eventArgs: Record<string, any>;
|
|
207
225
|
}
|
|
208
226
|
|
|
227
|
+
// Interrupt Session Management Interfaces
|
|
228
|
+
export interface InterruptSessionIsProcessedRequest extends BasemindedConnectionSocketMessage {
|
|
229
|
+
sessionId: string;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
export interface InterruptSessionIsProcessedResponse extends BaseSdkConnectionSocketMessageResponseCallbackAck {
|
|
233
|
+
isProcessed?: boolean;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export interface InterruptSessionLockRequest extends BasemindedConnectionSocketMessage {
|
|
237
|
+
sessionId: string;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
export interface InterruptSessionLockResponse extends BaseSdkConnectionSocketMessageResponseCallbackAck {
|
|
241
|
+
lockAcquired?: boolean;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
export interface InterruptSessionReleaseRequest extends BasemindedConnectionSocketMessage {
|
|
245
|
+
sessionId: string;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
export interface InterruptSessionReleaseResponse extends BaseSdkConnectionSocketMessageResponseCallbackAck {
|
|
249
|
+
success?: boolean;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export interface InterruptSessionEnqueueRequest extends BasemindedConnectionSocketMessage {
|
|
253
|
+
sessionId: string;
|
|
254
|
+
message: {
|
|
255
|
+
triggerBody: any;
|
|
256
|
+
triggerName: string;
|
|
257
|
+
appName?: string;
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
export interface InterruptSessionEnqueueResponse extends BaseSdkConnectionSocketMessageResponseCallbackAck {
|
|
262
|
+
success?: boolean;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
export interface InterruptSessionDequeueAllRequest extends BasemindedConnectionSocketMessage {
|
|
266
|
+
sessionId: string;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
export interface InterruptSessionDequeueAllResponse extends BaseSdkConnectionSocketMessageResponseCallbackAck {
|
|
270
|
+
messages?: Array<{
|
|
271
|
+
triggerBody: any;
|
|
272
|
+
triggerName: string;
|
|
273
|
+
appName?: string;
|
|
274
|
+
}>;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
export interface InterruptSessionDequeueRequest extends BasemindedConnectionSocketMessage {
|
|
278
|
+
sessionId: string;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
export interface InterruptSessionDequeueResponse extends BaseSdkConnectionSocketMessageResponseCallbackAck {
|
|
282
|
+
message?: {
|
|
283
|
+
triggerBody: any;
|
|
284
|
+
triggerName: string;
|
|
285
|
+
appName?: string;
|
|
286
|
+
} | null;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
export interface InterruptSessionHasMessagesRequest extends BasemindedConnectionSocketMessage {
|
|
290
|
+
sessionId: string;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
export interface InterruptSessionHasMessagesResponse extends BaseSdkConnectionSocketMessageResponseCallbackAck {
|
|
294
|
+
hasMessages?: boolean;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
export interface InterruptSessionGetMessagesRequest extends BasemindedConnectionSocketMessage {
|
|
298
|
+
sessionId: string;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
export interface InterruptSessionGetMessagesResponse extends BaseSdkConnectionSocketMessageResponseCallbackAck {
|
|
302
|
+
messages?: Array<{
|
|
303
|
+
triggerBody: any;
|
|
304
|
+
triggerName: string;
|
|
305
|
+
appName?: string;
|
|
306
|
+
}>;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
// Interrupt Session Management Interfaces
|
|
310
|
+
export interface InterruptSessionIsProcessedRequest extends BasemindedConnectionSocketMessage {
|
|
311
|
+
sessionId: string;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
export interface InterruptSessionIsProcessedResponse extends BaseSdkConnectionSocketMessageResponseCallbackAck {
|
|
315
|
+
isProcessed?: boolean;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
export interface InterruptSessionLockRequest extends BasemindedConnectionSocketMessage {
|
|
319
|
+
sessionId: string;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
export interface InterruptSessionReleaseRequest extends BasemindedConnectionSocketMessage {
|
|
323
|
+
sessionId: string;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
export interface InterruptSessionReleaseResponse extends BaseSdkConnectionSocketMessageResponseCallbackAck {
|
|
327
|
+
success?: boolean;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
export interface InterruptSessionEnqueueRequest extends BasemindedConnectionSocketMessage {
|
|
331
|
+
sessionId: string;
|
|
332
|
+
message: {
|
|
333
|
+
triggerBody: any;
|
|
334
|
+
triggerName: string;
|
|
335
|
+
appName?: string;
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
export interface InterruptSessionEnqueueResponse extends BaseSdkConnectionSocketMessageResponseCallbackAck {
|
|
340
|
+
success?: boolean;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
export interface InterruptSessionDequeueAllRequest extends BasemindedConnectionSocketMessage {
|
|
344
|
+
sessionId: string;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
export interface InterruptSessionDequeueAllResponse extends BaseSdkConnectionSocketMessageResponseCallbackAck {
|
|
348
|
+
messages?: Array<{
|
|
349
|
+
triggerBody: any;
|
|
350
|
+
triggerName: string;
|
|
351
|
+
appName?: string;
|
|
352
|
+
}>;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
export interface InterruptSessionDequeueRequest extends BasemindedConnectionSocketMessage {
|
|
356
|
+
sessionId: string;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
export interface InterruptSessionDequeueResponse extends BaseSdkConnectionSocketMessageResponseCallbackAck {
|
|
360
|
+
message?: {
|
|
361
|
+
triggerBody: any;
|
|
362
|
+
triggerName: string;
|
|
363
|
+
appName?: string;
|
|
364
|
+
} | null;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
export interface InterruptSessionHasMessagesRequest extends BasemindedConnectionSocketMessage {
|
|
368
|
+
sessionId: string;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
export interface InterruptSessionHasMessagesResponse extends BaseSdkConnectionSocketMessageResponseCallbackAck {
|
|
372
|
+
hasMessages?: boolean;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
export interface InterruptSessionGetMessagesRequest extends BasemindedConnectionSocketMessage {
|
|
376
|
+
sessionId: string;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
export interface InterruptSessionGetMessagesResponse extends BaseSdkConnectionSocketMessageResponseCallbackAck {
|
|
380
|
+
messages?: Array<{
|
|
381
|
+
triggerBody: any;
|
|
382
|
+
triggerName: string;
|
|
383
|
+
appName?: string;
|
|
384
|
+
}>;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
export interface RestoreCheckpointRequest extends BasemindedConnectionSocketMessage {
|
|
388
|
+
sessionId: string;
|
|
389
|
+
checkpointId: string;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
export interface RestoreCheckpointResponse extends BaseSdkConnectionSocketMessageResponseCallbackAck {
|
|
393
|
+
success?: boolean;
|
|
394
|
+
}
|
|
395
|
+
|
|
209
396
|
export interface RestoreCheckpointRequest extends BasemindedConnectionSocketMessage {
|
|
210
397
|
sessionId: string;
|
|
211
398
|
checkpointId: string;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as fs from 'fs';
|
|
2
2
|
import * as path from 'path';
|
|
3
3
|
import * as yaml from 'js-yaml';
|
|
4
|
-
import * as ejs from 'ejs';
|
|
5
4
|
import * as mindedConnection from '../platform/mindedConnection';
|
|
6
5
|
import { mindedConnectionSocketMessageType } from '../platform/mindedConnectionTypes';
|
|
7
6
|
import { getConfig } from '../platform/config';
|
|
@@ -14,6 +13,26 @@ export type Playbook = {
|
|
|
14
13
|
blocks: OutputBlockData[];
|
|
15
14
|
};
|
|
16
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Decode HTML entities in a string
|
|
18
|
+
*/
|
|
19
|
+
function decodeHtmlEntities(text: string): string {
|
|
20
|
+
const entities: Record<string, string> = {
|
|
21
|
+
'&': '&',
|
|
22
|
+
'<': '<',
|
|
23
|
+
'>': '>',
|
|
24
|
+
'"': '"',
|
|
25
|
+
''': "'",
|
|
26
|
+
''': "'",
|
|
27
|
+
''': "'",
|
|
28
|
+
'/': '/',
|
|
29
|
+
'`': '`',
|
|
30
|
+
'=': '=',
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
return text.replace(/&[#\w]+;/g, (entity) => entities[entity] || entity);
|
|
34
|
+
}
|
|
35
|
+
|
|
17
36
|
/**
|
|
18
37
|
* Convert EditorJS blocks to markdown
|
|
19
38
|
*/
|
|
@@ -29,11 +48,13 @@ function editorJsToMarkdown(blocks: OutputBlockData[]): string {
|
|
|
29
48
|
case 'header': {
|
|
30
49
|
const level = block.data?.level || 1;
|
|
31
50
|
const headerPrefix = '#'.repeat(level);
|
|
32
|
-
|
|
51
|
+
const text = block.data?.text || '';
|
|
52
|
+
return `${headerPrefix} ${decodeHtmlEntities(text)}`;
|
|
33
53
|
}
|
|
34
54
|
|
|
35
55
|
case 'paragraph': {
|
|
36
|
-
|
|
56
|
+
const text = block.data?.text || '';
|
|
57
|
+
return decodeHtmlEntities(text);
|
|
37
58
|
}
|
|
38
59
|
|
|
39
60
|
case 'list': {
|
|
@@ -41,10 +62,11 @@ function editorJsToMarkdown(blocks: OutputBlockData[]): string {
|
|
|
41
62
|
const style = block.data?.style || 'unordered';
|
|
42
63
|
return items
|
|
43
64
|
.map((item: string, index: number) => {
|
|
65
|
+
const decodedItem = decodeHtmlEntities(item);
|
|
44
66
|
if (style === 'ordered') {
|
|
45
|
-
return `${index + 1}. ${
|
|
67
|
+
return `${index + 1}. ${decodedItem}`;
|
|
46
68
|
} else {
|
|
47
|
-
return `- ${
|
|
69
|
+
return `- ${decodedItem}`;
|
|
48
70
|
}
|
|
49
71
|
})
|
|
50
72
|
.join('\n');
|
|
@@ -52,13 +74,13 @@ function editorJsToMarkdown(blocks: OutputBlockData[]): string {
|
|
|
52
74
|
|
|
53
75
|
case 'quote': {
|
|
54
76
|
const text = block.data?.text || '';
|
|
55
|
-
const caption = block.data?.caption ? `\n*${block.data.caption}*` : '';
|
|
56
|
-
return `> ${text}${caption}`;
|
|
77
|
+
const caption = block.data?.caption ? `\n*${decodeHtmlEntities(block.data.caption)}*` : '';
|
|
78
|
+
return `> ${decodeHtmlEntities(text)}${caption}`;
|
|
57
79
|
}
|
|
58
80
|
|
|
59
81
|
case 'code': {
|
|
60
82
|
const code = block.data?.code || '';
|
|
61
|
-
return `\`\`\`\n${code}\n\`\`\``;
|
|
83
|
+
return `\`\`\`\n${decodeHtmlEntities(code)}\n\`\`\``;
|
|
62
84
|
}
|
|
63
85
|
|
|
64
86
|
case 'delimiter': {
|
|
@@ -71,7 +93,7 @@ function editorJsToMarkdown(blocks: OutputBlockData[]): string {
|
|
|
71
93
|
}
|
|
72
94
|
}
|
|
73
95
|
} catch (error) {
|
|
74
|
-
logger.error({
|
|
96
|
+
logger.error({ msg: 'Error converting EditorJS blocks to markdown', error, block });
|
|
75
97
|
throw error;
|
|
76
98
|
}
|
|
77
99
|
})
|
|
@@ -113,7 +135,7 @@ function loadPlaybooksFromDirectories(directories: string[]): Playbook[] {
|
|
|
113
135
|
|
|
114
136
|
for (const directory of directories) {
|
|
115
137
|
if (!fs.existsSync(directory)) {
|
|
116
|
-
logger.info(`Playbooks directory does not exist: ${directory}`);
|
|
138
|
+
logger.info({ msg: `Playbooks directory does not exist: ${directory}` });
|
|
117
139
|
continue;
|
|
118
140
|
}
|
|
119
141
|
|
|
@@ -126,12 +148,12 @@ function loadPlaybooksFromDirectories(directories: string[]): Playbook[] {
|
|
|
126
148
|
|
|
127
149
|
if (playbook && playbook.name && playbook.blocks) {
|
|
128
150
|
playbooks.push(playbook);
|
|
129
|
-
logger.info(`Loaded playbook: ${playbook.name} from ${file}`);
|
|
151
|
+
logger.info({ msg: `Loaded playbook: ${playbook.name} from ${file}` });
|
|
130
152
|
} else {
|
|
131
|
-
logger.warn(`Invalid playbook structure in ${file}`);
|
|
153
|
+
logger.warn({ msg: `Invalid playbook structure in ${file}` });
|
|
132
154
|
}
|
|
133
155
|
} catch (error) {
|
|
134
|
-
logger.error(`Failed to load playbook file ${file}: ${error}`);
|
|
156
|
+
logger.error({ msg: `Failed to load playbook file ${file}: ${error}` });
|
|
135
157
|
}
|
|
136
158
|
}
|
|
137
159
|
}
|
|
@@ -159,9 +181,9 @@ function getAllYamlFiles(dir: string): string[] {
|
|
|
159
181
|
}
|
|
160
182
|
|
|
161
183
|
/**
|
|
162
|
-
*
|
|
184
|
+
* Combine playbooks into a single string
|
|
163
185
|
*/
|
|
164
|
-
export function
|
|
186
|
+
export function combinePlaybooks(playbooks: Playbook[]): string {
|
|
165
187
|
if (playbooks.length === 0) {
|
|
166
188
|
return '';
|
|
167
189
|
}
|
|
@@ -173,37 +195,5 @@ export function compilePlaybooks(playbooks: Playbook[], params: Record<string, a
|
|
|
173
195
|
});
|
|
174
196
|
|
|
175
197
|
const combinedPlaybooks = sections.join('\n\n');
|
|
176
|
-
|
|
177
|
-
try {
|
|
178
|
-
// First, render with EJS
|
|
179
|
-
let compiledPlaybooks = ejs.render(combinedPlaybooks, params);
|
|
180
|
-
|
|
181
|
-
// Then, replace placeholders in {} format
|
|
182
|
-
compiledPlaybooks = replacePlaceholders(compiledPlaybooks, params);
|
|
183
|
-
|
|
184
|
-
return compiledPlaybooks;
|
|
185
|
-
} catch (error) {
|
|
186
|
-
logger.error({ message: 'Error compiling playbooks', error });
|
|
187
|
-
return combinedPlaybooks; // Return uncompiled if there's an error
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* Replace placeholders in {key} format
|
|
193
|
-
*/
|
|
194
|
-
function replacePlaceholders(text: string, params: Record<string, any>): string {
|
|
195
|
-
return text.replace(/\{([^}]+)\}/g, (match, key) => {
|
|
196
|
-
const keys = key.split('.');
|
|
197
|
-
let value: any = params;
|
|
198
|
-
|
|
199
|
-
for (const k of keys) {
|
|
200
|
-
if (value && typeof value === 'object' && k in value) {
|
|
201
|
-
value = value[k];
|
|
202
|
-
} else {
|
|
203
|
-
return match; // Return original if key not found
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
return String(value);
|
|
208
|
-
});
|
|
198
|
+
return combinedPlaybooks;
|
|
209
199
|
}
|
package/src/types/Agent.types.ts
CHANGED
|
@@ -29,6 +29,8 @@ export interface AgentInvokeParams {
|
|
|
29
29
|
sessionId?: string;
|
|
30
30
|
/** Optional name of the application triggering the agent in case of an app trigger */
|
|
31
31
|
appName?: string;
|
|
32
|
+
/** Internal flag to bypass session processing check for recursive calls */
|
|
33
|
+
bypassSessionCheck?: boolean;
|
|
32
34
|
}
|
|
33
35
|
export interface HistoryStep {
|
|
34
36
|
type: NodeType;
|
|
@@ -30,7 +30,9 @@ export const createStateAnnotation = <Memory = any>() =>
|
|
|
30
30
|
default: () => [],
|
|
31
31
|
reducer: (a, b) => a.concat(b),
|
|
32
32
|
}),
|
|
33
|
-
sessionId: Annotation<string>(
|
|
33
|
+
sessionId: Annotation<string>({
|
|
34
|
+
reducer: (a, b) => b || a,
|
|
35
|
+
}),
|
|
34
36
|
goto: Annotation<string | null | undefined>({
|
|
35
37
|
default: () => null,
|
|
36
38
|
reducer: (a, b) => b,
|
|
@@ -8,6 +8,7 @@ import { AIMessage, BaseMessage, HumanMessage } from '@langchain/core/messages';
|
|
|
8
8
|
import { v4 as uuidv4 } from 'uuid';
|
|
9
9
|
import { logger } from '../utils/logger';
|
|
10
10
|
import { SessionType } from '../types/Agent.types';
|
|
11
|
+
import { QUEUE_INTERRUPT_DETECTED_BEFORE_SPEECH } from '../interrupts/BaseInterruptSessionManager';
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Voice Conversation class for managing individual ElevenLabs voice conversations
|
|
@@ -157,6 +158,12 @@ export class VoiceSession {
|
|
|
157
158
|
break;
|
|
158
159
|
case 'interruption':
|
|
159
160
|
logger.debug({ msg: '[Voice] Received interruption' });
|
|
161
|
+
if (await this.agent.interruptSessionManager.isProcessed(this.sessionId)) {
|
|
162
|
+
await this.agent.interruptSessionManager.enqueueMessage(this.sessionId, {
|
|
163
|
+
triggerBody: {},
|
|
164
|
+
triggerName: QUEUE_INTERRUPT_DETECTED_BEFORE_SPEECH,
|
|
165
|
+
});
|
|
166
|
+
}
|
|
160
167
|
this.onInterruptionCallback?.();
|
|
161
168
|
// Send interruption event to dashboard if connected
|
|
162
169
|
if (getConfig().dashboardConnected) {
|
|
@@ -225,9 +232,10 @@ export class VoiceSession {
|
|
|
225
232
|
}
|
|
226
233
|
|
|
227
234
|
private async updateAgentResponse(originalAgentResponse: string, correctedAgentResponse: string): Promise<void> {
|
|
235
|
+
const cleanedOriginalAgentResponse = originalAgentResponse.replace('... ', '');
|
|
228
236
|
const graphState = await this.agent.compiledGraph.getState(this.agent.getLangraphConfig(this.sessionId));
|
|
229
237
|
const agentMessage: AIMessage | null = graphState.values.messages.find(
|
|
230
|
-
(message: BaseMessage) => message.content ===
|
|
238
|
+
(message: BaseMessage) => message.content === cleanedOriginalAgentResponse && message instanceof AIMessage,
|
|
231
239
|
);
|
|
232
240
|
if (agentMessage) {
|
|
233
241
|
agentMessage.content = correctedAgentResponse;
|
|
@@ -252,19 +260,6 @@ export class VoiceSession {
|
|
|
252
260
|
this.elevenLabsSocket?.close();
|
|
253
261
|
}
|
|
254
262
|
|
|
255
|
-
/*
|
|
256
|
-
* Escalate the voice session
|
|
257
|
-
* @param parameters - The parameters to escalate the voice session. Parameters will be handeled differently according to the VOIP provider.
|
|
258
|
-
*/
|
|
259
|
-
public escalate(parameters: any): void {
|
|
260
|
-
mindedConnection.emit(mindedConnectionSocketMessageType.VOICE_ESCALATE, {
|
|
261
|
-
type: mindedConnectionSocketMessageType.VOICE_ESCALATE,
|
|
262
|
-
sessionId: this.sessionId,
|
|
263
|
-
timestamp: Date.now(),
|
|
264
|
-
parameters,
|
|
265
|
-
});
|
|
266
|
-
}
|
|
267
|
-
|
|
268
263
|
/*
|
|
269
264
|
* Set callback for audio data in base64 format
|
|
270
265
|
* @param callback - The callback to handle the audio data
|