@eko-ai/eko 1.0.12 → 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.
package/dist/web.esm.js CHANGED
@@ -30,6 +30,7 @@ function clickable_elements_to_string(element_tree, includeAttributes) {
30
30
  'type',
31
31
  'name',
32
32
  'role',
33
+ 'class',
33
34
  // 'href',
34
35
  'tabindex',
35
36
  'aria-label',
@@ -9173,9 +9174,11 @@ class ExportFile {
9173
9174
  * @returns > { success: true }
9174
9175
  */
9175
9176
  async execute(context, params) {
9177
+ var _a, _b, _c;
9176
9178
  if (typeof params !== 'object' || params === null || !('content' in params)) {
9177
9179
  throw new Error('Invalid parameters. Expected an object with a "content" property.');
9178
9180
  }
9181
+ 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));
9179
9182
  let type = 'text/plain';
9180
9183
  switch (params.fileType) {
9181
9184
  case 'csv':
@@ -9377,14 +9380,251 @@ class Screenshot {
9377
9380
  }
9378
9381
  }
9379
9382
 
9383
+ class CancelWorkflow {
9384
+ constructor() {
9385
+ this.name = 'cancel_workflow';
9386
+ this.description = 'Cancel the workflow. If any tool consistently encounters exceptions, invoke this tool to cancel the workflow.';
9387
+ this.input_schema = {
9388
+ type: 'object',
9389
+ properties: {
9390
+ reason: {
9391
+ type: 'string',
9392
+ description: 'Why the workflow should be cancelled.',
9393
+ },
9394
+ },
9395
+ required: ['reason'],
9396
+ };
9397
+ }
9398
+ async execute(context, params) {
9399
+ var _a;
9400
+ if (typeof params !== 'object' || params === null || !params.reason) {
9401
+ throw new Error('Invalid parameters. Expected an object with a "reason" property.');
9402
+ }
9403
+ const reason = params.reason;
9404
+ console.log("The workflow has been cancelled because: " + reason);
9405
+ await ((_a = context.workflow) === null || _a === undefined ? undefined : _a.cancel());
9406
+ return;
9407
+ }
9408
+ }
9409
+
9410
+ class HumanInputText {
9411
+ constructor() {
9412
+ this.name = 'human_input_text';
9413
+ 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.';
9414
+ this.input_schema = {
9415
+ type: 'object',
9416
+ properties: {
9417
+ question: {
9418
+ type: 'string',
9419
+ description: 'Ask the user here.',
9420
+ },
9421
+ },
9422
+ required: ['question'],
9423
+ };
9424
+ }
9425
+ async execute(context, params) {
9426
+ var _a;
9427
+ if (typeof params !== 'object' || params === null || !params.question) {
9428
+ throw new Error('Invalid parameters. Expected an object with a "question" property.');
9429
+ }
9430
+ const question = params.question;
9431
+ console.log("question: " + question);
9432
+ let onHumanInputText = (_a = context.callback) === null || _a === undefined ? undefined : _a.hooks.onHumanInputText;
9433
+ if (onHumanInputText) {
9434
+ let answer;
9435
+ try {
9436
+ answer = await onHumanInputText(question);
9437
+ }
9438
+ catch (e) {
9439
+ console.error(e);
9440
+ return { status: "Error: Cannot get user's answer.", answer: "" };
9441
+ }
9442
+ console.log("answer: " + answer);
9443
+ return { status: "OK", answer: answer };
9444
+ }
9445
+ else {
9446
+ console.error("`onHumanInputText` not implemented");
9447
+ return { status: "Error: Cannot get user's answer.", answer: "" };
9448
+ }
9449
+ }
9450
+ }
9451
+ class HumanInputSingleChoice {
9452
+ constructor() {
9453
+ this.name = 'human_input_single_choice';
9454
+ 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.';
9455
+ this.input_schema = {
9456
+ type: 'object',
9457
+ properties: {
9458
+ question: {
9459
+ type: 'string',
9460
+ description: 'Ask the user here.',
9461
+ },
9462
+ choices: {
9463
+ type: 'array',
9464
+ description: 'All of the choices.',
9465
+ }
9466
+ },
9467
+ required: ['question', 'choices'],
9468
+ };
9469
+ }
9470
+ async execute(context, params) {
9471
+ var _a;
9472
+ if (typeof params !== 'object' || params === null || !params.question || !params.choices) {
9473
+ throw new Error('Invalid parameters. Expected an object with a "question" and "choices" property.');
9474
+ }
9475
+ const question = params.question;
9476
+ const choices = params.choices;
9477
+ console.log("question: " + question);
9478
+ console.log("choices: " + choices);
9479
+ let onHumanInputSingleChoice = (_a = context.callback) === null || _a === undefined ? undefined : _a.hooks.onHumanInputSingleChoice;
9480
+ if (onHumanInputSingleChoice) {
9481
+ let answer;
9482
+ try {
9483
+ answer = await onHumanInputSingleChoice(question, choices);
9484
+ }
9485
+ catch (e) {
9486
+ console.error(e);
9487
+ return { status: "Error: Cannot get user's answer.", answer: "" };
9488
+ }
9489
+ console.log("answer: " + answer);
9490
+ return { status: "OK", answer: answer };
9491
+ }
9492
+ else {
9493
+ console.error("`onHumanInputSingleChoice` not implemented");
9494
+ return { status: "Error: Cannot get user's answer.", answer: "" };
9495
+ }
9496
+ }
9497
+ }
9498
+ class HumanInputMultipleChoice {
9499
+ constructor() {
9500
+ this.name = 'human_input_multiple_choice';
9501
+ 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.';
9502
+ this.input_schema = {
9503
+ type: 'object',
9504
+ properties: {
9505
+ question: {
9506
+ type: 'string',
9507
+ description: 'Ask the user here.',
9508
+ },
9509
+ choices: {
9510
+ type: 'array',
9511
+ description: 'All of the choices.',
9512
+ }
9513
+ },
9514
+ required: ['question', 'choices'],
9515
+ };
9516
+ }
9517
+ async execute(context, params) {
9518
+ var _a;
9519
+ if (typeof params !== 'object' || params === null || !params.question || !params.choices) {
9520
+ throw new Error('Invalid parameters. Expected an object with a "question" and "choices" property.');
9521
+ }
9522
+ const question = params.question;
9523
+ const choices = params.choices;
9524
+ console.log("question: " + question);
9525
+ console.log("choices: " + choices);
9526
+ let onHumanInputMultipleChoice = (_a = context.callback) === null || _a === undefined ? undefined : _a.hooks.onHumanInputMultipleChoice;
9527
+ if (onHumanInputMultipleChoice) {
9528
+ let answer;
9529
+ try {
9530
+ answer = await onHumanInputMultipleChoice(question, choices);
9531
+ }
9532
+ catch (e) {
9533
+ console.error(e);
9534
+ return { status: "`onHumanInputMultipleChoice` not implemented", answer: [] };
9535
+ }
9536
+ console.log("answer: " + answer);
9537
+ return { status: "OK", answer: answer };
9538
+ }
9539
+ else {
9540
+ console.error("Cannot get user's answer.");
9541
+ return { status: "Error: Cannot get user's answer.", answer: [] };
9542
+ }
9543
+ }
9544
+ }
9545
+ class HumanOperate {
9546
+ constructor() {
9547
+ this.name = 'human_operate';
9548
+ 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.';
9549
+ this.input_schema = {
9550
+ type: 'object',
9551
+ properties: {
9552
+ reason: {
9553
+ type: 'string',
9554
+ description: 'The reason why you need to transfer control.',
9555
+ },
9556
+ },
9557
+ required: ['reason'],
9558
+ };
9559
+ }
9560
+ async execute(context, params) {
9561
+ var _a;
9562
+ if (typeof params !== 'object' || params === null || !params.reason) {
9563
+ throw new Error('Invalid parameters. Expected an object with a "reason" property.');
9564
+ }
9565
+ const reason = params.reason;
9566
+ console.log("reason: " + reason);
9567
+ let onHumanOperate = (_a = context.callback) === null || _a === undefined ? undefined : _a.hooks.onHumanOperate;
9568
+ if (onHumanOperate) {
9569
+ let userOperation;
9570
+ try {
9571
+ userOperation = await onHumanOperate(reason);
9572
+ }
9573
+ catch (e) {
9574
+ console.error(e);
9575
+ return { status: "`onHumanOperate` not implemented", userOperation: "" };
9576
+ }
9577
+ console.log("userOperation: " + userOperation);
9578
+ return { status: "OK", userOperation: userOperation };
9579
+ }
9580
+ else {
9581
+ console.error("Cannot get user's operation.");
9582
+ return { status: "Error: Cannot get user's operation.", userOperation: "" };
9583
+ }
9584
+ }
9585
+ }
9586
+
9587
+ class SummaryWorkflow {
9588
+ constructor() {
9589
+ this.name = 'summary_workflow';
9590
+ this.description = 'Summarize briefly what this workflow has accomplished.';
9591
+ this.input_schema = {
9592
+ type: 'object',
9593
+ properties: {
9594
+ summary: {
9595
+ type: 'string',
9596
+ description: 'Your summary in markdown format.',
9597
+ },
9598
+ },
9599
+ required: ['summary'],
9600
+ };
9601
+ }
9602
+ async execute(context, params) {
9603
+ var _a, _b, _c;
9604
+ if (typeof params !== 'object' || params === null || !params.summary) {
9605
+ throw new Error('Invalid parameters. Expected an object with a "summary" property.');
9606
+ }
9607
+ const summary = params.summary;
9608
+ console.log("summary: " + summary);
9609
+ await ((_c = (_a = context.callback) === null || _a === undefined ? undefined : (_b = _a.hooks).onSummaryWorkflow) === null || _c === undefined ? undefined : _c.call(_b, summary));
9610
+ return { status: "OK" };
9611
+ }
9612
+ }
9613
+
9380
9614
  var tools = /*#__PURE__*/Object.freeze({
9381
9615
  __proto__: null,
9382
9616
  BrowserUse: BrowserUse,
9617
+ CancelWorkflow: CancelWorkflow,
9383
9618
  ElementClick: ElementClick,
9384
9619
  ExportFile: ExportFile,
9385
9620
  ExtractContent: ExtractContent,
9386
9621
  FindElementPosition: FindElementPosition,
9387
- Screenshot: Screenshot
9622
+ HumanInputMultipleChoice: HumanInputMultipleChoice,
9623
+ HumanInputSingleChoice: HumanInputSingleChoice,
9624
+ HumanInputText: HumanInputText,
9625
+ HumanOperate: HumanOperate,
9626
+ Screenshot: Screenshot,
9627
+ SummaryWorkflow: SummaryWorkflow
9388
9628
  });
9389
9629
 
9390
9630
  function loadTools() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eko-ai/eko",
3
- "version": "1.0.12",
3
+ "version": "1.0.14",
4
4
  "description": "Empowering language to transform human words into action.",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",