@cadenza.io/core 3.24.0 → 3.25.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/dist/index.d.mts +52 -3
- package/dist/index.d.ts +52 -3
- package/dist/index.js +309 -38
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +309 -38
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -1
package/dist/index.mjs
CHANGED
|
@@ -2455,6 +2455,7 @@ var GraphNode = class _GraphNode extends SignalEmitter {
|
|
|
2455
2455
|
uuid: this.id,
|
|
2456
2456
|
routineExecutionId: this.routineExecId,
|
|
2457
2457
|
executionTraceId: this.executionTraceId,
|
|
2458
|
+
inquiryId: context.__inquiryId ?? null,
|
|
2458
2459
|
context: this.context.getContext(),
|
|
2459
2460
|
metaContext: this.context.getMetadata(),
|
|
2460
2461
|
taskName: this.task.name,
|
|
@@ -2636,7 +2637,8 @@ var GraphNode = class _GraphNode extends SignalEmitter {
|
|
|
2636
2637
|
if (!this.divided && !this.processing) {
|
|
2637
2638
|
this.processing = true;
|
|
2638
2639
|
const inputValidation = this.task.validateInput(
|
|
2639
|
-
this.isMeta() ? this.context.
|
|
2640
|
+
this.isMeta() ? this.context.getFullContext() : this.context.getContext(),
|
|
2641
|
+
this.context.getMetadata()
|
|
2640
2642
|
);
|
|
2641
2643
|
if (inputValidation !== true) {
|
|
2642
2644
|
this.onError(inputValidation.__validationErrors);
|
|
@@ -2729,9 +2731,16 @@ var GraphNode = class _GraphNode extends SignalEmitter {
|
|
|
2729
2731
|
}
|
|
2730
2732
|
}
|
|
2731
2733
|
inquire(inquiry, context, options) {
|
|
2732
|
-
return Cadenza.
|
|
2734
|
+
return Cadenza.resolveRuntimeInquiryDelegate()(
|
|
2733
2735
|
inquiry,
|
|
2734
|
-
{
|
|
2736
|
+
{
|
|
2737
|
+
...context,
|
|
2738
|
+
__executionTraceId: context.__executionTraceId ?? context.__metadata?.__executionTraceId ?? this.executionTraceId,
|
|
2739
|
+
__inquirySourceTaskName: this.task.name,
|
|
2740
|
+
__inquirySourceTaskVersion: this.task.version,
|
|
2741
|
+
__inquirySourceTaskExecutionId: this.id,
|
|
2742
|
+
__inquirySourceRoutineExecutionId: this.routineExecId
|
|
2743
|
+
},
|
|
2735
2744
|
options
|
|
2736
2745
|
);
|
|
2737
2746
|
}
|
|
@@ -2971,7 +2980,10 @@ var GraphNode = class _GraphNode extends SignalEmitter {
|
|
|
2971
2980
|
return this.divideAsync(current);
|
|
2972
2981
|
}
|
|
2973
2982
|
while (!current.done && current.value !== void 0) {
|
|
2974
|
-
const outputValidation = this.task.validateOutput(
|
|
2983
|
+
const outputValidation = this.task.validateOutput(
|
|
2984
|
+
current.value,
|
|
2985
|
+
this.context.getMetadata()
|
|
2986
|
+
);
|
|
2975
2987
|
if (outputValidation !== true) {
|
|
2976
2988
|
this.onError(outputValidation.__validationErrors);
|
|
2977
2989
|
break;
|
|
@@ -2983,7 +2995,10 @@ var GraphNode = class _GraphNode extends SignalEmitter {
|
|
|
2983
2995
|
} else if (this.result !== void 0 && !this.errored) {
|
|
2984
2996
|
newNodes.push(...this.generateNewNodes(this.result));
|
|
2985
2997
|
if (typeof this.result !== "boolean") {
|
|
2986
|
-
const outputValidation = this.task.validateOutput(
|
|
2998
|
+
const outputValidation = this.task.validateOutput(
|
|
2999
|
+
this.result,
|
|
3000
|
+
this.context.getMetadata()
|
|
3001
|
+
);
|
|
2987
3002
|
if (outputValidation !== true) {
|
|
2988
3003
|
this.onError(outputValidation.__validationErrors);
|
|
2989
3004
|
}
|
|
@@ -3015,7 +3030,10 @@ var GraphNode = class _GraphNode extends SignalEmitter {
|
|
|
3015
3030
|
async divideAsync(current) {
|
|
3016
3031
|
const nextNodes = [];
|
|
3017
3032
|
const _current = await current;
|
|
3018
|
-
const outputValidation = this.task.validateOutput(
|
|
3033
|
+
const outputValidation = this.task.validateOutput(
|
|
3034
|
+
_current.value,
|
|
3035
|
+
this.context.getMetadata()
|
|
3036
|
+
);
|
|
3019
3037
|
if (outputValidation !== true) {
|
|
3020
3038
|
this.onError(outputValidation.__validationErrors);
|
|
3021
3039
|
return nextNodes;
|
|
@@ -3023,7 +3041,10 @@ var GraphNode = class _GraphNode extends SignalEmitter {
|
|
|
3023
3041
|
nextNodes.push(...this.generateNewNodes(_current.value));
|
|
3024
3042
|
}
|
|
3025
3043
|
for await (const result of this.result) {
|
|
3026
|
-
const outputValidation2 = this.task.validateOutput(
|
|
3044
|
+
const outputValidation2 = this.task.validateOutput(
|
|
3045
|
+
result,
|
|
3046
|
+
this.context.getMetadata()
|
|
3047
|
+
);
|
|
3027
3048
|
if (outputValidation2 !== true) {
|
|
3028
3049
|
this.onError(outputValidation2.__validationErrors);
|
|
3029
3050
|
return [];
|
|
@@ -3470,6 +3491,11 @@ var GraphRunner = class extends SignalEmitter {
|
|
|
3470
3491
|
context.__executionTraceId = executionTraceId;
|
|
3471
3492
|
const routineExecId = context.__routineExecId ?? uuid5();
|
|
3472
3493
|
context.__routineExecId = routineExecId;
|
|
3494
|
+
Cadenza.applyRuntimeValidationScopesToContext(
|
|
3495
|
+
context,
|
|
3496
|
+
routineName,
|
|
3497
|
+
allTasks
|
|
3498
|
+
);
|
|
3473
3499
|
const ctx = new GraphContext(context || {});
|
|
3474
3500
|
if (!isSubMeta) {
|
|
3475
3501
|
if (isNewTrace) {
|
|
@@ -4283,7 +4309,7 @@ var Task = class _Task extends SignalEmitter {
|
|
|
4283
4309
|
* @param {number} [retryDelayMax=0] - The maximum delay (in milliseconds) allowed between retries.
|
|
4284
4310
|
* @param {number} [retryDelayFactor=1] - The factor by which the retry delay increases after each attempt.
|
|
4285
4311
|
*/
|
|
4286
|
-
constructor(name, task, description = "", concurrency = 0, timeout = 0, register = true, isUnique = false, isMeta = false, isSubMeta = false, isHidden = false, getTagCallback = void 0, inputSchema
|
|
4312
|
+
constructor(name, task, description = "", concurrency = 0, timeout = 0, register = true, isUnique = false, isMeta = false, isSubMeta = false, isHidden = false, getTagCallback = void 0, inputSchema, validateInputContext = false, outputSchema, validateOutputContext = false, retryCount = 0, retryDelay = 0, retryDelayMax = 0, retryDelayFactor = 1) {
|
|
4287
4313
|
super(isSubMeta || isHidden);
|
|
4288
4314
|
this.version = 1;
|
|
4289
4315
|
this.isMeta = false;
|
|
@@ -4296,8 +4322,10 @@ var Task = class _Task extends SignalEmitter {
|
|
|
4296
4322
|
this.isEphemeral = false;
|
|
4297
4323
|
this.isDebounce = false;
|
|
4298
4324
|
this.inputContextSchema = { type: "object" };
|
|
4325
|
+
this.hasExplicitInputContextSchema = false;
|
|
4299
4326
|
this.validateInputContext = false;
|
|
4300
4327
|
this.outputContextSchema = { type: "object" };
|
|
4328
|
+
this.hasExplicitOutputContextSchema = false;
|
|
4301
4329
|
this.validateOutputContext = false;
|
|
4302
4330
|
this.retryCount = 0;
|
|
4303
4331
|
this.retryDelay = 0;
|
|
@@ -4327,9 +4355,11 @@ var Task = class _Task extends SignalEmitter {
|
|
|
4327
4355
|
this.isMeta = isMeta;
|
|
4328
4356
|
this.isSubMeta = isSubMeta;
|
|
4329
4357
|
this.isHidden = isHidden;
|
|
4330
|
-
this.inputContextSchema = inputSchema;
|
|
4358
|
+
this.inputContextSchema = inputSchema ?? { type: "object" };
|
|
4359
|
+
this.hasExplicitInputContextSchema = inputSchema !== void 0;
|
|
4331
4360
|
this.validateInputContext = validateInputContext;
|
|
4332
|
-
this.outputContextSchema = outputSchema;
|
|
4361
|
+
this.outputContextSchema = outputSchema ?? { type: "object" };
|
|
4362
|
+
this.hasExplicitOutputContextSchema = outputSchema !== void 0;
|
|
4333
4363
|
this.validateOutputContext = validateOutputContext;
|
|
4334
4364
|
this.retryCount = retryCount;
|
|
4335
4365
|
this.retryDelay = retryDelay;
|
|
@@ -4346,8 +4376,11 @@ var Task = class _Task extends SignalEmitter {
|
|
|
4346
4376
|
"meta.task.destroyed",
|
|
4347
4377
|
"meta.task.output_validation_failed",
|
|
4348
4378
|
"meta.task.input_validation_failed",
|
|
4379
|
+
"meta.task.input_schema_missing",
|
|
4380
|
+
"meta.task.output_schema_missing",
|
|
4349
4381
|
"meta.task.relationship_added",
|
|
4350
4382
|
"meta.task.relationship_removed",
|
|
4383
|
+
"meta.task.intent_associated",
|
|
4351
4384
|
"meta.task.layer_index_changed",
|
|
4352
4385
|
"meta.node.scheduled",
|
|
4353
4386
|
"meta.node.mapped",
|
|
@@ -4434,9 +4467,9 @@ var Task = class _Task extends SignalEmitter {
|
|
|
4434
4467
|
this.isSubMeta,
|
|
4435
4468
|
this.isHidden,
|
|
4436
4469
|
this.getTag,
|
|
4437
|
-
this.inputContextSchema,
|
|
4470
|
+
this.hasExplicitInputContextSchema ? this.inputContextSchema : void 0,
|
|
4438
4471
|
this.validateInputContext,
|
|
4439
|
-
this.outputContextSchema,
|
|
4472
|
+
this.hasExplicitOutputContextSchema ? this.outputContextSchema : void 0,
|
|
4440
4473
|
this.validateOutputContext,
|
|
4441
4474
|
this.retryCount,
|
|
4442
4475
|
this.retryDelay,
|
|
@@ -4483,9 +4516,11 @@ var Task = class _Task extends SignalEmitter {
|
|
|
4483
4516
|
}
|
|
4484
4517
|
setInputContextSchema(schema) {
|
|
4485
4518
|
this.inputContextSchema = schema;
|
|
4519
|
+
this.hasExplicitInputContextSchema = true;
|
|
4486
4520
|
}
|
|
4487
4521
|
setOutputContextSchema(schema) {
|
|
4488
4522
|
this.outputContextSchema = schema;
|
|
4523
|
+
this.hasExplicitOutputContextSchema = true;
|
|
4489
4524
|
}
|
|
4490
4525
|
setValidateInputContext(value) {
|
|
4491
4526
|
this.validateInputContext = value;
|
|
@@ -4722,19 +4757,86 @@ var Task = class _Task extends SignalEmitter {
|
|
|
4722
4757
|
* @param {AnyObject} context - The input context to validate.
|
|
4723
4758
|
* @return {true | AnyObject} - Returns `true` if validation succeeds, otherwise returns an error object containing details of the validation failure.
|
|
4724
4759
|
*/
|
|
4725
|
-
|
|
4726
|
-
|
|
4727
|
-
|
|
4728
|
-
|
|
4729
|
-
|
|
4730
|
-
|
|
4731
|
-
|
|
4732
|
-
|
|
4733
|
-
|
|
4734
|
-
|
|
4735
|
-
|
|
4736
|
-
|
|
4737
|
-
|
|
4760
|
+
getEffectiveValidationMode(direction, metadata = {}) {
|
|
4761
|
+
const resolvedPolicy = Cadenza.resolveRuntimeValidationPolicyForTask(
|
|
4762
|
+
this,
|
|
4763
|
+
metadata
|
|
4764
|
+
);
|
|
4765
|
+
const policyMode = direction === "input" ? resolvedPolicy.inputMode : resolvedPolicy.outputMode;
|
|
4766
|
+
const isExplicit = direction === "input" ? this.validateInputContext : this.validateOutputContext;
|
|
4767
|
+
return {
|
|
4768
|
+
resolvedPolicy,
|
|
4769
|
+
mode: isExplicit ? "enforce" : policyMode,
|
|
4770
|
+
warnOnMissingSchema: direction === "input" ? resolvedPolicy.warnOnMissingInputSchema : resolvedPolicy.warnOnMissingOutputSchema,
|
|
4771
|
+
hasExplicitSchema: direction === "input" ? this.hasExplicitInputContextSchema : this.hasExplicitOutputContextSchema,
|
|
4772
|
+
schema: direction === "input" ? this.inputContextSchema : this.outputContextSchema
|
|
4773
|
+
};
|
|
4774
|
+
}
|
|
4775
|
+
warnMissingSchema(direction, metadata = {}) {
|
|
4776
|
+
const resolvedPolicy = Cadenza.resolveRuntimeValidationPolicyForTask(
|
|
4777
|
+
this,
|
|
4778
|
+
metadata
|
|
4779
|
+
);
|
|
4780
|
+
const cacheKey = `${this.name}:${this.version}:${direction}:${resolvedPolicy.layer}`;
|
|
4781
|
+
if (!Cadenza.shouldEmitMissingSchemaWarning(cacheKey)) {
|
|
4782
|
+
return;
|
|
4783
|
+
}
|
|
4784
|
+
const ctx = {
|
|
4785
|
+
__taskName: this.name,
|
|
4786
|
+
__taskVersion: this.version,
|
|
4787
|
+
__layer: resolvedPolicy.layer,
|
|
4788
|
+
__activeScopeIds: resolvedPolicy.activeScopeIds
|
|
4789
|
+
};
|
|
4790
|
+
this.emitWithMetadata(`meta.task.${direction}_schema_missing`, ctx);
|
|
4791
|
+
console.warn(
|
|
4792
|
+
`[CADENZA_VALIDATION] Missing ${direction} schema for task '${this.name}'`,
|
|
4793
|
+
{
|
|
4794
|
+
taskName: this.name,
|
|
4795
|
+
taskVersion: this.version,
|
|
4796
|
+
direction,
|
|
4797
|
+
layer: resolvedPolicy.layer,
|
|
4798
|
+
activeScopeIds: resolvedPolicy.activeScopeIds
|
|
4799
|
+
}
|
|
4800
|
+
);
|
|
4801
|
+
}
|
|
4802
|
+
logValidationFailure(direction, validationErrors, metadata = {}) {
|
|
4803
|
+
const resolvedPolicy = Cadenza.resolveRuntimeValidationPolicyForTask(
|
|
4804
|
+
this,
|
|
4805
|
+
metadata
|
|
4806
|
+
);
|
|
4807
|
+
console.error(
|
|
4808
|
+
`[CADENZA_VALIDATION] ${direction} validation failed for task '${this.name}'`,
|
|
4809
|
+
{
|
|
4810
|
+
taskName: this.name,
|
|
4811
|
+
taskVersion: this.version,
|
|
4812
|
+
direction,
|
|
4813
|
+
layer: resolvedPolicy.layer,
|
|
4814
|
+
activeScopeIds: resolvedPolicy.activeScopeIds,
|
|
4815
|
+
errors: validationErrors
|
|
4816
|
+
}
|
|
4817
|
+
);
|
|
4818
|
+
}
|
|
4819
|
+
validateInput(context, metadata = {}) {
|
|
4820
|
+
const config = this.getEffectiveValidationMode("input", metadata);
|
|
4821
|
+
if (config.mode === "off") {
|
|
4822
|
+
return true;
|
|
4823
|
+
}
|
|
4824
|
+
if (!config.hasExplicitSchema) {
|
|
4825
|
+
if (config.warnOnMissingSchema) {
|
|
4826
|
+
this.warnMissingSchema("input", metadata);
|
|
4827
|
+
}
|
|
4828
|
+
return true;
|
|
4829
|
+
}
|
|
4830
|
+
const validationResult = this.validateSchema(context, config.schema);
|
|
4831
|
+
if (!validationResult.valid) {
|
|
4832
|
+
this.emitWithMetadata("meta.task.input_validation_failed", {
|
|
4833
|
+
__taskName: this.name,
|
|
4834
|
+
__taskVersion: this.version,
|
|
4835
|
+
__context: context,
|
|
4836
|
+
__errors: validationResult.errors
|
|
4837
|
+
});
|
|
4838
|
+
this.logValidationFailure("input", validationResult.errors, metadata);
|
|
4839
|
+
if (config.mode === "enforce") {
|
|
4738
4840
|
return {
|
|
4739
4841
|
errored: true,
|
|
4740
4842
|
__error: "Input context validation failed",
|
|
@@ -4751,19 +4853,27 @@ var Task = class _Task extends SignalEmitter {
|
|
|
4751
4853
|
* @return {true | AnyObject} Returns `true` if the output context is valid; otherwise, returns an object
|
|
4752
4854
|
* containing error information when validation fails.
|
|
4753
4855
|
*/
|
|
4754
|
-
validateOutput(context) {
|
|
4755
|
-
|
|
4756
|
-
|
|
4757
|
-
|
|
4758
|
-
|
|
4759
|
-
|
|
4760
|
-
if (
|
|
4761
|
-
this.
|
|
4762
|
-
|
|
4763
|
-
|
|
4764
|
-
|
|
4765
|
-
|
|
4766
|
-
|
|
4856
|
+
validateOutput(context, metadata = {}) {
|
|
4857
|
+
const config = this.getEffectiveValidationMode("output", metadata);
|
|
4858
|
+
if (config.mode === "off") {
|
|
4859
|
+
return true;
|
|
4860
|
+
}
|
|
4861
|
+
if (!config.hasExplicitSchema) {
|
|
4862
|
+
if (config.warnOnMissingSchema) {
|
|
4863
|
+
this.warnMissingSchema("output", metadata);
|
|
4864
|
+
}
|
|
4865
|
+
return true;
|
|
4866
|
+
}
|
|
4867
|
+
const validationResult = this.validateSchema(context, config.schema);
|
|
4868
|
+
if (!validationResult.valid) {
|
|
4869
|
+
this.emitWithMetadata("meta.task.output_validation_failed", {
|
|
4870
|
+
__taskName: this.name,
|
|
4871
|
+
__taskVersion: this.version,
|
|
4872
|
+
__result: context,
|
|
4873
|
+
__errors: validationResult.errors
|
|
4874
|
+
});
|
|
4875
|
+
this.logValidationFailure("output", validationResult.errors, metadata);
|
|
4876
|
+
if (config.mode === "enforce") {
|
|
4767
4877
|
return {
|
|
4768
4878
|
errored: true,
|
|
4769
4879
|
__error: "Output context validation failed",
|
|
@@ -5145,8 +5255,20 @@ var Task = class _Task extends SignalEmitter {
|
|
|
5145
5255
|
}
|
|
5146
5256
|
respondsTo(...inquires) {
|
|
5147
5257
|
for (const intentName of inquires) {
|
|
5258
|
+
if (this.handlesIntents.has(intentName)) {
|
|
5259
|
+
continue;
|
|
5260
|
+
}
|
|
5148
5261
|
this.handlesIntents.add(intentName);
|
|
5149
5262
|
Cadenza.inquiryBroker.observe(intentName, this);
|
|
5263
|
+
if (this.register) {
|
|
5264
|
+
this.emitWithMetadata("meta.task.intent_associated", {
|
|
5265
|
+
data: {
|
|
5266
|
+
intentName,
|
|
5267
|
+
taskName: this.name,
|
|
5268
|
+
taskVersion: this.version
|
|
5269
|
+
}
|
|
5270
|
+
});
|
|
5271
|
+
}
|
|
5150
5272
|
const intent = Cadenza.inquiryBroker.intents.get(intentName);
|
|
5151
5273
|
if (intent?.input) {
|
|
5152
5274
|
this.inputContextSchema = this.mergeSchemaVariant(
|
|
@@ -5154,6 +5276,7 @@ var Task = class _Task extends SignalEmitter {
|
|
|
5154
5276
|
intentName,
|
|
5155
5277
|
intent.input
|
|
5156
5278
|
);
|
|
5279
|
+
this.hasExplicitInputContextSchema = true;
|
|
5157
5280
|
}
|
|
5158
5281
|
if (intent?.output) {
|
|
5159
5282
|
this.outputContextSchema = this.mergeSchemaVariant(
|
|
@@ -5161,6 +5284,7 @@ var Task = class _Task extends SignalEmitter {
|
|
|
5161
5284
|
intentName,
|
|
5162
5285
|
intent.output
|
|
5163
5286
|
);
|
|
5287
|
+
this.hasExplicitOutputContextSchema = true;
|
|
5164
5288
|
}
|
|
5165
5289
|
}
|
|
5166
5290
|
return this;
|
|
@@ -6864,6 +6988,146 @@ var Cadenza = class {
|
|
|
6864
6988
|
static async inquire(inquiry, context, options) {
|
|
6865
6989
|
return this.inquiryBroker?.inquire(inquiry, context, options);
|
|
6866
6990
|
}
|
|
6991
|
+
static setRuntimeInquiryDelegate(delegate) {
|
|
6992
|
+
this.runtimeInquiryDelegate = delegate;
|
|
6993
|
+
}
|
|
6994
|
+
static resolveRuntimeInquiryDelegate() {
|
|
6995
|
+
return this.runtimeInquiryDelegate ?? ((inquiry, context, options) => this.inquire(inquiry, context, options));
|
|
6996
|
+
}
|
|
6997
|
+
static getRuntimeValidationPolicy() {
|
|
6998
|
+
return { ...this.runtimeValidationPolicy };
|
|
6999
|
+
}
|
|
7000
|
+
static setRuntimeValidationPolicy(policy = {}) {
|
|
7001
|
+
this.runtimeValidationPolicy = {
|
|
7002
|
+
...this.runtimeValidationPolicy,
|
|
7003
|
+
...policy
|
|
7004
|
+
};
|
|
7005
|
+
this.emittedMissingSchemaWarnings.clear();
|
|
7006
|
+
return this.getRuntimeValidationPolicy();
|
|
7007
|
+
}
|
|
7008
|
+
static replaceRuntimeValidationPolicy(policy = {}) {
|
|
7009
|
+
this.runtimeValidationPolicy = { ...policy };
|
|
7010
|
+
this.emittedMissingSchemaWarnings.clear();
|
|
7011
|
+
return this.getRuntimeValidationPolicy();
|
|
7012
|
+
}
|
|
7013
|
+
static clearRuntimeValidationPolicy() {
|
|
7014
|
+
this.runtimeValidationPolicy = {};
|
|
7015
|
+
this.emittedMissingSchemaWarnings.clear();
|
|
7016
|
+
}
|
|
7017
|
+
static getRuntimeValidationScopes() {
|
|
7018
|
+
return Array.from(this.runtimeValidationScopes.values()).map((scope) => ({
|
|
7019
|
+
...scope,
|
|
7020
|
+
startTaskNames: scope.startTaskNames ? [...scope.startTaskNames] : void 0,
|
|
7021
|
+
startRoutineNames: scope.startRoutineNames ? [...scope.startRoutineNames] : void 0,
|
|
7022
|
+
policy: scope.policy ? { ...scope.policy } : void 0
|
|
7023
|
+
}));
|
|
7024
|
+
}
|
|
7025
|
+
static upsertRuntimeValidationScope(scope) {
|
|
7026
|
+
if (!scope.id?.trim()) {
|
|
7027
|
+
throw new Error("Runtime validation scope id is required");
|
|
7028
|
+
}
|
|
7029
|
+
const normalizedScope = {
|
|
7030
|
+
id: scope.id,
|
|
7031
|
+
active: scope.active !== false,
|
|
7032
|
+
startTaskNames: scope.startTaskNames ? [...new Set(scope.startTaskNames)] : void 0,
|
|
7033
|
+
startRoutineNames: scope.startRoutineNames ? [...new Set(scope.startRoutineNames)] : void 0,
|
|
7034
|
+
policy: scope.policy ? { ...scope.policy } : void 0
|
|
7035
|
+
};
|
|
7036
|
+
this.runtimeValidationScopes.set(scope.id, normalizedScope);
|
|
7037
|
+
this.emittedMissingSchemaWarnings.clear();
|
|
7038
|
+
return {
|
|
7039
|
+
...normalizedScope,
|
|
7040
|
+
startTaskNames: normalizedScope.startTaskNames ? [...normalizedScope.startTaskNames] : void 0,
|
|
7041
|
+
startRoutineNames: normalizedScope.startRoutineNames ? [...normalizedScope.startRoutineNames] : void 0,
|
|
7042
|
+
policy: normalizedScope.policy ? { ...normalizedScope.policy } : void 0
|
|
7043
|
+
};
|
|
7044
|
+
}
|
|
7045
|
+
static removeRuntimeValidationScope(id) {
|
|
7046
|
+
this.runtimeValidationScopes.delete(id);
|
|
7047
|
+
this.emittedMissingSchemaWarnings.clear();
|
|
7048
|
+
}
|
|
7049
|
+
static clearRuntimeValidationScopes() {
|
|
7050
|
+
this.runtimeValidationScopes.clear();
|
|
7051
|
+
this.emittedMissingSchemaWarnings.clear();
|
|
7052
|
+
}
|
|
7053
|
+
static applyRuntimeValidationScopesToContext(context, routineName, tasks) {
|
|
7054
|
+
const existingScopeIds = /* @__PURE__ */ new Set();
|
|
7055
|
+
const metadataScopeIds = context.__metadata?.__runtimeValidationScopeIds;
|
|
7056
|
+
const rootScopeIds = context.__runtimeValidationScopeIds;
|
|
7057
|
+
if (Array.isArray(rootScopeIds)) {
|
|
7058
|
+
rootScopeIds.forEach((id) => existingScopeIds.add(id));
|
|
7059
|
+
}
|
|
7060
|
+
if (Array.isArray(metadataScopeIds)) {
|
|
7061
|
+
metadataScopeIds.forEach((id) => existingScopeIds.add(id));
|
|
7062
|
+
}
|
|
7063
|
+
const taskNames = new Set(tasks.map((task) => task.name));
|
|
7064
|
+
for (const scope of this.runtimeValidationScopes.values()) {
|
|
7065
|
+
if (scope.active === false) {
|
|
7066
|
+
continue;
|
|
7067
|
+
}
|
|
7068
|
+
const matchesRoutine = scope.startRoutineNames?.includes(routineName) === true;
|
|
7069
|
+
const matchesTask = scope.startTaskNames?.some((taskName) => taskNames.has(taskName)) === true;
|
|
7070
|
+
if (matchesRoutine || matchesTask) {
|
|
7071
|
+
existingScopeIds.add(scope.id);
|
|
7072
|
+
}
|
|
7073
|
+
}
|
|
7074
|
+
if (existingScopeIds.size > 0) {
|
|
7075
|
+
const scopeIds = Array.from(existingScopeIds);
|
|
7076
|
+
context.__runtimeValidationScopeIds = scopeIds;
|
|
7077
|
+
context.__metadata = {
|
|
7078
|
+
...context.__metadata ?? {},
|
|
7079
|
+
__runtimeValidationScopeIds: scopeIds
|
|
7080
|
+
};
|
|
7081
|
+
}
|
|
7082
|
+
return context;
|
|
7083
|
+
}
|
|
7084
|
+
static resolveRuntimeValidationPolicyForTask(task, metadata = {}) {
|
|
7085
|
+
const layer = task.isMeta || task.isSubMeta || metadata.__isSubMeta ? "meta" : "business";
|
|
7086
|
+
const activeScopeIds = /* @__PURE__ */ new Set();
|
|
7087
|
+
const rootScopeIds = metadata.__runtimeValidationScopeIds;
|
|
7088
|
+
const nestedScopeIds = metadata.__metadata?.__runtimeValidationScopeIds;
|
|
7089
|
+
if (Array.isArray(rootScopeIds)) {
|
|
7090
|
+
rootScopeIds.forEach((id) => activeScopeIds.add(id));
|
|
7091
|
+
}
|
|
7092
|
+
if (Array.isArray(nestedScopeIds)) {
|
|
7093
|
+
nestedScopeIds.forEach((id) => activeScopeIds.add(id));
|
|
7094
|
+
}
|
|
7095
|
+
const mergedPolicy = {
|
|
7096
|
+
...this.runtimeValidationPolicy
|
|
7097
|
+
};
|
|
7098
|
+
for (const scopeId of activeScopeIds) {
|
|
7099
|
+
const scope = this.runtimeValidationScopes.get(scopeId);
|
|
7100
|
+
if (!scope?.policy || scope.active === false) {
|
|
7101
|
+
continue;
|
|
7102
|
+
}
|
|
7103
|
+
Object.assign(mergedPolicy, scope.policy);
|
|
7104
|
+
}
|
|
7105
|
+
if (layer === "meta") {
|
|
7106
|
+
return {
|
|
7107
|
+
layer,
|
|
7108
|
+
inputMode: mergedPolicy.metaInput ?? "off",
|
|
7109
|
+
outputMode: mergedPolicy.metaOutput ?? "off",
|
|
7110
|
+
warnOnMissingInputSchema: mergedPolicy.warnOnMissingMetaInputSchema === true,
|
|
7111
|
+
warnOnMissingOutputSchema: mergedPolicy.warnOnMissingMetaOutputSchema === true,
|
|
7112
|
+
activeScopeIds: Array.from(activeScopeIds)
|
|
7113
|
+
};
|
|
7114
|
+
}
|
|
7115
|
+
return {
|
|
7116
|
+
layer,
|
|
7117
|
+
inputMode: mergedPolicy.businessInput ?? "off",
|
|
7118
|
+
outputMode: mergedPolicy.businessOutput ?? "off",
|
|
7119
|
+
warnOnMissingInputSchema: mergedPolicy.warnOnMissingBusinessInputSchema === true,
|
|
7120
|
+
warnOnMissingOutputSchema: mergedPolicy.warnOnMissingBusinessOutputSchema === true,
|
|
7121
|
+
activeScopeIds: Array.from(activeScopeIds)
|
|
7122
|
+
};
|
|
7123
|
+
}
|
|
7124
|
+
static shouldEmitMissingSchemaWarning(cacheKey) {
|
|
7125
|
+
if (this.emittedMissingSchemaWarnings.has(cacheKey)) {
|
|
7126
|
+
return false;
|
|
7127
|
+
}
|
|
7128
|
+
this.emittedMissingSchemaWarnings.add(cacheKey);
|
|
7129
|
+
return true;
|
|
7130
|
+
}
|
|
6867
7131
|
/**
|
|
6868
7132
|
* Creates an in-memory actor runtime instance.
|
|
6869
7133
|
*
|
|
@@ -7463,11 +7727,18 @@ var Cadenza = class {
|
|
|
7463
7727
|
this.registry?.reset();
|
|
7464
7728
|
this.taskCache.clear();
|
|
7465
7729
|
this.actorCache.clear();
|
|
7730
|
+
this.runtimeInquiryDelegate = void 0;
|
|
7731
|
+
this.runtimeValidationPolicy = {};
|
|
7732
|
+
this.runtimeValidationScopes.clear();
|
|
7733
|
+
this.emittedMissingSchemaWarnings.clear();
|
|
7466
7734
|
this.isBootstrapped = false;
|
|
7467
7735
|
}
|
|
7468
7736
|
};
|
|
7469
7737
|
Cadenza.taskCache = /* @__PURE__ */ new Map();
|
|
7470
7738
|
Cadenza.actorCache = /* @__PURE__ */ new Map();
|
|
7739
|
+
Cadenza.runtimeValidationPolicy = {};
|
|
7740
|
+
Cadenza.runtimeValidationScopes = /* @__PURE__ */ new Map();
|
|
7741
|
+
Cadenza.emittedMissingSchemaWarnings = /* @__PURE__ */ new Set();
|
|
7471
7742
|
Cadenza.isBootstrapped = false;
|
|
7472
7743
|
Cadenza.mode = "production";
|
|
7473
7744
|
|