@cadenza.io/core 1.11.7 → 1.11.9
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/index.d.mts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +50 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +50 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -38,6 +38,7 @@ var SignalBroker = class _SignalBroker {
|
|
|
38
38
|
// execId -> emitted signals
|
|
39
39
|
constructor() {
|
|
40
40
|
this.debug = false;
|
|
41
|
+
this.verbose = false;
|
|
41
42
|
this.signalObservers = /* @__PURE__ */ new Map();
|
|
42
43
|
this.emitStacks = /* @__PURE__ */ new Map();
|
|
43
44
|
this.addSignal("meta.signal_broker.added");
|
|
@@ -55,6 +56,9 @@ var SignalBroker = class _SignalBroker {
|
|
|
55
56
|
setDebug(value) {
|
|
56
57
|
this.debug = value;
|
|
57
58
|
}
|
|
59
|
+
setVerbose(value) {
|
|
60
|
+
this.verbose = value;
|
|
61
|
+
}
|
|
58
62
|
validateSignalName(signalName) {
|
|
59
63
|
if (signalName.length > 100) {
|
|
60
64
|
throw new Error(
|
|
@@ -158,8 +162,10 @@ var SignalBroker = class _SignalBroker {
|
|
|
158
162
|
}
|
|
159
163
|
}
|
|
160
164
|
execute(signal, context) {
|
|
165
|
+
var _a;
|
|
161
166
|
const isMeta = signal.startsWith("meta.");
|
|
162
167
|
const isSubMeta = signal.startsWith("sub_meta.");
|
|
168
|
+
const isMetric = (_a = context.__signalEmission) == null ? void 0 : _a.isMetric;
|
|
163
169
|
if (!isSubMeta && (!isMeta || this.debug)) {
|
|
164
170
|
const emittedAt = Date.now();
|
|
165
171
|
context.__signalEmission = {
|
|
@@ -176,7 +182,7 @@ var SignalBroker = class _SignalBroker {
|
|
|
176
182
|
} else {
|
|
177
183
|
delete context.__signalEmission;
|
|
178
184
|
}
|
|
179
|
-
if (this.debug) {
|
|
185
|
+
if (this.debug && (!isMetric || this.verbose)) {
|
|
180
186
|
console.log(
|
|
181
187
|
`Emitting signal ${signal} with context ${JSON.stringify(context)}`
|
|
182
188
|
);
|
|
@@ -933,6 +939,7 @@ var GraphNode = class _GraphNode extends SignalEmitter {
|
|
|
933
939
|
if (!this.task.isHidden) {
|
|
934
940
|
data.__signalEmission = {
|
|
935
941
|
taskId: this.task.id,
|
|
942
|
+
taskName: this.task.name,
|
|
936
943
|
taskExecutionId: this.id
|
|
937
944
|
};
|
|
938
945
|
data.__metadata = {
|
|
@@ -946,7 +953,9 @@ var GraphNode = class _GraphNode extends SignalEmitter {
|
|
|
946
953
|
if (!this.task.isHidden) {
|
|
947
954
|
data.__signalEmission = {
|
|
948
955
|
taskId: this.task.id,
|
|
949
|
-
|
|
956
|
+
taskName: this.task.name,
|
|
957
|
+
taskExecutionId: this.id,
|
|
958
|
+
isMetric: true
|
|
950
959
|
};
|
|
951
960
|
data.__metadata = {
|
|
952
961
|
__routineExecId: this.routineExecId
|
|
@@ -1498,7 +1507,7 @@ var Task = class extends SignalParticipant {
|
|
|
1498
1507
|
* @edge Emits 'meta.task.created' with { __task: this } for seed.
|
|
1499
1508
|
*/
|
|
1500
1509
|
constructor(name, task, description = "", concurrency = 0, timeout = 0, register = true, isUnique = false, isMeta = false, isSubMeta = false, isHidden = false, getTagCallback = void 0, inputSchema = void 0, validateInputContext = false, outputSchema = void 0, validateOutputContext = false, retryCount = 0, retryDelay = 0, retryDelayMax = 0, retryDelayFactor = 1) {
|
|
1501
|
-
super();
|
|
1510
|
+
super(isSubMeta || isHidden);
|
|
1502
1511
|
this.isMeta = false;
|
|
1503
1512
|
this.isSubMeta = false;
|
|
1504
1513
|
this.isHidden = false;
|
|
@@ -1546,7 +1555,7 @@ var Task = class extends SignalParticipant {
|
|
|
1546
1555
|
}
|
|
1547
1556
|
if (register && !this.isHidden && !this.isSubMeta) {
|
|
1548
1557
|
const { __functionString, __getTagCallback } = this.export();
|
|
1549
|
-
this.
|
|
1558
|
+
this.emitWithMetadata("meta.task.created", {
|
|
1550
1559
|
__task: {
|
|
1551
1560
|
uuid: this.id,
|
|
1552
1561
|
name: this.name,
|
|
@@ -1581,7 +1590,10 @@ var Task = class extends SignalParticipant {
|
|
|
1581
1590
|
setGlobalId(id) {
|
|
1582
1591
|
const oldId = this.id;
|
|
1583
1592
|
this.id = id;
|
|
1584
|
-
this.
|
|
1593
|
+
this.emitWithMetadata("meta.task.global_id_set", {
|
|
1594
|
+
__id: this.id,
|
|
1595
|
+
__oldId: oldId
|
|
1596
|
+
});
|
|
1585
1597
|
}
|
|
1586
1598
|
setTimeout(timeout) {
|
|
1587
1599
|
this.timeout = timeout;
|
|
@@ -1604,6 +1616,27 @@ var Task = class extends SignalParticipant {
|
|
|
1604
1616
|
setValidateOutputContext(value) {
|
|
1605
1617
|
this.validateOutputContext = value;
|
|
1606
1618
|
}
|
|
1619
|
+
emitWithMetadata(signal, ctx = {}) {
|
|
1620
|
+
const data = { ...ctx };
|
|
1621
|
+
if (!this.isHidden && !this.isSubMeta) {
|
|
1622
|
+
data.__signalEmission = {
|
|
1623
|
+
taskId: this.id,
|
|
1624
|
+
taskName: this.name
|
|
1625
|
+
};
|
|
1626
|
+
}
|
|
1627
|
+
this.emit(signal, data);
|
|
1628
|
+
}
|
|
1629
|
+
emitMetricsWithMetadata(signal, ctx = {}) {
|
|
1630
|
+
const data = { ...ctx };
|
|
1631
|
+
if (!this.isHidden && !this.isSubMeta) {
|
|
1632
|
+
data.__signalEmission = {
|
|
1633
|
+
taskId: this.id,
|
|
1634
|
+
taskName: this.name,
|
|
1635
|
+
isMetric: true
|
|
1636
|
+
};
|
|
1637
|
+
}
|
|
1638
|
+
this.emitMetrics(signal, data);
|
|
1639
|
+
}
|
|
1607
1640
|
/**
|
|
1608
1641
|
* Validates a context deeply against a schema.
|
|
1609
1642
|
* @param data - The data to validate (input context or output result).
|
|
@@ -1720,7 +1753,7 @@ var Task = class extends SignalParticipant {
|
|
|
1720
1753
|
this.inputContextSchema
|
|
1721
1754
|
);
|
|
1722
1755
|
if (!validationResult.valid) {
|
|
1723
|
-
this.
|
|
1756
|
+
this.emitWithMetadata("meta.task.input_validation_failed", {
|
|
1724
1757
|
__taskId: this.id,
|
|
1725
1758
|
__taskName: this.name,
|
|
1726
1759
|
__context: context,
|
|
@@ -1742,7 +1775,7 @@ var Task = class extends SignalParticipant {
|
|
|
1742
1775
|
this.outputContextSchema
|
|
1743
1776
|
);
|
|
1744
1777
|
if (!validationResult.valid) {
|
|
1745
|
-
this.
|
|
1778
|
+
this.emitWithMetadata("meta.task.outputValidationFailed", {
|
|
1746
1779
|
__taskId: this.id,
|
|
1747
1780
|
__result: context,
|
|
1748
1781
|
__errors: validationResult.errors
|
|
@@ -1782,7 +1815,7 @@ var Task = class extends SignalParticipant {
|
|
|
1782
1815
|
this.decouple(pred);
|
|
1783
1816
|
throw new Error(`Cycle adding pred ${pred.name} to ${this.name}`);
|
|
1784
1817
|
}
|
|
1785
|
-
this.
|
|
1818
|
+
this.emitMetricsWithMetadata("meta.task.relationship_added", {
|
|
1786
1819
|
data: {
|
|
1787
1820
|
taskId: this.id,
|
|
1788
1821
|
predecessorTaskId: pred.id
|
|
@@ -1802,7 +1835,7 @@ var Task = class extends SignalParticipant {
|
|
|
1802
1835
|
this.decouple(next);
|
|
1803
1836
|
throw new Error(`Cycle adding next ${next.name} to ${this.name}`);
|
|
1804
1837
|
}
|
|
1805
|
-
this.
|
|
1838
|
+
this.emitMetricsWithMetadata("meta.task.relationship_added", {
|
|
1806
1839
|
data: {
|
|
1807
1840
|
taskId: next.id,
|
|
1808
1841
|
predecessorTaskId: this.id
|
|
@@ -1833,7 +1866,7 @@ var Task = class extends SignalParticipant {
|
|
|
1833
1866
|
this.decouple(task);
|
|
1834
1867
|
throw new Error(`Cycle adding onFail ${task.name} to ${this.name}`);
|
|
1835
1868
|
}
|
|
1836
|
-
this.
|
|
1869
|
+
this.emitMetricsWithMetadata("meta.task.on_fail_relationship_added", {
|
|
1837
1870
|
data: {
|
|
1838
1871
|
taskId: this.id,
|
|
1839
1872
|
onFailTaskId: task.id
|
|
@@ -1877,7 +1910,7 @@ var Task = class extends SignalParticipant {
|
|
|
1877
1910
|
);
|
|
1878
1911
|
this.layerIndex = maxPred + 1;
|
|
1879
1912
|
if (prevLayerIndex !== this.layerIndex) {
|
|
1880
|
-
this.
|
|
1913
|
+
this.emitMetricsWithMetadata("meta.task.layer_index_changed", {
|
|
1881
1914
|
data: {
|
|
1882
1915
|
layerIndex: this.layerIndex
|
|
1883
1916
|
},
|
|
@@ -1923,7 +1956,7 @@ var Task = class extends SignalParticipant {
|
|
|
1923
1956
|
this.predecessorTasks.clear();
|
|
1924
1957
|
this.onFailTasks.clear();
|
|
1925
1958
|
this.destroyed = true;
|
|
1926
|
-
this.
|
|
1959
|
+
this.emitMetricsWithMetadata("meta.task.destroyed", {
|
|
1927
1960
|
data: { deleted: true },
|
|
1928
1961
|
filter: { uuid: this.id }
|
|
1929
1962
|
});
|
|
@@ -3018,6 +3051,11 @@ var Cadenza = class {
|
|
|
3018
3051
|
this.broker.setDebug(true);
|
|
3019
3052
|
this.runner.setDebug(true);
|
|
3020
3053
|
}
|
|
3054
|
+
if (mode === "verbose") {
|
|
3055
|
+
this.broker.setDebug(true);
|
|
3056
|
+
this.broker.setVerbose(true);
|
|
3057
|
+
this.runner.setDebug(true);
|
|
3058
|
+
}
|
|
3021
3059
|
}
|
|
3022
3060
|
/**
|
|
3023
3061
|
* Validates a name for uniqueness and non-emptiness.
|