@clearideas/agent-runtime-step-standard 0.9.0 → 1.0.0
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/NOTICE +2 -2
- package/dist/index.js +65 -2
- package/package.json +3 -3
package/NOTICE
CHANGED
|
@@ -3,6 +3,6 @@ Copyright 2026 Clear Ideas Incorporated
|
|
|
3
3
|
|
|
4
4
|
Clear Ideas is a trademark of Clear Ideas Incorporated.
|
|
5
5
|
|
|
6
|
-
The documentation site includes @clearideas/analytics 1.
|
|
6
|
+
The documentation site includes @clearideas/consent-analytics 0.1.0-rc.1, distributed
|
|
7
7
|
under the MIT License. Its license text is available at
|
|
8
|
-
docs/public/assets/analytics/LICENSE.clearideas-analytics.txt.
|
|
8
|
+
docs/public/assets/analytics/LICENSE.clearideas-consent-analytics.txt.
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { compilePromptTemplate, RunCancelledError, RunSuspendedError, withoutMessagesView, } from "@clearideas/agent-runtime-core";
|
|
1
|
+
import { compilePromptTemplate, createErrorSuspension, createLimitSuspension, RunCancelledError, RunSuspendedError, withoutMessagesView, } from "@clearideas/agent-runtime-core";
|
|
2
2
|
const getMappedVariable = (variables, path) => {
|
|
3
3
|
let current = variables;
|
|
4
4
|
for (const segment of path.split(".")) {
|
|
@@ -512,7 +512,9 @@ export class WebhookStepExecutor {
|
|
|
512
512
|
headers.set("Idempotency-Key", context.step.idempotencyKey);
|
|
513
513
|
}
|
|
514
514
|
else {
|
|
515
|
-
|
|
515
|
+
// The execution key distinguishes loop iterations and is stable when an
|
|
516
|
+
// execution resumes; for a top-level step it is the step id.
|
|
517
|
+
setHeader(headers, "Idempotency-Key", `${context.runId}:${context.executionKey ?? context.step.id}`);
|
|
516
518
|
}
|
|
517
519
|
let body;
|
|
518
520
|
if (context.step.body !== undefined && method === "GET") {
|
|
@@ -751,6 +753,44 @@ export class CodeStepExecutor {
|
|
|
751
753
|
sandbox: "run",
|
|
752
754
|
workspaces: [...(context.step.workspaces ?? [])],
|
|
753
755
|
});
|
|
756
|
+
// A code command changes workspaces in ways that cannot be judged safe
|
|
757
|
+
// to repeat. When the run waits for its host on failures (`onFailure:
|
|
758
|
+
// pause`, the default) and the previous attempt stopped while this code
|
|
759
|
+
// ran, pause once so the host can inspect (or restart from the previous
|
|
760
|
+
// step); the next resume runs it again. Under `fail` it runs again.
|
|
761
|
+
const reportInterruption = context.policies?.onFailure !== "fail" && context.checkpoint != null;
|
|
762
|
+
const saved = context.resume?.continuation;
|
|
763
|
+
const ownSaved = saved?.type === "code" && saved.stepId === context.step.id
|
|
764
|
+
? saved.phase
|
|
765
|
+
: undefined;
|
|
766
|
+
if (reportInterruption && ownSaved === "started") {
|
|
767
|
+
await context.checkpoint({
|
|
768
|
+
state: { ...context.variables },
|
|
769
|
+
continuation: {
|
|
770
|
+
type: "code",
|
|
771
|
+
stepId: context.step.id,
|
|
772
|
+
phase: "reported",
|
|
773
|
+
},
|
|
774
|
+
});
|
|
775
|
+
throw createErrorSuspension({
|
|
776
|
+
error: {
|
|
777
|
+
code: "STEP_INTERRUPTED_IN_DOUBT",
|
|
778
|
+
message: `Code step ${context.step.id} was interrupted while it ran in the run sandbox; its workspace changes may be partly applied. Inspect the workspace, then resume to run it again, or restart the run from the previous step.`,
|
|
779
|
+
retryable: true,
|
|
780
|
+
},
|
|
781
|
+
stepId: context.step.id,
|
|
782
|
+
});
|
|
783
|
+
}
|
|
784
|
+
if (reportInterruption) {
|
|
785
|
+
await context.checkpoint({
|
|
786
|
+
state: { ...context.variables },
|
|
787
|
+
continuation: {
|
|
788
|
+
type: "code",
|
|
789
|
+
stepId: context.step.id,
|
|
790
|
+
phase: "started",
|
|
791
|
+
},
|
|
792
|
+
});
|
|
793
|
+
}
|
|
754
794
|
const session = await context.runSandbox();
|
|
755
795
|
let result;
|
|
756
796
|
try {
|
|
@@ -775,9 +815,24 @@ export class CodeStepExecutor {
|
|
|
775
815
|
if (error.code === "sandbox_command_timeout") {
|
|
776
816
|
throw new SandboxTimeoutError(timeoutMs);
|
|
777
817
|
}
|
|
818
|
+
const limit = error.limit;
|
|
819
|
+
if (typeof limit?.name === "string" &&
|
|
820
|
+
typeof limit.used === "number" &&
|
|
821
|
+
typeof limit.value === "number") {
|
|
822
|
+
// A sandbox usage limit suspends the run until the host grants more.
|
|
823
|
+
throw createLimitSuspension({
|
|
824
|
+
limit: limit.name,
|
|
825
|
+
used: limit.used,
|
|
826
|
+
value: limit.value,
|
|
827
|
+
stepId: context.step.id,
|
|
828
|
+
});
|
|
829
|
+
}
|
|
778
830
|
throw error;
|
|
779
831
|
}
|
|
780
832
|
const { record } = result;
|
|
833
|
+
const notPersisted = result.notPersisted?.length
|
|
834
|
+
? JSON.parse(JSON.stringify(result.notPersisted))
|
|
835
|
+
: undefined;
|
|
781
836
|
await context.emit("code.execution.completed", {
|
|
782
837
|
exitCode: record.exitCode,
|
|
783
838
|
succeeded: record.exitCode === 0,
|
|
@@ -786,6 +841,13 @@ export class CodeStepExecutor {
|
|
|
786
841
|
sandbox: "run",
|
|
787
842
|
commandId: record.id,
|
|
788
843
|
});
|
|
844
|
+
if (notPersisted !== undefined) {
|
|
845
|
+
await context.emit("diagnostic", {
|
|
846
|
+
code: "WORKSPACE_CHANGES_NOT_SAVED",
|
|
847
|
+
message: `Code step ${context.step.id} changed workspace files that were not saved.`,
|
|
848
|
+
notPersisted,
|
|
849
|
+
});
|
|
850
|
+
}
|
|
789
851
|
if (record.exitCode !== 0) {
|
|
790
852
|
throw new SandboxExecutionError(context.step.id, record.exitCode);
|
|
791
853
|
}
|
|
@@ -803,6 +865,7 @@ export class CodeStepExecutor {
|
|
|
803
865
|
hasOutput: output !== undefined,
|
|
804
866
|
sandbox: "run",
|
|
805
867
|
command: JSON.parse(JSON.stringify(record)),
|
|
868
|
+
...(notPersisted !== undefined ? { notPersisted } : {}),
|
|
806
869
|
},
|
|
807
870
|
};
|
|
808
871
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clearideas/agent-runtime-step-standard",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
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,8 +36,8 @@
|
|
|
36
36
|
"postpack": "node ../../scripts/cleanup-package-license.mjs"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@clearideas/agent-runtime-contracts": "0.
|
|
40
|
-
"@clearideas/agent-runtime-core": "0.
|
|
39
|
+
"@clearideas/agent-runtime-contracts": "1.0.0",
|
|
40
|
+
"@clearideas/agent-runtime-core": "1.0.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"typescript": "^7.0.2",
|