@andromarces/agent-loops 0.2.2 → 0.3.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/README.md +192 -114
- package/docs/orchestrator-instructions.md +25 -22
- package/package.json +2 -2
- package/src/agents/agy.mjs +2 -11
- package/src/agents/codex.mjs +3 -20
- package/src/agents/copilot.mjs +8 -16
- package/src/agents/opencode.mjs +2 -7
- package/src/agents/shared.mjs +29 -0
- package/src/cli.mjs +46 -25
- package/src/hook/antigravity-parent-guard.mjs +28 -0
- package/src/hook/copilot-parent-guard.mjs +5 -30
- package/src/hook/decision.mjs +59 -6
- package/src/hook/opencode-plugin.mjs +92 -0
- package/src/hook/parent-guard.mjs +8 -33
- package/src/install/commands.mjs +268 -0
- package/src/install/fsutil.mjs +159 -0
- package/src/install/harnesses.mjs +170 -0
- package/src/install/installer.mjs +688 -0
- package/src/install/manifest.mjs +222 -0
- package/src/install/settings.mjs +217 -0
- package/src/install/templates/antigravity/agent-loop-antigravity-parent-guard.mjs +14 -0
- package/src/install/templates/antigravity/hooks.json +16 -0
- package/src/install/templates/antigravity/skills/agent-loop/SKILL.md +24 -0
- package/src/install/templates/claude/skills/agent-loop/SKILL.md +33 -0
- package/src/install/templates/codex/skills/agent-loop/SKILL.md +30 -0
- package/src/install/templates/codex/skills/agent-loop/agents/openai.yaml +2 -0
- package/src/install/templates/copilot/hooks/parent-guard.json +15 -0
- package/src/install/templates/opencode/plugins/parent-guard.ts +11 -0
- package/src/lib/args.mjs +23 -0
- package/src/lib/hash.mjs +9 -0
- package/src/lib/log.mjs +18 -3
- package/src/lib/process-ancestry.mjs +104 -0
- package/src/lib/runstate.mjs +133 -38
- package/src/lib/snapshot.mjs +3 -7
- package/src/role.mjs +71 -87
- package/src/runtime.mjs +9 -9
package/src/runtime.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { defaultAgents, runAgent } from "./agents/index.mjs";
|
|
2
|
+
import { DEFAULT_MAX_STEPS } from "./lib/args.mjs";
|
|
2
3
|
import { logError, logInfo, logWarn } from "./lib/log.mjs";
|
|
3
4
|
import { withMutationCheck } from "./lib/snapshot.mjs";
|
|
4
5
|
import { decide } from "./orchestrator.mjs";
|
|
@@ -59,8 +60,8 @@ export async function runChild(options) {
|
|
|
59
60
|
? workerPrompt(prompt, role.sessionId === null)
|
|
60
61
|
: reviewerPrompt(prompt);
|
|
61
62
|
|
|
62
|
-
const runFn =
|
|
63
|
-
|
|
63
|
+
const runFn = () =>
|
|
64
|
+
invoke(
|
|
64
65
|
agents,
|
|
65
66
|
role,
|
|
66
67
|
roleName,
|
|
@@ -69,7 +70,6 @@ export async function runChild(options) {
|
|
|
69
70
|
onEvent,
|
|
70
71
|
stepsUsed,
|
|
71
72
|
);
|
|
72
|
-
};
|
|
73
73
|
|
|
74
74
|
try {
|
|
75
75
|
const response = readOnly ? await withMutationCheck(cwd, roleName, runFn) : await runFn();
|
|
@@ -102,7 +102,7 @@ export async function runLoop(options) {
|
|
|
102
102
|
const {
|
|
103
103
|
task,
|
|
104
104
|
cwd,
|
|
105
|
-
maxSteps =
|
|
105
|
+
maxSteps = DEFAULT_MAX_STEPS,
|
|
106
106
|
timeout,
|
|
107
107
|
signal,
|
|
108
108
|
roles,
|
|
@@ -119,6 +119,8 @@ export async function runLoop(options) {
|
|
|
119
119
|
return { exitCode, ...detail };
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
+
let stepsUsed = 0;
|
|
123
|
+
|
|
122
124
|
const orchAdapter = {
|
|
123
125
|
async run(state, p, opts) {
|
|
124
126
|
return withMutationCheck(cwd, "orchestrator", () =>
|
|
@@ -127,7 +129,6 @@ export async function runLoop(options) {
|
|
|
127
129
|
},
|
|
128
130
|
};
|
|
129
131
|
|
|
130
|
-
let stepsUsed = 0;
|
|
131
132
|
let prompt = initialPrompt({ task, maxSteps });
|
|
132
133
|
|
|
133
134
|
while (true) {
|
|
@@ -140,11 +141,10 @@ export async function runLoop(options) {
|
|
|
140
141
|
options: { cwd, timeout, signal },
|
|
141
142
|
});
|
|
142
143
|
} catch (err) {
|
|
143
|
-
if (err?.name
|
|
144
|
-
//
|
|
145
|
-
|
|
144
|
+
if (err?.name !== "MutationError") {
|
|
145
|
+
// A MutationError is already logged at the detection site in withMutationCheck.
|
|
146
|
+
logError(`orchestrator turn failed: ${String(err?.message ?? err).split("\n")[0]}`);
|
|
146
147
|
}
|
|
147
|
-
logError(`orchestrator turn failed: ${String(err?.message ?? err).split("\n")[0]}`);
|
|
148
148
|
throw err;
|
|
149
149
|
}
|
|
150
150
|
|