Skip to content

Commit 990040d

Browse files
chore: version packages (#1921)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Hunter Lovell <hunter@hntrl.io>
1 parent 160f2e0 commit 990040d

File tree

3 files changed

+36
-37
lines changed

3 files changed

+36
-37
lines changed

.changeset/type-bag-pattern.md

Lines changed: 0 additions & 36 deletions
This file was deleted.

libs/langgraph-core/CHANGELOG.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,41 @@
1414
- Deprecate `stateSchema` property in favor of `state`
1515
- Simplify constructor overloads with unified `StateGraphInit` type
1616

17+
- [#1918](https://github.com/langchain-ai/langgraphjs/pull/1918) [`cc12263`](https://github.com/langchain-ai/langgraphjs/commit/cc12263ad26804ef53760cabf1bd2fda0be575d6) Thanks [@hntrl](https://github.com/hntrl)! - Add type bag pattern for `GraphNode` and `ConditionalEdgeRouter` type utilities.
18+
19+
**New types:**
20+
21+
- `GraphNodeTypes<InputSchema, OutputSchema, ContextSchema, Nodes>` - Type bag interface for GraphNode
22+
- `GraphNodeReturnValue<Update, Nodes>` - Return type helper for node functions
23+
- `ConditionalEdgeRouterTypes<InputSchema, ContextSchema, Nodes>` - Type bag interface for ConditionalEdgeRouter
24+
25+
**Usage:**
26+
27+
Both `GraphNode` and `ConditionalEdgeRouter` now support two patterns:
28+
29+
1. **Single schema** (backward compatible):
30+
31+
```typescript
32+
const node: GraphNode<typeof AgentState, MyContext, "agent" | "tool"> = ...
33+
```
34+
35+
2. **Type bag pattern** (new):
36+
```typescript
37+
const node: GraphNode<{
38+
InputSchema: typeof InputSchema;
39+
OutputSchema: typeof OutputSchema;
40+
ContextSchema: typeof ContextSchema;
41+
Nodes: "agent" | "tool";
42+
}> = (state, runtime) => {
43+
// state type inferred from InputSchema
44+
// return type validated against OutputSchema
45+
// runtime.configurable type inferred from ContextSchema
46+
return { answer: "response" };
47+
};
48+
```
49+
50+
The type bag pattern enables nodes that receive a subset of state fields and return different fields, with full type safety.
51+
1752
## 1.1.1
1853

1954
### Patch Changes

libs/langgraph/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,4 +162,4 @@
162162
"files": [
163163
"dist/"
164164
]
165-
}
165+
}

0 commit comments

Comments
 (0)