@minded-ai/mindedjs 1.0.43 → 1.0.45
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/nodes/addAppToolNode.d.ts.map +1 -1
- package/dist/nodes/addAppToolNode.js +13 -3
- package/dist/nodes/addAppToolNode.js.map +1 -1
- package/dist/platform/mindedConnection.d.ts +0 -1
- package/dist/platform/mindedConnection.d.ts.map +1 -1
- package/dist/platform/mindedConnection.js +0 -21
- package/dist/platform/mindedConnection.js.map +1 -1
- package/package.json +1 -1
- package/src/nodes/addAppToolNode.ts +45 -35
- package/src/platform/mindedConnection.ts +0 -23
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addAppToolNode.d.ts","sourceRoot":"","sources":["../../src/nodes/addAppToolNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,OAAO,EAAE,gBAAgB,EAAmB,MAAM,0BAA0B,CAAC;AAI7E,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAIlD,eAAO,MAAM,cAAc,GAAU,uBAIlC;
|
|
1
|
+
{"version":3,"file":"addAppToolNode.d.ts","sourceRoot":"","sources":["../../src/nodes/addAppToolNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,OAAO,EAAE,gBAAgB,EAAmB,MAAM,0BAA0B,CAAC;AAI7E,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAIlD,eAAO,MAAM,cAAc,GAAU,uBAIlC;IACD,KAAK,EAAE,gBAAgB,CAAC;IACxB,IAAI,EAAE,WAAW,CAAC;IAClB,GAAG,EAAE,CAAC,OAAO,YAAY,EAAE,MAAM,OAAO,YAAY,CAAC,CAAC;CACvD,kBA4CA,CAAC"}
|
|
@@ -32,11 +32,21 @@ const addAppToolNode = async ({ graph, node, llm, }) => {
|
|
|
32
32
|
if (Object.keys(state.memory).length !== 0) {
|
|
33
33
|
messages.push(new messages_1.SystemMessage(prompt));
|
|
34
34
|
}
|
|
35
|
-
const AIToolCallMessage = await llm
|
|
35
|
+
const AIToolCallMessage = await llm
|
|
36
|
+
.bindTools([tool], {
|
|
36
37
|
tool_choice: tool.name,
|
|
37
|
-
})
|
|
38
|
+
})
|
|
39
|
+
.invoke(messages);
|
|
38
40
|
const toolCallMessage = await tool.invoke(AIToolCallMessage.tool_calls[0]);
|
|
39
|
-
|
|
41
|
+
AIToolCallMessage.additional_kwargs = {
|
|
42
|
+
appActionInvocation: {
|
|
43
|
+
nodeTitle: node.name,
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
return {
|
|
47
|
+
messages: [AIToolCallMessage, toolCallMessage],
|
|
48
|
+
history: [{ type: Agent_types_1.FlowHistoryType.APP_ACTION_INVOCATION, nodeTitle: node.name }],
|
|
49
|
+
};
|
|
40
50
|
};
|
|
41
51
|
graph.addNode(node.name, callback);
|
|
42
52
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addAppToolNode.js","sourceRoot":"","sources":["../../src/nodes/addAppToolNode.ts"],"names":[],"mappings":";;;AACA,iDAA8D;AAE9D,uDAAyD;AAIzD,8EAA8E;AAC9E,sDAAuD;AAEhD,MAAM,cAAc,GAAG,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"addAppToolNode.js","sourceRoot":"","sources":["../../src/nodes/addAppToolNode.ts"],"names":[],"mappings":";;;AACA,iDAA8D;AAE9D,uDAAyD;AAIzD,8EAA8E;AAC9E,sDAAuD;AAEhD,MAAM,cAAc,GAAG,KAAK,EAAE,EACnC,KAAK,EACL,IAAI,EACJ,GAAG,GAKJ,EAAE,EAAE;IACH,MAAM,aAAa,GAAG,IAAA,4CAAsB,EAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACxD,MAAM,QAAQ,GAAiB,KAAK,EAAE,KAAmC,EAAE,EAAE;QAC3E,OAAO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AAC,iBAAiB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3E,iBAAiB,CAAC,iBAAiB,GAAG;YACpC,mBAAmB,EAAE;gBACnB,SAAS,EAAE,IAAI,CAAC,IAAI;aACrB;SACF,CAAC;QACF,OAAO;YACL,QAAQ,EAAE,CAAC,iBAAiB,EAAE,eAAe,CAAC;YAC9C,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,6BAAe,CAAC,qBAAqB,EAAE,SAAS,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC;SACjF,CAAC;IACJ,CAAC,CAAC;IACF,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AACrC,CAAC,CAAC;AApDW,QAAA,cAAc,kBAoDzB"}
|
|
@@ -5,7 +5,6 @@ export declare class MindedConnection {
|
|
|
5
5
|
[key: string]: ((message: BaseMindedConnectionSocketMessage) => void)[];
|
|
6
6
|
};
|
|
7
7
|
get isConnected(): boolean;
|
|
8
|
-
private waitForConnection;
|
|
9
8
|
on: (event: MindedConnectionSocketMessageType, callback: (message: BaseMindedConnectionSocketMessage) => void) => void;
|
|
10
9
|
emit: (event: MindedConnectionSocketMessageType, message: BaseMindedConnectionSocketMessage) => void;
|
|
11
10
|
awaitEmit: <T, R>(event: MindedConnectionSocketMessageType, message: T, timeoutMs?: number) => Promise<R>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mindedConnection.d.ts","sourceRoot":"","sources":["../../src/platform/mindedConnection.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iCAAiC,EAAE,iCAAiC,EAAE,MAAM,yBAAyB,CAAC;AAI/G,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,MAAM,CAAuB;IACrC,SAAS,EAAE;QACT,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,CAAC,OAAO,EAAE,iCAAiC,KAAK,IAAI,CAAC,EAAE,CAAC;KACzE,CAAM;IAEP,IAAW,WAAW,IAAI,OAAO,CAEhC;
|
|
1
|
+
{"version":3,"file":"mindedConnection.d.ts","sourceRoot":"","sources":["../../src/platform/mindedConnection.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iCAAiC,EAAE,iCAAiC,EAAE,MAAM,yBAAyB,CAAC;AAI/G,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,MAAM,CAAuB;IACrC,SAAS,EAAE;QACT,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,CAAC,OAAO,EAAE,iCAAiC,KAAK,IAAI,CAAC,EAAE,CAAC;KACzE,CAAM;IAEP,IAAW,WAAW,IAAI,OAAO,CAEhC;IAEM,EAAE,GAAI,OAAO,iCAAiC,EAAE,UAAU,CAAC,OAAO,EAAE,iCAAiC,KAAK,IAAI,UAKnH;IAEK,IAAI,GAAI,OAAO,iCAAiC,EAAE,SAAS,iCAAiC,UAIjG;IAEK,SAAS,GAAU,CAAC,EAAE,CAAC,EAAE,OAAO,iCAAiC,EAAE,SAAS,CAAC,EAAE,YAAW,MAAa,KAAG,OAAO,CAAC,CAAC,CAAC,CAuBzH;YAEY,OAAO;IA8DR,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAOpC"}
|
|
@@ -20,7 +20,6 @@ class MindedConnection {
|
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
22
|
this.awaitEmit = async (event, message, timeoutMs = 5000) => {
|
|
23
|
-
await this.waitForConnection();
|
|
24
23
|
if (!this.socket) {
|
|
25
24
|
throw new Error('Socket is not connected');
|
|
26
25
|
}
|
|
@@ -47,26 +46,6 @@ class MindedConnection {
|
|
|
47
46
|
var _a, _b;
|
|
48
47
|
return (_b = (_a = this.socket) === null || _a === void 0 ? void 0 : _a.connected) !== null && _b !== void 0 ? _b : false;
|
|
49
48
|
}
|
|
50
|
-
async waitForConnection() {
|
|
51
|
-
return new Promise((resolve, reject) => {
|
|
52
|
-
let attempts = 0;
|
|
53
|
-
const maxAttempts = 50;
|
|
54
|
-
const checkInterval = 100;
|
|
55
|
-
const checkConnection = () => {
|
|
56
|
-
var _a;
|
|
57
|
-
if ((_a = this.socket) === null || _a === void 0 ? void 0 : _a.connected) {
|
|
58
|
-
resolve();
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
attempts++;
|
|
62
|
-
if (attempts >= maxAttempts) {
|
|
63
|
-
reject(new Error('Connection failed'));
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
setInterval(checkConnection, checkInterval);
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
49
|
async connect(token) {
|
|
71
50
|
return new Promise((resolve, reject) => {
|
|
72
51
|
this.socket = (0, socket_io_client_1.io)((0, config_1.getConfig)().baseUrl, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mindedConnection.js","sourceRoot":"","sources":["../../src/platform/mindedConnection.ts"],"names":[],"mappings":";;;AAAA,uDAA8C;AAE9C,qCAAoC;AACpC,qCAAqC;AAErC,MAAa,gBAAgB;IAA7B;QACU,WAAM,GAAkB,IAAI,CAAC;QACrC,cAAS,GAEL,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"mindedConnection.js","sourceRoot":"","sources":["../../src/platform/mindedConnection.ts"],"names":[],"mappings":";;;AAAA,uDAA8C;AAE9C,qCAAoC;AACpC,qCAAqC;AAErC,MAAa,gBAAgB;IAA7B;QACU,WAAM,GAAkB,IAAI,CAAC;QACrC,cAAS,GAEL,EAAE,CAAC;QAMA,OAAE,GAAG,CAAC,KAAwC,EAAE,QAA8D,EAAE,EAAE;YACvH,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC3B,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;YAC7B,CAAC;YACD,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACvC,CAAC,CAAC;QAEK,SAAI,GAAG,CA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Type } from '../types/Agent.types';
|
|
10
10
|
|
|
11
11
|
export const addAppToolNode = async ({
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
graph,
|
|
13
|
+
node,
|
|
14
|
+
llm,
|
|
15
15
|
}: {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
graph: PreCompiledGraph;
|
|
17
|
+
node: AppToolNode;
|
|
18
|
+
llm: (typeof LLMProviders)[keyof typeof LLMProviders];
|
|
19
19
|
}) => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
const appRunnerTool = getAppActionRunnerTool(node.name);
|
|
21
|
+
const callback: RunnableLike = async (state: typeof stateAnnotation.State) => {
|
|
22
|
+
console.log(`Executing tool node ${appRunnerTool.name}`);
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
24
|
+
const executeWrapper = async (input: z.infer<typeof appRunnerTool.input>) => {
|
|
25
|
+
try {
|
|
26
|
+
const response = await appRunnerTool.execute({ input, memory: state.memory, triggerInvocations: state.triggerInvocations });
|
|
27
|
+
return response || {};
|
|
28
|
+
} catch (error) {
|
|
29
|
+
console.error('Error executing tool', error);
|
|
30
|
+
throw error;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
const tool = langchainTool(executeWrapper, {
|
|
34
|
+
name: appRunnerTool.name,
|
|
35
|
+
description: appRunnerTool.description,
|
|
36
|
+
schema: appRunnerTool.input,
|
|
37
|
+
});
|
|
38
|
+
const prompt = `
|
|
39
39
|
Additional context:
|
|
40
40
|
workflow memory: ${JSON.stringify(state.memory)}
|
|
41
41
|
`;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
const AIToolCallMessage = await llm.bindTools([tool], {
|
|
47
|
-
tool_choice: tool.name,
|
|
48
|
-
}).invoke(messages);
|
|
49
|
-
const toolCallMessage = await tool.invoke(AIToolCallMessage.tool_calls[0])
|
|
50
|
-
return { messages: [AIToolCallMessage, toolCallMessage], history: [{ type: FlowHistoryType.APP_ACTION_INVOCATION, nodeTitle: node.name }] };
|
|
42
|
+
const messages = state.messages || [];
|
|
43
|
+
if (Object.keys(state.memory).length !== 0) {
|
|
44
|
+
messages.push(new SystemMessage(prompt));
|
|
51
45
|
}
|
|
52
|
-
|
|
53
|
-
|
|
46
|
+
const AIToolCallMessage = await llm
|
|
47
|
+
.bindTools([tool], {
|
|
48
|
+
tool_choice: tool.name,
|
|
49
|
+
})
|
|
50
|
+
.invoke(messages);
|
|
51
|
+
const toolCallMessage = await tool.invoke(AIToolCallMessage.tool_calls[0]);
|
|
52
|
+
AIToolCallMessage.additional_kwargs = {
|
|
53
|
+
appActionInvocation: {
|
|
54
|
+
nodeTitle: node.name,
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
return {
|
|
58
|
+
messages: [AIToolCallMessage, toolCallMessage],
|
|
59
|
+
history: [{ type: FlowHistoryType.APP_ACTION_INVOCATION, nodeTitle: node.name }],
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
graph.addNode(node.name, callback);
|
|
63
|
+
};
|
|
@@ -13,27 +13,6 @@ export class MindedConnection {
|
|
|
13
13
|
return this.socket?.connected ?? false;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
private async waitForConnection(): Promise<void> {
|
|
17
|
-
return new Promise((resolve, reject) => {
|
|
18
|
-
let attempts = 0;
|
|
19
|
-
const maxAttempts = 50;
|
|
20
|
-
const checkInterval = 100;
|
|
21
|
-
|
|
22
|
-
const checkConnection = () => {
|
|
23
|
-
if (this.socket?.connected) {
|
|
24
|
-
resolve();
|
|
25
|
-
} else {
|
|
26
|
-
attempts++;
|
|
27
|
-
if (attempts >= maxAttempts) {
|
|
28
|
-
reject(new Error('Connection failed'));
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
setInterval(checkConnection, checkInterval);
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
|
|
37
16
|
public on = (event: MindedConnectionSocketMessageType, callback: (message: BaseMindedConnectionSocketMessage) => void) => {
|
|
38
17
|
if (!this.listeners[event]) {
|
|
39
18
|
this.listeners[event] = [];
|
|
@@ -48,8 +27,6 @@ export class MindedConnection {
|
|
|
48
27
|
};
|
|
49
28
|
|
|
50
29
|
public awaitEmit = async <T, R>(event: MindedConnectionSocketMessageType, message: T, timeoutMs: number = 5000): Promise<R> => {
|
|
51
|
-
await this.waitForConnection();
|
|
52
|
-
|
|
53
30
|
if (!this.socket) {
|
|
54
31
|
throw new Error('Socket is not connected');
|
|
55
32
|
}
|