@enderfga/claw-orchestrator 3.4.2 → 3.5.6

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.
Files changed (49) hide show
  1. package/README.md +9 -9
  2. package/configs/autoloop-coder-prompt.md +59 -0
  3. package/configs/autoloop-planner-prompt.md +136 -0
  4. package/configs/autoloop-reviewer-prompt.md +76 -0
  5. package/dist/bin/cli.js +30 -4
  6. package/dist/bin/cli.js.map +1 -1
  7. package/dist/src/autoloop/agent-tools.d.ts +44 -0
  8. package/dist/src/autoloop/agent-tools.js +71 -0
  9. package/dist/src/autoloop/agent-tools.js.map +1 -0
  10. package/dist/src/autoloop/dispatcher.d.ts +137 -0
  11. package/dist/src/autoloop/dispatcher.js +580 -0
  12. package/dist/src/autoloop/dispatcher.js.map +1 -0
  13. package/dist/src/autoloop/messages.d.ts +114 -0
  14. package/dist/src/autoloop/messages.js +92 -0
  15. package/dist/src/autoloop/messages.js.map +1 -0
  16. package/dist/src/autoloop/notify.d.ts +36 -0
  17. package/dist/src/autoloop/notify.js +166 -0
  18. package/dist/src/autoloop/notify.js.map +1 -0
  19. package/dist/src/autoloop/planner-tools.d.ts +81 -0
  20. package/dist/src/autoloop/planner-tools.js +140 -0
  21. package/dist/src/autoloop/planner-tools.js.map +1 -0
  22. package/dist/src/autoloop/runner.d.ts +48 -0
  23. package/dist/src/autoloop/runner.js +214 -0
  24. package/dist/src/autoloop/runner.js.map +1 -0
  25. package/dist/src/autoloop/types.d.ts +69 -0
  26. package/dist/src/autoloop/types.js +16 -0
  27. package/dist/src/autoloop/types.js.map +1 -0
  28. package/dist/src/dashboard/index.html +910 -0
  29. package/dist/src/embedded-server.d.ts +1 -0
  30. package/dist/src/embedded-server.js +237 -51
  31. package/dist/src/embedded-server.js.map +1 -1
  32. package/dist/src/index.d.ts +5 -2
  33. package/dist/src/index.js +67 -105
  34. package/dist/src/index.js.map +1 -1
  35. package/dist/src/session-manager.d.ts +47 -14
  36. package/dist/src/session-manager.js +135 -47
  37. package/dist/src/session-manager.js.map +1 -1
  38. package/package.json +2 -2
  39. package/skills/references/autoloop.md +176 -193
  40. package/configs/autoloop-bootstrap-prompt.md +0 -30
  41. package/configs/autoloop-compress-prompt.md +0 -50
  42. package/configs/autoloop-propose-prompt.md +0 -57
  43. package/configs/autoloop-ratchet-prompt.md +0 -56
  44. package/dist/src/autoloop-types.d.ts +0 -218
  45. package/dist/src/autoloop-types.js +0 -130
  46. package/dist/src/autoloop-types.js.map +0 -1
  47. package/dist/src/autoloop.d.ts +0 -70
  48. package/dist/src/autoloop.js +0 -910
  49. package/dist/src/autoloop.js.map +0 -1
