loopforge 1.8.0 → 1.15.1
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/backends/fs.d.ts.map +1 -1
- package/dist/backends/fs.js +13 -10
- package/dist/backends/fs.js.map +1 -1
- package/dist/backends/interface.d.ts +2 -0
- package/dist/backends/interface.d.ts.map +1 -1
- package/dist/builder.d.ts +13 -10
- package/dist/builder.d.ts.map +1 -1
- package/dist/builder.js +117 -96
- package/dist/builder.js.map +1 -1
- package/dist/enforcement-gate.d.ts +44 -0
- package/dist/enforcement-gate.d.ts.map +1 -0
- package/dist/enforcement-gate.js +253 -0
- package/dist/enforcement-gate.js.map +1 -0
- package/dist/engine.d.ts +13 -6
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +127 -171
- package/dist/engine.js.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/loop-compiler.d.ts +10 -2
- package/dist/loop-compiler.d.ts.map +1 -1
- package/dist/loop-compiler.js +882 -583
- package/dist/loop-compiler.js.map +1 -1
- package/dist/mcp/session.d.ts +12 -2
- package/dist/mcp/session.d.ts.map +1 -1
- package/dist/mcp/session.js +127 -64
- package/dist/mcp/session.js.map +1 -1
- package/dist/mcp/tools.js +4 -4
- package/dist/memory-bridge.js +1 -1
- package/dist/memory-bridge.js.map +1 -1
- package/dist/observability.d.ts +1 -1
- package/dist/observability.js +1 -1
- package/dist/policy.d.ts +80 -10
- package/dist/policy.d.ts.map +1 -1
- package/dist/policy.js +101 -30
- package/dist/policy.js.map +1 -1
- package/dist/protocol.d.ts +70 -16
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +40 -8
- package/dist/protocol.js.map +1 -1
- package/dist/replay.js +7 -7
- package/dist/replay.js.map +1 -1
- package/dist/runtime.d.ts +11 -7
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +125 -144
- package/dist/runtime.js.map +1 -1
- package/dist/tests/builder.test.js +42 -28
- package/dist/tests/builder.test.js.map +1 -1
- package/dist/tests/enforcement-gate.test.d.ts +2 -0
- package/dist/tests/enforcement-gate.test.d.ts.map +1 -0
- package/dist/tests/enforcement-gate.test.js +328 -0
- package/dist/tests/enforcement-gate.test.js.map +1 -0
- package/dist/tests/engine.test.js +22 -22
- package/dist/tests/engine.test.js.map +1 -1
- package/dist/tests/generate-schema.test.js +10 -7
- package/dist/tests/generate-schema.test.js.map +1 -1
- package/dist/tests/loop-compiler.test.js +273 -47
- package/dist/tests/loop-compiler.test.js.map +1 -1
- package/dist/tests/mcp.test.js +31 -11
- package/dist/tests/mcp.test.js.map +1 -1
- package/dist/tests/memory-bridge.test.js +0 -1
- package/dist/tests/memory-bridge.test.js.map +1 -1
- package/dist/tests/policy.test.js +6 -16
- package/dist/tests/policy.test.js.map +1 -1
- package/dist/tests/protocol.test.js +3 -2
- package/dist/tests/protocol.test.js.map +1 -1
- package/dist/tests/replay.test.js +9 -9
- package/dist/tests/replay.test.js.map +1 -1
- package/dist/tests/runtime.test.js +27 -13
- package/dist/tests/runtime.test.js.map +1 -1
- package/dist/tests/verification-gate.test.js +1 -1
- package/dist/tests/verification-gate.test.js.map +1 -1
- package/dist/verification-gate.d.ts +8 -2
- package/dist/verification-gate.d.ts.map +1 -1
- package/dist/verification-gate.js +5 -4
- package/dist/verification-gate.js.map +1 -1
- package/loop_policy.json +13 -26
- package/package.json +1 -1
- package/skills/perception/SKILL.md +42 -23
- package/skills/prompt-techniques/SKILL.md +52 -52
- package/skills/prompt-techniques/references/chain-of-thought.md +207 -207
- package/skills/prompt-techniques/references/few-shot.md +174 -174
- package/skills/prompt-techniques/references/least-to-most.md +182 -182
- package/skills/prompt-techniques/references/step-back.md +160 -160
- package/skills/prompt-techniques/references/tree-of-thought.md +191 -191
- package/skills/prompt-techniques/references/zero-shot.md +97 -97
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
/** Enforcement Gate — Layer 2 round-boundary runtime enforcement (v1.13).
|
|
2
|
+
*
|
|
3
|
+
* Pure-function module. Receives the verification gate's findings plus
|
|
4
|
+
* round-level context and decides whether to accept the round, reject it
|
|
5
|
+
* (force the agent to redo), or terminate the loop.
|
|
6
|
+
*
|
|
7
|
+
* This is the "runtime" that prompt-only constraint systems lack.
|
|
8
|
+
* Verification gate detects WHAT is wrong; enforcement gate decides
|
|
9
|
+
* what to DO about it.
|
|
10
|
+
*
|
|
11
|
+
* Decision semantics:
|
|
12
|
+
* - accept: round passes all checks; advance to next round as normal.
|
|
13
|
+
* - reject: agent's self-evaluation or round output is invalid; the
|
|
14
|
+
* agent receives a rejection prompt and must redo the SAME
|
|
15
|
+
* round. Round counter does NOT increment.
|
|
16
|
+
* - terminate: loop has reached an unrecoverable state; stop immediately
|
|
17
|
+
* with stopReason "enforcement_terminated".
|
|
18
|
+
*/
|
|
19
|
+
import { makeEnforcementResult } from "./protocol.js";
|
|
20
|
+
import { entryRound } from "./verification-gate.js";
|
|
21
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
22
|
+
// Helpers
|
|
23
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
24
|
+
/** Extract progress_estimate from a vault entry's execution_evidence.
|
|
25
|
+
* Returns null if no execution evidence is available. */
|
|
26
|
+
function entryProgress(entry) {
|
|
27
|
+
const evidence = entry.execution_evidence;
|
|
28
|
+
if (!evidence)
|
|
29
|
+
return null;
|
|
30
|
+
const pe = evidence.progress_estimate;
|
|
31
|
+
return typeof pe === "number" ? pe : null;
|
|
32
|
+
}
|
|
33
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
34
|
+
// Individual enforcement rules — each returns EnforcementResult | null
|
|
35
|
+
// Rules are ordered by priority. The first non-null result wins.
|
|
36
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
37
|
+
/** R1: Agent claims success but success_criteria_remaining has items.
|
|
38
|
+
* This is a lie — the agent must either finish the criteria or
|
|
39
|
+
* set success=false honestly. Triggered by the verification gate's
|
|
40
|
+
* "success_with_remaining_criteria" error flag. */
|
|
41
|
+
function enforceSuccessWithRemainingCriteria(flags) {
|
|
42
|
+
const flag = flags.find((f) => f.check === "success_with_remaining_criteria" && f.severity === "error");
|
|
43
|
+
if (!flag)
|
|
44
|
+
return null;
|
|
45
|
+
return makeEnforcementResult({
|
|
46
|
+
action: "reject",
|
|
47
|
+
reason: flag.detail,
|
|
48
|
+
fix_instructions: "You set success=true but success criteria remain unmet. " +
|
|
49
|
+
"Either: (a) complete the remaining criteria and re-submit your self-evaluation, " +
|
|
50
|
+
"or (b) set success=false and honestly report what remains to be done.",
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
/** R2: Same constraint violation appears in 3 consecutive rounds.
|
|
54
|
+
* The agent is repeating the same mistake. Triggered by the verification
|
|
55
|
+
* gate's "recurring_violation" error flag. */
|
|
56
|
+
function enforceRecurringViolation(flags) {
|
|
57
|
+
const flag = flags.find((f) => f.check === "recurring_violation" && f.severity === "error");
|
|
58
|
+
if (!flag)
|
|
59
|
+
return null;
|
|
60
|
+
return makeEnforcementResult({
|
|
61
|
+
action: "reject",
|
|
62
|
+
reason: flag.detail,
|
|
63
|
+
fix_instructions: "The same constraint violation has appeared in 3 consecutive rounds. " +
|
|
64
|
+
"You must: (a) explain WHY this violation keeps occurring, " +
|
|
65
|
+
"and (b) propose a DIFFERENT approach than what you used in the last 3 rounds. " +
|
|
66
|
+
"Do NOT retry the same strategy — it has failed 3 times.",
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
/** R3: Agent claims success but did nothing verifiable.
|
|
70
|
+
* Only fires when execution_evidence IS provided (structured self-eval path)
|
|
71
|
+
* but shows no files changed AND no tests run AND success=true.
|
|
72
|
+
* Skips when execution_evidence is undefined (heuristic fallback) —
|
|
73
|
+
* heuristic evaluations have no evidence by definition. */
|
|
74
|
+
function enforceEmptySuccess(selfEval, _flags) {
|
|
75
|
+
if (!selfEval.success)
|
|
76
|
+
return null;
|
|
77
|
+
const ev = selfEval.execution_evidence;
|
|
78
|
+
// Skip if no execution_evidence at all — this is the heuristic fallback
|
|
79
|
+
// case where the agent didn't provide structured evidence.
|
|
80
|
+
if (!ev)
|
|
81
|
+
return null;
|
|
82
|
+
const filesEmpty = ev.files_changed.length === 0;
|
|
83
|
+
const testsNotRun = ev.test_results === null;
|
|
84
|
+
if (!filesEmpty || !testsNotRun)
|
|
85
|
+
return null;
|
|
86
|
+
return makeEnforcementResult({
|
|
87
|
+
action: "reject",
|
|
88
|
+
reason: "Agent claims success but execution_evidence shows no files changed " +
|
|
89
|
+
"and no tests were run. There is no verifiable evidence of work.",
|
|
90
|
+
fix_instructions: "You must provide verifiable evidence: " +
|
|
91
|
+
"(a) list the files you changed in execution_evidence.files_changed, " +
|
|
92
|
+
"and (b) run tests and report results in execution_evidence.test_results. " +
|
|
93
|
+
"If you genuinely completed the task without file changes or tests, " +
|
|
94
|
+
"explain why in detail in your output_summary.",
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
/** R4: Progress has stalled for 3+ consecutive rounds.
|
|
98
|
+
* Detected by checking progress_estimate deltas across vault entries.
|
|
99
|
+
* First occurrence → REJECT (agent must change approach).
|
|
100
|
+
* Second consecutive occurrence → TERMINATE (agent cannot recover). */
|
|
101
|
+
function enforceProgressStall(_selfEval, _flags, currentRound, vaultEntries, consecutiveRejections) {
|
|
102
|
+
// Need at least 3 rounds of history
|
|
103
|
+
if (currentRound < 3)
|
|
104
|
+
return null;
|
|
105
|
+
// Collect progress estimates for the last 3 completed rounds from vault
|
|
106
|
+
const progressByRound = new Map();
|
|
107
|
+
for (const entry of vaultEntries) {
|
|
108
|
+
const rnd = entryRound(entry);
|
|
109
|
+
// Only consider rounds before the current one
|
|
110
|
+
if (rnd < 1 || rnd >= currentRound)
|
|
111
|
+
continue;
|
|
112
|
+
const pe = entryProgress(entry);
|
|
113
|
+
if (pe !== null)
|
|
114
|
+
progressByRound.set(rnd, pe);
|
|
115
|
+
}
|
|
116
|
+
// Need at least 3 data points
|
|
117
|
+
if (progressByRound.size < 3)
|
|
118
|
+
return null;
|
|
119
|
+
// Get the three most recent rounds with progress data
|
|
120
|
+
const sortedRounds = [...progressByRound.keys()].sort((a, b) => a - b);
|
|
121
|
+
const last3 = sortedRounds.slice(-3);
|
|
122
|
+
if (last3.length < 3)
|
|
123
|
+
return null;
|
|
124
|
+
// Verify these are the actual last 3 rounds (contiguous with current)
|
|
125
|
+
// Accept rounds that are within [currentRound-3, currentRound-1]
|
|
126
|
+
const expectedMin = currentRound - 3;
|
|
127
|
+
const actualMin = last3[0];
|
|
128
|
+
// Allow up to 1 round gap (some rounds may not have progress data)
|
|
129
|
+
if (actualMin < expectedMin - 1 || last3[2] > currentRound - 1)
|
|
130
|
+
return null;
|
|
131
|
+
const p1 = progressByRound.get(last3[0]);
|
|
132
|
+
const p2 = progressByRound.get(last3[1]);
|
|
133
|
+
const p3 = progressByRound.get(last3[2]);
|
|
134
|
+
const stallThreshold = 0.05;
|
|
135
|
+
const delta12 = p2 - p1;
|
|
136
|
+
const delta23 = p3 - p2;
|
|
137
|
+
// Both deltas must be below threshold AND not near completion
|
|
138
|
+
const isStalling = delta12 < stallThreshold &&
|
|
139
|
+
delta23 < stallThreshold &&
|
|
140
|
+
p3 < 0.95;
|
|
141
|
+
if (!isStalling)
|
|
142
|
+
return null;
|
|
143
|
+
// If already rejected once for stall → escalate to terminate
|
|
144
|
+
if (consecutiveRejections >= 1) {
|
|
145
|
+
return makeEnforcementResult({
|
|
146
|
+
action: "terminate",
|
|
147
|
+
reason: `Progress stalled for 3+ rounds ` +
|
|
148
|
+
`(${(p1 * 100).toFixed(0)}% → ${(p2 * 100).toFixed(0)}% → ${(p3 * 100).toFixed(0)}%) ` +
|
|
149
|
+
`and agent did not resolve after previous rejection. Terminating loop.`,
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
return makeEnforcementResult({
|
|
153
|
+
action: "reject",
|
|
154
|
+
reason: `Progress has stalled: ${(p1 * 100).toFixed(0)}% → ` +
|
|
155
|
+
`${(p2 * 100).toFixed(0)}% → ${(p3 * 100).toFixed(0)}% over the ` +
|
|
156
|
+
`last 3 rounds (delta < ${(stallThreshold * 100).toFixed(0)}% each round).`,
|
|
157
|
+
fix_instructions: "Your progress has been flat for 3 rounds. You must: " +
|
|
158
|
+
"(a) explain what is blocking progress, " +
|
|
159
|
+
"(b) propose a DIFFERENT technique or task decomposition, and " +
|
|
160
|
+
"(c) set a concrete, verifiable goal for the redo of this round. " +
|
|
161
|
+
"Do NOT repeat the same approach — it has not moved progress forward.",
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
/** R5: Two consecutive rejections → terminate.
|
|
165
|
+
* The agent has been unable or unwilling to fix the identified issues
|
|
166
|
+
* across two consecutive enforcement rejections. */
|
|
167
|
+
function enforceMaxRejections(consecutiveRejections) {
|
|
168
|
+
if (consecutiveRejections < 2)
|
|
169
|
+
return null;
|
|
170
|
+
return makeEnforcementResult({
|
|
171
|
+
action: "terminate",
|
|
172
|
+
reason: `${consecutiveRejections} consecutive enforcement rejections without ` +
|
|
173
|
+
`resolution. The agent has been unable to correct the identified issues.`,
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
177
|
+
// Main entry point
|
|
178
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
179
|
+
/** Enforce round-boundary rules based on the verification gate's findings
|
|
180
|
+
* and the agent's self-evaluation integrity.
|
|
181
|
+
*
|
|
182
|
+
* Rules run in priority order (R1 → R5). The first rule that fires wins.
|
|
183
|
+
*
|
|
184
|
+
* @param selfEval The agent's self-evaluation for the current round.
|
|
185
|
+
* @param verifyResult The verification gate's output (from verifySelfEvaluation).
|
|
186
|
+
* @param currentRound Current round number (1-based, BEFORE increment).
|
|
187
|
+
* @param vaultEntries Vault entries for this loop (used for progress tracking).
|
|
188
|
+
* @param consecutiveRejections How many consecutive rounds have already been rejected.
|
|
189
|
+
* Starts at 0; increments on each reject; resets on accept.
|
|
190
|
+
*/
|
|
191
|
+
export function enforceRound(selfEval, verifyResult, currentRound, vaultEntries, consecutiveRejections = 0) {
|
|
192
|
+
const { flags } = verifyResult;
|
|
193
|
+
// Run enforcement rules in priority order.
|
|
194
|
+
// Earlier rules take higher precedence.
|
|
195
|
+
const rules = [
|
|
196
|
+
() => enforceSuccessWithRemainingCriteria(flags),
|
|
197
|
+
() => enforceRecurringViolation(flags),
|
|
198
|
+
() => enforceEmptySuccess(selfEval, flags),
|
|
199
|
+
() => enforceProgressStall(selfEval, flags, currentRound, vaultEntries, consecutiveRejections),
|
|
200
|
+
() => enforceMaxRejections(consecutiveRejections),
|
|
201
|
+
];
|
|
202
|
+
for (const rule of rules) {
|
|
203
|
+
const result = rule();
|
|
204
|
+
if (result)
|
|
205
|
+
return result;
|
|
206
|
+
}
|
|
207
|
+
// All rules passed — accept the round
|
|
208
|
+
return makeEnforcementResult({
|
|
209
|
+
action: "accept",
|
|
210
|
+
reason: "",
|
|
211
|
+
fix_instructions: "",
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
/** Build a rejection prompt for the agent.
|
|
215
|
+
*
|
|
216
|
+
* The prompt clearly states the round was rejected, why, what the agent
|
|
217
|
+
* must fix, and that the agent must redo the SAME round (not advance).
|
|
218
|
+
*
|
|
219
|
+
* @param currentRound The round number that was rejected (NOT incremented).
|
|
220
|
+
* @param task The original loop task description.
|
|
221
|
+
* @param enforceResult The enforcement decision with reason and fix instructions.
|
|
222
|
+
*/
|
|
223
|
+
export function buildRejectionPrompt(currentRound, task, enforceResult) {
|
|
224
|
+
const lines = [
|
|
225
|
+
"## ⛔ Round " + currentRound + " — REJECTED",
|
|
226
|
+
"",
|
|
227
|
+
"Your self-evaluation for Round " + currentRound +
|
|
228
|
+
" was **rejected** by the enforcement gate.",
|
|
229
|
+
"",
|
|
230
|
+
"### Reason",
|
|
231
|
+
"",
|
|
232
|
+
enforceResult.reason,
|
|
233
|
+
"",
|
|
234
|
+
];
|
|
235
|
+
if (enforceResult.fix_instructions) {
|
|
236
|
+
lines.push("### Required Fix");
|
|
237
|
+
lines.push("");
|
|
238
|
+
lines.push(enforceResult.fix_instructions);
|
|
239
|
+
lines.push("");
|
|
240
|
+
}
|
|
241
|
+
lines.push("### Your Task (Round " + currentRound + " — Retry)");
|
|
242
|
+
lines.push("");
|
|
243
|
+
lines.push(task);
|
|
244
|
+
lines.push("");
|
|
245
|
+
lines.push("### Instructions");
|
|
246
|
+
lines.push("");
|
|
247
|
+
lines.push("1. Read and address each issue in **Required Fix** above.", "2. Re-execute **Round " + currentRound +
|
|
248
|
+
"** — do NOT advance to the next round.", "3. Submit a corrected self-evaluation via `loopforge_next`.", "4. Be honest in your self-evaluation — " +
|
|
249
|
+
"claiming success when criteria are unmet will be rejected again.", "5. If you believe this rejection is incorrect, " +
|
|
250
|
+
"explain why in your output_summary and the enforcement gate will re-evaluate.");
|
|
251
|
+
return lines.join("\n");
|
|
252
|
+
}
|
|
253
|
+
//# sourceMappingURL=enforcement-gate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enforcement-gate.js","sourceRoot":"","sources":["../src/enforcement-gate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AASH,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,8EAA8E;AAC9E,UAAU;AACV,8EAA8E;AAE9E;0DAC0D;AAC1D,SAAS,aAAa,CAAC,KAAiB;IACtC,MAAM,QAAQ,GAAG,KAAK,CAAC,kBAAyD,CAAC;IACjF,IAAI,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC3B,MAAM,EAAE,GAAG,QAAQ,CAAC,iBAAiB,CAAC;IACtC,OAAO,OAAO,EAAE,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,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AI,CAAC,IAAI,CAAC,CAAC;IACjB,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAEf,KAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;IAC/B,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACf,KAAK,CAAC,IAAI,CACR,2DAA2D,EAC3D,wBAAwB,GAAG,YAAY;QACvC,wCAAwC,EACxC,6DAA6D,EAC7D,yCAAyC;QACzC,kEAAkE,EAClE,iDAAiD;QACjD,+EAA+E,CAChF,CAAC;IAEF,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
package/dist/engine.d.ts
CHANGED
|
@@ -6,7 +6,16 @@
|
|
|
6
6
|
* EngineMetrics tracks silent-failure counters for observability.
|
|
7
7
|
*/
|
|
8
8
|
import type { VaultBackend } from "./backends/interface.js";
|
|
9
|
-
import { type AgentLoopResult, type LoopForgeRequest, type SelfEvaluation, type SessionState } from "./protocol.js";
|
|
9
|
+
import { type AgentLoopResult, type CriterionRevision, type ExecutionEvidence, type LoopForgeRequest, type SelfEvaluation, type SessionState } from "./protocol.js";
|
|
10
|
+
/** Parse ExecutionEvidence from a raw JSON object. Shared by buildSelfEvaluation
|
|
11
|
+
* and invokeLoopCompile — both parse the same execution_evidence shape. */
|
|
12
|
+
export declare function parseExecutionEvidence(raw: Record<string, unknown> | undefined | null): ExecutionEvidence | undefined;
|
|
13
|
+
/** Parse CriterionRevision[] from a raw JSON array. Shared by buildSelfEvaluation
|
|
14
|
+
* and invokeLoopCompile — both parse the same revised_success_criteria shape. */
|
|
15
|
+
export declare function parseCriterionRevisions(raw: unknown): CriterionRevision[];
|
|
16
|
+
/** Parse WorkerResult[] from a raw JSON array. Shared by buildSelfEvaluation
|
|
17
|
+
* and invokeLoopCompile — both parse the same worker_results shape. */
|
|
18
|
+
export declare function parseWorkerResults(raw: unknown): import("./protocol.js").WorkerResult[];
|
|
10
19
|
/** Extract a structured SelfEvaluation from agent output text.
|
|
11
20
|
* Returns null if no valid self-eval block is found.
|
|
12
21
|
* The agent is instructed to output JSON between the delimiters. */
|
|
@@ -42,14 +51,12 @@ export interface EngineMetrics {
|
|
|
42
51
|
sessionStart: number;
|
|
43
52
|
}
|
|
44
53
|
export declare class LoopForgeEngine {
|
|
45
|
-
skillsDir: string;
|
|
46
54
|
state: SessionState | null;
|
|
47
55
|
private backend;
|
|
48
56
|
private metrics;
|
|
49
57
|
private feedbackWriteBuffer;
|
|
50
58
|
lastTask: string | null;
|
|
51
|
-
|
|
52
|
-
constructor(skillsDir?: string, backend?: VaultBackend);
|
|
59
|
+
constructor(_skillsDir?: string, backend?: VaultBackend);
|
|
53
60
|
private resolveBackend;
|
|
54
61
|
/** Public accessor for the vault backend — used by runtime/verification gate. */
|
|
55
62
|
getBackend(): VaultBackend;
|
|
@@ -70,8 +77,8 @@ export declare class LoopForgeEngine {
|
|
|
70
77
|
* P0–P2: Also persists discovered_constraints, objective_refinement,
|
|
71
78
|
* and emerged_subtasks for the compiler to consume next round.
|
|
72
79
|
* Call this BEFORE invokeLoopCompile for the next round so that
|
|
73
|
-
* hydrateLoopContext picks up the latest
|
|
74
|
-
autoFeedback(selfEval: SelfEvaluation, loopId: string, round: number, task: string):
|
|
80
|
+
* hydrateLoopContext picks up the latest success flags. */
|
|
81
|
+
autoFeedback(selfEval: SelfEvaluation, loopId: string, round: number, task: string): boolean;
|
|
75
82
|
invokeLoopCompile(request: LoopForgeRequest, hydrateResults?: Record<string, unknown> | null): AgentLoopResult;
|
|
76
83
|
shouldBreak(): boolean;
|
|
77
84
|
}
|
package/dist/engine.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,KAAK,EAAE,YAAY,EAAc,MAAM,yBAAyB,CAAC;AACxE,OAAO,EAcL,KAAK,eAAe,
|
|
1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