UNPKG

@langchain/langgraph

Version:
1 lines 28.4 kB
{"version":3,"file":"run-stream.cjs","names":["#valuesDone","#discoveryStart","#eventStart","#abortController","#resolveValuesFn","#rejectValuesFn","#subgraphsIterable","filterSubgraphHandles","#valuesLog","#messagesIterable","createMessagesTransformer","#lifecycleIterable","RESOLVE_VALUES","REJECT_VALUES","StreamMux","createLifecycleTransformer","createSubgraphDiscoveryTransformer","filterLifecycleEntries","createValuesTransformer","isNativeTransformer"],"sources":["../../src/stream/run-stream.ts"],"sourcesContent":["/**\n * GraphRunStream and SubgraphRunStream — the public run stream classes.\n *\n * Built-in projections:\n * .subgraphs — recursive child subgraph discovery\n * .values — state snapshots (AsyncIterable & PromiseLike)\n * .messages — per-message ChatModelStream lifecycle\n * .messagesFrom — node-filtered messages\n * .output — final state Promise\n * .interrupted — whether the run ended due to an interrupt\n * .interrupts — interrupt payloads\n * .abort() — programmatic cancellation\n * .extensions — merged transformer projections\n *\n * Internal LangChain products (ReactAgent, DeepAgent) can subclass\n * GraphRunStream to add native projections (e.g. `run.toolCalls`,\n * `run.subagents`). See docs/native-stream-transformers.md for the\n * pattern.\n */\n\nimport type { StreamChunk } from \"../pregel/stream.js\";\nimport {\n createLifecycleTransformer,\n createMessagesTransformer,\n createSubgraphDiscoveryTransformer,\n createValuesTransformer,\n filterLifecycleEntries,\n filterSubgraphHandles,\n type LifecycleEntry,\n} from \"./transformers/index.js\";\nimport { StreamMux, pump, RESOLVE_VALUES, REJECT_VALUES } from \"./mux.js\";\nimport {\n isNativeTransformer,\n type ChatModelStreamHandle,\n type InferExtensions,\n type InterruptPayload,\n type Namespace,\n type ProtocolEvent,\n type StreamTransformer,\n} from \"./types.js\";\nimport type { StreamChannel } from \"./stream-channel.js\";\n\n/**\n * Symbol key for attaching the values log to a stream handle.\n * Using a symbol keeps this off the public autocomplete surface.\n */\nexport const SET_VALUES_LOG: unique symbol = Symbol(\"setValuesLog\");\n\n/**\n * Symbol key for attaching the messages iterable to a stream handle.\n * Using a symbol keeps this off the public autocomplete surface.\n */\nexport const SET_MESSAGES_ITERABLE: unique symbol = Symbol(\n \"setMessagesIterable\"\n);\n\n/**\n * Symbol key for attaching the lifecycle iterable to a stream handle.\n * Using a symbol keeps this off the public autocomplete surface.\n */\nexport const SET_LIFECYCLE_ITERABLE: unique symbol = Symbol(\n \"setLifecycleIterable\"\n);\n\n/**\n * Symbol key for attaching the subgraphs iterable to a stream handle.\n * Using a symbol keeps this off the public autocomplete surface.\n */\nexport const SET_SUBGRAPHS_ITERABLE: unique symbol = Symbol(\n \"setSubgraphsIterable\"\n);\n\n/**\n * Shared empty async iterable, returned from getters that haven't\n * been wired by {@link createGraphRunStream}. Avoids allocating a\n * fresh empty iterable on every access.\n */\nconst EMPTY_ASYNC_ITERABLE: AsyncIterable<never> = {\n [Symbol.asyncIterator](): AsyncIterator<never> {\n return {\n next: () =>\n Promise.resolve({\n value: undefined as never,\n done: true,\n }),\n };\n },\n};\n\n/**\n * Primary run stream for a LangGraph execution.\n *\n * Implements {@link AsyncIterable} over {@link ProtocolEvent} and exposes\n * ergonomic projections for values, messages, subgraphs, output, and\n * interrupts. Created by {@link createGraphRunStream}.\n *\n * @typeParam TValues - Shape of the graph's state values.\n * @typeParam TExtensions - Shape of additional transformer projections merged\n * into {@link GraphRunStream.extensions}.\n */\nexport class GraphRunStream<\n TValues = Record<string, unknown>,\n TExtensions extends Record<string, unknown> = Record<string, unknown>,\n> implements AsyncIterable<ProtocolEvent> {\n /**\n * Namespace path identifying this stream's position in the agent tree.\n * An empty array for the root stream.\n */\n readonly path: Namespace;\n\n /**\n * Merged projections from user-supplied {@link StreamTransformer} factories.\n * Each transformer's `init()` return value is spread into this object.\n */\n readonly extensions: TExtensions;\n\n /**\n * The central stream multiplexer that drives event dispatch and transformer\n * pipelines. Accessible to subclasses for direct event subscription.\n *\n * @internal\n */\n protected readonly _mux: StreamMux;\n\n #eventStart: number;\n #discoveryStart: number;\n #abortController: AbortController;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n #resolveValuesFn?: (v: any) => void;\n #rejectValuesFn?: (e: unknown) => void;\n readonly #valuesDone: Promise<TValues>;\n\n #valuesLog?: StreamChannel<Record<string, unknown>>;\n #messagesIterable?: AsyncIterable<ChatModelStreamHandle>;\n #lifecycleIterable?: AsyncIterable<LifecycleEntry>;\n #subgraphsIterable?: AsyncIterable<SubgraphRunStream>;\n\n /**\n * @param path - Namespace path for this stream (empty array for root).\n * @param mux - The {@link StreamMux} driving this run.\n * @param discoveryStart - Cursor offset into the mux discovery log.\n * @param eventStart - Cursor offset into the mux event log.\n * @param extensions - Pre-initialized transformer projections.\n * @param abortController - Controller for programmatic cancellation.\n */\n constructor(\n path: Namespace,\n mux: StreamMux,\n discoveryStart = 0,\n eventStart = 0,\n extensions?: TExtensions,\n abortController?: AbortController\n ) {\n this.path = path;\n this._mux = mux;\n this.#discoveryStart = discoveryStart;\n this.#eventStart = eventStart;\n this.extensions = extensions ?? ({} as TExtensions);\n this.#abortController = abortController ?? new AbortController();\n this.#valuesDone = new Promise<TValues>((resolve, reject) => {\n this.#resolveValuesFn = resolve;\n this.#rejectValuesFn = reject;\n });\n this.#valuesDone.catch(() => {\n // Keep run failures observable to explicit `await run.output` callers\n // without reporting unhandled rejections when consumers only iterate\n // protocol events.\n });\n }\n\n /**\n * Async iterator over all {@link ProtocolEvent}s at or below this\n * stream's namespace, starting from the configured event offset.\n *\n * @returns An async iterator yielding protocol events in arrival order.\n */\n [Symbol.asyncIterator](): AsyncIterator<ProtocolEvent> {\n return this._mux.subscribeEvents(this.path, this.#eventStart);\n }\n\n /**\n * Async iterable of child {@link SubgraphRunStream} instances discovered\n * during the run. Each yielded stream represents a direct child namespace.\n *\n * Backed by the shared `_discoveries` log on the mux, populated by\n * {@link createSubgraphDiscoveryTransformer}. For streams created\n * through {@link createGraphRunStream} the iterable is pre-wired\n * (via {@link SET_SUBGRAPHS_ITERABLE}) so iteration is cheap.\n * Streams constructed directly (e.g. in unit tests) fall back to\n * filtering `_mux._discoveries` on demand, preserving the original\n * behavior without requiring explicit wiring.\n *\n * @returns An async iterable of subgraph run streams.\n */\n get subgraphs(): AsyncIterable<SubgraphRunStream> {\n if (this.#subgraphsIterable) return this.#subgraphsIterable;\n return filterSubgraphHandles<SubgraphRunStream>(\n this._mux._discoveries,\n this.path,\n this.#discoveryStart\n );\n }\n\n /**\n * Dual-interface accessor for graph state snapshots.\n *\n * As an {@link AsyncIterable}, yields each intermediate state snapshot\n * as it arrives. As a {@link PromiseLike}, resolves with the final\n * state value when the run completes.\n *\n * @returns A combined async iterable and promise-like for state values.\n */\n get values(): AsyncIterable<TValues> & PromiseLike<TValues> {\n const log = this.#valuesLog;\n const done = this.#valuesDone;\n const mux = this._mux;\n const eventStart = this.#eventStart;\n const path = this.path;\n\n const iterable: AsyncIterable<TValues> = log\n ? (log.toAsyncIterable() as AsyncIterable<TValues>)\n : {\n [Symbol.asyncIterator]: () => {\n const base = mux.subscribeEvents(path, eventStart);\n return {\n async next(): Promise<IteratorResult<TValues>> {\n // eslint-disable-next-line no-constant-condition\n while (true) {\n const result = await base.next();\n if (result.done) {\n return {\n value: undefined as unknown as TValues,\n done: true,\n };\n }\n if (\n result.value.method === \"values\" &&\n result.value.params.namespace.length === path.length\n ) {\n return {\n value: result.value.params.data as TValues,\n done: false,\n };\n }\n }\n },\n };\n },\n };\n\n return {\n [Symbol.asyncIterator]: () => iterable[Symbol.asyncIterator](),\n then: done.then.bind(done),\n };\n }\n\n /**\n * All AI message lifecycles observed at this namespace level, in order.\n * Each yielded {@link ChatModelStream} represents one message-start →\n * message-finish lifecycle with streaming `.text`, `.reasoning`, and\n * `.usage` projections.\n *\n * @returns An async iterable of chat model streams.\n */\n get messages(): AsyncIterable<ChatModelStreamHandle> {\n if (this.#messagesIterable) return this.#messagesIterable;\n // Lazily create a messages transformer scoped to this stream's path.\n // This handles SubgraphRunStream instances that are created\n // dynamically by StreamMux and don't have a transformer pre-wired.\n // Uses addTransformer (which replays buffered events) so that\n // messages emitted before the getter is first accessed are not lost.\n const transformer = createMessagesTransformer(this.path);\n const projection = transformer.init();\n this._mux.addTransformer(transformer);\n this.#messagesIterable = projection.messages;\n return this.#messagesIterable;\n }\n\n /**\n * Sequence of {@link LifecycleEntry} records tracking the\n * `lifecycle` channel: when the run starts, when each subgraph\n * enters/exits, and the terminal status of the run as a whole.\n *\n * Backed by the built-in {@link createLifecycleTransformer}; the\n * root stream's iterable is wired during\n * {@link createGraphRunStream} setup, and each\n * {@link SubgraphRunStream} is wired in the subgraph discovery\n * factory with a subtree-scoped view (via\n * {@link filterLifecycleEntries}). Streams constructed outside\n * `createGraphRunStream` and not wired will yield nothing.\n *\n * @returns An async iterable of lifecycle entries in emission order.\n */\n get lifecycle(): AsyncIterable<LifecycleEntry> {\n return this.#lifecycleIterable ?? EMPTY_ASYNC_ITERABLE;\n }\n\n /**\n * Messages produced by a specific graph node. Use when the run has\n * multiple model-calling nodes and you only want messages from one.\n *\n * @param node - The graph node name to filter messages by.\n * @returns An async iterable of chat model streams from the given node.\n */\n messagesFrom(node: string): AsyncIterable<ChatModelStreamHandle> {\n const transformer = createMessagesTransformer(this.path, node);\n const projection = transformer.init();\n this._mux.addTransformer(transformer);\n return projection.messages;\n }\n\n /**\n * Promise that resolves with the final graph state when the run completes,\n * or rejects if the run fails.\n *\n * @returns A promise resolving to the final state values.\n */\n get output(): Promise<TValues> {\n return this.#valuesDone;\n }\n\n /**\n * Whether the run ended due to a human-in-the-loop interrupt.\n *\n * @returns `true` if the run was interrupted.\n */\n get interrupted(): boolean {\n return this._mux.interrupted;\n }\n\n /**\n * Interrupt payloads collected during the run, if any.\n *\n * @returns A readonly array of interrupt payloads.\n */\n get interrupts(): readonly InterruptPayload[] {\n return this._mux.interrupts;\n }\n\n /**\n * Programmatically abort this run. Equivalent to calling\n * `signal.abort(reason)`.\n *\n * @param reason - Optional abort reason passed to the signal.\n */\n abort(reason?: unknown): void {\n this.#abortController.abort(reason);\n }\n\n /**\n * The {@link AbortSignal} wired into this run for cancellation support.\n *\n * @returns The abort signal for this stream.\n */\n get signal(): AbortSignal {\n return this.#abortController.signal;\n }\n\n /**\n * Resolve the output/values promise with the final state snapshot.\n * Called by {@link StreamMux.close}.\n *\n * @param values - The final state values, or `undefined` if none.\n * @internal\n */\n [RESOLVE_VALUES](values: TValues | undefined): void {\n this.#resolveValuesFn?.(values as TValues);\n this.#resolveValuesFn = undefined;\n }\n\n /**\n * Reject the output/values promise with a run error.\n * Called by {@link StreamMux.fail}.\n *\n * @param err - The error that caused the run to fail.\n * @internal\n */\n [REJECT_VALUES](err: unknown): void {\n this.#rejectValuesFn?.(err);\n this.#rejectValuesFn = undefined;\n }\n\n /**\n * Attach the transformer-populated event log backing the `.values` iterable.\n * Called during stream setup in {@link createGraphRunStream}.\n *\n * @param log - The event log from the values transformer projection.\n * @internal\n */\n [SET_VALUES_LOG](log: StreamChannel<Record<string, unknown>>): void {\n this.#valuesLog = log;\n }\n\n /**\n * Attach the transformer-populated async iterable backing the `.messages`\n * accessor. Called during stream setup in {@link createGraphRunStream}.\n *\n * @param iterable - The async iterable from the messages transformer projection.\n * @internal\n */\n [SET_MESSAGES_ITERABLE](\n iterable: AsyncIterable<ChatModelStreamHandle>\n ): void {\n this.#messagesIterable = iterable;\n }\n\n /**\n * Attach the transformer-populated async iterable backing the\n * `.lifecycle` accessor. Called during stream setup in\n * {@link createGraphRunStream}.\n *\n * @param iterable - The async iterable from the lifecycle transformer projection.\n * @internal\n */\n [SET_LIFECYCLE_ITERABLE](iterable: AsyncIterable<LifecycleEntry>): void {\n this.#lifecycleIterable = iterable;\n }\n\n /**\n * Attach the transformer-populated async iterable backing the\n * `.subgraphs` accessor. Called during root stream setup in\n * {@link createGraphRunStream} and during child stream\n * construction in the discovery transformer factory.\n *\n * @param iterable - The async iterable of direct-child stream handles.\n * @internal\n */\n [SET_SUBGRAPHS_ITERABLE](iterable: AsyncIterable<SubgraphRunStream>): void {\n this.#subgraphsIterable = iterable;\n }\n}\n\n/**\n * A run stream for a child subgraph within a parent graph execution.\n *\n * Extends {@link GraphRunStream} with a parsed {@link name} and\n * {@link index} extracted from the last segment of the namespace path.\n * The segment is expected to follow the `\"name:index\"` convention;\n * when no numeric suffix is present, {@link index} defaults to `0`.\n *\n * @typeParam TValues - Shape of the subgraph's state values.\n * @typeParam TExtensions - Shape of additional transformer projections.\n */\nexport class SubgraphRunStream<\n TValues = Record<string, unknown>,\n TExtensions extends Record<string, unknown> = Record<string, unknown>,\n> extends GraphRunStream<TValues, TExtensions> {\n /**\n * The node name extracted from the last segment of the namespace path\n * (everything before the final colon, or the full segment if no colon).\n */\n readonly name: string;\n\n /**\n * The invocation index parsed from the `\"name:N\"` suffix of the last\n * namespace segment. Defaults to `0` when no numeric suffix is present.\n */\n readonly index: number;\n\n /**\n * @param path - Namespace path for this subgraph stream.\n * @param mux - The {@link StreamMux} driving this run.\n * @param discoveryStart - Cursor offset into the mux discovery log.\n * @param eventStart - Cursor offset into the mux event log.\n * @param extensions - Pre-initialized transformer projections.\n * @param abortController - Controller for programmatic cancellation.\n */\n constructor(\n path: Namespace,\n mux: StreamMux,\n discoveryStart = 0,\n eventStart = 0,\n extensions?: TExtensions,\n abortController?: AbortController\n ) {\n super(path, mux, discoveryStart, eventStart, extensions, abortController);\n const lastSegment = path[path.length - 1] ?? \"\";\n const colonIdx = lastSegment.lastIndexOf(\":\");\n if (colonIdx >= 0) {\n this.name = lastSegment.slice(0, colonIdx);\n const suffix = lastSegment.slice(colonIdx + 1);\n this.index = /^\\d+$/.test(suffix) ? Number(suffix) : 0;\n } else {\n this.name = lastSegment;\n this.index = 0;\n }\n }\n}\n\n/**\n * Options accepted by {@link createGraphRunStream}.\n */\nexport interface CreateGraphRunStreamOptions {\n /**\n * Optional abort controller shared with the outer run; if omitted, a\n * fresh controller is allocated for the returned stream.\n */\n abortController?: AbortController;\n}\n\n/**\n * Creates a {@link GraphRunStream} with built-in transformers and kicks off the\n * background pump that feeds raw stream chunks through the transformer pipeline.\n *\n * Built-in transformers are registered in this order:\n * 1. subgraph discovery — materializes SubgraphRunStream handles\n * for each newly observed top-level namespace and announces them\n * on the mux `_discoveries` log.\n * 2. lifecycle — synthesizes `lifecycle` channel events.\n * 3. values — powers `run.values` / `run.output`.\n * 4. messages — powers `run.messages` / `.messagesFrom`.\n *\n * Subgraph discovery is registered first so that downstream\n * transformers (notably lifecycle) observe child namespaces with\n * their stream handles already in place. User-supplied transformer\n * factories are registered afterwards.\n *\n * @typeParam TValues - Shape of the graph's state values.\n * @param source - Raw async iterable from `graph.stream(…, { subgraphs: true })`.\n * @param transformers - User-supplied transformer factories.\n * @param optionsOrAbortController - Either a full\n * {@link CreateGraphRunStreamOptions} object or (for backward\n * compatibility) a bare `AbortController`.\n * @returns A {@link GraphRunStream} for the root namespace.\n */\nexport function createGraphRunStream<\n TValues = Record<string, unknown>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const TTransformers extends ReadonlyArray<() => StreamTransformer<any>> = [],\n>(\n source: AsyncIterable<StreamChunk>,\n transformers: TTransformers = [] as unknown as TTransformers,\n optionsOrAbortController?: CreateGraphRunStreamOptions | AbortController\n): GraphRunStream<TValues, InferExtensions<TTransformers>> {\n const options: CreateGraphRunStreamOptions =\n // oxlint-disable-next-line no-instanceof/no-instanceof\n optionsOrAbortController instanceof AbortController\n ? { abortController: optionsOrAbortController }\n : (optionsOrAbortController ?? {});\n const { abortController } = options;\n\n const mux = new StreamMux();\n\n // Init lifecycle first so the subgraph discovery factory can close\n // over its log to wire each new child's `.lifecycle` view.\n const lifecycleTransformer = createLifecycleTransformer();\n const lifecycleProjection = lifecycleTransformer.init();\n const lifecycleLog = lifecycleProjection._lifecycleLog;\n\n const subgraphDiscoveryTransformer =\n createSubgraphDiscoveryTransformer<SubgraphRunStream>(mux, {\n createStream: (path, discoveryStart, eventStart) => {\n const sub = new SubgraphRunStream(\n path,\n mux,\n discoveryStart,\n eventStart\n );\n // Wire the child's `.subgraphs` to the shared discoveries log,\n // scoped to the child's path and its construction-time offset.\n sub[SET_SUBGRAPHS_ITERABLE](\n filterSubgraphHandles<SubgraphRunStream>(\n mux._discoveries,\n path,\n discoveryStart\n )\n );\n // Wire the child's `.lifecycle` to the shared lifecycle log,\n // filtered to its subtree. Capture the current log size so\n // entries emitted before discovery (e.g. root's `started`)\n // aren't replayed to the child. Entries emitted for this\n // discovery event itself land after the factory returns (the\n // subgraph transformer runs before the lifecycle transformer),\n // so the child still receives its own `started`.\n sub[SET_LIFECYCLE_ITERABLE](\n filterLifecycleEntries(lifecycleLog, path, lifecycleLog.size)\n );\n return sub;\n },\n });\n const subgraphsProjection = subgraphDiscoveryTransformer.init();\n\n // Registration order matters: subgraph discovery runs first so that\n // lifecycle and downstream transformers see child stream handles\n // already materialized.\n mux.addTransformer(subgraphDiscoveryTransformer);\n mux.addTransformer(lifecycleTransformer);\n\n const valuesTransformer = createValuesTransformer([]);\n const messagesTransformer = createMessagesTransformer([]);\n mux.addTransformer(valuesTransformer);\n mux.addTransformer(messagesTransformer);\n\n const extensions: Record<string, unknown> = {};\n const nativeProjections: Record<string, unknown>[] = [];\n for (const factory of transformers) {\n const transformer = factory();\n mux.addTransformer(transformer);\n const projection = transformer.init();\n if (isNativeTransformer(transformer)) {\n nativeProjections.push(projection);\n } else {\n Object.assign(extensions, projection);\n }\n // Only wire channels for extension transformers. Native transformers\n // produce non-serializable projections (Promises, AsyncIterables) that\n // must stay in-process — wiring them would inject garbage into the\n // protocol event stream.\n if (\n typeof projection === \"object\" &&\n projection !== null &&\n !isNativeTransformer(transformer)\n ) {\n mux.wireChannels(projection as Record<string, unknown>);\n }\n }\n\n const root = new GraphRunStream<TValues, InferExtensions<TTransformers>>(\n [],\n mux,\n 0,\n 0,\n extensions as InferExtensions<TTransformers>,\n abortController\n );\n\n /**\n * Assign native transformer projections to the root stream.\n */\n for (const proj of nativeProjections) {\n Object.assign(root, proj);\n }\n\n // Wire transformer projections into the root stream.\n const valuesProjection = valuesTransformer.init();\n root[SET_VALUES_LOG](valuesProjection._valuesLog);\n\n const messagesProjection = messagesTransformer.init();\n root[SET_MESSAGES_ITERABLE](messagesProjection.messages);\n root[SET_LIFECYCLE_ITERABLE](lifecycleProjection.lifecycle);\n root[SET_SUBGRAPHS_ITERABLE](subgraphsProjection.subgraphs);\n\n mux.register([], root);\n\n // Start background pump.\n pump(source, mux).catch((err) => {\n void err;\n });\n\n return root;\n}\n"],"mappings":";;;;;;;;;;;;AA8CA,MAAa,iBAAgC,OAAO,eAAe;;;;;AAMnE,MAAa,wBAAuC,OAClD,sBACD;;;;;AAMD,MAAa,yBAAwC,OACnD,uBACD;;;;;AAMD,MAAa,yBAAwC,OACnD,uBACD;;;;;;AAOD,MAAM,uBAA6C,EACjD,CAAC,OAAO,iBAAuC;AAC7C,QAAO,EACL,YACE,QAAQ,QAAQ;EACd,OAAO,KAAA;EACP,MAAM;EACP,CAAC,EACL;GAEJ;;;;;;;;;;;;AAaD,IAAa,iBAAb,MAG0C;;;;;CAKxC;;;;;CAMA;;;;;;;CAQA;CAEA;CACA;CACA;CAGA;CACA;CACA;CAEA;CACA;CACA;CACA;;;;;;;;;CAUA,YACE,MACA,KACA,iBAAiB,GACjB,aAAa,GACb,YACA,iBACA;AACA,OAAK,OAAO;AACZ,OAAK,OAAO;AACZ,QAAA,iBAAuB;AACvB,QAAA,aAAmB;AACnB,OAAK,aAAa,cAAe,EAAE;AACnC,QAAA,kBAAwB,mBAAmB,IAAI,iBAAiB;AAChE,QAAA,aAAmB,IAAI,SAAkB,SAAS,WAAW;AAC3D,SAAA,kBAAwB;AACxB,SAAA,iBAAuB;IACvB;AACF,QAAA,WAAiB,YAAY,GAI3B;;;;;;;;CASJ,CAAC,OAAO,iBAA+C;AACrD,SAAO,KAAK,KAAK,gBAAgB,KAAK,MAAM,MAAA,WAAiB;;;;;;;;;;;;;;;;CAiB/D,IAAI,YAA8C;AAChD,MAAI,MAAA,kBAAyB,QAAO,MAAA;AACpC,SAAOO,kBAAAA,sBACL,KAAK,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