@nodetool-ai/kernel 0.7.0-rc.22 → 0.8.1
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/README.md +51 -0
- package/dist/.nodetool-build-stamp +1 -0
- package/dist/actor.d.ts +381 -20
- package/dist/actor.d.ts.map +1 -1
- package/dist/actor.js +1619 -184
- package/dist/actor.js.map +1 -1
- package/dist/correlation-analysis.d.ts +104 -0
- package/dist/correlation-analysis.d.ts.map +1 -0
- package/dist/correlation-analysis.js +833 -0
- package/dist/correlation-analysis.js.map +1 -0
- package/dist/durable-inbox.d.ts +9 -0
- package/dist/durable-inbox.d.ts.map +1 -1
- package/dist/durable-inbox.js +55 -2
- package/dist/durable-inbox.js.map +1 -1
- package/dist/dynamic-slots.d.ts +58 -0
- package/dist/dynamic-slots.d.ts.map +1 -0
- package/dist/dynamic-slots.js +182 -0
- package/dist/dynamic-slots.js.map +1 -0
- package/dist/edge-ids.d.ts +11 -0
- package/dist/edge-ids.d.ts.map +1 -0
- package/dist/edge-ids.js +15 -0
- package/dist/edge-ids.js.map +1 -0
- package/dist/graph-utils.d.ts +12 -0
- package/dist/graph-utils.d.ts.map +1 -1
- package/dist/graph-utils.js +51 -16
- package/dist/graph-utils.js.map +1 -1
- package/dist/graph.d.ts +50 -9
- package/dist/graph.d.ts.map +1 -1
- package/dist/graph.js +308 -101
- package/dist/graph.js.map +1 -1
- package/dist/inbox.d.ts +158 -2
- package/dist/inbox.d.ts.map +1 -1
- package/dist/inbox.js +253 -11
- package/dist/inbox.js.map +1 -1
- package/dist/index.d.ts +13 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -7
- package/dist/index.js.map +1 -1
- package/dist/io.d.ts +103 -6
- package/dist/io.d.ts.map +1 -1
- package/dist/io.js +123 -12
- package/dist/io.js.map +1 -1
- package/dist/loop.d.ts +36 -0
- package/dist/loop.d.ts.map +1 -0
- package/dist/loop.js +166 -0
- package/dist/loop.js.map +1 -0
- package/dist/predicates.d.ts +8 -0
- package/dist/predicates.d.ts.map +1 -0
- package/dist/predicates.js +8 -0
- package/dist/predicates.js.map +1 -0
- package/dist/run-state.d.ts +65 -0
- package/dist/run-state.d.ts.map +1 -0
- package/dist/run-state.js +42 -0
- package/dist/run-state.js.map +1 -0
- package/dist/runner.d.ts +312 -15
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +1219 -156
- package/dist/runner.js.map +1 -1
- package/dist/substitute-validator.d.ts +44 -0
- package/dist/substitute-validator.d.ts.map +1 -0
- package/dist/substitute-validator.js +169 -0
- package/dist/substitute-validator.js.map +1 -0
- package/dist/supervisor.d.ts +148 -0
- package/dist/supervisor.d.ts.map +1 -0
- package/dist/supervisor.js +287 -0
- package/dist/supervisor.js.map +1 -0
- package/dist/trigger-wakeup.d.ts +74 -5
- package/dist/trigger-wakeup.d.ts.map +1 -1
- package/dist/trigger-wakeup.js +167 -45
- package/dist/trigger-wakeup.js.map +1 -1
- package/package.json +27 -9
- package/dist/channel.d.ts +0 -46
- package/dist/channel.d.ts.map +0 -1
- package/dist/channel.js +0 -191
- package/dist/channel.js.map +0 -1
- package/dist/suspendable.d.ts +0 -68
- package/dist/suspendable.d.ts.map +0 -1
- package/dist/suspendable.js +0 -108
- package/dist/suspendable.js.map +0 -1
- package/dist/trigger-manager.d.ts +0 -107
- package/dist/trigger-manager.d.ts.map +0 -1
- package/dist/trigger-manager.js +0 -214
- package/dist/trigger-manager.js.map +0 -1
- package/dist/trigger.d.ts +0 -57
- package/dist/trigger.d.ts.map +0 -1
- package/dist/trigger.js +0 -145
- package/dist/trigger.js.map +0 -1
package/dist/graph-utils.js
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
* Port of src/nodetool/workflows/graph_utils.py.
|
|
5
5
|
*/
|
|
6
6
|
import { isControlEdge, TypeMetadata } from "@nodetool-ai/protocol";
|
|
7
|
+
import { getDynamicSlotTypeString } from "./dynamic-slots.js";
|
|
8
|
+
import { isObjectValue, isString } from "./predicates.js";
|
|
7
9
|
/**
|
|
8
10
|
* Find a node by ID or throw.
|
|
9
11
|
*/
|
|
@@ -24,7 +26,9 @@ export function getNodeInputTypes(graph, nodeId) {
|
|
|
24
26
|
const result = {};
|
|
25
27
|
for (const edge of graph.findIncomingEdges(nodeId)) {
|
|
26
28
|
const sourceNode = graph.findNode(edge.source);
|
|
27
|
-
if (sourceNode &&
|
|
29
|
+
if (sourceNode &&
|
|
30
|
+
sourceNode.outputs &&
|
|
31
|
+
Object.hasOwn(sourceNode.outputs, edge.sourceHandle)) {
|
|
28
32
|
result[edge.targetHandle] = sourceNode.outputs[edge.sourceHandle];
|
|
29
33
|
}
|
|
30
34
|
else {
|
|
@@ -45,14 +49,23 @@ export function getDownstreamSubgraph(graph, nodeId, sourceHandle) {
|
|
|
45
49
|
.findOutgoingEdges(nodeId)
|
|
46
50
|
.filter((e) => e.sourceHandle === sourceHandle);
|
|
47
51
|
const includedNodeIds = new Set();
|
|
52
|
+
// Stryker disable next-line ArrayDeclaration: a non-empty seed is equivalent — a bogus Edge has no source/target in includedNodeIds and is dropped by the endpoint filter below
|
|
48
53
|
const includedEdges = [];
|
|
49
54
|
// Seed BFS with targets of initial edges
|
|
55
|
+
// Stryker disable next-line ArrayDeclaration: a non-empty seed is equivalent — a bogus node id has no outgoing edges, so BFS adds nothing for it
|
|
50
56
|
const queue = [];
|
|
57
|
+
const enqueued = new Set();
|
|
51
58
|
for (const e of initialEdges) {
|
|
52
59
|
includedEdges.push(e);
|
|
53
60
|
includedNodeIds.add(e.target);
|
|
54
61
|
includedNodeIds.add(e.source);
|
|
55
|
-
|
|
62
|
+
// Two initial edges can share a target (one output feeding two handles
|
|
63
|
+
// of the same node); enqueueing it twice would duplicate all of its
|
|
64
|
+
// outgoing edges in the result.
|
|
65
|
+
if (!enqueued.has(e.target)) {
|
|
66
|
+
enqueued.add(e.target);
|
|
67
|
+
queue.push(e.target);
|
|
68
|
+
}
|
|
56
69
|
}
|
|
57
70
|
// BFS over outgoing edges
|
|
58
71
|
while (queue.length > 0) {
|
|
@@ -72,8 +85,14 @@ export function getDownstreamSubgraph(graph, nodeId, sourceHandle) {
|
|
|
72
85
|
if (node)
|
|
73
86
|
nodes.push(node);
|
|
74
87
|
}
|
|
75
|
-
// Filter edges to those with both endpoints in included set
|
|
76
|
-
|
|
88
|
+
// Filter edges to those with both endpoints in included set. This is a
|
|
89
|
+
// defensive no-op given the BFS above (every pushed edge's source is the
|
|
90
|
+
// dequeued node and its target is added to the set), so its mutants are
|
|
91
|
+
// equivalent — kept for safety against future changes to the BFS.
|
|
92
|
+
// Stryker disable next-line MethodExpression: defensive no-op filter (see above)
|
|
93
|
+
const filteredEdges = includedEdges.filter(
|
|
94
|
+
// Stryker disable next-line ConditionalExpression,LogicalOperator: defensive no-op filter — both endpoints are always in the set
|
|
95
|
+
(e) => includedNodeIds.has(e.source) && includedNodeIds.has(e.target));
|
|
77
96
|
return { initialEdges, nodes, edges: filteredEdges };
|
|
78
97
|
}
|
|
79
98
|
// ---------------------------------------------------------------------------
|
|
@@ -84,7 +103,8 @@ export function getDownstreamSubgraph(graph, nodeId, sourceHandle) {
|
|
|
84
103
|
*/
|
|
85
104
|
export function isNodeBypassed(node) {
|
|
86
105
|
const ui = node.ui_properties;
|
|
87
|
-
|
|
106
|
+
// Stryker disable next-line ConditionalExpression: the `typeof ui !== "object"` operand is equivalent to drop — a truthy non-object (string/number) never throws on `.bypassed` and still yields `=== true → false`
|
|
107
|
+
if (!isObjectValue(ui))
|
|
88
108
|
return false;
|
|
89
109
|
return ui.bypassed === true;
|
|
90
110
|
}
|
|
@@ -92,34 +112,41 @@ export function isNodeBypassed(node) {
|
|
|
92
112
|
* Look up the declared type string of a node's output handle.
|
|
93
113
|
*/
|
|
94
114
|
function getOutputTypeString(node, handle) {
|
|
95
|
-
if (!node)
|
|
115
|
+
if (!node || !node.outputs)
|
|
96
116
|
return undefined;
|
|
97
|
-
return node.outputs
|
|
117
|
+
return Object.hasOwn(node.outputs, handle) ? node.outputs[handle] : undefined;
|
|
98
118
|
}
|
|
99
119
|
/**
|
|
100
120
|
* Look up the declared type string of a node's input (property) handle.
|
|
101
121
|
*
|
|
102
|
-
* Checks propertyTypes first (the authoritative map after graph load),
|
|
103
|
-
* then falls back to
|
|
104
|
-
*
|
|
122
|
+
* Checks propertyTypes first (the authoritative map after graph load), then
|
|
123
|
+
* a declared dynamic slot (`dynamic_inputs`), then falls back to a property
|
|
124
|
+
* value carrying an explicit `type` field for
|
|
125
|
+
* backwards compatibility with raw graph payloads. Plain string property
|
|
126
|
+
* values are runtime data (saved literals), never type names — treating
|
|
127
|
+
* them as types made bypass rewrites drop edges as "incompatible"
|
|
128
|
+
* (mirrors Graph.validateEdgeTypes).
|
|
105
129
|
*/
|
|
106
|
-
function getInputTypeString(node, handle) {
|
|
130
|
+
export function getInputTypeString(node, handle) {
|
|
107
131
|
if (!node)
|
|
108
132
|
return undefined;
|
|
109
133
|
const fromPropertyTypes = node.propertyTypes?.[handle];
|
|
110
134
|
if (fromPropertyTypes)
|
|
111
135
|
return fromPropertyTypes;
|
|
136
|
+
// A declared dynamic slot is typed; an undeclared one stays undefined so
|
|
137
|
+
// typesCompatible() keeps treating it as `any`.
|
|
138
|
+
const fromSlot = getDynamicSlotTypeString(node, handle);
|
|
139
|
+
if (fromSlot)
|
|
140
|
+
return fromSlot;
|
|
112
141
|
const props = node.properties;
|
|
113
142
|
if (props) {
|
|
114
143
|
const val = props[handle];
|
|
115
|
-
if (
|
|
144
|
+
if (isObjectValue(val) && "type" in val) {
|
|
116
145
|
const t = val.type;
|
|
117
|
-
|
|
146
|
+
// Stryker disable next-line ConditionalExpression: forcing this true is equivalent — returning a non-string `t` vs undefined are indistinguishable downstream (typesCompatible treats both as compatible)
|
|
147
|
+
if (isString(t))
|
|
118
148
|
return t;
|
|
119
149
|
}
|
|
120
|
-
else if (typeof val === "string") {
|
|
121
|
-
return val;
|
|
122
|
-
}
|
|
123
150
|
}
|
|
124
151
|
return undefined;
|
|
125
152
|
}
|
|
@@ -130,6 +157,7 @@ function getInputTypeString(node, handle) {
|
|
|
130
157
|
* handle types are not statically declared.
|
|
131
158
|
*/
|
|
132
159
|
function typesCompatible(sourceType, targetType) {
|
|
160
|
+
// Stryker disable next-line ConditionalExpression,LogicalOperator: equivalent — removing/weakening this guard still returns true for a missing type, because TypeMetadata.fromString(undefined) throws and the catch below returns true
|
|
133
161
|
if (!sourceType || !targetType)
|
|
134
162
|
return true;
|
|
135
163
|
try {
|
|
@@ -184,7 +212,14 @@ export function rewriteBypassedNodes(data) {
|
|
|
184
212
|
if (processed.has(bypassId))
|
|
185
213
|
continue;
|
|
186
214
|
const incoming = currentEdges.filter((e) => e.target === bypassId);
|
|
215
|
+
// This skip only orders processing so a chain collapses in one tidy
|
|
216
|
+
// pass; the outer `while (didChange)` re-processes, so out-of-order
|
|
217
|
+
// visits still converge to the same final edge set (see the
|
|
218
|
+
// "collapses ... out of dependency order" test). The mutants on this
|
|
219
|
+
// condition therefore don't change observable output.
|
|
220
|
+
// Stryker disable next-line MethodExpression,ArrowFunction,ConditionalExpression,BooleanLiteral: processing-order optimization — converges to the same final edges either way
|
|
187
221
|
const hasUnprocessedBypassedUpstream = incoming.some((e) => bypassedIds.has(e.source) && !processed.has(e.source));
|
|
222
|
+
// Stryker disable next-line ConditionalExpression: see above — skipping only reorders processing; the while-loop converges regardless
|
|
188
223
|
if (hasUnprocessedBypassedUpstream)
|
|
189
224
|
continue;
|
|
190
225
|
const incomingData = incoming.filter((e) => !isControlEdge(e));
|
package/dist/graph-utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph-utils.js","sourceRoot":"","sources":["../src/graph-utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"graph-utils.js","sourceRoot":"","sources":["../src/graph-utils.ts"],"names":[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C,CAAC;YAEpC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YACxB,SAAS,GAAG,IAAI,CAAC;QACnB,CAAC;IACH,CAAC;IAED,uDAAuD;IACvD,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAExE,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC;AACxD,CAAC"}
|
package/dist/graph.d.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* - Topological sort (Kahn's algorithm)
|
|
9
9
|
* - Streaming upstream computation
|
|
10
10
|
*/
|
|
11
|
-
import type { Edge, NodeDescriptor, GraphData } from "@nodetool-ai/protocol";
|
|
11
|
+
import type { Edge, NodeDescriptor, HydratedNodeDescriptor, GraphData, HydratedGraphData } from "@nodetool-ai/protocol";
|
|
12
12
|
export interface GraphValidationIssue {
|
|
13
13
|
nodeId?: string;
|
|
14
14
|
nodeType?: string;
|
|
@@ -28,8 +28,22 @@ export interface ResolvedNodeType {
|
|
|
28
28
|
nodeType: string;
|
|
29
29
|
propertyTypes?: Record<string, string>;
|
|
30
30
|
outputs?: Record<string, string>;
|
|
31
|
-
|
|
31
|
+
supportsDynamicInputs?: boolean;
|
|
32
32
|
descriptorDefaults?: Partial<NodeDescriptor>;
|
|
33
|
+
/**
|
|
34
|
+
* Flags only the individual node can answer, resolved from its saved
|
|
35
|
+
* properties. `descriptorDefaults` carries one value per node *type*, which
|
|
36
|
+
* cannot express a mode that lives in a node's own properties — a Code node
|
|
37
|
+
* streams its inputs when its body says so. When present, the answer takes
|
|
38
|
+
* the slot the matching `descriptorDefaults` flag holds, and the kernel stays
|
|
39
|
+
* registry-agnostic: it calls a function it was handed, as it already does
|
|
40
|
+
* for type resolution.
|
|
41
|
+
*/
|
|
42
|
+
resolveInstanceFlags?: (node: {
|
|
43
|
+
properties?: Record<string, unknown>;
|
|
44
|
+
}) => {
|
|
45
|
+
is_streaming_input?: boolean;
|
|
46
|
+
};
|
|
33
47
|
}
|
|
34
48
|
export type NodeTypeResolver = ((nodeType: string) => Promise<ResolvedNodeType | null> | ResolvedNodeType | null) | {
|
|
35
49
|
resolveNodeType: (nodeType: string) => Promise<ResolvedNodeType | null> | ResolvedNodeType | null;
|
|
@@ -37,6 +51,18 @@ export type NodeTypeResolver = ((nodeType: string) => Promise<ResolvedNodeType |
|
|
|
37
51
|
export interface GraphLoadOptions extends Omit<GraphFromDictOptions, "validateNodeType"> {
|
|
38
52
|
resolver: NodeTypeResolver;
|
|
39
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Mark a code-constructed graph as hydrated by defaulting absent behavior
|
|
56
|
+
* flags to false. For graphs built in code (tests, DSL output) where the
|
|
57
|
+
* author already set the flags that matter. NOT a substitute for registry
|
|
58
|
+
* hydration of client/wire graphs — there an absent flag means "unknown",
|
|
59
|
+
* not "off"; use `Graph.loadFromDict` or node-sdk's `hydrateGraphNodeFlags`.
|
|
60
|
+
*/
|
|
61
|
+
export declare function withExplicitNodeFlags(graph: GraphData): HydratedGraphData;
|
|
62
|
+
/** A Graph whose descriptors carry resolved behavior flags (see loadFromDict). */
|
|
63
|
+
export interface HydratedGraph extends Graph {
|
|
64
|
+
readonly nodes: ReadonlyArray<HydratedNodeDescriptor>;
|
|
65
|
+
}
|
|
40
66
|
export declare class Graph {
|
|
41
67
|
readonly nodes: ReadonlyArray<NodeDescriptor>;
|
|
42
68
|
readonly edges: ReadonlyArray<Edge>;
|
|
@@ -56,15 +82,18 @@ export declare class Graph {
|
|
|
56
82
|
* Throws GraphValidationError if nodes or edges are missing or not arrays.
|
|
57
83
|
*/
|
|
58
84
|
static fromDict(data: unknown, options?: GraphFromDictOptions): Graph;
|
|
59
|
-
static loadFromDict(data: unknown, options: GraphLoadOptions): Promise<
|
|
85
|
+
static loadFromDict(data: unknown, options: GraphLoadOptions): Promise<HydratedGraph>;
|
|
60
86
|
private _buildIndices;
|
|
61
87
|
/**
|
|
62
|
-
*
|
|
63
|
-
* In Python, BaseNode.is_controlled() is a runtime method that checks
|
|
64
|
-
*
|
|
65
|
-
*
|
|
88
|
+
* Return the node list with is_controlled set on every control-edge target.
|
|
89
|
+
* In Python, BaseNode.is_controlled() is a runtime method that checks the
|
|
90
|
+
* graph context; in TS we set the flag on the descriptor so the actor knows
|
|
91
|
+
* to use _runControlled(). Node objects are caller-owned (the runner passes
|
|
92
|
+
* `graphData.nodes` straight through), so a target lacking the flag is
|
|
93
|
+
* replaced with a shallow copy — the original is left untouched. Every other
|
|
94
|
+
* node keeps its identity.
|
|
66
95
|
*/
|
|
67
|
-
private
|
|
96
|
+
private static _withControlledFlags;
|
|
68
97
|
findNode(id: string): NodeDescriptor | undefined;
|
|
69
98
|
/**
|
|
70
99
|
* Return all edges where target == nodeId (incoming edges).
|
|
@@ -118,7 +147,7 @@ export declare class Graph {
|
|
|
118
147
|
required: string[];
|
|
119
148
|
};
|
|
120
149
|
/**
|
|
121
|
-
* Build a JSON Schema object from output nodes (
|
|
150
|
+
* Build a JSON Schema object from output nodes (`nodetool.output.*`).
|
|
122
151
|
*/
|
|
123
152
|
getOutputSchema(): {
|
|
124
153
|
properties: Record<string, unknown>;
|
|
@@ -130,6 +159,18 @@ export declare class Graph {
|
|
|
130
159
|
* Throws GraphValidationError on problems.
|
|
131
160
|
*/
|
|
132
161
|
validate(): void;
|
|
162
|
+
/**
|
|
163
|
+
* Verify that every data edge's `sourceHandle` is a declared output of its
|
|
164
|
+
* source node. Without this, an edge wired to a nonexistent output handle
|
|
165
|
+
* passes validation and then silently never delivers a value at runtime
|
|
166
|
+
* (`validateEdgeTypes` skips it for lack of a source type), leaving the
|
|
167
|
+
* target node waiting forever.
|
|
168
|
+
*
|
|
169
|
+
* Only enforced when the source node declares a non-empty static `outputs`
|
|
170
|
+
* map and does not produce dynamic outputs (whose handles aren't known
|
|
171
|
+
* statically). Nodes without output metadata are left untouched.
|
|
172
|
+
*/
|
|
173
|
+
validateDataEdgeSourceHandles(): void;
|
|
133
174
|
/**
|
|
134
175
|
* Verify that every edge references existing nodes.
|
|
135
176
|
*/
|
package/dist/graph.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../src/graph.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../src/graph.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAEV,IAAI,EACJ,cAAc,EACd,sBAAsB,EACtB,SAAS,EACT,iBAAiB,EAClB,MAAM,uBAAuB,CAAC;AAmB/B,MAAM,WAAW,oBAAoB;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,QAAQ,CAAC,MAAM,EAAE,oBAAoB,EAAE,CAAC;IACxC,YAAY,OAAO,EAAE,MAAM,EAAE,MAAM,GAAE,oBAAoB,EAAO,EAI/D;CACF;AAED,MAAM,WAAW,oBAAoB;IACnC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,gBAAgB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC;CAClD;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACvC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACj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