darwin-agents 0.4.9 → 0.5.0-alpha.2
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/CHANGELOG.md +85 -0
- package/dist/agents/analyst.d.ts +11 -0
- package/dist/agents/analyst.d.ts.map +1 -0
- package/dist/agents/analyst.js +78 -0
- package/dist/agents/analyst.js.map +1 -0
- package/dist/agents/blog-writer.d.ts +13 -0
- package/dist/agents/blog-writer.d.ts.map +1 -0
- package/dist/agents/blog-writer.js +59 -0
- package/dist/agents/blog-writer.js.map +1 -0
- package/dist/agents/critic.d.ts +11 -0
- package/dist/agents/critic.d.ts.map +1 -0
- package/dist/agents/critic.js +57 -0
- package/dist/agents/critic.js.map +1 -0
- package/dist/agents/index.d.ts +15 -0
- package/dist/agents/index.d.ts.map +1 -0
- package/dist/agents/index.js +31 -0
- package/dist/agents/index.js.map +1 -0
- package/dist/agents/investigator-critic.d.ts +10 -0
- package/dist/agents/investigator-critic.d.ts.map +1 -0
- package/dist/agents/investigator-critic.js +78 -0
- package/dist/agents/investigator-critic.js.map +1 -0
- package/dist/agents/investigator.d.ts +13 -0
- package/dist/agents/investigator.d.ts.map +1 -0
- package/dist/agents/investigator.js +105 -0
- package/dist/agents/investigator.js.map +1 -0
- package/dist/agents/marketing.d.ts +13 -0
- package/dist/agents/marketing.d.ts.map +1 -0
- package/dist/agents/marketing.js +59 -0
- package/dist/agents/marketing.js.map +1 -0
- package/dist/agents/researcher.d.ts +11 -0
- package/dist/agents/researcher.d.ts.map +1 -0
- package/dist/agents/researcher.js +68 -0
- package/dist/agents/researcher.js.map +1 -0
- package/dist/agents/writer.d.ts +9 -0
- package/dist/agents/writer.d.ts.map +1 -0
- package/dist/agents/writer.js +47 -0
- package/dist/agents/writer.js.map +1 -0
- package/dist/cli/create.d.ts +11 -0
- package/dist/cli/create.d.ts.map +1 -0
- package/dist/cli/create.js +104 -0
- package/dist/cli/create.js.map +1 -0
- package/dist/cli/evolve.d.ts +13 -0
- package/dist/cli/evolve.d.ts.map +1 -0
- package/dist/cli/evolve.js +69 -0
- package/dist/cli/evolve.js.map +1 -0
- package/dist/cli/index.d.ts +13 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +84 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/init.d.ts +12 -0
- package/dist/cli/init.d.ts.map +1 -0
- package/dist/cli/init.js +68 -0
- package/dist/cli/init.js.map +1 -0
- package/dist/cli/run.d.ts +7 -0
- package/dist/cli/run.d.ts.map +1 -0
- package/dist/cli/run.js +371 -0
- package/dist/cli/run.js.map +1 -0
- package/dist/cli/status.d.ts +7 -0
- package/dist/cli/status.d.ts.map +1 -0
- package/dist/cli/status.js +123 -0
- package/dist/cli/status.js.map +1 -0
- package/dist/core/agent.d.ts +53 -0
- package/dist/core/agent.d.ts.map +1 -0
- package/dist/core/agent.js +172 -0
- package/dist/core/agent.js.map +1 -0
- package/dist/core/runner.d.ts +75 -0
- package/dist/core/runner.d.ts.map +1 -0
- package/dist/core/runner.js +255 -0
- package/dist/core/runner.js.map +1 -0
- package/dist/evolution/loop.d.ts +100 -0
- package/dist/evolution/loop.d.ts.map +1 -0
- package/dist/evolution/loop.js +424 -0
- package/dist/evolution/loop.js.map +1 -0
- package/dist/evolution/multi-critic.d.ts +58 -0
- package/dist/evolution/multi-critic.d.ts.map +1 -0
- package/dist/evolution/multi-critic.js +326 -0
- package/dist/evolution/multi-critic.js.map +1 -0
- package/dist/evolution/notifications.d.ts +32 -0
- package/dist/evolution/notifications.d.ts.map +1 -0
- package/dist/evolution/notifications.js +92 -0
- package/dist/evolution/notifications.js.map +1 -0
- package/dist/evolution/optimizer.d.ts +64 -0
- package/dist/evolution/optimizer.d.ts.map +1 -0
- package/dist/evolution/optimizer.js +223 -0
- package/dist/evolution/optimizer.js.map +1 -0
- package/dist/evolution/patterns.d.ts +63 -0
- package/dist/evolution/patterns.d.ts.map +1 -0
- package/dist/evolution/patterns.js +297 -0
- package/dist/evolution/patterns.js.map +1 -0
- package/dist/evolution/safety.d.ts +76 -0
- package/dist/evolution/safety.d.ts.map +1 -0
- package/dist/evolution/safety.js +182 -0
- package/dist/evolution/safety.js.map +1 -0
- package/dist/evolution/tracker.d.ts +48 -0
- package/dist/evolution/tracker.d.ts.map +1 -0
- package/dist/evolution/tracker.js +163 -0
- package/dist/evolution/tracker.js.map +1 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +35 -0
- package/dist/index.js.map +1 -0
- package/dist/memory/index.d.ts +32 -0
- package/dist/memory/index.d.ts.map +1 -0
- package/dist/memory/index.js +49 -0
- package/dist/memory/index.js.map +1 -0
- package/dist/memory/postgres-memory.d.ts +52 -0
- package/dist/memory/postgres-memory.d.ts.map +1 -0
- package/dist/memory/postgres-memory.js +515 -0
- package/dist/memory/postgres-memory.js.map +1 -0
- package/dist/memory/sqlite-memory.d.ts +36 -0
- package/dist/memory/sqlite-memory.d.ts.map +1 -0
- package/dist/memory/sqlite-memory.js +380 -0
- package/dist/memory/sqlite-memory.js.map +1 -0
- package/dist/providers/anthropic.d.ts +20 -0
- package/dist/providers/anthropic.d.ts.map +1 -0
- package/dist/providers/anthropic.js +82 -0
- package/dist/providers/anthropic.js.map +1 -0
- package/dist/providers/claude-cli.d.ts +35 -0
- package/dist/providers/claude-cli.d.ts.map +1 -0
- package/dist/providers/claude-cli.js +153 -0
- package/dist/providers/claude-cli.js.map +1 -0
- package/dist/providers/index.d.ts +39 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/providers/index.js +58 -0
- package/dist/providers/index.js.map +1 -0
- package/dist/providers/ollama.d.ts +17 -0
- package/dist/providers/ollama.d.ts.map +1 -0
- package/dist/providers/ollama.js +64 -0
- package/dist/providers/ollama.js.map +1 -0
- package/dist/providers/openai.d.ts +19 -0
- package/dist/providers/openai.d.ts.map +1 -0
- package/dist/providers/openai.js +75 -0
- package/dist/providers/openai.js.map +1 -0
- package/dist/providers/types.d.ts +62 -0
- package/dist/providers/types.d.ts.map +1 -0
- package/dist/providers/types.js +9 -0
- package/dist/providers/types.js.map +1 -0
- package/dist/src/core/trace-capture.d.ts +107 -0
- package/dist/src/core/trace-capture.d.ts.map +1 -0
- package/dist/src/core/trace-capture.js +183 -0
- package/dist/src/core/trace-capture.js.map +1 -0
- package/dist/src/evolution/optimizer-gepa.d.ts +149 -0
- package/dist/src/evolution/optimizer-gepa.d.ts.map +1 -0
- package/dist/src/evolution/optimizer-gepa.js +198 -0
- package/dist/src/evolution/optimizer-gepa.js.map +1 -0
- package/dist/src/evolution/pareto.d.ts +116 -0
- package/dist/src/evolution/pareto.d.ts.map +1 -0
- package/dist/src/evolution/pareto.js +140 -0
- package/dist/src/evolution/pareto.js.map +1 -0
- package/dist/src/evolution/reflector.d.ts +107 -0
- package/dist/src/evolution/reflector.d.ts.map +1 -0
- package/dist/src/evolution/reflector.js +158 -0
- package/dist/src/evolution/reflector.js.map +1 -0
- package/dist/src/evolution/run-prompt-fn.d.ts +11 -0
- package/dist/src/evolution/run-prompt-fn.d.ts.map +1 -0
- package/dist/src/evolution/run-prompt-fn.js +11 -0
- package/dist/src/evolution/run-prompt-fn.js.map +1 -0
- package/dist/src/index.d.ts +7 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +6 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/memory/postgres-memory.d.ts.map +1 -1
- package/dist/src/memory/postgres-memory.js +38 -3
- package/dist/src/memory/postgres-memory.js.map +1 -1
- package/dist/src/memory/sqlite-memory.d.ts.map +1 -1
- package/dist/src/memory/sqlite-memory.js +47 -2
- package/dist/src/memory/sqlite-memory.js.map +1 -1
- package/dist/src/types.d.ts +136 -0
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js.map +1 -1
- package/dist/types.d.ts +221 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +19 -0
- package/dist/types.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Darwin — Pareto-Front Selection (Phase 2 A2, S1185 follow-up).
|
|
3
|
+
*
|
|
4
|
+
* Pure functions for multi-objective optimization in the GEPA-style
|
|
5
|
+
* reflective optimizer. The classic Pareto definition:
|
|
6
|
+
*
|
|
7
|
+
* A "dominates" B iff:
|
|
8
|
+
* - For ALL objectives O: A[O] is at least as good as B[O].
|
|
9
|
+
* - For at LEAST ONE objective O: A[O] is strictly better than B[O].
|
|
10
|
+
*
|
|
11
|
+
* A "non-dominated" variant is one that is not dominated by any other.
|
|
12
|
+
* The non-dominated set is the Pareto front.
|
|
13
|
+
*
|
|
14
|
+
* This module is **pure** — no LLM calls, no I/O, no Date.now(). Tests
|
|
15
|
+
* are fully deterministic.
|
|
16
|
+
*
|
|
17
|
+
* Reference: GEPA (Genetic-Pareto) reflective optimizer
|
|
18
|
+
* https://gepa-ai.github.io/gepa/ — Pareto-efficient search over text
|
|
19
|
+
* components with LLM-guided reflection.
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* One objective in a multi-objective Pareto comparison.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* import type { DarwinMetrics } from "darwin-agents";
|
|
26
|
+
* const objectives: ParetoObjective<DarwinMetrics>[] = [
|
|
27
|
+
* { key: "qualityScore", direction: "maximize" },
|
|
28
|
+
* { key: "sourceCount", direction: "maximize" },
|
|
29
|
+
* { key: "durationMs", direction: "minimize" },
|
|
30
|
+
* { key: "outputLength", direction: "maximize" },
|
|
31
|
+
* ];
|
|
32
|
+
*
|
|
33
|
+
* Or use the pre-built {@link DARWIN_DEFAULT_OBJECTIVES} constant.
|
|
34
|
+
*/
|
|
35
|
+
export interface ParetoObjective<T> {
|
|
36
|
+
/** Field on the variant to compare. Must hold a finite number. */
|
|
37
|
+
key: keyof T;
|
|
38
|
+
/**
|
|
39
|
+
* `"maximize"` if higher = better (qualityScore, sourceCount).
|
|
40
|
+
* `"minimize"` if lower = better (durationMs, cost).
|
|
41
|
+
*/
|
|
42
|
+
direction: "maximize" | "minimize";
|
|
43
|
+
/**
|
|
44
|
+
* Optional weight for tie-breaking scalarisation only — does NOT
|
|
45
|
+
* affect strict Pareto dominance. Default 1.
|
|
46
|
+
*
|
|
47
|
+
* **Scale warning (S1185 R1 Critic Finding M4):** weights operate on
|
|
48
|
+
* the raw objective values. If your objectives have very different
|
|
49
|
+
* scales (e.g. cost in dollars 0-10000 vs success-rate 0-1), the
|
|
50
|
+
* larger-scale objective dominates the scalarised sum regardless of
|
|
51
|
+
* weight. Pre-normalise your objectives to comparable ranges before
|
|
52
|
+
* relying on {@link paretoSelect}'s truncation step. Strict
|
|
53
|
+
* dominance ({@link dominates}, {@link nonDominatedFront}) is
|
|
54
|
+
* unaffected — per-dimension comparison handles scale correctly.
|
|
55
|
+
*/
|
|
56
|
+
weight?: number;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Pre-built objective set matching `DarwinMetrics` field names.
|
|
60
|
+
*
|
|
61
|
+
* Drop-in default for `paretoSelect`/`GepaOptimizer.nextGeneration`
|
|
62
|
+
* when you optimise the standard Darwin metrics. Note that
|
|
63
|
+
* `outputLength` is direction `"maximize"` because Darwin uses output
|
|
64
|
+
* length as a proxy for completeness/depth in its existing weight
|
|
65
|
+
* scheme — if your domain treats long outputs as worse, override the
|
|
66
|
+
* direction in a custom array.
|
|
67
|
+
*/
|
|
68
|
+
export declare const DARWIN_DEFAULT_OBJECTIVES: ReadonlyArray<ParetoObjective<{
|
|
69
|
+
qualityScore: number;
|
|
70
|
+
sourceCount: number;
|
|
71
|
+
durationMs: number;
|
|
72
|
+
outputLength: number;
|
|
73
|
+
}>>;
|
|
74
|
+
/**
|
|
75
|
+
* True iff `a` Pareto-dominates `b` over the given objectives.
|
|
76
|
+
*
|
|
77
|
+
* Returns false if either side has a non-finite value for any objective
|
|
78
|
+
* (NaN/Infinity are treated as "not comparable" — defensive against
|
|
79
|
+
* malformed variants poisoning the front).
|
|
80
|
+
*/
|
|
81
|
+
export declare function dominates<T extends Record<string, unknown>>(a: T, b: T, objectives: ReadonlyArray<ParetoObjective<T>>): boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Return the subset of `variants` that are NOT dominated by any other
|
|
84
|
+
* variant in the set. This is the Pareto front.
|
|
85
|
+
*
|
|
86
|
+
* Empty input → empty output. Single variant → that variant. Naive
|
|
87
|
+
* O(N²) implementation which is fine for the N≤20 variant pools the
|
|
88
|
+
* GEPA optimizer works with.
|
|
89
|
+
*
|
|
90
|
+
* Duplicates (identical objective vectors) are all kept — no variant
|
|
91
|
+
* dominates an identical one (strictlyBetterSomewhere stays false).
|
|
92
|
+
*/
|
|
93
|
+
export declare function nonDominatedFront<T extends Record<string, unknown>>(variants: ReadonlyArray<T>, objectives: ReadonlyArray<ParetoObjective<T>>): T[];
|
|
94
|
+
/**
|
|
95
|
+
* Scalarise a variant to a single number for tie-breaking. Sum of
|
|
96
|
+
* normalised direction-adjusted values × weight. NOT used for strict
|
|
97
|
+
* Pareto dominance — only when a fixed-size pick is needed after the
|
|
98
|
+
* front is identified (e.g. carrying 3 best forward to next GEPA
|
|
99
|
+
* generation).
|
|
100
|
+
*
|
|
101
|
+
* Non-finite values contribute 0 (defensive).
|
|
102
|
+
*/
|
|
103
|
+
export declare function scalarise<T extends Record<string, unknown>>(variant: T, objectives: ReadonlyArray<ParetoObjective<T>>): number;
|
|
104
|
+
/**
|
|
105
|
+
* Pareto-select up to `maxKeep` variants:
|
|
106
|
+
* 1. Compute non-dominated front.
|
|
107
|
+
* 2. If front size ≤ maxKeep: return front.
|
|
108
|
+
* 3. If front size > maxKeep: sort by scalarised score (descending),
|
|
109
|
+
* keep top maxKeep.
|
|
110
|
+
*
|
|
111
|
+
* Use this when the GEPA generation budget is fixed (e.g. carry exactly
|
|
112
|
+
* 3 variants to the next round) but the Pareto front happens to be
|
|
113
|
+
* larger.
|
|
114
|
+
*/
|
|
115
|
+
export declare function paretoSelect<T extends Record<string, unknown>>(variants: ReadonlyArray<T>, objectives: ReadonlyArray<ParetoObjective<T>>, maxKeep?: number): T[];
|
|
116
|
+
//# sourceMappingURL=pareto.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pareto.d.ts","sourceRoot":"","sources":["../../../src/evolution/pareto.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,eAAe,CAAC,CAAC;IAChC,kEAAkE;IAClE,GAAG,EAAE,MAAM,CAAC,CAAC;IACb;;;OAGG;IACH,SAAS,EAAE,UAAU,GAAG,UAAU,CAAC;IACnC;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,yBAAyB,EAAE,aAAa,CAAC,eAAe,CAAC;IACpE,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC,CAKD,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACzD,CAAC,EAAE,CAAC,EACJ,CAAC,EAAE,CAAC,EACJ,UAAU,EAAE,aAAa,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,GAC5C,OAAO,CAeT;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjE,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,EAC1B,UAAU,EAAE,aAAa,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,GAC5C,CAAC,EAAE,CAoBL;AAED;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACzD,OAAO,EAAE,CAAC,EACV,UAAU,EAAE,aAAa,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,GAC5C,MAAM,CAUR;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5D,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,EAC1B,UAAU,EAAE,aAAa,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,EAC7C,OAAO,CAAC,EAAE,MAAM,GACf,CAAC,EAAE,CAML"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Darwin — Pareto-Front Selection (Phase 2 A2, S1185 follow-up).
|
|
3
|
+
*
|
|
4
|
+
* Pure functions for multi-objective optimization in the GEPA-style
|
|
5
|
+
* reflective optimizer. The classic Pareto definition:
|
|
6
|
+
*
|
|
7
|
+
* A "dominates" B iff:
|
|
8
|
+
* - For ALL objectives O: A[O] is at least as good as B[O].
|
|
9
|
+
* - For at LEAST ONE objective O: A[O] is strictly better than B[O].
|
|
10
|
+
*
|
|
11
|
+
* A "non-dominated" variant is one that is not dominated by any other.
|
|
12
|
+
* The non-dominated set is the Pareto front.
|
|
13
|
+
*
|
|
14
|
+
* This module is **pure** — no LLM calls, no I/O, no Date.now(). Tests
|
|
15
|
+
* are fully deterministic.
|
|
16
|
+
*
|
|
17
|
+
* Reference: GEPA (Genetic-Pareto) reflective optimizer
|
|
18
|
+
* https://gepa-ai.github.io/gepa/ — Pareto-efficient search over text
|
|
19
|
+
* components with LLM-guided reflection.
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* Pre-built objective set matching `DarwinMetrics` field names.
|
|
23
|
+
*
|
|
24
|
+
* Drop-in default for `paretoSelect`/`GepaOptimizer.nextGeneration`
|
|
25
|
+
* when you optimise the standard Darwin metrics. Note that
|
|
26
|
+
* `outputLength` is direction `"maximize"` because Darwin uses output
|
|
27
|
+
* length as a proxy for completeness/depth in its existing weight
|
|
28
|
+
* scheme — if your domain treats long outputs as worse, override the
|
|
29
|
+
* direction in a custom array.
|
|
30
|
+
*/
|
|
31
|
+
export const DARWIN_DEFAULT_OBJECTIVES = [
|
|
32
|
+
{ key: "qualityScore", direction: "maximize", weight: 0.5 },
|
|
33
|
+
{ key: "sourceCount", direction: "maximize", weight: 0.15 },
|
|
34
|
+
{ key: "outputLength", direction: "maximize", weight: 0.1 },
|
|
35
|
+
{ key: "durationMs", direction: "minimize", weight: 0.25 },
|
|
36
|
+
];
|
|
37
|
+
/**
|
|
38
|
+
* True iff `a` Pareto-dominates `b` over the given objectives.
|
|
39
|
+
*
|
|
40
|
+
* Returns false if either side has a non-finite value for any objective
|
|
41
|
+
* (NaN/Infinity are treated as "not comparable" — defensive against
|
|
42
|
+
* malformed variants poisoning the front).
|
|
43
|
+
*/
|
|
44
|
+
export function dominates(a, b, objectives) {
|
|
45
|
+
if (objectives.length === 0)
|
|
46
|
+
return false;
|
|
47
|
+
let strictlyBetterSomewhere = false;
|
|
48
|
+
for (const obj of objectives) {
|
|
49
|
+
const av = a[obj.key];
|
|
50
|
+
const bv = b[obj.key];
|
|
51
|
+
if (typeof av !== "number" || typeof bv !== "number")
|
|
52
|
+
return false;
|
|
53
|
+
if (!Number.isFinite(av) || !Number.isFinite(bv))
|
|
54
|
+
return false;
|
|
55
|
+
// Normalise direction so "better" is always ">" in comparison.
|
|
56
|
+
const aNorm = obj.direction === "maximize" ? av : -av;
|
|
57
|
+
const bNorm = obj.direction === "maximize" ? bv : -bv;
|
|
58
|
+
if (aNorm < bNorm)
|
|
59
|
+
return false; // a is worse on this objective → not dominating
|
|
60
|
+
if (aNorm > bNorm)
|
|
61
|
+
strictlyBetterSomewhere = true;
|
|
62
|
+
}
|
|
63
|
+
return strictlyBetterSomewhere;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Return the subset of `variants` that are NOT dominated by any other
|
|
67
|
+
* variant in the set. This is the Pareto front.
|
|
68
|
+
*
|
|
69
|
+
* Empty input → empty output. Single variant → that variant. Naive
|
|
70
|
+
* O(N²) implementation which is fine for the N≤20 variant pools the
|
|
71
|
+
* GEPA optimizer works with.
|
|
72
|
+
*
|
|
73
|
+
* Duplicates (identical objective vectors) are all kept — no variant
|
|
74
|
+
* dominates an identical one (strictlyBetterSomewhere stays false).
|
|
75
|
+
*/
|
|
76
|
+
export function nonDominatedFront(variants, objectives) {
|
|
77
|
+
if (variants.length === 0)
|
|
78
|
+
return [];
|
|
79
|
+
if (objectives.length === 0) {
|
|
80
|
+
// Without objectives no variant dominates any other — keep all.
|
|
81
|
+
return [...variants];
|
|
82
|
+
}
|
|
83
|
+
const result = [];
|
|
84
|
+
for (let i = 0; i < variants.length; i++) {
|
|
85
|
+
const candidate = variants[i];
|
|
86
|
+
let dominated = false;
|
|
87
|
+
for (let j = 0; j < variants.length; j++) {
|
|
88
|
+
if (i === j)
|
|
89
|
+
continue;
|
|
90
|
+
if (dominates(variants[j], candidate, objectives)) {
|
|
91
|
+
dominated = true;
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (!dominated)
|
|
96
|
+
result.push(candidate);
|
|
97
|
+
}
|
|
98
|
+
return result;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Scalarise a variant to a single number for tie-breaking. Sum of
|
|
102
|
+
* normalised direction-adjusted values × weight. NOT used for strict
|
|
103
|
+
* Pareto dominance — only when a fixed-size pick is needed after the
|
|
104
|
+
* front is identified (e.g. carrying 3 best forward to next GEPA
|
|
105
|
+
* generation).
|
|
106
|
+
*
|
|
107
|
+
* Non-finite values contribute 0 (defensive).
|
|
108
|
+
*/
|
|
109
|
+
export function scalarise(variant, objectives) {
|
|
110
|
+
let total = 0;
|
|
111
|
+
for (const obj of objectives) {
|
|
112
|
+
const v = variant[obj.key];
|
|
113
|
+
if (typeof v !== "number" || !Number.isFinite(v))
|
|
114
|
+
continue;
|
|
115
|
+
const weight = obj.weight ?? 1;
|
|
116
|
+
const directionAdjusted = obj.direction === "maximize" ? v : -v;
|
|
117
|
+
total += directionAdjusted * weight;
|
|
118
|
+
}
|
|
119
|
+
return total;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Pareto-select up to `maxKeep` variants:
|
|
123
|
+
* 1. Compute non-dominated front.
|
|
124
|
+
* 2. If front size ≤ maxKeep: return front.
|
|
125
|
+
* 3. If front size > maxKeep: sort by scalarised score (descending),
|
|
126
|
+
* keep top maxKeep.
|
|
127
|
+
*
|
|
128
|
+
* Use this when the GEPA generation budget is fixed (e.g. carry exactly
|
|
129
|
+
* 3 variants to the next round) but the Pareto front happens to be
|
|
130
|
+
* larger.
|
|
131
|
+
*/
|
|
132
|
+
export function paretoSelect(variants, objectives, maxKeep) {
|
|
133
|
+
const front = nonDominatedFront(variants, objectives);
|
|
134
|
+
if (typeof maxKeep !== "number" || front.length <= maxKeep)
|
|
135
|
+
return front;
|
|
136
|
+
return [...front]
|
|
137
|
+
.sort((a, b) => scalarise(b, objectives) - scalarise(a, objectives))
|
|
138
|
+
.slice(0, maxKeep);
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=pareto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pareto.js","sourceRoot":"","sources":["../../../src/evolution/pareto.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAwCH;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAKhC;IACJ,EAAE,GAAG,EAAE,cAAc,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE;IAC3D,EAAE,GAAG,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE;IAC3D,EAAE,GAAG,EAAE,cAAc,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE;IAC3D,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U,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAChE,KAAK,IAAI,iBAAiB,GAAG,MAAM,CAAC;IACtC,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,YAAY,CAC1B,QAA0B,EAC1B,UAA6C,EAC7C,OAAgB;IAEhB,MAAM,KAAK,GAAG,iBAAiB,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IACtD,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,IAAI,OAAO;QAAE,OAAO,KAAK,CAAC;IACzE,OAAO,CAAC,GAAG,KAAK,CAAC;SACd,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC,EAAE,UAAU,CAAC,GAAG,SAAS,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;SACnE,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Darwin — Reflective Text Feedback (Phase 2 A2, S1185 follow-up).
|
|
3
|
+
*
|
|
4
|
+
* GEPA's signature insight: instead of guiding mutation by a single
|
|
5
|
+
* scalar reward, give the optimizer rich TEXT feedback ("what went
|
|
6
|
+
* wrong, what to fix, what NOT to change") and let it synthesise the
|
|
7
|
+
* mutation from that feedback.
|
|
8
|
+
*
|
|
9
|
+
* This module is a pure TS port of the GEPA-style reflector — no
|
|
10
|
+
* Python sidecar, no hard dep on `@gepa-ai/gepa`. The reflector takes
|
|
11
|
+
* a current prompt + a set of (variant, score, trace) feedbacks and
|
|
12
|
+
* asks an injected LLM to write a SMALLEST-POSSIBLE-EDIT mutation of
|
|
13
|
+
* the current prompt that addresses the failure modes.
|
|
14
|
+
*
|
|
15
|
+
* Reference snippet from GEPA docs:
|
|
16
|
+
*
|
|
17
|
+
* "Make the smallest possible targeted edit to fix the identified
|
|
18
|
+
* failure mode. Preserve all existing correct behavior. Do not
|
|
19
|
+
* rewrite from scratch."
|
|
20
|
+
*
|
|
21
|
+
* The module is composable with the existing `PromptOptimizer` —
|
|
22
|
+
* `GepaOptimizer` (next file) coordinates Reflector + paretoSelect into
|
|
23
|
+
* a generation loop. The reflector itself is single-shot.
|
|
24
|
+
*
|
|
25
|
+
* **Inspired by, not lifted from** the official `gepa-ai/gepa` Python
|
|
26
|
+
* library. This is a pure TS port of GEPA's core ideas (Pareto-front +
|
|
27
|
+
* reflective mutation) — see `optimizer-gepa.ts` for the deliberate
|
|
28
|
+
* deviations from Algorithm 1/2 of the GEPA paper (arxiv 2507.19457).
|
|
29
|
+
* For a feature-complete GEPA experience use the upstream Python tool.
|
|
30
|
+
*
|
|
31
|
+
* **Single-LM design note (R1 Research Finding F7, S1185):** GEPA's
|
|
32
|
+
* official guidance is to use a STRONGER LM for reflection than for
|
|
33
|
+
* task execution (their `reflection_lm` parameter). This adapter
|
|
34
|
+
* intentionally accepts only one injected `RunPromptFn` to keep the
|
|
35
|
+
* V0.5 alpha surface minimal. Stronger-reflection-LM support
|
|
36
|
+
* (`reflectionRunPrompt` override) is deferred to V0.5.1 — pass a
|
|
37
|
+
* higher-tier model in your single `runPrompt` callback as a workaround.
|
|
38
|
+
*/
|
|
39
|
+
import type { ExecutionTrace } from "../types.js";
|
|
40
|
+
import type { RunPromptFn } from "./run-prompt-fn.js";
|
|
41
|
+
export type { RunPromptFn };
|
|
42
|
+
/** One variant's evaluation feedback, fed into the reflector. */
|
|
43
|
+
export interface ReflectiveFeedback {
|
|
44
|
+
/** Identifier of the variant this feedback refers to (e.g. "v3"). */
|
|
45
|
+
variantId: string;
|
|
46
|
+
/** Scalar score for at-a-glance ranking. */
|
|
47
|
+
score: number;
|
|
48
|
+
/**
|
|
49
|
+
* Rich text feedback describing what went well, what failed, and
|
|
50
|
+
* (ideally) WHY. The richer this is, the better the mutation. GEPA
|
|
51
|
+
* docs recommend including: expected vs. actual, specific issue
|
|
52
|
+
* analysis, and any provider-side error class.
|
|
53
|
+
*/
|
|
54
|
+
textFeedback: string;
|
|
55
|
+
/** Optional execution trace (A1 trajectory) for tool-level context. */
|
|
56
|
+
trace?: ExecutionTrace;
|
|
57
|
+
/** Optional: the variant's prompt text itself (helps the reflector compare). */
|
|
58
|
+
variantPrompt?: string;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Options accepted by {@link Reflector#reflect}.
|
|
62
|
+
*/
|
|
63
|
+
export interface ReflectOptions {
|
|
64
|
+
/**
|
|
65
|
+
* Override the reflection prompt template. Default is GEPA's
|
|
66
|
+
* "smallest possible targeted edit" template. Use a custom template
|
|
67
|
+
* when you want different mutation pressure (e.g. exploratory vs.
|
|
68
|
+
* conservative).
|
|
69
|
+
*/
|
|
70
|
+
reflectionPromptTemplate?: string;
|
|
71
|
+
/**
|
|
72
|
+
* Max characters of `textFeedback` included per variant. Default
|
|
73
|
+
* 2000 — keeps the meta-prompt under typical context windows even
|
|
74
|
+
* with N=5 variants.
|
|
75
|
+
*/
|
|
76
|
+
feedbackCap?: number;
|
|
77
|
+
/**
|
|
78
|
+
* Hard upper bound on the returned mutated-prompt length. Default
|
|
79
|
+
* `Math.max(currentPrompt.length * 1.3, 3500)` — same growth ceiling
|
|
80
|
+
* as `PromptOptimizer.generateVariant` for symmetry.
|
|
81
|
+
*/
|
|
82
|
+
maxMutationLength?: number;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Single-shot reflector. Wraps one LLM call that takes the current
|
|
86
|
+
* prompt + per-variant feedback and returns a mutated prompt.
|
|
87
|
+
*/
|
|
88
|
+
export declare class Reflector {
|
|
89
|
+
private readonly runPrompt;
|
|
90
|
+
constructor(runPrompt: RunPromptFn);
|
|
91
|
+
/**
|
|
92
|
+
* Build a reflection meta-prompt and ask the injected LLM for a
|
|
93
|
+
* mutated prompt. Returns the mutated prompt text (cleaned + capped).
|
|
94
|
+
*
|
|
95
|
+
* Throws `TypeError` if `currentPrompt` is empty or `feedbacks` is
|
|
96
|
+
* empty — meaningless inputs are a programmer bug, not a runtime
|
|
97
|
+
* edge.
|
|
98
|
+
*/
|
|
99
|
+
reflect(currentPrompt: string, feedbacks: ReadonlyArray<ReflectiveFeedback>, opts?: ReflectOptions): Promise<string>;
|
|
100
|
+
/** Single-feedback formatter. */
|
|
101
|
+
private formatFeedback;
|
|
102
|
+
/** Strip markdown fences and leading/trailing whitespace. */
|
|
103
|
+
private cleanOutput;
|
|
104
|
+
/** Truncate at the last sentence/newline boundary within `maxLength`. */
|
|
105
|
+
private truncateAtSentenceBoundary;
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=reflector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reflector.d.ts","sourceRoot":"","sources":["../../../src/evolution/reflector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAKtD,YAAY,EAAE,WAAW,EAAE,CAAC;AAE5B,iEAAiE;AACjE,MAAM,WAAW,kBAAkB;IACjC,qEAAqE;IACrE,SAAS,EAAE,MAAM,CAAC;IAClB,4CAA4C;IAC5C,KAAK,EAAE,MAAM,CAAC;IACd;;;;;OAKG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB,uEAAuE;IACvE,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB,gFAAgF;IAChF,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;;OAKG;IACH,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAsBD;;;GAGG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAc;gBAE5B,SAAS,EAAE,WAAW;IAOlC;;;;;;;OAOG;IACG,OAAO,CACX,aAAa,EAAE,MAAM,EACrB,SAAS,EAAE,aAAa,CAAC,kBAAkB,CAAC,EAC5C,IAAI,GAAE,cAAmB,GACxB,OAAO,CAAC,MAAM,CAAC;IA+ClB,iCAAiC;IACjC,OAAO,CAAC,cAAc;IA2BtB,6DAA6D;IAC7D,OAAO,CAAC,WAAW;IAQnB,yEAAyE;IACzE,OAAO,CAAC,0BAA0B;CAUnC"}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Darwin — Reflective Text Feedback (Phase 2 A2, S1185 follow-up).
|
|
3
|
+
*
|
|
4
|
+
* GEPA's signature insight: instead of guiding mutation by a single
|
|
5
|
+
* scalar reward, give the optimizer rich TEXT feedback ("what went
|
|
6
|
+
* wrong, what to fix, what NOT to change") and let it synthesise the
|
|
7
|
+
* mutation from that feedback.
|
|
8
|
+
*
|
|
9
|
+
* This module is a pure TS port of the GEPA-style reflector — no
|
|
10
|
+
* Python sidecar, no hard dep on `@gepa-ai/gepa`. The reflector takes
|
|
11
|
+
* a current prompt + a set of (variant, score, trace) feedbacks and
|
|
12
|
+
* asks an injected LLM to write a SMALLEST-POSSIBLE-EDIT mutation of
|
|
13
|
+
* the current prompt that addresses the failure modes.
|
|
14
|
+
*
|
|
15
|
+
* Reference snippet from GEPA docs:
|
|
16
|
+
*
|
|
17
|
+
* "Make the smallest possible targeted edit to fix the identified
|
|
18
|
+
* failure mode. Preserve all existing correct behavior. Do not
|
|
19
|
+
* rewrite from scratch."
|
|
20
|
+
*
|
|
21
|
+
* The module is composable with the existing `PromptOptimizer` —
|
|
22
|
+
* `GepaOptimizer` (next file) coordinates Reflector + paretoSelect into
|
|
23
|
+
* a generation loop. The reflector itself is single-shot.
|
|
24
|
+
*
|
|
25
|
+
* **Inspired by, not lifted from** the official `gepa-ai/gepa` Python
|
|
26
|
+
* library. This is a pure TS port of GEPA's core ideas (Pareto-front +
|
|
27
|
+
* reflective mutation) — see `optimizer-gepa.ts` for the deliberate
|
|
28
|
+
* deviations from Algorithm 1/2 of the GEPA paper (arxiv 2507.19457).
|
|
29
|
+
* For a feature-complete GEPA experience use the upstream Python tool.
|
|
30
|
+
*
|
|
31
|
+
* **Single-LM design note (R1 Research Finding F7, S1185):** GEPA's
|
|
32
|
+
* official guidance is to use a STRONGER LM for reflection than for
|
|
33
|
+
* task execution (their `reflection_lm` parameter). This adapter
|
|
34
|
+
* intentionally accepts only one injected `RunPromptFn` to keep the
|
|
35
|
+
* V0.5 alpha surface minimal. Stronger-reflection-LM support
|
|
36
|
+
* (`reflectionRunPrompt` override) is deferred to V0.5.1 — pass a
|
|
37
|
+
* higher-tier model in your single `runPrompt` callback as a workaround.
|
|
38
|
+
*/
|
|
39
|
+
const DEFAULT_FEEDBACK_CAP = 2000;
|
|
40
|
+
const DEFAULT_REFLECTION_TEMPLATE = `
|
|
41
|
+
You are a prompt-engineering reflector. Below is an instruction prompt followed by feedback from {N} variant evaluations.
|
|
42
|
+
|
|
43
|
+
CURRENT INSTRUCTION:
|
|
44
|
+
\`\`\`
|
|
45
|
+
{CURRENT_PROMPT}
|
|
46
|
+
\`\`\`
|
|
47
|
+
|
|
48
|
+
VARIANT FEEDBACKS:
|
|
49
|
+
{FEEDBACKS}
|
|
50
|
+
|
|
51
|
+
Task: produce the SMALLEST POSSIBLE TARGETED EDIT of the CURRENT INSTRUCTION that:
|
|
52
|
+
- addresses the lowest-scoring failure modes identified above,
|
|
53
|
+
- preserves all existing correct behavior (do NOT rewrite from scratch),
|
|
54
|
+
- keeps the same overall length envelope (no growth beyond ~30%).
|
|
55
|
+
|
|
56
|
+
Return ONLY the updated instruction text. No prose, no explanations, no markdown fences.
|
|
57
|
+
`.trim();
|
|
58
|
+
/**
|
|
59
|
+
* Single-shot reflector. Wraps one LLM call that takes the current
|
|
60
|
+
* prompt + per-variant feedback and returns a mutated prompt.
|
|
61
|
+
*/
|
|
62
|
+
export class Reflector {
|
|
63
|
+
runPrompt;
|
|
64
|
+
constructor(runPrompt) {
|
|
65
|
+
if (typeof runPrompt !== "function") {
|
|
66
|
+
throw new TypeError("Reflector: runPrompt must be a function");
|
|
67
|
+
}
|
|
68
|
+
this.runPrompt = runPrompt;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Build a reflection meta-prompt and ask the injected LLM for a
|
|
72
|
+
* mutated prompt. Returns the mutated prompt text (cleaned + capped).
|
|
73
|
+
*
|
|
74
|
+
* Throws `TypeError` if `currentPrompt` is empty or `feedbacks` is
|
|
75
|
+
* empty — meaningless inputs are a programmer bug, not a runtime
|
|
76
|
+
* edge.
|
|
77
|
+
*/
|
|
78
|
+
async reflect(currentPrompt, feedbacks, opts = {}) {
|
|
79
|
+
if (typeof currentPrompt !== "string" || currentPrompt.length === 0) {
|
|
80
|
+
throw new TypeError("Reflector.reflect: currentPrompt must be a non-empty string");
|
|
81
|
+
}
|
|
82
|
+
if (feedbacks.length === 0) {
|
|
83
|
+
throw new TypeError("Reflector.reflect: feedbacks must contain at least one entry");
|
|
84
|
+
}
|
|
85
|
+
const template = opts.reflectionPromptTemplate ?? DEFAULT_REFLECTION_TEMPLATE;
|
|
86
|
+
// R1 V0.5.0-alpha.2 Critic Finding H2 + R2 Critic Finding R2-C1
|
|
87
|
+
// (S1185): clamp feedbackCap to a positive finite integer.
|
|
88
|
+
// `Math.max(1, Math.floor(NaN))` is `NaN` — would silently zero
|
|
89
|
+
// every feedback (`slice(0, NaN) === ""`). Explicit `Number.isFinite`
|
|
90
|
+
// guard rejects NaN/Infinity and falls back to the default.
|
|
91
|
+
const rawCap = opts.feedbackCap ?? DEFAULT_FEEDBACK_CAP;
|
|
92
|
+
const cap = Number.isFinite(rawCap) && rawCap > 0
|
|
93
|
+
? Math.floor(rawCap)
|
|
94
|
+
: DEFAULT_FEEDBACK_CAP;
|
|
95
|
+
const feedbackBlock = feedbacks
|
|
96
|
+
.map((f, i) => this.formatFeedback(f, i + 1, cap))
|
|
97
|
+
.join("\n\n");
|
|
98
|
+
// R1 V0.5.0-alpha.2 Critic Finding H1 (S1185): substitute
|
|
99
|
+
// `{CURRENT_PROMPT}` LAST so a user prompt that happens to contain
|
|
100
|
+
// `{N}` or `{FEEDBACKS}` literally cannot trigger double-substitution.
|
|
101
|
+
// String.prototype.replace replaces only the first occurrence — by
|
|
102
|
+
// ordering the user-controlled substitution last, no template-injection
|
|
103
|
+
// path remains.
|
|
104
|
+
const metaPrompt = template
|
|
105
|
+
.replace("{N}", String(feedbacks.length))
|
|
106
|
+
.replace("{FEEDBACKS}", feedbackBlock)
|
|
107
|
+
.replace("{CURRENT_PROMPT}", currentPrompt);
|
|
108
|
+
let mutated = await this.runPrompt(metaPrompt);
|
|
109
|
+
mutated = this.cleanOutput(mutated);
|
|
110
|
+
const maxLength = opts.maxMutationLength ?? Math.max(Math.round(currentPrompt.length * 1.3), 3500);
|
|
111
|
+
if (mutated.length > maxLength) {
|
|
112
|
+
mutated = this.truncateAtSentenceBoundary(mutated, maxLength);
|
|
113
|
+
}
|
|
114
|
+
return mutated;
|
|
115
|
+
}
|
|
116
|
+
/** Single-feedback formatter. */
|
|
117
|
+
formatFeedback(fb, index, cap) {
|
|
118
|
+
const cappedText = fb.textFeedback.length > cap
|
|
119
|
+
? fb.textFeedback.slice(0, cap) + "\n[...truncated]"
|
|
120
|
+
: fb.textFeedback;
|
|
121
|
+
const lines = [
|
|
122
|
+
`=== Variant ${index} — ${fb.variantId} (score ${fb.score.toFixed(2)}) ===`,
|
|
123
|
+
`Feedback:`,
|
|
124
|
+
cappedText,
|
|
125
|
+
];
|
|
126
|
+
if (fb.trace) {
|
|
127
|
+
const toolNames = Array.from(new Set((fb.trace.toolCalls ?? []).map((c) => c.tool))).slice(0, 5);
|
|
128
|
+
if (toolNames.length > 0) {
|
|
129
|
+
lines.push(`Trace summary: ${fb.trace.turnCount} turns, ` +
|
|
130
|
+
`${fb.trace.toolCalls?.length ?? 0} tool calls (top: ${toolNames.join(", ")}), ` +
|
|
131
|
+
`${fb.trace.errors?.length ?? 0} errors.`);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return lines.join("\n");
|
|
135
|
+
}
|
|
136
|
+
/** Strip markdown fences and leading/trailing whitespace. */
|
|
137
|
+
cleanOutput(raw) {
|
|
138
|
+
let out = raw.trim();
|
|
139
|
+
// Strip ```...``` fences if the LLM ignored "no fences"
|
|
140
|
+
const fence = out.match(/^```[a-z]*\n?([\s\S]*?)\n?```$/i);
|
|
141
|
+
if (fence)
|
|
142
|
+
out = fence[1].trim();
|
|
143
|
+
return out;
|
|
144
|
+
}
|
|
145
|
+
/** Truncate at the last sentence/newline boundary within `maxLength`. */
|
|
146
|
+
truncateAtSentenceBoundary(text, maxLength) {
|
|
147
|
+
if (text.length <= maxLength)
|
|
148
|
+
return text;
|
|
149
|
+
const truncated = text.slice(0, maxLength);
|
|
150
|
+
const lastPeriod = truncated.lastIndexOf(".");
|
|
151
|
+
const lastNewline = truncated.lastIndexOf("\n");
|
|
152
|
+
const cutPoint = Math.max(lastPeriod, lastNewline);
|
|
153
|
+
return cutPoint > maxLength * 0.7
|
|
154
|
+
? truncated.slice(0, cutPoint + 1)
|
|
155
|
+
: truncated;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
//# sourceMappingURL=reflector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reflector.js","sourceRoot":"","sources":["../../../src/evolution/reflector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAsDH,MAAM,oBAAoB,GAAG,IAAI,CAAC;AAClC,MAAM,2BAA2B,GAAG;;;;;;;;;;;;;;;;;CAiBnC,CAAC,IAAI,EAAE,CAAC;AAET;;;GAG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QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;QACnD,OAAO,QAAQ,GAAG,SAAS,GAAG,GAAG;YAC/B,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,GAAG,CAAC,CAAC;YAClC,CAAC,CAAC,SAAS,CAAC;IAChB,CAAC;CACF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared type for LLM-call injection.
|
|
3
|
+
*
|
|
4
|
+
* Both `PromptOptimizer` and `Reflector` accept an injected function
|
|
5
|
+
* with this signature so the optimizer/reflector stays provider-agnostic.
|
|
6
|
+
* Extracted to its own file (S1185 R1 Analyst Finding A1) so the
|
|
7
|
+
* signature has a single source of truth — future evolution
|
|
8
|
+
* (e.g. adding an `options` param) updates one declaration, not two.
|
|
9
|
+
*/
|
|
10
|
+
export type RunPromptFn = (prompt: string) => Promise<string>;
|
|
11
|
+
//# sourceMappingURL=run-prompt-fn.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-prompt-fn.d.ts","sourceRoot":"","sources":["../../../src/evolution/run-prompt-fn.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,MAAM,MAAM,WAAW,GAAG,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared type for LLM-call injection.
|
|
3
|
+
*
|
|
4
|
+
* Both `PromptOptimizer` and `Reflector` accept an injected function
|
|
5
|
+
* with this signature so the optimizer/reflector stays provider-agnostic.
|
|
6
|
+
* Extracted to its own file (S1185 R1 Analyst Finding A1) so the
|
|
7
|
+
* signature has a single source of truth — future evolution
|
|
8
|
+
* (e.g. adding an `options` param) updates one declaration, not two.
|
|
9
|
+
*/
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=run-prompt-fn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-prompt-fn.js","sourceRoot":"","sources":["../../../src/evolution/run-prompt-fn.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG"}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -17,7 +17,9 @@
|
|
|
17
17
|
*/
|
|
18
18
|
export { defineAgent, defineConfig, loadConfig, loadConfigSync } from './core/agent.js';
|
|
19
19
|
export { runAgent } from './core/runner.js';
|
|
20
|
-
export
|
|
20
|
+
export { createTraceCapture } from './core/trace-capture.js';
|
|
21
|
+
export type { TraceCapture, TraceCaptureOptions } from './core/trace-capture.js';
|
|
22
|
+
export type { AgentDefinition, DarwinConfig, DarwinExperiment, DarwinMetrics, DarwinPattern, DarwinState, ExecutionTrace, ExperimentFeedback, EvolutionConfig, Learning, McpServerConfig, MemoryProvider, MetricWeights, PromptVersion, PromptVersionStats, RunResult, SafetyThresholds, TraceToolCall, TraceTokenUsage, TraceTurnError, } from './types.js';
|
|
21
23
|
export { DEFAULT_WEIGHTS, DEFAULT_SAFETY } from './types.js';
|
|
22
24
|
export { writer, researcher, critic, analyst, builtinAgents } from './agents/index.js';
|
|
23
25
|
export { createProvider } from './providers/index.js';
|
|
@@ -29,4 +31,8 @@ export { ClaudeCliProvider } from './providers/claude-cli.js';
|
|
|
29
31
|
export { createMemory, SqliteMemoryProvider, PostgresMemoryProvider } from './memory/index.js';
|
|
30
32
|
export { loadNotificationConfig } from './evolution/notifications.js';
|
|
31
33
|
export type { NotificationConfig } from './evolution/notifications.js';
|
|
34
|
+
export { dominates, nonDominatedFront, paretoSelect, scalarise, DARWIN_DEFAULT_OBJECTIVES, type ParetoObjective, } from './evolution/pareto.js';
|
|
35
|
+
export { Reflector, type ReflectiveFeedback, type ReflectOptions, } from './evolution/reflector.js';
|
|
36
|
+
export type { RunPromptFn } from './evolution/run-prompt-fn.js';
|
|
37
|
+
export { GepaOptimizer, type ScoredVariant, type GenerateOptions as GepaGenerateOptions, type NextGenerationOptions as GepaNextGenerationOptions, } from './evolution/optimizer-gepa.js';
|
|
32
38
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACxF,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAG5C,YAAY,EACV,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,QAAQ,EACR,eAAe,EACf,cAAc,EACd,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,SAAS,EACT,gBAAgB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACxF,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAG5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,YAAY,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAGjF,YAAY,EACV,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,WAAW,EACX,cAAc,EACd,kBAAkB,EAClB,eAAe,EACf,QAAQ,EACR,eAAe,EACf,cAAc,EACd,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,SAAS,EACT,gBAAgB,EAChB,aAAa,EACb,eAAe,EACf,cAAc,GACf,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAG7D,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGvF,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACvG,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAG9D,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAG/F,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AACtE,YAAY,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAGvE,OAAO,EACL,SAAS,EACT,iBAAiB,EACjB,YAAY,EACZ,SAAS,EACT,yBAAyB,EACzB,KAAK,eAAe,GACrB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,SAAS,EACT,KAAK,kBAAkB,EACvB,KAAK,cAAc,GACpB,MAAM,0BAA0B,CAAC;AAClC,YAAY,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EACL,aAAa,EACb,KAAK,aAAa,EAClB,KAAK,eAAe,IAAI,mBAAmB,EAC3C,KAAK,qBAAqB,IAAI,yBAAyB,GACxD,MAAM,+BAA+B,CAAC"}
|
package/dist/src/index.js
CHANGED
|
@@ -18,6 +18,8 @@
|
|
|
18
18
|
// Core API
|
|
19
19
|
export { defineAgent, defineConfig, loadConfig, loadConfigSync } from './core/agent.js';
|
|
20
20
|
export { runAgent } from './core/runner.js';
|
|
21
|
+
// V0.5.0-alpha.1 — Execution Trace Capture (S1184 Phase 2 A1)
|
|
22
|
+
export { createTraceCapture } from './core/trace-capture.js';
|
|
21
23
|
// Constants
|
|
22
24
|
export { DEFAULT_WEIGHTS, DEFAULT_SAFETY } from './types.js';
|
|
23
25
|
// Built-in Agents
|
|
@@ -32,4 +34,8 @@ export { ClaudeCliProvider } from './providers/claude-cli.js';
|
|
|
32
34
|
export { createMemory, SqliteMemoryProvider, PostgresMemoryProvider } from './memory/index.js';
|
|
33
35
|
// Notifications
|
|
34
36
|
export { loadNotificationConfig } from './evolution/notifications.js';
|
|
37
|
+
// V0.5.0-alpha.2 — GEPA-Style Reflective Optimizer (S1185 Phase 2 A2)
|
|
38
|
+
export { dominates, nonDominatedFront, paretoSelect, scalarise, DARWIN_DEFAULT_OBJECTIVES, } from './evolution/pareto.js';
|
|
39
|
+
export { Reflector, } from './evolution/reflector.js';
|
|
40
|
+
export { GepaOptimizer, } from './evolution/optimizer-gepa.js';
|
|
35
41
|
//# sourceMappingURL=index.js.map
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,WAAW;AACX,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACxF,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,WAAW;AACX,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACxF,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,8DAA8D;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AA2B7D,YAAY;AACZ,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE7D,kBAAkB;AAClB,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvF,YAAY;AACZ,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAE9D,SAAS;AACT,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAE/F,gBAAgB;AAChB,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAGtE,sEAAsE;AACtE,OAAO,EACL,SAAS,EACT,iBAAiB,EACjB,YAAY,EACZ,SAAS,EACT,yBAAyB,GAE1B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,SAAS,GAGV,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,aAAa,GAId,MAAM,+BAA+B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postgres-memory.d.ts","sourceRoot":"","sources":["../../../src/memory/postgres-memory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAMH,OAAO,KAAK,EACV,gBAAgB,EAChB,WAAW,
|
|
1
|
+
{"version":3,"file":"postgres-memory.d.ts","sourceRoot":"","sources":["../../../src/memory/postgres-memory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAMH,OAAO,KAAK,EACV,gBAAgB,EAChB,WAAW,EAEX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