@eko-ai/eko 1.0.13 → 1.0.14

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.
@@ -69,21 +69,29 @@ class HumanInputText {
69
69
  };
70
70
  }
71
71
  async execute(context, params) {
72
- var _a, _b, _c;
72
+ var _a;
73
73
  if (typeof params !== 'object' || params === null || !params.question) {
74
74
  throw new Error('Invalid parameters. Expected an object with a "question" property.');
75
75
  }
76
76
  const question = params.question;
77
77
  console.log("question: " + question);
78
- let answer = await ((_c = (_a = context.callback) === null || _a === undefined ? undefined : (_b = _a.hooks).onHumanInputText) === null || _c === undefined ? undefined : _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 {
78
+ let onHumanInputText = (_a = context.callback) === null || _a === undefined ? undefined : _a.hooks.onHumanInputText;
79
+ if (onHumanInputText) {
80
+ let answer;
81
+ try {
82
+ answer = await onHumanInputText(question);
83
+ }
84
+ catch (e) {
85
+ console.error(e);
86
+ return { status: "Error: Cannot get user's answer.", answer: "" };
87
+ }
84
88
  console.log("answer: " + answer);
85
89
  return { status: "OK", answer: answer };
86
90
  }
91
+ else {
92
+ console.error("`onHumanInputText` not implemented");
93
+ return { status: "Error: Cannot get user's answer.", answer: "" };
94
+ }
87
95
  }
88
96
  }
89
97
  class HumanInputSingleChoice {
@@ -106,7 +114,7 @@ class HumanInputSingleChoice {
106
114
  };
107
115
  }
108
116
  async execute(context, params) {
109
- var _a, _b, _c;
117
+ var _a;
110
118
  if (typeof params !== 'object' || params === null || !params.question || !params.choices) {
111
119
  throw new Error('Invalid parameters. Expected an object with a "question" and "choices" property.');
112
120
  }
@@ -114,15 +122,23 @@ class HumanInputSingleChoice {
114
122
  const choices = params.choices;
115
123
  console.log("question: " + question);
116
124
  console.log("choices: " + choices);
117
- let answer = await ((_c = (_a = context.callback) === null || _a === undefined ? undefined : (_b = _a.hooks).onHumanInputSingleChoice) === null || _c === undefined ? undefined : _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 {
125
+ let onHumanInputSingleChoice = (_a = context.callback) === null || _a === undefined ? undefined : _a.hooks.onHumanInputSingleChoice;
126
+ if (onHumanInputSingleChoice) {
127
+ let answer;
128
+ try {
129
+ answer = await onHumanInputSingleChoice(question, choices);
130
+ }
131
+ catch (e) {
132
+ console.error(e);
133
+ return { status: "Error: Cannot get user's answer.", answer: "" };
134
+ }
123
135
  console.log("answer: " + answer);
124
136
  return { status: "OK", answer: answer };
125
137
  }
138
+ else {
139
+ console.error("`onHumanInputSingleChoice` not implemented");
140
+ return { status: "Error: Cannot get user's answer.", answer: "" };
141
+ }
126
142
  }
127
143
  }
128
144
  class HumanInputMultipleChoice {
@@ -145,7 +161,7 @@ class HumanInputMultipleChoice {
145
161
  };
146
162
  }
147
163
  async execute(context, params) {
148
- var _a, _b, _c;
164
+ var _a;
149
165
  if (typeof params !== 'object' || params === null || !params.question || !params.choices) {
150
166
  throw new Error('Invalid parameters. Expected an object with a "question" and "choices" property.');
151
167
  }
@@ -153,15 +169,23 @@ class HumanInputMultipleChoice {
153
169
  const choices = params.choices;
154
170
  console.log("question: " + question);
155
171
  console.log("choices: " + choices);
156
- let answer = await ((_c = (_a = context.callback) === null || _a === undefined ? undefined : (_b = _a.hooks).onHumanInputMultipleChoice) === null || _c === undefined ? undefined : _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 {
172
+ let onHumanInputMultipleChoice = (_a = context.callback) === null || _a === undefined ? undefined : _a.hooks.onHumanInputMultipleChoice;
173
+ if (onHumanInputMultipleChoice) {
174
+ let answer;
175
+ try {
176
+ answer = await onHumanInputMultipleChoice(question, choices);
177
+ }
178
+ catch (e) {
179
+ console.error(e);
180
+ return { status: "`onHumanInputMultipleChoice` not implemented", answer: [] };
181
+ }
162
182
  console.log("answer: " + answer);
163
183
  return { status: "OK", answer: answer };
164
184
  }
185
+ else {
186
+ console.error("Cannot get user's answer.");
187
+ return { status: "Error: Cannot get user's answer.", answer: [] };
188
+ }
165
189
  }
166
190
  }
167
191
  class HumanOperate {
@@ -180,28 +204,36 @@ class HumanOperate {
180
204
  };
181
205
  }
182
206
  async execute(context, params) {
183
- var _a, _b, _c;
207
+ var _a;
184
208
  if (typeof params !== 'object' || params === null || !params.reason) {
185
209
  throw new Error('Invalid parameters. Expected an object with a "reason" property.');
186
210
  }
187
211
  const reason = params.reason;
188
212
  console.log("reason: " + reason);
189
- let userOperation = await ((_c = (_a = context.callback) === null || _a === undefined ? undefined : (_b = _a.hooks).onHumanOperate) === null || _c === undefined ? undefined : _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 {
213
+ let onHumanOperate = (_a = context.callback) === null || _a === undefined ? undefined : _a.hooks.onHumanOperate;
214
+ if (onHumanOperate) {
215
+ let userOperation;
216
+ try {
217
+ userOperation = await onHumanOperate(reason);
218
+ }
219
+ catch (e) {
220
+ console.error(e);
221
+ return { status: "`onHumanOperate` not implemented", userOperation: "" };
222
+ }
195
223
  console.log("userOperation: " + userOperation);
196
224
  return { status: "OK", userOperation: userOperation };
197
225
  }
226
+ else {
227
+ console.error("Cannot get user's operation.");
228
+ return { status: "Error: Cannot get user's operation.", userOperation: "" };
229
+ }
198
230
  }
199
231
  }
200
232
 
201
233
  class SummaryWorkflow {
202
234
  constructor() {
203
235
  this.name = 'summary_workflow';
204
- this.description = 'Summarize what this workflow has done from start to finish using an ordered list .';
236
+ this.description = 'Summarize briefly what this workflow has accomplished.';
205
237
  this.input_schema = {
206
238
  type: 'object',
207
239
  properties: {
@@ -70809,6 +70841,7 @@ function run_build_dom_tree() {
70809
70841
  'type',
70810
70842
  'name',
70811
70843
  'role',
70844
+ 'class',
70812
70845
  // 'href',
70813
70846
  'tabindex',
70814
70847
  'aria-label',
@@ -67,21 +67,29 @@ class HumanInputText {
67
67
  };
68
68
  }
69
69
  async execute(context, params) {
70
- var _a, _b, _c;
70
+ var _a;
71
71
  if (typeof params !== 'object' || params === null || !params.question) {
72
72
  throw new Error('Invalid parameters. Expected an object with a "question" property.');
73
73
  }
74
74
  const question = params.question;
75
75
  console.log("question: " + question);
76
- let answer = await ((_c = (_a = context.callback) === null || _a === undefined ? undefined : (_b = _a.hooks).onHumanInputText) === null || _c === undefined ? undefined : _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 {
76
+ let onHumanInputText = (_a = context.callback) === null || _a === undefined ? undefined : _a.hooks.onHumanInputText;
77
+ if (onHumanInputText) {
78
+ let answer;
79
+ try {
80
+ answer = await onHumanInputText(question);
81
+ }
82
+ catch (e) {
83
+ console.error(e);
84
+ return { status: "Error: Cannot get user's answer.", answer: "" };
85
+ }
82
86
  console.log("answer: " + answer);
83
87
  return { status: "OK", answer: answer };
84
88
  }
89
+ else {
90
+ console.error("`onHumanInputText` not implemented");
91
+ return { status: "Error: Cannot get user's answer.", answer: "" };
92
+ }
85
93
  }
86
94
  }
87
95
  class HumanInputSingleChoice {
@@ -104,7 +112,7 @@ class HumanInputSingleChoice {
104
112
  };
105
113
  }
106
114
  async execute(context, params) {
107
- var _a, _b, _c;
115
+ var _a;
108
116
  if (typeof params !== 'object' || params === null || !params.question || !params.choices) {
109
117
  throw new Error('Invalid parameters. Expected an object with a "question" and "choices" property.');
110
118
  }
@@ -112,15 +120,23 @@ class HumanInputSingleChoice {
112
120
  const choices = params.choices;
113
121
  console.log("question: " + question);
114
122
  console.log("choices: " + choices);
115
- let answer = await ((_c = (_a = context.callback) === null || _a === undefined ? undefined : (_b = _a.hooks).onHumanInputSingleChoice) === null || _c === undefined ? undefined : _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 {
123
+ let onHumanInputSingleChoice = (_a = context.callback) === null || _a === undefined ? undefined : _a.hooks.onHumanInputSingleChoice;
124
+ if (onHumanInputSingleChoice) {
125
+ let answer;
126
+ try {
127
+ answer = await onHumanInputSingleChoice(question, choices);
128
+ }
129
+ catch (e) {
130
+ console.error(e);
131
+ return { status: "Error: Cannot get user's answer.", answer: "" };
132
+ }
121
133
  console.log("answer: " + answer);
122
134
  return { status: "OK", answer: answer };
123
135
  }
136
+ else {
137
+ console.error("`onHumanInputSingleChoice` not implemented");
138
+ return { status: "Error: Cannot get user's answer.", answer: "" };
139
+ }
124
140
  }
125
141
  }
126
142
  class HumanInputMultipleChoice {
@@ -143,7 +159,7 @@ class HumanInputMultipleChoice {
143
159
  };
144
160
  }
145
161
  async execute(context, params) {
146
- var _a, _b, _c;
162
+ var _a;
147
163
  if (typeof params !== 'object' || params === null || !params.question || !params.choices) {
148
164
  throw new Error('Invalid parameters. Expected an object with a "question" and "choices" property.');
149
165
  }
@@ -151,15 +167,23 @@ class HumanInputMultipleChoice {
151
167
  const choices = params.choices;
152
168
  console.log("question: " + question);
153
169
  console.log("choices: " + choices);
154
- let answer = await ((_c = (_a = context.callback) === null || _a === undefined ? undefined : (_b = _a.hooks).onHumanInputMultipleChoice) === null || _c === undefined ? undefined : _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 {
170
+ let onHumanInputMultipleChoice = (_a = context.callback) === null || _a === undefined ? undefined : _a.hooks.onHumanInputMultipleChoice;
171
+ if (onHumanInputMultipleChoice) {
172
+ let answer;
173
+ try {
174
+ answer = await onHumanInputMultipleChoice(question, choices);
175
+ }
176
+ catch (e) {
177
+ console.error(e);
178
+ return { status: "`onHumanInputMultipleChoice` not implemented", answer: [] };
179
+ }
160
180
  console.log("answer: " + answer);
161
181
  return { status: "OK", answer: answer };
162
182
  }
183
+ else {
184
+ console.error("Cannot get user's answer.");
185
+ return { status: "Error: Cannot get user's answer.", answer: [] };
186
+ }
163
187
  }
164
188
  }
165
189
  class HumanOperate {
@@ -178,28 +202,36 @@ class HumanOperate {
178
202
  };
179
203
  }
180
204
  async execute(context, params) {
181
- var _a, _b, _c;
205
+ var _a;
182
206
  if (typeof params !== 'object' || params === null || !params.reason) {
183
207
  throw new Error('Invalid parameters. Expected an object with a "reason" property.');
184
208
  }
185
209
  const reason = params.reason;
186
210
  console.log("reason: " + reason);
187
- let userOperation = await ((_c = (_a = context.callback) === null || _a === undefined ? undefined : (_b = _a.hooks).onHumanOperate) === null || _c === undefined ? undefined : _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 {
211
+ let onHumanOperate = (_a = context.callback) === null || _a === undefined ? undefined : _a.hooks.onHumanOperate;
212
+ if (onHumanOperate) {
213
+ let userOperation;
214
+ try {
215
+ userOperation = await onHumanOperate(reason);
216
+ }
217
+ catch (e) {
218
+ console.error(e);
219
+ return { status: "`onHumanOperate` not implemented", userOperation: "" };
220
+ }
193
221
  console.log("userOperation: " + userOperation);
194
222
  return { status: "OK", userOperation: userOperation };
195
223
  }
224
+ else {
225
+ console.error("Cannot get user's operation.");
226
+ return { status: "Error: Cannot get user's operation.", userOperation: "" };
227
+ }
196
228
  }
197
229
  }
198
230
 
199
231
  class SummaryWorkflow {
200
232
  constructor() {
201
233
  this.name = 'summary_workflow';
202
- this.description = 'Summarize what this workflow has done from start to finish using an ordered list .';
234
+ this.description = 'Summarize briefly what this workflow has accomplished.';
203
235
  this.input_schema = {
204
236
  type: 'object',
205
237
  properties: {
@@ -70807,6 +70839,7 @@ function run_build_dom_tree() {
70807
70839
  'type',
70808
70840
  'name',
70809
70841
  'role',
70842
+ 'class',
70810
70843
  // 'href',
70811
70844
  'tabindex',
70812
70845
  'aria-label',
@@ -0,0 +1,10 @@
1
+ export declare class ChromeMock {
2
+ static tabs_create(createProperties: chrome.tabs.CreateProperties): Promise<chrome.tabs.Tab>;
3
+ static tabs_get(tabId: number): Promise<chrome.tabs.Tab>;
4
+ static tabs_remove(tabId: number): Promise<void>;
5
+ static windows_create(createData: chrome.windows.CreateData): Promise<chrome.windows.Window>;
6
+ static windows_get(windowId: number): Promise<chrome.windows.Window>;
7
+ static windows_getCurrent(): Promise<chrome.windows.Window>;
8
+ static windows_remove(windowId: number): Promise<void>;
9
+ }
10
+ export declare const ChromeProxy: any;
@@ -8,6 +8,8 @@ export declare class DeepseekProvider implements LLMProvider {
8
8
  constructor(apiKey: string, defaultModel?: string | null, options?: ClientOptions);
9
9
  hasVisionCapacity(): boolean;
10
10
  private buildParams;
11
+ private extractJsonFromModelOutput;
12
+ private json2ToolCall;
11
13
  generateText(messages: Message[], params: LLMParameters): Promise<LLMResponse>;
12
14
  generateStream(messages: Message[], params: LLMParameters, handler: LLMStreamHandler): Promise<void>;
13
15
  }
@@ -1,6 +1,7 @@
1
1
  import { Action, ExecutionContext, Tool } from "./action.types";
2
2
  import { LLMProvider } from "./llm.types";
3
3
  import { ExecutionLogger } from "@/utils/execution-logger";
4
+ import { ExportFileParam } from "./tools.types";
4
5
  export interface NodeOutput {
5
6
  name: string;
6
7
  description: string;
@@ -48,5 +49,6 @@ export interface WorkflowCallback {
48
49
  onHumanInputMultipleChoice?: (question: string, choices: string[]) => Promise<string[]>;
49
50
  onHumanOperate?: (reason: string) => Promise<string>;
50
51
  onSummaryWorkflow?: (summary: string) => Promise<void>;
52
+ onExportFile?: (param: ExportFileParam) => Promise<void>;
51
53
  };
52
54
  }
@@ -4,4 +4,5 @@ import { ExportFile } from './export_file';
4
4
  import { ExtractContent } from './extract_content';
5
5
  import { FindElementPosition } from './find_element_position';
6
6
  import { Screenshot } from './screenshot';
7
+ export * from '../../universal_tools';
7
8
  export { BrowserUse, ElementClick, ExportFile, ExtractContent, FindElementPosition, Screenshot, };
package/dist/web.cjs.js CHANGED
@@ -32,6 +32,7 @@ function clickable_elements_to_string(element_tree, includeAttributes) {
32
32
  'type',
33
33
  'name',
34
34
  'role',
35
+ 'class',
35
36
  // 'href',
36
37
  'tabindex',
37
38
  'aria-label',
@@ -9175,9 +9176,11 @@ class ExportFile {
9175
9176
  * @returns > { success: true }
9176
9177
  */
9177
9178
  async execute(context, params) {
9179
+ var _a, _b, _c;
9178
9180
  if (typeof params !== 'object' || params === null || !('content' in params)) {
9179
9181
  throw new Error('Invalid parameters. Expected an object with a "content" property.');
9180
9182
  }
9183
+ await ((_c = (_b = (_a = context.callback) === null || _a === undefined ? undefined : _a.hooks) === null || _b === undefined ? undefined : _b.onExportFile) === null || _c === undefined ? undefined : _c.call(_b, params));
9181
9184
  let type = 'text/plain';
9182
9185
  switch (params.fileType) {
9183
9186
  case 'csv':
@@ -9379,14 +9382,251 @@ class Screenshot {
9379
9382
  }
9380
9383
  }
9381
9384
 
9385
+ class CancelWorkflow {
9386
+ constructor() {
9387
+ this.name = 'cancel_workflow';
9388
+ this.description = 'Cancel the workflow. If any tool consistently encounters exceptions, invoke this tool to cancel the workflow.';
9389
+ this.input_schema = {
9390
+ type: 'object',
9391
+ properties: {
9392
+ reason: {
9393
+ type: 'string',
9394
+ description: 'Why the workflow should be cancelled.',
9395
+ },
9396
+ },
9397
+ required: ['reason'],
9398
+ };
9399
+ }
9400
+ async execute(context, params) {
9401
+ var _a;
9402
+ if (typeof params !== 'object' || params === null || !params.reason) {
9403
+ throw new Error('Invalid parameters. Expected an object with a "reason" property.');
9404
+ }
9405
+ const reason = params.reason;
9406
+ console.log("The workflow has been cancelled because: " + reason);
9407
+ await ((_a = context.workflow) === null || _a === undefined ? undefined : _a.cancel());
9408
+ return;
9409
+ }
9410
+ }
9411
+
9412
+ class HumanInputText {
9413
+ constructor() {
9414
+ this.name = 'human_input_text';
9415
+ 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.';
9416
+ this.input_schema = {
9417
+ type: 'object',
9418
+ properties: {
9419
+ question: {
9420
+ type: 'string',
9421
+ description: 'Ask the user here.',
9422
+ },
9423
+ },
9424
+ required: ['question'],
9425
+ };
9426
+ }
9427
+ async execute(context, params) {
9428
+ var _a;
9429
+ if (typeof params !== 'object' || params === null || !params.question) {
9430
+ throw new Error('Invalid parameters. Expected an object with a "question" property.');
9431
+ }
9432
+ const question = params.question;
9433
+ console.log("question: " + question);
9434
+ let onHumanInputText = (_a = context.callback) === null || _a === undefined ? undefined : _a.hooks.onHumanInputText;
9435
+ if (onHumanInputText) {
9436
+ let answer;
9437
+ try {
9438
+ answer = await onHumanInputText(question);
9439
+ }
9440
+ catch (e) {
9441
+ console.error(e);
9442
+ return { status: "Error: Cannot get user's answer.", answer: "" };
9443
+ }
9444
+ console.log("answer: " + answer);
9445
+ return { status: "OK", answer: answer };
9446
+ }
9447
+ else {
9448
+ console.error("`onHumanInputText` not implemented");
9449
+ return { status: "Error: Cannot get user's answer.", answer: "" };
9450
+ }
9451
+ }
9452
+ }
9453
+ class HumanInputSingleChoice {
9454
+ constructor() {
9455
+ this.name = 'human_input_single_choice';
9456
+ 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.';
9457
+ this.input_schema = {
9458
+ type: 'object',
9459
+ properties: {
9460
+ question: {
9461
+ type: 'string',
9462
+ description: 'Ask the user here.',
9463
+ },
9464
+ choices: {
9465
+ type: 'array',
9466
+ description: 'All of the choices.',
9467
+ }
9468
+ },
9469
+ required: ['question', 'choices'],
9470
+ };
9471
+ }
9472
+ async execute(context, params) {
9473
+ var _a;
9474
+ if (typeof params !== 'object' || params === null || !params.question || !params.choices) {
9475
+ throw new Error('Invalid parameters. Expected an object with a "question" and "choices" property.');
9476
+ }
9477
+ const question = params.question;
9478
+ const choices = params.choices;
9479
+ console.log("question: " + question);
9480
+ console.log("choices: " + choices);
9481
+ let onHumanInputSingleChoice = (_a = context.callback) === null || _a === undefined ? undefined : _a.hooks.onHumanInputSingleChoice;
9482
+ if (onHumanInputSingleChoice) {
9483
+ let answer;
9484
+ try {
9485
+ answer = await onHumanInputSingleChoice(question, choices);
9486
+ }
9487
+ catch (e) {
9488
+ console.error(e);
9489
+ return { status: "Error: Cannot get user's answer.", answer: "" };
9490
+ }
9491
+ console.log("answer: " + answer);
9492
+ return { status: "OK", answer: answer };
9493
+ }
9494
+ else {
9495
+ console.error("`onHumanInputSingleChoice` not implemented");
9496
+ return { status: "Error: Cannot get user's answer.", answer: "" };
9497
+ }
9498
+ }
9499
+ }
9500
+ class HumanInputMultipleChoice {
9501
+ constructor() {
9502
+ this.name = 'human_input_multiple_choice';
9503
+ 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.';
9504
+ this.input_schema = {
9505
+ type: 'object',
9506
+ properties: {
9507
+ question: {
9508
+ type: 'string',
9509
+ description: 'Ask the user here.',
9510
+ },
9511
+ choices: {
9512
+ type: 'array',
9513
+ description: 'All of the choices.',
9514
+ }
9515
+ },
9516
+ required: ['question', 'choices'],
9517
+ };
9518
+ }
9519
+ async execute(context, params) {
9520
+ var _a;
9521
+ if (typeof params !== 'object' || params === null || !params.question || !params.choices) {
9522
+ throw new Error('Invalid parameters. Expected an object with a "question" and "choices" property.');
9523
+ }
9524
+ const question = params.question;
9525
+ const choices = params.choices;
9526
+ console.log("question: " + question);
9527
+ console.log("choices: " + choices);
9528
+ let onHumanInputMultipleChoice = (_a = context.callback) === null || _a === undefined ? undefined : _a.hooks.onHumanInputMultipleChoice;
9529
+ if (onHumanInputMultipleChoice) {
9530
+ let answer;
9531
+ try {
9532
+ answer = await onHumanInputMultipleChoice(question, choices);
9533
+ }
9534
+ catch (e) {
9535
+ console.error(e);
9536
+ return { status: "`onHumanInputMultipleChoice` not implemented", answer: [] };
9537
+ }
9538
+ console.log("answer: " + answer);
9539
+ return { status: "OK", answer: answer };
9540
+ }
9541
+ else {
9542
+ console.error("Cannot get user's answer.");
9543
+ return { status: "Error: Cannot get user's answer.", answer: [] };
9544
+ }
9545
+ }
9546
+ }
9547
+ class HumanOperate {
9548
+ constructor() {
9549
+ this.name = 'human_operate';
9550
+ 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.';
9551
+ this.input_schema = {
9552
+ type: 'object',
9553
+ properties: {
9554
+ reason: {
9555
+ type: 'string',
9556
+ description: 'The reason why you need to transfer control.',
9557
+ },
9558
+ },
9559
+ required: ['reason'],
9560
+ };
9561
+ }
9562
+ async execute(context, params) {
9563
+ var _a;
9564
+ if (typeof params !== 'object' || params === null || !params.reason) {
9565
+ throw new Error('Invalid parameters. Expected an object with a "reason" property.');
9566
+ }
9567
+ const reason = params.reason;
9568
+ console.log("reason: " + reason);
9569
+ let onHumanOperate = (_a = context.callback) === null || _a === undefined ? undefined : _a.hooks.onHumanOperate;
9570
+ if (onHumanOperate) {
9571
+ let userOperation;
9572
+ try {
9573
+ userOperation = await onHumanOperate(reason);
9574
+ }
9575
+ catch (e) {
9576
+ console.error(e);
9577
+ return { status: "`onHumanOperate` not implemented", userOperation: "" };
9578
+ }
9579
+ console.log("userOperation: " + userOperation);
9580
+ return { status: "OK", userOperation: userOperation };
9581
+ }
9582
+ else {
9583
+ console.error("Cannot get user's operation.");
9584
+ return { status: "Error: Cannot get user's operation.", userOperation: "" };
9585
+ }
9586
+ }
9587
+ }
9588
+
9589
+ class SummaryWorkflow {
9590
+ constructor() {
9591
+ this.name = 'summary_workflow';
9592
+ this.description = 'Summarize briefly what this workflow has accomplished.';
9593
+ this.input_schema = {
9594
+ type: 'object',
9595
+ properties: {
9596
+ summary: {
9597
+ type: 'string',
9598
+ description: 'Your summary in markdown format.',
9599
+ },
9600
+ },
9601
+ required: ['summary'],
9602
+ };
9603
+ }
9604
+ async execute(context, params) {
9605
+ var _a, _b, _c;
9606
+ if (typeof params !== 'object' || params === null || !params.summary) {
9607
+ throw new Error('Invalid parameters. Expected an object with a "summary" property.');
9608
+ }
9609
+ const summary = params.summary;
9610
+ console.log("summary: " + summary);
9611
+ await ((_c = (_a = context.callback) === null || _a === undefined ? undefined : (_b = _a.hooks).onSummaryWorkflow) === null || _c === undefined ? undefined : _c.call(_b, summary));
9612
+ return { status: "OK" };
9613
+ }
9614
+ }
9615
+
9382
9616
  var tools = /*#__PURE__*/Object.freeze({
9383
9617
  __proto__: null,
9384
9618
  BrowserUse: BrowserUse,
9619
+ CancelWorkflow: CancelWorkflow,
9385
9620
  ElementClick: ElementClick,
9386
9621
  ExportFile: ExportFile,
9387
9622
  ExtractContent: ExtractContent,
9388
9623
  FindElementPosition: FindElementPosition,
9389
- Screenshot: Screenshot
9624
+ HumanInputMultipleChoice: HumanInputMultipleChoice,
9625
+ HumanInputSingleChoice: HumanInputSingleChoice,
9626
+ HumanInputText: HumanInputText,
9627
+ HumanOperate: HumanOperate,
9628
+ Screenshot: Screenshot,
9629
+ SummaryWorkflow: SummaryWorkflow
9390
9630
  });
9391
9631
 
9392
9632
  function loadTools() {