darwin-langgraph 0.2.0-alpha.1 → 0.3.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.
- package/CHANGELOG.md +105 -0
- package/README.md +90 -2
- package/dist/darwin-callback-handler.d.ts +31 -2
- package/dist/darwin-callback-handler.d.ts.map +1 -1
- package/dist/darwin-callback-handler.js +57 -7
- package/dist/darwin-callback-handler.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/with-darwin-evolution.d.ts +24 -0
- package/dist/with-darwin-evolution.d.ts.map +1 -1
- package/dist/with-darwin-evolution.js +46 -0
- package/dist/with-darwin-evolution.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,111 @@
|
|
|
3
3
|
All notable changes to `darwin-langgraph` are documented here.
|
|
4
4
|
The project adheres to [Semantic Versioning](https://semver.org/).
|
|
5
5
|
|
|
6
|
+
## [0.3.0-alpha.1] — 2026-05-25
|
|
7
|
+
|
|
8
|
+
V0.3 closes the three deferred items from V0.2's R2 review (parent-run
|
|
9
|
+
propagation, double-wrap detection, hung-invoke guard) and lifts the
|
|
10
|
+
repository to the StudioMeyer open-source-standard documentation layout
|
|
11
|
+
(CONTRIBUTING, CODE_OF_CONDUCT, SECURITY, ECOSYSTEM, issue + PR
|
|
12
|
+
templates, GitHub Actions CI matrix on Node 20 + 22).
|
|
13
|
+
|
|
14
|
+
### Added — three new behaviours + one new option
|
|
15
|
+
|
|
16
|
+
- **`DarwinTrajectoryEvent.runId` + `.parentRunId`** — propagated by
|
|
17
|
+
`DarwinCallbackHandler` from the LangChain callback contract. Lets
|
|
18
|
+
downstream consumers (OTEL exporters, Langfuse, LangSmith, custom
|
|
19
|
+
span-tree loggers) rebuild the chain hierarchy from the event payload
|
|
20
|
+
alone without a separate runId-tracking side-channel. `runId` is
|
|
21
|
+
always present on V0.2+ handler events; `parentRunId` is present
|
|
22
|
+
only when the chain has a parent (omitted for top-level invokes).
|
|
23
|
+
- **`withDarwinEvolution` double-wrap warning** — a `Symbol.for(...)`
|
|
24
|
+
sentinel is stamped on each wrapped graph. A second wrap of the same
|
|
25
|
+
graph instance now emits a one-shot `console.warn` flagging the
|
|
26
|
+
duplicate-hook footgun. The wrap still succeeds (some users legitimately
|
|
27
|
+
layer multiple `nodeMap` slices), but the silent-double-fire case
|
|
28
|
+
is now visible in logs.
|
|
29
|
+
- **`DarwinCallbackHandler` hung-invoke guard** — new option
|
|
30
|
+
`maxInFlightRuns?: number` on `DarwinCallbackHandlerOptions`. Caps the
|
|
31
|
+
internal `runId → InFlightRun` map. When the cap is exceeded the
|
|
32
|
+
oldest entry is evicted (LRU via Map insertion order) and a
|
|
33
|
+
one-shot warning fires. Defaults to 1024 — small enough to surface
|
|
34
|
+
real leaks within minutes, large enough for typical fan-out. Set to
|
|
35
|
+
`Infinity` to opt out.
|
|
36
|
+
|
|
37
|
+
### Changed
|
|
38
|
+
|
|
39
|
+
- **`DarwinCallbackHandlerOptions` type exported** alongside
|
|
40
|
+
`DarwinCallbackHandler`. Was internal in V0.2; now a public type so
|
|
41
|
+
consumers can build wrapper handlers without re-declaring the shape.
|
|
42
|
+
- **`InFlightRun` shape** — internal change in `DarwinCallbackHandler`:
|
|
43
|
+
the `runIdToName` map now stores `{ nodeName, parentRunId }` rather
|
|
44
|
+
than just the name string, to carry parentRunId through to
|
|
45
|
+
`handleChainEnd`. Non-breaking — only the internal field type changed.
|
|
46
|
+
- **VERSION constant bumped** to `0.3.0-alpha.1` in both `package.json`
|
|
47
|
+
and `src/index.ts` (verified by `prepublishOnly` script).
|
|
48
|
+
|
|
49
|
+
### Added — open-source documentation standard
|
|
50
|
+
|
|
51
|
+
The repo now matches the
|
|
52
|
+
[`temporal-memory-workflows`](https://github.com/studiomeyer-io/temporal-memory-workflows)
|
|
53
|
+
OS-standard layout. New top-level files:
|
|
54
|
+
|
|
55
|
+
- **`CONTRIBUTING.md`** — folder layout, code-review expectations, PR
|
|
56
|
+
format, Conventional Commits convention, deprecation contract on
|
|
57
|
+
`withDarwinEvolution`, adapter-vs-upstream-bugs separation.
|
|
58
|
+
- **`CODE_OF_CONDUCT.md`** — adapted from Contributor Covenant 2.1.
|
|
59
|
+
- **`SECURITY.md`** — disclosure policy, supported versions
|
|
60
|
+
(`0.3.x` + `0.2.x` security-only), supply-chain stance (no
|
|
61
|
+
postinstall scripts), defense-in-depth layer breakdown.
|
|
62
|
+
- **`ECOSYSTEM.md`** — where the adapter sits in the StudioMeyer
|
|
63
|
+
toolkit, pairing notes with `darwin-agents` /
|
|
64
|
+
`@langchain/langgraph` / `temporal-memory-workflows`, when-to-use-what
|
|
65
|
+
decision table, sibling-repo links.
|
|
66
|
+
- **`.github/ISSUE_TEMPLATE/{bug_report,feature_request,config}.yml`**
|
|
67
|
+
— surface-aware bug template, problem-first feature template, contact
|
|
68
|
+
links routing to upstream where appropriate.
|
|
69
|
+
- **`.github/PULL_REQUEST_TEMPLATE.md`** — surface checklist,
|
|
70
|
+
zero-hard-dep check, deprecation-contract check, R1/R2 code-review
|
|
71
|
+
trail field for maintainers.
|
|
72
|
+
- **`.github/workflows/ci.yml`** — Node 20 + 22 matrix, runs
|
|
73
|
+
`npm ci` → `verify-version-sync` → `typecheck` → `examples:check` →
|
|
74
|
+
`test` → `build` on every push to `main` and every PR.
|
|
75
|
+
|
|
76
|
+
### Test coverage
|
|
77
|
+
|
|
78
|
+
- **132/132 vitest tests green** (was 116 in V0.2, **+16 V0.3 tests**).
|
|
79
|
+
- New test file: `tests/v03-features.test.ts` (16 tests across 4 groups:
|
|
80
|
+
parent-run propagation, double-wrap warning, hung-invoke timeout
|
|
81
|
+
guard, `vi.resetModules()` pattern for module-level flag tests).
|
|
82
|
+
- tsc strict + examples typecheck + version-sync + build all clean.
|
|
83
|
+
- No regressions: all V0.1 + V0.2 surface tests + R1 + R2 fixes still
|
|
84
|
+
green.
|
|
85
|
+
|
|
86
|
+
### Migration notes
|
|
87
|
+
|
|
88
|
+
- **From V0.2.x → V0.3.x:** No code changes required. The
|
|
89
|
+
`runId`/`parentRunId` fields on `DarwinTrajectoryEvent` are optional
|
|
90
|
+
additions; existing callbacks ignore them. The double-wrap warning
|
|
91
|
+
only fires if you actually double-wrap (most users do not). The
|
|
92
|
+
default `maxInFlightRuns: 1024` cap is invisible in normal use.
|
|
93
|
+
- **From V0.1.x → V0.3.x:** Still recommended to migrate from
|
|
94
|
+
`withDarwinEvolution` to `DarwinCallbackHandler` — see V0.2
|
|
95
|
+
migration notes in this changelog.
|
|
96
|
+
|
|
97
|
+
### V0.4 Roadmap (deferred)
|
|
98
|
+
|
|
99
|
+
- **`reflectionRunPrompt` override on `darwin-agents` (paper-fidelity).**
|
|
100
|
+
The GEPA paper uses a stronger reflection LM than the task LM. Currently
|
|
101
|
+
the adapter inherits `darwin-agents@0.5.0-alpha.2`'s single-`runPrompt`
|
|
102
|
+
implementation. Defer to a paired bump.
|
|
103
|
+
- **OTEL exporter binding helper** — turn the pure `toOtelAttributes`
|
|
104
|
+
mapping into a one-liner that registers a span per trajectory with
|
|
105
|
+
a configured tracer.
|
|
106
|
+
- **Langfuse handler subclass** — `DarwinLangfuseHandler` that extends
|
|
107
|
+
`DarwinCallbackHandler` and emits Langfuse traces directly.
|
|
108
|
+
- **LangSmith trace correlation** — propagate `runId`/`parentRunId`
|
|
109
|
+
into a LangSmith-compatible attribute set.
|
|
110
|
+
|
|
6
111
|
## [0.2.0-alpha.1] — 2026-05-25
|
|
7
112
|
|
|
8
113
|
### Added — three new surfaces (V0.1 roadmap → LIVE)
|
package/README.md
CHANGED
|
@@ -202,7 +202,8 @@ The [`examples/`](./examples/) directory ships three runnable scripts:
|
|
|
202
202
|
|
|
203
203
|
| `darwin-langgraph` | `darwin-agents` | `@langchain/langgraph` | Status |
|
|
204
204
|
|---|---|---|---|
|
|
205
|
-
| `0.
|
|
205
|
+
| `0.3.0-alpha.x` | `^0.5.0-alpha.1` | `^1.3.0` | alpha (this release) |
|
|
206
|
+
| `0.2.0-alpha.x` | `^0.5.0-alpha.1` | `^1.3.0` | superseded |
|
|
206
207
|
| `0.1.0-alpha.x` | `^0.5.0-alpha.1` | `^1.3.0` | superseded |
|
|
207
208
|
|
|
208
209
|
The peer-dep range `darwin-agents: "^0.5.0-alpha.1"` follows npm's
|
|
@@ -210,7 +211,83 @@ prerelease semver rules — `0.5.0-alpha.N` and `0.5.0` final satisfy it,
|
|
|
210
211
|
but `0.5.1-alpha.0` does NOT. A patch release of this adapter will be
|
|
211
212
|
required when `darwin-agents` bumps past `0.5.x`.
|
|
212
213
|
|
|
213
|
-
## V0.
|
|
214
|
+
## V0.3 — observability + safety (LIVE this release)
|
|
215
|
+
|
|
216
|
+
V0.3 closes the three deferred items from V0.2's R2 review. Backwards
|
|
217
|
+
compatible — no consumer code changes required.
|
|
218
|
+
|
|
219
|
+
### Parent-run propagation on `DarwinTrajectoryEvent`
|
|
220
|
+
|
|
221
|
+
`DarwinCallbackHandler` now populates two new fields on every emitted
|
|
222
|
+
event:
|
|
223
|
+
|
|
224
|
+
- **`runId: string`** — the LangChain runId of the node-chain that
|
|
225
|
+
produced the trajectory. Stable identifier suitable for correlation
|
|
226
|
+
with OTEL spans, Langfuse traces, LangSmith runs.
|
|
227
|
+
- **`parentRunId?: string`** — the runId of the chain that invoked
|
|
228
|
+
this node-chain. Omitted for top-level invokes. Use it to build the
|
|
229
|
+
full span hierarchy in OTEL exporters.
|
|
230
|
+
|
|
231
|
+
```ts
|
|
232
|
+
const handler = new DarwinCallbackHandler({
|
|
233
|
+
nodeMap: { research: "researcher" },
|
|
234
|
+
onTrajectory: (event) => {
|
|
235
|
+
const attrs = toOtelAttributes(event.trajectory);
|
|
236
|
+
const span = tracer.startSpan(event.nodeName, {
|
|
237
|
+
attributes: { ...attrs, "darwin.run.id": event.runId },
|
|
238
|
+
});
|
|
239
|
+
// event.parentRunId can be used as the parent context for span linking
|
|
240
|
+
span.end();
|
|
241
|
+
},
|
|
242
|
+
});
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
`withDarwinEvolution` legacy events do NOT carry the runId fields (no
|
|
246
|
+
runId exists in the monkey-patch path). Migrate to
|
|
247
|
+
`DarwinCallbackHandler` if you need them.
|
|
248
|
+
|
|
249
|
+
### Double-wrap warning on `withDarwinEvolution`
|
|
250
|
+
|
|
251
|
+
A `Symbol.for("darwin-langgraph.evolution.wrapped")` sentinel is now
|
|
252
|
+
stamped on each wrapped graph. A second `withDarwinEvolution(graph, …)`
|
|
253
|
+
call on the same graph instance emits a one-shot `console.warn`:
|
|
254
|
+
|
|
255
|
+
```
|
|
256
|
+
[darwin-langgraph] withDarwinEvolution(): graph appears to be wrapped twice
|
|
257
|
+
— both hooks will fire per run, producing duplicate trajectories.
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
Some users legitimately layer multiple `nodeMap` slices on one graph,
|
|
261
|
+
so the wrap still succeeds — but the silent-double-fire footgun is now
|
|
262
|
+
visible in logs. To layer cleanly, prefer multiple
|
|
263
|
+
`DarwinCallbackHandler` instances via `callbacks: [h1, h2]`.
|
|
264
|
+
|
|
265
|
+
### Hung-invoke guard on `DarwinCallbackHandler`
|
|
266
|
+
|
|
267
|
+
New option `maxInFlightRuns?: number` on
|
|
268
|
+
`DarwinCallbackHandlerOptions`. Caps the internal `runId → InFlightRun`
|
|
269
|
+
map at the configured size. When the cap is exceeded, the oldest
|
|
270
|
+
entry is evicted (Map insertion order) and a one-shot warning fires.
|
|
271
|
+
Defaults to **1024** — large enough for typical fan-out, small enough
|
|
272
|
+
to surface a real leak within minutes of an incident.
|
|
273
|
+
|
|
274
|
+
```ts
|
|
275
|
+
const handler = new DarwinCallbackHandler({
|
|
276
|
+
nodeMap: { research: "researcher" },
|
|
277
|
+
onTrajectory: (event) => { /* ... */ },
|
|
278
|
+
maxInFlightRuns: 500, // tighter for memory-constrained workers
|
|
279
|
+
});
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
Set `maxInFlightRuns: Infinity` to opt out (discouraged in production).
|
|
283
|
+
|
|
284
|
+
This defends against the failure mode where `handleChainEnd` /
|
|
285
|
+
`handleChainError` never fires (LangGraph internal bug, OS-level kill
|
|
286
|
+
of the worker mid-invoke, parent invoke aborted mid-flight). Without
|
|
287
|
+
the cap, the map grows without bound and leaks memory in long-running
|
|
288
|
+
processes (server singletons, schedulers, Temporal Workers).
|
|
289
|
+
|
|
290
|
+
### V0.2 — new surfaces (still LIVE)
|
|
214
291
|
|
|
215
292
|
V0.2 ships the three items from the V0.1 V0.2-roadmap, plus runtime
|
|
216
293
|
deprecation warnings on the legacy wrapper:
|
|
@@ -256,6 +333,17 @@ Two lines:
|
|
|
256
333
|
`DarwinTrajectoryEvent` shape passed to `onTrajectory` are 100% identical
|
|
257
334
|
between both APIs — no other code changes required.
|
|
258
335
|
|
|
336
|
+
## Migration from v0.2.x to v0.3.x
|
|
337
|
+
|
|
338
|
+
**No code changes required.** V0.3 is purely additive:
|
|
339
|
+
|
|
340
|
+
- `event.runId` and `event.parentRunId` are new optional fields — existing
|
|
341
|
+
callbacks that don't read them keep working untouched.
|
|
342
|
+
- The double-wrap warning only fires if you actually double-wrap (most
|
|
343
|
+
users do not).
|
|
344
|
+
- The default `maxInFlightRuns: 1024` is invisible in normal use. Override
|
|
345
|
+
only if you have memory pressure or want to opt out via `Infinity`.
|
|
346
|
+
|
|
259
347
|
The adapter releases follow `darwin-agents` major bumps. When
|
|
260
348
|
`@langchain/langgraph` 2.x lands, the adapter ships a new major within
|
|
261
349
|
the same minor of the underlying Darwin release.
|
|
@@ -52,6 +52,28 @@
|
|
|
52
52
|
import { BaseCallbackHandler } from "@langchain/core/callbacks/base";
|
|
53
53
|
import type { ChainValues } from "@langchain/core/utils/types";
|
|
54
54
|
import type { DarwinEvolutionOptions } from "./with-darwin-evolution.js";
|
|
55
|
+
/**
|
|
56
|
+
* V0.3 — extra options on top of `DarwinEvolutionOptions`. Pass to
|
|
57
|
+
* `new DarwinCallbackHandler({ ...opts, maxInFlightRuns })`.
|
|
58
|
+
*
|
|
59
|
+
* NEW V0.3 (S1187).
|
|
60
|
+
*/
|
|
61
|
+
export interface DarwinCallbackHandlerOptions extends DarwinEvolutionOptions {
|
|
62
|
+
/**
|
|
63
|
+
* Maximum number of in-flight `runId → nodeName` mappings the handler
|
|
64
|
+
* holds at once. If `handleChainEnd` / `handleChainError` never fires
|
|
65
|
+
* (LangGraph internal bug, OS-level kill of the worker mid-invoke,
|
|
66
|
+
* etc.) the map would otherwise grow without bound and leak memory.
|
|
67
|
+
*
|
|
68
|
+
* When the limit is exceeded, the OLDEST entry is evicted and a
|
|
69
|
+
* one-shot warning is logged. Default: 1024 (enough for typical
|
|
70
|
+
* fan-out patterns with safety margin, small enough to surface real
|
|
71
|
+
* leaks within minutes of an incident).
|
|
72
|
+
*
|
|
73
|
+
* Set to `Infinity` to opt out — discouraged in production.
|
|
74
|
+
*/
|
|
75
|
+
maxInFlightRuns?: number;
|
|
76
|
+
}
|
|
55
77
|
/**
|
|
56
78
|
* LangChain `BaseCallbackHandler` that listens for LangGraph node-chain
|
|
57
79
|
* events and dispatches Darwin trajectory hooks. Pass it via the
|
|
@@ -63,9 +85,16 @@ export declare class DarwinCallbackHandler extends BaseCallbackHandler {
|
|
|
63
85
|
readonly awaitHandlers = false;
|
|
64
86
|
private readonly resolved;
|
|
65
87
|
private readonly onTrajectory;
|
|
88
|
+
/**
|
|
89
|
+
* runId → in-flight run state. Map preserves insertion order so the
|
|
90
|
+
* oldest entry is always at `.keys().next().value` for LRU eviction
|
|
91
|
+
* when the cap is exceeded (V0.3 hung-invoke guard).
|
|
92
|
+
*/
|
|
66
93
|
private readonly runIdToName;
|
|
94
|
+
private readonly maxInFlightRuns;
|
|
67
95
|
private warned;
|
|
68
|
-
|
|
96
|
+
private evictionWarned;
|
|
97
|
+
constructor(opts: DarwinCallbackHandlerOptions);
|
|
69
98
|
/**
|
|
70
99
|
* Capture the run-id → node-name mapping.
|
|
71
100
|
*
|
|
@@ -76,7 +105,7 @@ export declare class DarwinCallbackHandler extends BaseCallbackHandler {
|
|
|
76
105
|
* `BaseCallbackHandler` d.ts is undefined for LangGraph chains at
|
|
77
106
|
* runtime — we keep it as a fallback for non-LangGraph chains.
|
|
78
107
|
*/
|
|
79
|
-
handleChainStart(_chain: unknown, _inputs: ChainValues, runId: string, _runType?: string, _tags?: string[], metadata?: Record<string, unknown>, runName?: string,
|
|
108
|
+
handleChainStart(_chain: unknown, _inputs: ChainValues, runId: string, _runType?: string, _tags?: string[], metadata?: Record<string, unknown>, runName?: string, parentRunId?: string, _extra?: Record<string, unknown>): void;
|
|
80
109
|
/**
|
|
81
110
|
* When a node-chain finishes, look up its name, locate the matching
|
|
82
111
|
* trajectory in `outputs`, and dispatch onTrajectory.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"darwin-callback-handler.d.ts","sourceRoot":"","sources":["../src/darwin-callback-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAI/D,OAAO,KAAK,EACV,sBAAsB,EAGvB,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"darwin-callback-handler.d.ts","sourceRoot":"","sources":["../src/darwin-callback-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAI/D,OAAO,KAAK,EACV,sBAAsB,EAGvB,MAAM,4BAA4B,CAAC;AAEpC;;;;;GAK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AO;IAaf;;;;OAIG;IACI,gBAAgB,IAAI,MAAM;CAGlC"}
|
|
@@ -51,6 +51,8 @@
|
|
|
51
51
|
*/
|
|
52
52
|
import { BaseCallbackHandler } from "@langchain/core/callbacks/base";
|
|
53
53
|
import { DarwinEvolutionHookError } from "./errors.js";
|
|
54
|
+
/** Default cap. Aligned with reasonable LangGraph fan-out (~1k nodes / minute). */
|
|
55
|
+
const DEFAULT_MAX_IN_FLIGHT_RUNS = 1024;
|
|
54
56
|
function isExecutionTrace(value) {
|
|
55
57
|
if (!value || typeof value !== "object")
|
|
56
58
|
return false;
|
|
@@ -96,8 +98,15 @@ export class DarwinCallbackHandler extends BaseCallbackHandler {
|
|
|
96
98
|
awaitHandlers = false;
|
|
97
99
|
resolved;
|
|
98
100
|
onTrajectory;
|
|
101
|
+
/**
|
|
102
|
+
* runId → in-flight run state. Map preserves insertion order so the
|
|
103
|
+
* oldest entry is always at `.keys().next().value` for LRU eviction
|
|
104
|
+
* when the cap is exceeded (V0.3 hung-invoke guard).
|
|
105
|
+
*/
|
|
99
106
|
runIdToName = new Map();
|
|
107
|
+
maxInFlightRuns;
|
|
100
108
|
warned = false;
|
|
109
|
+
evictionWarned = false;
|
|
101
110
|
constructor(opts) {
|
|
102
111
|
super();
|
|
103
112
|
if (!opts || !opts.nodeMap || Object.keys(opts.nodeMap).length === 0) {
|
|
@@ -106,6 +115,18 @@ export class DarwinCallbackHandler extends BaseCallbackHandler {
|
|
|
106
115
|
const defaultKey = opts.defaultTrajectoryKey ?? "darwinTrajectory";
|
|
107
116
|
this.resolved = normaliseNodeMap(opts.nodeMap, defaultKey);
|
|
108
117
|
this.onTrajectory = opts.onTrajectory;
|
|
118
|
+
// V0.3 (S1187): hung-invoke guard. NaN / negative / non-number falls
|
|
119
|
+
// back to default. Infinity disables the cap (opt-out).
|
|
120
|
+
const raw = opts.maxInFlightRuns;
|
|
121
|
+
if (raw === Infinity) {
|
|
122
|
+
this.maxInFlightRuns = Infinity;
|
|
123
|
+
}
|
|
124
|
+
else if (typeof raw === "number" && Number.isFinite(raw) && raw > 0) {
|
|
125
|
+
this.maxInFlightRuns = Math.floor(raw);
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
this.maxInFlightRuns = DEFAULT_MAX_IN_FLIGHT_RUNS;
|
|
129
|
+
}
|
|
109
130
|
}
|
|
110
131
|
/**
|
|
111
132
|
* Capture the run-id → node-name mapping.
|
|
@@ -117,7 +138,7 @@ export class DarwinCallbackHandler extends BaseCallbackHandler {
|
|
|
117
138
|
* `BaseCallbackHandler` d.ts is undefined for LangGraph chains at
|
|
118
139
|
* runtime — we keep it as a fallback for non-LangGraph chains.
|
|
119
140
|
*/
|
|
120
|
-
handleChainStart(_chain, _inputs, runId, _runType, _tags, metadata, runName,
|
|
141
|
+
handleChainStart(_chain, _inputs, runId, _runType, _tags, metadata, runName, parentRunId, _extra) {
|
|
121
142
|
// Primary source: metadata.langgraph_node (set by LangGraph internals).
|
|
122
143
|
let nodeName;
|
|
123
144
|
if (metadata && typeof metadata === "object") {
|
|
@@ -136,7 +157,31 @@ export class DarwinCallbackHandler extends BaseCallbackHandler {
|
|
|
136
157
|
// makes lookup in handleChainEnd a simple `.has()` check.
|
|
137
158
|
if (!this.resolved.has(nodeName))
|
|
138
159
|
return;
|
|
139
|
-
|
|
160
|
+
// V0.3 (S1187): hung-invoke guard. If we are about to exceed the cap
|
|
161
|
+
// AND the runId is genuinely new (not a re-fire), evict the oldest
|
|
162
|
+
// entry. Map iteration order is insertion order — the first key is
|
|
163
|
+
// the oldest. Warn once per handler instance so a real leak shows up
|
|
164
|
+
// in logs without spamming.
|
|
165
|
+
if (this.maxInFlightRuns !== Infinity &&
|
|
166
|
+
!this.runIdToName.has(runId) &&
|
|
167
|
+
this.runIdToName.size >= this.maxInFlightRuns) {
|
|
168
|
+
const oldest = this.runIdToName.keys().next().value;
|
|
169
|
+
if (oldest !== undefined) {
|
|
170
|
+
this.runIdToName.delete(oldest);
|
|
171
|
+
}
|
|
172
|
+
if (!this.evictionWarned) {
|
|
173
|
+
this.evictionWarned = true;
|
|
174
|
+
console.warn(`[darwin-langgraph] DarwinCallbackHandler: in-flight runs exceeded ` +
|
|
175
|
+
`${this.maxInFlightRuns} — evicting oldest entry. This usually ` +
|
|
176
|
+
`means handleChainEnd / handleChainError did not fire for some ` +
|
|
177
|
+
`runs (worker crash, parent invoke aborted mid-flight, or ` +
|
|
178
|
+
`LangGraph internal bug). Subsequent evictions are silent.`);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
this.runIdToName.set(runId, {
|
|
182
|
+
nodeName,
|
|
183
|
+
parentRunId: typeof parentRunId === "string" ? parentRunId : undefined,
|
|
184
|
+
});
|
|
140
185
|
}
|
|
141
186
|
/**
|
|
142
187
|
* When a node-chain finishes, look up its name, locate the matching
|
|
@@ -148,19 +193,19 @@ export class DarwinCallbackHandler extends BaseCallbackHandler {
|
|
|
148
193
|
* partial state under its configured name.
|
|
149
194
|
*/
|
|
150
195
|
handleChainEnd(outputs, runId, _parentRunId, _tags, _kwargs) {
|
|
151
|
-
const
|
|
152
|
-
if (!
|
|
196
|
+
const inFlight = this.runIdToName.get(runId);
|
|
197
|
+
if (!inFlight)
|
|
153
198
|
return;
|
|
154
199
|
// One-shot cleanup of the mapping so completed runs don't leak.
|
|
155
200
|
// R1 V0.2 Critic Finding 1 (S1185): the `runIdToName.delete` here
|
|
156
201
|
// is the ONLY dedup we need — LangGraph guarantees `handleChainEnd`
|
|
157
202
|
// fires exactly once per `runId`, and after deletion any second
|
|
158
|
-
// call returns early at `if (!
|
|
203
|
+
// call returns early at `if (!inFlight)`. The pre-V0.2 `firedRuns`
|
|
159
204
|
// Set was redundant AND leaked unbounded — removed.
|
|
160
205
|
this.runIdToName.delete(runId);
|
|
161
206
|
if (!this.onTrajectory)
|
|
162
207
|
return;
|
|
163
|
-
const entry = this.resolved.get(
|
|
208
|
+
const entry = this.resolved.get(inFlight.nodeName);
|
|
164
209
|
if (!entry)
|
|
165
210
|
return;
|
|
166
211
|
if (outputs === null || typeof outputs !== "object")
|
|
@@ -169,11 +214,16 @@ export class DarwinCallbackHandler extends BaseCallbackHandler {
|
|
|
169
214
|
if (!isExecutionTrace(trajectory))
|
|
170
215
|
return;
|
|
171
216
|
const frozen = Object.freeze({ ...outputs });
|
|
217
|
+
// V0.3 (S1187): propagate runId + parentRunId so OTEL exporters,
|
|
218
|
+
// Langfuse, LangSmith, etc. can rebuild the span hierarchy from the
|
|
219
|
+
// event payload alone (no separate runId-tracking side-channel).
|
|
172
220
|
const event = {
|
|
173
|
-
nodeName:
|
|
221
|
+
nodeName: inFlight.nodeName,
|
|
174
222
|
agentName: entry.agentName,
|
|
175
223
|
trajectory,
|
|
176
224
|
finalState: frozen,
|
|
225
|
+
runId,
|
|
226
|
+
...(inFlight.parentRunId !== undefined ? { parentRunId: inFlight.parentRunId } : {}),
|
|
177
227
|
};
|
|
178
228
|
// Fire-and-forget. The handler base class supports async returns
|
|
179
229
|
// but we don't want to block the chain end on slow user callbacks.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"darwin-callback-handler.js","sourceRoot":"","sources":["../src/darwin-callback-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAIrE,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"darwin-callback-handler.js","sourceRoot":"","sources":["../src/darwin-callback-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAIrE,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAmDvD,mFAAmF;AACnF,MAAM,0BAA0B,GA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
|
|
|
40
40
|
export { createDarwinNode, type CreateDarwinNodeOptions, type DarwinNodeFn, type DarwinRunOptionsPassthrough, } from "./create-darwin-node.js";
|
|
41
41
|
export { darwinAnnotation, getDarwinChannelSpec, lastWriteWinsTrajectoryReducer, } from "./darwin-annotation.js";
|
|
42
42
|
export { withDarwinEvolution, type DarwinEvolutionOptions, type DarwinNodeMapEntry, type DarwinTrajectoryEvent, } from "./with-darwin-evolution.js";
|
|
43
|
-
export { DarwinCallbackHandler } from "./darwin-callback-handler.js";
|
|
43
|
+
export { DarwinCallbackHandler, type DarwinCallbackHandlerOptions, } from "./darwin-callback-handler.js";
|
|
44
44
|
export { toOtelAttributes, toolCallToOtelAttributes, type OtelAttributes, type ToOtelAttributesOptions, type ToolCallOtelOptions, } from "./to-otel-attributes.js";
|
|
45
45
|
export { darwinMessagesAnnotation, getMessagesChannelSpec, } from "./darwin-messages-annotation.js";
|
|
46
46
|
export { DarwinNodeError, DarwinEvolutionHookError } from "./errors.js";
|
|
47
47
|
export type { AgentDefinition, DarwinExperiment, ExecutionTrace, MemoryProvider, RunResult, TraceToolCall, TraceTokenUsage, TraceTurnError, } from "./types.js";
|
|
48
48
|
/** Adapter version — sync with `package.json` on every release. */
|
|
49
|
-
export declare const VERSION = "0.
|
|
49
|
+
export declare const VERSION = "0.3.0-alpha.1";
|
|
50
50
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAEH,OAAO,EACL,gBAAgB,EAChB,KAAK,uBAAuB,EAC5B,KAAK,YAAY,EACjB,KAAK,2BAA2B,GACjC,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,8BAA8B,GAC/B,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,mBAAmB,EACnB,KAAK,sBAAsB,EAC3B,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,GAC3B,MAAM,4BAA4B,CAAC;AAGpC,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAEH,OAAO,EACL,gBAAgB,EAChB,KAAK,uBAAuB,EAC5B,KAAK,YAAY,EACjB,KAAK,2BAA2B,GACjC,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,8BAA8B,GAC/B,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,mBAAmB,EACnB,KAAK,sBAAsB,EAC3B,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,GAC3B,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EACL,qBAAqB,EACrB,KAAK,4BAA4B,GAClC,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EACL,gBAAgB,EAChB,wBAAwB,EACxB,KAAK,cAAc,EACnB,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,GACzB,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EACL,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAExE,YAAY,EACV,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,SAAS,EACT,aAAa,EACb,eAAe,EACf,cAAc,GACf,MAAM,YAAY,CAAC;AAEpB,mEAAmE;AACnE,eAAO,MAAM,OAAO,kBAAkB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -41,12 +41,12 @@ export { createDarwinNode, } from "./create-darwin-node.js";
|
|
|
41
41
|
export { darwinAnnotation, getDarwinChannelSpec, lastWriteWinsTrajectoryReducer, } from "./darwin-annotation.js";
|
|
42
42
|
export { withDarwinEvolution, } from "./with-darwin-evolution.js";
|
|
43
43
|
// V0.2 — LangChain-native callback handler (preferred over `withDarwinEvolution`)
|
|
44
|
-
export { DarwinCallbackHandler } from "./darwin-callback-handler.js";
|
|
44
|
+
export { DarwinCallbackHandler, } from "./darwin-callback-handler.js";
|
|
45
45
|
// V0.2 — OTEL GenAI Semantic Conventions mapping
|
|
46
46
|
export { toOtelAttributes, toolCallToOtelAttributes, } from "./to-otel-attributes.js";
|
|
47
47
|
// V0.2 — MessagesAnnotation interop for graphs mixing createReactAgent + createDarwinNode
|
|
48
48
|
export { darwinMessagesAnnotation, getMessagesChannelSpec, } from "./darwin-messages-annotation.js";
|
|
49
49
|
export { DarwinNodeError, DarwinEvolutionHookError } from "./errors.js";
|
|
50
50
|
/** Adapter version — sync with `package.json` on every release. */
|
|
51
|
-
export const VERSION = "0.
|
|
51
|
+
export const VERSION = "0.3.0-alpha.1";
|
|
52
52
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAEH,OAAO,EACL,gBAAgB,GAIjB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,8BAA8B,GAC/B,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,mBAAmB,GAIpB,MAAM,4BAA4B,CAAC;AAEpC,kFAAkF;AAClF,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAEH,OAAO,EACL,gBAAgB,GAIjB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,8BAA8B,GAC/B,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,mBAAmB,GAIpB,MAAM,4BAA4B,CAAC;AAEpC,kFAAkF;AAClF,OAAO,EACL,qBAAqB,GAEtB,MAAM,8BAA8B,CAAC;AAEtC,iDAAiD;AACjD,OAAO,EACL,gBAAgB,EAChB,wBAAwB,GAIzB,MAAM,yBAAyB,CAAC;AAEjC,0FAA0F;AAC1F,OAAO,EACL,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAaxE,mEAAmE;AACnE,MAAM,CAAC,MAAM,OAAO,GAAG,eAAe,CAAC"}
|
|
@@ -50,6 +50,30 @@ export interface DarwinTrajectoryEvent {
|
|
|
50
50
|
* state and corrupts subsequent runs (R1 Critic Finding 4, S1185).
|
|
51
51
|
*/
|
|
52
52
|
finalState: Readonly<Record<string, unknown>>;
|
|
53
|
+
/**
|
|
54
|
+
* LangChain runId of the node-chain that produced this trajectory.
|
|
55
|
+
* Only populated by {@link DarwinCallbackHandler} (v0.2+) where the
|
|
56
|
+
* runId is part of the LangChain callback contract. Undefined for the
|
|
57
|
+
* legacy `withDarwinEvolution` monkey-patch path (no runId there).
|
|
58
|
+
*
|
|
59
|
+
* Stable identifier suitable for correlation with OTEL spans, Langfuse
|
|
60
|
+
* traces, LangSmith runs, or custom run-id-based logging.
|
|
61
|
+
*
|
|
62
|
+
* NEW V0.3 (S1187).
|
|
63
|
+
*/
|
|
64
|
+
runId?: string;
|
|
65
|
+
/**
|
|
66
|
+
* LangChain parentRunId — the runId of the chain that invoked this
|
|
67
|
+
* node-chain. For top-level graph invokes the parent is the graph
|
|
68
|
+
* itself. For child graphs / nested invocations the parent is the
|
|
69
|
+
* outer graph's runId. Only populated by {@link DarwinCallbackHandler}.
|
|
70
|
+
*
|
|
71
|
+
* Use this to build span/trace hierarchies in OTEL exporters,
|
|
72
|
+
* Langfuse, etc.
|
|
73
|
+
*
|
|
74
|
+
* NEW V0.3 (S1187).
|
|
75
|
+
*/
|
|
76
|
+
parentRunId?: string;
|
|
53
77
|
}
|
|
54
78
|
/** Options for {@link withDarwinEvolution}. */
|
|
55
79
|
export interface DarwinEvolutionOptions {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"with-darwin-evolution.d.ts","sourceRoot":"","sources":["../src/with-darwin-evolution.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAIpD,gFAAgF;AAChF,MAAM,MAAM,kBAAkB,GAC1B,MAAM,GACN;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAA;CAAE,CAAC;AAEjD,sEAAsE;AACtE,MAAM,WAAW,qBAAqB;IACpC,gEAAgE;IAChE,QAAQ,EAAE,MAAM,CAAC;IACjB,sDAAsD;IACtD,SAAS,EAAE,MAAM,CAAC;IAClB,oCAAoC;IACpC,UAAU,EAAE,cAAc,CAAC;IAC3B;;;;;;OAMG;IACH,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"with-darwin-evolution.d.ts","sourceRoot":"","sources":["../src/with-darwin-evolution.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAIpD,gFAAgF;AAChF,MAAM,MAAM,kBAAkB,GAC1B,MAAM,GACN;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAA;CAAE,CAAC;AAEjD,sEAAsE;AACtE,MAAM,WAAW,qBAAqB;IACpC,gEAAgE;IAChE,QAAQ,EAAE,MAAM,CAAC;IACjB,sDAAsD;IACtD,SAAS,EAAE,MAAM,CAAC;IAClB,oCAAoC;IACpC,UAAU,EAAE,cAAc,CAAC;IAC3B;;;;;;OAMG;IACH,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAC9C;;;;;;;;;;OAUG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;;;;;;;OAUG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,+CAA+C;AAC/C,MAAM,WAAW,sBAAsB;IACrC;;;;;;;;;;;;OAYG;IACH,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IAC5C;;;OAGG;IACH,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,qBAAqB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtE,mGAAmG;IACnG,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED,yEAAyE;AACzE,UAAU,cAAc;IACtB,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC3D,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC;CAC3E;AAyDD,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,cAAc,EAC1D,KAAK,EAAE,CAAC,EACR,IAAI,EAAE,sBAAsB,GAC3B,CAAC,CAsRH"}
|
|
@@ -58,8 +58,29 @@ import { DarwinEvolutionHookError } from "./errors.js";
|
|
|
58
58
|
* first warn we go silent — never spam.
|
|
59
59
|
*
|
|
60
60
|
* R1 V0.2 Research Finding 7 + Analyst Observation 2 (S1185).
|
|
61
|
+
*
|
|
62
|
+
* Exported for tests via `vi.resetModules()` re-import.
|
|
61
63
|
*/
|
|
62
64
|
let withDarwinEvolutionDeprecationWarned = false;
|
|
65
|
+
/**
|
|
66
|
+
* Process-wide double-wrap warning flag. Fires once per process if a
|
|
67
|
+
* caller wraps the same graph twice with `withDarwinEvolution`. Catches
|
|
68
|
+
* the silent footgun where the SECOND wrap chains on top of the first
|
|
69
|
+
* — both hooks fire per run, often producing duplicate evolution
|
|
70
|
+
* trajectories and confusing test failures.
|
|
71
|
+
*
|
|
72
|
+
* NEW V0.3 (S1187).
|
|
73
|
+
*/
|
|
74
|
+
let withDarwinEvolutionDoubleWrapWarned = false;
|
|
75
|
+
/**
|
|
76
|
+
* Sentinel symbol stamped on graphs that have already been wrapped.
|
|
77
|
+
* Looked up at the start of each `withDarwinEvolution` call to detect
|
|
78
|
+
* double-wrap. Using a Symbol (not a string) so it cannot be cleared
|
|
79
|
+
* accidentally by `JSON.parse(JSON.stringify(graph))` style cloning.
|
|
80
|
+
*
|
|
81
|
+
* NEW V0.3 (S1187).
|
|
82
|
+
*/
|
|
83
|
+
const DARWIN_EVOLUTION_WRAPPED = Symbol.for("darwin-langgraph.evolution.wrapped");
|
|
63
84
|
export function withDarwinEvolution(graph, opts) {
|
|
64
85
|
if (!withDarwinEvolutionDeprecationWarned) {
|
|
65
86
|
withDarwinEvolutionDeprecationWarned = true;
|
|
@@ -67,6 +88,23 @@ export function withDarwinEvolution(graph, opts) {
|
|
|
67
88
|
"and will be removed in v1.0.0. Migrate to DarwinCallbackHandler — " +
|
|
68
89
|
"see https://github.com/studiomeyer-io/darwin-langgraph#migration");
|
|
69
90
|
}
|
|
91
|
+
// V0.3 (S1187): double-wrap detection. If the graph carries our
|
|
92
|
+
// sentinel, the caller passed a wrapped graph through `withDarwinEvolution`
|
|
93
|
+
// again — both hooks will fire and produce duplicate trajectories. Warn
|
|
94
|
+
// once per process and continue (some users may legitimately layer
|
|
95
|
+
// multiple wrappers with different `nodeMap` slices, so we don't
|
|
96
|
+
// throw — but the warning is loud).
|
|
97
|
+
const wrappedGraph = graph;
|
|
98
|
+
if (wrappedGraph[DARWIN_EVOLUTION_WRAPPED] === true) {
|
|
99
|
+
if (!withDarwinEvolutionDoubleWrapWarned) {
|
|
100
|
+
withDarwinEvolutionDoubleWrapWarned = true;
|
|
101
|
+
console.warn("[darwin-langgraph] withDarwinEvolution(): graph appears to be wrapped " +
|
|
102
|
+
"twice — both hooks will fire per run, producing duplicate trajectories. " +
|
|
103
|
+
"If this is intentional, ignore this warning; otherwise wrap only once " +
|
|
104
|
+
"or migrate to DarwinCallbackHandler which supports multiple handlers " +
|
|
105
|
+
"natively via callbacks: [h1, h2]. Subsequent double-wraps are silent.");
|
|
106
|
+
}
|
|
107
|
+
}
|
|
70
108
|
if (!opts || !opts.nodeMap || Object.keys(opts.nodeMap).length === 0) {
|
|
71
109
|
throw new DarwinEvolutionHookError("withDarwinEvolution: opts.nodeMap is required and must contain at least one entry.");
|
|
72
110
|
}
|
|
@@ -279,6 +317,14 @@ export function withDarwinEvolution(graph, opts) {
|
|
|
279
317
|
configurable: true,
|
|
280
318
|
enumerable: false,
|
|
281
319
|
});
|
|
320
|
+
// V0.3 (S1187): stamp the sentinel so a subsequent call detects the
|
|
321
|
+
// double-wrap. Non-enumerable so it doesn't leak in JSON/log dumps.
|
|
322
|
+
Object.defineProperty(graph, DARWIN_EVOLUTION_WRAPPED, {
|
|
323
|
+
value: true,
|
|
324
|
+
writable: false,
|
|
325
|
+
configurable: true,
|
|
326
|
+
enumerable: false,
|
|
327
|
+
});
|
|
282
328
|
}
|
|
283
329
|
catch (err) {
|
|
284
330
|
throw new DarwinEvolutionHookError("withDarwinEvolution: could not wrap graph.invoke / graph.stream " +
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"with-darwin-evolution.js","sourceRoot":"","sources":["../src/with-darwin-evolution.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAIH,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"with-darwin-evolution.js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AAC;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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "darwin-langgraph",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0-alpha.1",
|
|
4
4
|
"description": "LangGraph.js adapter for darwin-agents — wrap self-evolving Darwin agents as StateGraph nodes with zero hard deps.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|