@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/index.mjs
CHANGED
|
@@ -219,16 +219,27 @@ function wrap(fn, name, reference, process2, options = {}) {
|
|
|
219
219
|
validate(options.contract?.args, args);
|
|
220
220
|
phase = "execution";
|
|
221
221
|
const value = fn.apply(this, args);
|
|
222
|
+
const observeResult = (result) => {
|
|
223
|
+
let succeeded = true;
|
|
224
|
+
try {
|
|
225
|
+
succeeded = (options.succeeded ?? process2?.succeeded)?.(result) ?? true;
|
|
226
|
+
} catch {
|
|
227
|
+
}
|
|
228
|
+
if (succeeded)
|
|
229
|
+
emit("completed");
|
|
230
|
+
else
|
|
231
|
+
emit("failed", "execution");
|
|
232
|
+
};
|
|
222
233
|
const complete = (result) => {
|
|
223
234
|
phase = "output";
|
|
224
235
|
validate(options.contract?.result, result);
|
|
225
|
-
|
|
236
|
+
observeResult(result);
|
|
226
237
|
return result;
|
|
227
238
|
};
|
|
228
239
|
if (value && typeof value.then === "function") {
|
|
229
240
|
if (options.contract?.result)
|
|
230
241
|
return Promise.resolve(value).then(complete).catch(failed);
|
|
231
|
-
void Promise.resolve(value).then(
|
|
242
|
+
void Promise.resolve(value).then(observeResult, () => emit("failed", "execution"));
|
|
232
243
|
return value;
|
|
233
244
|
}
|
|
234
245
|
return complete(value);
|