@langchain/langgraph 1.2.1 → 1.2.3
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/channels/any_value.cjs +3 -4
- package/dist/channels/any_value.cjs.map +1 -1
- package/dist/channels/any_value.js +1 -2
- package/dist/channels/any_value.js.map +1 -1
- package/dist/channels/base.cjs +2 -3
- package/dist/channels/base.cjs.map +1 -1
- package/dist/channels/base.js +1 -2
- package/dist/channels/base.js.map +1 -1
- package/dist/channels/binop.cjs +4 -5
- package/dist/channels/binop.cjs.map +1 -1
- package/dist/channels/binop.js +1 -2
- package/dist/channels/binop.js.map +1 -1
- package/dist/channels/dynamic_barrier_value.cjs +4 -5
- package/dist/channels/dynamic_barrier_value.cjs.map +1 -1
- package/dist/channels/dynamic_barrier_value.js +1 -2
- package/dist/channels/dynamic_barrier_value.js.map +1 -1
- package/dist/channels/ephemeral_value.cjs +3 -4
- package/dist/channels/ephemeral_value.cjs.map +1 -1
- package/dist/channels/ephemeral_value.js +1 -2
- package/dist/channels/ephemeral_value.js.map +1 -1
- package/dist/channels/index.cjs +11 -12
- package/dist/channels/index.js +1 -2
- package/dist/channels/last_value.cjs +3 -4
- package/dist/channels/last_value.cjs.map +1 -1
- package/dist/channels/last_value.js +1 -2
- package/dist/channels/last_value.js.map +1 -1
- package/dist/channels/named_barrier_value.cjs +3 -4
- package/dist/channels/named_barrier_value.cjs.map +1 -1
- package/dist/channels/named_barrier_value.js +1 -2
- package/dist/channels/named_barrier_value.js.map +1 -1
- package/dist/channels/topic.cjs +3 -4
- package/dist/channels/topic.cjs.map +1 -1
- package/dist/channels/topic.js +1 -2
- package/dist/channels/topic.js.map +1 -1
- package/dist/channels/untracked_value.cjs +3 -4
- package/dist/channels/untracked_value.cjs.map +1 -1
- package/dist/channels/untracked_value.js +1 -2
- package/dist/channels/untracked_value.js.map +1 -1
- package/dist/constants.cjs +4 -9
- package/dist/constants.cjs.map +1 -1
- package/dist/constants.js +5 -7
- package/dist/constants.js.map +1 -1
- package/dist/errors.cjs +1 -2
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.js +1 -1
- package/dist/errors.js.map +1 -1
- package/dist/func/index.cjs +9 -10
- package/dist/func/index.cjs.map +1 -1
- package/dist/func/index.js +1 -2
- package/dist/func/index.js.map +1 -1
- package/dist/graph/annotation.cjs +3 -4
- package/dist/graph/annotation.cjs.map +1 -1
- package/dist/graph/annotation.js +1 -2
- package/dist/graph/annotation.js.map +1 -1
- package/dist/graph/graph.cjs +23 -24
- package/dist/graph/graph.cjs.map +1 -1
- package/dist/graph/graph.js +16 -17
- package/dist/graph/graph.js.map +1 -1
- package/dist/graph/index.cjs +6 -6
- package/dist/graph/index.js +7 -8
- package/dist/graph/message.cjs +4 -5
- package/dist/graph/message.cjs.map +1 -1
- package/dist/graph/message.js +1 -2
- package/dist/graph/message.js.map +1 -1
- package/dist/graph/messages_annotation.cjs +4 -5
- package/dist/graph/messages_annotation.cjs.map +1 -1
- package/dist/graph/messages_annotation.d.ts +0 -1
- package/dist/graph/messages_annotation.d.ts.map +1 -1
- package/dist/graph/messages_annotation.js +1 -2
- package/dist/graph/messages_annotation.js.map +1 -1
- package/dist/graph/messages_reducer.cjs +2 -3
- package/dist/graph/messages_reducer.cjs.map +1 -1
- package/dist/graph/messages_reducer.js +2 -3
- package/dist/graph/messages_reducer.js.map +1 -1
- package/dist/graph/state.cjs +24 -25
- package/dist/graph/state.cjs.map +1 -1
- package/dist/graph/state.js +10 -11
- package/dist/graph/state.js.map +1 -1
- package/dist/graph/types.cjs +4 -5
- package/dist/graph/types.cjs.map +1 -1
- package/dist/graph/types.js +2 -3
- package/dist/graph/types.js.map +1 -1
- package/dist/graph/zod/index.cjs +5 -6
- package/dist/graph/zod/index.d.cts +0 -1
- package/dist/graph/zod/index.d.ts +0 -1
- package/dist/graph/zod/index.js +1 -2
- package/dist/graph/zod/meta.cjs +4 -5
- package/dist/graph/zod/meta.cjs.map +1 -1
- package/dist/graph/zod/meta.js +2 -3
- package/dist/graph/zod/meta.js.map +1 -1
- package/dist/graph/zod/plugin.cjs +2 -3
- package/dist/graph/zod/plugin.cjs.map +1 -1
- package/dist/graph/zod/plugin.js +2 -3
- package/dist/graph/zod/plugin.js.map +1 -1
- package/dist/graph/zod/schema.cjs +5 -6
- package/dist/graph/zod/schema.cjs.map +1 -1
- package/dist/graph/zod/schema.js +4 -5
- package/dist/graph/zod/schema.js.map +1 -1
- package/dist/graph/zod/zod-registry.cjs +2 -3
- package/dist/graph/zod/zod-registry.cjs.map +1 -1
- package/dist/graph/zod/zod-registry.js +1 -2
- package/dist/graph/zod/zod-registry.js.map +1 -1
- package/dist/hash.cjs +1 -2
- package/dist/hash.cjs.map +1 -1
- package/dist/hash.js +1 -1
- package/dist/index.cjs +60 -61
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/dist/interrupt.cjs +7 -8
- package/dist/interrupt.cjs.map +1 -1
- package/dist/interrupt.js +5 -6
- package/dist/interrupt.js.map +1 -1
- package/dist/prebuilt/agentName.cjs +1 -2
- package/dist/prebuilt/agentName.cjs.map +1 -1
- package/dist/prebuilt/agentName.js +1 -2
- package/dist/prebuilt/agentName.js.map +1 -1
- package/dist/prebuilt/agent_executor.cjs +4 -5
- package/dist/prebuilt/agent_executor.cjs.map +1 -1
- package/dist/prebuilt/agent_executor.d.ts +0 -1
- package/dist/prebuilt/agent_executor.d.ts.map +1 -1
- package/dist/prebuilt/agent_executor.js +1 -2
- package/dist/prebuilt/agent_executor.js.map +1 -1
- package/dist/prebuilt/chat_agent_executor.cjs +4 -5
- package/dist/prebuilt/chat_agent_executor.cjs.map +1 -1
- package/dist/prebuilt/chat_agent_executor.js +1 -2
- package/dist/prebuilt/chat_agent_executor.js.map +1 -1
- package/dist/prebuilt/index.cjs +8 -9
- package/dist/prebuilt/index.js +1 -2
- package/dist/prebuilt/react_agent_executor.cjs +8 -9
- package/dist/prebuilt/react_agent_executor.cjs.map +1 -1
- package/dist/prebuilt/react_agent_executor.d.ts +0 -2
- package/dist/prebuilt/react_agent_executor.d.ts.map +1 -1
- package/dist/prebuilt/react_agent_executor.js +1 -2
- package/dist/prebuilt/react_agent_executor.js.map +1 -1
- package/dist/prebuilt/tool_executor.cjs +1 -2
- package/dist/prebuilt/tool_executor.cjs.map +1 -1
- package/dist/prebuilt/tool_executor.js +1 -2
- package/dist/prebuilt/tool_executor.js.map +1 -1
- package/dist/prebuilt/tool_node.cjs +4 -5
- package/dist/prebuilt/tool_node.cjs.map +1 -1
- package/dist/prebuilt/tool_node.js +1 -2
- package/dist/prebuilt/tool_node.js.map +1 -1
- package/dist/pregel/algo.cjs +30 -31
- package/dist/pregel/algo.cjs.map +1 -1
- package/dist/pregel/algo.d.ts +0 -5
- package/dist/pregel/algo.d.ts.map +1 -1
- package/dist/pregel/algo.js +23 -24
- package/dist/pregel/algo.js.map +1 -1
- package/dist/pregel/call.cjs +5 -6
- package/dist/pregel/call.cjs.map +1 -1
- package/dist/pregel/call.js +2 -3
- package/dist/pregel/call.js.map +1 -1
- package/dist/pregel/debug.cjs +10 -11
- package/dist/pregel/debug.cjs.map +1 -1
- package/dist/pregel/debug.js +8 -9
- package/dist/pregel/debug.js.map +1 -1
- package/dist/pregel/index.cjs +47 -48
- package/dist/pregel/index.cjs.map +1 -1
- package/dist/pregel/index.js +28 -29
- package/dist/pregel/index.js.map +1 -1
- package/dist/pregel/io.cjs +7 -8
- package/dist/pregel/io.cjs.map +1 -1
- package/dist/pregel/io.js +5 -6
- package/dist/pregel/io.js.map +1 -1
- package/dist/pregel/loop.cjs +29 -30
- package/dist/pregel/loop.cjs.map +1 -1
- package/dist/pregel/loop.js +20 -21
- package/dist/pregel/loop.js.map +1 -1
- package/dist/pregel/messages.cjs +4 -5
- package/dist/pregel/messages.cjs.map +1 -1
- package/dist/pregel/messages.js +4 -5
- package/dist/pregel/messages.js.map +1 -1
- package/dist/pregel/read.cjs +4 -5
- package/dist/pregel/read.cjs.map +1 -1
- package/dist/pregel/read.d.ts +0 -1
- package/dist/pregel/read.d.ts.map +1 -1
- package/dist/pregel/read.js +1 -2
- package/dist/pregel/read.js.map +1 -1
- package/dist/pregel/remote.cjs +9 -10
- package/dist/pregel/remote.cjs.map +1 -1
- package/dist/pregel/remote.d.ts +0 -2
- package/dist/pregel/remote.d.ts.map +1 -1
- package/dist/pregel/remote.js +7 -8
- package/dist/pregel/remote.js.map +1 -1
- package/dist/pregel/retry.cjs +8 -14
- package/dist/pregel/retry.cjs.map +1 -1
- package/dist/pregel/retry.js +4 -10
- package/dist/pregel/retry.js.map +1 -1
- package/dist/pregel/runner.cjs +8 -9
- package/dist/pregel/runner.cjs.map +1 -1
- package/dist/pregel/runner.js +4 -5
- package/dist/pregel/runner.js.map +1 -1
- package/dist/pregel/stream.cjs +3 -4
- package/dist/pregel/stream.cjs.map +1 -1
- package/dist/pregel/stream.d.ts +0 -1
- package/dist/pregel/stream.js +3 -4
- package/dist/pregel/stream.js.map +1 -1
- package/dist/pregel/types.cjs +1 -2
- package/dist/pregel/types.cjs.map +1 -1
- package/dist/pregel/types.js +1 -1
- package/dist/pregel/types.js.map +1 -1
- package/dist/pregel/utils/config.cjs +6 -7
- package/dist/pregel/utils/config.cjs.map +1 -1
- package/dist/pregel/utils/config.js +6 -7
- package/dist/pregel/utils/config.js.map +1 -1
- package/dist/pregel/utils/index.cjs +2 -3
- package/dist/pregel/utils/index.cjs.map +1 -1
- package/dist/pregel/utils/index.js +1 -2
- package/dist/pregel/utils/index.js.map +1 -1
- package/dist/pregel/utils/subgraph.cjs +1 -2
- package/dist/pregel/utils/subgraph.cjs.map +1 -1
- package/dist/pregel/utils/subgraph.js +1 -1
- package/dist/pregel/validate.cjs +4 -5
- package/dist/pregel/validate.cjs.map +1 -1
- package/dist/pregel/validate.js +2 -3
- package/dist/pregel/validate.js.map +1 -1
- package/dist/pregel/write.cjs +5 -8
- package/dist/pregel/write.cjs.map +1 -1
- package/dist/pregel/write.js +2 -5
- package/dist/pregel/write.js.map +1 -1
- package/dist/remote.cjs +3 -4
- package/dist/remote.js +1 -2
- package/dist/setup/async_local_storage.cjs +1 -2
- package/dist/setup/async_local_storage.cjs.map +1 -1
- package/dist/setup/async_local_storage.js +1 -2
- package/dist/setup/async_local_storage.js.map +1 -1
- package/dist/state/adapter.cjs +2 -3
- package/dist/state/adapter.cjs.map +1 -1
- package/dist/state/adapter.js +1 -2
- package/dist/state/adapter.js.map +1 -1
- package/dist/state/index.cjs +8 -8
- package/dist/state/index.d.ts +1 -2
- package/dist/state/index.js +7 -8
- package/dist/state/prebuilt/index.cjs +1 -1
- package/dist/state/prebuilt/index.js +2 -3
- package/dist/state/prebuilt/messages.cjs +3 -4
- package/dist/state/prebuilt/messages.cjs.map +1 -1
- package/dist/state/prebuilt/messages.js +3 -7
- package/dist/state/prebuilt/messages.js.map +1 -1
- package/dist/state/schema.cjs +16 -12
- package/dist/state/schema.cjs.map +1 -1
- package/dist/state/schema.d.cts.map +1 -1
- package/dist/state/schema.d.ts +0 -1
- package/dist/state/schema.d.ts.map +1 -1
- package/dist/state/schema.js +8 -4
- package/dist/state/schema.js.map +1 -1
- package/dist/state/types.cjs +1 -2
- package/dist/state/types.cjs.map +1 -1
- package/dist/state/types.js +1 -1
- package/dist/state/values/index.cjs +2 -2
- package/dist/state/values/index.js +3 -4
- package/dist/state/values/reduced.cjs +1 -2
- package/dist/state/values/reduced.cjs.map +1 -1
- package/dist/state/values/reduced.js +1 -1
- package/dist/state/values/reduced.js.map +1 -1
- package/dist/state/values/untracked.cjs +1 -2
- package/dist/state/values/untracked.cjs.map +1 -1
- package/dist/state/values/untracked.js +1 -1
- package/dist/state/values/untracked.js.map +1 -1
- package/dist/utils.cjs +2 -3
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.js +1 -2
- package/dist/utils.js.map +1 -1
- package/dist/web.cjs +58 -59
- package/dist/web.d.ts +0 -3
- package/dist/web.js +1 -2
- package/dist/writer.cjs +1 -2
- package/dist/writer.cjs.map +1 -1
- package/dist/writer.js +1 -2
- package/dist/writer.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
const require_errors = require(
|
|
2
|
-
const require_base = require(
|
|
3
|
-
|
|
1
|
+
const require_errors = require("../errors.cjs");
|
|
2
|
+
const require_base = require("./base.cjs");
|
|
4
3
|
//#region src/channels/any_value.ts
|
|
5
4
|
/**
|
|
6
5
|
* Stores the last value received, assumes that if multiple values are received, they are all equal.
|
|
@@ -40,7 +39,7 @@ var AnyValue = class AnyValue extends require_base.BaseChannel {
|
|
|
40
39
|
return this.value.length !== 0;
|
|
41
40
|
}
|
|
42
41
|
};
|
|
43
|
-
|
|
44
42
|
//#endregion
|
|
45
43
|
exports.AnyValue = AnyValue;
|
|
44
|
+
|
|
46
45
|
//# sourceMappingURL=any_value.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"any_value.cjs","names":["BaseChannel","EmptyChannelError"],"sources":["../../src/channels/any_value.ts"],"sourcesContent":["import { EmptyChannelError } from \"../errors.js\";\nimport { BaseChannel } from \"./base.js\";\n\n/**\n * Stores the last value received, assumes that if multiple values are received, they are all equal.\n *\n * Note: Unlike 'LastValue' if multiple nodes write to this channel in a single step, the values\n * will be continuously overwritten.\n */\nexport class AnyValue<Value> extends BaseChannel<Value, Value, Value> {\n lc_graph_name = \"AnyValue\";\n\n // value is an array so we don't misinterpret an update to undefined as no write\n value: [Value] | [] = [];\n\n constructor() {\n super();\n }\n\n fromCheckpoint(checkpoint?: Value) {\n const empty = new AnyValue<Value>();\n if (typeof checkpoint !== \"undefined\") {\n empty.value = [checkpoint];\n }\n return empty as this;\n }\n\n update(values: Value[]): boolean {\n if (values.length === 0) {\n const updated = this.value.length > 0;\n this.value = [];\n return updated;\n }\n\n // eslint-disable-next-line prefer-destructuring\n this.value = [values[values.length - 1]];\n return false;\n }\n\n get(): Value {\n if (this.value.length === 0) {\n throw new EmptyChannelError();\n }\n return this.value[0];\n }\n\n checkpoint(): Value {\n if (this.value.length === 0) {\n throw new EmptyChannelError();\n }\n return this.value[0];\n }\n\n isAvailable(): boolean {\n return this.value.length !== 0;\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"any_value.cjs","names":["BaseChannel","EmptyChannelError"],"sources":["../../src/channels/any_value.ts"],"sourcesContent":["import { EmptyChannelError } from \"../errors.js\";\nimport { BaseChannel } from \"./base.js\";\n\n/**\n * Stores the last value received, assumes that if multiple values are received, they are all equal.\n *\n * Note: Unlike 'LastValue' if multiple nodes write to this channel in a single step, the values\n * will be continuously overwritten.\n */\nexport class AnyValue<Value> extends BaseChannel<Value, Value, Value> {\n lc_graph_name = \"AnyValue\";\n\n // value is an array so we don't misinterpret an update to undefined as no write\n value: [Value] | [] = [];\n\n constructor() {\n super();\n }\n\n fromCheckpoint(checkpoint?: Value) {\n const empty = new AnyValue<Value>();\n if (typeof checkpoint !== \"undefined\") {\n empty.value = [checkpoint];\n }\n return empty as this;\n }\n\n update(values: Value[]): boolean {\n if (values.length === 0) {\n const updated = this.value.length > 0;\n this.value = [];\n return updated;\n }\n\n // eslint-disable-next-line prefer-destructuring\n this.value = [values[values.length - 1]];\n return false;\n }\n\n get(): Value {\n if (this.value.length === 0) {\n throw new EmptyChannelError();\n }\n return this.value[0];\n }\n\n checkpoint(): Value {\n if (this.value.length === 0) {\n throw new EmptyChannelError();\n }\n return this.value[0];\n }\n\n isAvailable(): boolean {\n return this.value.length !== 0;\n }\n}\n"],"mappings":";;;;;;;;;AASA,IAAa,WAAb,MAAa,iBAAwBA,aAAAA,YAAiC;CACpE,gBAAgB;CAGhB,QAAsB,EAAE;CAExB,cAAc;AACZ,SAAO;;CAGT,eAAe,YAAoB;EACjC,MAAM,QAAQ,IAAI,UAAiB;AACnC,MAAI,OAAO,eAAe,YACxB,OAAM,QAAQ,CAAC,WAAW;AAE5B,SAAO;;CAGT,OAAO,QAA0B;AAC/B,MAAI,OAAO,WAAW,GAAG;GACvB,MAAM,UAAU,KAAK,MAAM,SAAS;AACpC,QAAK,QAAQ,EAAE;AACf,UAAO;;AAIT,OAAK,QAAQ,CAAC,OAAO,OAAO,SAAS,GAAG;AACxC,SAAO;;CAGT,MAAa;AACX,MAAI,KAAK,MAAM,WAAW,EACxB,OAAM,IAAIC,eAAAA,mBAAmB;AAE/B,SAAO,KAAK,MAAM;;CAGpB,aAAoB;AAClB,MAAI,KAAK,MAAM,WAAW,EACxB,OAAM,IAAIA,eAAAA,mBAAmB;AAE/B,SAAO,KAAK,MAAM;;CAGpB,cAAuB;AACrB,SAAO,KAAK,MAAM,WAAW"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { EmptyChannelError } from "../errors.js";
|
|
2
2
|
import { BaseChannel } from "./base.js";
|
|
3
|
-
|
|
4
3
|
//#region src/channels/any_value.ts
|
|
5
4
|
/**
|
|
6
5
|
* Stores the last value received, assumes that if multiple values are received, they are all equal.
|
|
@@ -40,7 +39,7 @@ var AnyValue = class AnyValue extends BaseChannel {
|
|
|
40
39
|
return this.value.length !== 0;
|
|
41
40
|
}
|
|
42
41
|
};
|
|
43
|
-
|
|
44
42
|
//#endregion
|
|
45
43
|
export { AnyValue };
|
|
44
|
+
|
|
46
45
|
//# sourceMappingURL=any_value.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"any_value.js","names":[],"sources":["../../src/channels/any_value.ts"],"sourcesContent":["import { EmptyChannelError } from \"../errors.js\";\nimport { BaseChannel } from \"./base.js\";\n\n/**\n * Stores the last value received, assumes that if multiple values are received, they are all equal.\n *\n * Note: Unlike 'LastValue' if multiple nodes write to this channel in a single step, the values\n * will be continuously overwritten.\n */\nexport class AnyValue<Value> extends BaseChannel<Value, Value, Value> {\n lc_graph_name = \"AnyValue\";\n\n // value is an array so we don't misinterpret an update to undefined as no write\n value: [Value] | [] = [];\n\n constructor() {\n super();\n }\n\n fromCheckpoint(checkpoint?: Value) {\n const empty = new AnyValue<Value>();\n if (typeof checkpoint !== \"undefined\") {\n empty.value = [checkpoint];\n }\n return empty as this;\n }\n\n update(values: Value[]): boolean {\n if (values.length === 0) {\n const updated = this.value.length > 0;\n this.value = [];\n return updated;\n }\n\n // eslint-disable-next-line prefer-destructuring\n this.value = [values[values.length - 1]];\n return false;\n }\n\n get(): Value {\n if (this.value.length === 0) {\n throw new EmptyChannelError();\n }\n return this.value[0];\n }\n\n checkpoint(): Value {\n if (this.value.length === 0) {\n throw new EmptyChannelError();\n }\n return this.value[0];\n }\n\n isAvailable(): boolean {\n return this.value.length !== 0;\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"any_value.js","names":[],"sources":["../../src/channels/any_value.ts"],"sourcesContent":["import { EmptyChannelError } from \"../errors.js\";\nimport { BaseChannel } from \"./base.js\";\n\n/**\n * Stores the last value received, assumes that if multiple values are received, they are all equal.\n *\n * Note: Unlike 'LastValue' if multiple nodes write to this channel in a single step, the values\n * will be continuously overwritten.\n */\nexport class AnyValue<Value> extends BaseChannel<Value, Value, Value> {\n lc_graph_name = \"AnyValue\";\n\n // value is an array so we don't misinterpret an update to undefined as no write\n value: [Value] | [] = [];\n\n constructor() {\n super();\n }\n\n fromCheckpoint(checkpoint?: Value) {\n const empty = new AnyValue<Value>();\n if (typeof checkpoint !== \"undefined\") {\n empty.value = [checkpoint];\n }\n return empty as this;\n }\n\n update(values: Value[]): boolean {\n if (values.length === 0) {\n const updated = this.value.length > 0;\n this.value = [];\n return updated;\n }\n\n // eslint-disable-next-line prefer-destructuring\n this.value = [values[values.length - 1]];\n return false;\n }\n\n get(): Value {\n if (this.value.length === 0) {\n throw new EmptyChannelError();\n }\n return this.value[0];\n }\n\n checkpoint(): Value {\n if (this.value.length === 0) {\n throw new EmptyChannelError();\n }\n return this.value[0];\n }\n\n isAvailable(): boolean {\n return this.value.length !== 0;\n }\n}\n"],"mappings":";;;;;;;;;AASA,IAAa,WAAb,MAAa,iBAAwB,YAAiC;CACpE,gBAAgB;CAGhB,QAAsB,EAAE;CAExB,cAAc;AACZ,SAAO;;CAGT,eAAe,YAAoB;EACjC,MAAM,QAAQ,IAAI,UAAiB;AACnC,MAAI,OAAO,eAAe,YACxB,OAAM,QAAQ,CAAC,WAAW;AAE5B,SAAO;;CAGT,OAAO,QAA0B;AAC/B,MAAI,OAAO,WAAW,GAAG;GACvB,MAAM,UAAU,KAAK,MAAM,SAAS;AACpC,QAAK,QAAQ,EAAE;AACf,UAAO;;AAIT,OAAK,QAAQ,CAAC,OAAO,OAAO,SAAS,GAAG;AACxC,SAAO;;CAGT,MAAa;AACX,MAAI,KAAK,MAAM,WAAW,EACxB,OAAM,IAAI,mBAAmB;AAE/B,SAAO,KAAK,MAAM;;CAGpB,aAAoB;AAClB,MAAI,KAAK,MAAM,WAAW,EACxB,OAAM,IAAI,mBAAmB;AAE/B,SAAO,KAAK,MAAM;;CAGpB,cAAuB;AACrB,SAAO,KAAK,MAAM,WAAW"}
|
package/dist/channels/base.cjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
const require_errors = require(
|
|
1
|
+
const require_errors = require("../errors.cjs");
|
|
2
2
|
let _langchain_langgraph_checkpoint = require("@langchain/langgraph-checkpoint");
|
|
3
|
-
|
|
4
3
|
//#region src/channels/base.ts
|
|
5
4
|
function isBaseChannel(obj) {
|
|
6
5
|
return obj != null && obj.lg_is_channel === true;
|
|
@@ -102,11 +101,11 @@ function createCheckpoint(checkpoint, channels, step, options) {
|
|
|
102
101
|
versions_seen: checkpoint.versions_seen
|
|
103
102
|
};
|
|
104
103
|
}
|
|
105
|
-
|
|
106
104
|
//#endregion
|
|
107
105
|
exports.BaseChannel = BaseChannel;
|
|
108
106
|
exports.createCheckpoint = createCheckpoint;
|
|
109
107
|
exports.emptyChannels = emptyChannels;
|
|
110
108
|
exports.getOnlyChannels = getOnlyChannels;
|
|
111
109
|
exports.isBaseChannel = isBaseChannel;
|
|
110
|
+
|
|
112
111
|
//# sourceMappingURL=base.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.cjs","names":["EmptyChannelError"],"sources":["../../src/channels/base.ts"],"sourcesContent":["import {\n ReadonlyCheckpoint,\n uuid6,\n Checkpoint,\n} from \"@langchain/langgraph-checkpoint\";\nimport { EmptyChannelError } from \"../errors.js\";\n\nexport function isBaseChannel(obj: unknown): obj is BaseChannel {\n return obj != null && (obj as BaseChannel).lg_is_channel === true;\n}\n\n/** @internal */\nexport abstract class BaseChannel<\n ValueType = unknown,\n UpdateType = unknown,\n CheckpointType = unknown\n> {\n ValueType: ValueType;\n\n UpdateType: UpdateType;\n\n /**\n * The name of the channel.\n */\n abstract lc_graph_name: string;\n\n /** @ignore */\n lg_is_channel = true;\n\n /**\n * Return a new identical channel, optionally initialized from a checkpoint.\n * Can be thought of as a \"restoration\" from a checkpoint which is a \"snapshot\" of the channel's state.\n *\n * @param {CheckpointType | undefined} checkpoint\n * @param {CheckpointType | undefined} initialValue\n * @returns {this}\n */\n abstract fromCheckpoint(checkpoint?: CheckpointType): this;\n\n /**\n * Update the channel's value with the given sequence of updates.\n * The order of the updates in the sequence is arbitrary.\n * This method is called by Pregel for all channels at the end of each step.\n * If there are no updates, it is called with an empty sequence.\n *\n * Raises InvalidUpdateError if the sequence of updates is invalid.\n * Returns True if the channel was updated, False otherwise.\n *\n * @throws {InvalidUpdateError} if the sequence of updates is invalid.\n * @param {Array<UpdateType>} values\n * @returns {void}\n */\n abstract update(values: UpdateType[]): boolean;\n\n /**\n * Return the current value of the channel.\n *\n * @throws {EmptyChannelError} if the channel is empty (never updated yet).\n * @returns {ValueType}\n */\n abstract get(): ValueType;\n\n /**\n * Return a string representation of the channel's current state.\n *\n * @throws {EmptyChannelError} if the channel is empty (never updated yet), or doesn't support checkpoints.\n * @returns {CheckpointType | undefined}\n */\n abstract checkpoint(): CheckpointType | undefined;\n\n /**\n * Mark the current value of the channel as consumed. By default, no-op.\n * A channel can use this method to modify its state, preventing the value\n * from being consumed again.\n *\n * Returns True if the channel was updated, False otherwise.\n */\n consume(): boolean {\n return false;\n }\n\n /**\n * Notify the channel that the Pregel run is finishing. By default, no-op.\n * A channel can use this method to modify its state, preventing finish.\n *\n * Returns True if the channel was updated, False otherwise.\n */\n finish(): boolean {\n return false;\n }\n\n /**\n * Return True if the channel is available (not empty), False otherwise.\n * Subclasses should override this method to provide a more efficient\n * implementation than calling get() and catching EmptyChannelError.\n */\n isAvailable(): boolean {\n try {\n this.get();\n return true;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n if (error.name === EmptyChannelError.unminifiable_name) {\n return false;\n }\n throw error;\n }\n }\n\n /**\n * Compare this channel with another channel for equality.\n * Used to determine if two channels with the same key are semantically equivalent.\n * Subclasses should override this method to provide a meaningful comparison.\n *\n * @param {BaseChannel} other - The other channel to compare with.\n * @returns {boolean} True if the channels are equal, false otherwise.\n */\n equals(other: BaseChannel): boolean {\n return this === other;\n }\n}\n\nconst IS_ONLY_BASE_CHANNEL = Symbol.for(\"LG_IS_ONLY_BASE_CHANNEL\");\nexport function getOnlyChannels(\n channels: Record<string, BaseChannel>\n): Record<string, BaseChannel> {\n // @ts-expect-error - we know it's a record of base channels\n if (channels[IS_ONLY_BASE_CHANNEL] === true) return channels;\n\n const newChannels = {} as Record<string, BaseChannel>;\n for (const k in channels) {\n if (!Object.prototype.hasOwnProperty.call(channels, k)) continue;\n const value = channels[k];\n if (isBaseChannel(value)) newChannels[k] = value;\n }\n\n Object.assign(newChannels, { [IS_ONLY_BASE_CHANNEL]: true });\n return newChannels;\n}\n\nexport function emptyChannels<Cc extends Record<string, BaseChannel>>(\n channels: Cc,\n checkpoint: ReadonlyCheckpoint\n): Cc {\n const filteredChannels = getOnlyChannels(channels) as Cc;\n\n const newChannels = {} as Cc;\n for (const k in filteredChannels) {\n if (!Object.prototype.hasOwnProperty.call(filteredChannels, k)) continue;\n const channelValue = checkpoint.channel_values[k];\n newChannels[k] = filteredChannels[k].fromCheckpoint(channelValue);\n }\n Object.assign(newChannels, { [IS_ONLY_BASE_CHANNEL]: true });\n return newChannels;\n}\n\nexport function createCheckpoint<ValueType>(\n checkpoint: ReadonlyCheckpoint,\n channels: Record<string, BaseChannel<ValueType>> | undefined,\n step: number,\n options?: { id?: string }\n): Checkpoint {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let values: Record<string, any>;\n if (channels === undefined) {\n values = checkpoint.channel_values;\n } else {\n values = {};\n for (const k in channels) {\n if (!Object.prototype.hasOwnProperty.call(channels, k)) continue;\n try {\n values[k] = channels[k].checkpoint();\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n if (error.name === EmptyChannelError.unminifiable_name) {\n // no-op\n } else {\n throw error; // Rethrow unexpected errors\n }\n }\n }\n }\n\n return {\n v: 4,\n id: options?.id ?? uuid6(step),\n ts: new Date().toISOString(),\n channel_values: values,\n channel_versions: checkpoint.channel_versions,\n versions_seen: checkpoint.versions_seen,\n };\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"base.cjs","names":["EmptyChannelError"],"sources":["../../src/channels/base.ts"],"sourcesContent":["import {\n ReadonlyCheckpoint,\n uuid6,\n Checkpoint,\n} from \"@langchain/langgraph-checkpoint\";\nimport { EmptyChannelError } from \"../errors.js\";\n\nexport function isBaseChannel(obj: unknown): obj is BaseChannel {\n return obj != null && (obj as BaseChannel).lg_is_channel === true;\n}\n\n/** @internal */\nexport abstract class BaseChannel<\n ValueType = unknown,\n UpdateType = unknown,\n CheckpointType = unknown\n> {\n ValueType: ValueType;\n\n UpdateType: UpdateType;\n\n /**\n * The name of the channel.\n */\n abstract lc_graph_name: string;\n\n /** @ignore */\n lg_is_channel = true;\n\n /**\n * Return a new identical channel, optionally initialized from a checkpoint.\n * Can be thought of as a \"restoration\" from a checkpoint which is a \"snapshot\" of the channel's state.\n *\n * @param {CheckpointType | undefined} checkpoint\n * @param {CheckpointType | undefined} initialValue\n * @returns {this}\n */\n abstract fromCheckpoint(checkpoint?: CheckpointType): this;\n\n /**\n * Update the channel's value with the given sequence of updates.\n * The order of the updates in the sequence is arbitrary.\n * This method is called by Pregel for all channels at the end of each step.\n * If there are no updates, it is called with an empty sequence.\n *\n * Raises InvalidUpdateError if the sequence of updates is invalid.\n * Returns True if the channel was updated, False otherwise.\n *\n * @throws {InvalidUpdateError} if the sequence of updates is invalid.\n * @param {Array<UpdateType>} values\n * @returns {void}\n */\n abstract update(values: UpdateType[]): boolean;\n\n /**\n * Return the current value of the channel.\n *\n * @throws {EmptyChannelError} if the channel is empty (never updated yet).\n * @returns {ValueType}\n */\n abstract get(): ValueType;\n\n /**\n * Return a string representation of the channel's current state.\n *\n * @throws {EmptyChannelError} if the channel is empty (never updated yet), or doesn't support checkpoints.\n * @returns {CheckpointType | undefined}\n */\n abstract checkpoint(): CheckpointType | undefined;\n\n /**\n * Mark the current value of the channel as consumed. By default, no-op.\n * A channel can use this method to modify its state, preventing the value\n * from being consumed again.\n *\n * Returns True if the channel was updated, False otherwise.\n */\n consume(): boolean {\n return false;\n }\n\n /**\n * Notify the channel that the Pregel run is finishing. By default, no-op.\n * A channel can use this method to modify its state, preventing finish.\n *\n * Returns True if the channel was updated, False otherwise.\n */\n finish(): boolean {\n return false;\n }\n\n /**\n * Return True if the channel is available (not empty), False otherwise.\n * Subclasses should override this method to provide a more efficient\n * implementation than calling get() and catching EmptyChannelError.\n */\n isAvailable(): boolean {\n try {\n this.get();\n return true;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n if (error.name === EmptyChannelError.unminifiable_name) {\n return false;\n }\n throw error;\n }\n }\n\n /**\n * Compare this channel with another channel for equality.\n * Used to determine if two channels with the same key are semantically equivalent.\n * Subclasses should override this method to provide a meaningful comparison.\n *\n * @param {BaseChannel} other - The other channel to compare with.\n * @returns {boolean} True if the channels are equal, false otherwise.\n */\n equals(other: BaseChannel): boolean {\n return this === other;\n }\n}\n\nconst IS_ONLY_BASE_CHANNEL = Symbol.for(\"LG_IS_ONLY_BASE_CHANNEL\");\nexport function getOnlyChannels(\n channels: Record<string, BaseChannel>\n): Record<string, BaseChannel> {\n // @ts-expect-error - we know it's a record of base channels\n if (channels[IS_ONLY_BASE_CHANNEL] === true) return channels;\n\n const newChannels = {} as Record<string, BaseChannel>;\n for (const k in channels) {\n if (!Object.prototype.hasOwnProperty.call(channels, k)) continue;\n const value = channels[k];\n if (isBaseChannel(value)) newChannels[k] = value;\n }\n\n Object.assign(newChannels, { [IS_ONLY_BASE_CHANNEL]: true });\n return newChannels;\n}\n\nexport function emptyChannels<Cc extends Record<string, BaseChannel>>(\n channels: Cc,\n checkpoint: ReadonlyCheckpoint\n): Cc {\n const filteredChannels = getOnlyChannels(channels) as Cc;\n\n const newChannels = {} as Cc;\n for (const k in filteredChannels) {\n if (!Object.prototype.hasOwnProperty.call(filteredChannels, k)) continue;\n const channelValue = checkpoint.channel_values[k];\n newChannels[k] = filteredChannels[k].fromCheckpoint(channelValue);\n }\n Object.assign(newChannels, { [IS_ONLY_BASE_CHANNEL]: true });\n return newChannels;\n}\n\nexport function createCheckpoint<ValueType>(\n checkpoint: ReadonlyCheckpoint,\n channels: Record<string, BaseChannel<ValueType>> | undefined,\n step: number,\n options?: { id?: string }\n): Checkpoint {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let values: Record<string, any>;\n if (channels === undefined) {\n values = checkpoint.channel_values;\n } else {\n values = {};\n for (const k in channels) {\n if (!Object.prototype.hasOwnProperty.call(channels, k)) continue;\n try {\n values[k] = channels[k].checkpoint();\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n if (error.name === EmptyChannelError.unminifiable_name) {\n // no-op\n } else {\n throw error; // Rethrow unexpected errors\n }\n }\n }\n }\n\n return {\n v: 4,\n id: options?.id ?? uuid6(step),\n ts: new Date().toISOString(),\n channel_values: values,\n channel_versions: checkpoint.channel_versions,\n versions_seen: checkpoint.versions_seen,\n };\n}\n"],"mappings":";;;AAOA,SAAgB,cAAc,KAAkC;AAC9D,QAAO,OAAO,QAAS,IAAoB,kBAAkB;;;AAI/D,IAAsB,cAAtB,MAIE;CACA;CAEA;;CAQA,gBAAgB;;;;;;;;CAkDhB,UAAmB;AACjB,SAAO;;;;;;;;CAST,SAAkB;AAChB,SAAO;;;;;;;CAQT,cAAuB;AACrB,MAAI;AACF,QAAK,KAAK;AACV,UAAO;WAEA,OAAY;AACnB,OAAI,MAAM,SAASA,eAAAA,kBAAkB,kBACnC,QAAO;AAET,SAAM;;;;;;;;;;;CAYV,OAAO,OAA6B;AAClC,SAAO,SAAS;;;AAIpB,MAAM,uBAAuB,OAAO,IAAI,0BAA0B;AAClE,SAAgB,gBACd,UAC6B;AAE7B,KAAI,SAAS,0BAA0B,KAAM,QAAO;CAEpD,MAAM,cAAc,EAAE;AACtB,MAAK,MAAM,KAAK,UAAU;AACxB,MAAI,CAAC,OAAO,UAAU,eAAe,KAAK,UAAU,EAAE,CAAE;EACxD,MAAM,QAAQ,SAAS;AACvB,MAAI,cAAc,MAAM,CAAE,aAAY,KAAK;;AAG7C,QAAO,OAAO,aAAa,GAAG,uBAAuB,MAAM,CAAC;AAC5D,QAAO;;AAGT,SAAgB,cACd,UACA,YACI;CACJ,MAAM,mBAAmB,gBAAgB,SAAS;CAElD,MAAM,cAAc,EAAE;AACtB,MAAK,MAAM,KAAK,kBAAkB;AAChC,MAAI,CAAC,OAAO,UAAU,eAAe,KAAK,kBAAkB,EAAE,CAAE;EAChE,MAAM,eAAe,WAAW,eAAe;AAC/C,cAAY,KAAK,iBAAiB,GAAG,eAAe,aAAa;;AAEnE,QAAO,OAAO,aAAa,GAAG,uBAAuB,MAAM,CAAC;AAC5D,QAAO;;AAGT,SAAgB,iBACd,YACA,UACA,MACA,SACY;CAEZ,IAAI;AACJ,KAAI,aAAa,KAAA,EACf,UAAS,WAAW;MACf;AACL,WAAS,EAAE;AACX,OAAK,MAAM,KAAK,UAAU;AACxB,OAAI,CAAC,OAAO,UAAU,eAAe,KAAK,UAAU,EAAE,CAAE;AACxD,OAAI;AACF,WAAO,KAAK,SAAS,GAAG,YAAY;YAE7B,OAAY;AACnB,QAAI,MAAM,SAASA,eAAAA,kBAAkB,mBAAmB,OAGtD,OAAM;;;;AAMd,QAAO;EACL,GAAG;EACH,IAAI,SAAS,OAAA,GAAA,gCAAA,OAAY,KAAK;EAC9B,qBAAI,IAAI,MAAM,EAAC,aAAa;EAC5B,gBAAgB;EAChB,kBAAkB,WAAW;EAC7B,eAAe,WAAW;EAC3B"}
|
package/dist/channels/base.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { EmptyChannelError } from "../errors.js";
|
|
2
2
|
import { uuid6 } from "@langchain/langgraph-checkpoint";
|
|
3
|
-
|
|
4
3
|
//#region src/channels/base.ts
|
|
5
4
|
function isBaseChannel(obj) {
|
|
6
5
|
return obj != null && obj.lg_is_channel === true;
|
|
@@ -102,7 +101,7 @@ function createCheckpoint(checkpoint, channels, step, options) {
|
|
|
102
101
|
versions_seen: checkpoint.versions_seen
|
|
103
102
|
};
|
|
104
103
|
}
|
|
105
|
-
|
|
106
104
|
//#endregion
|
|
107
105
|
export { BaseChannel, createCheckpoint, emptyChannels, getOnlyChannels, isBaseChannel };
|
|
106
|
+
|
|
108
107
|
//# sourceMappingURL=base.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","names":[],"sources":["../../src/channels/base.ts"],"sourcesContent":["import {\n ReadonlyCheckpoint,\n uuid6,\n Checkpoint,\n} from \"@langchain/langgraph-checkpoint\";\nimport { EmptyChannelError } from \"../errors.js\";\n\nexport function isBaseChannel(obj: unknown): obj is BaseChannel {\n return obj != null && (obj as BaseChannel).lg_is_channel === true;\n}\n\n/** @internal */\nexport abstract class BaseChannel<\n ValueType = unknown,\n UpdateType = unknown,\n CheckpointType = unknown\n> {\n ValueType: ValueType;\n\n UpdateType: UpdateType;\n\n /**\n * The name of the channel.\n */\n abstract lc_graph_name: string;\n\n /** @ignore */\n lg_is_channel = true;\n\n /**\n * Return a new identical channel, optionally initialized from a checkpoint.\n * Can be thought of as a \"restoration\" from a checkpoint which is a \"snapshot\" of the channel's state.\n *\n * @param {CheckpointType | undefined} checkpoint\n * @param {CheckpointType | undefined} initialValue\n * @returns {this}\n */\n abstract fromCheckpoint(checkpoint?: CheckpointType): this;\n\n /**\n * Update the channel's value with the given sequence of updates.\n * The order of the updates in the sequence is arbitrary.\n * This method is called by Pregel for all channels at the end of each step.\n * If there are no updates, it is called with an empty sequence.\n *\n * Raises InvalidUpdateError if the sequence of updates is invalid.\n * Returns True if the channel was updated, False otherwise.\n *\n * @throws {InvalidUpdateError} if the sequence of updates is invalid.\n * @param {Array<UpdateType>} values\n * @returns {void}\n */\n abstract update(values: UpdateType[]): boolean;\n\n /**\n * Return the current value of the channel.\n *\n * @throws {EmptyChannelError} if the channel is empty (never updated yet).\n * @returns {ValueType}\n */\n abstract get(): ValueType;\n\n /**\n * Return a string representation of the channel's current state.\n *\n * @throws {EmptyChannelError} if the channel is empty (never updated yet), or doesn't support checkpoints.\n * @returns {CheckpointType | undefined}\n */\n abstract checkpoint(): CheckpointType | undefined;\n\n /**\n * Mark the current value of the channel as consumed. By default, no-op.\n * A channel can use this method to modify its state, preventing the value\n * from being consumed again.\n *\n * Returns True if the channel was updated, False otherwise.\n */\n consume(): boolean {\n return false;\n }\n\n /**\n * Notify the channel that the Pregel run is finishing. By default, no-op.\n * A channel can use this method to modify its state, preventing finish.\n *\n * Returns True if the channel was updated, False otherwise.\n */\n finish(): boolean {\n return false;\n }\n\n /**\n * Return True if the channel is available (not empty), False otherwise.\n * Subclasses should override this method to provide a more efficient\n * implementation than calling get() and catching EmptyChannelError.\n */\n isAvailable(): boolean {\n try {\n this.get();\n return true;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n if (error.name === EmptyChannelError.unminifiable_name) {\n return false;\n }\n throw error;\n }\n }\n\n /**\n * Compare this channel with another channel for equality.\n * Used to determine if two channels with the same key are semantically equivalent.\n * Subclasses should override this method to provide a meaningful comparison.\n *\n * @param {BaseChannel} other - The other channel to compare with.\n * @returns {boolean} True if the channels are equal, false otherwise.\n */\n equals(other: BaseChannel): boolean {\n return this === other;\n }\n}\n\nconst IS_ONLY_BASE_CHANNEL = Symbol.for(\"LG_IS_ONLY_BASE_CHANNEL\");\nexport function getOnlyChannels(\n channels: Record<string, BaseChannel>\n): Record<string, BaseChannel> {\n // @ts-expect-error - we know it's a record of base channels\n if (channels[IS_ONLY_BASE_CHANNEL] === true) return channels;\n\n const newChannels = {} as Record<string, BaseChannel>;\n for (const k in channels) {\n if (!Object.prototype.hasOwnProperty.call(channels, k)) continue;\n const value = channels[k];\n if (isBaseChannel(value)) newChannels[k] = value;\n }\n\n Object.assign(newChannels, { [IS_ONLY_BASE_CHANNEL]: true });\n return newChannels;\n}\n\nexport function emptyChannels<Cc extends Record<string, BaseChannel>>(\n channels: Cc,\n checkpoint: ReadonlyCheckpoint\n): Cc {\n const filteredChannels = getOnlyChannels(channels) as Cc;\n\n const newChannels = {} as Cc;\n for (const k in filteredChannels) {\n if (!Object.prototype.hasOwnProperty.call(filteredChannels, k)) continue;\n const channelValue = checkpoint.channel_values[k];\n newChannels[k] = filteredChannels[k].fromCheckpoint(channelValue);\n }\n Object.assign(newChannels, { [IS_ONLY_BASE_CHANNEL]: true });\n return newChannels;\n}\n\nexport function createCheckpoint<ValueType>(\n checkpoint: ReadonlyCheckpoint,\n channels: Record<string, BaseChannel<ValueType>> | undefined,\n step: number,\n options?: { id?: string }\n): Checkpoint {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let values: Record<string, any>;\n if (channels === undefined) {\n values = checkpoint.channel_values;\n } else {\n values = {};\n for (const k in channels) {\n if (!Object.prototype.hasOwnProperty.call(channels, k)) continue;\n try {\n values[k] = channels[k].checkpoint();\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n if (error.name === EmptyChannelError.unminifiable_name) {\n // no-op\n } else {\n throw error; // Rethrow unexpected errors\n }\n }\n }\n }\n\n return {\n v: 4,\n id: options?.id ?? uuid6(step),\n ts: new Date().toISOString(),\n channel_values: values,\n channel_versions: checkpoint.channel_versions,\n versions_seen: checkpoint.versions_seen,\n };\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"base.js","names":[],"sources":["../../src/channels/base.ts"],"sourcesContent":["import {\n ReadonlyCheckpoint,\n uuid6,\n Checkpoint,\n} from \"@langchain/langgraph-checkpoint\";\nimport { EmptyChannelError } from \"../errors.js\";\n\nexport function isBaseChannel(obj: unknown): obj is BaseChannel {\n return obj != null && (obj as BaseChannel).lg_is_channel === true;\n}\n\n/** @internal */\nexport abstract class BaseChannel<\n ValueType = unknown,\n UpdateType = unknown,\n CheckpointType = unknown\n> {\n ValueType: ValueType;\n\n UpdateType: UpdateType;\n\n /**\n * The name of the channel.\n */\n abstract lc_graph_name: string;\n\n /** @ignore */\n lg_is_channel = true;\n\n /**\n * Return a new identical channel, optionally initialized from a checkpoint.\n * Can be thought of as a \"restoration\" from a checkpoint which is a \"snapshot\" of the channel's state.\n *\n * @param {CheckpointType | undefined} checkpoint\n * @param {CheckpointType | undefined} initialValue\n * @returns {this}\n */\n abstract fromCheckpoint(checkpoint?: CheckpointType): this;\n\n /**\n * Update the channel's value with the given sequence of updates.\n * The order of the updates in the sequence is arbitrary.\n * This method is called by Pregel for all channels at the end of each step.\n * If there are no updates, it is called with an empty sequence.\n *\n * Raises InvalidUpdateError if the sequence of updates is invalid.\n * Returns True if the channel was updated, False otherwise.\n *\n * @throws {InvalidUpdateError} if the sequence of updates is invalid.\n * @param {Array<UpdateType>} values\n * @returns {void}\n */\n abstract update(values: UpdateType[]): boolean;\n\n /**\n * Return the current value of the channel.\n *\n * @throws {EmptyChannelError} if the channel is empty (never updated yet).\n * @returns {ValueType}\n */\n abstract get(): ValueType;\n\n /**\n * Return a string representation of the channel's current state.\n *\n * @throws {EmptyChannelError} if the channel is empty (never updated yet), or doesn't support checkpoints.\n * @returns {CheckpointType | undefined}\n */\n abstract checkpoint(): CheckpointType | undefined;\n\n /**\n * Mark the current value of the channel as consumed. By default, no-op.\n * A channel can use this method to modify its state, preventing the value\n * from being consumed again.\n *\n * Returns True if the channel was updated, False otherwise.\n */\n consume(): boolean {\n return false;\n }\n\n /**\n * Notify the channel that the Pregel run is finishing. By default, no-op.\n * A channel can use this method to modify its state, preventing finish.\n *\n * Returns True if the channel was updated, False otherwise.\n */\n finish(): boolean {\n return false;\n }\n\n /**\n * Return True if the channel is available (not empty), False otherwise.\n * Subclasses should override this method to provide a more efficient\n * implementation than calling get() and catching EmptyChannelError.\n */\n isAvailable(): boolean {\n try {\n this.get();\n return true;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n if (error.name === EmptyChannelError.unminifiable_name) {\n return false;\n }\n throw error;\n }\n }\n\n /**\n * Compare this channel with another channel for equality.\n * Used to determine if two channels with the same key are semantically equivalent.\n * Subclasses should override this method to provide a meaningful comparison.\n *\n * @param {BaseChannel} other - The other channel to compare with.\n * @returns {boolean} True if the channels are equal, false otherwise.\n */\n equals(other: BaseChannel): boolean {\n return this === other;\n }\n}\n\nconst IS_ONLY_BASE_CHANNEL = Symbol.for(\"LG_IS_ONLY_BASE_CHANNEL\");\nexport function getOnlyChannels(\n channels: Record<string, BaseChannel>\n): Record<string, BaseChannel> {\n // @ts-expect-error - we know it's a record of base channels\n if (channels[IS_ONLY_BASE_CHANNEL] === true) return channels;\n\n const newChannels = {} as Record<string, BaseChannel>;\n for (const k in channels) {\n if (!Object.prototype.hasOwnProperty.call(channels, k)) continue;\n const value = channels[k];\n if (isBaseChannel(value)) newChannels[k] = value;\n }\n\n Object.assign(newChannels, { [IS_ONLY_BASE_CHANNEL]: true });\n return newChannels;\n}\n\nexport function emptyChannels<Cc extends Record<string, BaseChannel>>(\n channels: Cc,\n checkpoint: ReadonlyCheckpoint\n): Cc {\n const filteredChannels = getOnlyChannels(channels) as Cc;\n\n const newChannels = {} as Cc;\n for (const k in filteredChannels) {\n if (!Object.prototype.hasOwnProperty.call(filteredChannels, k)) continue;\n const channelValue = checkpoint.channel_values[k];\n newChannels[k] = filteredChannels[k].fromCheckpoint(channelValue);\n }\n Object.assign(newChannels, { [IS_ONLY_BASE_CHANNEL]: true });\n return newChannels;\n}\n\nexport function createCheckpoint<ValueType>(\n checkpoint: ReadonlyCheckpoint,\n channels: Record<string, BaseChannel<ValueType>> | undefined,\n step: number,\n options?: { id?: string }\n): Checkpoint {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let values: Record<string, any>;\n if (channels === undefined) {\n values = checkpoint.channel_values;\n } else {\n values = {};\n for (const k in channels) {\n if (!Object.prototype.hasOwnProperty.call(channels, k)) continue;\n try {\n values[k] = channels[k].checkpoint();\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n if (error.name === EmptyChannelError.unminifiable_name) {\n // no-op\n } else {\n throw error; // Rethrow unexpected errors\n }\n }\n }\n }\n\n return {\n v: 4,\n id: options?.id ?? uuid6(step),\n ts: new Date().toISOString(),\n channel_values: values,\n channel_versions: checkpoint.channel_versions,\n versions_seen: checkpoint.versions_seen,\n };\n}\n"],"mappings":";;;AAOA,SAAgB,cAAc,KAAkC;AAC9D,QAAO,OAAO,QAAS,IAAoB,kBAAkB;;;AAI/D,IAAsB,cAAtB,MAIE;CACA;CAEA;;CAQA,gBAAgB;;;;;;;;CAkDhB,UAAmB;AACjB,SAAO;;;;;;;;CAST,SAAkB;AAChB,SAAO;;;;;;;CAQT,cAAuB;AACrB,MAAI;AACF,QAAK,KAAK;AACV,UAAO;WAEA,OAAY;AACnB,OAAI,MAAM,SAAS,kBAAkB,kBACnC,QAAO;AAET,SAAM;;;;;;;;;;;CAYV,OAAO,OAA6B;AAClC,SAAO,SAAS;;;AAIpB,MAAM,uBAAuB,OAAO,IAAI,0BAA0B;AAClE,SAAgB,gBACd,UAC6B;AAE7B,KAAI,SAAS,0BAA0B,KAAM,QAAO;CAEpD,MAAM,cAAc,EAAE;AACtB,MAAK,MAAM,KAAK,UAAU;AACxB,MAAI,CAAC,OAAO,UAAU,eAAe,KAAK,UAAU,EAAE,CAAE;EACxD,MAAM,QAAQ,SAAS;AACvB,MAAI,cAAc,MAAM,CAAE,aAAY,KAAK;;AAG7C,QAAO,OAAO,aAAa,GAAG,uBAAuB,MAAM,CAAC;AAC5D,QAAO;;AAGT,SAAgB,cACd,UACA,YACI;CACJ,MAAM,mBAAmB,gBAAgB,SAAS;CAElD,MAAM,cAAc,EAAE;AACtB,MAAK,MAAM,KAAK,kBAAkB;AAChC,MAAI,CAAC,OAAO,UAAU,eAAe,KAAK,kBAAkB,EAAE,CAAE;EAChE,MAAM,eAAe,WAAW,eAAe;AAC/C,cAAY,KAAK,iBAAiB,GAAG,eAAe,aAAa;;AAEnE,QAAO,OAAO,aAAa,GAAG,uBAAuB,MAAM,CAAC;AAC5D,QAAO;;AAGT,SAAgB,iBACd,YACA,UACA,MACA,SACY;CAEZ,IAAI;AACJ,KAAI,aAAa,KAAA,EACf,UAAS,WAAW;MACf;AACL,WAAS,EAAE;AACX,OAAK,MAAM,KAAK,UAAU;AACxB,OAAI,CAAC,OAAO,UAAU,eAAe,KAAK,UAAU,EAAE,CAAE;AACxD,OAAI;AACF,WAAO,KAAK,SAAS,GAAG,YAAY;YAE7B,OAAY;AACnB,QAAI,MAAM,SAAS,kBAAkB,mBAAmB,OAGtD,OAAM;;;;AAMd,QAAO;EACL,GAAG;EACH,IAAI,SAAS,MAAM,MAAM,KAAK;EAC9B,qBAAI,IAAI,MAAM,EAAC,aAAa;EAC5B,gBAAgB;EAChB,kBAAkB,WAAW;EAC7B,eAAe,WAAW;EAC3B"}
|
package/dist/channels/binop.cjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
const require_constants = require(
|
|
2
|
-
const require_errors = require(
|
|
3
|
-
const require_base = require(
|
|
4
|
-
|
|
1
|
+
const require_constants = require("../constants.cjs");
|
|
2
|
+
const require_errors = require("../errors.cjs");
|
|
3
|
+
const require_base = require("./base.cjs");
|
|
5
4
|
//#region src/channels/binop.ts
|
|
6
5
|
const isBinaryOperatorAggregate = (value) => {
|
|
7
6
|
return value != null && value.lc_graph_name === "BinaryOperatorAggregate";
|
|
@@ -67,7 +66,7 @@ var BinaryOperatorAggregate = class BinaryOperatorAggregate extends require_base
|
|
|
67
66
|
return this.operator === other.operator;
|
|
68
67
|
}
|
|
69
68
|
};
|
|
70
|
-
|
|
71
69
|
//#endregion
|
|
72
70
|
exports.BinaryOperatorAggregate = BinaryOperatorAggregate;
|
|
71
|
+
|
|
73
72
|
//# sourceMappingURL=binop.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"binop.cjs","names":["BaseChannel","_getOverwriteValue","_isOverwriteValue","InvalidUpdateError","EmptyChannelError"],"sources":["../../src/channels/binop.ts"],"sourcesContent":["import {\n _getOverwriteValue,\n _isOverwriteValue,\n type OverwriteValue,\n} from \"../constants.js\";\nimport { EmptyChannelError, InvalidUpdateError } from \"../errors.js\";\nimport { BaseChannel } from \"./base.js\";\n\ntype OverwriteOrValue<ValueType, UpdateType> =\n | OverwriteValue<ValueType>\n | UpdateType;\n\nexport type BinaryOperator<ValueType, UpdateType> = (\n a: ValueType,\n b: UpdateType\n) => ValueType;\n\nconst isBinaryOperatorAggregate = (\n value: BaseChannel\n): value is BinaryOperatorAggregate<unknown, unknown> => {\n return value != null && value.lc_graph_name === \"BinaryOperatorAggregate\";\n};\n\n/**\n * Stores the result of applying a binary operator to the current value and each new value.\n */\nexport class BinaryOperatorAggregate<\n ValueType,\n UpdateType = ValueType\n> extends BaseChannel<\n ValueType,\n OverwriteOrValue<ValueType, UpdateType>,\n ValueType\n> {\n lc_graph_name = \"BinaryOperatorAggregate\";\n\n value: ValueType | undefined;\n\n operator: BinaryOperator<ValueType, UpdateType>;\n\n initialValueFactory?: () => ValueType;\n\n constructor(\n operator: BinaryOperator<ValueType, UpdateType>,\n initialValueFactory?: () => ValueType\n ) {\n super();\n\n this.operator = operator;\n this.initialValueFactory = initialValueFactory;\n this.value = initialValueFactory?.();\n }\n\n public fromCheckpoint(checkpoint?: ValueType) {\n const empty = new BinaryOperatorAggregate(\n this.operator,\n this.initialValueFactory\n );\n if (typeof checkpoint !== \"undefined\") {\n empty.value = checkpoint;\n }\n return empty as this;\n }\n\n public update(values: OverwriteOrValue<ValueType, UpdateType>[]): boolean {\n let newValues = values;\n if (!newValues.length) return false;\n\n if (this.value === undefined) {\n const first = newValues[0];\n const [isOverwrite, overwriteVal] = _getOverwriteValue<ValueType>(first);\n if (isOverwrite) {\n this.value = overwriteVal;\n } else {\n this.value = first as ValueType;\n }\n newValues = newValues.slice(1);\n }\n\n let seenOverwrite = false;\n for (const incoming of newValues) {\n if (_isOverwriteValue<ValueType>(incoming)) {\n if (seenOverwrite) {\n throw new InvalidUpdateError(\n \"Can receive only one Overwrite value per step.\"\n );\n }\n const [, val] = _getOverwriteValue<ValueType>(incoming);\n this.value = val;\n seenOverwrite = true;\n continue;\n } else if (!seenOverwrite && this.value !== undefined) {\n this.value = this.operator(this.value, incoming);\n }\n }\n return true;\n }\n\n public get(): ValueType {\n if (this.value === undefined) {\n throw new EmptyChannelError();\n }\n return this.value;\n }\n\n public checkpoint(): ValueType {\n if (this.value === undefined) {\n throw new EmptyChannelError();\n }\n return this.value;\n }\n\n isAvailable(): boolean {\n return this.value !== undefined;\n }\n\n /**\n * Compare this channel with another channel for equality.\n * Two BinaryOperatorAggregate channels are equal if they have the same operator function.\n * This follows the Python implementation which compares operator references.\n */\n equals(other: BaseChannel): boolean {\n if (this === other) return true;\n if (!isBinaryOperatorAggregate(other)) return false;\n return this.operator === other.operator;\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"binop.cjs","names":["BaseChannel","_getOverwriteValue","_isOverwriteValue","InvalidUpdateError","EmptyChannelError"],"sources":["../../src/channels/binop.ts"],"sourcesContent":["import {\n _getOverwriteValue,\n _isOverwriteValue,\n type OverwriteValue,\n} from \"../constants.js\";\nimport { EmptyChannelError, InvalidUpdateError } from \"../errors.js\";\nimport { BaseChannel } from \"./base.js\";\n\ntype OverwriteOrValue<ValueType, UpdateType> =\n | OverwriteValue<ValueType>\n | UpdateType;\n\nexport type BinaryOperator<ValueType, UpdateType> = (\n a: ValueType,\n b: UpdateType\n) => ValueType;\n\nconst isBinaryOperatorAggregate = (\n value: BaseChannel\n): value is BinaryOperatorAggregate<unknown, unknown> => {\n return value != null && value.lc_graph_name === \"BinaryOperatorAggregate\";\n};\n\n/**\n * Stores the result of applying a binary operator to the current value and each new value.\n */\nexport class BinaryOperatorAggregate<\n ValueType,\n UpdateType = ValueType\n> extends BaseChannel<\n ValueType,\n OverwriteOrValue<ValueType, UpdateType>,\n ValueType\n> {\n lc_graph_name = \"BinaryOperatorAggregate\";\n\n value: ValueType | undefined;\n\n operator: BinaryOperator<ValueType, UpdateType>;\n\n initialValueFactory?: () => ValueType;\n\n constructor(\n operator: BinaryOperator<ValueType, UpdateType>,\n initialValueFactory?: () => ValueType\n ) {\n super();\n\n this.operator = operator;\n this.initialValueFactory = initialValueFactory;\n this.value = initialValueFactory?.();\n }\n\n public fromCheckpoint(checkpoint?: ValueType) {\n const empty = new BinaryOperatorAggregate(\n this.operator,\n this.initialValueFactory\n );\n if (typeof checkpoint !== \"undefined\") {\n empty.value = checkpoint;\n }\n return empty as this;\n }\n\n public update(values: OverwriteOrValue<ValueType, UpdateType>[]): boolean {\n let newValues = values;\n if (!newValues.length) return false;\n\n if (this.value === undefined) {\n const first = newValues[0];\n const [isOverwrite, overwriteVal] = _getOverwriteValue<ValueType>(first);\n if (isOverwrite) {\n this.value = overwriteVal;\n } else {\n this.value = first as ValueType;\n }\n newValues = newValues.slice(1);\n }\n\n let seenOverwrite = false;\n for (const incoming of newValues) {\n if (_isOverwriteValue<ValueType>(incoming)) {\n if (seenOverwrite) {\n throw new InvalidUpdateError(\n \"Can receive only one Overwrite value per step.\"\n );\n }\n const [, val] = _getOverwriteValue<ValueType>(incoming);\n this.value = val;\n seenOverwrite = true;\n continue;\n } else if (!seenOverwrite && this.value !== undefined) {\n this.value = this.operator(this.value, incoming);\n }\n }\n return true;\n }\n\n public get(): ValueType {\n if (this.value === undefined) {\n throw new EmptyChannelError();\n }\n return this.value;\n }\n\n public checkpoint(): ValueType {\n if (this.value === undefined) {\n throw new EmptyChannelError();\n }\n return this.value;\n }\n\n isAvailable(): boolean {\n return this.value !== undefined;\n }\n\n /**\n * Compare this channel with another channel for equality.\n * Two BinaryOperatorAggregate channels are equal if they have the same operator function.\n * This follows the Python implementation which compares operator references.\n */\n equals(other: BaseChannel): boolean {\n if (this === other) return true;\n if (!isBinaryOperatorAggregate(other)) return false;\n return this.operator === other.operator;\n }\n}\n"],"mappings":";;;;AAiBA,MAAM,6BACJ,UACuD;AACvD,QAAO,SAAS,QAAQ,MAAM,kBAAkB;;;;;AAMlD,IAAa,0BAAb,MAAa,gCAGHA,aAAAA,YAIR;CACA,gBAAgB;CAEhB;CAEA;CAEA;CAEA,YACE,UACA,qBACA;AACA,SAAO;AAEP,OAAK,WAAW;AAChB,OAAK,sBAAsB;AAC3B,OAAK,QAAQ,uBAAuB;;CAGtC,eAAsB,YAAwB;EAC5C,MAAM,QAAQ,IAAI,wBAChB,KAAK,UACL,KAAK,oBACN;AACD,MAAI,OAAO,eAAe,YACxB,OAAM,QAAQ;AAEhB,SAAO;;CAGT,OAAc,QAA4D;EACxE,IAAI,YAAY;AAChB,MAAI,CAAC,UAAU,OAAQ,QAAO;AAE9B,MAAI,KAAK,UAAU,KAAA,GAAW;GAC5B,MAAM,QAAQ,UAAU;GACxB,MAAM,CAAC,aAAa,gBAAgBC,kBAAAA,mBAA8B,MAAM;AACxE,OAAI,YACF,MAAK,QAAQ;OAEb,MAAK,QAAQ;AAEf,eAAY,UAAU,MAAM,EAAE;;EAGhC,IAAI,gBAAgB;AACpB,OAAK,MAAM,YAAY,UACrB,KAAIC,kBAAAA,kBAA6B,SAAS,EAAE;AAC1C,OAAI,cACF,OAAM,IAAIC,eAAAA,mBACR,iDACD;GAEH,MAAM,GAAG,OAAOF,kBAAAA,mBAA8B,SAAS;AACvD,QAAK,QAAQ;AACb,mBAAgB;AAChB;aACS,CAAC,iBAAiB,KAAK,UAAU,KAAA,EAC1C,MAAK,QAAQ,KAAK,SAAS,KAAK,OAAO,SAAS;AAGpD,SAAO;;CAGT,MAAwB;AACtB,MAAI,KAAK,UAAU,KAAA,EACjB,OAAM,IAAIG,eAAAA,mBAAmB;AAE/B,SAAO,KAAK;;CAGd,aAA+B;AAC7B,MAAI,KAAK,UAAU,KAAA,EACjB,OAAM,IAAIA,eAAAA,mBAAmB;AAE/B,SAAO,KAAK;;CAGd,cAAuB;AACrB,SAAO,KAAK,UAAU,KAAA;;;;;;;CAQxB,OAAO,OAA6B;AAClC,MAAI,SAAS,MAAO,QAAO;AAC3B,MAAI,CAAC,0BAA0B,MAAM,CAAE,QAAO;AAC9C,SAAO,KAAK,aAAa,MAAM"}
|
package/dist/channels/binop.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { _getOverwriteValue, _isOverwriteValue } from "../constants.js";
|
|
2
2
|
import { EmptyChannelError, InvalidUpdateError } from "../errors.js";
|
|
3
3
|
import { BaseChannel } from "./base.js";
|
|
4
|
-
|
|
5
4
|
//#region src/channels/binop.ts
|
|
6
5
|
const isBinaryOperatorAggregate = (value) => {
|
|
7
6
|
return value != null && value.lc_graph_name === "BinaryOperatorAggregate";
|
|
@@ -67,7 +66,7 @@ var BinaryOperatorAggregate = class BinaryOperatorAggregate extends BaseChannel
|
|
|
67
66
|
return this.operator === other.operator;
|
|
68
67
|
}
|
|
69
68
|
};
|
|
70
|
-
|
|
71
69
|
//#endregion
|
|
72
70
|
export { BinaryOperatorAggregate };
|
|
71
|
+
|
|
73
72
|
//# sourceMappingURL=binop.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"binop.js","names":[],"sources":["../../src/channels/binop.ts"],"sourcesContent":["import {\n _getOverwriteValue,\n _isOverwriteValue,\n type OverwriteValue,\n} from \"../constants.js\";\nimport { EmptyChannelError, InvalidUpdateError } from \"../errors.js\";\nimport { BaseChannel } from \"./base.js\";\n\ntype OverwriteOrValue<ValueType, UpdateType> =\n | OverwriteValue<ValueType>\n | UpdateType;\n\nexport type BinaryOperator<ValueType, UpdateType> = (\n a: ValueType,\n b: UpdateType\n) => ValueType;\n\nconst isBinaryOperatorAggregate = (\n value: BaseChannel\n): value is BinaryOperatorAggregate<unknown, unknown> => {\n return value != null && value.lc_graph_name === \"BinaryOperatorAggregate\";\n};\n\n/**\n * Stores the result of applying a binary operator to the current value and each new value.\n */\nexport class BinaryOperatorAggregate<\n ValueType,\n UpdateType = ValueType\n> extends BaseChannel<\n ValueType,\n OverwriteOrValue<ValueType, UpdateType>,\n ValueType\n> {\n lc_graph_name = \"BinaryOperatorAggregate\";\n\n value: ValueType | undefined;\n\n operator: BinaryOperator<ValueType, UpdateType>;\n\n initialValueFactory?: () => ValueType;\n\n constructor(\n operator: BinaryOperator<ValueType, UpdateType>,\n initialValueFactory?: () => ValueType\n ) {\n super();\n\n this.operator = operator;\n this.initialValueFactory = initialValueFactory;\n this.value = initialValueFactory?.();\n }\n\n public fromCheckpoint(checkpoint?: ValueType) {\n const empty = new BinaryOperatorAggregate(\n this.operator,\n this.initialValueFactory\n );\n if (typeof checkpoint !== \"undefined\") {\n empty.value = checkpoint;\n }\n return empty as this;\n }\n\n public update(values: OverwriteOrValue<ValueType, UpdateType>[]): boolean {\n let newValues = values;\n if (!newValues.length) return false;\n\n if (this.value === undefined) {\n const first = newValues[0];\n const [isOverwrite, overwriteVal] = _getOverwriteValue<ValueType>(first);\n if (isOverwrite) {\n this.value = overwriteVal;\n } else {\n this.value = first as ValueType;\n }\n newValues = newValues.slice(1);\n }\n\n let seenOverwrite = false;\n for (const incoming of newValues) {\n if (_isOverwriteValue<ValueType>(incoming)) {\n if (seenOverwrite) {\n throw new InvalidUpdateError(\n \"Can receive only one Overwrite value per step.\"\n );\n }\n const [, val] = _getOverwriteValue<ValueType>(incoming);\n this.value = val;\n seenOverwrite = true;\n continue;\n } else if (!seenOverwrite && this.value !== undefined) {\n this.value = this.operator(this.value, incoming);\n }\n }\n return true;\n }\n\n public get(): ValueType {\n if (this.value === undefined) {\n throw new EmptyChannelError();\n }\n return this.value;\n }\n\n public checkpoint(): ValueType {\n if (this.value === undefined) {\n throw new EmptyChannelError();\n }\n return this.value;\n }\n\n isAvailable(): boolean {\n return this.value !== undefined;\n }\n\n /**\n * Compare this channel with another channel for equality.\n * Two BinaryOperatorAggregate channels are equal if they have the same operator function.\n * This follows the Python implementation which compares operator references.\n */\n equals(other: BaseChannel): boolean {\n if (this === other) return true;\n if (!isBinaryOperatorAggregate(other)) return false;\n return this.operator === other.operator;\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"binop.js","names":[],"sources":["../../src/channels/binop.ts"],"sourcesContent":["import {\n _getOverwriteValue,\n _isOverwriteValue,\n type OverwriteValue,\n} from \"../constants.js\";\nimport { EmptyChannelError, InvalidUpdateError } from \"../errors.js\";\nimport { BaseChannel } from \"./base.js\";\n\ntype OverwriteOrValue<ValueType, UpdateType> =\n | OverwriteValue<ValueType>\n | UpdateType;\n\nexport type BinaryOperator<ValueType, UpdateType> = (\n a: ValueType,\n b: UpdateType\n) => ValueType;\n\nconst isBinaryOperatorAggregate = (\n value: BaseChannel\n): value is BinaryOperatorAggregate<unknown, unknown> => {\n return value != null && value.lc_graph_name === \"BinaryOperatorAggregate\";\n};\n\n/**\n * Stores the result of applying a binary operator to the current value and each new value.\n */\nexport class BinaryOperatorAggregate<\n ValueType,\n UpdateType = ValueType\n> extends BaseChannel<\n ValueType,\n OverwriteOrValue<ValueType, UpdateType>,\n ValueType\n> {\n lc_graph_name = \"BinaryOperatorAggregate\";\n\n value: ValueType | undefined;\n\n operator: BinaryOperator<ValueType, UpdateType>;\n\n initialValueFactory?: () => ValueType;\n\n constructor(\n operator: BinaryOperator<ValueType, UpdateType>,\n initialValueFactory?: () => ValueType\n ) {\n super();\n\n this.operator = operator;\n this.initialValueFactory = initialValueFactory;\n this.value = initialValueFactory?.();\n }\n\n public fromCheckpoint(checkpoint?: ValueType) {\n const empty = new BinaryOperatorAggregate(\n this.operator,\n this.initialValueFactory\n );\n if (typeof checkpoint !== \"undefined\") {\n empty.value = checkpoint;\n }\n return empty as this;\n }\n\n public update(values: OverwriteOrValue<ValueType, UpdateType>[]): boolean {\n let newValues = values;\n if (!newValues.length) return false;\n\n if (this.value === undefined) {\n const first = newValues[0];\n const [isOverwrite, overwriteVal] = _getOverwriteValue<ValueType>(first);\n if (isOverwrite) {\n this.value = overwriteVal;\n } else {\n this.value = first as ValueType;\n }\n newValues = newValues.slice(1);\n }\n\n let seenOverwrite = false;\n for (const incoming of newValues) {\n if (_isOverwriteValue<ValueType>(incoming)) {\n if (seenOverwrite) {\n throw new InvalidUpdateError(\n \"Can receive only one Overwrite value per step.\"\n );\n }\n const [, val] = _getOverwriteValue<ValueType>(incoming);\n this.value = val;\n seenOverwrite = true;\n continue;\n } else if (!seenOverwrite && this.value !== undefined) {\n this.value = this.operator(this.value, incoming);\n }\n }\n return true;\n }\n\n public get(): ValueType {\n if (this.value === undefined) {\n throw new EmptyChannelError();\n }\n return this.value;\n }\n\n public checkpoint(): ValueType {\n if (this.value === undefined) {\n throw new EmptyChannelError();\n }\n return this.value;\n }\n\n isAvailable(): boolean {\n return this.value !== undefined;\n }\n\n /**\n * Compare this channel with another channel for equality.\n * Two BinaryOperatorAggregate channels are equal if they have the same operator function.\n * This follows the Python implementation which compares operator references.\n */\n equals(other: BaseChannel): boolean {\n if (this === other) return true;\n if (!isBinaryOperatorAggregate(other)) return false;\n return this.operator === other.operator;\n }\n}\n"],"mappings":";;;;AAiBA,MAAM,6BACJ,UACuD;AACvD,QAAO,SAAS,QAAQ,MAAM,kBAAkB;;;;;AAMlD,IAAa,0BAAb,MAAa,gCAGH,YAIR;CACA,gBAAgB;CAEhB;CAEA;CAEA;CAEA,YACE,UACA,qBACA;AACA,SAAO;AAEP,OAAK,WAAW;AAChB,OAAK,sBAAsB;AAC3B,OAAK,QAAQ,uBAAuB;;CAGtC,eAAsB,YAAwB;EAC5C,MAAM,QAAQ,IAAI,wBAChB,KAAK,UACL,KAAK,oBACN;AACD,MAAI,OAAO,eAAe,YACxB,OAAM,QAAQ;AAEhB,SAAO;;CAGT,OAAc,QAA4D;EACxE,IAAI,YAAY;AAChB,MAAI,CAAC,UAAU,OAAQ,QAAO;AAE9B,MAAI,KAAK,UAAU,KAAA,GAAW;GAC5B,MAAM,QAAQ,UAAU;GACxB,MAAM,CAAC,aAAa,gBAAgB,mBAA8B,MAAM;AACxE,OAAI,YACF,MAAK,QAAQ;OAEb,MAAK,QAAQ;AAEf,eAAY,UAAU,MAAM,EAAE;;EAGhC,IAAI,gBAAgB;AACpB,OAAK,MAAM,YAAY,UACrB,KAAI,kBAA6B,SAAS,EAAE;AAC1C,OAAI,cACF,OAAM,IAAI,mBACR,iDACD;GAEH,MAAM,GAAG,OAAO,mBAA8B,SAAS;AACvD,QAAK,QAAQ;AACb,mBAAgB;AAChB;aACS,CAAC,iBAAiB,KAAK,UAAU,KAAA,EAC1C,MAAK,QAAQ,KAAK,SAAS,KAAK,OAAO,SAAS;AAGpD,SAAO;;CAGT,MAAwB;AACtB,MAAI,KAAK,UAAU,KAAA,EACjB,OAAM,IAAI,mBAAmB;AAE/B,SAAO,KAAK;;CAGd,aAA+B;AAC7B,MAAI,KAAK,UAAU,KAAA,EACjB,OAAM,IAAI,mBAAmB;AAE/B,SAAO,KAAK;;CAGd,cAAuB;AACrB,SAAO,KAAK,UAAU,KAAA;;;;;;;CAQxB,OAAO,OAA6B;AAClC,MAAI,SAAS,MAAO,QAAO;AAC3B,MAAI,CAAC,0BAA0B,MAAM,CAAE,QAAO;AAC9C,SAAO,KAAK,aAAa,MAAM"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
const require_errors = require(
|
|
2
|
-
const require_base = require(
|
|
3
|
-
const require_named_barrier_value = require(
|
|
4
|
-
|
|
1
|
+
const require_errors = require("../errors.cjs");
|
|
2
|
+
const require_base = require("./base.cjs");
|
|
3
|
+
const require_named_barrier_value = require("./named_barrier_value.cjs");
|
|
5
4
|
//#region src/channels/dynamic_barrier_value.ts
|
|
6
5
|
function isWaitForNames(v) {
|
|
7
6
|
return v.__names !== void 0;
|
|
@@ -69,7 +68,7 @@ var DynamicBarrierValue = class DynamicBarrierValue extends require_base.BaseCha
|
|
|
69
68
|
return !!this.names && require_named_barrier_value.areSetsEqual(this.names, this.seen);
|
|
70
69
|
}
|
|
71
70
|
};
|
|
72
|
-
|
|
73
71
|
//#endregion
|
|
74
72
|
exports.DynamicBarrierValue = DynamicBarrierValue;
|
|
73
|
+
|
|
75
74
|
//# sourceMappingURL=dynamic_barrier_value.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dynamic_barrier_value.cjs","names":["BaseChannel","InvalidUpdateError","areSetsEqual","EmptyChannelError"],"sources":["../../src/channels/dynamic_barrier_value.ts"],"sourcesContent":["import { EmptyChannelError, InvalidUpdateError } from \"../errors.js\";\nimport { BaseChannel } from \"./base.js\";\nimport { areSetsEqual } from \"./named_barrier_value.js\";\n\nexport interface WaitForNames<Value> {\n __names: Value[];\n}\n\nfunction isWaitForNames<Value>(\n v: WaitForNames<Value> | Value\n): v is WaitForNames<Value> {\n return (v as WaitForNames<Value>).__names !== undefined;\n}\n\n/**\n * A channel that switches between two states\n *\n * - in the \"priming\" state it can't be read from.\n * - if it receives a WaitForNames update, it switches to the \"waiting\" state.\n * - in the \"waiting\" state it collects named values until all are received.\n * - once all named values are received, it can be read once, and it switches\n * back to the \"priming\" state.\n */\nexport class DynamicBarrierValue<Value> extends BaseChannel<\n void,\n Value | WaitForNames<Value>,\n [Value[] | undefined, Value[]]\n> {\n lc_graph_name = \"DynamicBarrierValue\";\n\n names?: Set<Value>; // Names of nodes that we want to wait for.\n\n seen: Set<Value>;\n\n constructor() {\n super();\n this.names = undefined;\n this.seen = new Set<Value>();\n }\n\n fromCheckpoint(checkpoint?: [Value[] | undefined, Value[]]) {\n const empty = new DynamicBarrierValue<Value>();\n if (typeof checkpoint !== \"undefined\") {\n empty.names = new Set(checkpoint[0]);\n empty.seen = new Set(checkpoint[1]);\n }\n return empty as this;\n }\n\n update(values: (Value | WaitForNames<Value>)[]): boolean {\n const waitForNames = values.filter(isWaitForNames);\n if (waitForNames.length > 0) {\n if (waitForNames.length > 1) {\n throw new InvalidUpdateError(\n \"Received multiple WaitForNames updates in the same step.\"\n );\n }\n this.names = new Set(waitForNames[0].__names);\n return true;\n } else if (this.names !== undefined) {\n let updated = false;\n for (const value of values) {\n if (isWaitForNames(value)) {\n throw new Error(\n \"Assertion Error: Received unexpected WaitForNames instance.\"\n );\n }\n if (this.names.has(value) && !this.seen.has(value)) {\n this.seen.add(value);\n updated = true;\n }\n }\n return updated;\n }\n return false;\n }\n\n consume(): boolean {\n if (this.seen && this.names && areSetsEqual(this.seen, this.names)) {\n this.seen = new Set<Value>();\n this.names = undefined;\n return true;\n }\n return false;\n }\n\n // If we have not yet seen all the node names we want to wait for,\n // throw an error to prevent continuing.\n get(): void {\n if (!this.names || !areSetsEqual(this.names, this.seen)) {\n throw new EmptyChannelError();\n }\n return undefined;\n }\n\n checkpoint(): [Value[] | undefined, Value[]] {\n return [this.names ? [...this.names] : undefined, [...this.seen]];\n }\n\n isAvailable(): boolean {\n return !!this.names && areSetsEqual(this.names, this.seen);\n }\n}\n\n/**\n * A channel that switches between two states with an additional finished flag\n *\n * - in the \"priming\" state it can't be read from.\n * - if it receives a WaitForNames update, it switches to the \"waiting\" state.\n * - in the \"waiting\" state it collects named values until all are received.\n * - once all named values are received, and the finished flag is set, it can be read once, and it switches\n * back to the \"priming\" state.\n * @internal\n */\nexport class DynamicBarrierValueAfterFinish<Value> extends BaseChannel<\n void,\n Value | WaitForNames<Value>,\n [Value[] | undefined, Value[], boolean]\n> {\n lc_graph_name = \"DynamicBarrierValueAfterFinish\";\n\n names?: Set<Value>; // Names of nodes that we want to wait for.\n\n seen: Set<Value>;\n\n finished: boolean;\n\n constructor() {\n super();\n this.names = undefined;\n this.seen = new Set<Value>();\n this.finished = false;\n }\n\n fromCheckpoint(checkpoint?: [Value[] | undefined, Value[], boolean]) {\n const empty = new DynamicBarrierValueAfterFinish<Value>();\n if (typeof checkpoint !== \"undefined\") {\n const [names, seen, finished] = checkpoint;\n empty.names = names ? new Set(names) : undefined;\n empty.seen = new Set(seen);\n empty.finished = finished;\n }\n return empty as this;\n }\n\n update(values: (Value | WaitForNames<Value>)[]): boolean {\n const waitForNames = values.filter(isWaitForNames);\n if (waitForNames.length > 0) {\n if (waitForNames.length > 1) {\n throw new InvalidUpdateError(\n \"Received multiple WaitForNames updates in the same step.\"\n );\n }\n this.names = new Set(waitForNames[0].__names);\n return true;\n } else if (this.names !== undefined) {\n let updated = false;\n for (const value of values) {\n if (isWaitForNames(value)) {\n throw new Error(\n \"Assertion Error: Received unexpected WaitForNames instance.\"\n );\n }\n if (this.names.has(value) && !this.seen.has(value)) {\n this.seen.add(value);\n updated = true;\n }\n }\n return updated;\n }\n return false;\n }\n\n consume(): boolean {\n if (\n this.finished &&\n this.seen &&\n this.names &&\n areSetsEqual(this.seen, this.names)\n ) {\n this.seen = new Set<Value>();\n this.names = undefined;\n this.finished = false;\n return true;\n }\n return false;\n }\n\n finish(): boolean {\n if (!this.finished && this.names && areSetsEqual(this.names, this.seen)) {\n this.finished = true;\n return true;\n }\n return false;\n }\n\n get(): void {\n if (!this.finished || !this.names || !areSetsEqual(this.names, this.seen)) {\n throw new EmptyChannelError();\n }\n return undefined;\n }\n\n checkpoint(): [Value[] | undefined, Value[], boolean] {\n return [\n this.names ? [...this.names] : undefined,\n [...this.seen],\n this.finished,\n ];\n }\n\n isAvailable(): boolean {\n return this.finished && !!this.names && areSetsEqual(this.names, this.seen);\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"dynamic_barrier_value.cjs","names":["BaseChannel","InvalidUpdateError","areSetsEqual","EmptyChannelError"],"sources":["../../src/channels/dynamic_barrier_value.ts"],"sourcesContent":["import { EmptyChannelError, InvalidUpdateError } from \"../errors.js\";\nimport { BaseChannel } from \"./base.js\";\nimport { areSetsEqual } from \"./named_barrier_value.js\";\n\nexport interface WaitForNames<Value> {\n __names: Value[];\n}\n\nfunction isWaitForNames<Value>(\n v: WaitForNames<Value> | Value\n): v is WaitForNames<Value> {\n return (v as WaitForNames<Value>).__names !== undefined;\n}\n\n/**\n * A channel that switches between two states\n *\n * - in the \"priming\" state it can't be read from.\n * - if it receives a WaitForNames update, it switches to the \"waiting\" state.\n * - in the \"waiting\" state it collects named values until all are received.\n * - once all named values are received, it can be read once, and it switches\n * back to the \"priming\" state.\n */\nexport class DynamicBarrierValue<Value> extends BaseChannel<\n void,\n Value | WaitForNames<Value>,\n [Value[] | undefined, Value[]]\n> {\n lc_graph_name = \"DynamicBarrierValue\";\n\n names?: Set<Value>; // Names of nodes that we want to wait for.\n\n seen: Set<Value>;\n\n constructor() {\n super();\n this.names = undefined;\n this.seen = new Set<Value>();\n }\n\n fromCheckpoint(checkpoint?: [Value[] | undefined, Value[]]) {\n const empty = new DynamicBarrierValue<Value>();\n if (typeof checkpoint !== \"undefined\") {\n empty.names = new Set(checkpoint[0]);\n empty.seen = new Set(checkpoint[1]);\n }\n return empty as this;\n }\n\n update(values: (Value | WaitForNames<Value>)[]): boolean {\n const waitForNames = values.filter(isWaitForNames);\n if (waitForNames.length > 0) {\n if (waitForNames.length > 1) {\n throw new InvalidUpdateError(\n \"Received multiple WaitForNames updates in the same step.\"\n );\n }\n this.names = new Set(waitForNames[0].__names);\n return true;\n } else if (this.names !== undefined) {\n let updated = false;\n for (const value of values) {\n if (isWaitForNames(value)) {\n throw new Error(\n \"Assertion Error: Received unexpected WaitForNames instance.\"\n );\n }\n if (this.names.has(value) && !this.seen.has(value)) {\n this.seen.add(value);\n updated = true;\n }\n }\n return updated;\n }\n return false;\n }\n\n consume(): boolean {\n if (this.seen && this.names && areSetsEqual(this.seen, this.names)) {\n this.seen = new Set<Value>();\n this.names = undefined;\n return true;\n }\n return false;\n }\n\n // If we have not yet seen all the node names we want to wait for,\n // throw an error to prevent continuing.\n get(): void {\n if (!this.names || !areSetsEqual(this.names, this.seen)) {\n throw new EmptyChannelError();\n }\n return undefined;\n }\n\n checkpoint(): [Value[] | undefined, Value[]] {\n return [this.names ? [...this.names] : undefined, [...this.seen]];\n }\n\n isAvailable(): boolean {\n return !!this.names && areSetsEqual(this.names, this.seen);\n }\n}\n\n/**\n * A channel that switches between two states with an additional finished flag\n *\n * - in the \"priming\" state it can't be read from.\n * - if it receives a WaitForNames update, it switches to the \"waiting\" state.\n * - in the \"waiting\" state it collects named values until all are received.\n * - once all named values are received, and the finished flag is set, it can be read once, and it switches\n * back to the \"priming\" state.\n * @internal\n */\nexport class DynamicBarrierValueAfterFinish<Value> extends BaseChannel<\n void,\n Value | WaitForNames<Value>,\n [Value[] | undefined, Value[], boolean]\n> {\n lc_graph_name = \"DynamicBarrierValueAfterFinish\";\n\n names?: Set<Value>; // Names of nodes that we want to wait for.\n\n seen: Set<Value>;\n\n finished: boolean;\n\n constructor() {\n super();\n this.names = undefined;\n this.seen = new Set<Value>();\n this.finished = false;\n }\n\n fromCheckpoint(checkpoint?: [Value[] | undefined, Value[], boolean]) {\n const empty = new DynamicBarrierValueAfterFinish<Value>();\n if (typeof checkpoint !== \"undefined\") {\n const [names, seen, finished] = checkpoint;\n empty.names = names ? new Set(names) : undefined;\n empty.seen = new Set(seen);\n empty.finished = finished;\n }\n return empty as this;\n }\n\n update(values: (Value | WaitForNames<Value>)[]): boolean {\n const waitForNames = values.filter(isWaitForNames);\n if (waitForNames.length > 0) {\n if (waitForNames.length > 1) {\n throw new InvalidUpdateError(\n \"Received multiple WaitForNames updates in the same step.\"\n );\n }\n this.names = new Set(waitForNames[0].__names);\n return true;\n } else if (this.names !== undefined) {\n let updated = false;\n for (const value of values) {\n if (isWaitForNames(value)) {\n throw new Error(\n \"Assertion Error: Received unexpected WaitForNames instance.\"\n );\n }\n if (this.names.has(value) && !this.seen.has(value)) {\n this.seen.add(value);\n updated = true;\n }\n }\n return updated;\n }\n return false;\n }\n\n consume(): boolean {\n if (\n this.finished &&\n this.seen &&\n this.names &&\n areSetsEqual(this.seen, this.names)\n ) {\n this.seen = new Set<Value>();\n this.names = undefined;\n this.finished = false;\n return true;\n }\n return false;\n }\n\n finish(): boolean {\n if (!this.finished && this.names && areSetsEqual(this.names, this.seen)) {\n this.finished = true;\n return true;\n }\n return false;\n }\n\n get(): void {\n if (!this.finished || !this.names || !areSetsEqual(this.names, this.seen)) {\n throw new EmptyChannelError();\n }\n return undefined;\n }\n\n checkpoint(): [Value[] | undefined, Value[], boolean] {\n return [\n this.names ? [...this.names] : undefined,\n [...this.seen],\n this.finished,\n ];\n }\n\n isAvailable(): boolean {\n return this.finished && !!this.names && areSetsEqual(this.names, this.seen);\n }\n}\n"],"mappings":";;;;AAQA,SAAS,eACP,GAC0B;AAC1B,QAAQ,EAA0B,YAAY,KAAA;;;;;;;;;;;AAYhD,IAAa,sBAAb,MAAa,4BAAmCA,aAAAA,YAI9C;CACA,gBAAgB;CAEhB;CAEA;CAEA,cAAc;AACZ,SAAO;AACP,OAAK,QAAQ,KAAA;AACb,OAAK,uBAAO,IAAI,KAAY;;CAG9B,eAAe,YAA6C;EAC1D,MAAM,QAAQ,IAAI,qBAA4B;AAC9C,MAAI,OAAO,eAAe,aAAa;AACrC,SAAM,QAAQ,IAAI,IAAI,WAAW,GAAG;AACpC,SAAM,OAAO,IAAI,IAAI,WAAW,GAAG;;AAErC,SAAO;;CAGT,OAAO,QAAkD;EACvD,MAAM,eAAe,OAAO,OAAO,eAAe;AAClD,MAAI,aAAa,SAAS,GAAG;AAC3B,OAAI,aAAa,SAAS,EACxB,OAAM,IAAIC,eAAAA,mBACR,2DACD;AAEH,QAAK,QAAQ,IAAI,IAAI,aAAa,GAAG,QAAQ;AAC7C,UAAO;aACE,KAAK,UAAU,KAAA,GAAW;GACnC,IAAI,UAAU;AACd,QAAK,MAAM,SAAS,QAAQ;AAC1B,QAAI,eAAe,MAAM,CACvB,OAAM,IAAI,MACR,8DACD;AAEH,QAAI,KAAK,MAAM,IAAI,MAAM,IAAI,CAAC,KAAK,KAAK,IAAI,MAAM,EAAE;AAClD,UAAK,KAAK,IAAI,MAAM;AACpB,eAAU;;;AAGd,UAAO;;AAET,SAAO;;CAGT,UAAmB;AACjB,MAAI,KAAK,QAAQ,KAAK,SAASC,4BAAAA,aAAa,KAAK,MAAM,KAAK,MAAM,EAAE;AAClE,QAAK,uBAAO,IAAI,KAAY;AAC5B,QAAK,QAAQ,KAAA;AACb,UAAO;;AAET,SAAO;;CAKT,MAAY;AACV,MAAI,CAAC,KAAK,SAAS,CAACA,4BAAAA,aAAa,KAAK,OAAO,KAAK,KAAK,CACrD,OAAM,IAAIC,eAAAA,mBAAmB;;CAKjC,aAA6C;AAC3C,SAAO,CAAC,KAAK,QAAQ,CAAC,GAAG,KAAK,MAAM,GAAG,KAAA,GAAW,CAAC,GAAG,KAAK,KAAK,CAAC;;CAGnE,cAAuB;AACrB,SAAO,CAAC,CAAC,KAAK,SAASD,4BAAAA,aAAa,KAAK,OAAO,KAAK,KAAK"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { EmptyChannelError, InvalidUpdateError } from "../errors.js";
|
|
2
2
|
import { BaseChannel } from "./base.js";
|
|
3
3
|
import { areSetsEqual } from "./named_barrier_value.js";
|
|
4
|
-
|
|
5
4
|
//#region src/channels/dynamic_barrier_value.ts
|
|
6
5
|
function isWaitForNames(v) {
|
|
7
6
|
return v.__names !== void 0;
|
|
@@ -69,7 +68,7 @@ var DynamicBarrierValue = class DynamicBarrierValue extends BaseChannel {
|
|
|
69
68
|
return !!this.names && areSetsEqual(this.names, this.seen);
|
|
70
69
|
}
|
|
71
70
|
};
|
|
72
|
-
|
|
73
71
|
//#endregion
|
|
74
72
|
export { DynamicBarrierValue };
|
|
73
|
+
|
|
75
74
|
//# sourceMappingURL=dynamic_barrier_value.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dynamic_barrier_value.js","names":[],"sources":["../../src/channels/dynamic_barrier_value.ts"],"sourcesContent":["import { EmptyChannelError, InvalidUpdateError } from \"../errors.js\";\nimport { BaseChannel } from \"./base.js\";\nimport { areSetsEqual } from \"./named_barrier_value.js\";\n\nexport interface WaitForNames<Value> {\n __names: Value[];\n}\n\nfunction isWaitForNames<Value>(\n v: WaitForNames<Value> | Value\n): v is WaitForNames<Value> {\n return (v as WaitForNames<Value>).__names !== undefined;\n}\n\n/**\n * A channel that switches between two states\n *\n * - in the \"priming\" state it can't be read from.\n * - if it receives a WaitForNames update, it switches to the \"waiting\" state.\n * - in the \"waiting\" state it collects named values until all are received.\n * - once all named values are received, it can be read once, and it switches\n * back to the \"priming\" state.\n */\nexport class DynamicBarrierValue<Value> extends BaseChannel<\n void,\n Value | WaitForNames<Value>,\n [Value[] | undefined, Value[]]\n> {\n lc_graph_name = \"DynamicBarrierValue\";\n\n names?: Set<Value>; // Names of nodes that we want to wait for.\n\n seen: Set<Value>;\n\n constructor() {\n super();\n this.names = undefined;\n this.seen = new Set<Value>();\n }\n\n fromCheckpoint(checkpoint?: [Value[] | undefined, Value[]]) {\n const empty = new DynamicBarrierValue<Value>();\n if (typeof checkpoint !== \"undefined\") {\n empty.names = new Set(checkpoint[0]);\n empty.seen = new Set(checkpoint[1]);\n }\n return empty as this;\n }\n\n update(values: (Value | WaitForNames<Value>)[]): boolean {\n const waitForNames = values.filter(isWaitForNames);\n if (waitForNames.length > 0) {\n if (waitForNames.length > 1) {\n throw new InvalidUpdateError(\n \"Received multiple WaitForNames updates in the same step.\"\n );\n }\n this.names = new Set(waitForNames[0].__names);\n return true;\n } else if (this.names !== undefined) {\n let updated = false;\n for (const value of values) {\n if (isWaitForNames(value)) {\n throw new Error(\n \"Assertion Error: Received unexpected WaitForNames instance.\"\n );\n }\n if (this.names.has(value) && !this.seen.has(value)) {\n this.seen.add(value);\n updated = true;\n }\n }\n return updated;\n }\n return false;\n }\n\n consume(): boolean {\n if (this.seen && this.names && areSetsEqual(this.seen, this.names)) {\n this.seen = new Set<Value>();\n this.names = undefined;\n return true;\n }\n return false;\n }\n\n // If we have not yet seen all the node names we want to wait for,\n // throw an error to prevent continuing.\n get(): void {\n if (!this.names || !areSetsEqual(this.names, this.seen)) {\n throw new EmptyChannelError();\n }\n return undefined;\n }\n\n checkpoint(): [Value[] | undefined, Value[]] {\n return [this.names ? [...this.names] : undefined, [...this.seen]];\n }\n\n isAvailable(): boolean {\n return !!this.names && areSetsEqual(this.names, this.seen);\n }\n}\n\n/**\n * A channel that switches between two states with an additional finished flag\n *\n * - in the \"priming\" state it can't be read from.\n * - if it receives a WaitForNames update, it switches to the \"waiting\" state.\n * - in the \"waiting\" state it collects named values until all are received.\n * - once all named values are received, and the finished flag is set, it can be read once, and it switches\n * back to the \"priming\" state.\n * @internal\n */\nexport class DynamicBarrierValueAfterFinish<Value> extends BaseChannel<\n void,\n Value | WaitForNames<Value>,\n [Value[] | undefined, Value[], boolean]\n> {\n lc_graph_name = \"DynamicBarrierValueAfterFinish\";\n\n names?: Set<Value>; // Names of nodes that we want to wait for.\n\n seen: Set<Value>;\n\n finished: boolean;\n\n constructor() {\n super();\n this.names = undefined;\n this.seen = new Set<Value>();\n this.finished = false;\n }\n\n fromCheckpoint(checkpoint?: [Value[] | undefined, Value[], boolean]) {\n const empty = new DynamicBarrierValueAfterFinish<Value>();\n if (typeof checkpoint !== \"undefined\") {\n const [names, seen, finished] = checkpoint;\n empty.names = names ? new Set(names) : undefined;\n empty.seen = new Set(seen);\n empty.finished = finished;\n }\n return empty as this;\n }\n\n update(values: (Value | WaitForNames<Value>)[]): boolean {\n const waitForNames = values.filter(isWaitForNames);\n if (waitForNames.length > 0) {\n if (waitForNames.length > 1) {\n throw new InvalidUpdateError(\n \"Received multiple WaitForNames updates in the same step.\"\n );\n }\n this.names = new Set(waitForNames[0].__names);\n return true;\n } else if (this.names !== undefined) {\n let updated = false;\n for (const value of values) {\n if (isWaitForNames(value)) {\n throw new Error(\n \"Assertion Error: Received unexpected WaitForNames instance.\"\n );\n }\n if (this.names.has(value) && !this.seen.has(value)) {\n this.seen.add(value);\n updated = true;\n }\n }\n return updated;\n }\n return false;\n }\n\n consume(): boolean {\n if (\n this.finished &&\n this.seen &&\n this.names &&\n areSetsEqual(this.seen, this.names)\n ) {\n this.seen = new Set<Value>();\n this.names = undefined;\n this.finished = false;\n return true;\n }\n return false;\n }\n\n finish(): boolean {\n if (!this.finished && this.names && areSetsEqual(this.names, this.seen)) {\n this.finished = true;\n return true;\n }\n return false;\n }\n\n get(): void {\n if (!this.finished || !this.names || !areSetsEqual(this.names, this.seen)) {\n throw new EmptyChannelError();\n }\n return undefined;\n }\n\n checkpoint(): [Value[] | undefined, Value[], boolean] {\n return [\n this.names ? [...this.names] : undefined,\n [...this.seen],\n this.finished,\n ];\n }\n\n isAvailable(): boolean {\n return this.finished && !!this.names && areSetsEqual(this.names, this.seen);\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"dynamic_barrier_value.js","names":[],"sources":["../../src/channels/dynamic_barrier_value.ts"],"sourcesContent":["import { EmptyChannelError, InvalidUpdateError } from \"../errors.js\";\nimport { BaseChannel } from \"./base.js\";\nimport { areSetsEqual } from \"./named_barrier_value.js\";\n\nexport interface WaitForNames<Value> {\n __names: Value[];\n}\n\nfunction isWaitForNames<Value>(\n v: WaitForNames<Value> | Value\n): v is WaitForNames<Value> {\n return (v as WaitForNames<Value>).__names !== undefined;\n}\n\n/**\n * A channel that switches between two states\n *\n * - in the \"priming\" state it can't be read from.\n * - if it receives a WaitForNames update, it switches to the \"waiting\" state.\n * - in the \"waiting\" state it collects named values until all are received.\n * - once all named values are received, it can be read once, and it switches\n * back to the \"priming\" state.\n */\nexport class DynamicBarrierValue<Value> extends BaseChannel<\n void,\n Value | WaitForNames<Value>,\n [Value[] | undefined, Value[]]\n> {\n lc_graph_name = \"DynamicBarrierValue\";\n\n names?: Set<Value>; // Names of nodes that we want to wait for.\n\n seen: Set<Value>;\n\n constructor() {\n super();\n this.names = undefined;\n this.seen = new Set<Value>();\n }\n\n fromCheckpoint(checkpoint?: [Value[] | undefined, Value[]]) {\n const empty = new DynamicBarrierValue<Value>();\n if (typeof checkpoint !== \"undefined\") {\n empty.names = new Set(checkpoint[0]);\n empty.seen = new Set(checkpoint[1]);\n }\n return empty as this;\n }\n\n update(values: (Value | WaitForNames<Value>)[]): boolean {\n const waitForNames = values.filter(isWaitForNames);\n if (waitForNames.length > 0) {\n if (waitForNames.length > 1) {\n throw new InvalidUpdateError(\n \"Received multiple WaitForNames updates in the same step.\"\n );\n }\n this.names = new Set(waitForNames[0].__names);\n return true;\n } else if (this.names !== undefined) {\n let updated = false;\n for (const value of values) {\n if (isWaitForNames(value)) {\n throw new Error(\n \"Assertion Error: Received unexpected WaitForNames instance.\"\n );\n }\n if (this.names.has(value) && !this.seen.has(value)) {\n this.seen.add(value);\n updated = true;\n }\n }\n return updated;\n }\n return false;\n }\n\n consume(): boolean {\n if (this.seen && this.names && areSetsEqual(this.seen, this.names)) {\n this.seen = new Set<Value>();\n this.names = undefined;\n return true;\n }\n return false;\n }\n\n // If we have not yet seen all the node names we want to wait for,\n // throw an error to prevent continuing.\n get(): void {\n if (!this.names || !areSetsEqual(this.names, this.seen)) {\n throw new EmptyChannelError();\n }\n return undefined;\n }\n\n checkpoint(): [Value[] | undefined, Value[]] {\n return [this.names ? [...this.names] : undefined, [...this.seen]];\n }\n\n isAvailable(): boolean {\n return !!this.names && areSetsEqual(this.names, this.seen);\n }\n}\n\n/**\n * A channel that switches between two states with an additional finished flag\n *\n * - in the \"priming\" state it can't be read from.\n * - if it receives a WaitForNames update, it switches to the \"waiting\" state.\n * - in the \"waiting\" state it collects named values until all are received.\n * - once all named values are received, and the finished flag is set, it can be read once, and it switches\n * back to the \"priming\" state.\n * @internal\n */\nexport class DynamicBarrierValueAfterFinish<Value> extends BaseChannel<\n void,\n Value | WaitForNames<Value>,\n [Value[] | undefined, Value[], boolean]\n> {\n lc_graph_name = \"DynamicBarrierValueAfterFinish\";\n\n names?: Set<Value>; // Names of nodes that we want to wait for.\n\n seen: Set<Value>;\n\n finished: boolean;\n\n constructor() {\n super();\n this.names = undefined;\n this.seen = new Set<Value>();\n this.finished = false;\n }\n\n fromCheckpoint(checkpoint?: [Value[] | undefined, Value[], boolean]) {\n const empty = new DynamicBarrierValueAfterFinish<Value>();\n if (typeof checkpoint !== \"undefined\") {\n const [names, seen, finished] = checkpoint;\n empty.names = names ? new Set(names) : undefined;\n empty.seen = new Set(seen);\n empty.finished = finished;\n }\n return empty as this;\n }\n\n update(values: (Value | WaitForNames<Value>)[]): boolean {\n const waitForNames = values.filter(isWaitForNames);\n if (waitForNames.length > 0) {\n if (waitForNames.length > 1) {\n throw new InvalidUpdateError(\n \"Received multiple WaitForNames updates in the same step.\"\n );\n }\n this.names = new Set(waitForNames[0].__names);\n return true;\n } else if (this.names !== undefined) {\n let updated = false;\n for (const value of values) {\n if (isWaitForNames(value)) {\n throw new Error(\n \"Assertion Error: Received unexpected WaitForNames instance.\"\n );\n }\n if (this.names.has(value) && !this.seen.has(value)) {\n this.seen.add(value);\n updated = true;\n }\n }\n return updated;\n }\n return false;\n }\n\n consume(): boolean {\n if (\n this.finished &&\n this.seen &&\n this.names &&\n areSetsEqual(this.seen, this.names)\n ) {\n this.seen = new Set<Value>();\n this.names = undefined;\n this.finished = false;\n return true;\n }\n return false;\n }\n\n finish(): boolean {\n if (!this.finished && this.names && areSetsEqual(this.names, this.seen)) {\n this.finished = true;\n return true;\n }\n return false;\n }\n\n get(): void {\n if (!this.finished || !this.names || !areSetsEqual(this.names, this.seen)) {\n throw new EmptyChannelError();\n }\n return undefined;\n }\n\n checkpoint(): [Value[] | undefined, Value[], boolean] {\n return [\n this.names ? [...this.names] : undefined,\n [...this.seen],\n this.finished,\n ];\n }\n\n isAvailable(): boolean {\n return this.finished && !!this.names && areSetsEqual(this.names, this.seen);\n }\n}\n"],"mappings":";;;;AAQA,SAAS,eACP,GAC0B;AAC1B,QAAQ,EAA0B,YAAY,KAAA;;;;;;;;;;;AAYhD,IAAa,sBAAb,MAAa,4BAAmC,YAI9C;CACA,gBAAgB;CAEhB;CAEA;CAEA,cAAc;AACZ,SAAO;AACP,OAAK,QAAQ,KAAA;AACb,OAAK,uBAAO,IAAI,KAAY;;CAG9B,eAAe,YAA6C;EAC1D,MAAM,QAAQ,IAAI,qBAA4B;AAC9C,MAAI,OAAO,eAAe,aAAa;AACrC,SAAM,QAAQ,IAAI,IAAI,WAAW,GAAG;AACpC,SAAM,OAAO,IAAI,IAAI,WAAW,GAAG;;AAErC,SAAO;;CAGT,OAAO,QAAkD;EACvD,MAAM,eAAe,OAAO,OAAO,eAAe;AAClD,MAAI,aAAa,SAAS,GAAG;AAC3B,OAAI,aAAa,SAAS,EACxB,OAAM,IAAI,mBACR,2DACD;AAEH,QAAK,QAAQ,IAAI,IAAI,aAAa,GAAG,QAAQ;AAC7C,UAAO;aACE,KAAK,UAAU,KAAA,GAAW;GACnC,IAAI,UAAU;AACd,QAAK,MAAM,SAAS,QAAQ;AAC1B,QAAI,eAAe,MAAM,CACvB,OAAM,IAAI,MACR,8DACD;AAEH,QAAI,KAAK,MAAM,IAAI,MAAM,IAAI,CAAC,KAAK,KAAK,IAAI,MAAM,EAAE;AAClD,UAAK,KAAK,IAAI,MAAM;AACpB,eAAU;;;AAGd,UAAO;;AAET,SAAO;;CAGT,UAAmB;AACjB,MAAI,KAAK,QAAQ,KAAK,SAAS,aAAa,KAAK,MAAM,KAAK,MAAM,EAAE;AAClE,QAAK,uBAAO,IAAI,KAAY;AAC5B,QAAK,QAAQ,KAAA;AACb,UAAO;;AAET,SAAO;;CAKT,MAAY;AACV,MAAI,CAAC,KAAK,SAAS,CAAC,aAAa,KAAK,OAAO,KAAK,KAAK,CACrD,OAAM,IAAI,mBAAmB;;CAKjC,aAA6C;AAC3C,SAAO,CAAC,KAAK,QAAQ,CAAC,GAAG,KAAK,MAAM,GAAG,KAAA,GAAW,CAAC,GAAG,KAAK,KAAK,CAAC;;CAGnE,cAAuB;AACrB,SAAO,CAAC,CAAC,KAAK,SAAS,aAAa,KAAK,OAAO,KAAK,KAAK"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
const require_errors = require(
|
|
2
|
-
const require_base = require(
|
|
3
|
-
|
|
1
|
+
const require_errors = require("../errors.cjs");
|
|
2
|
+
const require_base = require("./base.cjs");
|
|
4
3
|
//#region src/channels/ephemeral_value.ts
|
|
5
4
|
/**
|
|
6
5
|
* Stores the value received in the step immediately preceding, clears after.
|
|
@@ -40,7 +39,7 @@ var EphemeralValue = class EphemeralValue extends require_base.BaseChannel {
|
|
|
40
39
|
return this.value.length !== 0;
|
|
41
40
|
}
|
|
42
41
|
};
|
|
43
|
-
|
|
44
42
|
//#endregion
|
|
45
43
|
exports.EphemeralValue = EphemeralValue;
|
|
44
|
+
|
|
46
45
|
//# sourceMappingURL=ephemeral_value.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ephemeral_value.cjs","names":["BaseChannel","InvalidUpdateError","EmptyChannelError"],"sources":["../../src/channels/ephemeral_value.ts"],"sourcesContent":["import { EmptyChannelError, InvalidUpdateError } from \"../errors.js\";\nimport { BaseChannel } from \"./base.js\";\n\n/**\n * Stores the value received in the step immediately preceding, clears after.\n */\nexport class EphemeralValue<Value> extends BaseChannel<Value, Value, Value> {\n lc_graph_name = \"EphemeralValue\";\n\n guard: boolean;\n\n // value is an array so we don't misinterpret an update to undefined as no write\n value: [Value] | [] = [];\n\n constructor(guard: boolean = true) {\n super();\n this.guard = guard;\n }\n\n fromCheckpoint(checkpoint?: Value) {\n const empty = new EphemeralValue<Value>(this.guard);\n if (typeof checkpoint !== \"undefined\") {\n empty.value = [checkpoint];\n }\n return empty as this;\n }\n\n update(values: Value[]): boolean {\n if (values.length === 0) {\n const updated = this.value.length > 0;\n // If there are no updates for this specific channel at the end of the step, wipe it.\n this.value = [];\n return updated;\n }\n if (values.length !== 1 && this.guard) {\n throw new InvalidUpdateError(\n \"EphemeralValue can only receive one value per step.\"\n );\n }\n\n // eslint-disable-next-line prefer-destructuring\n this.value = [values[values.length - 1]];\n return true;\n }\n\n get(): Value {\n if (this.value.length === 0) {\n throw new EmptyChannelError();\n }\n return this.value[0];\n }\n\n checkpoint(): Value {\n if (this.value.length === 0) {\n throw new EmptyChannelError();\n }\n return this.value[0];\n }\n\n isAvailable(): boolean {\n return this.value.length !== 0;\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ephemeral_value.cjs","names":["BaseChannel","InvalidUpdateError","EmptyChannelError"],"sources":["../../src/channels/ephemeral_value.ts"],"sourcesContent":["import { EmptyChannelError, InvalidUpdateError } from \"../errors.js\";\nimport { BaseChannel } from \"./base.js\";\n\n/**\n * Stores the value received in the step immediately preceding, clears after.\n */\nexport class EphemeralValue<Value> extends BaseChannel<Value, Value, Value> {\n lc_graph_name = \"EphemeralValue\";\n\n guard: boolean;\n\n // value is an array so we don't misinterpret an update to undefined as no write\n value: [Value] | [] = [];\n\n constructor(guard: boolean = true) {\n super();\n this.guard = guard;\n }\n\n fromCheckpoint(checkpoint?: Value) {\n const empty = new EphemeralValue<Value>(this.guard);\n if (typeof checkpoint !== \"undefined\") {\n empty.value = [checkpoint];\n }\n return empty as this;\n }\n\n update(values: Value[]): boolean {\n if (values.length === 0) {\n const updated = this.value.length > 0;\n // If there are no updates for this specific channel at the end of the step, wipe it.\n this.value = [];\n return updated;\n }\n if (values.length !== 1 && this.guard) {\n throw new InvalidUpdateError(\n \"EphemeralValue can only receive one value per step.\"\n );\n }\n\n // eslint-disable-next-line prefer-destructuring\n this.value = [values[values.length - 1]];\n return true;\n }\n\n get(): Value {\n if (this.value.length === 0) {\n throw new EmptyChannelError();\n }\n return this.value[0];\n }\n\n checkpoint(): Value {\n if (this.value.length === 0) {\n throw new EmptyChannelError();\n }\n return this.value[0];\n }\n\n isAvailable(): boolean {\n return this.value.length !== 0;\n }\n}\n"],"mappings":";;;;;;AAMA,IAAa,iBAAb,MAAa,uBAA8BA,aAAAA,YAAiC;CAC1E,gBAAgB;CAEhB;CAGA,QAAsB,EAAE;CAExB,YAAY,QAAiB,MAAM;AACjC,SAAO;AACP,OAAK,QAAQ;;CAGf,eAAe,YAAoB;EACjC,MAAM,QAAQ,IAAI,eAAsB,KAAK,MAAM;AACnD,MAAI,OAAO,eAAe,YACxB,OAAM,QAAQ,CAAC,WAAW;AAE5B,SAAO;;CAGT,OAAO,QAA0B;AAC/B,MAAI,OAAO,WAAW,GAAG;GACvB,MAAM,UAAU,KAAK,MAAM,SAAS;AAEpC,QAAK,QAAQ,EAAE;AACf,UAAO;;AAET,MAAI,OAAO,WAAW,KAAK,KAAK,MAC9B,OAAM,IAAIC,eAAAA,mBACR,sDACD;AAIH,OAAK,QAAQ,CAAC,OAAO,OAAO,SAAS,GAAG;AACxC,SAAO;;CAGT,MAAa;AACX,MAAI,KAAK,MAAM,WAAW,EACxB,OAAM,IAAIC,eAAAA,mBAAmB;AAE/B,SAAO,KAAK,MAAM;;CAGpB,aAAoB;AAClB,MAAI,KAAK,MAAM,WAAW,EACxB,OAAM,IAAIA,eAAAA,mBAAmB;AAE/B,SAAO,KAAK,MAAM;;CAGpB,cAAuB;AACrB,SAAO,KAAK,MAAM,WAAW"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { EmptyChannelError, InvalidUpdateError } from "../errors.js";
|
|
2
2
|
import { BaseChannel } from "./base.js";
|
|
3
|
-
|
|
4
3
|
//#region src/channels/ephemeral_value.ts
|
|
5
4
|
/**
|
|
6
5
|
* Stores the value received in the step immediately preceding, clears after.
|
|
@@ -40,7 +39,7 @@ var EphemeralValue = class EphemeralValue extends BaseChannel {
|
|
|
40
39
|
return this.value.length !== 0;
|
|
41
40
|
}
|
|
42
41
|
};
|
|
43
|
-
|
|
44
42
|
//#endregion
|
|
45
43
|
export { EphemeralValue };
|
|
44
|
+
|
|
46
45
|
//# sourceMappingURL=ephemeral_value.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ephemeral_value.js","names":[],"sources":["../../src/channels/ephemeral_value.ts"],"sourcesContent":["import { EmptyChannelError, InvalidUpdateError } from \"../errors.js\";\nimport { BaseChannel } from \"./base.js\";\n\n/**\n * Stores the value received in the step immediately preceding, clears after.\n */\nexport class EphemeralValue<Value> extends BaseChannel<Value, Value, Value> {\n lc_graph_name = \"EphemeralValue\";\n\n guard: boolean;\n\n // value is an array so we don't misinterpret an update to undefined as no write\n value: [Value] | [] = [];\n\n constructor(guard: boolean = true) {\n super();\n this.guard = guard;\n }\n\n fromCheckpoint(checkpoint?: Value) {\n const empty = new EphemeralValue<Value>(this.guard);\n if (typeof checkpoint !== \"undefined\") {\n empty.value = [checkpoint];\n }\n return empty as this;\n }\n\n update(values: Value[]): boolean {\n if (values.length === 0) {\n const updated = this.value.length > 0;\n // If there are no updates for this specific channel at the end of the step, wipe it.\n this.value = [];\n return updated;\n }\n if (values.length !== 1 && this.guard) {\n throw new InvalidUpdateError(\n \"EphemeralValue can only receive one value per step.\"\n );\n }\n\n // eslint-disable-next-line prefer-destructuring\n this.value = [values[values.length - 1]];\n return true;\n }\n\n get(): Value {\n if (this.value.length === 0) {\n throw new EmptyChannelError();\n }\n return this.value[0];\n }\n\n checkpoint(): Value {\n if (this.value.length === 0) {\n throw new EmptyChannelError();\n }\n return this.value[0];\n }\n\n isAvailable(): boolean {\n return this.value.length !== 0;\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ephemeral_value.js","names":[],"sources":["../../src/channels/ephemeral_value.ts"],"sourcesContent":["import { EmptyChannelError, InvalidUpdateError } from \"../errors.js\";\nimport { BaseChannel } from \"./base.js\";\n\n/**\n * Stores the value received in the step immediately preceding, clears after.\n */\nexport class EphemeralValue<Value> extends BaseChannel<Value, Value, Value> {\n lc_graph_name = \"EphemeralValue\";\n\n guard: boolean;\n\n // value is an array so we don't misinterpret an update to undefined as no write\n value: [Value] | [] = [];\n\n constructor(guard: boolean = true) {\n super();\n this.guard = guard;\n }\n\n fromCheckpoint(checkpoint?: Value) {\n const empty = new EphemeralValue<Value>(this.guard);\n if (typeof checkpoint !== \"undefined\") {\n empty.value = [checkpoint];\n }\n return empty as this;\n }\n\n update(values: Value[]): boolean {\n if (values.length === 0) {\n const updated = this.value.length > 0;\n // If there are no updates for this specific channel at the end of the step, wipe it.\n this.value = [];\n return updated;\n }\n if (values.length !== 1 && this.guard) {\n throw new InvalidUpdateError(\n \"EphemeralValue can only receive one value per step.\"\n );\n }\n\n // eslint-disable-next-line prefer-destructuring\n this.value = [values[values.length - 1]];\n return true;\n }\n\n get(): Value {\n if (this.value.length === 0) {\n throw new EmptyChannelError();\n }\n return this.value[0];\n }\n\n checkpoint(): Value {\n if (this.value.length === 0) {\n throw new EmptyChannelError();\n }\n return this.value[0];\n }\n\n isAvailable(): boolean {\n return this.value.length !== 0;\n }\n}\n"],"mappings":";;;;;;AAMA,IAAa,iBAAb,MAAa,uBAA8B,YAAiC;CAC1E,gBAAgB;CAEhB;CAGA,QAAsB,EAAE;CAExB,YAAY,QAAiB,MAAM;AACjC,SAAO;AACP,OAAK,QAAQ;;CAGf,eAAe,YAAoB;EACjC,MAAM,QAAQ,IAAI,eAAsB,KAAK,MAAM;AACnD,MAAI,OAAO,eAAe,YACxB,OAAM,QAAQ,CAAC,WAAW;AAE5B,SAAO;;CAGT,OAAO,QAA0B;AAC/B,MAAI,OAAO,WAAW,GAAG;GACvB,MAAM,UAAU,KAAK,MAAM,SAAS;AAEpC,QAAK,QAAQ,EAAE;AACf,UAAO;;AAET,MAAI,OAAO,WAAW,KAAK,KAAK,MAC9B,OAAM,IAAI,mBACR,sDACD;AAIH,OAAK,QAAQ,CAAC,OAAO,OAAO,SAAS,GAAG;AACxC,SAAO;;CAGT,MAAa;AACX,MAAI,KAAK,MAAM,WAAW,EACxB,OAAM,IAAI,mBAAmB;AAE/B,SAAO,KAAK,MAAM;;CAGpB,aAAoB;AAClB,MAAI,KAAK,MAAM,WAAW,EACxB,OAAM,IAAI,mBAAmB;AAE/B,SAAO,KAAK,MAAM;;CAGpB,cAAuB;AACrB,SAAO,KAAK,MAAM,WAAW"}
|
package/dist/channels/index.cjs
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value:
|
|
2
|
-
const require_base = require(
|
|
3
|
-
const require_binop = require(
|
|
4
|
-
const require_last_value = require(
|
|
5
|
-
const require_topic = require(
|
|
6
|
-
const require_ephemeral_value = require(
|
|
7
|
-
const require_named_barrier_value = require(
|
|
8
|
-
const require_any_value = require(
|
|
9
|
-
const require_dynamic_barrier_value = require(
|
|
10
|
-
const require_untracked_value = require(
|
|
11
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_base = require("./base.cjs");
|
|
3
|
+
const require_binop = require("./binop.cjs");
|
|
4
|
+
const require_last_value = require("./last_value.cjs");
|
|
5
|
+
const require_topic = require("./topic.cjs");
|
|
6
|
+
const require_ephemeral_value = require("./ephemeral_value.cjs");
|
|
7
|
+
const require_named_barrier_value = require("./named_barrier_value.cjs");
|
|
8
|
+
const require_any_value = require("./any_value.cjs");
|
|
9
|
+
const require_dynamic_barrier_value = require("./dynamic_barrier_value.cjs");
|
|
10
|
+
const require_untracked_value = require("./untracked_value.cjs");
|
|
12
11
|
exports.AnyValue = require_any_value.AnyValue;
|
|
13
12
|
exports.BaseChannel = require_base.BaseChannel;
|
|
14
13
|
exports.BinaryOperatorAggregate = require_binop.BinaryOperatorAggregate;
|
|
@@ -21,4 +20,4 @@ exports.NamedBarrierValueAfterFinish = require_named_barrier_value.NamedBarrierV
|
|
|
21
20
|
exports.Topic = require_topic.Topic;
|
|
22
21
|
exports.UntrackedValueChannel = require_untracked_value.UntrackedValueChannel;
|
|
23
22
|
exports.createCheckpoint = require_base.createCheckpoint;
|
|
24
|
-
exports.empty = require_base.emptyChannels;
|
|
23
|
+
exports.empty = require_base.emptyChannels;
|
package/dist/channels/index.js
CHANGED
|
@@ -7,5 +7,4 @@ import { NamedBarrierValue, NamedBarrierValueAfterFinish } from "./named_barrier
|
|
|
7
7
|
import { AnyValue } from "./any_value.js";
|
|
8
8
|
import { DynamicBarrierValue } from "./dynamic_barrier_value.js";
|
|
9
9
|
import { UntrackedValueChannel } from "./untracked_value.js";
|
|
10
|
-
|
|
11
|
-
export { AnyValue, BaseChannel, BinaryOperatorAggregate, DynamicBarrierValue, EphemeralValue, LastValue, LastValueAfterFinish, NamedBarrierValue, NamedBarrierValueAfterFinish, Topic, UntrackedValueChannel, createCheckpoint, emptyChannels as empty };
|
|
10
|
+
export { AnyValue, BaseChannel, BinaryOperatorAggregate, DynamicBarrierValue, EphemeralValue, LastValue, LastValueAfterFinish, NamedBarrierValue, NamedBarrierValueAfterFinish, Topic, UntrackedValueChannel, createCheckpoint, emptyChannels as empty };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
const require_errors = require(
|
|
2
|
-
const require_base = require(
|
|
3
|
-
|
|
1
|
+
const require_errors = require("../errors.cjs");
|
|
2
|
+
const require_base = require("./base.cjs");
|
|
4
3
|
//#region src/channels/last_value.ts
|
|
5
4
|
/**
|
|
6
5
|
* Stores the last value received, can receive at most one value per step.
|
|
@@ -91,8 +90,8 @@ var LastValueAfterFinish = class LastValueAfterFinish extends require_base.BaseC
|
|
|
91
90
|
return this.value.length !== 0 && this.finished;
|
|
92
91
|
}
|
|
93
92
|
};
|
|
94
|
-
|
|
95
93
|
//#endregion
|
|
96
94
|
exports.LastValue = LastValue;
|
|
97
95
|
exports.LastValueAfterFinish = LastValueAfterFinish;
|
|
96
|
+
|
|
98
97
|
//# sourceMappingURL=last_value.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"last_value.cjs","names":["BaseChannel","InvalidUpdateError","EmptyChannelError"],"sources":["../../src/channels/last_value.ts"],"sourcesContent":["import { EmptyChannelError, InvalidUpdateError } from \"../errors.js\";\nimport { BaseChannel } from \"./base.js\";\n\n/**\n * Stores the last value received, can receive at most one value per step.\n *\n * Since `update` is only called once per step and value can only be of length 1,\n * LastValue always stores the last value of a single node. If multiple nodes attempt to\n * write to this channel in a single step, an error will be thrown.\n * @internal\n */\nexport class LastValue<Value> extends BaseChannel<Value, Value, Value> {\n lc_graph_name = \"LastValue\";\n\n // value is an array so we don't misinterpret an update to undefined as no write\n value: [Value] | [] = [];\n\n constructor(protected initialValueFactory?: () => Value) {\n super();\n if (initialValueFactory) {\n this.value = [initialValueFactory()];\n }\n }\n\n fromCheckpoint(checkpoint?: Value) {\n const empty = new LastValue<Value>(this.initialValueFactory);\n if (typeof checkpoint !== \"undefined\") {\n empty.value = [checkpoint];\n }\n\n return empty as this;\n }\n\n update(values: Value[]): boolean {\n if (values.length === 0) {\n return false;\n }\n if (values.length !== 1) {\n throw new InvalidUpdateError(\n \"LastValue can only receive one value per step.\",\n { lc_error_code: \"INVALID_CONCURRENT_GRAPH_UPDATE\" }\n );\n }\n\n // eslint-disable-next-line prefer-destructuring\n this.value = [values[values.length - 1]];\n return true;\n }\n\n get(): Value {\n if (this.value.length === 0) {\n throw new EmptyChannelError();\n }\n return this.value[0];\n }\n\n checkpoint(): Value {\n if (this.value.length === 0) {\n throw new EmptyChannelError();\n }\n return this.value[0];\n }\n\n isAvailable(): boolean {\n return this.value.length !== 0;\n }\n}\n\n/**\n * Stores the last value received, but only made available after finish().\n * Once made available, clears the value.\n */\nexport class LastValueAfterFinish<Value> extends BaseChannel<\n Value,\n Value,\n [Value, boolean]\n> {\n lc_graph_name = \"LastValueAfterFinish\";\n\n // value is an array so we don't misinterpret an update to undefined as no write\n value: [Value] | [] = [];\n\n finished: boolean = false;\n\n fromCheckpoint(checkpoint?: [Value, boolean]) {\n const empty = new LastValueAfterFinish<Value>();\n if (typeof checkpoint !== \"undefined\") {\n const [value, finished] = checkpoint;\n empty.value = [value];\n empty.finished = finished;\n }\n return empty as this;\n }\n\n update(values: Value[]): boolean {\n if (values.length === 0) {\n return false;\n }\n\n this.finished = false;\n // eslint-disable-next-line prefer-destructuring\n this.value = [values[values.length - 1]];\n return true;\n }\n\n get(): Value {\n if (this.value.length === 0 || !this.finished) {\n throw new EmptyChannelError();\n }\n return this.value[0];\n }\n\n checkpoint(): [Value, boolean] | undefined {\n if (this.value.length === 0) return undefined;\n return [this.value[0], this.finished];\n }\n\n consume(): boolean {\n if (this.finished) {\n this.finished = false;\n this.value = [];\n return true;\n }\n return false;\n }\n\n finish(): boolean {\n if (!this.finished && this.value.length > 0) {\n this.finished = true;\n return true;\n }\n return false;\n }\n\n isAvailable(): boolean {\n return this.value.length !== 0 && this.finished;\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"last_value.cjs","names":["BaseChannel","InvalidUpdateError","EmptyChannelError"],"sources":["../../src/channels/last_value.ts"],"sourcesContent":["import { EmptyChannelError, InvalidUpdateError } from \"../errors.js\";\nimport { BaseChannel } from \"./base.js\";\n\n/**\n * Stores the last value received, can receive at most one value per step.\n *\n * Since `update` is only called once per step and value can only be of length 1,\n * LastValue always stores the last value of a single node. If multiple nodes attempt to\n * write to this channel in a single step, an error will be thrown.\n * @internal\n */\nexport class LastValue<Value> extends BaseChannel<Value, Value, Value> {\n lc_graph_name = \"LastValue\";\n\n // value is an array so we don't misinterpret an update to undefined as no write\n value: [Value] | [] = [];\n\n constructor(protected initialValueFactory?: () => Value) {\n super();\n if (initialValueFactory) {\n this.value = [initialValueFactory()];\n }\n }\n\n fromCheckpoint(checkpoint?: Value) {\n const empty = new LastValue<Value>(this.initialValueFactory);\n if (typeof checkpoint !== \"undefined\") {\n empty.value = [checkpoint];\n }\n\n return empty as this;\n }\n\n update(values: Value[]): boolean {\n if (values.length === 0) {\n return false;\n }\n if (values.length !== 1) {\n throw new InvalidUpdateError(\n \"LastValue can only receive one value per step.\",\n { lc_error_code: \"INVALID_CONCURRENT_GRAPH_UPDATE\" }\n );\n }\n\n // eslint-disable-next-line prefer-destructuring\n this.value = [values[values.length - 1]];\n return true;\n }\n\n get(): Value {\n if (this.value.length === 0) {\n throw new EmptyChannelError();\n }\n return this.value[0];\n }\n\n checkpoint(): Value {\n if (this.value.length === 0) {\n throw new EmptyChannelError();\n }\n return this.value[0];\n }\n\n isAvailable(): boolean {\n return this.value.length !== 0;\n }\n}\n\n/**\n * Stores the last value received, but only made available after finish().\n * Once made available, clears the value.\n */\nexport class LastValueAfterFinish<Value> extends BaseChannel<\n Value,\n Value,\n [Value, boolean]\n> {\n lc_graph_name = \"LastValueAfterFinish\";\n\n // value is an array so we don't misinterpret an update to undefined as no write\n value: [Value] | [] = [];\n\n finished: boolean = false;\n\n fromCheckpoint(checkpoint?: [Value, boolean]) {\n const empty = new LastValueAfterFinish<Value>();\n if (typeof checkpoint !== \"undefined\") {\n const [value, finished] = checkpoint;\n empty.value = [value];\n empty.finished = finished;\n }\n return empty as this;\n }\n\n update(values: Value[]): boolean {\n if (values.length === 0) {\n return false;\n }\n\n this.finished = false;\n // eslint-disable-next-line prefer-destructuring\n this.value = [values[values.length - 1]];\n return true;\n }\n\n get(): Value {\n if (this.value.length === 0 || !this.finished) {\n throw new EmptyChannelError();\n }\n return this.value[0];\n }\n\n checkpoint(): [Value, boolean] | undefined {\n if (this.value.length === 0) return undefined;\n return [this.value[0], this.finished];\n }\n\n consume(): boolean {\n if (this.finished) {\n this.finished = false;\n this.value = [];\n return true;\n }\n return false;\n }\n\n finish(): boolean {\n if (!this.finished && this.value.length > 0) {\n this.finished = true;\n return true;\n }\n return false;\n }\n\n isAvailable(): boolean {\n return this.value.length !== 0 && this.finished;\n }\n}\n"],"mappings":";;;;;;;;;;;AAWA,IAAa,YAAb,MAAa,kBAAyBA,aAAAA,YAAiC;CACrE,gBAAgB;CAGhB,QAAsB,EAAE;CAExB,YAAY,qBAA6C;AACvD,SAAO;AADa,OAAA,sBAAA;AAEpB,MAAI,oBACF,MAAK,QAAQ,CAAC,qBAAqB,CAAC;;CAIxC,eAAe,YAAoB;EACjC,MAAM,QAAQ,IAAI,UAAiB,KAAK,oBAAoB;AAC5D,MAAI,OAAO,eAAe,YACxB,OAAM,QAAQ,CAAC,WAAW;AAG5B,SAAO;;CAGT,OAAO,QAA0B;AAC/B,MAAI,OAAO,WAAW,EACpB,QAAO;AAET,MAAI,OAAO,WAAW,EACpB,OAAM,IAAIC,eAAAA,mBACR,kDACA,EAAE,eAAe,mCAAmC,CACrD;AAIH,OAAK,QAAQ,CAAC,OAAO,OAAO,SAAS,GAAG;AACxC,SAAO;;CAGT,MAAa;AACX,MAAI,KAAK,MAAM,WAAW,EACxB,OAAM,IAAIC,eAAAA,mBAAmB;AAE/B,SAAO,KAAK,MAAM;;CAGpB,aAAoB;AAClB,MAAI,KAAK,MAAM,WAAW,EACxB,OAAM,IAAIA,eAAAA,mBAAmB;AAE/B,SAAO,KAAK,MAAM;;CAGpB,cAAuB;AACrB,SAAO,KAAK,MAAM,WAAW;;;;;;;AAQjC,IAAa,uBAAb,MAAa,6BAAoCF,aAAAA,YAI/C;CACA,gBAAgB;CAGhB,QAAsB,EAAE;CAExB,WAAoB;CAEpB,eAAe,YAA+B;EAC5C,MAAM,QAAQ,IAAI,sBAA6B;AAC/C,MAAI,OAAO,eAAe,aAAa;GACrC,MAAM,CAAC,OAAO,YAAY;AAC1B,SAAM,QAAQ,CAAC,MAAM;AACrB,SAAM,WAAW;;AAEnB,SAAO;;CAGT,OAAO,QAA0B;AAC/B,MAAI,OAAO,WAAW,EACpB,QAAO;AAGT,OAAK,WAAW;AAEhB,OAAK,QAAQ,CAAC,OAAO,OAAO,SAAS,GAAG;AACxC,SAAO;;CAGT,MAAa;AACX,MAAI,KAAK,MAAM,WAAW,KAAK,CAAC,KAAK,SACnC,OAAM,IAAIE,eAAAA,mBAAmB;AAE/B,SAAO,KAAK,MAAM;;CAGpB,aAA2C;AACzC,MAAI,KAAK,MAAM,WAAW,EAAG,QAAO,KAAA;AACpC,SAAO,CAAC,KAAK,MAAM,IAAI,KAAK,SAAS;;CAGvC,UAAmB;AACjB,MAAI,KAAK,UAAU;AACjB,QAAK,WAAW;AAChB,QAAK,QAAQ,EAAE;AACf,UAAO;;AAET,SAAO;;CAGT,SAAkB;AAChB,MAAI,CAAC,KAAK,YAAY,KAAK,MAAM,SAAS,GAAG;AAC3C,QAAK,WAAW;AAChB,UAAO;;AAET,SAAO;;CAGT,cAAuB;AACrB,SAAO,KAAK,MAAM,WAAW,KAAK,KAAK"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { EmptyChannelError, InvalidUpdateError } from "../errors.js";
|
|
2
2
|
import { BaseChannel } from "./base.js";
|
|
3
|
-
|
|
4
3
|
//#region src/channels/last_value.ts
|
|
5
4
|
/**
|
|
6
5
|
* Stores the last value received, can receive at most one value per step.
|
|
@@ -91,7 +90,7 @@ var LastValueAfterFinish = class LastValueAfterFinish extends BaseChannel {
|
|
|
91
90
|
return this.value.length !== 0 && this.finished;
|
|
92
91
|
}
|
|
93
92
|
};
|
|
94
|
-
|
|
95
93
|
//#endregion
|
|
96
94
|
export { LastValue, LastValueAfterFinish };
|
|
95
|
+
|
|
97
96
|
//# sourceMappingURL=last_value.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"last_value.js","names":[],"sources":["../../src/channels/last_value.ts"],"sourcesContent":["import { EmptyChannelError, InvalidUpdateError } from \"../errors.js\";\nimport { BaseChannel } from \"./base.js\";\n\n/**\n * Stores the last value received, can receive at most one value per step.\n *\n * Since `update` is only called once per step and value can only be of length 1,\n * LastValue always stores the last value of a single node. If multiple nodes attempt to\n * write to this channel in a single step, an error will be thrown.\n * @internal\n */\nexport class LastValue<Value> extends BaseChannel<Value, Value, Value> {\n lc_graph_name = \"LastValue\";\n\n // value is an array so we don't misinterpret an update to undefined as no write\n value: [Value] | [] = [];\n\n constructor(protected initialValueFactory?: () => Value) {\n super();\n if (initialValueFactory) {\n this.value = [initialValueFactory()];\n }\n }\n\n fromCheckpoint(checkpoint?: Value) {\n const empty = new LastValue<Value>(this.initialValueFactory);\n if (typeof checkpoint !== \"undefined\") {\n empty.value = [checkpoint];\n }\n\n return empty as this;\n }\n\n update(values: Value[]): boolean {\n if (values.length === 0) {\n return false;\n }\n if (values.length !== 1) {\n throw new InvalidUpdateError(\n \"LastValue can only receive one value per step.\",\n { lc_error_code: \"INVALID_CONCURRENT_GRAPH_UPDATE\" }\n );\n }\n\n // eslint-disable-next-line prefer-destructuring\n this.value = [values[values.length - 1]];\n return true;\n }\n\n get(): Value {\n if (this.value.length === 0) {\n throw new EmptyChannelError();\n }\n return this.value[0];\n }\n\n checkpoint(): Value {\n if (this.value.length === 0) {\n throw new EmptyChannelError();\n }\n return this.value[0];\n }\n\n isAvailable(): boolean {\n return this.value.length !== 0;\n }\n}\n\n/**\n * Stores the last value received, but only made available after finish().\n * Once made available, clears the value.\n */\nexport class LastValueAfterFinish<Value> extends BaseChannel<\n Value,\n Value,\n [Value, boolean]\n> {\n lc_graph_name = \"LastValueAfterFinish\";\n\n // value is an array so we don't misinterpret an update to undefined as no write\n value: [Value] | [] = [];\n\n finished: boolean = false;\n\n fromCheckpoint(checkpoint?: [Value, boolean]) {\n const empty = new LastValueAfterFinish<Value>();\n if (typeof checkpoint !== \"undefined\") {\n const [value, finished] = checkpoint;\n empty.value = [value];\n empty.finished = finished;\n }\n return empty as this;\n }\n\n update(values: Value[]): boolean {\n if (values.length === 0) {\n return false;\n }\n\n this.finished = false;\n // eslint-disable-next-line prefer-destructuring\n this.value = [values[values.length - 1]];\n return true;\n }\n\n get(): Value {\n if (this.value.length === 0 || !this.finished) {\n throw new EmptyChannelError();\n }\n return this.value[0];\n }\n\n checkpoint(): [Value, boolean] | undefined {\n if (this.value.length === 0) return undefined;\n return [this.value[0], this.finished];\n }\n\n consume(): boolean {\n if (this.finished) {\n this.finished = false;\n this.value = [];\n return true;\n }\n return false;\n }\n\n finish(): boolean {\n if (!this.finished && this.value.length > 0) {\n this.finished = true;\n return true;\n }\n return false;\n }\n\n isAvailable(): boolean {\n return this.value.length !== 0 && this.finished;\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"last_value.js","names":[],"sources":["../../src/channels/last_value.ts"],"sourcesContent":["import { EmptyChannelError, InvalidUpdateError } from \"../errors.js\";\nimport { BaseChannel } from \"./base.js\";\n\n/**\n * Stores the last value received, can receive at most one value per step.\n *\n * Since `update` is only called once per step and value can only be of length 1,\n * LastValue always stores the last value of a single node. If multiple nodes attempt to\n * write to this channel in a single step, an error will be thrown.\n * @internal\n */\nexport class LastValue<Value> extends BaseChannel<Value, Value, Value> {\n lc_graph_name = \"LastValue\";\n\n // value is an array so we don't misinterpret an update to undefined as no write\n value: [Value] | [] = [];\n\n constructor(protected initialValueFactory?: () => Value) {\n super();\n if (initialValueFactory) {\n this.value = [initialValueFactory()];\n }\n }\n\n fromCheckpoint(checkpoint?: Value) {\n const empty = new LastValue<Value>(this.initialValueFactory);\n if (typeof checkpoint !== \"undefined\") {\n empty.value = [checkpoint];\n }\n\n return empty as this;\n }\n\n update(values: Value[]): boolean {\n if (values.length === 0) {\n return false;\n }\n if (values.length !== 1) {\n throw new InvalidUpdateError(\n \"LastValue can only receive one value per step.\",\n { lc_error_code: \"INVALID_CONCURRENT_GRAPH_UPDATE\" }\n );\n }\n\n // eslint-disable-next-line prefer-destructuring\n this.value = [values[values.length - 1]];\n return true;\n }\n\n get(): Value {\n if (this.value.length === 0) {\n throw new EmptyChannelError();\n }\n return this.value[0];\n }\n\n checkpoint(): Value {\n if (this.value.length === 0) {\n throw new EmptyChannelError();\n }\n return this.value[0];\n }\n\n isAvailable(): boolean {\n return this.value.length !== 0;\n }\n}\n\n/**\n * Stores the last value received, but only made available after finish().\n * Once made available, clears the value.\n */\nexport class LastValueAfterFinish<Value> extends BaseChannel<\n Value,\n Value,\n [Value, boolean]\n> {\n lc_graph_name = \"LastValueAfterFinish\";\n\n // value is an array so we don't misinterpret an update to undefined as no write\n value: [Value] | [] = [];\n\n finished: boolean = false;\n\n fromCheckpoint(checkpoint?: [Value, boolean]) {\n const empty = new LastValueAfterFinish<Value>();\n if (typeof checkpoint !== \"undefined\") {\n const [value, finished] = checkpoint;\n empty.value = [value];\n empty.finished = finished;\n }\n return empty as this;\n }\n\n update(values: Value[]): boolean {\n if (values.length === 0) {\n return false;\n }\n\n this.finished = false;\n // eslint-disable-next-line prefer-destructuring\n this.value = [values[values.length - 1]];\n return true;\n }\n\n get(): Value {\n if (this.value.length === 0 || !this.finished) {\n throw new EmptyChannelError();\n }\n return this.value[0];\n }\n\n checkpoint(): [Value, boolean] | undefined {\n if (this.value.length === 0) return undefined;\n return [this.value[0], this.finished];\n }\n\n consume(): boolean {\n if (this.finished) {\n this.finished = false;\n this.value = [];\n return true;\n }\n return false;\n }\n\n finish(): boolean {\n if (!this.finished && this.value.length > 0) {\n this.finished = true;\n return true;\n }\n return false;\n }\n\n isAvailable(): boolean {\n return this.value.length !== 0 && this.finished;\n }\n}\n"],"mappings":";;;;;;;;;;;AAWA,IAAa,YAAb,MAAa,kBAAyB,YAAiC;CACrE,gBAAgB;CAGhB,QAAsB,EAAE;CAExB,YAAY,qBAA6C;AACvD,SAAO;AADa,OAAA,sBAAA;AAEpB,MAAI,oBACF,MAAK,QAAQ,CAAC,qBAAqB,CAAC;;CAIxC,eAAe,YAAoB;EACjC,MAAM,QAAQ,IAAI,UAAiB,KAAK,oBAAoB;AAC5D,MAAI,OAAO,eAAe,YACxB,OAAM,QAAQ,CAAC,WAAW;AAG5B,SAAO;;CAGT,OAAO,QAA0B;AAC/B,MAAI,OAAO,WAAW,EACpB,QAAO;AAET,MAAI,OAAO,WAAW,EACpB,OAAM,IAAI,mBACR,kDACA,EAAE,eAAe,mCAAmC,CACrD;AAIH,OAAK,QAAQ,CAAC,OAAO,OAAO,SAAS,GAAG;AACxC,SAAO;;CAGT,MAAa;AACX,MAAI,KAAK,MAAM,WAAW,EACxB,OAAM,IAAI,mBAAmB;AAE/B,SAAO,KAAK,MAAM;;CAGpB,aAAoB;AAClB,MAAI,KAAK,MAAM,WAAW,EACxB,OAAM,IAAI,mBAAmB;AAE/B,SAAO,KAAK,MAAM;;CAGpB,cAAuB;AACrB,SAAO,KAAK,MAAM,WAAW;;;;;;;AAQjC,IAAa,uBAAb,MAAa,6BAAoC,YAI/C;CACA,gBAAgB;CAGhB,QAAsB,EAAE;CAExB,WAAoB;CAEpB,eAAe,YAA+B;EAC5C,MAAM,QAAQ,IAAI,sBAA6B;AAC/C,MAAI,OAAO,eAAe,aAAa;GACrC,MAAM,CAAC,OAAO,YAAY;AAC1B,SAAM,QAAQ,CAAC,MAAM;AACrB,SAAM,WAAW;;AAEnB,SAAO;;CAGT,OAAO,QAA0B;AAC/B,MAAI,OAAO,WAAW,EACpB,QAAO;AAGT,OAAK,WAAW;AAEhB,OAAK,QAAQ,CAAC,OAAO,OAAO,SAAS,GAAG;AACxC,SAAO;;CAGT,MAAa;AACX,MAAI,KAAK,MAAM,WAAW,KAAK,CAAC,KAAK,SACnC,OAAM,IAAI,mBAAmB;AAE/B,SAAO,KAAK,MAAM;;CAGpB,aAA2C;AACzC,MAAI,KAAK,MAAM,WAAW,EAAG,QAAO,KAAA;AACpC,SAAO,CAAC,KAAK,MAAM,IAAI,KAAK,SAAS;;CAGvC,UAAmB;AACjB,MAAI,KAAK,UAAU;AACjB,QAAK,WAAW;AAChB,QAAK,QAAQ,EAAE;AACf,UAAO;;AAET,SAAO;;CAGT,SAAkB;AAChB,MAAI,CAAC,KAAK,YAAY,KAAK,MAAM,SAAS,GAAG;AAC3C,QAAK,WAAW;AAChB,UAAO;;AAET,SAAO;;CAGT,cAAuB;AACrB,SAAO,KAAK,MAAM,WAAW,KAAK,KAAK"}
|