@langchain/langgraph 0.3.12 → 0.4.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.
Files changed (74) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/channels/base.cjs +1 -2
  3. package/dist/channels/base.js +1 -2
  4. package/dist/channels/base.js.map +1 -1
  5. package/dist/channels/topic.cjs +5 -5
  6. package/dist/channels/topic.js +5 -5
  7. package/dist/channels/topic.js.map +1 -1
  8. package/dist/constants.cjs +3 -3
  9. package/dist/constants.d.ts +2 -5
  10. package/dist/constants.js +2 -2
  11. package/dist/constants.js.map +1 -1
  12. package/dist/errors.cjs +1 -1
  13. package/dist/errors.js +1 -1
  14. package/dist/errors.js.map +1 -1
  15. package/dist/graph/annotation.cjs +1 -5
  16. package/dist/graph/annotation.d.ts +4 -5
  17. package/dist/graph/annotation.js +1 -5
  18. package/dist/graph/annotation.js.map +1 -1
  19. package/dist/graph/graph.cjs +1 -3
  20. package/dist/graph/graph.d.ts +3 -3
  21. package/dist/graph/graph.js +1 -3
  22. package/dist/graph/graph.js.map +1 -1
  23. package/dist/graph/state.cjs +6 -10
  24. package/dist/graph/state.d.ts +8 -8
  25. package/dist/graph/state.js +7 -11
  26. package/dist/graph/state.js.map +1 -1
  27. package/dist/interrupt.cjs +2 -13
  28. package/dist/interrupt.js +2 -13
  29. package/dist/interrupt.js.map +1 -1
  30. package/dist/prebuilt/agent_executor.d.ts +22 -1
  31. package/dist/prebuilt/agent_executor.js.map +1 -1
  32. package/dist/pregel/algo.cjs +42 -71
  33. package/dist/pregel/algo.d.ts +9 -10
  34. package/dist/pregel/algo.js +42 -71
  35. package/dist/pregel/algo.js.map +1 -1
  36. package/dist/pregel/index.cjs +56 -92
  37. package/dist/pregel/index.d.ts +12 -30
  38. package/dist/pregel/index.js +57 -93
  39. package/dist/pregel/index.js.map +1 -1
  40. package/dist/pregel/loop.cjs +25 -86
  41. package/dist/pregel/loop.d.ts +5 -11
  42. package/dist/pregel/loop.js +25 -86
  43. package/dist/pregel/loop.js.map +1 -1
  44. package/dist/pregel/remote.d.ts +9 -12
  45. package/dist/pregel/remote.js.map +1 -1
  46. package/dist/pregel/runnable_types.d.ts +15 -2
  47. package/dist/pregel/types.d.ts +23 -10
  48. package/dist/pregel/types.js.map +1 -1
  49. package/dist/pregel/utils/config.cjs +2 -0
  50. package/dist/pregel/utils/config.js +2 -0
  51. package/dist/pregel/utils/config.js.map +1 -1
  52. package/dist/pregel/validate.d.ts +2 -3
  53. package/dist/pregel/validate.js.map +1 -1
  54. package/dist/web.cjs +0 -1
  55. package/dist/web.d.ts +1 -2
  56. package/dist/web.js +0 -1
  57. package/dist/web.js.map +1 -1
  58. package/package.json +7 -6
  59. package/dist/managed/base.cjs +0 -177
  60. package/dist/managed/base.d.ts +0 -38
  61. package/dist/managed/base.js +0 -168
  62. package/dist/managed/base.js.map +0 -1
  63. package/dist/managed/index.cjs +0 -20
  64. package/dist/managed/index.d.ts +0 -3
  65. package/dist/managed/index.js +0 -4
  66. package/dist/managed/index.js.map +0 -1
  67. package/dist/managed/is_last_step.cjs +0 -12
  68. package/dist/managed/is_last_step.d.ts +0 -4
  69. package/dist/managed/is_last_step.js +0 -8
  70. package/dist/managed/is_last_step.js.map +0 -1
  71. package/dist/managed/shared_value.cjs +0 -112
  72. package/dist/managed/shared_value.d.ts +0 -24
  73. package/dist/managed/shared_value.js +0 -108
  74. package/dist/managed/shared_value.js.map +0 -1
