@langchain/langgraph 0.2.4 → 0.2.5-rc.0
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/dist/graph/state.cjs +12 -1
- package/dist/graph/state.d.ts +8 -6
- package/dist/graph/state.js +12 -1
- package/dist/prebuilt/agent_executor.d.ts +1 -1
- package/dist/pregel/index.cjs +13 -0
- package/dist/pregel/index.d.ts +1 -0
- package/dist/pregel/index.js +13 -0
- package/dist/pregel/types.d.ts +1 -0
- package/package.json +1 -1
package/dist/graph/state.cjs
CHANGED
|
@@ -78,7 +78,7 @@ const ROOT = "__root__";
|
|
|
78
78
|
* ```
|
|
79
79
|
*/
|
|
80
80
|
class StateGraph extends graph_js_1.Graph {
|
|
81
|
-
constructor(fields) {
|
|
81
|
+
constructor(fields, configSchema) {
|
|
82
82
|
super();
|
|
83
83
|
Object.defineProperty(this, "channels", {
|
|
84
84
|
enumerable: true,
|
|
@@ -124,6 +124,13 @@ class StateGraph extends graph_js_1.Graph {
|
|
|
124
124
|
writable: true,
|
|
125
125
|
value: new Map()
|
|
126
126
|
});
|
|
127
|
+
/** @internal */
|
|
128
|
+
Object.defineProperty(this, "_configSchema", {
|
|
129
|
+
enumerable: true,
|
|
130
|
+
configurable: true,
|
|
131
|
+
writable: true,
|
|
132
|
+
value: void 0
|
|
133
|
+
});
|
|
127
134
|
if (isStateGraphArgsWithInputOutputSchemas(fields)) {
|
|
128
135
|
this._schemaDefinition = fields.input.spec;
|
|
129
136
|
this._inputDefinition = fields.input.spec;
|
|
@@ -152,6 +159,7 @@ class StateGraph extends graph_js_1.Graph {
|
|
|
152
159
|
this._addSchema(this._schemaDefinition);
|
|
153
160
|
this._addSchema(this._inputDefinition);
|
|
154
161
|
this._addSchema(this._outputDefinition);
|
|
162
|
+
this._configSchema = configSchema?.spec;
|
|
155
163
|
}
|
|
156
164
|
get allEdges() {
|
|
157
165
|
return new Set([
|
|
@@ -251,6 +259,9 @@ class StateGraph extends graph_js_1.Graph {
|
|
|
251
259
|
// create empty compiled graph
|
|
252
260
|
const compiled = new CompiledStateGraph({
|
|
253
261
|
builder: this,
|
|
262
|
+
configKeys: this._configSchema
|
|
263
|
+
? Object.keys(this._configSchema)
|
|
264
|
+
: undefined,
|
|
254
265
|
checkpointer,
|
|
255
266
|
interruptAfter,
|
|
256
267
|
interruptBefore,
|
package/dist/graph/state.d.ts
CHANGED
|
@@ -95,7 +95,7 @@ export type StateGraphArgsWithInputOutputSchemas<SD extends StateDefinition, O e
|
|
|
95
95
|
* // }
|
|
96
96
|
* ```
|
|
97
97
|
*/
|
|
98
|
-
export declare class StateGraph<SD extends StateDefinition | unknown, S = SD extends StateDefinition ? StateType<SD> : SD, U = SD extends StateDefinition ? UpdateType<SD> : Partial<S>, N extends string = typeof START, I extends StateDefinition = SD extends StateDefinition ? SD : StateDefinition, O extends StateDefinition = SD extends StateDefinition ? SD : StateDefinition> extends Graph<N, S, U, StateGraphNodeSpec<S, U>> {
|
|
98
|
+
export declare class StateGraph<SD extends StateDefinition | unknown, S = SD extends StateDefinition ? StateType<SD> : SD, U = SD extends StateDefinition ? UpdateType<SD> : Partial<S>, N extends string = typeof START, I extends StateDefinition = SD extends StateDefinition ? SD : StateDefinition, O extends StateDefinition = SD extends StateDefinition ? SD : StateDefinition, C extends StateDefinition = StateDefinition> extends Graph<N, S, U, StateGraphNodeSpec<S, U>> {
|
|
99
99
|
channels: Record<string, BaseChannel | ManagedValueSpec>;
|
|
100
100
|
waitingEdges: Set<[N[], N]>;
|
|
101
101
|
/** @internal */
|
|
@@ -109,20 +109,22 @@ export declare class StateGraph<SD extends StateDefinition | unknown, S = SD ext
|
|
|
109
109
|
* @internal
|
|
110
110
|
*/
|
|
111
111
|
_schemaDefinitions: Map<any, any>;
|
|
112
|
-
|
|
112
|
+
/** @internal */
|
|
113
|
+
_configSchema: C | undefined;
|
|
114
|
+
constructor(fields: SD extends StateDefinition ? SD | AnnotationRoot<SD> | StateGraphArgs<S> | StateGraphArgsWithStateSchema<SD, I, O> | StateGraphArgsWithInputOutputSchemas<SD, O> : StateGraphArgs<S>, configSchema?: AnnotationRoot<C>);
|
|
113
115
|
get allEdges(): Set<[string, string]>;
|
|
114
116
|
_addSchema(stateDefinition: StateDefinition): void;
|
|
115
|
-
addNode<K extends string, NodeInput = S>(key: K, action: RunnableLike<NodeInput, U extends object ? U & Record<string, any> : U>, options?: StateGraphAddNodeOptions): StateGraph<SD, S, U, N | K, I, O>;
|
|
117
|
+
addNode<K extends string, NodeInput = S>(key: K, action: RunnableLike<NodeInput, U extends object ? U & Record<string, any> : U>, options?: StateGraphAddNodeOptions): StateGraph<SD, S, U, N | K, I, O, C>;
|
|
116
118
|
addEdge(startKey: typeof START | N | N[], endKey: N | typeof END): this;
|
|
117
119
|
compile({ checkpointer, store, interruptBefore, interruptAfter, }?: {
|
|
118
120
|
checkpointer?: BaseCheckpointSaver;
|
|
119
121
|
store?: BaseStore;
|
|
120
122
|
interruptBefore?: N[] | All;
|
|
121
123
|
interruptAfter?: N[] | All;
|
|
122
|
-
}): CompiledStateGraph<S, U, N, I, O>;
|
|
124
|
+
}): CompiledStateGraph<S, U, N, I, O, C>;
|
|
123
125
|
}
|
|
124
|
-
export declare class CompiledStateGraph<S, U, N extends string = typeof START, I extends StateDefinition = StateDefinition, O extends StateDefinition = StateDefinition> extends CompiledGraph<N, S, U> {
|
|
125
|
-
builder: StateGraph<unknown, S, U, N, I, O>;
|
|
126
|
+
export declare class CompiledStateGraph<S, U, N extends string = typeof START, I extends StateDefinition = StateDefinition, O extends StateDefinition = StateDefinition, C extends StateDefinition = StateDefinition> extends CompiledGraph<N, S, U> {
|
|
127
|
+
builder: StateGraph<unknown, S, U, N, I, O, C>;
|
|
126
128
|
attachNode(key: typeof START, node?: never): void;
|
|
127
129
|
attachNode(key: N, node: StateGraphNodeSpec<S, U>): void;
|
|
128
130
|
attachEdge(start: N | N[] | "__start__", end: N | "__end__"): void;
|
package/dist/graph/state.js
CHANGED
|
@@ -75,7 +75,7 @@ const ROOT = "__root__";
|
|
|
75
75
|
* ```
|
|
76
76
|
*/
|
|
77
77
|
export class StateGraph extends Graph {
|
|
78
|
-
constructor(fields) {
|
|
78
|
+
constructor(fields, configSchema) {
|
|
79
79
|
super();
|
|
80
80
|
Object.defineProperty(this, "channels", {
|
|
81
81
|
enumerable: true,
|
|
@@ -121,6 +121,13 @@ export class StateGraph extends Graph {
|
|
|
121
121
|
writable: true,
|
|
122
122
|
value: new Map()
|
|
123
123
|
});
|
|
124
|
+
/** @internal */
|
|
125
|
+
Object.defineProperty(this, "_configSchema", {
|
|
126
|
+
enumerable: true,
|
|
127
|
+
configurable: true,
|
|
128
|
+
writable: true,
|
|
129
|
+
value: void 0
|
|
130
|
+
});
|
|
124
131
|
if (isStateGraphArgsWithInputOutputSchemas(fields)) {
|
|
125
132
|
this._schemaDefinition = fields.input.spec;
|
|
126
133
|
this._inputDefinition = fields.input.spec;
|
|
@@ -149,6 +156,7 @@ export class StateGraph extends Graph {
|
|
|
149
156
|
this._addSchema(this._schemaDefinition);
|
|
150
157
|
this._addSchema(this._inputDefinition);
|
|
151
158
|
this._addSchema(this._outputDefinition);
|
|
159
|
+
this._configSchema = configSchema?.spec;
|
|
152
160
|
}
|
|
153
161
|
get allEdges() {
|
|
154
162
|
return new Set([
|
|
@@ -248,6 +256,9 @@ export class StateGraph extends Graph {
|
|
|
248
256
|
// create empty compiled graph
|
|
249
257
|
const compiled = new CompiledStateGraph({
|
|
250
258
|
builder: this,
|
|
259
|
+
configKeys: this._configSchema
|
|
260
|
+
? Object.keys(this._configSchema)
|
|
261
|
+
: undefined,
|
|
251
262
|
checkpointer,
|
|
252
263
|
interruptAfter,
|
|
253
264
|
interruptBefore,
|
|
@@ -18,5 +18,5 @@ export interface AgentExecutorState {
|
|
|
18
18
|
export declare function createAgentExecutor({ agentRunnable, tools, }: {
|
|
19
19
|
agentRunnable: Runnable;
|
|
20
20
|
tools: Array<Tool> | ToolExecutor;
|
|
21
|
-
}): import("../graph/state.js").CompiledStateGraph<AgentExecutorState, Partial<AgentExecutorState>, "__start__" | "agent" | "action", import("../graph/annotation.js").StateDefinition, import("../graph/annotation.js").StateDefinition>;
|
|
21
|
+
}): import("../graph/state.js").CompiledStateGraph<AgentExecutorState, Partial<AgentExecutorState>, "__start__" | "agent" | "action", import("../graph/annotation.js").StateDefinition, import("../graph/annotation.js").StateDefinition, import("../graph/annotation.js").StateDefinition>;
|
|
22
22
|
export {};
|
package/dist/pregel/index.cjs
CHANGED
|
@@ -113,6 +113,12 @@ class Pregel extends runnables_1.Runnable {
|
|
|
113
113
|
writable: true,
|
|
114
114
|
value: void 0
|
|
115
115
|
});
|
|
116
|
+
Object.defineProperty(this, "configKeys", {
|
|
117
|
+
enumerable: true,
|
|
118
|
+
configurable: true,
|
|
119
|
+
writable: true,
|
|
120
|
+
value: void 0
|
|
121
|
+
});
|
|
116
122
|
Object.defineProperty(this, "autoValidate", {
|
|
117
123
|
enumerable: true,
|
|
118
124
|
configurable: true,
|
|
@@ -183,6 +189,7 @@ class Pregel extends runnables_1.Runnable {
|
|
|
183
189
|
this.streamMode = streamMode ?? this.streamMode;
|
|
184
190
|
this.inputChannels = fields.inputChannels;
|
|
185
191
|
this.outputChannels = fields.outputChannels;
|
|
192
|
+
this.configKeys = fields.configKeys;
|
|
186
193
|
this.streamChannels = fields.streamChannels ?? this.streamChannels;
|
|
187
194
|
this.interruptAfter = fields.interruptAfter;
|
|
188
195
|
this.interruptBefore = fields.interruptBefore;
|
|
@@ -425,6 +432,12 @@ class Pregel extends runnables_1.Runnable {
|
|
|
425
432
|
else {
|
|
426
433
|
defaultCheckpointer = this.checkpointer;
|
|
427
434
|
}
|
|
435
|
+
if (this.configKeys !== undefined) {
|
|
436
|
+
const newConfigurable = Object.fromEntries(Object.entries(rest.configurable ?? {}).filter(([key]) => {
|
|
437
|
+
return this.configKeys?.includes(key);
|
|
438
|
+
}));
|
|
439
|
+
rest.configurable = newConfigurable;
|
|
440
|
+
}
|
|
428
441
|
return [
|
|
429
442
|
defaultDebug,
|
|
430
443
|
defaultStreamMode,
|
package/dist/pregel/index.d.ts
CHANGED
|
@@ -45,6 +45,7 @@ export declare class Pregel<Nn extends StrRecord<string, PregelNode>, Cc extends
|
|
|
45
45
|
channels: Cc;
|
|
46
46
|
inputChannels: keyof Cc | Array<keyof Cc>;
|
|
47
47
|
outputChannels: keyof Cc | Array<keyof Cc>;
|
|
48
|
+
configKeys?: string[];
|
|
48
49
|
autoValidate: boolean;
|
|
49
50
|
streamMode: StreamMode[];
|
|
50
51
|
streamChannels?: keyof Cc | Array<keyof Cc>;
|
package/dist/pregel/index.js
CHANGED
|
@@ -109,6 +109,12 @@ export class Pregel extends Runnable {
|
|
|
109
109
|
writable: true,
|
|
110
110
|
value: void 0
|
|
111
111
|
});
|
|
112
|
+
Object.defineProperty(this, "configKeys", {
|
|
113
|
+
enumerable: true,
|
|
114
|
+
configurable: true,
|
|
115
|
+
writable: true,
|
|
116
|
+
value: void 0
|
|
117
|
+
});
|
|
112
118
|
Object.defineProperty(this, "autoValidate", {
|
|
113
119
|
enumerable: true,
|
|
114
120
|
configurable: true,
|
|
@@ -179,6 +185,7 @@ export class Pregel extends Runnable {
|
|
|
179
185
|
this.streamMode = streamMode ?? this.streamMode;
|
|
180
186
|
this.inputChannels = fields.inputChannels;
|
|
181
187
|
this.outputChannels = fields.outputChannels;
|
|
188
|
+
this.configKeys = fields.configKeys;
|
|
182
189
|
this.streamChannels = fields.streamChannels ?? this.streamChannels;
|
|
183
190
|
this.interruptAfter = fields.interruptAfter;
|
|
184
191
|
this.interruptBefore = fields.interruptBefore;
|
|
@@ -421,6 +428,12 @@ export class Pregel extends Runnable {
|
|
|
421
428
|
else {
|
|
422
429
|
defaultCheckpointer = this.checkpointer;
|
|
423
430
|
}
|
|
431
|
+
if (this.configKeys !== undefined) {
|
|
432
|
+
const newConfigurable = Object.fromEntries(Object.entries(rest.configurable ?? {}).filter(([key]) => {
|
|
433
|
+
return this.configKeys?.includes(key);
|
|
434
|
+
}));
|
|
435
|
+
rest.configurable = newConfigurable;
|
|
436
|
+
}
|
|
424
437
|
return [
|
|
425
438
|
defaultDebug,
|
|
426
439
|
defaultStreamMode,
|
package/dist/pregel/types.d.ts
CHANGED
|
@@ -26,6 +26,7 @@ export interface PregelInterface<Nn extends StrRecord<string, PregelNode>, Cc ex
|
|
|
26
26
|
streamMode?: StreamMode | StreamMode[];
|
|
27
27
|
inputChannels: keyof Cc | Array<keyof Cc>;
|
|
28
28
|
outputChannels: keyof Cc | Array<keyof Cc>;
|
|
29
|
+
configKeys?: string[];
|
|
29
30
|
/**
|
|
30
31
|
* @default []
|
|
31
32
|
*/
|