darwin-langgraph 0.1.0-alpha.1

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.
@@ -0,0 +1,256 @@
1
+ /**
2
+ * Surface 3 — `withDarwinEvolution(graph, opts)`.
3
+ *
4
+ * Wraps a compiled `StateGraph` with a fire-and-forget post-run hook
5
+ * that mirrors Darwin's closed-loop evolution pattern (see
6
+ * `agents/lib/darwin-hook.ts` for the in-tree Nex implementation):
7
+ *
8
+ * 1. After `graph.invoke(...)` resolves, we extract trajectories from
9
+ * the final state and dispatch them to `opts.onTrajectory` per
10
+ * mapped node.
11
+ * 2. The same applies to `graph.stream(...)` — we wrap the async
12
+ * iterator and replay the final-state chunk to the hook once the
13
+ * consumer finishes iterating.
14
+ *
15
+ * Design notes (S1185):
16
+ * - **Never throws inside the hook.** Caller logic that fails inside
17
+ * `onTrajectory` is logged once per process and otherwise swallowed.
18
+ * The graph result the consumer sees is identical with or without
19
+ * the wrap.
20
+ * - **No mutation of `graph` if it doesn't expose `invoke`/`stream`
21
+ * as own properties.** We bind via `Object.defineProperty` and fall
22
+ * back to a no-op wrap if the graph is frozen. This means future
23
+ * LangGraph internals that move `invoke` to a hidden prototype slot
24
+ * won't crash — at worst, the hook silently never fires (the test
25
+ * suite catches that case).
26
+ * - **`nodeMap` shape:** either `string` (treated as
27
+ * `{ agentName: string, trajectoryKey: defaultKey }`) or an object
28
+ * with explicit `trajectoryKey`. Supports both ergonomic one-liner
29
+ * and per-node trajectory routing in the same graph.
30
+ */
31
+ import { DarwinEvolutionHookError } from "./errors.js";
32
+ /**
33
+ * Wraps a compiled LangGraph so the supplied `onTrajectory` callback
34
+ * fires for each node listed in `nodeMap` after every `invoke` / `stream`
35
+ * run. Returns the same graph instance for chaining.
36
+ *
37
+ * @throws {DarwinEvolutionHookError} when `nodeMap` is empty or missing.
38
+ */
39
+ export function withDarwinEvolution(graph, opts) {
40
+ if (!opts || !opts.nodeMap || Object.keys(opts.nodeMap).length === 0) {
41
+ throw new DarwinEvolutionHookError("withDarwinEvolution: opts.nodeMap is required and must contain at least one entry.");
42
+ }
43
+ const defaultKey = opts.defaultTrajectoryKey ?? "darwinTrajectory";
44
+ const callback = opts.onTrajectory;
45
+ // Normalise nodeMap once. Each entry knows its trajectoryKey so the
46
+ // hot path doesn't re-resolve defaults per invocation.
47
+ const resolved = new Map();
48
+ for (const [nodeName, entry] of Object.entries(opts.nodeMap)) {
49
+ if (typeof entry === "string") {
50
+ resolved.set(nodeName, { agentName: entry, trajectoryKey: defaultKey });
51
+ }
52
+ else if (entry !== null &&
53
+ typeof entry === "object" &&
54
+ typeof entry.agentName === "string" &&
55
+ typeof entry.trajectoryKey === "string") {
56
+ resolved.set(nodeName, {
57
+ agentName: entry.agentName,
58
+ trajectoryKey: entry.trajectoryKey,
59
+ });
60
+ }
61
+ else {
62
+ throw new DarwinEvolutionHookError(`withDarwinEvolution: nodeMap entry for "${nodeName}" must be a string or ` +
63
+ `{ agentName, trajectoryKey }, got ${typeof entry}.`);
64
+ }
65
+ }
66
+ let warned = false;
67
+ const swallow = (err) => {
68
+ if (warned || !err)
69
+ return;
70
+ warned = true;
71
+ console.warn(`[darwin-langgraph] onTrajectory callback threw — swallowed. ` +
72
+ `Subsequent throws will be silent. Original error: ` +
73
+ `${err?.message ?? String(err)}`);
74
+ };
75
+ const fireHook = async (finalState) => {
76
+ if (!callback)
77
+ return;
78
+ if (finalState === null || typeof finalState !== "object")
79
+ return;
80
+ const stateObj = finalState;
81
+ const frozen = Object.freeze({ ...stateObj });
82
+ for (const [nodeName, { agentName, trajectoryKey }] of resolved) {
83
+ const trajectory = stateObj[trajectoryKey];
84
+ if (!trajectory || typeof trajectory !== "object" || trajectory.version !== 1) {
85
+ continue;
86
+ }
87
+ try {
88
+ await callback({
89
+ nodeName,
90
+ agentName,
91
+ trajectory,
92
+ finalState: frozen,
93
+ });
94
+ }
95
+ catch (err) {
96
+ swallow(err);
97
+ }
98
+ }
99
+ };
100
+ // Bind originals once. We keep references so consumer re-binds via
101
+ // a second `withDarwinEvolution` call still work (the second wrap
102
+ // chains on top of the first wrap's wrapped methods).
103
+ const originalInvoke = graph.invoke.bind(graph);
104
+ const originalStream = graph.stream.bind(graph);
105
+ /**
106
+ * `graph.invoke` is internally implemented on top of `graph.stream` in
107
+ * `@langchain/langgraph@1.x`. If we naively wrap both, every `invoke`
108
+ * call fires the hook TWICE — once from the wrapped stream that invoke
109
+ * consumed, once from the wrapped invoke itself. We tag each in-flight
110
+ * `invoke` with a unique `Symbol` stored in a `Set` and the wrapped
111
+ * `stream` checks `set.size > 0` to know it was called from inside an
112
+ * invoke (in which case the outer invoke handles the hook).
113
+ *
114
+ * R1 Critic Finding 1 fix (S1185): replaced the prior shared-counter
115
+ * with a `Set<symbol>`. JS is single-threaded, so `Set.add` followed by
116
+ * `Set.size` in another microtask cannot interleave at the byte level
117
+ * — concurrent invokes both increment the set BEFORE either stream sees
118
+ * `size > 0`, so both streams correctly suppress and both invokes
119
+ * correctly fire the hook exactly once each. The prior `let
120
+ * invokesInFlight = 0` had a race window where two concurrent invokes
121
+ * could both read `0` and both fire from invoke AND stream.
122
+ */
123
+ const activeInvokeMarkers = new Set();
124
+ const wrappedInvoke = async (input, config) => {
125
+ const marker = Symbol("darwin-langgraph:invoke");
126
+ activeInvokeMarkers.add(marker);
127
+ try {
128
+ const result = await originalInvoke(input, config);
129
+ // Fire-and-forget — don't await the hook from the caller's perspective.
130
+ void fireHook(result).catch(swallow);
131
+ return result;
132
+ }
133
+ finally {
134
+ activeInvokeMarkers.delete(marker);
135
+ }
136
+ };
137
+ /**
138
+ * R1 Critic Finding 2 fix (S1185): warn once if the consumer calls
139
+ * `stream()` with a `streamMode` other than `"values"`. The hook is
140
+ * shape-tolerant but for `"updates"` / `"messages"` modes the last
141
+ * chunk is a node-update dict, NOT the final state — the trajectory
142
+ * lookup silently misses. Users hit this constantly because
143
+ * `streamMode: "updates"` is the implicit default.
144
+ */
145
+ let streamModeWarned = false;
146
+ const warnStreamMode = (mode) => {
147
+ if (streamModeWarned)
148
+ return;
149
+ streamModeWarned = true;
150
+ console.warn(`[darwin-langgraph] withDarwinEvolution: stream() called with streamMode=` +
151
+ `${typeof mode === "string" ? `"${mode}"` : String(mode)}. ` +
152
+ `The trajectory hook reliably fires only when streamMode="values" ` +
153
+ `(default for invoke()). For "updates"/"messages"/multi-mode streams, ` +
154
+ `the last chunk is not the final state and the hook may silently skip. ` +
155
+ `Subsequent calls will be silent.`);
156
+ };
157
+ const wrappedStream = async (input, config) => {
158
+ // R2 Critic Finding R2-3: compute `suppressHook` BEFORE awaiting
159
+ // `originalStream` to make the ordering guarantee explicit.
160
+ //
161
+ // Ordering invariant: `wrappedInvoke` calls `activeInvokeMarkers.add()`
162
+ // SYNCHRONOUSLY before its `await originalInvoke()` yields. Inside
163
+ // `originalInvoke`, LangGraph calls the UNWRAPPED `graph.stream`
164
+ // (which our wrapper's `originalStream.bind(graph)` points to), so
165
+ // this wrapper IS NOT re-entered from invoke's stream call. The only
166
+ // way control reaches `wrappedStream` is via a direct user call to
167
+ // `graph.stream()`. The Set check therefore correctly tells us:
168
+ // "is some OTHER invoke currently in-flight?". If yes, this stream
169
+ // is parallel work whose hook the invoke side will handle — suppress.
170
+ // If no, this is a top-level stream call — fire the hook ourselves.
171
+ const suppressHook = activeInvokeMarkers.size > 0;
172
+ const iter = await originalStream(input, config);
173
+ if (suppressHook) {
174
+ return iter;
175
+ }
176
+ // R1 Critic Finding 2: warn if caller asked for a non-"values" stream
177
+ // mode so the silent-skip case at least surfaces in logs.
178
+ if (config !== null &&
179
+ typeof config === "object" &&
180
+ "streamMode" in config) {
181
+ const mode = config.streamMode;
182
+ if (mode !== "values" && !(Array.isArray(mode) && mode.includes("values"))) {
183
+ warnStreamMode(mode);
184
+ }
185
+ }
186
+ // Wrap the async iterator so we can capture the final chunk for the hook.
187
+ let lastChunk = undefined;
188
+ let hookFired = false;
189
+ const fireOnce = (chunk) => {
190
+ if (hookFired)
191
+ return;
192
+ hookFired = true;
193
+ void fireHook(chunk).catch(swallow);
194
+ };
195
+ const wrapped = {
196
+ [Symbol.asyncIterator]() {
197
+ const inner = iter[Symbol.asyncIterator]();
198
+ return {
199
+ async next() {
200
+ const res = await inner.next();
201
+ if (res.done) {
202
+ // Fire hook with the last chunk we saw. For `streamMode: "values"`
203
+ // the last chunk IS the final state. For other modes it may be
204
+ // a node-update — the hook tolerates both via shape sniffing.
205
+ fireOnce(lastChunk);
206
+ }
207
+ else {
208
+ lastChunk = res.value;
209
+ }
210
+ return res;
211
+ },
212
+ async return(value) {
213
+ // Consumer broke early — still fire the hook with what we have.
214
+ fireOnce(lastChunk);
215
+ if (typeof inner.return === "function") {
216
+ return inner.return(value);
217
+ }
218
+ return { value: undefined, done: true };
219
+ },
220
+ async throw(err) {
221
+ // No hook on throw — graph state is by definition incomplete.
222
+ if (typeof inner.throw === "function") {
223
+ return inner.throw(err);
224
+ }
225
+ throw err;
226
+ },
227
+ };
228
+ },
229
+ };
230
+ return wrapped;
231
+ };
232
+ // Try to overwrite as own properties. If the graph is frozen, fall
233
+ // back to wrapping the prototype-bound methods (best-effort, but
234
+ // tests will catch any regression).
235
+ try {
236
+ Object.defineProperty(graph, "invoke", {
237
+ value: wrappedInvoke,
238
+ writable: true,
239
+ configurable: true,
240
+ enumerable: false,
241
+ });
242
+ Object.defineProperty(graph, "stream", {
243
+ value: wrappedStream,
244
+ writable: true,
245
+ configurable: true,
246
+ enumerable: false,
247
+ });
248
+ }
249
+ catch (err) {
250
+ throw new DarwinEvolutionHookError("withDarwinEvolution: could not wrap graph.invoke / graph.stream " +
251
+ "(graph instance is frozen or non-configurable). Consider wrapping the " +
252
+ "graph at compile time instead.", { cause: err });
253
+ }
254
+ return graph;
255
+ }
256
+ //# sourceMappingURL=with-darwin-evolution.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with-darwin-evolution.js","sourceRoot":"","sources":["../src/with-darwin-evolution.ts"],"names":[],"mappings":"A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AE,IAAI;YACd,YAAY,EAAE,IAAI;YAClB,UAAU,EAAE,KAAK;SAClB,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,IAAI,wBAAwB,CAChC,kEAAkE;YAChE,wEAAwE;YACxE,gCAAgC,EAClC,EAAE,KAAK,EAAE,GAAG,EAAE,CACf,CAAC;IACJ,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
package/package.json ADDED
@@ -0,0 +1,79 @@
1
+ {
2
+ "name": "darwin-langgraph",
3
+ "version": "0.1.0-alpha.1",
4
+ "description": "LangGraph.js adapter for darwin-agents — wrap self-evolving Darwin agents as StateGraph nodes with zero hard deps.",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.js",
11
+ "types": "./dist/index.d.ts"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "README.md",
17
+ "CHANGELOG.md",
18
+ "LICENSE"
19
+ ],
20
+ "scripts": {
21
+ "build": "tsc",
22
+ "test": "vitest run",
23
+ "test:watch": "vitest",
24
+ "typecheck": "tsc --noEmit",
25
+ "examples:check": "tsc --noEmit --project tsconfig.examples.json",
26
+ "verify:version-sync": "node -e \"const p=JSON.parse(require('fs').readFileSync('./package.json','utf8'));const s=require('fs').readFileSync('./src/index.ts','utf8');const m=s.match(/VERSION = \\\"([^\\\"]+)\\\"/);if(!m){console.error('VERSION not found in src/index.ts');process.exit(1)}if(m[1]!==p.version){console.error('VERSION mismatch: package.json='+p.version+', src/index.ts='+m[1]);process.exit(1)}console.log('VERSION sync OK: '+m[1])\"",
27
+ "prepublishOnly": "npm run verify:version-sync && npm run typecheck && npm run test && npm run build"
28
+ },
29
+ "keywords": [
30
+ "langgraph",
31
+ "langchain",
32
+ "darwin-agents",
33
+ "ai-agents",
34
+ "agent-orchestration",
35
+ "self-evolving-agents",
36
+ "stategraph",
37
+ "multi-agent",
38
+ "ab-testing",
39
+ "trajectory-capture",
40
+ "gepa"
41
+ ],
42
+ "author": "StudioMeyer <hello@studiomeyer.io>",
43
+ "license": "MIT",
44
+ "repository": {
45
+ "type": "git",
46
+ "url": "git+https://github.com/studiomeyer-io/darwin-langgraph.git"
47
+ },
48
+ "bugs": {
49
+ "url": "https://github.com/studiomeyer-io/darwin-langgraph/issues"
50
+ },
51
+ "homepage": "https://github.com/studiomeyer-io/darwin-langgraph#readme",
52
+ "peerDependencies": {
53
+ "@langchain/langgraph": "^1.3.0",
54
+ "darwin-agents": "^0.5.0-alpha.1"
55
+ },
56
+ "peerDependenciesMeta": {
57
+ "@langchain/langgraph": {
58
+ "optional": false
59
+ },
60
+ "darwin-agents": {
61
+ "optional": false
62
+ }
63
+ },
64
+ "devDependencies": {
65
+ "@langchain/langgraph": "^1.3.2",
66
+ "@types/node": "^22.10.0",
67
+ "darwin-agents": "^0.5.0-alpha.1",
68
+ "tsx": "^4.19.0",
69
+ "typescript": "^5.6.0",
70
+ "vitest": "^2.1.0"
71
+ },
72
+ "engines": {
73
+ "node": ">=20"
74
+ },
75
+ "publishConfig": {
76
+ "access": "public",
77
+ "tag": "alpha"
78
+ }
79
+ }