@granular-software/sdk 0.4.82 → 0.4.84
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/agent-evals.js +13 -2
- package/dist/agent-evals.js.map +1 -1
- package/dist/agent-evals.mjs +13 -2
- package/dist/agent-evals.mjs.map +1 -1
- package/dist/cli/index.js +14 -3
- package/dist/index.js +13 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +13 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/agent-evals.js
CHANGED
|
@@ -8732,16 +8732,27 @@ function wrap(fn, name, reference, process2, options = {}) {
|
|
|
8732
8732
|
validate(options.contract?.args, args);
|
|
8733
8733
|
phase = "execution";
|
|
8734
8734
|
const value = fn.apply(this, args);
|
|
8735
|
+
const observeResult = (result) => {
|
|
8736
|
+
let succeeded = true;
|
|
8737
|
+
try {
|
|
8738
|
+
succeeded = (options.succeeded ?? process2?.succeeded)?.(result) ?? true;
|
|
8739
|
+
} catch {
|
|
8740
|
+
}
|
|
8741
|
+
if (succeeded)
|
|
8742
|
+
emit("completed");
|
|
8743
|
+
else
|
|
8744
|
+
emit("failed", "execution");
|
|
8745
|
+
};
|
|
8735
8746
|
const complete = (result) => {
|
|
8736
8747
|
phase = "output";
|
|
8737
8748
|
validate(options.contract?.result, result);
|
|
8738
|
-
|
|
8749
|
+
observeResult(result);
|
|
8739
8750
|
return result;
|
|
8740
8751
|
};
|
|
8741
8752
|
if (value && typeof value.then === "function") {
|
|
8742
8753
|
if (options.contract?.result)
|
|
8743
8754
|
return Promise.resolve(value).then(complete).catch(failed);
|
|
8744
|
-
void Promise.resolve(value).then(
|
|
8755
|
+
void Promise.resolve(value).then(observeResult, () => emit("failed", "execution"));
|
|
8745
8756
|
return value;
|
|
8746
8757
|
}
|
|
8747
8758
|
return complete(value);
|