@@ -1,177 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NoopManagedValue = exports.ManagedValueMapping = exports.ChannelKeyPlaceholder = exports.WritableManagedValue = exports.ManagedValue = void 0;
4
- exports.isManagedValue = isManagedValue;
5
- exports.isConfiguredManagedValue = isConfiguredManagedValue;
6
- const constants_js_1 = require("../constants.cjs");
7
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
8
- class ManagedValue {
9
- constructor(config, _params) {
10
- Object.defineProperty(this, "runtime", {
11
- enumerable: true,
12
- configurable: true,
13
- writable: true,
14
- value: false
15
- });
16
- Object.defineProperty(this, "config", {
17
- enumerable: true,
18
- configurable: true,
19
- writable: true,
20
- value: void 0
21
- });
22
- Object.defineProperty(this, "_promises", {
23
- enumerable: true,
24
- configurable: true,
25
- writable: true,
26
- value: []
27
- });
28
- Object.defineProperty(this, "lg_is_managed_value", {
29
- enumerable: true,
30
- configurable: true,
31
- writable: true,
32
- value: true
33
- });
34
- this.config = config;
35
- }
36
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
37
- static async initialize(_config,
38
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
39
- _args) {
40
- throw new Error("Not implemented");
41
- }
42
- async promises() {
43
- return Promise.all(this._promises);
44
- }
45
- addPromise(promise) {
46
- this._promises.push(promise);
47
- }
48
- }
49
- exports.ManagedValue = ManagedValue;
50
- class WritableManagedValue extends ManagedValue {
51
- }
52
- exports.WritableManagedValue = WritableManagedValue;
53
- exports.ChannelKeyPlaceholder = "__channel_key_placeholder__";
54
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
55
- class ManagedValueMapping extends Map {
56
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
57
- constructor(entries) {
58
- super(entries ? Array.from(entries) : undefined);
59
- }
60
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
61
- replaceRuntimeValues(step, values) {
62
- if (this.size === 0 || !values) {
63
- return;
64
- }
65
- if (Array.from(this.values()).every((mv) => !mv.runtime)) {
66
- return;
67
- }
68
- if (typeof values === "object" && !Array.isArray(values)) {
69
- for (const [key, value] of Object.entries(values)) {
70
- for (const [chan, mv] of this.entries()) {
71
- if (mv.runtime && mv.call(step) === value) {
72
- // eslint-disable-next-line no-param-reassign
73
- values[key] = { [constants_js_1.RUNTIME_PLACEHOLDER]: chan };
74
- }
75
- }
76
- }
77
- }
78
- else if (typeof values === "object" && "constructor" in values) {
79
- for (const key of Object.getOwnPropertyNames(Object.getPrototypeOf(values))) {
80
- try {
81
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
82
- const value = values[key];
83
- for (const [chan, mv] of this.entries()) {
84
- if (mv.runtime && mv.call(step) === value) {
85
- // eslint-disable-next-line @typescript-eslint/no-explicit-any, no-param-reassign
86
- values[key] = { [constants_js_1.RUNTIME_PLACEHOLDER]: chan };
87
- }
88
- }
89
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
90
- }
91
- catch (error) {
92
- // Ignore if TypeError
93
- if (error.name !== TypeError.name) {
94
- throw error;
95
- }
96
- }
97
- }
98
- }
99
- }
100
- replaceRuntimePlaceholders(step,
101
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
102
- values) {
103
- if (this.size === 0 || !values) {
104
- return;
105
- }
106
- if (Array.from(this.values()).every((mv) => !mv.runtime)) {
107
- return;
108
- }
109
- if (typeof values === "object" && !Array.isArray(values)) {
110
- for (const [key, value] of Object.entries(values)) {
111
- if (typeof value === "object" &&
112
- value !== null &&
113
- constants_js_1.RUNTIME_PLACEHOLDER in value) {
114
- const placeholder = value[constants_js_1.RUNTIME_PLACEHOLDER];
115
- if (typeof placeholder === "string") {
116
- // eslint-disable-next-line no-param-reassign
117
- values[key] = this.get(placeholder)?.call(step);
118
- }
119
- }
120
- }
121
- }
122
- else if (typeof values === "object" && "constructor" in values) {
123
- for (const key of Object.getOwnPropertyNames(Object.getPrototypeOf(values))) {
124
- try {
125
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
126
- const value = values[key];
127
- if (typeof value === "object" &&
128
- value !== null &&
129
- constants_js_1.RUNTIME_PLACEHOLDER in value) {
130
- const managedValue = this.get(value[constants_js_1.RUNTIME_PLACEHOLDER]);
131
- if (managedValue) {
132
- // eslint-disable-next-line @typescript-eslint/no-explicit-any, no-param-reassign
133
- values[key] = managedValue.call(step);
134
- }
135
- }
136
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
137
- }
138
- catch (error) {
139
- // Ignore if TypeError
140
- if (error.name !== TypeError.name) {
141
- throw error;
142
- }
143
- }
144
- }
145
- }
146
- }
147
- }
148
- exports.ManagedValueMapping = ManagedValueMapping;
149
- function isManagedValue(value) {
150
- if (typeof value === "object" && value && "lg_is_managed_value" in value) {
151
- return true;
152
- }
153
- return false;
154
- }
155
- function isConfiguredManagedValue(value) {
156
- if (typeof value === "object" &&
157
- value &&
158
- "cls" in value &&
159
- "params" in value) {
160
- return true;
161
- }
162
- return false;
163
- }
164
- /**
165
- * No-op class used when getting state values, as managed values should never be returned
166
- * in get state calls.
167
- */
168
- class NoopManagedValue extends ManagedValue {
169
- call() { }
170
- static async initialize(config,
171
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
172
- _args) {
173
- return Promise.resolve(new NoopManagedValue(config));
174
- }
175
- }
176
- exports.NoopManagedValue = NoopManagedValue;
177
- //# sourceMappingURL=base.js.map
@@ -1,38 +0,0 @@
1
- import { RunnableConfig } from "@langchain/core/runnables";
2
- export interface ManagedValueParams extends Record<string, any> {
3
- }
4
- export declare abstract class ManagedValue<Value = any> {
5
- runtime: boolean;
6
- config: RunnableConfig;
7
- private _promises;
8
- lg_is_managed_value: boolean;
9
- constructor(config: RunnableConfig, _params?: ManagedValueParams);
10
- static initialize<Value = any>(_config: RunnableConfig, _args?: any): Promise<ManagedValue<Value>>;
11
- abstract call(step: number): Value;
12
- promises(): Promise<unknown>;
13
- protected addPromise(promise: Promise<unknown>): void;
14
- }
15
- export declare abstract class WritableManagedValue<Value = any, Update = any> extends ManagedValue<Value> {
16
- abstract update(writes: Update[]): Promise<void>;
17
- }
18
- export declare const ChannelKeyPlaceholder = "__channel_key_placeholder__";
19
- export type ManagedValueSpec = typeof ManagedValue | ConfiguredManagedValue;
20
- export interface ConfiguredManagedValue<Value = any> {
21
- cls: typeof ManagedValue<Value>;
22
- params: ManagedValueParams;
23
- }
24
- export declare class ManagedValueMapping extends Map<string, ManagedValue<any>> {
25
- constructor(entries?: Iterable<[string, ManagedValue<any>]> | null);
26
- replaceRuntimeValues(step: number, values: Record<string, any> | any): void;
27
- replaceRuntimePlaceholders(step: number, values: Record<string, any> | any): void;
28
- }
29
- export declare function isManagedValue(value: unknown): value is typeof ManagedValue;
30
- export declare function isConfiguredManagedValue(value: unknown): value is ConfiguredManagedValue;
31
- /**
32
- * No-op class used when getting state values, as managed values should never be returned
33
- * in get state calls.
34
- */
35
- export declare class NoopManagedValue extends ManagedValue {
36
- call(): void;
37
- static initialize(config: RunnableConfig, _args?: any): Promise<ManagedValue>;
38
- }
@@ -1,168 +0,0 @@
1
- import { RUNTIME_PLACEHOLDER } from "../constants.js";
2
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
3
- export class ManagedValue {
4
- constructor(config, _params) {
5
- Object.defineProperty(this, "runtime", {
6
- enumerable: true,
7
- configurable: true,
8
- writable: true,
9
- value: false
10
- });
11
- Object.defineProperty(this, "config", {
12
- enumerable: true,
13
- configurable: true,
14
- writable: true,
15
- value: void 0
16
- });
17
- Object.defineProperty(this, "_promises", {
18
- enumerable: true,
19
- configurable: true,
20
- writable: true,
21
- value: []
22
- });
23
- Object.defineProperty(this, "lg_is_managed_value", {
24
- enumerable: true,
25
- configurable: true,
26
- writable: true,
27
- value: true
28
- });
29
- this.config = config;
30
- }
31
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
32
- static async initialize(_config,
33
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
34
- _args) {
35
- throw new Error("Not implemented");
36
- }
37
- async promises() {
38
- return Promise.all(this._promises);
39
- }
40
- addPromise(promise) {
41
- this._promises.push(promise);
42
- }
43
- }
44
- export class WritableManagedValue extends ManagedValue {
45
- }
46
- export const ChannelKeyPlaceholder = "__channel_key_placeholder__";
47
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
48
- export class ManagedValueMapping extends Map {
49
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
50
- constructor(entries) {
51
- super(entries ? Array.from(entries) : undefined);
52
- }
53
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
54
- replaceRuntimeValues(step, values) {
55
- if (this.size === 0 || !values) {
56
- return;
57
- }
58
- if (Array.from(this.values()).every((mv) => !mv.runtime)) {
59
- return;
60
- }
61
- if (typeof values === "object" && !Array.isArray(values)) {
62
- for (const [key, value] of Object.entries(values)) {
63
- for (const [chan, mv] of this.entries()) {
64
- if (mv.runtime && mv.call(step) === value) {
65
- // eslint-disable-next-line no-param-reassign
66
- values[key] = { [RUNTIME_PLACEHOLDER]: chan };
67
- }
68
- }
69
- }
70
- }
71
- else if (typeof values === "object" && "constructor" in values) {
72
- for (const key of Object.getOwnPropertyNames(Object.getPrototypeOf(values))) {
73
- try {
74
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
75
- const value = values[key];
76
- for (const [chan, mv] of this.entries()) {
77
- if (mv.runtime && mv.call(step) === value) {
78
- // eslint-disable-next-line @typescript-eslint/no-explicit-any, no-param-reassign
79
- values[key] = { [RUNTIME_PLACEHOLDER]: chan };
80
- }
81
- }
82
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
83
- }
84
- catch (error) {
85
- // Ignore if TypeError
86
- if (error.name !== TypeError.name) {
87
- throw error;
88
- }
89
- }
90
- }
91
- }
92
- }
93
- replaceRuntimePlaceholders(step,
94
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
95
- values) {
96
- if (this.size === 0 || !values) {
97
- return;
98
- }
99
- if (Array.from(this.values()).every((mv) => !mv.runtime)) {
100
- return;
101
- }
102
- if (typeof values === "object" && !Array.isArray(values)) {
103
- for (const [key, value] of Object.entries(values)) {
104
- if (typeof value === "object" &&
105
- value !== null &&
106
- RUNTIME_PLACEHOLDER in value) {
107
- const placeholder = value[RUNTIME_PLACEHOLDER];
108
- if (typeof placeholder === "string") {
109
- // eslint-disable-next-line no-param-reassign
110
- values[key] = this.get(placeholder)?.call(step);
111
- }
112
- }
113
- }
114
- }
115
- else if (typeof values === "object" && "constructor" in values) {
116
- for (const key of Object.getOwnPropertyNames(Object.getPrototypeOf(values))) {
117
- try {
118
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
119
- const value = values[key];
120
- if (typeof value === "object" &&
121
- value !== null &&
122
- RUNTIME_PLACEHOLDER in value) {
123
- const managedValue = this.get(value[RUNTIME_PLACEHOLDER]);
124
- if (managedValue) {
125
- // eslint-disable-next-line @typescript-eslint/no-explicit-any, no-param-reassign
126
- values[key] = managedValue.call(step);
127
- }
128
- }
129
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
130
- }
131
- catch (error) {
132
- // Ignore if TypeError
133
- if (error.name !== TypeError.name) {
134
- throw error;
135
- }
136
- }
137
- }
138
- }
139
- }
140
- }
141
- export function isManagedValue(value) {
142
- if (typeof value === "object" && value && "lg_is_managed_value" in value) {
143
- return true;
144
- }
145
- return false;
146
- }
147
- export function isConfiguredManagedValue(value) {
148
- if (typeof value === "object" &&
149
- value &&
150
- "cls" in value &&
151
- "params" in value) {
152
- return true;
153
- }
154
- return false;
155
- }
156
- /**
157
- * No-op class used when getting state values, as managed values should never be returned
158
- * in get state calls.
159
- */
160
- export class NoopManagedValue extends ManagedValue {
161
- call() { }
162
- static async initialize(config,
163
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
164
- _args) {
165
- return Promise.resolve(new NoopManagedValue(config));
166
- }
167
- }
168
- //# sourceMappingURL=base.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/managed/base.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAKtD,8DAA8D;AAC9D,MAAM,OAAgB,YAAY;IAShC,YAAY,MAAsB,EAAE,OAA4B;QARhE;;;;mBAAmB,KAAK;WAAC;QAEzB;;;;;WAAuB;QAEf;;;;mBAAgC,EAAE;WAAC;QAE3C;;;;mBAAsB,IAAI;WAAC;QAGzB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,8DAA8D;IAC9D,MAAM,CAAC,KAAK,CAAC,UAAU,CACrB,OAAuB;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Y,EAAE,CAAC;4BACjB,iFAAiF;4BAChF,MAAc,CAAC,GAAG,CAAC,GAAG,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;wBACjD,CAAC;oBACH,CAAC;oBACD,8DAA8D;gBAChE,CAAC;gBAAC,OAAO,KAAU,EAAE,CAAC;oBACpB,sBAAsB;oBACtB,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,IAAI,EAAE,CAAC;wBAClC,MAAM,KAAK,CAAC;oBACd,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;CACF;AAED,MAAM,UAAU,cAAc,CAAC,KAAc;IAC3C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,IAAI,qBAAqB,IAAI,KAAK,EAAE,CAAC;QACzE,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,wBAAwB,CACtC,KAAc;IAEd,IACE,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK;QACL,KAAK,IAAI,KAAK;QACd,QAAQ,IAAI,KAAK,EACjB,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;GAGG;AACH,MAAM,OAAO,gBAAiB,SAAQ,YAAY;IAChD,IAAI,KAAI,CAAC;IAET,MAAM,CAAC,KAAK,CAAC,UAAU,CACrB,MAAsB;IACtB,8DAA8D;IAC9D,KAAW;QAEX,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC;IACvD,CAAC;CACF"}
@@ -1,20 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./base.cjs"), exports);
18
- __exportStar(require("./is_last_step.cjs"), exports);
19
- __exportStar(require("./shared_value.cjs"), exports);
20
- //# sourceMappingURL=index.js.map
@@ -1,3 +0,0 @@
1
- export * from "./base.js";
2
- export * from "./is_last_step.js";
3
- export * from "./shared_value.js";
@@ -1,4 +0,0 @@
1
- export * from "./base.js";
2
- export * from "./is_last_step.js";
3
- export * from "./shared_value.js";
4
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/managed/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC"}
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.IsLastStepManager = void 0;
4
- const constants_js_1 = require("../constants.cjs");
5
- const base_js_1 = require("./base.cjs");
6
- class IsLastStepManager extends base_js_1.ManagedValue {
7
- call(step) {
8
- return step === (this.config.recursionLimit ?? constants_js_1.RECURSION_LIMIT_DEFAULT) - 1;
9
- }
10
- }
11
- exports.IsLastStepManager = IsLastStepManager;
12
- //# sourceMappingURL=is_last_step.js.map
@@ -1,4 +0,0 @@
1
- import { ManagedValue } from "./base.js";
2
- export declare class IsLastStepManager extends ManagedValue<boolean> {
3
- call(step: number): boolean;
4
- }
@@ -1,8 +0,0 @@
1
- import { RECURSION_LIMIT_DEFAULT } from "../constants.js";
2
- import { ManagedValue } from "./base.js";
3
- export class IsLastStepManager extends ManagedValue {
4
- call(step) {
5
- return step === (this.config.recursionLimit ?? RECURSION_LIMIT_DEFAULT) - 1;
6
- }
7
- }
8
- //# sourceMappingURL=is_last_step.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"is_last_step.js","sourceRoot":"","sources":["../../src/managed/is_last_step.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC,MAAM,OAAO,iBAAkB,SAAQ,YAAqB;IAC1D,IAAI,CAAC,IAAY;QACf,OAAO,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,cAAc,IAAI,uBAAuB,CAAC,GAAG,CAAC,CAAC;IAC9E,CAAC;CACF"}
@@ -1,112 +0,0 @@
1
- "use strict";
2
- /* eslint-disable @typescript-eslint/no-explicit-any */
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.SharedValue = void 0;
5
- const base_js_1 = require("./base.cjs");
6
- const errors_js_1 = require("../errors.cjs");
7
- class SharedValue extends base_js_1.WritableManagedValue {
8
- constructor(config, params) {
9
- super(config, params);
10
- Object.defineProperty(this, "scope", {
11
- enumerable: true,
12
- configurable: true,
13
- writable: true,
14
- value: void 0
15
- });
16
- Object.defineProperty(this, "store", {
17
- enumerable: true,
18
- configurable: true,
19
- writable: true,
20
- value: void 0
21
- });
22
- Object.defineProperty(this, "ns", {
23
- enumerable: true,
24
- configurable: true,
25
- writable: true,
26
- value: void 0
27
- });
28
- Object.defineProperty(this, "value", {
29
- enumerable: true,
30
- configurable: true,
31
- writable: true,
32
- value: {}
33
- });
34
- this.scope = params.scope;
35
- this.store = config.store || null;
36
- if (!this.store) {
37
- this.ns = null;
38
- }
39
- else if (config.configurable?.[this.scope]) {
40
- const scopeValue = config.configurable[this.scope];
41
- const scopedValueString = typeof scopeValue === "string"
42
- ? scopeValue
43
- : JSON.stringify(scopeValue);
44
- this.ns = ["scoped", this.scope, params.key, scopedValueString];
45
- }
46
- else {
47
- throw new Error(`Required scope "${this.scope}" for shared state key was not passed in "config.configurable".`);
48
- }
49
- }
50
- static async initialize(config, args) {
51
- const instance = new this(config, args);
52
- await instance.loadStore();
53
- return instance;
54
- }
55
- static on(scope) {
56
- return {
57
- cls: SharedValue,
58
- params: {
59
- scope,
60
- key: base_js_1.ChannelKeyPlaceholder,
61
- },
62
- };
63
- }
64
- call(_step) {
65
- return { ...this.value };
66
- }
67
- processUpdate(values) {
68
- const writes = [];
69
- for (const vv of values) {
70
- for (const [k, v] of Object.entries(vv)) {
71
- if (v === null) {
72
- if (k in this.value) {
73
- delete this.value[k];
74
- if (this.ns) {
75
- writes.push({ namespace: this.ns, key: k, value: null });
76
- }
77
- }
78
- }
79
- else if (typeof v !== "object" || v === null) {
80
- throw new errors_js_1.InvalidUpdateError("Received a non-object value");
81
- }
82
- else {
83
- this.value[k] = v;
84
- if (this.ns) {
85
- writes.push({ namespace: this.ns, key: k, value: v });
86
- }
87
- }
88
- }
89
- }
90
- return writes;
91
- }
92
- async update(values) {
93
- if (!this.store) {
94
- this.processUpdate(values);
95
- }
96
- else {
97
- await this.store.batch(this.processUpdate(values));
98
- }
99
- }
100
- async loadStore() {
101
- if (this.store && this.ns) {
102
- const saved = await this.store.search(this.ns);
103
- this.value = saved.reduce((acc, item) => {
104
- acc[item.key] = item.value;
105
- return acc;
106
- }, {});
107
- }
108
- return false;
109
- }
110
- }
111
- exports.SharedValue = SharedValue;
112
- //# sourceMappingURL=shared_value.js.map
@@ -1,24 +0,0 @@
1
- import { RunnableConfig } from "@langchain/core/runnables";
2
- import { BaseStore } from "@langchain/langgraph-checkpoint";
3
- import { ConfiguredManagedValue, ManagedValue, ManagedValueParams, WritableManagedValue } from "./base.js";
4
- import { LangGraphRunnableConfig } from "../pregel/runnable_types.js";
5
- type Value = Record<string, Record<string, any>>;
6
- type Update = Record<string, Record<string, any> | null>;
7
- export interface SharedValueParams extends ManagedValueParams {
8
- scope: string;
9
- key: string;
10
- }
11
- export declare class SharedValue extends WritableManagedValue<Value, Update> {
12
- scope: string;
13
- store: BaseStore | null;
14
- ns: ["scoped", string, string, any] | null;
15
- value: Value;
16
- constructor(config: LangGraphRunnableConfig, params: SharedValueParams);
17
- static initialize<Value = any>(config: RunnableConfig, args: SharedValueParams): Promise<ManagedValue<Value>>;
18
- static on(scope: string): ConfiguredManagedValue<Value>;
19
- call(_step: number): Value;
20
- private processUpdate;
21
- update(values: Update[]): Promise<void>;
22
- private loadStore;
23
- }
24
- export {};