loopforge 2.7.0 → 3.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/README.md +136 -182
- package/dist/canonical-event-writer.d.ts +20 -0
- package/dist/canonical-event-writer.d.ts.map +1 -0
- package/dist/canonical-event-writer.js +131 -0
- package/dist/canonical-event-writer.js.map +1 -0
- package/dist/canonical-state.d.ts +20 -16
- package/dist/canonical-state.d.ts.map +1 -1
- package/dist/canonical-state.js +211 -64
- package/dist/canonical-state.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +11 -10
- package/dist/cli.js.map +1 -1
- package/dist/cognitive-governance.d.ts +48 -0
- package/dist/cognitive-governance.d.ts.map +1 -0
- package/dist/cognitive-governance.js +226 -0
- package/dist/cognitive-governance.js.map +1 -0
- package/dist/compiler-subgoals.d.ts +7 -0
- package/dist/compiler-subgoals.d.ts.map +1 -0
- package/dist/compiler-subgoals.js +93 -0
- package/dist/compiler-subgoals.js.map +1 -0
- package/dist/derive-id.d.ts +12 -0
- package/dist/derive-id.d.ts.map +1 -0
- package/dist/derive-id.js +31 -0
- package/dist/derive-id.js.map +1 -0
- package/dist/evidence-provider.d.ts +26 -26
- package/dist/evidence-provider.d.ts.map +1 -1
- package/dist/evidence-provider.js +45 -71
- package/dist/evidence-provider.js.map +1 -1
- package/dist/generate-schema.js +90 -2
- package/dist/generate-schema.js.map +1 -1
- package/dist/index.d.ts +23 -29
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -26
- package/dist/index.js.map +1 -1
- package/dist/loop-compiler.d.ts +2 -2
- package/dist/loop-compiler.d.ts.map +1 -1
- package/dist/loop-compiler.js +321 -315
- package/dist/loop-compiler.js.map +1 -1
- package/dist/loop-extras-parser.d.ts +2 -2
- package/dist/loop-extras-parser.d.ts.map +1 -1
- package/dist/loop-extras-parser.js +2 -2
- package/dist/loop-extras-parser.js.map +1 -1
- package/dist/loop-store.d.ts +20 -58
- package/dist/loop-store.d.ts.map +1 -1
- package/dist/loop-store.js +232 -311
- package/dist/loop-store.js.map +1 -1
- package/dist/mcp/server.d.ts +3 -3
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +123 -19
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/session-projection.d.ts +5 -0
- package/dist/mcp/session-projection.d.ts.map +1 -0
- package/dist/mcp/session-projection.js +18 -0
- package/dist/mcp/session-projection.js.map +1 -0
- package/dist/mcp/session-queue.d.ts +3 -0
- package/dist/mcp/session-queue.d.ts.map +1 -0
- package/dist/mcp/session-queue.js +18 -0
- package/dist/mcp/session-queue.js.map +1 -0
- package/dist/mcp/session-types.d.ts +72 -0
- package/dist/mcp/session-types.d.ts.map +1 -0
- package/dist/mcp/session-types.js +2 -0
- package/dist/mcp/session-types.js.map +1 -0
- package/dist/mcp/session.d.ts +65 -84
- package/dist/mcp/session.d.ts.map +1 -1
- package/dist/mcp/session.js +667 -224
- package/dist/mcp/session.js.map +1 -1
- package/dist/mcp/tools.d.ts +26 -1
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/mcp/tools.js +401 -254
- package/dist/mcp/tools.js.map +1 -1
- package/dist/policy-metrics.d.ts +24 -0
- package/dist/policy-metrics.d.ts.map +1 -1
- package/dist/policy-metrics.js +174 -0
- package/dist/policy-metrics.js.map +1 -1
- package/dist/policy.d.ts +74 -12
- package/dist/policy.d.ts.map +1 -1
- package/dist/policy.js +124 -19
- package/dist/policy.js.map +1 -1
- package/dist/prompt-assembler.d.ts +8 -4
- package/dist/prompt-assembler.d.ts.map +1 -1
- package/dist/prompt-assembler.js +533 -86
- package/dist/prompt-assembler.js.map +1 -1
- package/dist/prompt-policy.d.ts +8 -1
- package/dist/prompt-policy.d.ts.map +1 -1
- package/dist/prompt-policy.js +26 -8
- package/dist/prompt-policy.js.map +1 -1
- package/dist/protocol.d.ts +259 -173
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +17 -96
- package/dist/protocol.js.map +1 -1
- package/dist/replay.d.ts +11 -3
- package/dist/replay.d.ts.map +1 -1
- package/dist/replay.js +51 -14
- package/dist/replay.js.map +1 -1
- package/dist/round-commit-store.d.ts +12 -0
- package/dist/round-commit-store.d.ts.map +1 -0
- package/dist/round-commit-store.js +13 -0
- package/dist/round-commit-store.js.map +1 -0
- package/dist/round-coordinator.d.ts +53 -22
- package/dist/round-coordinator.d.ts.map +1 -1
- package/dist/round-coordinator.js +140 -44
- package/dist/round-coordinator.js.map +1 -1
- package/dist/round-driver.d.ts +18 -10
- package/dist/round-driver.d.ts.map +1 -1
- package/dist/round-driver.js +11 -13
- package/dist/round-driver.js.map +1 -1
- package/dist/round-gate.d.ts +31 -0
- package/dist/round-gate.d.ts.map +1 -0
- package/dist/round-gate.js +259 -0
- package/dist/round-gate.js.map +1 -0
- package/dist/round-recovery.d.ts +17 -0
- package/dist/round-recovery.d.ts.map +1 -0
- package/dist/round-recovery.js +117 -0
- package/dist/round-recovery.js.map +1 -0
- package/dist/round-report.d.ts +16 -0
- package/dist/round-report.d.ts.map +1 -0
- package/dist/round-report.js +401 -0
- package/dist/round-report.js.map +1 -0
- package/dist/round-transaction.d.ts +23 -12
- package/dist/round-transaction.d.ts.map +1 -1
- package/dist/round-transaction.js +104 -91
- package/dist/round-transaction.js.map +1 -1
- package/dist/runtime-services.d.ts +59 -0
- package/dist/runtime-services.d.ts.map +1 -0
- package/dist/{engine.js → runtime-services.js} +157 -275
- package/dist/runtime-services.js.map +1 -0
- package/dist/storage.d.ts +3 -9
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +6 -17
- package/dist/storage.js.map +1 -1
- package/dist/token-utils.d.ts +12 -8
- package/dist/token-utils.d.ts.map +1 -1
- package/dist/token-utils.js +56 -10
- package/dist/token-utils.js.map +1 -1
- package/dist/vault-format.d.ts +4 -0
- package/dist/vault-format.d.ts.map +1 -0
- package/dist/vault-format.js +4 -0
- package/dist/vault-format.js.map +1 -0
- package/dist/vault-types.d.ts +24 -0
- package/dist/vault-types.d.ts.map +1 -0
- package/dist/vault-types.js +2 -0
- package/dist/vault-types.js.map +1 -0
- package/loop_policy.json +10 -12
- package/loopforge-policy.json +340 -0
- package/package.json +13 -7
- package/skills/perception/SKILL.md +200 -90
- package/dist/backends/interface.d.ts +0 -39
- package/dist/backends/interface.d.ts.map +0 -1
- package/dist/backends/interface.js +0 -6
- package/dist/backends/interface.js.map +0 -1
- package/dist/enforcement-gate.d.ts +0 -50
- package/dist/enforcement-gate.d.ts.map +0 -1
- package/dist/enforcement-gate.js +0 -501
- package/dist/enforcement-gate.js.map +0 -1
- package/dist/engine.d.ts +0 -59
- package/dist/engine.d.ts.map +0 -1
- package/dist/engine.js.map +0 -1
- package/dist/interop.d.ts +0 -35
- package/dist/interop.d.ts.map +0 -1
- package/dist/interop.js +0 -34
- package/dist/interop.js.map +0 -1
- package/dist/run.d.ts +0 -51
- package/dist/run.d.ts.map +0 -1
- package/dist/run.js +0 -200
- package/dist/run.js.map +0 -1
- package/dist/self-eval.d.ts +0 -23
- package/dist/self-eval.d.ts.map +0 -1
- package/dist/self-eval.js +0 -151
- package/dist/self-eval.js.map +0 -1
- package/dist/verification-gate.d.ts +0 -52
- package/dist/verification-gate.d.ts.map +0 -1
- package/dist/verification-gate.js +0 -527
- package/dist/verification-gate.js.map +0 -1
package/dist/interop.d.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/** Dependency-free ecosystem checkpoint boundary.
|
|
2
|
-
*
|
|
3
|
-
* **@experimental** — This module is a lightweight stub (57 lines as of v2.0.0).
|
|
4
|
-
* The checkpoint interface is stable but the integration surface (sinks, schema
|
|
5
|
-
* versioning, external consumer contracts) has not been validated in production.
|
|
6
|
-
* Use for prototyping; expect the envelope shape to evolve before v2.1.
|
|
7
|
-
*
|
|
8
|
-
* LangGraph checkpointers, workflow engines, databases, and agent SDKs can
|
|
9
|
-
* consume this neutral envelope without LoopForge importing their packages.
|
|
10
|
-
*/
|
|
11
|
-
import type { McpSession } from "./mcp/session.js";
|
|
12
|
-
import type { RoundTransactionSnapshot } from "./round-transaction.js";
|
|
13
|
-
import { getPolicyMetrics } from "./policy-metrics.js";
|
|
14
|
-
export declare const COGNITIVE_CHECKPOINT_SCHEMA_VERSION: 1;
|
|
15
|
-
export interface CognitiveStateCheckpoint {
|
|
16
|
-
schemaVersion: typeof COGNITIVE_CHECKPOINT_SCHEMA_VERSION;
|
|
17
|
-
checkpointId: string;
|
|
18
|
-
loopId: string;
|
|
19
|
-
sessionId: string;
|
|
20
|
-
task: string;
|
|
21
|
-
status: "running" | "stopped" | "stalled" | "paused";
|
|
22
|
-
round: number;
|
|
23
|
-
maxRounds: number;
|
|
24
|
-
roundId?: string;
|
|
25
|
-
prompt?: string | null;
|
|
26
|
-
successTrajectory: boolean[];
|
|
27
|
-
roundSnapshot?: RoundTransactionSnapshot;
|
|
28
|
-
policyMetrics: ReturnType<typeof getPolicyMetrics>;
|
|
29
|
-
updatedAt: string;
|
|
30
|
-
}
|
|
31
|
-
export interface CognitiveCheckpointSink {
|
|
32
|
-
save(checkpoint: CognitiveStateCheckpoint): void | Promise<void>;
|
|
33
|
-
}
|
|
34
|
-
export declare function createCognitiveCheckpoint(session: McpSession, updatedAt?: string): CognitiveStateCheckpoint;
|
|
35
|
-
//# sourceMappingURL=interop.d.ts.map
|
package/dist/interop.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"interop.d.ts","sourceRoot":"","sources":["../src/interop.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD,eAAO,MAAM,mCAAmC,EAAG,CAAU,CAAC;AAE9D,MAAM,WAAW,wBAAwB;IACvC,aAAa,EAAE,OAAO,mCAAmC,CAAC;IAC1D,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;IACrD,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,iBAAiB,EAAE,OAAO,EAAE,CAAC;IAC7B,aAAa,CAAC,EAAE,wBAAwB,CAAC;IACzC,aAAa,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC;IACnD,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,uBAAuB;IACtC,IAAI,CAAC,UAAU,EAAE,wBAAwB,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAClE;AAED,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,UAAU,EACnB,SAAS,SAA2B,GACnC,wBAAwB,CAoB1B"}
|
package/dist/interop.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/** Dependency-free ecosystem checkpoint boundary.
|
|
2
|
-
*
|
|
3
|
-
* **@experimental** — This module is a lightweight stub (57 lines as of v2.0.0).
|
|
4
|
-
* The checkpoint interface is stable but the integration surface (sinks, schema
|
|
5
|
-
* versioning, external consumer contracts) has not been validated in production.
|
|
6
|
-
* Use for prototyping; expect the envelope shape to evolve before v2.1.
|
|
7
|
-
*
|
|
8
|
-
* LangGraph checkpointers, workflow engines, databases, and agent SDKs can
|
|
9
|
-
* consume this neutral envelope without LoopForge importing their packages.
|
|
10
|
-
*/
|
|
11
|
-
import { getPolicyMetrics } from "./policy-metrics.js";
|
|
12
|
-
export const COGNITIVE_CHECKPOINT_SCHEMA_VERSION = 1;
|
|
13
|
-
export function createCognitiveCheckpoint(session, updatedAt = new Date().toISOString()) {
|
|
14
|
-
const roundId = session.roundSnapshot?.roundId;
|
|
15
|
-
return {
|
|
16
|
-
schemaVersion: COGNITIVE_CHECKPOINT_SCHEMA_VERSION,
|
|
17
|
-
checkpointId: roundId
|
|
18
|
-
? `${roundId}:session`
|
|
19
|
-
: `loop:${session.loopId}:round:${session.currentRound}:session`,
|
|
20
|
-
loopId: session.loopId,
|
|
21
|
-
sessionId: session.sessionId,
|
|
22
|
-
task: session.task,
|
|
23
|
-
status: session.status,
|
|
24
|
-
round: session.currentRound,
|
|
25
|
-
maxRounds: session.maxRounds,
|
|
26
|
-
roundId,
|
|
27
|
-
prompt: session.currentPrompt,
|
|
28
|
-
successTrajectory: [...session.successTrajectory],
|
|
29
|
-
roundSnapshot: session.roundSnapshot,
|
|
30
|
-
policyMetrics: getPolicyMetrics(session.loopId),
|
|
31
|
-
updatedAt,
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
//# sourceMappingURL=interop.js.map
|
package/dist/interop.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"interop.js","sourceRoot":"","sources":["../src/interop.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD,MAAM,CAAC,MAAM,mCAAmC,GAAG,CAAU,CAAC;AAuB9D,MAAM,UAAU,yBAAyB,CACvC,OAAmB,EACnB,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;IAEpC,MAAM,OAAO,GAAG,OAAO,CAAC,aAAa,EAAE,OAAO,CAAC;IAC/C,OAAO;QACL,aAAa,EAAE,mCAAmC;QAClD,YAAY,EAAE,OAAO;YACnB,CAAC,CAAC,GAAG,OAAO,UAAU;YACtB,CAAC,CAAC,QAAQ,OAAO,CAAC,MAAM,UAAU,OAAO,CAAC,YAAY,UAAU;QAClE,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,KAAK,EAAE,OAAO,CAAC,YAAY;QAC3B,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,OAAO;QACP,MAAM,EAAE,OAAO,CAAC,aAAa;QAC7B,iBAAiB,EAAE,CAAC,GAAG,OAAO,CAAC,iBAAiB,CAAC;QACjD,aAAa,EAAE,OAAO,CAAC,aAAa;QACpC,aAAa,EAAE,gBAAgB,CAAC,OAAO,CAAC,MAAM,CAAC;QAC/C,SAAS;KACV,CAAC;AACJ,CAAC"}
|
package/dist/run.d.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/** Autonomous loop runner — Library API entry point (v2.6).
|
|
2
|
-
*
|
|
3
|
-
* Wires the engine, compiler, self-eval extraction, and feedback persistence
|
|
4
|
-
* into a single call that the host controls end-to-end. The agent never gets
|
|
5
|
-
* a chance to "skip" the loop — the host calls execute(), extracts the result,
|
|
6
|
-
* and feeds it back to LoopForge in the same tick.
|
|
7
|
-
*/
|
|
8
|
-
import { type SelfEvaluation } from "./protocol.js";
|
|
9
|
-
import type { LoopStore } from "./loop-store.js";
|
|
10
|
-
import type { ExternalContextProvider, LoopTerminalSink } from "./protocol.js";
|
|
11
|
-
import type { PromptArtifact } from "./protocol.js";
|
|
12
|
-
export interface RunInput {
|
|
13
|
-
/** The task description — what the agent should accomplish. */
|
|
14
|
-
task: string;
|
|
15
|
-
/** Hard constraints that must not be violated across all rounds. */
|
|
16
|
-
constraintsFromPlan?: string[];
|
|
17
|
-
/** Maximum rounds before auto-stop. Falls back to policy default when omitted. */
|
|
18
|
-
maxRounds?: number;
|
|
19
|
-
/** The agent executor. Receives the compiled prompt and an AbortSignal.
|
|
20
|
-
* Must return the agent's raw output (text). The runner extracts the
|
|
21
|
-
* structured self-evaluation from it. */
|
|
22
|
-
execute: (prompt: string, context: {
|
|
23
|
-
signal: AbortSignal;
|
|
24
|
-
}) => Promise<string>;
|
|
25
|
-
/** Optional external context injected before each compile. */
|
|
26
|
-
contextProvider?: ExternalContextProvider;
|
|
27
|
-
/** Optional terminal event sinks (telemetry, logging, etc.). */
|
|
28
|
-
terminalSinks?: LoopTerminalSink[];
|
|
29
|
-
/** Optional typed store — falls back to .loopforge/ when omitted. */
|
|
30
|
-
store?: LoopStore;
|
|
31
|
-
/** Optional abort signal for cancelling the entire loop. */
|
|
32
|
-
signal?: AbortSignal;
|
|
33
|
-
}
|
|
34
|
-
export interface RunResult {
|
|
35
|
-
/** Whether the loop completed successfully (should_continue=false + success=true). */
|
|
36
|
-
success: boolean;
|
|
37
|
-
/** Why the loop stopped. */
|
|
38
|
-
stopReason: string;
|
|
39
|
-
/** Number of rounds completed. */
|
|
40
|
-
roundsCompleted: number;
|
|
41
|
-
/** True/false for each committed round. */
|
|
42
|
-
successTrajectory: boolean[];
|
|
43
|
-
/** The loop's stable identity — can be used to replay later. */
|
|
44
|
-
loopId: string;
|
|
45
|
-
/** The last self-evaluation submitted by the agent. */
|
|
46
|
-
lastEvaluation?: SelfEvaluation;
|
|
47
|
-
/** Prompt artifacts produced across the loop (for audit). */
|
|
48
|
-
artifacts: PromptArtifact[];
|
|
49
|
-
}
|
|
50
|
-
export declare function run(input: RunInput): Promise<RunResult>;
|
|
51
|
-
//# sourceMappingURL=run.d.ts.map
|
package/dist/run.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAA8B,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AAEhF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,uBAAuB,EAAqB,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAElG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD,MAAM,WAAW,QAAQ;IACvB,+DAA+D;IAC/D,IAAI,EAAE,MAAM,CAAC;IACb,oEAAoE;IACpE,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC/B,kFAAkF;IAClF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;8CAE0C;IAC1C,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE;QAAE,MAAM,EAAE,WAAW,CAAA;KAAE,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAC/E,8DAA8D;IAC9D,eAAe,CAAC,EAAE,uBAAuB,CAAC;IAC1C,gEAAgE;IAChE,aAAa,CAAC,EAAE,gBAAgB,EAAE,CAAC;IACnC,qEAAqE;IACrE,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,4DAA4D;IAC5D,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,MAAM,WAAW,SAAS;IACxB,sFAAsF;IACtF,OAAO,EAAE,OAAO,CAAC;IACjB,4BAA4B;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,kCAAkC;IAClC,eAAe,EAAE,MAAM,CAAC;IACxB,2CAA2C;IAC3C,iBAAiB,EAAE,OAAO,EAAE,CAAC;IAC7B,gEAAgE;IAChE,MAAM,EAAE,MAAM,CAAC;IACf,uDAAuD;IACvD,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,6DAA6D;IAC7D,SAAS,EAAE,cAAc,EAAE,CAAC;CAC7B;AAkCD,wBAAsB,GAAG,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC,CA6J7D"}
|
package/dist/run.js
DELETED
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
/** Autonomous loop runner — Library API entry point (v2.6).
|
|
2
|
-
*
|
|
3
|
-
* Wires the engine, compiler, self-eval extraction, and feedback persistence
|
|
4
|
-
* into a single call that the host controls end-to-end. The agent never gets
|
|
5
|
-
* a chance to "skip" the loop — the host calls execute(), extracts the result,
|
|
6
|
-
* and feeds it back to LoopForge in the same tick.
|
|
7
|
-
*/
|
|
8
|
-
import { LoopForgeEngine, extractSelfEvaluation } from "./engine.js";
|
|
9
|
-
import { Mode } from "./protocol.js";
|
|
10
|
-
import { FileLoopStore } from "./loop-store.js";
|
|
11
|
-
import { logEvent } from "./observability.js";
|
|
12
|
-
function makeRunResult(loopId, lastResponse, roundsCompleted, successTrajectory, lastEval, artifacts = []) {
|
|
13
|
-
if (!lastResponse?.response) {
|
|
14
|
-
return {
|
|
15
|
-
success: false,
|
|
16
|
-
stopReason: "executor_failure",
|
|
17
|
-
roundsCompleted,
|
|
18
|
-
successTrajectory,
|
|
19
|
-
loopId,
|
|
20
|
-
lastEvaluation: lastEval,
|
|
21
|
-
artifacts,
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
return {
|
|
25
|
-
success: lastEval?.success === true && lastEval?.should_continue === false,
|
|
26
|
-
stopReason: lastEval?.should_continue === false
|
|
27
|
-
? (lastEval?.success ? "completed" : "failed")
|
|
28
|
-
: "max_rounds",
|
|
29
|
-
roundsCompleted,
|
|
30
|
-
successTrajectory,
|
|
31
|
-
loopId,
|
|
32
|
-
lastEvaluation: lastEval,
|
|
33
|
-
artifacts,
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
export async function run(input) {
|
|
37
|
-
const store = input.store ?? new FileLoopStore();
|
|
38
|
-
const engine = new LoopForgeEngine(store);
|
|
39
|
-
const loopId = `run-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
|
|
40
|
-
const maxRounds = input.maxRounds ?? 20;
|
|
41
|
-
const artifacts = [];
|
|
42
|
-
let round = 1;
|
|
43
|
-
let lastEval;
|
|
44
|
-
const successTrajectory = [];
|
|
45
|
-
const task = input.task.trim();
|
|
46
|
-
if (!task)
|
|
47
|
-
throw new Error("run: task must be non-empty");
|
|
48
|
-
while (round <= maxRounds) {
|
|
49
|
-
// Check for external abort
|
|
50
|
-
if (input.signal?.aborted) {
|
|
51
|
-
return makeRunResult(loopId, null, round - 1, successTrajectory, lastEval, artifacts);
|
|
52
|
-
}
|
|
53
|
-
// ── 1. Compile prompt ──────────────────────────────────────────────
|
|
54
|
-
const request = {
|
|
55
|
-
task,
|
|
56
|
-
mode: Mode.LOOP_COMPILE,
|
|
57
|
-
feedback: null,
|
|
58
|
-
skill_name: null,
|
|
59
|
-
task_id: null,
|
|
60
|
-
loop_id: loopId,
|
|
61
|
-
round,
|
|
62
|
-
max_rounds: maxRounds,
|
|
63
|
-
constraints_from_plan: input.constraintsFromPlan ?? [],
|
|
64
|
-
goal_id: loopId,
|
|
65
|
-
domain: "",
|
|
66
|
-
};
|
|
67
|
-
// External context injection
|
|
68
|
-
if (input.contextProvider) {
|
|
69
|
-
try {
|
|
70
|
-
const ctx = await input.contextProvider({
|
|
71
|
-
loopId,
|
|
72
|
-
round,
|
|
73
|
-
task,
|
|
74
|
-
domain: "",
|
|
75
|
-
lastEvaluation: lastEval,
|
|
76
|
-
});
|
|
77
|
-
if (ctx?.trim())
|
|
78
|
-
request.external_context = ctx.trim();
|
|
79
|
-
}
|
|
80
|
-
catch {
|
|
81
|
-
logEvent("context_provider_error", { loopId, round });
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
// Forward last round result
|
|
85
|
-
if (lastEval) {
|
|
86
|
-
request.last_round_result = {
|
|
87
|
-
round: round - 1,
|
|
88
|
-
success: lastEval.success,
|
|
89
|
-
output_summary: lastEval.output_summary,
|
|
90
|
-
constraint_violations: lastEval.constraint_violations,
|
|
91
|
-
manual_fixes_needed: "",
|
|
92
|
-
discovered_constraints: lastEval.discovered_constraints ?? [],
|
|
93
|
-
objective_refinement: lastEval.objective_refinement ?? "",
|
|
94
|
-
emerged_subtasks: lastEval.emerged_subtasks ?? [],
|
|
95
|
-
execution_evidence: lastEval.execution_evidence,
|
|
96
|
-
retracted_constraints: lastEval.retracted_constraints ?? [],
|
|
97
|
-
revised_success_criteria: lastEval.revised_success_criteria ?? [],
|
|
98
|
-
wrong_assumptions: lastEval.wrong_assumptions ?? [],
|
|
99
|
-
worker_results: lastEval.worker_results ?? [],
|
|
100
|
-
compression_checkpoint: lastEval.compression_checkpoint ?? false,
|
|
101
|
-
checkpoint_label: lastEval.checkpoint_label ?? "",
|
|
102
|
-
next_action: lastEval.next_action,
|
|
103
|
-
completed_subtasks: lastEval.completed_subtasks ?? [],
|
|
104
|
-
blocked_subtasks: lastEval.blocked_subtasks ?? [],
|
|
105
|
-
canceled_subtasks: lastEval.canceled_subtasks ?? [],
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
let response;
|
|
109
|
-
try {
|
|
110
|
-
response = engine.invokeLoopCompile(request);
|
|
111
|
-
}
|
|
112
|
-
catch (exc) {
|
|
113
|
-
logEvent("compile_error", { loopId, round, error: String(exc) });
|
|
114
|
-
return makeRunResult(loopId, null, round - 1, successTrajectory, lastEval, artifacts);
|
|
115
|
-
}
|
|
116
|
-
if (response.status !== "ok" || !response.response?.prompt) {
|
|
117
|
-
return makeRunResult(loopId, response, round - 1, successTrajectory, lastEval, artifacts);
|
|
118
|
-
}
|
|
119
|
-
const artifact = response.response.prompt_artifact;
|
|
120
|
-
if (artifact)
|
|
121
|
-
artifacts.push(artifact);
|
|
122
|
-
// ── 2. Execute agent ───────────────────────────────────────────────
|
|
123
|
-
let output;
|
|
124
|
-
try {
|
|
125
|
-
output = await input.execute(response.response.prompt, {
|
|
126
|
-
signal: input.signal ?? new AbortController().signal,
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
catch (exc) {
|
|
130
|
-
logEvent("execute_error", { loopId, round, error: String(exc) });
|
|
131
|
-
// Persist terminal state before returning
|
|
132
|
-
if (lastEval)
|
|
133
|
-
engine.autoFeedback(lastEval, loopId, round - 1, task);
|
|
134
|
-
void notifyTerminal(input.terminalSinks, {
|
|
135
|
-
loopId, task, success: false, stopReason: "executor_failure",
|
|
136
|
-
roundsCompleted: round - 1, successTrajectory, lastEvaluation: lastEval,
|
|
137
|
-
});
|
|
138
|
-
return {
|
|
139
|
-
success: false,
|
|
140
|
-
stopReason: "executor_failure",
|
|
141
|
-
roundsCompleted: round - 1,
|
|
142
|
-
successTrajectory,
|
|
143
|
-
loopId,
|
|
144
|
-
lastEvaluation: lastEval,
|
|
145
|
-
artifacts,
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
// ── 3. Extract self-evaluation ─────────────────────────────────────
|
|
149
|
-
const selfEval = extractSelfEvaluation(output);
|
|
150
|
-
if (!selfEval) {
|
|
151
|
-
logEvent("extraction_failed", { loopId, round });
|
|
152
|
-
return makeRunResult(loopId, response, round - 1, successTrajectory, lastEval, artifacts);
|
|
153
|
-
}
|
|
154
|
-
lastEval = selfEval;
|
|
155
|
-
successTrajectory.push(selfEval.success);
|
|
156
|
-
// ── 4. Persist feedback ────────────────────────────────────────────
|
|
157
|
-
engine.autoFeedback(selfEval, loopId, round, task);
|
|
158
|
-
// ── 5. Check stop ──────────────────────────────────────────────────
|
|
159
|
-
if (!selfEval.should_continue) {
|
|
160
|
-
const result = makeRunResult(loopId, response, round, successTrajectory, lastEval, artifacts);
|
|
161
|
-
void notifyTerminal(input.terminalSinks, {
|
|
162
|
-
loopId, task,
|
|
163
|
-
success: result.success,
|
|
164
|
-
stopReason: result.stopReason,
|
|
165
|
-
roundsCompleted: round,
|
|
166
|
-
successTrajectory,
|
|
167
|
-
lastEvaluation: lastEval,
|
|
168
|
-
});
|
|
169
|
-
return result;
|
|
170
|
-
}
|
|
171
|
-
round++;
|
|
172
|
-
}
|
|
173
|
-
const result = makeRunResult(loopId, null, round - 1, successTrajectory, lastEval, artifacts);
|
|
174
|
-
result.stopReason = "max_rounds";
|
|
175
|
-
void notifyTerminal(input.terminalSinks, {
|
|
176
|
-
loopId, task,
|
|
177
|
-
success: false,
|
|
178
|
-
stopReason: "max_rounds",
|
|
179
|
-
roundsCompleted: round - 1,
|
|
180
|
-
successTrajectory,
|
|
181
|
-
lastEvaluation: lastEval,
|
|
182
|
-
});
|
|
183
|
-
return result;
|
|
184
|
-
}
|
|
185
|
-
function notifyTerminal(sinks, event) {
|
|
186
|
-
if (!sinks?.length)
|
|
187
|
-
return;
|
|
188
|
-
for (const sink of sinks) {
|
|
189
|
-
try {
|
|
190
|
-
const pending = sink(event);
|
|
191
|
-
if (pending && typeof pending.then === "function") {
|
|
192
|
-
void pending.catch(() => undefined);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
catch {
|
|
196
|
-
// Sink failures must never fail the loop.
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
//# sourceMappingURL=run.js.map
|
package/dist/run.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"run.js","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,EAAE,IAAI,EAA6C,MAAM,eAAe,CAAC;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAyC9C,SAAS,aAAa,CACpB,MAAc,EACd,YAAoC,EACpC,eAAuB,EACvB,iBAA4B,EAC5B,QAAyB,EACzB,YAA8B,EAAE;IAEhC,IAAI,CAAC,YAAY,EAAE,QAAQ,EAAE,CAAC;QAC5B,OAAO;YACL,OAAO,EAAE,KAAK;YACd,UAAU,EAAE,kBAAkB;YAC9B,eAAe;YACf,iBAAiB;YACjB,MAAM;YACN,cAAc,EAAE,QAAQ;YACxB,SAAS;SACV,CAAC;IACJ,CAAC;IACD,OAAO;QACL,OAAO,EAAE,QAAQ,EAAE,OAAO,KAAK,IAAI,IAAI,QAAQ,EAAE,eAAe,KAAK,KAAK;QAC1E,UAAU,EAAE,QAAQ,EAAE,eAAe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,CACrB,KAAqC,EACrC,KAAwB;IAExB,IAAI,CAAC,KAAK,EAAE,MAAM;QAAE,OAAO;IAC3B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;YAC5B,IAAI,OAAO,IAAI,OAAO,OAAO,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;gBAClD,KAAK,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;YACtC,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,0CAA0C;QAC5C,CAAC;IACH,CAAC;AACH,CAAC"}
|
package/dist/self-eval.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/** Self-evaluation extraction and parsing — pure functions.
|
|
2
|
-
*
|
|
3
|
-
* These functions parse an Agent's raw output into a structured
|
|
4
|
-
* SelfEvaluation. They have no dependency on Engine state, file I/O,
|
|
5
|
-
* or external services. They are shared by both the MCP tool handler
|
|
6
|
-
* (which receives structured JSON directly) and the legacy invoke
|
|
7
|
-
* path (which regex-scans free-text Agent output).
|
|
8
|
-
*/
|
|
9
|
-
import { type CriterionRevision, type ExecutionEvidence, type SelfEvaluation } from "./protocol.js";
|
|
10
|
-
/** Parse ExecutionEvidence from a raw JSON object. */
|
|
11
|
-
export declare function parseExecutionEvidence(raw: Record<string, unknown> | undefined | null): ExecutionEvidence | undefined;
|
|
12
|
-
/** Parse CriterionRevision[] from a raw JSON array. */
|
|
13
|
-
export declare function parseCriterionRevisions(raw: unknown): CriterionRevision[];
|
|
14
|
-
/** Parse WorkerResult[] from a raw JSON array. */
|
|
15
|
-
export declare function parseWorkerResults(raw: unknown): import("./protocol.js").WorkerResult[];
|
|
16
|
-
/** Extract a structured SelfEvaluation from agent output text.
|
|
17
|
-
* Returns null if no valid self-eval block is found.
|
|
18
|
-
* The agent is instructed to output JSON between the delimiters. */
|
|
19
|
-
export declare function extractSelfEvaluation(text: string): SelfEvaluation | null;
|
|
20
|
-
/** Build a SelfEvaluation from a parsed JSON object.
|
|
21
|
-
* Lenient parsing: missing optional fields get sensible defaults. */
|
|
22
|
-
export declare function buildSelfEvaluation(raw: Record<string, unknown>): SelfEvaluation;
|
|
23
|
-
//# sourceMappingURL=self-eval.d.ts.map
|
package/dist/self-eval.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"self-eval.d.ts","sourceRoot":"","sources":["../src/self-eval.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAIL,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACpB,MAAM,eAAe,CAAC;AAIvB,sDAAsD;AACtD,wBAAgB,sBAAsB,CACpC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GAAG,IAAI,GAC9C,iBAAiB,GAAG,SAAS,CAwB/B;AAED,uDAAuD;AACvD,wBAAgB,uBAAuB,CACrC,GAAG,EAAE,OAAO,GACX,iBAAiB,EAAE,CAWrB;AAED,kDAAkD;AAClD,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,OAAO,GACX,OAAO,eAAe,EAAE,YAAY,EAAE,CAqBxC;AAID;;qEAEqE;AACrE,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI,CAczE;AAED;sEACsE;AACtE,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC3B,cAAc,CAuDhB"}
|
package/dist/self-eval.js
DELETED
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
/** Self-evaluation extraction and parsing — pure functions.
|
|
2
|
-
*
|
|
3
|
-
* These functions parse an Agent's raw output into a structured
|
|
4
|
-
* SelfEvaluation. They have no dependency on Engine state, file I/O,
|
|
5
|
-
* or external services. They are shared by both the MCP tool handler
|
|
6
|
-
* (which receives structured JSON directly) and the legacy invoke
|
|
7
|
-
* path (which regex-scans free-text Agent output).
|
|
8
|
-
*/
|
|
9
|
-
import { makeExecutionEvidence, makeSelfEvaluation, SELF_EVAL_REGEX, } from "./protocol.js";
|
|
10
|
-
// ── Raw parsing helpers ───────────────────────────────────────────────────
|
|
11
|
-
/** Parse ExecutionEvidence from a raw JSON object. */
|
|
12
|
-
export function parseExecutionEvidence(raw) {
|
|
13
|
-
if (!raw || typeof raw !== "object")
|
|
14
|
-
return undefined;
|
|
15
|
-
const testResults = raw.test_results;
|
|
16
|
-
return makeExecutionEvidence({
|
|
17
|
-
files_changed: Array.isArray(raw.files_changed)
|
|
18
|
-
? raw.files_changed.filter((v) => typeof v === "string")
|
|
19
|
-
: [],
|
|
20
|
-
test_results: testResults && typeof testResults.passed === "number"
|
|
21
|
-
? {
|
|
22
|
-
passed: testResults.passed,
|
|
23
|
-
failed: testResults.failed ?? 0,
|
|
24
|
-
skipped: testResults.skipped ?? 0,
|
|
25
|
-
}
|
|
26
|
-
: null,
|
|
27
|
-
success_criteria_met: Array.isArray(raw.success_criteria_met)
|
|
28
|
-
? raw.success_criteria_met.filter((v) => typeof v === "string")
|
|
29
|
-
: [],
|
|
30
|
-
success_criteria_remaining: Array.isArray(raw.success_criteria_remaining)
|
|
31
|
-
? raw.success_criteria_remaining.filter((v) => typeof v === "string")
|
|
32
|
-
: [],
|
|
33
|
-
progress_estimate: typeof raw.progress_estimate === "number"
|
|
34
|
-
? Math.max(0, Math.min(1, raw.progress_estimate))
|
|
35
|
-
: 0.0,
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
/** Parse CriterionRevision[] from a raw JSON array. */
|
|
39
|
-
export function parseCriterionRevisions(raw) {
|
|
40
|
-
if (!Array.isArray(raw))
|
|
41
|
-
return [];
|
|
42
|
-
return raw
|
|
43
|
-
.filter((v) => typeof v === "object" && v !== null &&
|
|
44
|
-
typeof v.old === "string" &&
|
|
45
|
-
typeof v.new === "string")
|
|
46
|
-
.map((v) => {
|
|
47
|
-
const r = v;
|
|
48
|
-
return { old: r.old, new: r.new };
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
/** Parse WorkerResult[] from a raw JSON array. */
|
|
52
|
-
export function parseWorkerResults(raw) {
|
|
53
|
-
if (!Array.isArray(raw))
|
|
54
|
-
return [];
|
|
55
|
-
return raw
|
|
56
|
-
.filter((v) => typeof v === "object" && v !== null &&
|
|
57
|
-
typeof v.agentId === "string" &&
|
|
58
|
-
typeof v.subTask === "string" &&
|
|
59
|
-
typeof v.resultSummary === "string")
|
|
60
|
-
.map((v) => {
|
|
61
|
-
const w = v;
|
|
62
|
-
return {
|
|
63
|
-
agentId: w.agentId,
|
|
64
|
-
subAgentType: typeof w.subAgentType === "string" ? w.subAgentType : "general-purpose",
|
|
65
|
-
subTask: w.subTask,
|
|
66
|
-
resultSummary: w.resultSummary,
|
|
67
|
-
success: typeof w.success === "boolean" ? w.success : false,
|
|
68
|
-
discoveredConstraints: Array.isArray(w.discoveredConstraints)
|
|
69
|
-
? w.discoveredConstraints.filter((c) => typeof c === "string")
|
|
70
|
-
: [],
|
|
71
|
-
};
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
// ── Self-evaluation extraction ───────────────────────────────────────────
|
|
75
|
-
/** Extract a structured SelfEvaluation from agent output text.
|
|
76
|
-
* Returns null if no valid self-eval block is found.
|
|
77
|
-
* The agent is instructed to output JSON between the delimiters. */
|
|
78
|
-
export function extractSelfEvaluation(text) {
|
|
79
|
-
const match = text.match(SELF_EVAL_REGEX);
|
|
80
|
-
if (!match)
|
|
81
|
-
return null;
|
|
82
|
-
try {
|
|
83
|
-
const raw = JSON.parse(match[1]);
|
|
84
|
-
if (typeof raw.success !== "boolean")
|
|
85
|
-
return null;
|
|
86
|
-
if (typeof raw.output_summary !== "string")
|
|
87
|
-
return null;
|
|
88
|
-
if (!Array.isArray(raw.constraint_violations))
|
|
89
|
-
return null;
|
|
90
|
-
if (typeof raw.should_continue !== "boolean")
|
|
91
|
-
return null;
|
|
92
|
-
return buildSelfEvaluation(raw);
|
|
93
|
-
}
|
|
94
|
-
catch {
|
|
95
|
-
return null;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
/** Build a SelfEvaluation from a parsed JSON object.
|
|
99
|
-
* Lenient parsing: missing optional fields get sensible defaults. */
|
|
100
|
-
export function buildSelfEvaluation(raw) {
|
|
101
|
-
const executionEvidence = parseExecutionEvidence(raw.execution_evidence);
|
|
102
|
-
const retractedConstraints = Array.isArray(raw.retracted_constraints)
|
|
103
|
-
? raw.retracted_constraints.filter((v) => typeof v === "string")
|
|
104
|
-
: [];
|
|
105
|
-
const revisedCriteria = parseCriterionRevisions(raw.revised_success_criteria);
|
|
106
|
-
const wrongAssumptions = Array.isArray(raw.wrong_assumptions)
|
|
107
|
-
? raw.wrong_assumptions.filter((v) => typeof v === "string")
|
|
108
|
-
: [];
|
|
109
|
-
const workerResults = parseWorkerResults(raw.worker_results);
|
|
110
|
-
return makeSelfEvaluation({
|
|
111
|
-
success: typeof raw.success === "boolean" ? raw.success : false,
|
|
112
|
-
output_summary: typeof raw.output_summary === "string" ? raw.output_summary : "",
|
|
113
|
-
constraint_violations: Array.isArray(raw.constraint_violations)
|
|
114
|
-
? raw.constraint_violations.filter((v) => typeof v === "string")
|
|
115
|
-
: [],
|
|
116
|
-
should_continue: typeof raw.should_continue === "boolean" ? raw.should_continue : true,
|
|
117
|
-
discovered_constraints: Array.isArray(raw.discovered_constraints)
|
|
118
|
-
? raw.discovered_constraints.filter((v) => typeof v === "string")
|
|
119
|
-
: [],
|
|
120
|
-
objective_refinement: typeof raw.objective_refinement === "string"
|
|
121
|
-
? raw.objective_refinement
|
|
122
|
-
: "",
|
|
123
|
-
emerged_subtasks: Array.isArray(raw.emerged_subtasks)
|
|
124
|
-
? raw.emerged_subtasks.filter((v) => typeof v === "string")
|
|
125
|
-
: [],
|
|
126
|
-
execution_evidence: executionEvidence,
|
|
127
|
-
retracted_constraints: retractedConstraints,
|
|
128
|
-
revised_success_criteria: revisedCriteria,
|
|
129
|
-
wrong_assumptions: wrongAssumptions,
|
|
130
|
-
worker_results: workerResults,
|
|
131
|
-
compression_checkpoint: typeof raw.compression_checkpoint === "boolean" ? raw.compression_checkpoint : false,
|
|
132
|
-
checkpoint_label: typeof raw.checkpoint_label === "string" ? raw.checkpoint_label : "",
|
|
133
|
-
next_action: typeof raw.next_action === "string" ? raw.next_action : undefined,
|
|
134
|
-
completed_subtasks: Array.isArray(raw.completed_subtasks)
|
|
135
|
-
? raw.completed_subtasks.filter((v) => typeof v === "string")
|
|
136
|
-
: [],
|
|
137
|
-
blocked_subtasks: Array.isArray(raw.blocked_subtasks)
|
|
138
|
-
? raw.blocked_subtasks.filter((v) => typeof v === "string")
|
|
139
|
-
: [],
|
|
140
|
-
canceled_subtasks: Array.isArray(raw.canceled_subtasks)
|
|
141
|
-
? raw.canceled_subtasks.filter((v) => typeof v === "string")
|
|
142
|
-
: [],
|
|
143
|
-
stop_reason: raw.stop_reason === "gave_up" || raw.stop_reason === "blocked" || raw.stop_reason === "needs_human_input"
|
|
144
|
-
? raw.stop_reason
|
|
145
|
-
: undefined,
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
// v2.6: heuristicSelfEvaluation removed — if structured extraction fails,
|
|
149
|
-
// the round is stalled. The 20-line keyword heuristic was dead weight; an
|
|
150
|
-
// agent that can't produce a structured self-evaluation is genuinely stuck.
|
|
151
|
-
//# sourceMappingURL=self-eval.js.map
|
package/dist/self-eval.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"self-eval.js","sourceRoot":"","sources":["../src/self-eval.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,qBAAqB,EACrB,kBAAkB,EAClB,eAAe,GAIhB,MAAM,eAAe,CAAC;AAEvB,6EAA6E;AAE7E,sDAAsD;AACtD,MAAM,UAAU,sBAAsB,CACp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AAO,CAAC,KAAK,QAAQ,CAAC;YACtE,CAAC,CAAC,EAAE;QACN,gBAAgB,EAAE,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC;YACnD,CAAC,CAAC,GAAG,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAU,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC;YACpE,CAAC,CAAC,EAAE;QACN,iBAAiB,EAAE,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC;YACrD,CAAC,CAAC,GAAG,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAU,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC;YACrE,CAAC,CAAC,EAAE;QACN,WAAW,EACT,GAAG,CAAC,WAAW,KAAK,SAAS,IAAI,GAAG,CAAC,WAAW,KAAK,SAAS,IAAI,GAAG,CAAC,WAAW,KAAK,mBAAmB;YACvG,CAAC,CAAC,GAAG,CAAC,WAAW;YACjB,CAAC,CAAC,SAAS;KAChB,CAAC,CAAC;AACL,CAAC;AAED,0EAA0E;AAC1E,0EAA0E;AAC1E,4EAA4E"}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/** Verification Gate — Layer 1 cross-round consistency checks.
|
|
2
|
-
*
|
|
3
|
-
* Pure-function module. Validates an agent's SelfEvaluation against the
|
|
4
|
-
* loop's own lineage before it enters the compiler.
|
|
5
|
-
*
|
|
6
|
-
* Verdict semantics:
|
|
7
|
-
* - trusted: all checks passed; flags are informational only.
|
|
8
|
-
* - suspect: one or more warn-level flags; flags become warnings in
|
|
9
|
-
* the next prompt so the agent can clarify.
|
|
10
|
-
* - contradicted: one or more error-level flags; the success flag for
|
|
11
|
-
* this round is excluded from the success trend (NOT
|
|
12
|
-
* modified). Flags become hard constraints — the agent
|
|
13
|
-
* must respond in the next round.
|
|
14
|
-
*/
|
|
15
|
-
import type { VaultEntry } from "./backends/interface.js";
|
|
16
|
-
import type { ProviderSnapshot } from "./evidence-provider.js";
|
|
17
|
-
import type { SelfEvaluation, VerificationResult } from "./protocol.js";
|
|
18
|
-
export { type GitFileState, captureGitFileState, captureGitModifiedFiles, } from "./evidence-provider.js";
|
|
19
|
-
/** Extract the round number from a vault entry's loop_lineage.
|
|
20
|
-
* Returns 0 if the entry has no lineage or no round field.
|
|
21
|
-
* In practice, persistLoopLineage always writes round ≥ 1, so 0
|
|
22
|
-
* unambiguously means "not a valid round entry" in this context.
|
|
23
|
-
* Exported for reuse by enforcement-gate.ts. */
|
|
24
|
-
export declare function entryRound(entry: VaultEntry): number;
|
|
25
|
-
interface ParsedTestCounts {
|
|
26
|
-
passed: number;
|
|
27
|
-
failed: number;
|
|
28
|
-
skipped: number;
|
|
29
|
-
total: number;
|
|
30
|
-
}
|
|
31
|
-
/** Best-effort parse of test counts from common test-runner output formats.
|
|
32
|
-
*
|
|
33
|
-
* Scans the last 2000 characters of stdout (where summary lines typically
|
|
34
|
-
* appear) and tries patterns in descending specificity order. Returns null
|
|
35
|
-
* when the output format is unrecognized, stdout is empty, or a confident
|
|
36
|
-
* parse cannot be made.
|
|
37
|
-
*
|
|
38
|
-
* Recognized formats: Jest verbose/compact, Mocha, pytest/unittest, Go test,
|
|
39
|
-
* and PHPUnit OK summaries. */
|
|
40
|
-
export declare function parseTestOutput(stdout: string): ParsedTestCounts | null;
|
|
41
|
-
/** Verify a SelfEvaluation against the loop's cross-round lineage.
|
|
42
|
-
*
|
|
43
|
-
* @param selfEval The agent's self-evaluation for the current round.
|
|
44
|
-
* @param currentRound The current round number (1-based).
|
|
45
|
-
* @param vaultEntries Vault entries for this loop (non-feedback only).
|
|
46
|
-
* @param prevSelfEval The agent's self-evaluation from the previous round
|
|
47
|
-
* (null for round 1).
|
|
48
|
-
* @param evidenceSnapshots v1.18: Evidence snapshots from configured providers.
|
|
49
|
-
* Used by checkEvidenceIntegrity for multi-provider
|
|
50
|
-
* cross-validation. Defaults to empty array. */
|
|
51
|
-
export declare function verifySelfEvaluation(selfEval: SelfEvaluation, currentRound: number, vaultEntries: VaultEntry[], prevSelfEval?: SelfEvaluation | null, evidenceSnapshots?: ProviderSnapshot[]): VerificationResult;
|
|
52
|
-
//# sourceMappingURL=verification-gate.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"verification-gate.d.ts","sourceRoot":"","sources":["../src/verification-gate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,OAAO,KAAK,EAAE,cAAc,EAAoB,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAO1F,OAAO,EACL,KAAK,YAAY,EACjB,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,wBAAwB,CAAC;AAMhC;;;;iDAIiD;AACjD,wBAAgB,UAAU,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAEpD;AAkTD,UAAU,gBAAgB;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;gCAQgC;AAChC,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,gBAAgB,GAAG,IAAI,CA4DvE;AA8ID;;;;;;;;;4EAS4E;AAC5E,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,cAAc,EACxB,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,UAAU,EAAE,EAC1B,YAAY,GAAE,cAAc,GAAG,IAAW,EAC1C,iBAAiB,GAAE,gBAAgB,EAAO,GACzC,kBAAkB,CAgDpB"}
|