darwin-agents 0.8.0 → 0.10.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.
Files changed (51) hide show
  1. package/CHANGELOG.md +113 -0
  2. package/README.md +77 -0
  3. package/dist/src/cli/canary.d.ts +13 -0
  4. package/dist/src/cli/canary.d.ts.map +1 -0
  5. package/dist/src/cli/canary.js +66 -0
  6. package/dist/src/cli/canary.js.map +1 -0
  7. package/dist/src/cli/evolution-flags.d.ts +2 -0
  8. package/dist/src/cli/evolution-flags.d.ts.map +1 -1
  9. package/dist/src/cli/evolution-flags.js +36 -1
  10. package/dist/src/cli/evolution-flags.js.map +1 -1
  11. package/dist/src/cli/evolve.d.ts +2 -0
  12. package/dist/src/cli/evolve.d.ts.map +1 -1
  13. package/dist/src/cli/evolve.js +10 -0
  14. package/dist/src/cli/evolve.js.map +1 -1
  15. package/dist/src/cli/index.js +7 -0
  16. package/dist/src/cli/index.js.map +1 -1
  17. package/dist/src/cli/run.d.ts.map +1 -1
  18. package/dist/src/cli/run.js +16 -1
  19. package/dist/src/cli/run.js.map +1 -1
  20. package/dist/src/evolution/canary.d.ts +164 -0
  21. package/dist/src/evolution/canary.d.ts.map +1 -0
  22. package/dist/src/evolution/canary.js +244 -0
  23. package/dist/src/evolution/canary.js.map +1 -0
  24. package/dist/src/evolution/critic-families.d.ts +51 -0
  25. package/dist/src/evolution/critic-families.d.ts.map +1 -0
  26. package/dist/src/evolution/critic-families.js +51 -0
  27. package/dist/src/evolution/critic-families.js.map +1 -0
  28. package/dist/src/evolution/demos.d.ts +128 -0
  29. package/dist/src/evolution/demos.d.ts.map +1 -0
  30. package/dist/src/evolution/demos.js +196 -0
  31. package/dist/src/evolution/demos.js.map +1 -0
  32. package/dist/src/evolution/enabled-state.d.ts +5 -5
  33. package/dist/src/evolution/enabled-state.d.ts.map +1 -1
  34. package/dist/src/evolution/enabled-state.js +10 -5
  35. package/dist/src/evolution/enabled-state.js.map +1 -1
  36. package/dist/src/evolution/loop.d.ts +36 -0
  37. package/dist/src/evolution/loop.d.ts.map +1 -1
  38. package/dist/src/evolution/loop.js +118 -19
  39. package/dist/src/evolution/loop.js.map +1 -1
  40. package/dist/src/evolution/selection.d.ts +73 -0
  41. package/dist/src/evolution/selection.d.ts.map +1 -0
  42. package/dist/src/evolution/selection.js +121 -0
  43. package/dist/src/evolution/selection.js.map +1 -0
  44. package/dist/src/index.d.ts +3 -0
  45. package/dist/src/index.d.ts.map +1 -1
  46. package/dist/src/index.js +16 -0
  47. package/dist/src/index.js.map +1 -1
  48. package/dist/src/types.d.ts +67 -0
  49. package/dist/src/types.d.ts.map +1 -1
  50. package/dist/src/types.js.map +1 -1
  51. package/package.json +4 -1
