darwin-langgraph 0.1.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 +212 -3
- package/README.md +148 -16
- package/dist/darwin-callback-handler.d.ts +134 -0
- package/dist/darwin-callback-handler.d.ts.map +1 -0
- package/dist/darwin-callback-handler.js +261 -0
- package/dist/darwin-callback-handler.js.map +1 -0
- package/dist/darwin-messages-annotation.d.ts +70 -0
- package/dist/darwin-messages-annotation.d.ts.map +1 -0
- package/dist/darwin-messages-annotation.js +78 -0
- package/dist/darwin-messages-annotation.js.map +1 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/dist/to-otel-attributes.d.ts +116 -0
- package/dist/to-otel-attributes.d.ts.map +1 -0
- package/dist/to-otel-attributes.js +178 -0
- package/dist/to-otel-attributes.js.map +1 -0
- package/dist/with-darwin-evolution.d.ts +24 -7
- package/dist/with-darwin-evolution.d.ts.map +1 -1
- package/dist/with-darwin-evolution.js +82 -2
- package/dist/with-darwin-evolution.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Surface 5 (V0.2) — `toOtelAttributes(trajectory, opts?)`.
|
|
3
|
+
*
|
|
4
|
+
* Pure mapper from Darwin's `ExecutionTrace` to a flat
|
|
5
|
+
* `Record<string, string | number | boolean>` keyed by
|
|
6
|
+
* [OpenTelemetry GenAI Semantic Conventions](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/gen-ai/gen-ai-spans.md)
|
|
7
|
+
* attribute names — so any OTEL-compatible exporter (Langfuse,
|
|
8
|
+
* Braintrust, Honeycomb, Datadog, New Relic, Grafana) picks up the
|
|
9
|
+
* trace data without further mapping.
|
|
10
|
+
*
|
|
11
|
+
* Coverage:
|
|
12
|
+
* - `gen_ai.operation.name` = `"invoke_agent"` (constant per OTEL
|
|
13
|
+
* GenAI spec for agent-level operations).
|
|
14
|
+
* - `gen_ai.agent.name` = `opts.agentName` (callers passes the
|
|
15
|
+
* agent's logical name).
|
|
16
|
+
* - `gen_ai.agent.id` = `opts.agentId` (optional UUID/run id).
|
|
17
|
+
* - `gen_ai.usage.input_tokens` / `output_tokens` / `cache_read_tokens` /
|
|
18
|
+
* `cache_creation_tokens` — only emitted when the upstream
|
|
19
|
+
* trajectory captured token usage (i.e. provider reported it).
|
|
20
|
+
* - `darwin.trajectory.tool_calls.count` (custom, non-OTEL — namespaced
|
|
21
|
+
* under `darwin.*` to avoid colliding with future OTEL fields).
|
|
22
|
+
* - `darwin.trajectory.text_blocks` / `turns` / `mcp_invocations` /
|
|
23
|
+
* `errors.count` — same custom namespace.
|
|
24
|
+
* - `darwin.trajectory.captured_at` — ISO string for traceability.
|
|
25
|
+
*
|
|
26
|
+
* Per OTEL GenAI spec we DO NOT emit `gen_ai.tool.call.arguments` /
|
|
27
|
+
* `gen_ai.tool.call.result` here — those are span-level attributes
|
|
28
|
+
* meant to be attached to per-tool-call spans, not the aggregate
|
|
29
|
+
* trajectory. Callers who need them should iterate `trajectory.toolCalls`
|
|
30
|
+
* and emit one child span per call.
|
|
31
|
+
*
|
|
32
|
+
* Design notes:
|
|
33
|
+
* - **Sparse output.** Undefined fields stay out of the result rather
|
|
34
|
+
* than appearing as `null` — keeps OTEL exporters from over-counting
|
|
35
|
+
* missing-data buckets.
|
|
36
|
+
* - **No allocation on hot path.** The function builds a single
|
|
37
|
+
* object literal incrementally; no Map / Set / array intermediates.
|
|
38
|
+
* - **Pure.** No side effects, no I/O, no Date.now() — fully
|
|
39
|
+
* testable with deterministic inputs.
|
|
40
|
+
*/
|
|
41
|
+
/**
|
|
42
|
+
* Build the OTEL attribute bag for an `ExecutionTrace`.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts
|
|
46
|
+
* import { toOtelAttributes } from "darwin-langgraph";
|
|
47
|
+
*
|
|
48
|
+
* const attrs = toOtelAttributes(event.trajectory, {
|
|
49
|
+
* agentName: event.agentName,
|
|
50
|
+
* agentId: someExperimentId,
|
|
51
|
+
* });
|
|
52
|
+
* // attrs = {
|
|
53
|
+
* // "gen_ai.operation.name": "invoke_agent",
|
|
54
|
+
* // "gen_ai.agent.name": "researcher",
|
|
55
|
+
* // "gen_ai.agent.id": "exp-2026-05-25-001",
|
|
56
|
+
* // "gen_ai.usage.input_tokens": 1200,
|
|
57
|
+
* // "gen_ai.usage.output_tokens": 340,
|
|
58
|
+
* // "darwin.trajectory.tool_calls.count": 3,
|
|
59
|
+
* // "darwin.trajectory.text_blocks": 2,
|
|
60
|
+
* // "darwin.trajectory.turns": 4,
|
|
61
|
+
* // "darwin.trajectory.mcp_invocations": 2,
|
|
62
|
+
* // "darwin.trajectory.errors.count": 0,
|
|
63
|
+
* // "darwin.trajectory.captured_at": "2026-05-25T08:00:00.000Z",
|
|
64
|
+
* // }
|
|
65
|
+
*
|
|
66
|
+
* // OTEL exporter usage (any tracer):
|
|
67
|
+
* span.setAttributes(attrs);
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
export function toOtelAttributes(trajectory, opts = {}) {
|
|
71
|
+
if (!trajectory || typeof trajectory !== "object" || trajectory.version !== 1) {
|
|
72
|
+
throw new TypeError(`toOtelAttributes: trajectory must be an ExecutionTrace with version=1, got ${trajectory === null ? "null" : typeof trajectory}`);
|
|
73
|
+
}
|
|
74
|
+
const ns = opts.customNamespace ?? "darwin";
|
|
75
|
+
const attrs = {
|
|
76
|
+
// OTEL GenAI required-style attributes
|
|
77
|
+
"gen_ai.operation.name": "invoke_agent",
|
|
78
|
+
};
|
|
79
|
+
if (opts.agentName)
|
|
80
|
+
attrs["gen_ai.agent.name"] = opts.agentName;
|
|
81
|
+
if (opts.agentId)
|
|
82
|
+
attrs["gen_ai.agent.id"] = opts.agentId;
|
|
83
|
+
// Token usage — only emit when provider reported FINITE numbers. NaN
|
|
84
|
+
// and Infinity pass `typeof === "number"` but OTEL exporters drop
|
|
85
|
+
// spans with non-finite numeric attrs silently (R1 V0.2 Critic
|
|
86
|
+
// Finding 3 + Finding 7, S1185).
|
|
87
|
+
//
|
|
88
|
+
// OTEL GenAI spec attribute names (R1 V0.2 Research Finding 1, S1185):
|
|
89
|
+
// cache fields are `gen_ai.usage.cache_read.input_tokens` /
|
|
90
|
+
// `cache_creation.input_tokens` per the official registry, NOT the
|
|
91
|
+
// shorter `cache_read_tokens` / `cache_creation_tokens` we had pre-fix.
|
|
92
|
+
const usage = trajectory.tokenUsage;
|
|
93
|
+
if (usage) {
|
|
94
|
+
if (typeof usage.inputTokens === "number" && Number.isFinite(usage.inputTokens)) {
|
|
95
|
+
attrs["gen_ai.usage.input_tokens"] = usage.inputTokens;
|
|
96
|
+
}
|
|
97
|
+
if (typeof usage.outputTokens === "number" && Number.isFinite(usage.outputTokens)) {
|
|
98
|
+
attrs["gen_ai.usage.output_tokens"] = usage.outputTokens;
|
|
99
|
+
}
|
|
100
|
+
if (typeof usage.cacheReadTokens === "number" && Number.isFinite(usage.cacheReadTokens)) {
|
|
101
|
+
attrs["gen_ai.usage.cache_read.input_tokens"] = usage.cacheReadTokens;
|
|
102
|
+
}
|
|
103
|
+
if (typeof usage.cacheCreationTokens === "number" &&
|
|
104
|
+
Number.isFinite(usage.cacheCreationTokens)) {
|
|
105
|
+
attrs["gen_ai.usage.cache_creation.input_tokens"] = usage.cacheCreationTokens;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
// Darwin-namespaced aggregates (always emitted, even when 0, so
|
|
109
|
+
// dashboards can graph deltas correctly). Defensive `?? 0` fallback
|
|
110
|
+
// in case a future darwin-agents version makes a field optional.
|
|
111
|
+
const toolCallsCount = Array.isArray(trajectory.toolCalls)
|
|
112
|
+
? trajectory.toolCalls.length
|
|
113
|
+
: 0;
|
|
114
|
+
const errorsCount = Array.isArray(trajectory.errors) ? trajectory.errors.length : 0;
|
|
115
|
+
attrs[`${ns}.trajectory.tool_calls.count`] = toolCallsCount;
|
|
116
|
+
attrs[`${ns}.trajectory.text_blocks`] =
|
|
117
|
+
Number.isFinite(trajectory.textBlockCount) ? trajectory.textBlockCount : 0;
|
|
118
|
+
attrs[`${ns}.trajectory.turns`] =
|
|
119
|
+
Number.isFinite(trajectory.turnCount) ? trajectory.turnCount : 0;
|
|
120
|
+
attrs[`${ns}.trajectory.mcp_invocations`] =
|
|
121
|
+
Number.isFinite(trajectory.mcpInvocations) ? trajectory.mcpInvocations : 0;
|
|
122
|
+
attrs[`${ns}.trajectory.errors.count`] = errorsCount;
|
|
123
|
+
if (typeof trajectory.capturedAt === "string" && trajectory.capturedAt.length > 0) {
|
|
124
|
+
attrs[`${ns}.trajectory.captured_at`] = trajectory.capturedAt;
|
|
125
|
+
}
|
|
126
|
+
return attrs;
|
|
127
|
+
}
|
|
128
|
+
export function toolCallToOtelAttributes(call, opts = {}) {
|
|
129
|
+
const ns = opts.customNamespace ?? "darwin";
|
|
130
|
+
// R1 V0.2 Research Finding 3 (S1185): per OTEL GenAI spec, `gen_ai.tool.type`
|
|
131
|
+
// takes one of `function` (client-side, agent generates params),
|
|
132
|
+
// `extension` (agent-side, calls external APIs), or `datastore`. MCP
|
|
133
|
+
// tools execute server-side via the agent and call external APIs —
|
|
134
|
+
// they map to `"extension"`, not `"function"`. We route on the
|
|
135
|
+
// existing `mcp__` prefix heuristic.
|
|
136
|
+
const isMcp = call.tool.startsWith("mcp__");
|
|
137
|
+
const toolType = isMcp ? "extension" : "function";
|
|
138
|
+
const attrs = {
|
|
139
|
+
"gen_ai.operation.name": "execute_tool",
|
|
140
|
+
"gen_ai.tool.name": call.tool,
|
|
141
|
+
"gen_ai.tool.type": toolType,
|
|
142
|
+
[`${ns}.tool.outcome`]: call.outcome,
|
|
143
|
+
[`${ns}.tool.duration_ms`]: Number.isFinite(call.durationMs) ? call.durationMs : 0,
|
|
144
|
+
[`${ns}.tool.turn`]: Number.isFinite(call.turn) ? call.turn : 0,
|
|
145
|
+
[`${ns}.tool.is_mcp`]: isMcp,
|
|
146
|
+
};
|
|
147
|
+
// `call.id` is optional on TraceToolCall — only emit when present so
|
|
148
|
+
// OTEL exporters don't see empty-string ids.
|
|
149
|
+
if (typeof call.id === "string" && call.id.length > 0) {
|
|
150
|
+
attrs["gen_ai.tool.call.id"] = call.id;
|
|
151
|
+
}
|
|
152
|
+
if (call.outcome === "error") {
|
|
153
|
+
if (typeof call.errorClass === "string" && call.errorClass.length > 0) {
|
|
154
|
+
attrs["error.type"] = call.errorClass;
|
|
155
|
+
}
|
|
156
|
+
if (typeof call.errorMessage === "string" && call.errorMessage.length > 0) {
|
|
157
|
+
attrs[`${ns}.tool.error.message`] = call.errorMessage;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
if (typeof call.retryCount === "number" && call.retryCount > 0) {
|
|
161
|
+
attrs[`${ns}.tool.retry_count`] = call.retryCount;
|
|
162
|
+
}
|
|
163
|
+
if (opts.includeArguments && call.args !== undefined) {
|
|
164
|
+
try {
|
|
165
|
+
attrs["gen_ai.tool.call.arguments"] = JSON.stringify(call.args);
|
|
166
|
+
}
|
|
167
|
+
catch {
|
|
168
|
+
attrs["gen_ai.tool.call.arguments"] = "<unserialisable>";
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
if (opts.includeResults &&
|
|
172
|
+
typeof call.resultSummary === "string" &&
|
|
173
|
+
call.resultSummary.length > 0) {
|
|
174
|
+
attrs["gen_ai.tool.call.result"] = call.resultSummary;
|
|
175
|
+
}
|
|
176
|
+
return attrs;
|
|
177
|
+
}
|
|
178
|
+
//# sourceMappingURL=to-otel-attributes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"to-otel-attributes.js","sourceRoot":"","sources":["../src/to-otel-attributes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAqBH;;;;;;;;;;;;;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Ac;QACnB,OAAO,IAAI,CAAC,aAAa,KAAK,QAAQ;QACtC,IAAI,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,EAC7B,CAAC;QACD,KAAK,CAAC,yBAAyB,CAAC,GAAG,IAAI,CAAC,aAAa,CAAC;IACxD,CAAC;IAED,OAAO,KAAK,CAAC;AACf,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 {
|
|
@@ -80,13 +104,6 @@ interface InvokableGraph {
|
|
|
80
104
|
invoke(input: unknown, config?: unknown): Promise<unknown>;
|
|
81
105
|
stream(input: unknown, config?: unknown): Promise<AsyncIterable<unknown>>;
|
|
82
106
|
}
|
|
83
|
-
/**
|
|
84
|
-
* Wraps a compiled LangGraph so the supplied `onTrajectory` callback
|
|
85
|
-
* fires for each node listed in `nodeMap` after every `invoke` / `stream`
|
|
86
|
-
* run. Returns the same graph instance for chaining.
|
|
87
|
-
*
|
|
88
|
-
* @throws {DarwinEvolutionHookError} when `nodeMap` is empty or missing.
|
|
89
|
-
*/
|
|
90
107
|
export declare function withDarwinEvolution<G extends InvokableGraph>(graph: G, opts: DarwinEvolutionOptions): G;
|
|
91
108
|
export {};
|
|
92
109
|
//# sourceMappingURL=with-darwin-evolution.d.ts.map
|
|
@@ -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,KA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C3B,CAAC,CAsRH"}
|
|
@@ -34,9 +34,77 @@ import { DarwinEvolutionHookError } from "./errors.js";
|
|
|
34
34
|
* fires for each node listed in `nodeMap` after every `invoke` / `stream`
|
|
35
35
|
* run. Returns the same graph instance for chaining.
|
|
36
36
|
*
|
|
37
|
+
* @deprecated Since v0.2.0 — prefer {@link DarwinCallbackHandler} which uses
|
|
38
|
+
* LangChain's canonical callback mechanism instead of monkey-patching
|
|
39
|
+
* `graph.invoke` / `graph.stream`. This wrapper continues to work
|
|
40
|
+
* identically for back-compat but will be removed in v1.0. Migration:
|
|
41
|
+
*
|
|
42
|
+
* ```ts
|
|
43
|
+
* // Before (v0.1):
|
|
44
|
+
* const graph = withDarwinEvolution(compiledGraph, { nodeMap, onTrajectory });
|
|
45
|
+
* const r = await graph.invoke(input);
|
|
46
|
+
*
|
|
47
|
+
* // After (v0.2 — recommended):
|
|
48
|
+
* const handler = new DarwinCallbackHandler({ nodeMap, onTrajectory });
|
|
49
|
+
* const r = await compiledGraph.invoke(input, { callbacks: [handler] });
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
37
52
|
* @throws {DarwinEvolutionHookError} when `nodeMap` is empty or missing.
|
|
38
53
|
*/
|
|
54
|
+
/**
|
|
55
|
+
* Process-wide deprecation warning flag for `withDarwinEvolution`. We
|
|
56
|
+
* emit one `console.warn` on the first call so CI runs (no IDE for
|
|
57
|
+
* `@deprecated` strikethrough) still see the migration hint. After the
|
|
58
|
+
* first warn we go silent — never spam.
|
|
59
|
+
*
|
|
60
|
+
* R1 V0.2 Research Finding 7 + Analyst Observation 2 (S1185).
|
|
61
|
+
*
|
|
62
|
+
* Exported for tests via `vi.resetModules()` re-import.
|
|
63
|
+
*/
|
|
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");
|
|
39
84
|
export function withDarwinEvolution(graph, opts) {
|
|
85
|
+
if (!withDarwinEvolutionDeprecationWarned) {
|
|
86
|
+
withDarwinEvolutionDeprecationWarned = true;
|
|
87
|
+
console.warn("[darwin-langgraph] withDarwinEvolution() is deprecated since v0.2.0 " +
|
|
88
|
+
"and will be removed in v1.0.0. Migrate to DarwinCallbackHandler — " +
|
|
89
|
+
"see https://github.com/studiomeyer-io/darwin-langgraph#migration");
|
|
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
|
+
}
|
|
40
108
|
if (!opts || !opts.nodeMap || Object.keys(opts.nodeMap).length === 0) {
|
|
41
109
|
throw new DarwinEvolutionHookError("withDarwinEvolution: opts.nodeMap is required and must contain at least one entry.");
|
|
42
110
|
}
|
|
@@ -65,12 +133,16 @@ export function withDarwinEvolution(graph, opts) {
|
|
|
65
133
|
}
|
|
66
134
|
let warned = false;
|
|
67
135
|
const swallow = (err) => {
|
|
68
|
-
|
|
136
|
+
// R2 V0.2 Critic Finding R2-1 (S1185): do NOT short-circuit on
|
|
137
|
+
// falsy `err` — `throw 0` / `throw null` / `throw ""` from user
|
|
138
|
+
// callbacks must still surface in logs. Diverged from
|
|
139
|
+
// DarwinCallbackHandler.swallow until R2 caught it.
|
|
140
|
+
if (warned)
|
|
69
141
|
return;
|
|
70
142
|
warned = true;
|
|
71
143
|
console.warn(`[darwin-langgraph] onTrajectory callback threw — swallowed. ` +
|
|
72
144
|
`Subsequent throws will be silent. Original error: ` +
|
|
73
|
-
`${err
|
|
145
|
+
`${err instanceof Error ? err.message : String(err)}`);
|
|
74
146
|
};
|
|
75
147
|
const fireHook = async (finalState) => {
|
|
76
148
|
if (!callback)
|
|
@@ -245,6 +317,14 @@ export function withDarwinEvolution(graph, opts) {
|
|
|
245
317
|
configurable: true,
|
|
246
318
|
enumerable: false,
|
|
247
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
|
+
});
|
|
248
328
|
}
|
|
249
329
|
catch (err) {
|
|
250
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","sourceRoot":"","sources":["../src/with-darwin-evolution.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAIH,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAgFvD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH;;;;;;;;;GASG;AACH,IAAI,oCAAoC,GAAG,KAAK,CAAC;AAEjD;;;;;;;;GAQG;AACH,IAAI,mCAAmC,GAAG,KAAK,CAAC;AAEhD;;;;;;;GAOG;AACH,MAAM,wBAAwB,GAAG,MAAM,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAC;AAElF,MAAM,UAAU,mBAAmB,CACjC,KAAQ,EACR,IAA4B;IAE5B,IAAI,CAAC,oCAAoC,EAAE,CAAC;QAC1C,oCAAoC,GAAG,IAAI,CAAC;QAC5C,OAAO,CAAC,IAAI,CACV,sEAAsE;YACpE,oEAAoE;YACpE,kEAAkE,CACrE,CAAC;IACJ,CAAC;IACD,gEAAgE;IAChE,4EAA4E;IAC5E,wEAAwE;IACxE,mEAAmE;IACnE,iEAAiE;IACjE,oCAAoC;IACpC,MAAM,YAAY,GAAG,KAAqD,CAAC;IAC3E,IAAI,YAAY,CAAC,wBAAwB,CAAC,KAAK,IAAI,EAA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AClB,UAAU,EAAE,KAAK;SAClB,CAAC,CAAC;QACH,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,QAAQ,EAAE;YACrC,KAAK,EAAE,aAAa;YACpB,QAAQ,EAAE,IAAI;YACd,YAAY,EAAE,IAAI;YAClB,UAAU,EAAE,KAAK;SAClB,CAAC,CAAC;QACH,oEAAoE;QACpE,oEAAoE;QACpE,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,wBAAwB,EAAE;YACrD,KAAK,EAAE,IAAI;YACX,QAAQ,EAAE,KAAK;YACf,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
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",
|