@eko-ai/eko 1.0.14 → 1.0.15-alpha.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/index.cjs.js +17 -0
- package/dist/index.esm.js +17 -0
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -471,15 +471,24 @@ class ActionImpl {
|
|
|
471
471
|
// Store the promise of tool execution
|
|
472
472
|
toolExecutionPromise = (async () => {
|
|
473
473
|
var _a;
|
|
474
|
+
console.log("toolExecutionPromise()...");
|
|
475
|
+
console.log(`context.callback: ${context.callback}`);
|
|
476
|
+
if (context.callback) {
|
|
477
|
+
console.log(`context.callback.hooks.beforeToolUse: ${context.callback.hooks.beforeToolUse}`);
|
|
478
|
+
console.log(`context.callback.hooks.afterToolUse: ${context.callback.hooks.afterToolUse}`);
|
|
479
|
+
}
|
|
474
480
|
try {
|
|
475
481
|
// beforeToolUse
|
|
482
|
+
console.log("beforeToolUse");
|
|
476
483
|
context.__skip = false;
|
|
484
|
+
console.log("if #1");
|
|
477
485
|
if (context.callback && context.callback.hooks.beforeToolUse) {
|
|
478
486
|
let modified_input = await context.callback.hooks.beforeToolUse(tool, context, toolCall.input);
|
|
479
487
|
if (modified_input) {
|
|
480
488
|
toolCall.input = modified_input;
|
|
481
489
|
}
|
|
482
490
|
}
|
|
491
|
+
console.log("if #2");
|
|
483
492
|
if (context.__skip || context.__abort || ((_a = context.signal) === null || _a === void 0 ? void 0 : _a.aborted)) {
|
|
484
493
|
toolResultMessage = {
|
|
485
494
|
role: 'user',
|
|
@@ -494,15 +503,20 @@ class ActionImpl {
|
|
|
494
503
|
return;
|
|
495
504
|
}
|
|
496
505
|
// Execute the tool
|
|
506
|
+
console.log("Execute the tool...");
|
|
497
507
|
let result = await tool.execute(context, toolCall.input);
|
|
508
|
+
console.log("Execute the tool...done");
|
|
498
509
|
// afterToolUse
|
|
510
|
+
console.log("afterToolUse");
|
|
499
511
|
if (context.callback && context.callback.hooks.afterToolUse) {
|
|
500
512
|
let modified_result = await context.callback.hooks.afterToolUse(tool, context, result);
|
|
501
513
|
if (modified_result) {
|
|
502
514
|
result = modified_result;
|
|
503
515
|
}
|
|
504
516
|
}
|
|
517
|
+
console.log("set result_has_image...");
|
|
505
518
|
const result_has_image = result && result.image;
|
|
519
|
+
console.log("set resultContent...");
|
|
506
520
|
const resultContent = result_has_image
|
|
507
521
|
? {
|
|
508
522
|
type: 'tool_result',
|
|
@@ -519,11 +533,13 @@ class ActionImpl {
|
|
|
519
533
|
tool_use_id: toolCall.id,
|
|
520
534
|
content: [{ type: 'text', text: JSON.stringify(result) }],
|
|
521
535
|
};
|
|
536
|
+
console.log("set resultContentText...");
|
|
522
537
|
const resultContentText = result_has_image
|
|
523
538
|
? result.text
|
|
524
539
|
? result.text + ' [Image]'
|
|
525
540
|
: '[Image]'
|
|
526
541
|
: JSON.stringify(result);
|
|
542
|
+
console.log("set resultMessage...");
|
|
527
543
|
const resultMessage = {
|
|
528
544
|
role: 'user',
|
|
529
545
|
content: [resultContent],
|
|
@@ -553,6 +569,7 @@ class ActionImpl {
|
|
|
553
569
|
toolResultMessage = errorResult;
|
|
554
570
|
this.logger.logError(err, context);
|
|
555
571
|
}
|
|
572
|
+
console.log("toolExecutionPromise()...done");
|
|
556
573
|
})();
|
|
557
574
|
},
|
|
558
575
|
onComplete: (llmResponse) => {
|
package/dist/index.esm.js
CHANGED
|
@@ -467,15 +467,24 @@ class ActionImpl {
|
|
|
467
467
|
// Store the promise of tool execution
|
|
468
468
|
toolExecutionPromise = (async () => {
|
|
469
469
|
var _a;
|
|
470
|
+
console.log("toolExecutionPromise()...");
|
|
471
|
+
console.log(`context.callback: ${context.callback}`);
|
|
472
|
+
if (context.callback) {
|
|
473
|
+
console.log(`context.callback.hooks.beforeToolUse: ${context.callback.hooks.beforeToolUse}`);
|
|
474
|
+
console.log(`context.callback.hooks.afterToolUse: ${context.callback.hooks.afterToolUse}`);
|
|
475
|
+
}
|
|
470
476
|
try {
|
|
471
477
|
// beforeToolUse
|
|
478
|
+
console.log("beforeToolUse");
|
|
472
479
|
context.__skip = false;
|
|
480
|
+
console.log("if #1");
|
|
473
481
|
if (context.callback && context.callback.hooks.beforeToolUse) {
|
|
474
482
|
let modified_input = await context.callback.hooks.beforeToolUse(tool, context, toolCall.input);
|
|
475
483
|
if (modified_input) {
|
|
476
484
|
toolCall.input = modified_input;
|
|
477
485
|
}
|
|
478
486
|
}
|
|
487
|
+
console.log("if #2");
|
|
479
488
|
if (context.__skip || context.__abort || ((_a = context.signal) === null || _a === void 0 ? void 0 : _a.aborted)) {
|
|
480
489
|
toolResultMessage = {
|
|
481
490
|
role: 'user',
|
|
@@ -490,15 +499,20 @@ class ActionImpl {
|
|
|
490
499
|
return;
|
|
491
500
|
}
|
|
492
501
|
// Execute the tool
|
|
502
|
+
console.log("Execute the tool...");
|
|
493
503
|
let result = await tool.execute(context, toolCall.input);
|
|
504
|
+
console.log("Execute the tool...done");
|
|
494
505
|
// afterToolUse
|
|
506
|
+
console.log("afterToolUse");
|
|
495
507
|
if (context.callback && context.callback.hooks.afterToolUse) {
|
|
496
508
|
let modified_result = await context.callback.hooks.afterToolUse(tool, context, result);
|
|
497
509
|
if (modified_result) {
|
|
498
510
|
result = modified_result;
|
|
499
511
|
}
|
|
500
512
|
}
|
|
513
|
+
console.log("set result_has_image...");
|
|
501
514
|
const result_has_image = result && result.image;
|
|
515
|
+
console.log("set resultContent...");
|
|
502
516
|
const resultContent = result_has_image
|
|
503
517
|
? {
|
|
504
518
|
type: 'tool_result',
|
|
@@ -515,11 +529,13 @@ class ActionImpl {
|
|
|
515
529
|
tool_use_id: toolCall.id,
|
|
516
530
|
content: [{ type: 'text', text: JSON.stringify(result) }],
|
|
517
531
|
};
|
|
532
|
+
console.log("set resultContentText...");
|
|
518
533
|
const resultContentText = result_has_image
|
|
519
534
|
? result.text
|
|
520
535
|
? result.text + ' [Image]'
|
|
521
536
|
: '[Image]'
|
|
522
537
|
: JSON.stringify(result);
|
|
538
|
+
console.log("set resultMessage...");
|
|
523
539
|
const resultMessage = {
|
|
524
540
|
role: 'user',
|
|
525
541
|
content: [resultContent],
|
|
@@ -549,6 +565,7 @@ class ActionImpl {
|
|
|
549
565
|
toolResultMessage = errorResult;
|
|
550
566
|
this.logger.logError(err, context);
|
|
551
567
|
}
|
|
568
|
+
console.log("toolExecutionPromise()...done");
|
|
552
569
|
})();
|
|
553
570
|
},
|
|
554
571
|
onComplete: (llmResponse) => {
|