@@ -0,0 +1,128 @@
1
+ /**
2
+ * Demo injection (v0.10.0) — SIMBA-style "append a demo" challenger source.
3
+ *
4
+ * DSPy's SIMBA optimizer (Stochastic Introspective Mini-Batch Ascent) improves
5
+ * programs through two complementary strategies: appending self-reflective
6
+ * RULES (Darwin's reflector already covers that ground) and appending
7
+ * successful past examples as DEMONSTRATIONS. This module is Darwin's
8
+ * adaptation of the second strategy to the online evolution loop:
9
+ *
10
+ * 1. Harvest the agent's own highest-scoring past runs from memory
11
+ * (score ≥ threshold, successful, non-trivial output).
12
+ * 2. Prefer diversity: at most one demo per task type, best-scoring first.
13
+ * 3. Render them as a clearly-delimited "Demonstrations" section and
14
+ * append it to (or refresh it inside) the current prompt.
15
+ *
16
+ * The demo-augmented prompt is a CHALLENGER like any other — it goes through
17
+ * the same alignment guard, the same A/B test, and the same safety gate as a
18
+ * reflective or merged mutation. If demos don't actually help this agent, the
19
+ * incumbent wins and nothing changes.
20
+ *
21
+ * Design notes:
22
+ * - Zero LLM cost. Selection and rendering are pure string/array work on
23
+ * data Darwin already persists (task, output, score, taskType). This makes
24
+ * demos the cheapest challenger source in the loop.
25
+ * - Idempotent via markers. The section is wrapped in
26
+ * `<!-- darwin:demos:start/end -->` comments so a later demo cycle
27
+ * REPLACES the previous section instead of stacking a second one, and
28
+ * {@link stripDemoSection} can remove it cleanly.
29
+ * - Demo text comes from the agent's OWN prior outputs (already produced
30
+ * under this prompt lineage), not from an external input channel. Excerpts
31
+ * are length-capped and fenced, but callers embedding third-party data in
32
+ * tasks should be aware demos quote past tasks verbatim.
33
+ * - Determinism. Given the same experiment list and options, selection and
34
+ * rendering are fully deterministic (stable sort, no randomness) — the
35
+ * loop's no-op check ("would this produce the same prompt?") stays cheap.
36
+ */
37
+ import type { DarwinExperiment } from "../types.js";
38
+ /** One harvested demonstration, ready for rendering. */
39
+ export interface DemoCandidate {
40
+ /** The task the agent was given. */
41
+ task: string;
42
+ /** The agent's (high-scoring) output. */
43
+ output: string;
44
+ /** Critic score (1-10) that qualified this run as a demo. */
45
+ score: number;
46
+ /** Task category the run was classified under. */
47
+ taskType: string;
48
+ }
49
+ /** Options for {@link selectDemoCandidates}. */
50
+ export interface DemoSelectionOptions {
51
+ /**
52
+ * Maximum number of demos to keep (default {@link DEFAULT_MAX_DEMOS}).
53
+ * SIMBA defaults to 4 per predictor; Darwin defaults lower (2) because the
54
+ * online loop appends demos to a single system prompt and prompt length
55
+ * correlates NEGATIVELY with reliability (documented v2-prompt incident).
56
+ */
57
+ maxDemos?: number;
58
+ /**
59
+ * Minimum critic score for a run to qualify (default
60
+ * {@link DEFAULT_DEMO_SCORE_THRESHOLD}). Mirrors the closed-loop feedback
61
+ * convention where ≥ 8 marks a high-quality pattern.
62
+ */
63
+ scoreThreshold?: number;
64
+ /**
65
+ * Minimum output length (chars) for a run to qualify (default
66
+ * {@link DEFAULT_DEMO_MIN_OUTPUT_CHARS}). Filters out degenerate/truncated
67
+ * outputs that scored well on a technicality.
68
+ */
69
+ minOutputChars?: number;
70
+ }
71
+ /** Options for {@link buildDemoSection}. */
72
+ export interface DemoRenderOptions {
73
+ /** Cap on the quoted task text, chars (default {@link DEFAULT_DEMO_TASK_CHARS}). */
74
+ maxTaskChars?: number;
75
+ /**
76
+ * Cap on each quoted output excerpt, chars (default
77
+ * {@link DEFAULT_DEMO_OUTPUT_CHARS}). Truncation prefers a sentence/newline
78
+ * boundary, same policy as the reflector's output cleaning.
79
+ */
80
+ maxOutputChars?: number;
81
+ }
82
+ export declare const DEFAULT_MAX_DEMOS = 2;
83
+ export declare const DEFAULT_DEMO_SCORE_THRESHOLD = 8;
84
+ export declare const DEFAULT_DEMO_MIN_OUTPUT_CHARS = 200;
85
+ export declare const DEFAULT_DEMO_TASK_CHARS = 240;
86
+ export declare const DEFAULT_DEMO_OUTPUT_CHARS = 900;
87
+ /** Start marker — everything between the markers is Darwin-managed. */
88
+ export declare const DEMO_SECTION_START = "<!-- darwin:demos:start -->";
89
+ /** End marker. */
90
+ export declare const DEMO_SECTION_END = "<!-- darwin:demos:end -->";
91
+ /**
92
+ * Harvest demo candidates from an agent's experiment history.
93
+ *
94
+ * Filter: successful runs with a critic score ≥ `scoreThreshold` and an
95
+ * output of at least `minOutputChars`. Diversity: at most ONE demo per task
96
+ * type (the best-scoring run of that type, recency as tie-break) so two demos
97
+ * never showcase the same narrow strength. Order: score descending, then
98
+ * most-recent first — fully deterministic.
99
+ */
100
+ export declare function selectDemoCandidates(experiments: ReadonlyArray<DarwinExperiment>, options?: DemoSelectionOptions): DemoCandidate[];
101
+ /**
102
+ * Render demo candidates as a marker-delimited prompt section.
103
+ *
104
+ * Returns an empty string for an empty demo list so callers can treat
105
+ * "nothing to inject" uniformly.
106
+ */
107
+ export declare function buildDemoSection(demos: ReadonlyArray<DemoCandidate>, options?: DemoRenderOptions): string;
108
+ /**
109
+ * Apply a rendered demo section to a prompt.
110
+ *
111
+ * If the prompt already contains a marker-delimited demo section it is
112
+ * REPLACED in place (demos stay fresh, never stack); otherwise the section is
113
+ * appended after a blank line. An empty `section` returns the prompt with any
114
+ * existing demo section stripped — passing "no demos" acts as removal.
115
+ *
116
+ * The replacement uses a FUNCTION replacer: with a string replacer,
117
+ * `$&` / `$'` / `` $` `` / `$$` inside the section (an agent output quoting
118
+ * JS-regex or shell docs contains exactly these) would be interpreted as
119
+ * replacement patterns and garble the prompt on every refresh cycle.
120
+ */
121
+ export declare function applyDemoSection(prompt: string, section: string): string;
122
+ /**
123
+ * Remove the marker-delimited demo section (if any), collapsing the blank
124
+ * line that {@link applyDemoSection} inserted. Prompts without a section are
125
+ * returned unchanged.
126
+ */
127
+ export declare function stripDemoSection(prompt: string): string;
128
+ //# sourceMappingURL=demos.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"demos.d.ts","sourceRoot":"","sources":["../../../src/evolution/demos.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAIpD,wDAAwD;AACxD,MAAM,WAAW,aAAa;IAC5B,oCAAoC;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,yCAAyC;IACzC,MAAM,EAAE,MAAM,CAAC;IACf,6DAA6D;IAC7D,KAAK,EAAE,MAAM,CAAC;IACd,kDAAkD;IAClD,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,gDAAgD;AAChD,MAAM,WAAW,oBAAoB;IACnC;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,4CAA4C;AAC5C,MAAM,WAAW,iBAAiB;IAChC,oFAAoF;IACpF,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAID,eAAO,MAAM,iBAAiB,IAAI,CAAC;AACnC,eAAO,MAAM,4BAA4B,IAAI,CAAC;AAC9C,eAAO,MAAM,6BAA6B,MAAM,CAAC;AACjD,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAC3C,eAAO,MAAM,yBAAyB,MAAM,CAAC;AAE7C,uEAAuE;AACvE,eAAO,MAAM,kBAAkB,gCAAgC,CAAC;AAChE,kBAAkB;AAClB,eAAO,MAAM,gBAAgB,8BAA8B,CAAC;AAiB5D;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,aAAa,CAAC,gBAAgB,CAAC,EAC5C,OAAO,GAAE,oBAAyB,GACjC,aAAa,EAAE,CAmDjB;AA2BD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,aAAa,CAAC,aAAa,CAAC,EACnC,OAAO,GAAE,iBAAsB,GAC9B,MAAM,CAgBR;AASD;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAOxE;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAGvD"}
@@ -0,0 +1,196 @@
1
+ /**
2
+ * Demo injection (v0.10.0) — SIMBA-style "append a demo" challenger source.
3
+ *
4
+ * DSPy's SIMBA optimizer (Stochastic Introspective Mini-Batch Ascent) improves
5
+ * programs through two complementary strategies: appending self-reflective
6
+ * RULES (Darwin's reflector already covers that ground) and appending
7
+ * successful past examples as DEMONSTRATIONS. This module is Darwin's
8
+ * adaptation of the second strategy to the online evolution loop:
9
+ *
10
+ * 1. Harvest the agent's own highest-scoring past runs from memory
11
+ * (score ≥ threshold, successful, non-trivial output).
12
+ * 2. Prefer diversity: at most one demo per task type, best-scoring first.
13
+ * 3. Render them as a clearly-delimited "Demonstrations" section and
14
+ * append it to (or refresh it inside) the current prompt.
15
+ *
16
+ * The demo-augmented prompt is a CHALLENGER like any other — it goes through
17
+ * the same alignment guard, the same A/B test, and the same safety gate as a
18
+ * reflective or merged mutation. If demos don't actually help this agent, the
19
+ * incumbent wins and nothing changes.
20
+ *
21
+ * Design notes:
22
+ * - Zero LLM cost. Selection and rendering are pure string/array work on
23
+ * data Darwin already persists (task, output, score, taskType). This makes
24
+ * demos the cheapest challenger source in the loop.
25
+ * - Idempotent via markers. The section is wrapped in
26
+ * `<!-- darwin:demos:start/end -->` comments so a later demo cycle
27
+ * REPLACES the previous section instead of stacking a second one, and
28
+ * {@link stripDemoSection} can remove it cleanly.
29
+ * - Demo text comes from the agent's OWN prior outputs (already produced
30
+ * under this prompt lineage), not from an external input channel. Excerpts
31
+ * are length-capped and fenced, but callers embedding third-party data in
32
+ * tasks should be aware demos quote past tasks verbatim.
33
+ * - Determinism. Given the same experiment list and options, selection and
34
+ * rendering are fully deterministic (stable sort, no randomness) — the
35
+ * loop's no-op check ("would this produce the same prompt?") stays cheap.
36
+ */
37
+ // ─── Defaults & markers ─────────────────────────────────────────────────────
38
+ export const DEFAULT_MAX_DEMOS = 2;
39
+ export const DEFAULT_DEMO_SCORE_THRESHOLD = 8;
40
+ export const DEFAULT_DEMO_MIN_OUTPUT_CHARS = 200;
41
+ export const DEFAULT_DEMO_TASK_CHARS = 240;
42
+ export const DEFAULT_DEMO_OUTPUT_CHARS = 900;
43
+ /** Start marker — everything between the markers is Darwin-managed. */
44
+ export const DEMO_SECTION_START = "<!-- darwin:demos:start -->";
45
+ /** End marker. */
46
+ export const DEMO_SECTION_END = "<!-- darwin:demos:end -->";
47
+ const DEMO_SECTION_INTRO = "## Demonstrations\n" +
48
+ "The following are excerpts from this agent's own highest-rated past " +
49
+ "responses. Match their quality, depth and structure — do NOT copy their " +
50
+ "content or treat their subject matter as part of the current task.";
51
+ // ─── Selection ──────────────────────────────────────────────────────────────
52
+ /** Clamp helper: finite number ≥ min, else fallback. */
53
+ function clampOption(value, min, fallback) {
54
+ return typeof value === "number" && Number.isFinite(value) && value >= min
55
+ ? Math.floor(value)
56
+ : fallback;
57
+ }
58
+ /**
59
+ * Harvest demo candidates from an agent's experiment history.
60
+ *
61
+ * Filter: successful runs with a critic score ≥ `scoreThreshold` and an
62
+ * output of at least `minOutputChars`. Diversity: at most ONE demo per task
63
+ * type (the best-scoring run of that type, recency as tie-break) so two demos
64
+ * never showcase the same narrow strength. Order: score descending, then
65
+ * most-recent first — fully deterministic.
66
+ */
67
+ export function selectDemoCandidates(experiments, options = {}) {
68
+ const maxDemos = clampOption(options.maxDemos, 1, DEFAULT_MAX_DEMOS);
69
+ const threshold = typeof options.scoreThreshold === "number" && Number.isFinite(options.scoreThreshold)
70
+ ? options.scoreThreshold
71
+ : DEFAULT_DEMO_SCORE_THRESHOLD;
72
+ const minChars = clampOption(options.minOutputChars, 0, DEFAULT_DEMO_MIN_OUTPUT_CHARS);
73
+ const qualified = experiments.filter((exp) => {
74
+ if (!exp.success)
75
+ return false;
76
+ const score = exp.feedback?.score;
77
+ if (typeof score !== "number" || !Number.isFinite(score) || score < threshold)
78
+ return false;
79
+ const output = exp.output;
80
+ if (typeof output !== "string" || output.trim().length < minChars)
81
+ return false;
82
+ return typeof exp.task === "string" && exp.task.trim().length > 0;
83
+ });
84
+ // Best run per task type (score desc, then completedAt desc as tie-break).
85
+ const bestPerType = new Map();
86
+ for (const exp of qualified) {
87
+ const key = exp.taskType || "general";
88
+ const incumbent = bestPerType.get(key);
89
+ if (incumbent === undefined) {
90
+ bestPerType.set(key, exp);
91
+ continue;
92
+ }
93
+ const expScore = exp.feedback.score;
94
+ const incScore = incumbent.feedback.score;
95
+ if (expScore > incScore ||
96
+ (expScore === incScore && exp.completedAt > incumbent.completedAt)) {
97
+ bestPerType.set(key, exp);
98
+ }
99
+ }
100
+ const picked = [...bestPerType.values()].sort((a, b) => {
101
+ const scoreDelta = b.feedback.score - a.feedback.score;
102
+ if (scoreDelta !== 0)
103
+ return scoreDelta;
104
+ // Recency tie-break; ISO timestamps sort lexicographically.
105
+ if (a.completedAt < b.completedAt)
106
+ return 1;
107
+ if (a.completedAt > b.completedAt)
108
+ return -1;
109
+ return 0;
110
+ });
111
+ return picked.slice(0, maxDemos).map((exp) => ({
112
+ task: exp.task.trim(),
113
+ output: exp.output.trim(),
114
+ score: exp.feedback.score,
115
+ taskType: exp.taskType || "general",
116
+ }));
117
+ }
118
+ // ─── Rendering ──────────────────────────────────────────────────────────────
119
+ /**
120
+ * Strip the demo-section marker literals out of quoted demo text. A past
121
+ * output that itself contains `<!-- darwin:demos:end -->` (e.g. an agent
122
+ * writing ABOUT Darwin) would otherwise plant an early end-marker inside the
123
+ * section — the next refresh cycle's lazy marker-to-marker match would then
124
+ * cut at the wrong span and leave half the old section dangling in the prompt.
125
+ */
126
+ function stripMarkerLiterals(text) {
127
+ return text.split(DEMO_SECTION_START).join("").split(DEMO_SECTION_END).join("");
128
+ }
129
+ /** Truncate at the last sentence/newline boundary within `maxLength`. */
130
+ function truncateAtSentenceBoundary(text, maxLength) {
131
+ if (text.length <= maxLength)
132
+ return text;
133
+ const truncated = text.slice(0, maxLength);
134
+ const lastPeriod = truncated.lastIndexOf(".");
135
+ const lastNewline = truncated.lastIndexOf("\n");
136
+ const cutPoint = Math.max(lastPeriod, lastNewline);
137
+ // Only honour the boundary when it keeps a meaningful chunk (> 40%).
138
+ const kept = cutPoint > maxLength * 0.4 ? truncated.slice(0, cutPoint + 1) : truncated;
139
+ return `${kept.trimEnd()} [...]`;
140
+ }
141
+ /**
142
+ * Render demo candidates as a marker-delimited prompt section.
143
+ *
144
+ * Returns an empty string for an empty demo list so callers can treat
145
+ * "nothing to inject" uniformly.
146
+ */
147
+ export function buildDemoSection(demos, options = {}) {
148
+ if (demos.length === 0)
149
+ return "";
150
+ const maxTask = clampOption(options.maxTaskChars, 20, DEFAULT_DEMO_TASK_CHARS);
151
+ const maxOutput = clampOption(options.maxOutputChars, 80, DEFAULT_DEMO_OUTPUT_CHARS);
152
+ const blocks = demos.map((demo, i) => {
153
+ const task = truncateAtSentenceBoundary(stripMarkerLiterals(demo.task), maxTask);
154
+ const excerpt = truncateAtSentenceBoundary(stripMarkerLiterals(demo.output), maxOutput);
155
+ return (`### Demonstration ${i + 1} — task type "${demo.taskType}" (scored ${demo.score}/10)\n` +
156
+ `Task: ${task}\n` +
157
+ `Response excerpt:\n"""\n${excerpt}\n"""`);
158
+ });
159
+ return [DEMO_SECTION_START, DEMO_SECTION_INTRO, ...blocks, DEMO_SECTION_END].join("\n\n");
160
+ }
161
+ // ─── Application ────────────────────────────────────────────────────────────
162
+ /** Regex matching one marker-delimited demo section (including markers). */
163
+ const DEMO_SECTION_PATTERN = new RegExp(`${DEMO_SECTION_START.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}[\\s\\S]*?${DEMO_SECTION_END.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}`);
164
+ /**
165
+ * Apply a rendered demo section to a prompt.
166
+ *
167
+ * If the prompt already contains a marker-delimited demo section it is
168
+ * REPLACED in place (demos stay fresh, never stack); otherwise the section is
169
+ * appended after a blank line. An empty `section` returns the prompt with any
170
+ * existing demo section stripped — passing "no demos" acts as removal.
171
+ *
172
+ * The replacement uses a FUNCTION replacer: with a string replacer,
173
+ * `$&` / `$'` / `` $` `` / `$$` inside the section (an agent output quoting
174
+ * JS-regex or shell docs contains exactly these) would be interpreted as
175
+ * replacement patterns and garble the prompt on every refresh cycle.
176
+ */
177
+ export function applyDemoSection(prompt, section) {
178
+ if (section === "")
179
+ return stripDemoSection(prompt);
180
+ if (DEMO_SECTION_PATTERN.test(prompt)) {
181
+ return prompt.replace(DEMO_SECTION_PATTERN, () => section);
182
+ }
183
+ const trimmed = prompt.replace(/\s+$/, "");
184
+ return `${trimmed}\n\n${section}`;
185
+ }
186
+ /**
187
+ * Remove the marker-delimited demo section (if any), collapsing the blank
188
+ * line that {@link applyDemoSection} inserted. Prompts without a section are
189
+ * returned unchanged.
190
+ */
191
+ export function stripDemoSection(prompt) {
192
+ if (!DEMO_SECTION_PATTERN.test(prompt))
193
+ return prompt;
194
+ return prompt.replace(DEMO_SECTION_PATTERN, "").replace(/\n{3,}/g, "\n\n").replace(/\s+$/, "");
195
+ }
196
+ //# sourceMappingURL=demos.js.map
@@ -0,0 +1 @@
1
+ {"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OAAO,MAAM,CAAC;IACtD,OAAO,MAAM,CAAC,OAAO,CAAC,oBAAoB,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AACjG,CAAC"}
@@ -39,11 +39,11 @@ export declare function setEvolutionEnabled(memory: MemoryProvider, agentName: s
39
39
  * ({@link DarwinState.evolutionConfigOverrides}) merged ON TOP, then any
40
40
  * in-this-process CLI override merged last (e.g. `darwin run … --gepa`).
41
41
  *
42
- * Only the five advanced flags are overridable; every other field
43
- * (`enabled`, `metrics`, `minRuns`, …) is taken verbatim from the static
44
- * config. Returns `undefined` when the agent has no `evolution` block AND no
45
- * persisted/CLI override would create one — overriding a flag on an agent that
46
- * never opted into evolution is meaningless.
42
+ * Only the advanced flags in {@link OVERRIDE_KEYS} are overridable; every
43
+ * other field (`enabled`, `metrics`, `minRuns`, …) is taken verbatim from the
44
+ * static config. Returns `undefined` when the agent has no `evolution` block
45
+ * AND no persisted/CLI override would create one — overriding a flag on an
46
+ * agent that never opted into evolution is meaningless.
47
47
  *
48
48
  * Read defensively: undefined override values are skipped so they never clobber
49
49
  * a static default with `undefined`.
@@ -1 +1 @@
1
- {"version":3,"file":"enabled-state.d.ts","sourceRoot":"","sources":["../../../src/evolution/enabled-state.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EACV,eAAe,EACf,WAAW,EACX,eAAe,EACf,uBAAuB,EACvB,cAAc,EACf,MAAM,aAAa,CAAC;AAErB;;;;;;;;;;;;GAYG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,eAAe,EACtB,KAAK,EAAE,IAAI,CAAC,WAAW,EAAE,kBAAkB,CAAC,GAC3C,OAAO,CAUT;AAED;;;;;;GAMG;AACH,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,cAAc,EACtB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,IAAI,CAAC,CAQf;AAaD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,eAAe,EACtB,KAAK,EAAE,IAAI,CAAC,WAAW,EAAE,0BAA0B,CAAC,EACpD,WAAW,CAAC,EAAE,uBAAuB,GACpC,eAAe,GAAG,SAAS,CA8B7B;AAED;;;;;GAKG;AACH,wBAAsB,2BAA2B,CAC/C,MAAM,EAAE,cAAc,EACtB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,IAAI,CAAC,CASf"}
1
+ {"version":3,"file":"enabled-state.d.ts","sourceRoot":"","sources":["../../../src/evolution/enabled-state.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EACV,eAAe,EACf,WAAW,EACX,eAAe,EACf,uBAAuB,EACvB,cAAc,EACf,MAAM,aAAa,CAAC;AAErB;;;;;;;;;;;;GAYG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,eAAe,EACtB,KAAK,EAAE,IAAI,CAAC,WAAW,EAAE,kBAAkB,CAAC,GAC3C,OAAO,CAUT;AAED;;;;;;GAMG;AACH,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,cAAc,EACtB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,IAAI,CAAC,CAQf;AAeD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,eAAe,EACtB,KAAK,EAAE,IAAI,CAAC,WAAW,EAAE,0BAA0B,CAAC,EACpD,WAAW,CAAC,EAAE,uBAAuB,GACpC,eAAe,GAAG,SAAS,CAgC7B;AAED;;;;;GAKG;AACH,wBAAsB,2BAA2B,CAC/C,MAAM,EAAE,cAAc,EACtB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,IAAI,CAAC,CASf"}
@@ -58,6 +58,8 @@ const OVERRIDE_KEYS = [
58
58
  'paretoGate',
59
59
  'useCoverage',
60
60
  'reflectionModel',
61
+ 'useDemos',
62
+ 'candidateSelection',
61
63
  ];
62
64
  /**
63
65
  * Resolve the effective {@link EvolutionConfig} for an agent: the static
@@ -65,11 +67,11 @@ const OVERRIDE_KEYS = [
65
67
  * ({@link DarwinState.evolutionConfigOverrides}) merged ON TOP, then any
66
68
  * in-this-process CLI override merged last (e.g. `darwin run … --gepa`).
67
69
  *
68
- * Only the five advanced flags are overridable; every other field
69
- * (`enabled`, `metrics`, `minRuns`, …) is taken verbatim from the static
70
- * config. Returns `undefined` when the agent has no `evolution` block AND no
71
- * persisted/CLI override would create one — overriding a flag on an agent that
72
- * never opted into evolution is meaningless.
70
+ * Only the advanced flags in {@link OVERRIDE_KEYS} are overridable; every
71
+ * other field (`enabled`, `metrics`, `minRuns`, …) is taken verbatim from the
72
+ * static config. Returns `undefined` when the agent has no `evolution` block
73
+ * AND no persisted/CLI override would create one — overriding a flag on an
74
+ * agent that never opted into evolution is meaningless.
73
75
  *
74
76
  * Read defensively: undefined override values are skipped so they never clobber
75
77
  * a static default with `undefined`.
@@ -95,6 +97,9 @@ export function resolveEvolutionConfig(agent, state, cliOverride) {
95
97
  if (key === 'reflectionModel') {
96
98
  resolved.reflectionModel = value;
97
99
  }
100
+ else if (key === 'candidateSelection') {
101
+ resolved.candidateSelection = value;
102
+ }
98
103
  else {
99
104
  resolved[key] = value;
100
105
  }
@@ -1 +1 @@
1
- {"version":3,"file":"enabled-state.js","sourceRoot":"","sources":["../../../src/evolution/enabled-state.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAUH;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,uBAAuB,CACrC,KAAsB,EACtB,KAA4C;IAE5C,MAAM,SAAS,GAAG,KAAK,CAAC,gBAAgB,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACvD,IAAI,OAAO,SAAS,KAAK,SAAS,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AAC;QACxE,OAAO,KAAK,CAAC;IACf,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -58,6 +58,13 @@ interface DarwinLoopDeps {
58
58
  * (only used when `embed` is set). Default 0.82.
59
59
  */
60
60
  alignmentSimilarityThreshold?: number;
61
+ /**
62
+ * v0.10.0 — Random source in [0, 1) for the stochastic parent-selection
63
+ * strategies (`candidateSelection: 'pareto' | 'epsilon-greedy'`). Injected
64
+ * for deterministic tests; default `Math.random`. Never consulted on the
65
+ * default `'active'` path.
66
+ */
67
+ rng?: () => number;
61
68
  }
62
69
  export declare class DarwinLoop {
63
70
  private memory;
@@ -70,6 +77,7 @@ export declare class DarwinLoop {
70
77
  private gepa?;
71
78
  private embed?;
72
79
  private alignmentSimilarityThreshold?;
80
+ private rng?;
73
81
  constructor(deps: DarwinLoopDeps);
74
82
  /**
75
83
  * Called AFTER every agent run. Drives the evolution cycle.
@@ -173,6 +181,34 @@ export declare class DarwinLoop {
173
181
  * v0.7.0 — Merge cadence (every K-th cycle). Default 3, clamped ≥ 1.
174
182
  */
175
183
  private mergeEveryK;
184
+ /**
185
+ * v0.10.0 — Demo-injection cadence (every K-th cycle). Default 4, clamped
186
+ * ≥ 1. Deliberately offset from the merge default (3) so the two
187
+ * non-reflective challenger sources don't collide on the same cycles.
188
+ */
189
+ private demoEveryK;
190
+ /**
191
+ * v0.10.0 — Build a SIMBA-style demo challenger: current prompt + a
192
+ * marker-delimited "Demonstrations" section harvested from this agent's
193
+ * highest-scoring past runs. Pure selection + rendering — no LLM call.
194
+ *
195
+ * Returns `null` (→ caller falls through to GEPA/legacy generation) when
196
+ * no run qualifies (score/threshold/length filters) or when the rendered
197
+ * demo set is byte-identical to what the prompt already carries — an A/B
198
+ * test of a version against itself would be pointless.
199
+ */
200
+ private tryDemoVariant;
201
+ /**
202
+ * v0.10.0 — Scored version history for parent selection AND merge: every
203
+ * prompt version that has text and at least one run's worth of averaged
204
+ * metrics, as {@link ScoredVariant}s. One getAverageMetrics
205
+ * (→ loadExperiments) call per version. O(N) backend round-trips, but N is
206
+ * the agent's prompt-version count (≤ ~20 in practice) and this only runs
207
+ * on selection/merge cadences, so it is cheap — same pattern handleABTest
208
+ * already uses for the Pareto gate. (Extracted from tryMergeVariant,
209
+ * behaviour unchanged.)
210
+ */
211
+ private buildScoredHistory;
176
212
  /**
177
213
  * v0.7.0 — GEPA system-aware MERGE (paper Appendix-D). Builds scored
178
214
  * variants from this agent's prompt-version history (each version's prompt
@@ -1 +1 @@
1
- {"version":3,"file":"loop.d.ts","sourceRoot":"","sources":["../../../src/evolution/loop.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAEV,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,cAAc,EAGf,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,KAAK,EAAE,eAAe,EAAoB,MAAM,gBAAgB,CAAC;AACxE,OAAO,KAAK,EAAE,UAAU,EAAiB,MAAM,aAAa,CAAC;AAC7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE7D,OAAO,KAAK,EAAE,aAAa,EAAiB,MAAM,qBAAqB,CAAC;AAGxE,OAAO,EAAkE,KAAK,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAK9G,MAAM,WAAW,eAAe;IAC9B,aAAa,EAAE,aAAa,EAAE,CAAC;IAC/B,aAAa,EAAE,OAAO,CAAC;IACvB,aAAa,EAAE,OAAO,CAAC;IACvB,eAAe,EAAE,OAAO,CAAC;IACzB,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;CACjB;AAID,UAAU,cAAc;IACtB,MAAM,EAAE,cAAc,CAAC;IACvB,OAAO,EAAE,iBAAiB,CAAC;IA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