@eko-ai/eko 1.0.8 → 1.0.9
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/README.md +14 -6
- package/dist/core/eko.d.ts +3 -2
- package/dist/extension/tools/get_all_tabs.d.ts +9 -0
- package/dist/extension/tools/index.d.ts +3 -1
- package/dist/extension/tools/tab_management.d.ts +1 -1
- package/dist/extension/utils.d.ts +1 -1
- package/dist/extension.cjs.js +687 -216
- package/dist/extension.esm.js +687 -216
- package/dist/index.cjs.js +451 -127
- package/dist/index.d.ts +2 -1
- package/dist/index.esm.js +451 -128
- package/dist/models/action.d.ts +8 -4
- package/dist/models/workflow.d.ts +8 -3
- package/dist/nodejs/tools/index.d.ts +1 -0
- package/dist/nodejs.cjs.js +211 -2
- package/dist/nodejs.esm.js +211 -2
- package/dist/schemas/workflow.schema.d.ts +2 -13
- package/dist/services/llm/claude-provider.d.ts +2 -1
- package/dist/services/llm/openai-provider.d.ts +2 -1
- package/dist/services/parser/workflow-parser.d.ts +0 -7
- package/dist/types/action.types.d.ts +8 -3
- package/dist/types/tools.types.d.ts +44 -1
- package/dist/types/workflow.types.d.ts +22 -9
- package/dist/universal_tools/cancel_workflow.d.ts +9 -0
- package/dist/universal_tools/human.d.ts +30 -0
- package/dist/universal_tools/index.d.ts +4 -0
- package/dist/universal_tools/summary_workflow.d.ts +9 -0
- package/dist/utils/execution-logger.d.ts +69 -0
- package/package.json +2 -3
package/dist/models/action.d.ts
CHANGED
|
@@ -1,22 +1,26 @@
|
|
|
1
1
|
import { Action, Tool, ExecutionContext } from '../types/action.types';
|
|
2
|
+
import { NodeInput, NodeOutput } from '../types/workflow.types';
|
|
2
3
|
import { LLMProvider, LLMParameters } from '../types/llm.types';
|
|
3
4
|
export declare class ActionImpl implements Action {
|
|
4
5
|
type: 'prompt';
|
|
5
6
|
name: string;
|
|
6
7
|
description: string;
|
|
7
8
|
tools: Tool<any, any>[];
|
|
8
|
-
|
|
9
|
+
llmProvider: LLMProvider | undefined;
|
|
9
10
|
private llmConfig?;
|
|
10
11
|
private readonly maxRounds;
|
|
11
12
|
private writeContextTool;
|
|
13
|
+
private toolResults;
|
|
14
|
+
private logger;
|
|
12
15
|
constructor(type: 'prompt', // Only support prompt type
|
|
13
|
-
name: string, description: string, tools: Tool<any, any>[], llmProvider: LLMProvider, llmConfig?: LLMParameters | undefined, config?: {
|
|
16
|
+
name: string, description: string, tools: Tool<any, any>[], llmProvider: LLMProvider | undefined, llmConfig?: LLMParameters | undefined, config?: {
|
|
14
17
|
maxRounds?: number;
|
|
15
18
|
});
|
|
16
19
|
private executeSingleRound;
|
|
17
20
|
private handleHistoryImageMessages;
|
|
18
|
-
|
|
21
|
+
private countImages;
|
|
22
|
+
execute(input: NodeInput, output: NodeOutput, context: ExecutionContext, outputSchema?: unknown): Promise<unknown>;
|
|
19
23
|
private formatSystemPrompt;
|
|
20
24
|
private formatUserPrompt;
|
|
21
|
-
static createPromptAction(name: string, description: string, tools: Tool<any, any>[], llmProvider: LLMProvider, llmConfig?: LLMParameters): Action;
|
|
25
|
+
static createPromptAction(name: string, description: string, tools: Tool<any, any>[], llmProvider: LLMProvider | undefined, llmConfig?: LLMParameters): Action;
|
|
22
26
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ExecutionLogger, LogOptions } from "@/utils/execution-logger";
|
|
2
|
+
import { Workflow, WorkflowNode, NodeOutput, LLMProvider, WorkflowCallback } from "../types";
|
|
2
3
|
export declare class WorkflowImpl implements Workflow {
|
|
3
4
|
id: string;
|
|
4
5
|
name: string;
|
|
@@ -7,8 +8,12 @@ export declare class WorkflowImpl implements Workflow {
|
|
|
7
8
|
variables: Map<string, unknown>;
|
|
8
9
|
llmProvider?: LLMProvider | undefined;
|
|
9
10
|
abort?: boolean;
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
private logger?;
|
|
12
|
+
abortControllers: Map<string, AbortController>;
|
|
13
|
+
constructor(id: string, name: string, description?: string | undefined, nodes?: WorkflowNode[], variables?: Map<string, unknown>, llmProvider?: LLMProvider | undefined, loggerOptions?: LogOptions);
|
|
14
|
+
setLogger(logger: ExecutionLogger): void;
|
|
15
|
+
cancel(): Promise<void>;
|
|
16
|
+
execute(callback?: WorkflowCallback): Promise<NodeOutput[]>;
|
|
12
17
|
addNode(node: WorkflowNode): void;
|
|
13
18
|
removeNode(nodeId: string): void;
|
|
14
19
|
getNode(nodeId: string): WorkflowNode;
|
package/dist/nodejs.cjs.js
CHANGED
|
@@ -26,6 +26,205 @@ var require$$2$2 = require('http2');
|
|
|
26
26
|
var require$$2$3 = require('inspector');
|
|
27
27
|
var require$$0$5 = require('async_hooks');
|
|
28
28
|
|
|
29
|
+
class CancelWorkflow {
|
|
30
|
+
constructor() {
|
|
31
|
+
this.name = 'cancel_workflow';
|
|
32
|
+
this.description = 'Cancel the workflow. If any tool consistently encounters exceptions, invoke this tool to cancel the workflow.';
|
|
33
|
+
this.input_schema = {
|
|
34
|
+
type: 'object',
|
|
35
|
+
properties: {
|
|
36
|
+
reason: {
|
|
37
|
+
type: 'string',
|
|
38
|
+
description: 'Why the workflow should be cancelled.',
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
required: ['reason'],
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
async execute(context, params) {
|
|
45
|
+
var _a;
|
|
46
|
+
if (typeof params !== 'object' || params === null || !params.reason) {
|
|
47
|
+
throw new Error('Invalid parameters. Expected an object with a "reason" property.');
|
|
48
|
+
}
|
|
49
|
+
const reason = params.reason;
|
|
50
|
+
console.log("The workflow has been cancelled because: " + reason);
|
|
51
|
+
await ((_a = context.workflow) === null || _a === void 0 ? void 0 : _a.cancel());
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
class HumanInputText {
|
|
57
|
+
constructor() {
|
|
58
|
+
this.name = 'human_input_text';
|
|
59
|
+
this.description = 'When you are unsure about the details of your next action, call me and ask the user for details in the "question" field. The user will provide you with a text as an answer.';
|
|
60
|
+
this.input_schema = {
|
|
61
|
+
type: 'object',
|
|
62
|
+
properties: {
|
|
63
|
+
question: {
|
|
64
|
+
type: 'string',
|
|
65
|
+
description: 'Ask the user here.',
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
required: ['question'],
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
async execute(context, params) {
|
|
72
|
+
var _a, _b, _c;
|
|
73
|
+
if (typeof params !== 'object' || params === null || !params.question) {
|
|
74
|
+
throw new Error('Invalid parameters. Expected an object with a "question" property.');
|
|
75
|
+
}
|
|
76
|
+
const question = params.question;
|
|
77
|
+
console.log("question: " + question);
|
|
78
|
+
let answer = await ((_c = (_a = context.callback) === null || _a === void 0 ? void 0 : (_b = _a.hooks).onHumanInputText) === null || _c === void 0 ? void 0 : _c.call(_b, question));
|
|
79
|
+
if (!answer) {
|
|
80
|
+
console.error("Cannot get user's answer.");
|
|
81
|
+
return { status: "Error: Cannot get user's answer.", answer: "" };
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
console.log("answer: " + answer);
|
|
85
|
+
return { status: "OK", answer: answer };
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
class HumanInputSingleChoice {
|
|
90
|
+
constructor() {
|
|
91
|
+
this.name = 'human_input_single_choice';
|
|
92
|
+
this.description = 'When you are unsure about the details of your next action, call me and ask the user for details in the "question" field with at least 2 choices. The user will provide you with ONE choice as an answer.';
|
|
93
|
+
this.input_schema = {
|
|
94
|
+
type: 'object',
|
|
95
|
+
properties: {
|
|
96
|
+
question: {
|
|
97
|
+
type: 'string',
|
|
98
|
+
description: 'Ask the user here.',
|
|
99
|
+
},
|
|
100
|
+
choices: {
|
|
101
|
+
type: 'array',
|
|
102
|
+
description: 'All of the choices.',
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
required: ['question', 'choices'],
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
async execute(context, params) {
|
|
109
|
+
var _a, _b, _c;
|
|
110
|
+
if (typeof params !== 'object' || params === null || !params.question || !params.choices) {
|
|
111
|
+
throw new Error('Invalid parameters. Expected an object with a "question" and "choices" property.');
|
|
112
|
+
}
|
|
113
|
+
const question = params.question;
|
|
114
|
+
const choices = params.choices;
|
|
115
|
+
console.log("question: " + question);
|
|
116
|
+
console.log("choices: " + choices);
|
|
117
|
+
let answer = await ((_c = (_a = context.callback) === null || _a === void 0 ? void 0 : (_b = _a.hooks).onHumanInputSingleChoice) === null || _c === void 0 ? void 0 : _c.call(_b, question, choices));
|
|
118
|
+
if (!answer) {
|
|
119
|
+
console.error("Cannot get user's answer.");
|
|
120
|
+
return { status: "Error: Cannot get user's answer.", answer: "" };
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
console.log("answer: " + answer);
|
|
124
|
+
return { status: "OK", answer: answer };
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
class HumanInputMultipleChoice {
|
|
129
|
+
constructor() {
|
|
130
|
+
this.name = 'human_input_multiple_choice';
|
|
131
|
+
this.description = 'When you are unsure about the details of your next action, call me and ask the user for details in the "question" field with at least 2 choices. The user will provide you with ONE or MORE choice as an answer.';
|
|
132
|
+
this.input_schema = {
|
|
133
|
+
type: 'object',
|
|
134
|
+
properties: {
|
|
135
|
+
question: {
|
|
136
|
+
type: 'string',
|
|
137
|
+
description: 'Ask the user here.',
|
|
138
|
+
},
|
|
139
|
+
choices: {
|
|
140
|
+
type: 'array',
|
|
141
|
+
description: 'All of the choices.',
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
required: ['question', 'choices'],
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
async execute(context, params) {
|
|
148
|
+
var _a, _b, _c;
|
|
149
|
+
if (typeof params !== 'object' || params === null || !params.question || !params.choices) {
|
|
150
|
+
throw new Error('Invalid parameters. Expected an object with a "question" and "choices" property.');
|
|
151
|
+
}
|
|
152
|
+
const question = params.question;
|
|
153
|
+
const choices = params.choices;
|
|
154
|
+
console.log("question: " + question);
|
|
155
|
+
console.log("choices: " + choices);
|
|
156
|
+
let answer = await ((_c = (_a = context.callback) === null || _a === void 0 ? void 0 : (_b = _a.hooks).onHumanInputMultipleChoice) === null || _c === void 0 ? void 0 : _c.call(_b, question, choices));
|
|
157
|
+
if (!answer) {
|
|
158
|
+
console.error("Cannot get user's answer.");
|
|
159
|
+
return { status: "Error: Cannot get user's answer.", answer: [] };
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
console.log("answer: " + answer);
|
|
163
|
+
return { status: "OK", answer: answer };
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
class HumanOperate {
|
|
168
|
+
constructor() {
|
|
169
|
+
this.name = 'human_operate';
|
|
170
|
+
this.description = 'When you encounter operations that require login, CAPTCHA verification, or other tasks that you cannot complete, please call this tool, transfer control to the user, and explain why.';
|
|
171
|
+
this.input_schema = {
|
|
172
|
+
type: 'object',
|
|
173
|
+
properties: {
|
|
174
|
+
reason: {
|
|
175
|
+
type: 'string',
|
|
176
|
+
description: 'The reason why you need to transfer control.',
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
required: ['reason'],
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
async execute(context, params) {
|
|
183
|
+
var _a, _b, _c;
|
|
184
|
+
if (typeof params !== 'object' || params === null || !params.reason) {
|
|
185
|
+
throw new Error('Invalid parameters. Expected an object with a "reason" property.');
|
|
186
|
+
}
|
|
187
|
+
const reason = params.reason;
|
|
188
|
+
console.log("reason: " + reason);
|
|
189
|
+
let userOperation = await ((_c = (_a = context.callback) === null || _a === void 0 ? void 0 : (_b = _a.hooks).onHumanOperate) === null || _c === void 0 ? void 0 : _c.call(_b, reason));
|
|
190
|
+
if (!userOperation) {
|
|
191
|
+
console.error("Cannot get user's operation.");
|
|
192
|
+
return { status: "Error: Cannot get user's operation.", userOperation: "" };
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
console.log("userOperation: " + userOperation);
|
|
196
|
+
return { status: "OK", userOperation: userOperation };
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
class SummaryWorkflow {
|
|
202
|
+
constructor() {
|
|
203
|
+
this.name = 'summary_workflow';
|
|
204
|
+
this.description = 'Summarize what this workflow has done from start to finish using an ordered list .';
|
|
205
|
+
this.input_schema = {
|
|
206
|
+
type: 'object',
|
|
207
|
+
properties: {
|
|
208
|
+
summary: {
|
|
209
|
+
type: 'string',
|
|
210
|
+
description: 'Your summary in markdown format.',
|
|
211
|
+
},
|
|
212
|
+
},
|
|
213
|
+
required: ['summary'],
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
async execute(context, params) {
|
|
217
|
+
var _a, _b, _c;
|
|
218
|
+
if (typeof params !== 'object' || params === null || !params.summary) {
|
|
219
|
+
throw new Error('Invalid parameters. Expected an object with a "summary" property.');
|
|
220
|
+
}
|
|
221
|
+
const summary = params.summary;
|
|
222
|
+
console.log("summary: " + summary);
|
|
223
|
+
await ((_c = (_a = context.callback) === null || _a === void 0 ? void 0 : (_b = _a.hooks).onSummaryWorkflow) === null || _c === void 0 ? void 0 : _c.call(_b, summary));
|
|
224
|
+
return { status: "OK" };
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
29
228
|
const execAsync = require$$1.promisify(require$$12.exec);
|
|
30
229
|
class CommandExecute {
|
|
31
230
|
constructor() {
|
|
@@ -71394,7 +71593,11 @@ class BrowserUse {
|
|
|
71394
71593
|
quality: 50,
|
|
71395
71594
|
});
|
|
71396
71595
|
let base64 = screenshotBuffer.toString('base64');
|
|
71397
|
-
let image =
|
|
71596
|
+
let image = {
|
|
71597
|
+
type: 'base64',
|
|
71598
|
+
media_type: 'image/jpeg',
|
|
71599
|
+
data: base64,
|
|
71600
|
+
};
|
|
71398
71601
|
await page.evaluate(() => {
|
|
71399
71602
|
return window.remove_highlight();
|
|
71400
71603
|
});
|
|
@@ -71622,9 +71825,15 @@ function do_input(params) {
|
|
|
71622
71825
|
var tools = /*#__PURE__*/Object.freeze({
|
|
71623
71826
|
__proto__: null,
|
|
71624
71827
|
BrowserUse: BrowserUse,
|
|
71828
|
+
CancelWorkflow: CancelWorkflow,
|
|
71625
71829
|
CommandExecute: CommandExecute,
|
|
71626
71830
|
FileRead: FileRead,
|
|
71627
|
-
FileWrite: FileWrite
|
|
71831
|
+
FileWrite: FileWrite,
|
|
71832
|
+
HumanInputMultipleChoice: HumanInputMultipleChoice,
|
|
71833
|
+
HumanInputSingleChoice: HumanInputSingleChoice,
|
|
71834
|
+
HumanInputText: HumanInputText,
|
|
71835
|
+
HumanOperate: HumanOperate,
|
|
71836
|
+
SummaryWorkflow: SummaryWorkflow
|
|
71628
71837
|
});
|
|
71629
71838
|
|
|
71630
71839
|
function loadTools() {
|
package/dist/nodejs.esm.js
CHANGED
|
@@ -24,6 +24,205 @@ import require$$2$1 from 'http2';
|
|
|
24
24
|
import require$$2$3 from 'inspector';
|
|
25
25
|
import require$$0$5 from 'async_hooks';
|
|
26
26
|
|
|
27
|
+
class CancelWorkflow {
|
|
28
|
+
constructor() {
|
|
29
|
+
this.name = 'cancel_workflow';
|
|
30
|
+
this.description = 'Cancel the workflow. If any tool consistently encounters exceptions, invoke this tool to cancel the workflow.';
|
|
31
|
+
this.input_schema = {
|
|
32
|
+
type: 'object',
|
|
33
|
+
properties: {
|
|
34
|
+
reason: {
|
|
35
|
+
type: 'string',
|
|
36
|
+
description: 'Why the workflow should be cancelled.',
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
required: ['reason'],
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
async execute(context, params) {
|
|
43
|
+
var _a;
|
|
44
|
+
if (typeof params !== 'object' || params === null || !params.reason) {
|
|
45
|
+
throw new Error('Invalid parameters. Expected an object with a "reason" property.');
|
|
46
|
+
}
|
|
47
|
+
const reason = params.reason;
|
|
48
|
+
console.log("The workflow has been cancelled because: " + reason);
|
|
49
|
+
await ((_a = context.workflow) === null || _a === void 0 ? void 0 : _a.cancel());
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
class HumanInputText {
|
|
55
|
+
constructor() {
|
|
56
|
+
this.name = 'human_input_text';
|
|
57
|
+
this.description = 'When you are unsure about the details of your next action, call me and ask the user for details in the "question" field. The user will provide you with a text as an answer.';
|
|
58
|
+
this.input_schema = {
|
|
59
|
+
type: 'object',
|
|
60
|
+
properties: {
|
|
61
|
+
question: {
|
|
62
|
+
type: 'string',
|
|
63
|
+
description: 'Ask the user here.',
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
required: ['question'],
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
async execute(context, params) {
|
|
70
|
+
var _a, _b, _c;
|
|
71
|
+
if (typeof params !== 'object' || params === null || !params.question) {
|
|
72
|
+
throw new Error('Invalid parameters. Expected an object with a "question" property.');
|
|
73
|
+
}
|
|
74
|
+
const question = params.question;
|
|
75
|
+
console.log("question: " + question);
|
|
76
|
+
let answer = await ((_c = (_a = context.callback) === null || _a === void 0 ? void 0 : (_b = _a.hooks).onHumanInputText) === null || _c === void 0 ? void 0 : _c.call(_b, question));
|
|
77
|
+
if (!answer) {
|
|
78
|
+
console.error("Cannot get user's answer.");
|
|
79
|
+
return { status: "Error: Cannot get user's answer.", answer: "" };
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
console.log("answer: " + answer);
|
|
83
|
+
return { status: "OK", answer: answer };
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
class HumanInputSingleChoice {
|
|
88
|
+
constructor() {
|
|
89
|
+
this.name = 'human_input_single_choice';
|
|
90
|
+
this.description = 'When you are unsure about the details of your next action, call me and ask the user for details in the "question" field with at least 2 choices. The user will provide you with ONE choice as an answer.';
|
|
91
|
+
this.input_schema = {
|
|
92
|
+
type: 'object',
|
|
93
|
+
properties: {
|
|
94
|
+
question: {
|
|
95
|
+
type: 'string',
|
|
96
|
+
description: 'Ask the user here.',
|
|
97
|
+
},
|
|
98
|
+
choices: {
|
|
99
|
+
type: 'array',
|
|
100
|
+
description: 'All of the choices.',
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
required: ['question', 'choices'],
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
async execute(context, params) {
|
|
107
|
+
var _a, _b, _c;
|
|
108
|
+
if (typeof params !== 'object' || params === null || !params.question || !params.choices) {
|
|
109
|
+
throw new Error('Invalid parameters. Expected an object with a "question" and "choices" property.');
|
|
110
|
+
}
|
|
111
|
+
const question = params.question;
|
|
112
|
+
const choices = params.choices;
|
|
113
|
+
console.log("question: " + question);
|
|
114
|
+
console.log("choices: " + choices);
|
|
115
|
+
let answer = await ((_c = (_a = context.callback) === null || _a === void 0 ? void 0 : (_b = _a.hooks).onHumanInputSingleChoice) === null || _c === void 0 ? void 0 : _c.call(_b, question, choices));
|
|
116
|
+
if (!answer) {
|
|
117
|
+
console.error("Cannot get user's answer.");
|
|
118
|
+
return { status: "Error: Cannot get user's answer.", answer: "" };
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
console.log("answer: " + answer);
|
|
122
|
+
return { status: "OK", answer: answer };
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
class HumanInputMultipleChoice {
|
|
127
|
+
constructor() {
|
|
128
|
+
this.name = 'human_input_multiple_choice';
|
|
129
|
+
this.description = 'When you are unsure about the details of your next action, call me and ask the user for details in the "question" field with at least 2 choices. The user will provide you with ONE or MORE choice as an answer.';
|
|
130
|
+
this.input_schema = {
|
|
131
|
+
type: 'object',
|
|
132
|
+
properties: {
|
|
133
|
+
question: {
|
|
134
|
+
type: 'string',
|
|
135
|
+
description: 'Ask the user here.',
|
|
136
|
+
},
|
|
137
|
+
choices: {
|
|
138
|
+
type: 'array',
|
|
139
|
+
description: 'All of the choices.',
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
required: ['question', 'choices'],
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
async execute(context, params) {
|
|
146
|
+
var _a, _b, _c;
|
|
147
|
+
if (typeof params !== 'object' || params === null || !params.question || !params.choices) {
|
|
148
|
+
throw new Error('Invalid parameters. Expected an object with a "question" and "choices" property.');
|
|
149
|
+
}
|
|
150
|
+
const question = params.question;
|
|
151
|
+
const choices = params.choices;
|
|
152
|
+
console.log("question: " + question);
|
|
153
|
+
console.log("choices: " + choices);
|
|
154
|
+
let answer = await ((_c = (_a = context.callback) === null || _a === void 0 ? void 0 : (_b = _a.hooks).onHumanInputMultipleChoice) === null || _c === void 0 ? void 0 : _c.call(_b, question, choices));
|
|
155
|
+
if (!answer) {
|
|
156
|
+
console.error("Cannot get user's answer.");
|
|
157
|
+
return { status: "Error: Cannot get user's answer.", answer: [] };
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
console.log("answer: " + answer);
|
|
161
|
+
return { status: "OK", answer: answer };
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
class HumanOperate {
|
|
166
|
+
constructor() {
|
|
167
|
+
this.name = 'human_operate';
|
|
168
|
+
this.description = 'When you encounter operations that require login, CAPTCHA verification, or other tasks that you cannot complete, please call this tool, transfer control to the user, and explain why.';
|
|
169
|
+
this.input_schema = {
|
|
170
|
+
type: 'object',
|
|
171
|
+
properties: {
|
|
172
|
+
reason: {
|
|
173
|
+
type: 'string',
|
|
174
|
+
description: 'The reason why you need to transfer control.',
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
required: ['reason'],
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
async execute(context, params) {
|
|
181
|
+
var _a, _b, _c;
|
|
182
|
+
if (typeof params !== 'object' || params === null || !params.reason) {
|
|
183
|
+
throw new Error('Invalid parameters. Expected an object with a "reason" property.');
|
|
184
|
+
}
|
|
185
|
+
const reason = params.reason;
|
|
186
|
+
console.log("reason: " + reason);
|
|
187
|
+
let userOperation = await ((_c = (_a = context.callback) === null || _a === void 0 ? void 0 : (_b = _a.hooks).onHumanOperate) === null || _c === void 0 ? void 0 : _c.call(_b, reason));
|
|
188
|
+
if (!userOperation) {
|
|
189
|
+
console.error("Cannot get user's operation.");
|
|
190
|
+
return { status: "Error: Cannot get user's operation.", userOperation: "" };
|
|
191
|
+
}
|
|
192
|
+
else {
|
|
193
|
+
console.log("userOperation: " + userOperation);
|
|
194
|
+
return { status: "OK", userOperation: userOperation };
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
class SummaryWorkflow {
|
|
200
|
+
constructor() {
|
|
201
|
+
this.name = 'summary_workflow';
|
|
202
|
+
this.description = 'Summarize what this workflow has done from start to finish using an ordered list .';
|
|
203
|
+
this.input_schema = {
|
|
204
|
+
type: 'object',
|
|
205
|
+
properties: {
|
|
206
|
+
summary: {
|
|
207
|
+
type: 'string',
|
|
208
|
+
description: 'Your summary in markdown format.',
|
|
209
|
+
},
|
|
210
|
+
},
|
|
211
|
+
required: ['summary'],
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
async execute(context, params) {
|
|
215
|
+
var _a, _b, _c;
|
|
216
|
+
if (typeof params !== 'object' || params === null || !params.summary) {
|
|
217
|
+
throw new Error('Invalid parameters. Expected an object with a "summary" property.');
|
|
218
|
+
}
|
|
219
|
+
const summary = params.summary;
|
|
220
|
+
console.log("summary: " + summary);
|
|
221
|
+
await ((_c = (_a = context.callback) === null || _a === void 0 ? void 0 : (_b = _a.hooks).onSummaryWorkflow) === null || _c === void 0 ? void 0 : _c.call(_b, summary));
|
|
222
|
+
return { status: "OK" };
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
27
226
|
const execAsync = promisify(exec);
|
|
28
227
|
class CommandExecute {
|
|
29
228
|
constructor() {
|
|
@@ -71392,7 +71591,11 @@ class BrowserUse {
|
|
|
71392
71591
|
quality: 50,
|
|
71393
71592
|
});
|
|
71394
71593
|
let base64 = screenshotBuffer.toString('base64');
|
|
71395
|
-
let image =
|
|
71594
|
+
let image = {
|
|
71595
|
+
type: 'base64',
|
|
71596
|
+
media_type: 'image/jpeg',
|
|
71597
|
+
data: base64,
|
|
71598
|
+
};
|
|
71396
71599
|
await page.evaluate(() => {
|
|
71397
71600
|
return window.remove_highlight();
|
|
71398
71601
|
});
|
|
@@ -71620,9 +71823,15 @@ function do_input(params) {
|
|
|
71620
71823
|
var tools = /*#__PURE__*/Object.freeze({
|
|
71621
71824
|
__proto__: null,
|
|
71622
71825
|
BrowserUse: BrowserUse,
|
|
71826
|
+
CancelWorkflow: CancelWorkflow,
|
|
71623
71827
|
CommandExecute: CommandExecute,
|
|
71624
71828
|
FileRead: FileRead,
|
|
71625
|
-
FileWrite: FileWrite
|
|
71829
|
+
FileWrite: FileWrite,
|
|
71830
|
+
HumanInputMultipleChoice: HumanInputMultipleChoice,
|
|
71831
|
+
HumanInputSingleChoice: HumanInputSingleChoice,
|
|
71832
|
+
HumanInputText: HumanInputText,
|
|
71833
|
+
HumanOperate: HumanOperate,
|
|
71834
|
+
SummaryWorkflow: SummaryWorkflow
|
|
71626
71835
|
});
|
|
71627
71836
|
|
|
71628
71837
|
function loadTools() {
|
|
@@ -30,24 +30,13 @@ export declare const workflowSchema: {
|
|
|
30
30
|
type: string;
|
|
31
31
|
};
|
|
32
32
|
};
|
|
33
|
-
input: {
|
|
34
|
-
type: string;
|
|
35
|
-
properties: {
|
|
36
|
-
type: {
|
|
37
|
-
type: string;
|
|
38
|
-
};
|
|
39
|
-
schema: {
|
|
40
|
-
type: string;
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
33
|
output: {
|
|
45
34
|
type: string;
|
|
46
35
|
properties: {
|
|
47
|
-
|
|
36
|
+
name: {
|
|
48
37
|
type: string;
|
|
49
38
|
};
|
|
50
|
-
|
|
39
|
+
description: {
|
|
51
40
|
type: string;
|
|
52
41
|
};
|
|
53
42
|
};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { ClientOptions } from '@anthropic-ai/sdk';
|
|
1
|
+
import Anthropic, { ClientOptions } from '@anthropic-ai/sdk';
|
|
2
2
|
import { LLMProvider, LLMParameters, LLMResponse, Message, LLMStreamHandler } from '../../types/llm.types';
|
|
3
3
|
export declare class ClaudeProvider implements LLMProvider {
|
|
4
4
|
private client;
|
|
5
5
|
private defaultModel;
|
|
6
|
+
constructor(options: Anthropic, defaultModel?: string);
|
|
6
7
|
constructor(options: ClientOptions, defaultModel?: string);
|
|
7
8
|
constructor(apiKey: string, defaultModel?: string | null, options?: ClientOptions);
|
|
8
9
|
private processResponse;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { ClientOptions } from 'openai';
|
|
1
|
+
import OpenAI, { ClientOptions } from 'openai';
|
|
2
2
|
import { LLMProvider, LLMParameters, LLMResponse, Message, LLMStreamHandler } from '../../types/llm.types';
|
|
3
3
|
export declare class OpenaiProvider implements LLMProvider {
|
|
4
4
|
private client;
|
|
5
5
|
private defaultModel;
|
|
6
|
+
constructor(client: OpenAI, defaultModel?: string);
|
|
6
7
|
constructor(options: ClientOptions, defaultModel?: string);
|
|
7
8
|
constructor(apiKey: string, defaultModel?: string | null, options?: ClientOptions);
|
|
8
9
|
private buildParams;
|
|
@@ -14,16 +14,9 @@ export declare class WorkflowParser {
|
|
|
14
14
|
* Validate workflow JSON structure against schema
|
|
15
15
|
*/
|
|
16
16
|
static validate(json: unknown): ValidationResult;
|
|
17
|
-
/**
|
|
18
|
-
* Convert parsed JSON to runtime Workflow object
|
|
19
|
-
*/
|
|
20
17
|
private static toRuntime;
|
|
21
18
|
/**
|
|
22
19
|
* Convert runtime Workflow object to JSON structure
|
|
23
20
|
*/
|
|
24
21
|
private static fromRuntime;
|
|
25
|
-
/**
|
|
26
|
-
* Helper to convert IO definitions
|
|
27
|
-
*/
|
|
28
|
-
private static convertIO;
|
|
29
22
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { Workflow } from "./workflow.types";
|
|
1
2
|
import { LLMProvider } from "./llm.types";
|
|
2
|
-
import { WorkflowCallback } from "./workflow.types";
|
|
3
|
+
import { NodeOutput, WorkflowCallback } from "./workflow.types";
|
|
4
|
+
import { NodeInput } from "./workflow.types";
|
|
3
5
|
export interface Tool<T, R> {
|
|
4
6
|
name: string;
|
|
5
7
|
description: string;
|
|
@@ -25,14 +27,17 @@ export interface Property {
|
|
|
25
27
|
export interface ExecutionContext {
|
|
26
28
|
llmProvider: LLMProvider;
|
|
27
29
|
variables: Map<string, unknown>;
|
|
30
|
+
workflow?: Workflow;
|
|
28
31
|
tools?: Map<string, Tool<any, any>>;
|
|
29
32
|
callback?: WorkflowCallback;
|
|
33
|
+
signal?: AbortSignal;
|
|
30
34
|
[key: string]: any;
|
|
31
35
|
}
|
|
32
36
|
export interface Action {
|
|
33
37
|
type: 'prompt' | 'script' | 'hybrid';
|
|
34
38
|
name: string;
|
|
35
39
|
description: string;
|
|
36
|
-
execute: (input:
|
|
37
|
-
tools: Tool<any, any
|
|
40
|
+
execute: (input: NodeInput, output: NodeOutput, context: ExecutionContext) => Promise<unknown>;
|
|
41
|
+
tools: Array<Tool<any, any>>;
|
|
42
|
+
llmProvider?: LLMProvider;
|
|
38
43
|
}
|