@@ -1,218 +0,0 @@
1
- /**
2
- * Types for the autoloop feature.
3
- *
4
- * Contracts are documented in tasks/autoloop.md. Schemas here are intentionally
5
- * narrow — additions belong in the design doc first.
6
- */
7
- import type { EngineType } from './types.js';
8
- export type AutoloopPhase = 'BOOTSTRAP' | 'PROPOSE' | 'EXECUTE' | 'MEASURE' | 'RATCHET' | 'COMPRESS' | 'IDLE' | 'TERMINATED';
9
- export type AutoloopStatus = 'starting' | 'running' | 'paused' | 'completed' | 'error' | 'stopped';
10
- export interface ScalarSpec {
11
- /** Name of the metric for display / logs */
12
- name: string;
13
- /** Optimisation direction */
14
- direction: 'min' | 'max';
15
- /**
16
- * Shell command that prints the scalar value to stdout (one number).
17
- * Run by EXECUTE in the workspace. Must be deterministic.
18
- */
19
- extract_cmd: string;
20
- /**
21
- * Hard wall-clock cap on extract_cmd in seconds. Default 600 (10 min).
22
- * For long ML evals (training + measure), set this to your real upper
23
- * bound — e.g. 14400 for a 4-hour training run.
24
- */
25
- extract_timeout_sec?: number;
26
- /** Stop when scalar reaches this. For 'min' direction, stop when ≤ target. */
27
- target?: number;
28
- /** Changes within ±noise_floor are not considered improvements. Default 0. */
29
- noise_floor?: number;
30
- }
31
- export interface GateSpec {
32
- /** Stable identifier (used in state.json gate accounting) */
33
- name: string;
34
- /**
35
- * Shell command. Exit code 0 = pass, non-zero = fail.
36
- * Time-limited (see GateSpec.timeout_sec).
37
- */
38
- cmd: string;
39
- /**
40
- * Pass condition. Currently only 'exit-0' is supported.
41
- * Future: 'stdout-matches:<regex>', 'json-field:<path>=<value>'.
42
- */
43
- must: 'exit-0';
44
- /** Per-gate timeout in seconds. Default 300. */
45
- timeout_sec?: number;
46
- }
47
- export interface TerminationSpec {
48
- scalar_target_hit?: boolean;
49
- max_iters: number;
50
- /** Plateau triggers async push but loop continues unless user stops. */
51
- plateau_iters: number;
52
- max_cost_usd: number;
53
- /** Cap on un-locked aspirational gates (agent must rotate before adding more). */
54
- max_pending_aspirational: number;
55
- }
56
- export interface GoalSpec {
57
- /**
58
- * Optional: when null/absent, the loop has no faithful scalar; goal_completion
59
- * becomes the de-facto scalar (= locked_gates_passed / locked_gates_total).
60
- */
61
- scalar?: ScalarSpec;
62
- /** Locked gates (user-approved). Hard requirements; all must pass for ratchet. */
63
- gates: GateSpec[];
64
- /**
65
- * Aspirational gates proposed by agent during BOOTSTRAP or mid-loop.
66
- * Don't count toward goal_completion until user moves them to `gates`.
67
- * Capped by termination.max_pending_aspirational.
68
- */
69
- aspirational_gates?: GateSpec[];
70
- termination: TerminationSpec;
71
- }
72
- export interface BestPoint {
73
- iter: number;
74
- metric: number;
75
- git_sha: string;
76
- gate_completion: number;
77
- }
78
- export interface MetricPoint {
79
- iter: number;
80
- metric: number;
81
- gate_completion: number;
82
- }
83
- export interface StateTree {
84
- /** For serial v1: always points to last committed iter. */
85
- parent_iter: number | null;
86
- /** For population (v2): list of forks. v1 always [iter] or []. */
87
- children_iters: number[];
88
- }
89
- export type RatchetDecision = 'commit' | 'reset' | 'pending';
90
- export interface AutoloopState {
91
- task_id: string;
92
- branch: string;
93
- phase: AutoloopPhase;
94
- status: AutoloopStatus;
95
- iter: number;
96
- started_at: string;
97
- best: BestPoint | null;
98
- last_metric: MetricPoint | null;
99
- plateau_count: number;
100
- /** Set by RATCHET only. PROPOSE / MEASURE may not write this. */
101
- decision: RatchetDecision | null;
102
- decision_reason: string | null;
103
- /**
104
- * Git sha of the BOOTSTRAP commit. Used as the floor for git reset when no
105
- * `best` exists yet (otherwise we'd reset to HEAD~1, which after a failed
106
- * propose-then-resume can be the wrong target).
107
- */
108
- bootstrap_sha: string | null;
109
- tree: StateTree;
110
- termination: {
111
- fired: boolean;
112
- reason: string | null;
113
- };
114
- cost_usd_so_far: number;
115
- /** Pushed-but-not-yet-locked aspirational gates the agent has proposed. */
116
- pending_aspirational_count: number;
117
- }
118
- export interface MetricHistoryEntry {
119
- iter: number;
120
- ts: string;
121
- metric: number;
122
- gate_completion: number;
123
- phase_at_record: AutoloopPhase;
124
- git_sha_pre?: string;
125
- git_sha_post?: string;
126
- }
127
- export interface GateResult {
128
- name: string;
129
- passed: boolean;
130
- exit_code: number;
131
- duration_ms: number;
132
- /** Truncated stdout/stderr tail for diagnostic context. */
133
- output_tail: string;
134
- }
135
- export interface EvalOutput {
136
- iter: number;
137
- ts: string;
138
- /** All locked-gate results, in goal.json order. */
139
- gates: GateResult[];
140
- /** null when no scalar in goal.json or extract_cmd failed. */
141
- scalar: number | null;
142
- /** Computed = (gates that passed) / (locked gates total). */
143
- gate_completion: number;
144
- /** True if every locked gate passed. */
145
- all_gates_passed: boolean;
146
- }
147
- export interface RatchetOutput {
148
- iter: number;
149
- decision: RatchetDecision;
150
- reason: string;
151
- /** True if RATCHET wants the runner to push the user (e.g. unsure / new-best / plateau). */
152
- push_user?: {
153
- kind: 'new_best' | 'plateau' | 'unsure_no_metric' | 'aspirational_proposed';
154
- text: string;
155
- };
156
- }
157
- export type PushKind = 'bootstrap_aspirational' | 'new_best' | 'plateau' | 'unsure_no_metric' | 'aspirational_proposed' | 'termination' | 'hard_error';
158
- export interface PushEvent {
159
- kind: PushKind;
160
- text: string;
161
- task_id: string;
162
- iter: number;
163
- ts: string;
164
- }
165
- export interface AutoloopConfig {
166
- /** Workspace path — must be a git repo. tasks/<id>/ will be created here. */
167
- workspace: string;
168
- /** Path to plan.md (will be copied into tasks/<id>/plan.md). */
169
- plan_path: string;
170
- /** Path to goal.json (will be copied + validated into tasks/<id>/goal.json). */
171
- goal_path: string;
172
- /** Override for the task id; defaults to a timestamped slug. */
173
- task_id?: string;
174
- /** Engine for PROPOSE/BOOTSTRAP/COMPRESS. Default 'claude'. */
175
- propose_engine?: EngineType;
176
- /** Model for PROPOSE/BOOTSTRAP/COMPRESS. Default 'opus'. */
177
- propose_model?: string;
178
- /** Engine for RATCHET. Default 'claude'. */
179
- ratchet_engine?: EngineType;
180
- /** Model for RATCHET. Default 'opus'. */
181
- ratchet_model?: string;
182
- /** How often to run COMPRESS. Default 10. */
183
- compress_every_k?: number;
184
- /** Per-iter wall clock for PROPOSE/EXECUTE phases (ms). Default 600_000 (10 min). */
185
- per_iter_timeout_ms?: number;
186
- /** Push hook command (defaults to `openclaw message send`). Set to null to disable pushes. */
187
- push_cmd?: string | null;
188
- }
189
- export interface AutoloopHandle {
190
- id: string;
191
- status: AutoloopStatus;
192
- task_dir: string;
193
- started_at: string;
194
- ended_at?: string;
195
- /** Last-known phase from state.json (cheap to read). */
196
- current_phase?: AutoloopPhase;
197
- current_iter?: number;
198
- best_metric?: number;
199
- error?: string;
200
- }
201
- export declare class GoalSpecError extends Error {
202
- constructor(message: string);
203
- }
204
- export declare function validateGoalSpec(raw: unknown): GoalSpec;
205
- /**
206
- * Derive the metric value used for ratcheting from an EvalOutput.
207
- * Rule:
208
- * - If goal has a scalar AND eval produced one, use the scalar.
209
- * - Otherwise, use gate_completion (∈ [0, 1]).
210
- */
211
- export declare function deriveMetric(eval_out: EvalOutput, goal: GoalSpec): number;
212
- /**
213
- * Did `candidate` improve over `incumbent` for this goal? Honours noise_floor.
214
- * If no scalar, "improve" means strictly higher gate_completion.
215
- */
216
- export declare function isImprovement(candidate: number, incumbent: number | null, goal: GoalSpec): boolean;
217
- /** Has the scalar/gate target been hit? */
218
- export declare function isTargetReached(metric: number, gate_completion: number, goal: GoalSpec): boolean;
@@ -1,130 +0,0 @@
1
- /**
2
- * Types for the autoloop feature.
3
- *
4
- * Contracts are documented in tasks/autoloop.md. Schemas here are intentionally
5
- * narrow — additions belong in the design doc first.
6
- */
7
- // ─── Validation Helpers ─────────────────────────────────────────────────────
8
- export class GoalSpecError extends Error {
9
- constructor(message) {
10
- super(`goal.json: ${message}`);
11
- this.name = 'GoalSpecError';
12
- }
13
- }
14
- export function validateGoalSpec(raw) {
15
- if (!raw || typeof raw !== 'object')
16
- throw new GoalSpecError('must be an object');
17
- const o = raw;
18
- if (!Array.isArray(o.gates))
19
- throw new GoalSpecError('`gates` must be an array');
20
- const gates = o.gates.map((g, i) => validateGate(g, `gates[${i}]`));
21
- let scalar;
22
- if (o.scalar != null)
23
- scalar = validateScalar(o.scalar);
24
- let aspirational_gates;
25
- if (Array.isArray(o.aspirational_gates)) {
26
- aspirational_gates = o.aspirational_gates.map((g, i) => validateGate(g, `aspirational_gates[${i}]`));
27
- }
28
- if (!o.termination || typeof o.termination !== 'object') {
29
- throw new GoalSpecError('`termination` is required');
30
- }
31
- const termination = validateTermination(o.termination);
32
- // Cross-check: if no scalar, gates must be non-empty (otherwise the loop has nothing to ratchet against)
33
- if (!scalar && gates.length === 0) {
34
- throw new GoalSpecError('must have at least one of `scalar` or `gates`');
35
- }
36
- return { scalar, gates, aspirational_gates, termination };
37
- }
38
- function validateScalar(raw) {
39
- const o = raw;
40
- if (typeof o.name !== 'string')
41
- throw new GoalSpecError('scalar.name must be string');
42
- if (o.direction !== 'min' && o.direction !== 'max') {
43
- throw new GoalSpecError('scalar.direction must be "min" or "max"');
44
- }
45
- if (typeof o.extract_cmd !== 'string' || !o.extract_cmd.trim()) {
46
- throw new GoalSpecError('scalar.extract_cmd must be a non-empty string');
47
- }
48
- return {
49
- name: o.name,
50
- direction: o.direction,
51
- extract_cmd: o.extract_cmd,
52
- extract_timeout_sec: typeof o.extract_timeout_sec === 'number' && o.extract_timeout_sec > 0 ? o.extract_timeout_sec : 600,
53
- target: typeof o.target === 'number' ? o.target : undefined,
54
- noise_floor: typeof o.noise_floor === 'number' ? o.noise_floor : 0,
55
- };
56
- }
57
- function validateGate(raw, ctx) {
58
- const o = raw;
59
- if (typeof o.name !== 'string')
60
- throw new GoalSpecError(`${ctx}.name must be string`);
61
- if (typeof o.cmd !== 'string' || !o.cmd.trim()) {
62
- throw new GoalSpecError(`${ctx}.cmd must be a non-empty string`);
63
- }
64
- if (o.must !== 'exit-0') {
65
- throw new GoalSpecError(`${ctx}.must must be "exit-0" (other modes not yet supported)`);
66
- }
67
- return {
68
- name: o.name,
69
- cmd: o.cmd,
70
- must: 'exit-0',
71
- timeout_sec: typeof o.timeout_sec === 'number' && o.timeout_sec > 0 ? o.timeout_sec : 300,
72
- };
73
- }
74
- function validateTermination(raw) {
75
- const o = raw;
76
- const num = (k, def) => {
77
- if (typeof o[k] === 'number' && Number.isFinite(o[k]))
78
- return o[k];
79
- if (def !== undefined)
80
- return def;
81
- throw new GoalSpecError(`termination.${k} must be a number`);
82
- };
83
- return {
84
- scalar_target_hit: o.scalar_target_hit !== false,
85
- max_iters: num('max_iters', 200),
86
- plateau_iters: num('plateau_iters', 10),
87
- max_cost_usd: num('max_cost_usd', 200),
88
- max_pending_aspirational: num('max_pending_aspirational', 5),
89
- };
90
- }
91
- /**
92
- * Derive the metric value used for ratcheting from an EvalOutput.
93
- * Rule:
94
- * - If goal has a scalar AND eval produced one, use the scalar.
95
- * - Otherwise, use gate_completion (∈ [0, 1]).
96
- */
97
- export function deriveMetric(eval_out, goal) {
98
- if (goal.scalar && eval_out.scalar != null)
99
- return eval_out.scalar;
100
- return eval_out.gate_completion;
101
- }
102
- /**
103
- * Did `candidate` improve over `incumbent` for this goal? Honours noise_floor.
104
- * If no scalar, "improve" means strictly higher gate_completion.
105
- */
106
- export function isImprovement(candidate, incumbent, goal) {
107
- if (incumbent === null)
108
- return true;
109
- if (goal.scalar) {
110
- const noise = goal.scalar.noise_floor ?? 0;
111
- if (goal.scalar.direction === 'min')
112
- return candidate < incumbent - noise;
113
- return candidate > incumbent + noise;
114
- }
115
- // No scalar: gate_completion, higher is better, no noise floor.
116
- return candidate > incumbent;
117
- }
118
- /** Has the scalar/gate target been hit? */
119
- export function isTargetReached(metric, gate_completion, goal) {
120
- if (!goal.termination.scalar_target_hit)
121
- return false;
122
- if (goal.scalar?.target != null) {
123
- if (goal.scalar.direction === 'min')
124
- return metric <= goal.scalar.target;
125
- return metric >= goal.scalar.target;
126
- }
127
- // No scalar target set; "done" means all gates passing.
128
- return gate_completion >= 1.0;
129
- }
130
- //# sourceMappingURL=autoloop-types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"autoloop-types.js","sourceRoot":"","sources":["../../src/autoloop-types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA2PH,+EAA+E;AAE/E,MAAM,OAAO,aAAc,SAAQ,KAAK;IACtC,YAAY,OAAe;QACzB,KAAK,CAAC,cAAc,OAAO,EAAE,CAAC,CAAC;QAC/B,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;IAC9B,CAAC;CACF;AAED,MAAM,UAAU,gBAAgB,CAAC,GAAY;IAC3C,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,MAAM,IAAI,aAAa,CAAC,mBAAmB,CAAC,CAAC;IAClF,MAAM,CAAC,GAAG,GAA8B,CAAC;IAEzC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;QAAE,MAAM,IAAI,aAAa,CAAC,0BAA0B,CAAC,CAAC;IACjF,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,YAAY,CAAC,CAAC,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;IAEpE,IAAI,MAA8B,CAAC;IACnC,IAAI,CAAC,CAAC,MAAM,IAAI,IAAI;QAAE,MAAM,GAAG,cAAc,CAAC,CAAC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CAAC;QAChB,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,WAAW,IAAI,CAAC,CAAC;QAC3C,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,KAAK,KAAK;YAAE,OAAO,SAAS,GAAG,SAAS,GAAG,KAAK,CAAC;QAC1E,OAAO,SAAS,GAAG,SAAS,GAAG,KAAK,CAAC;IACvC,CAAC;IACD,gEAAgE;IAChE,OAAO,SAAS,GAAG,SAAS,CAAC;AAC/B,CAAC;AAED,2CAA2C;AAC3C,MAAM,UAAU,eAAe,CAAC,MAAc,EAAE,eAAuB,EAAE,IAAc;IACrF,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,iBAAiB;QAAE,OAAO,KAAK,CAAC;IACtD,IAAI,IAAI,CAAC,MAAM,EAAE,MAAM,IAAI,IAAI,EAAE,CAAC;QAChC,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,KAAK,KAAK;YAAE,OAAO,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;QACzE,OAAO,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;IACtC,CAAC;IACD,wDAAwD;IACxD,OAAO,eAAe,IAAI,GAAG,CAAC;AAChC,CAAC"}
@@ -1,70 +0,0 @@
1
- /**
2
- * Autoloop driver — phase machine for autonomous workspace iteration.
3
- *
4
- * Contract: tasks/autoloop.md. This file implements the runner; phase prompts
5
- * live in configs/autoloop-*-prompt.md.
6
- *
7
- * Lifecycle (one runner per task):
8
- * start() → BOOTSTRAP → loop { PROPOSE → EXECUTE → MEASURE → RATCHET → maybe COMPRESS } → TERMINATED
9
- *
10
- * Termination triggers: scalar target hit, max_iters, max_cost_usd, hard error,
11
- * explicit stop(). Plateau pushes the user but does NOT halt the loop (per
12
- * design constraint C9 — proactivity).
13
- */
14
- import { EventEmitter } from 'node:events';
15
- import type { SessionManager } from './session-manager.js';
16
- import type { Logger } from './logger.js';
17
- import type { EngineType } from './types.js';
18
- import type { AutoloopConfig, AutoloopHandle } from './autoloop-types.js';
19
- export declare class AutoloopRunner extends EventEmitter {
20
- readonly id: string;
21
- readonly config: AutoloopConfig;
22
- readonly taskDir: string;
23
- readonly branch: string;
24
- private state;
25
- private goal;
26
- private stopRequested;
27
- private startedAt;
28
- private endedAt?;
29
- private status;
30
- private errorMsg?;
31
- private readonly manager;
32
- private readonly logger;
33
- constructor(manager: SessionManager, config: AutoloopConfig, logger?: Logger);
34
- /** Start the loop. Resolves after BOOTSTRAP; iteration runs in the background. */
35
- start(): Promise<void>;
36
- /**
37
- * Resume an interrupted autoloop from on-disk state. Skips BOOTSTRAP and
38
- * jumps straight to the iteration loop. Resets the workspace to the last
39
- * known best (or the BOOTSTRAP baseline if no best yet) so any half-finished
40
- * PROPOSE that crashed mid-flight is discarded.
41
- */
42
- resume(): Promise<void>;
43
- /** Ask the loop to halt at the next phase boundary. Resolves when actually stopped. */
44
- stop(): Promise<void>;
45
- /** Inject a hint that the next PROPOSE will read. */
46
- inject(text: string): void;
47
- /** Cheap status snapshot from in-memory state. */
48
- handle(): AutoloopHandle;
49
- private prepareTaskDir;
50
- private loadAndValidateGoal;
51
- private initialState;
52
- private ensureBranch;
53
- private runBootstrap;
54
- private runLoop;
55
- private runPropose;
56
- private runExecute;
57
- private runMeasure;
58
- private runRatchet;
59
- private runCompress;
60
- private persistState;
61
- private gitSha;
62
- private gitReset;
63
- private readMetricHistory;
64
- private readLastRatchet;
65
- private tryRead;
66
- private push;
67
- private terminate;
68
- private fail;
69
- }
70
- export type { EngineType };