@clearideas/agent-runtime-step-standard 0.6.1 → 0.6.3
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 +28 -11
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -209,19 +209,34 @@ const operationSignal = (parent, timeoutMs) => {
|
|
|
209
209
|
},
|
|
210
210
|
};
|
|
211
211
|
};
|
|
212
|
-
const raceWithSignal = async (
|
|
212
|
+
const raceWithSignal = async (start, signal) => {
|
|
213
213
|
if (signal.aborted)
|
|
214
214
|
throw abortReason(signal);
|
|
215
215
|
return new Promise((resolve, reject) => {
|
|
216
|
-
const
|
|
216
|
+
const cleanup = () => signal.removeEventListener("abort", onAbort);
|
|
217
|
+
const onAbort = () => {
|
|
218
|
+
cleanup();
|
|
219
|
+
reject(abortReason(signal));
|
|
220
|
+
};
|
|
221
|
+
// Subscribe before invoking host code: start() may abort synchronously.
|
|
217
222
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
+
if (signal.aborted) {
|
|
224
|
+
onAbort();
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
try {
|
|
228
|
+
Promise.resolve(start()).then((value) => {
|
|
229
|
+
cleanup();
|
|
230
|
+
resolve(value);
|
|
231
|
+
}, (error) => {
|
|
232
|
+
cleanup();
|
|
233
|
+
reject(error);
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
catch (error) {
|
|
237
|
+
cleanup();
|
|
223
238
|
reject(error);
|
|
224
|
-
}
|
|
239
|
+
}
|
|
225
240
|
});
|
|
226
241
|
};
|
|
227
242
|
const byteLength = (value) => new TextEncoder().encode(value).byteLength;
|
|
@@ -271,6 +286,7 @@ export class ApprovalStepExecutor {
|
|
|
271
286
|
if (!context.approvals) {
|
|
272
287
|
throw new Error(`Approval step ${context.step.id} requires an ApprovalAdapter`);
|
|
273
288
|
}
|
|
289
|
+
const approvals = context.approvals;
|
|
274
290
|
if (context.signal?.aborted)
|
|
275
291
|
throw abortReason(context.signal);
|
|
276
292
|
await context.emit("approval.requested", {
|
|
@@ -279,7 +295,7 @@ export class ApprovalStepExecutor {
|
|
|
279
295
|
const operation = operationSignal(context.signal, this.#timeoutMs);
|
|
280
296
|
let result;
|
|
281
297
|
try {
|
|
282
|
-
result = await raceWithSignal(
|
|
298
|
+
result = await raceWithSignal(() => approvals.requestApproval({
|
|
283
299
|
runId: context.runId,
|
|
284
300
|
stepId: context.step.id,
|
|
285
301
|
prompt: compilePromptTemplate(context.step.prompt, context.variables),
|
|
@@ -528,7 +544,7 @@ export class WebhookStepExecutor {
|
|
|
528
544
|
}
|
|
529
545
|
let output;
|
|
530
546
|
try {
|
|
531
|
-
output = await raceWithSignal(readWebhookOutput(response, this.#maximumResponseBytes), operation.signal);
|
|
547
|
+
output = await raceWithSignal(() => readWebhookOutput(response, this.#maximumResponseBytes), operation.signal);
|
|
532
548
|
}
|
|
533
549
|
catch (error) {
|
|
534
550
|
const timedOut = operation.didTimeOut();
|
|
@@ -593,6 +609,7 @@ export class CodeStepExecutor {
|
|
|
593
609
|
if (!context.sandbox) {
|
|
594
610
|
throw new Error(`Code step ${context.step.id} requires a SandboxAdapter`);
|
|
595
611
|
}
|
|
612
|
+
const sandbox = context.sandbox;
|
|
596
613
|
if (context.signal?.aborted)
|
|
597
614
|
throw abortReason(context.signal);
|
|
598
615
|
const timeoutMs = positiveInteger(context.step.timeoutMs, this.#defaultTimeoutMs, this.#maximumTimeoutMs, "Code timeoutMs");
|
|
@@ -604,7 +621,7 @@ export class CodeStepExecutor {
|
|
|
604
621
|
const operation = operationSignal(context.signal, timeoutMs);
|
|
605
622
|
let result;
|
|
606
623
|
try {
|
|
607
|
-
result = await raceWithSignal(
|
|
624
|
+
result = await raceWithSignal(() => sandbox.execute({
|
|
608
625
|
runId: context.runId,
|
|
609
626
|
stepId: context.step.id,
|
|
610
627
|
language: context.step.language,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clearideas/agent-runtime-step-standard",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"description": "Approval, webhook, and sandboxed code executors for Clear Ideas Agent Runtime.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Clear Ideas Incorporated",
|
|
@@ -36,12 +36,12 @@
|
|
|
36
36
|
"postpack": "node ../../scripts/cleanup-package-license.mjs"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@clearideas/agent-runtime-contracts": "0.6.
|
|
40
|
-
"@clearideas/agent-runtime-core": "0.6.
|
|
39
|
+
"@clearideas/agent-runtime-contracts": "0.6.3",
|
|
40
|
+
"@clearideas/agent-runtime-core": "0.6.3"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"typescript": "^7.0.2",
|
|
44
|
-
"vitest": "^5.
|
|
44
|
+
"vitest": "^5.1.0"
|
|
45
45
|
},
|
|
46
46
|
"engines": {
|
|
47
47
|
"node": ">=24"
|