@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.js CHANGED
@@ -1320,6 +1320,14 @@ var BaseAgent = class {
1320
1320
  finishedAt,
1321
1321
  metadata: {}
1322
1322
  });
1323
+ if (!result.success) {
1324
+ await this.triggerHook(HookEvents.ToolError, {
1325
+ context,
1326
+ tool: tool2,
1327
+ toolName: tool2.name,
1328
+ error: result.error
1329
+ });
1330
+ }
1323
1331
  await this.triggerHook(HookEvents.AfterTool, {
1324
1332
  context,
1325
1333
  tool: tool2,
@@ -1618,7 +1626,7 @@ var mergeSchemaDefaults = (schema, value) => {
1618
1626
 
1619
1627
  // package.json
1620
1628
  var package_default = {
1621
- version: "0.4.0"};
1629
+ version: "0.4.1"};
1622
1630
 
1623
1631
  // src/utils/version.ts
1624
1632
  var SDK_NAME = "@opperai/agents";
@@ -3379,6 +3387,11 @@ var mcp = (...configs) => {
3379
3387
 
3380
3388
  // src/utils/tool-decorators.ts
3381
3389
  init_tool();
3390
+ var isToolResult = (value) => {
3391
+ if (typeof value !== "object" || value === null) return false;
3392
+ const obj = value;
3393
+ return typeof obj["success"] === "boolean" && typeof obj["toolName"] === "string" && ("output" in obj || "error" in obj);
3394
+ };
3382
3395
  var reflectWithMetadata = Reflect;
3383
3396
  var ReflectMetadata = {
3384
3397
  define: (metadataKey, metadataValue, target, propertyKey) => {
@@ -3508,6 +3521,9 @@ function createFunctionTool(fn, options = {}) {
3508
3521
  } else {
3509
3522
  result = await Promise.resolve(fn(input, context));
3510
3523
  }
3524
+ if (isToolResult(result)) {
3525
+ return result;
3526
+ }
3511
3527
  return ToolResultFactory.success(name, result, {
3512
3528
  startedAt,
3513
3529
  finishedAt: Date.now(),