@cat-factory/orchestration 0.113.1 → 0.114.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/dist/modules/execution/AgentContextBuilder.d.ts.map +1 -1
- package/dist/modules/execution/AgentContextBuilder.js +13 -1
- package/dist/modules/execution/AgentContextBuilder.js.map +1 -1
- package/dist/modules/execution/ExecutionService.d.ts +1 -0
- package/dist/modules/execution/ExecutionService.d.ts.map +1 -1
- package/dist/modules/execution/ExecutionService.js +27 -0
- package/dist/modules/execution/ExecutionService.js.map +1 -1
- package/dist/modules/execution/RalphController.d.ts +62 -0
- package/dist/modules/execution/RalphController.d.ts.map +1 -0
- package/dist/modules/execution/RalphController.js +170 -0
- package/dist/modules/execution/RalphController.js.map +1 -0
- package/dist/modules/execution/RunDispatcher.d.ts +3 -0
- package/dist/modules/execution/RunDispatcher.d.ts.map +1 -1
- package/dist/modules/execution/RunDispatcher.js +16 -0
- package/dist/modules/execution/RunDispatcher.js.map +1 -1
- package/dist/modules/execution/ralph.logic.d.ts +51 -0
- package/dist/modules/execution/ralph.logic.d.ts.map +1 -0
- package/dist/modules/execution/ralph.logic.js +80 -0
- package/dist/modules/execution/ralph.logic.js.map +1 -0
- package/package.json +11 -11
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { RALPH_AGENT_KIND, RALPH_DEFAULT_MAX_ITERATIONS, RALPH_MAX_ITERATIONS_CONFIG_ID, RALPH_VALIDATION_COMMAND_CONFIG_ID, } from '@cat-factory/agents';
|
|
2
|
+
// Pure logic + constants for the "Ralph loop" step — a persistent, retry-until-done coding
|
|
3
|
+
// loop whose exit condition is a programmatic validation command run by the harness. Kept
|
|
4
|
+
// side-effect-free (no engine I/O) so it is unit- and conformance-testable in isolation; the
|
|
5
|
+
// stateful driving lives in `RalphController` + `RunDispatcher`.
|
|
6
|
+
// Re-exported so in-package sites source the kind id here (agents stays the single source).
|
|
7
|
+
export { RALPH_AGENT_KIND };
|
|
8
|
+
/** Default repo-relative path of the append-only progress log the ralph agent maintains. */
|
|
9
|
+
export const RALPH_PROGRESS_PATH = '.cat-factory/ralph-progress.md';
|
|
10
|
+
/**
|
|
11
|
+
* Hard ceiling on the per-task iteration budget, so a fat-fingered config value can't make the
|
|
12
|
+
* loop spin (near-)forever. Well above any sane hand-set budget; the default is much smaller.
|
|
13
|
+
*/
|
|
14
|
+
export const MAX_RALPH_ITERATIONS_CAP = 50;
|
|
15
|
+
/** Whether a step's kind is the ralph-loop kind. */
|
|
16
|
+
export function isRalphKind(kind) {
|
|
17
|
+
return kind === RALPH_AGENT_KIND;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Resolve a ralph step's per-task config from the block's agent-config values: the validation
|
|
21
|
+
* command (the completion criterion) and the iteration budget (clamped, defaulting to
|
|
22
|
+
* {@link RALPH_DEFAULT_MAX_ITERATIONS}). The command may resolve empty when the task pinned
|
|
23
|
+
* none — the engine treats that as a misconfiguration and fails the step with a clear message
|
|
24
|
+
* (a ralph loop is meaningless without a programmatic criterion).
|
|
25
|
+
*/
|
|
26
|
+
export function resolveRalphConfig(agentConfig) {
|
|
27
|
+
const validationCommand = (agentConfig?.[RALPH_VALIDATION_COMMAND_CONFIG_ID] ?? '').trim();
|
|
28
|
+
const raw = Number(agentConfig?.[RALPH_MAX_ITERATIONS_CONFIG_ID]);
|
|
29
|
+
const maxIterations = Number.isFinite(raw) && raw >= 1
|
|
30
|
+
? Math.min(Math.floor(raw), MAX_RALPH_ITERATIONS_CAP)
|
|
31
|
+
: RALPH_DEFAULT_MAX_ITERATIONS;
|
|
32
|
+
return { validationCommand, maxIterations };
|
|
33
|
+
}
|
|
34
|
+
/** Seed a fresh ralph step state from a resolved config (attempts start at 0, no history). */
|
|
35
|
+
export function seedRalphState(config) {
|
|
36
|
+
return {
|
|
37
|
+
phase: 'iterating',
|
|
38
|
+
attempts: 0,
|
|
39
|
+
maxIterations: config.maxIterations,
|
|
40
|
+
validationCommand: config.validationCommand,
|
|
41
|
+
progressPath: RALPH_PROGRESS_PATH,
|
|
42
|
+
attemptLog: [],
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Fold a ralph step's state into the container context's `ralphValidation` block: the command
|
|
47
|
+
* the harness runs, the progress-log path, and the 1-based iteration number about to run
|
|
48
|
+
* (`attempts + 1`). Returns undefined when the step carries no ralph state or an empty command
|
|
49
|
+
* (a misconfigured step must not dispatch a validation-less run — the engine fails it instead).
|
|
50
|
+
*/
|
|
51
|
+
export function buildRalphValidation(ralph) {
|
|
52
|
+
if (!ralph || !ralph.validationCommand.trim())
|
|
53
|
+
return undefined;
|
|
54
|
+
return {
|
|
55
|
+
command: ralph.validationCommand,
|
|
56
|
+
progressPath: ralph.progressPath ?? RALPH_PROGRESS_PATH,
|
|
57
|
+
iteration: ralph.attempts + 1,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Decide the loop's next move from the step state (AFTER the just-finished iteration has been
|
|
62
|
+
* counted into `attempts`) and its verdict: the criterion passed ⇒ `done`; else another
|
|
63
|
+
* iteration remains within the budget ⇒ `retry`; else the budget is spent ⇒ `exhausted`.
|
|
64
|
+
*/
|
|
65
|
+
export function decideRalphNext(ralph, verdict) {
|
|
66
|
+
if (verdict?.validationPassed)
|
|
67
|
+
return 'done';
|
|
68
|
+
return ralph.attempts < ralph.maxIterations ? 'retry' : 'exhausted';
|
|
69
|
+
}
|
|
70
|
+
/** One-line, human-readable summary of a verdict for notifications / failure messages. */
|
|
71
|
+
export function describeRalphVerdict(verdict) {
|
|
72
|
+
if (!verdict)
|
|
73
|
+
return 'the validation run produced no verdict';
|
|
74
|
+
if (verdict.validationPassed)
|
|
75
|
+
return 'the validation command passed';
|
|
76
|
+
const tail = verdict.validationOutputTail?.trim();
|
|
77
|
+
const head = `the validation command failed (exit ${verdict.exitCode})`;
|
|
78
|
+
return tail ? `${head}:\n${tail}` : head;
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=ralph.logic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ralph.logic.js","sourceRoot":"","sources":["../../../src/modules/execution/ralph.logic.ts"],"names":[],"mappings":"AACA,OAAO,EACL,gBAAgB,EAChB,4BAA4B,EAC5B,8BAA8B,EAC9B,kCAAkC,GACnC,MAAM,qBAAqB,CAAA;AAE5B,2FAA2F;AAC3F,0FAA0F;AAC1F,6FAA6F;AAC7F,iEAAiE;AAEjE,4FAA4F;AAC5F,OAAO,EAAE,gBAAgB,EAAE,CAAA;AAE3B,4FAA4F;AAC5F,MAAM,CAAC,MAAM,mBAAmB,GAAG,gCAAgC,CAAA;AAEnE;;;GAGG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,EAAE,CAAA;AAE1C,oDAAoD;AACpD,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,OAAO,IAAI,KAAK,gBAAgB,CAAA;AAClC,CAAC;AAUD;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAAC,WAA0C;IAC3E,MAAM,iBAAiB,GAAG,CAAC,WAAW,EAAE,CAAC,kCAAkC,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAA;IAC1F,MAAM,GAAG,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC,8BAA8B,CAAC,CAAC,CAAA;IACjE,MAAM,aAAa,GACjB,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC;QAC9B,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,wBAAwB,CAAC;QACrD,CAAC,CAAC,4BAA4B,CAAA;IAClC,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,CAAA;AAC7C,CAAC;AAED,8FAA8F;AAC9F,MAAM,UAAU,cAAc,CAAC,MAAmB;IAChD,OAAO;QACL,KAAK,EAAE,WAAW;QAClB,QAAQ,E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|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.114.0",
|
|
4
4
|
"description": "Delivery-workflow engine for the Agent Architecture Board (execution, bootstrap, pipelines, board, boardScan, requirements, and composition root).",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -25,20 +25,20 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"ai": "^6.0.224",
|
|
28
|
-
"@cat-factory/
|
|
29
|
-
"@cat-factory/
|
|
30
|
-
"@cat-factory/
|
|
31
|
-
"@cat-factory/integrations": "0.84.
|
|
32
|
-
"@cat-factory/kernel": "0.
|
|
33
|
-
"@cat-factory/
|
|
34
|
-
"@cat-factory/sandbox": "0.9.
|
|
35
|
-
"@cat-factory/
|
|
36
|
-
"@cat-factory/
|
|
28
|
+
"@cat-factory/agents": "0.60.0",
|
|
29
|
+
"@cat-factory/caching": "0.8.8",
|
|
30
|
+
"@cat-factory/contracts": "0.136.0",
|
|
31
|
+
"@cat-factory/integrations": "0.84.6",
|
|
32
|
+
"@cat-factory/kernel": "0.130.0",
|
|
33
|
+
"@cat-factory/prompt-fragments": "0.13.25",
|
|
34
|
+
"@cat-factory/sandbox": "0.9.87",
|
|
35
|
+
"@cat-factory/spend": "0.12.37",
|
|
36
|
+
"@cat-factory/workspaces": "0.13.48"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"typescript": "7.0.2",
|
|
40
40
|
"vitest": "^4.1.10",
|
|
41
|
-
"@cat-factory/sandbox-fixtures": "0.7.
|
|
41
|
+
"@cat-factory/sandbox-fixtures": "0.7.160"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
44
|
"build": "tsc -b tsconfig.build.json",
|