@minded-ai/mindedjs 1.0.151-beta-1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent.d.ts +2 -2
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +33 -55
- package/dist/agent.js.map +1 -1
- package/dist/edges/createLogicalRouter.d.ts.map +1 -1
- package/dist/edges/createLogicalRouter.js +4 -18
- package/dist/edges/createLogicalRouter.js.map +1 -1
- package/dist/events/AgentEvents.d.ts +5 -14
- package/dist/events/AgentEvents.d.ts.map +1 -1
- package/dist/internalTools/libraryActionRunnerTool.d.ts.map +1 -1
- package/dist/internalTools/libraryActionRunnerTool.js +0 -1
- package/dist/internalTools/libraryActionRunnerTool.js.map +1 -1
- package/dist/interrupts/BaseInterruptSessionManager.d.ts +2 -2
- package/dist/interrupts/BaseInterruptSessionManager.d.ts.map +1 -1
- package/dist/interrupts/BaseInterruptSessionManager.js +1 -7
- package/dist/interrupts/BaseInterruptSessionManager.js.map +1 -1
- package/dist/nodes/addAppToolNode.d.ts.map +1 -1
- package/dist/nodes/addAppToolNode.js +24 -18
- package/dist/nodes/addAppToolNode.js.map +1 -1
- package/dist/nodes/addBrowserTaskNode.d.ts.map +1 -1
- package/dist/nodes/addBrowserTaskNode.js +30 -27
- package/dist/nodes/addBrowserTaskNode.js.map +1 -1
- package/dist/nodes/addBrowserTaskRunNode.d.ts.map +1 -1
- package/dist/nodes/addBrowserTaskRunNode.js +18 -20
- package/dist/nodes/addBrowserTaskRunNode.js.map +1 -1
- package/dist/nodes/addJumpToNode.d.ts.map +1 -1
- package/dist/nodes/addJumpToNode.js +8 -9
- package/dist/nodes/addJumpToNode.js.map +1 -1
- package/dist/nodes/addJunctionNode.d.ts.map +1 -1
- package/dist/nodes/addJunctionNode.js +8 -9
- package/dist/nodes/addJunctionNode.js.map +1 -1
- package/dist/nodes/addPromptNode.d.ts.map +1 -1
- package/dist/nodes/addPromptNode.js +107 -270
- package/dist/nodes/addPromptNode.js.map +1 -1
- package/dist/nodes/addToolNode.d.ts.map +1 -1
- package/dist/nodes/addToolNode.js +33 -20
- package/dist/nodes/addToolNode.js.map +1 -1
- package/dist/nodes/addToolRunNode.d.ts.map +1 -1
- package/dist/nodes/addToolRunNode.js +15 -21
- package/dist/nodes/addToolRunNode.js.map +1 -1
- package/dist/nodes/addTriggerNode.js +9 -11
- package/dist/nodes/addTriggerNode.js.map +1 -1
- package/dist/nodes/compilePrompt.d.ts.map +1 -1
- package/dist/nodes/compilePrompt.js +2 -0
- package/dist/nodes/compilePrompt.js.map +1 -1
- package/dist/platform/mindedCheckpointSaver.js.map +1 -1
- package/dist/platform/toolExecutor.d.ts.map +1 -1
- package/dist/platform/toolExecutor.js +4 -20
- package/dist/platform/toolExecutor.js.map +1 -1
- package/dist/playbooks/playbooks.d.ts +1 -1
- package/dist/playbooks/playbooks.d.ts.map +1 -1
- package/dist/playbooks/playbooks.js +1 -1
- package/dist/playbooks/playbooks.js.map +1 -1
- package/dist/toolsLibrary/classifier.d.ts.map +1 -1
- package/dist/toolsLibrary/classifier.js +5 -9
- package/dist/toolsLibrary/classifier.js.map +1 -1
- package/dist/toolsLibrary/extraction.d.ts.map +1 -1
- package/dist/toolsLibrary/extraction.js +5 -9
- package/dist/toolsLibrary/extraction.js.map +1 -1
- package/dist/toolsLibrary/parseDocument.d.ts.map +1 -1
- package/dist/toolsLibrary/parseDocument.js +6 -14
- package/dist/toolsLibrary/parseDocument.js.map +1 -1
- package/dist/types/Agent.types.d.ts +1 -1
- package/dist/types/Agent.types.d.ts.map +1 -1
- package/dist/types/LangGraph.types.d.ts.map +1 -1
- package/dist/types/LangGraph.types.js +30 -42
- package/dist/types/LangGraph.types.js.map +1 -1
- package/dist/types/Tools.types.d.ts +2 -7
- package/dist/types/Tools.types.d.ts.map +1 -1
- package/docs/sdk/agent-api.md +1 -1
- package/package.json +1 -1
- package/src/agent.ts +37 -63
- package/src/edges/createLogicalRouter.ts +4 -19
- package/src/events/AgentEvents.ts +5 -14
- package/src/internalTools/libraryActionRunnerTool.ts +0 -1
- package/src/interrupts/BaseInterruptSessionManager.ts +3 -9
- package/src/nodes/addAppToolNode.ts +19 -11
- package/src/nodes/addBrowserTaskNode.ts +22 -16
- package/src/nodes/addBrowserTaskRunNode.ts +10 -9
- package/src/nodes/addJumpToNode.ts +5 -4
- package/src/nodes/addJunctionNode.ts +5 -4
- package/src/nodes/addPromptNode.ts +107 -299
- package/src/nodes/addToolNode.ts +34 -20
- package/src/nodes/addToolRunNode.ts +15 -15
- package/src/nodes/addTriggerNode.ts +5 -5
- package/src/nodes/compilePrompt.ts +3 -0
- package/src/platform/mindedCheckpointSaver.ts +13 -13
- package/src/platform/toolExecutor.ts +4 -20
- package/src/playbooks/playbooks.ts +2 -2
- package/src/toolsLibrary/classifier.ts +6 -9
- package/src/toolsLibrary/extraction.ts +6 -9
- package/src/toolsLibrary/parseDocument.ts +7 -14
- package/src/types/Agent.types.ts +1 -1
- package/src/types/LangGraph.types.ts +30 -41
- package/src/types/Tools.types.ts +2 -7
- package/dist/browserTask/README.md +0 -419
- package/dist/browserTask/browserAgent.py +0 -632
- package/dist/browserTask/captcha_isolated.png +0 -0
- package/dist/browserTask/executeBrowserTask.ts +0 -79
- package/dist/browserTask/requirements.txt +0 -8
- package/dist/browserTask/setup.sh +0 -144
- package/dist/internalTools/retell.d.ts +0 -12
- package/dist/internalTools/retell.d.ts.map +0 -1
- package/dist/internalTools/retell.js +0 -54
- package/dist/internalTools/retell.js.map +0 -1
- package/dist/internalTools/sendPlaceholderMessage.d.ts +0 -14
- package/dist/internalTools/sendPlaceholderMessage.d.ts.map +0 -1
- package/dist/internalTools/sendPlaceholderMessage.js +0 -61
- package/dist/internalTools/sendPlaceholderMessage.js.map +0 -1
- package/dist/utils/extractStateMemoryResponse.d.ts +0 -5
- package/dist/utils/extractStateMemoryResponse.d.ts.map +0 -1
- package/dist/utils/extractStateMemoryResponse.js +0 -91
- package/dist/utils/extractStateMemoryResponse.js.map +0 -1
- package/src/utils/extractStateMemoryResponse.ts +0 -94
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { Tool } from '../types/Tools.types';
|
|
2
2
|
import { Agent } from '../agent';
|
|
3
3
|
import { logger } from '../utils/logger';
|
|
4
|
-
import extractToolStateResponse from '../utils/extractStateMemoryResponse';
|
|
5
|
-
import { ToolMessage } from '@langchain/core/messages';
|
|
6
4
|
|
|
7
5
|
export interface ToolExecutionRequest {
|
|
8
6
|
toolName: string;
|
|
@@ -70,7 +68,7 @@ export class ToolExecutor {
|
|
|
70
68
|
state.cdpUrl = cdpUrl;
|
|
71
69
|
}
|
|
72
70
|
|
|
73
|
-
|
|
71
|
+
await tool.execute({
|
|
74
72
|
input: toolParams,
|
|
75
73
|
state,
|
|
76
74
|
agent: this.agent,
|
|
@@ -83,25 +81,11 @@ export class ToolExecutor {
|
|
|
83
81
|
executionTimeMs: endTime - startTime,
|
|
84
82
|
});
|
|
85
83
|
|
|
86
|
-
//
|
|
87
|
-
|
|
88
|
-
let result = response;
|
|
89
|
-
|
|
90
|
-
// If the response is a ToolMessage, extract state updates
|
|
91
|
-
if (response && typeof response === 'object' && 'content' in response) {
|
|
92
|
-
const toolMessage = response as ToolMessage;
|
|
93
|
-
stateUpdate = extractToolStateResponse(toolMessage);
|
|
94
|
-
// Extract the content as the result
|
|
95
|
-
result = { result: toolMessage.content };
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// Update the session state if there are state changes
|
|
99
|
-
if (Object.keys(stateUpdate).length > 0) {
|
|
100
|
-
await this.agent.updateState({ sessionId, state: stateUpdate });
|
|
101
|
-
}
|
|
84
|
+
// Always update the session state after tool execution req
|
|
85
|
+
await this.agent.updateState({ sessionId, state });
|
|
102
86
|
|
|
103
87
|
return {
|
|
104
|
-
|
|
88
|
+
state,
|
|
105
89
|
};
|
|
106
90
|
} catch (err) {
|
|
107
91
|
logger.error({
|
|
@@ -183,9 +183,9 @@ function getAllYamlFiles(dir: string): string[] {
|
|
|
183
183
|
/**
|
|
184
184
|
* Combine playbooks into a single string
|
|
185
185
|
*/
|
|
186
|
-
export function combinePlaybooks(playbooks: Playbook[]): string {
|
|
186
|
+
export function combinePlaybooks(playbooks: Playbook[]): string | null {
|
|
187
187
|
if (playbooks.length === 0) {
|
|
188
|
-
return
|
|
188
|
+
return null;
|
|
189
189
|
}
|
|
190
190
|
|
|
191
191
|
// Combine all playbooks into sections
|
|
@@ -191,17 +191,14 @@ const classifierTool: Tool<typeof schema, any> = {
|
|
|
191
191
|
confidence: result.confidence,
|
|
192
192
|
});
|
|
193
193
|
|
|
194
|
+
state.memory.lastClassification = {
|
|
195
|
+
content: content.substring(0, 100) + (content.length > 100 ? '...' : ''),
|
|
196
|
+
result,
|
|
197
|
+
timestamp: new Date().toISOString(),
|
|
198
|
+
};
|
|
199
|
+
|
|
194
200
|
return {
|
|
195
201
|
result,
|
|
196
|
-
state: {
|
|
197
|
-
memory: {
|
|
198
|
-
lastClassification: {
|
|
199
|
-
content: content.substring(0, 100) + (content.length > 100 ? '...' : ''),
|
|
200
|
-
result,
|
|
201
|
-
timestamp: new Date().toISOString(),
|
|
202
|
-
},
|
|
203
|
-
},
|
|
204
|
-
},
|
|
205
202
|
};
|
|
206
203
|
} catch (err) {
|
|
207
204
|
logger.error({
|
|
@@ -369,17 +369,14 @@ const extractionTool: Tool<typeof schema, any> = {
|
|
|
369
369
|
resultKeys: Object.keys(result),
|
|
370
370
|
});
|
|
371
371
|
|
|
372
|
+
state.memory.lastExtraction = {
|
|
373
|
+
content: content.substring(0, 100) + (content.length > 100 ? '...' : ''),
|
|
374
|
+
result,
|
|
375
|
+
timestamp: new Date().toISOString(),
|
|
376
|
+
};
|
|
377
|
+
|
|
372
378
|
return {
|
|
373
379
|
result,
|
|
374
|
-
state: {
|
|
375
|
-
memory: {
|
|
376
|
-
lastExtraction: {
|
|
377
|
-
content: content.substring(0, 100) + (content.length > 100 ? '...' : ''),
|
|
378
|
-
result,
|
|
379
|
-
timestamp: new Date().toISOString(),
|
|
380
|
-
},
|
|
381
|
-
},
|
|
382
|
-
},
|
|
383
380
|
};
|
|
384
381
|
} catch (err) {
|
|
385
382
|
logger.error({
|
|
@@ -101,18 +101,15 @@ const parseDocumentTool: Tool<typeof schema, any> = {
|
|
|
101
101
|
// Extract from document using the SDK's document extraction capabilities
|
|
102
102
|
const result = await extractFromDocument(extractionOptions);
|
|
103
103
|
|
|
104
|
+
state.memory.lastParsedDocument = {
|
|
105
|
+
source: combinedInput.documentPath || combinedInput.documentUrl || 'content',
|
|
106
|
+
extractedAt: new Date().toISOString(),
|
|
107
|
+
extractedRaw: !!combinedInput.extractRaw,
|
|
108
|
+
};
|
|
109
|
+
|
|
104
110
|
// Return only the extracted data, not the metadata as requested
|
|
105
111
|
return {
|
|
106
112
|
result: result.data,
|
|
107
|
-
state: {
|
|
108
|
-
memory: {
|
|
109
|
-
lastParsedDocument: {
|
|
110
|
-
source: combinedInput.documentPath || combinedInput.documentUrl || 'content',
|
|
111
|
-
extractedAt: new Date().toISOString(),
|
|
112
|
-
extractedRaw: !!combinedInput.extractRaw,
|
|
113
|
-
},
|
|
114
|
-
},
|
|
115
|
-
},
|
|
116
113
|
};
|
|
117
114
|
} catch (err) {
|
|
118
115
|
logger.error({
|
|
@@ -121,13 +118,9 @@ const parseDocumentTool: Tool<typeof schema, any> = {
|
|
|
121
118
|
err,
|
|
122
119
|
});
|
|
123
120
|
|
|
121
|
+
state.memory.documentParsingError = err instanceof Error ? err.message : String(err);
|
|
124
122
|
return {
|
|
125
123
|
result: `Failed to parse document: ${err instanceof Error ? err.message : String(err)}`,
|
|
126
|
-
state: {
|
|
127
|
-
memory: {
|
|
128
|
-
documentParsingError: err instanceof Error ? err.message : String(err),
|
|
129
|
-
},
|
|
130
|
-
},
|
|
131
124
|
};
|
|
132
125
|
}
|
|
133
126
|
},
|
package/src/types/Agent.types.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { NodeType } from './Flows.types';
|
|
|
5
5
|
export type EmitSignature<Memory, E extends keyof AgentEventRequestPayloads<Memory>> = (
|
|
6
6
|
event: E,
|
|
7
7
|
payload: AgentEventRequestPayloads<Memory>[E],
|
|
8
|
-
) => Promise<AgentEventResponsePayloads
|
|
8
|
+
) => Promise<AgentEventResponsePayloads[E][]>;
|
|
9
9
|
|
|
10
10
|
export type MindedSDKConfig = {
|
|
11
11
|
flows: string[];
|
|
@@ -4,36 +4,12 @@ import { HistoryStep, SessionType } from './Agent.types';
|
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
import { logger } from '../utils/logger';
|
|
6
6
|
|
|
7
|
-
// Define default values once
|
|
8
|
-
const STATE_DEFAULTS = {
|
|
9
|
-
messages: [] as BaseMessage[],
|
|
10
|
-
history: [] as HistoryStep[],
|
|
11
|
-
sessionId: '',
|
|
12
|
-
goto: null as string | null | undefined,
|
|
13
|
-
sessionType: SessionType.TEXT,
|
|
14
|
-
scenario: {} as Record<string, string | boolean>,
|
|
15
|
-
cdpUrl: null as string | null,
|
|
16
|
-
};
|
|
17
|
-
|
|
18
7
|
export const createStateAnnotation = <Memory = any>(memorySchema?: z.ZodSchema<Memory>) =>
|
|
19
8
|
Annotation.Root({
|
|
20
9
|
messages: Annotation<Array<BaseMessage>>({
|
|
21
|
-
default: () =>
|
|
22
|
-
reducer
|
|
23
|
-
|
|
24
|
-
for (const message of newMessages) {
|
|
25
|
-
if (message.additional_kwargs?.update) {
|
|
26
|
-
const index = res.findIndex((m) => m.id && m.id === message.id);
|
|
27
|
-
if (index !== -1) {
|
|
28
|
-
res[index].content = message.content;
|
|
29
|
-
res[index].additional_kwargs = { ...res[index].additional_kwargs, ...message.additional_kwargs };
|
|
30
|
-
}
|
|
31
|
-
} else {
|
|
32
|
-
res.push(message);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
return res;
|
|
36
|
-
},
|
|
10
|
+
default: () => [] as BaseMessage[],
|
|
11
|
+
// Direct replacement - no reducer, just replace the entire value
|
|
12
|
+
reducer: (_, newValue) => newValue,
|
|
37
13
|
}),
|
|
38
14
|
memory: Annotation<Memory>({
|
|
39
15
|
default: () => {
|
|
@@ -47,32 +23,39 @@ export const createStateAnnotation = <Memory = any>(memorySchema?: z.ZodSchema<M
|
|
|
47
23
|
}
|
|
48
24
|
return {} as Memory;
|
|
49
25
|
},
|
|
50
|
-
|
|
26
|
+
// Direct replacement - no reducer, just replace the entire value
|
|
27
|
+
reducer: (_, newValue) => newValue,
|
|
51
28
|
}),
|
|
52
29
|
history: Annotation<Array<HistoryStep>>({
|
|
53
|
-
default: () =>
|
|
54
|
-
reducer
|
|
30
|
+
default: () => [] as HistoryStep[],
|
|
31
|
+
// Direct replacement - no reducer, just replace the entire value
|
|
32
|
+
reducer: (_, newValue) => newValue,
|
|
55
33
|
}),
|
|
56
34
|
sessionId: Annotation<string>({
|
|
57
|
-
default: () =>
|
|
58
|
-
reducer
|
|
35
|
+
default: () => '',
|
|
36
|
+
// Direct replacement - no reducer, just replace the entire value
|
|
37
|
+
reducer: (_, newValue) => newValue,
|
|
59
38
|
}),
|
|
60
39
|
goto: Annotation<string | null | undefined>({
|
|
61
|
-
default: () =>
|
|
62
|
-
reducer
|
|
40
|
+
default: () => null as string | null | undefined,
|
|
41
|
+
// Direct replacement - no reducer, just replace the entire value
|
|
42
|
+
reducer: (_, newValue) => newValue,
|
|
63
43
|
}),
|
|
64
44
|
sessionType: Annotation<SessionType>({
|
|
65
|
-
default: () =>
|
|
66
|
-
reducer
|
|
45
|
+
default: () => SessionType.TEXT,
|
|
46
|
+
// Direct replacement - no reducer, just replace the entire value
|
|
47
|
+
reducer: (_, newValue) => newValue,
|
|
67
48
|
}),
|
|
68
49
|
scenario: Annotation<Record<string, string | boolean>>({
|
|
69
|
-
default: () =>
|
|
70
|
-
reducer
|
|
50
|
+
default: () => ({} as Record<string, string | boolean>),
|
|
51
|
+
// Direct replacement - no reducer, just replace the entire value
|
|
52
|
+
reducer: (_, newValue) => newValue,
|
|
71
53
|
}),
|
|
72
54
|
// Available only when executing browser-use
|
|
73
55
|
cdpUrl: Annotation<string | null>({
|
|
74
|
-
default: () =>
|
|
75
|
-
reducer
|
|
56
|
+
default: () => null as string | null,
|
|
57
|
+
// Direct replacement - no reducer, just replace the entire value
|
|
58
|
+
reducer: (_, newValue) => newValue,
|
|
76
59
|
}),
|
|
77
60
|
});
|
|
78
61
|
|
|
@@ -83,7 +66,13 @@ export const getInitialState = <Memory = any>(memorySchema?: z.ZodSchema<Memory>
|
|
|
83
66
|
const memory = memorySchema ? memorySchema.parse({}) : ({} as Memory);
|
|
84
67
|
|
|
85
68
|
return {
|
|
86
|
-
|
|
69
|
+
messages: [],
|
|
70
|
+
history: [],
|
|
71
|
+
sessionId: '',
|
|
72
|
+
goto: null,
|
|
73
|
+
sessionType: SessionType.TEXT,
|
|
74
|
+
scenario: {},
|
|
75
|
+
cdpUrl: null,
|
|
87
76
|
memory,
|
|
88
77
|
} as State<Memory>;
|
|
89
78
|
};
|
package/src/types/Tools.types.ts
CHANGED
|
@@ -2,13 +2,8 @@ import { z } from 'zod';
|
|
|
2
2
|
import { Agent } from '../';
|
|
3
3
|
import { State } from './LangGraph.types';
|
|
4
4
|
|
|
5
|
-
// Type for state updates that allows partial memory
|
|
6
|
-
type StateUpdate<Memory = any> = Omit<Partial<State<Memory>>, 'memory'> & {
|
|
7
|
-
memory?: Partial<Memory>;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
5
|
// Valid return type for new API
|
|
11
|
-
export type ToolReturnType
|
|
6
|
+
export type ToolReturnType = { result?: any } | void;
|
|
12
7
|
|
|
13
8
|
export interface Tool<Input extends z.ZodSchema, Memory = any> {
|
|
14
9
|
name: string;
|
|
@@ -16,7 +11,7 @@ export interface Tool<Input extends z.ZodSchema, Memory = any> {
|
|
|
16
11
|
input: Input;
|
|
17
12
|
isGlobal?: boolean;
|
|
18
13
|
allowExecutionRequests?: boolean;
|
|
19
|
-
execute: (input: ToolExecuteInput<Input, Memory>) => Promise<ToolReturnType
|
|
14
|
+
execute: (input: ToolExecuteInput<Input, Memory>) => Promise<ToolReturnType>;
|
|
20
15
|
}
|
|
21
16
|
|
|
22
17
|
export interface ToolExecuteInput<Input extends z.ZodSchema, Memory = any> {
|