@opperai/agents 0.4.0 → 0.4.1

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 CHANGED
@@ -1341,6 +1341,14 @@ var BaseAgent = class {
1341
1341
  finishedAt,
1342
1342
  metadata: {}
1343
1343
  });
1344
+ if (!result.success) {
1345
+ await this.triggerHook(HookEvents.ToolError, {
1346
+ context,
1347
+ tool: tool2,
1348
+ toolName: tool2.name,
1349
+ error: result.error
1350
+ });
1351
+ }
1344
1352
  await this.triggerHook(HookEvents.AfterTool, {
1345
1353
  context,
1346
1354
  tool: tool2,
@@ -1639,7 +1647,7 @@ var mergeSchemaDefaults = (schema, value) => {
1639
1647
 
1640
1648
  // package.json
1641
1649
  var package_default = {
1642
- version: "0.4.0"};
1650
+ version: "0.4.1"};
1643
1651
 
1644
1652
  // src/utils/version.ts
1645
1653
  var SDK_NAME = "@opperai/agents";
@@ -3400,6 +3408,11 @@ var mcp = (...configs) => {
3400
3408
 
3401
3409
  // src/utils/tool-decorators.ts
3402
3410
  init_tool();
3411
+ var isToolResult = (value) => {
3412
+ if (typeof value !== "object" || value === null) return false;
3413
+ const obj = value;
3414
+ return typeof obj["success"] === "boolean" && typeof obj["toolName"] === "string" && ("output" in obj || "error" in obj);
3415
+ };
3403
3416
  var reflectWithMetadata = Reflect;
3404
3417
  var ReflectMetadata = {
3405
3418
  define: (metadataKey, metadataValue, target, propertyKey) => {
@@ -3529,6 +3542,9 @@ function createFunctionTool(fn, options = {}) {
3529
3542
  } else {
3530
3543
  result = await Promise.resolve(fn(input, context));
3531
3544
  }
3545
+ if (isToolResult(result)) {
3546
+ return result;
3547
+ }
3532
3548
  return exports.ToolResultFactory.success(name, result, {
3533
3549
  startedAt,
3534
3550
  finishedAt: Date.now(),