@cadenza.io/core 3.17.1 → 3.18.0

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.js CHANGED
@@ -29,7 +29,6 @@ __export(index_exports, {
29
29
  GraphRunner: () => GraphRunner,
30
30
  SignalBroker: () => SignalBroker,
31
31
  SignalEmitter: () => SignalEmitter,
32
- SignalTask: () => SignalTask,
33
32
  Task: () => Task,
34
33
  default: () => index_default
35
34
  });
@@ -1527,17 +1526,24 @@ var SignalBroker = class _SignalBroker {
1527
1526
  squashId,
1528
1527
  debounce_default(() => {
1529
1528
  options.squash = false;
1530
- this.emit(signal, this.squashedContexts.get(squashId), options);
1529
+ this.emit(
1530
+ signal,
1531
+ options.mergeFunction ? options.mergeFunction(
1532
+ this.squashedContexts.get(squashId)[0],
1533
+ ...this.squashedContexts.get(squashId).slice(1)
1534
+ ) : merge_default(
1535
+ this.squashedContexts.get(squashId)[0],
1536
+ ...this.squashedContexts.get(squashId).slice(1)
1537
+ ),
1538
+ options
1539
+ );
1531
1540
  this.squashedEmitters.delete(squashId);
1532
1541
  this.squashedContexts.delete(squashId);
1533
1542
  }, delayMs ?? 300)
1534
1543
  );
1535
- this.squashedContexts.set(squashId, context);
1544
+ this.squashedContexts.set(squashId, [context]);
1536
1545
  } else {
1537
- this.squashedContexts.set(
1538
- squashId,
1539
- options.mergeFunction ? options.mergeFunction(this.squashedContexts.get(squashId), context) : merge_default(this.squashedContexts.get(squashId), context)
1540
- );
1546
+ this.squashedContexts.get(squashId)?.push(context);
1541
1547
  }
1542
1548
  this.squashedEmitters.get(squashId)();
1543
1549
  }
@@ -2115,7 +2121,7 @@ var SignalEmitter = class {
2115
2121
  * @param options
2116
2122
  */
2117
2123
  emit(signal, data = {}, options = {}) {
2118
- Cadenza.broker.emit(signal, data, options);
2124
+ Cadenza.signalBroker.emit(signal, data, options);
2119
2125
  }
2120
2126
  /**
2121
2127
  * Emits a signal via the broker if not silent.
@@ -2127,7 +2133,7 @@ var SignalEmitter = class {
2127
2133
  if (this.silent) {
2128
2134
  return;
2129
2135
  }
2130
- Cadenza.broker.emit(signal, data, options);
2136
+ Cadenza.signalBroker.emit(signal, data, options);
2131
2137
  }
2132
2138
  };
2133
2139
 
@@ -2439,7 +2445,7 @@ var GraphNode = class _GraphNode extends SignalEmitter {
2439
2445
  );
2440
2446
  if (this.graphDone()) {
2441
2447
  const context2 = this.context.getFullContext();
2442
- if (context2.__isDeputy)
2448
+ if (context2.__isDeputy || context2.__isInquiry)
2443
2449
  this.emitWithMetadata(
2444
2450
  `meta.node.graph_completed:${this.routineExecId}`,
2445
2451
  context2
@@ -2547,6 +2553,7 @@ var GraphNode = class _GraphNode extends SignalEmitter {
2547
2553
  const result = this.task.execute(
2548
2554
  this.context,
2549
2555
  this.emitWithMetadata.bind(this),
2556
+ this.inquire.bind(this),
2550
2557
  this.onProgress.bind(this),
2551
2558
  { nodeId: this.id, routineExecId: this.routineExecId }
2552
2559
  );
@@ -2565,6 +2572,13 @@ var GraphNode = class _GraphNode extends SignalEmitter {
2565
2572
  });
2566
2573
  }
2567
2574
  }
2575
+ inquire(inquiry, context, options) {
2576
+ return Cadenza.inquire(
2577
+ inquiry,
2578
+ { ...context, __executionTraceId: this.executionTraceId },
2579
+ options
2580
+ );
2581
+ }
2568
2582
  /**
2569
2583
  * Emits a signal along with its associated metadata. The metadata includes
2570
2584
  * task-specific information such as task name, version, execution ID, and
@@ -3193,8 +3207,7 @@ var GraphRoutine = class extends SignalEmitter {
3193
3207
  */
3194
3208
  doOn(...signals) {
3195
3209
  signals.forEach((signal) => {
3196
- if (this.observedSignals.has(signal)) return;
3197
- Cadenza.broker.observe(signal, this);
3210
+ this.tasks.forEach((task) => task.doOn(signal));
3198
3211
  this.observedSignals.add(signal);
3199
3212
  });
3200
3213
  return this;
@@ -3208,7 +3221,7 @@ var GraphRoutine = class extends SignalEmitter {
3208
3221
  */
3209
3222
  unsubscribeAll() {
3210
3223
  this.observedSignals.forEach(
3211
- (signal) => Cadenza.broker.unsubscribe(signal, this)
3224
+ (signal) => this.tasks.forEach((task) => task.unsubscribe(signal))
3212
3225
  );
3213
3226
  this.observedSignals.clear();
3214
3227
  return this;
@@ -3221,10 +3234,8 @@ var GraphRoutine = class extends SignalEmitter {
3221
3234
  */
3222
3235
  unsubscribe(...signals) {
3223
3236
  signals.forEach((signal) => {
3224
- if (this.observedSignals.has(signal)) {
3225
- Cadenza.broker.unsubscribe(signal, this);
3226
- this.observedSignals.delete(signal);
3227
- }
3237
+ this.tasks.forEach((task) => task.unsubscribe(signal));
3238
+ this.observedSignals.delete(signal);
3228
3239
  });
3229
3240
  return this;
3230
3241
  }
@@ -3509,7 +3520,8 @@ var Task = class _Task extends SignalEmitter {
3509
3520
  this.signalsToEmitAfter = /* @__PURE__ */ new Set();
3510
3521
  this.signalsToEmitOnFail = /* @__PURE__ */ new Set();
3511
3522
  this.observedSignals = /* @__PURE__ */ new Set();
3512
- this.intents = /* @__PURE__ */ new Set();
3523
+ this.handlesIntents = /* @__PURE__ */ new Set();
3524
+ this.inquiresIntents = /* @__PURE__ */ new Set();
3513
3525
  this.name = name;
3514
3526
  this.taskFunction = task;
3515
3527
  this.description = description;
@@ -3588,7 +3600,8 @@ var Task = class _Task extends SignalEmitter {
3588
3600
  observed: Array.from(this.observedSignals)
3589
3601
  },
3590
3602
  intents: {
3591
- handles: Array.from(this.intents)
3603
+ handles: Array.from(this.handlesIntents),
3604
+ inquires: Array.from(this.inquiresIntents)
3592
3605
  }
3593
3606
  },
3594
3607
  taskInstance: this,
@@ -3880,14 +3893,16 @@ var Task = class _Task extends SignalEmitter {
3880
3893
  *
3881
3894
  * @param {GraphContext} context The execution context which provides data and functions necessary for the task.
3882
3895
  * @param {function(string, AnyObject): void} emit A function to emit signals and communicate intermediate results or states.
3896
+ * @param {function(string, AnyObject, InquiryOptions): Promise<AnyObject>} inquire A function to inquire something from another task.
3883
3897
  * @param {function(number): void} progressCallback A callback function used to report task progress as a percentage (0 to 100).
3884
3898
  * @param {{ nodeId: string; routineExecId: string }} nodeData An object containing identifiers related to the node and execution routine.
3885
3899
  * @return {TaskResult} The result of the executed task.
3886
3900
  */
3887
- execute(context, emit, progressCallback, nodeData) {
3901
+ execute(context, emit, inquire, progressCallback, nodeData) {
3888
3902
  return this.taskFunction(
3889
3903
  this.isMeta ? context.getClonedFullContext() : context.getClonedContext(),
3890
3904
  emit,
3905
+ inquire,
3891
3906
  progressCallback
3892
3907
  );
3893
3908
  }
@@ -4097,7 +4112,7 @@ var Task = class _Task extends SignalEmitter {
4097
4112
  doOn(...signals) {
4098
4113
  signals.forEach((signal) => {
4099
4114
  if (this.observedSignals.has(signal)) return;
4100
- Cadenza.broker.observe(signal, this);
4115
+ Cadenza.signalBroker.observe(signal, this);
4101
4116
  this.observedSignals.add(signal);
4102
4117
  if (this.register) {
4103
4118
  this.emitWithMetadata("meta.task.observed_signal", {
@@ -4151,7 +4166,7 @@ var Task = class _Task extends SignalEmitter {
4151
4166
  attachSignal(...signals) {
4152
4167
  signals.forEach((signal) => {
4153
4168
  this.emitsSignals.add(signal);
4154
- Cadenza.broker.registerEmittedSignal(signal);
4169
+ Cadenza.signalBroker.registerEmittedSignal(signal);
4155
4170
  if (this.register) {
4156
4171
  const data = {
4157
4172
  signals: {
@@ -4183,7 +4198,7 @@ var Task = class _Task extends SignalEmitter {
4183
4198
  unsubscribe(...signals) {
4184
4199
  signals.forEach((signal) => {
4185
4200
  if (this.observedSignals.has(signal)) {
4186
- Cadenza.broker.unsubscribe(signal, this);
4201
+ Cadenza.signalBroker.unsubscribe(signal, this);
4187
4202
  this.observedSignals.delete(signal);
4188
4203
  if (this.register) {
4189
4204
  signal = signal.split(":")[0];
@@ -4243,8 +4258,30 @@ var Task = class _Task extends SignalEmitter {
4243
4258
  this.signalsToEmitAfter.clear();
4244
4259
  return this;
4245
4260
  }
4246
- handlesIntent(intent) {
4247
- this.intents.add(intent);
4261
+ respondsTo(...inquires) {
4262
+ for (const intentName of inquires) {
4263
+ this.handlesIntents.add(intentName);
4264
+ Cadenza.inquiryBroker.observe(intentName, this);
4265
+ const intent = Cadenza.inquiryBroker.intents.get(intentName);
4266
+ this.inputContextSchema = intent?.input;
4267
+ this.outputContextSchema = intent?.output;
4268
+ }
4269
+ return this;
4270
+ }
4271
+ attachIntents(...intentNames) {
4272
+ for (const intent of intentNames) {
4273
+ this.inquiresIntents.add(intent);
4274
+ }
4275
+ return this;
4276
+ }
4277
+ detachIntents(...intentNames) {
4278
+ for (const intent of intentNames) {
4279
+ this.inquiresIntents.delete(intent);
4280
+ }
4281
+ return this;
4282
+ }
4283
+ detachAllIntents() {
4284
+ this.inquiresIntents.clear();
4248
4285
  return this;
4249
4286
  }
4250
4287
  /**
@@ -4581,6 +4618,7 @@ var DebounceTask = class extends Task {
4581
4618
  this.lastTimeout = null;
4582
4619
  this.lastProgressCallback = null;
4583
4620
  this.lastEmitFunction = null;
4621
+ this.lastInquireFunction = null;
4584
4622
  this.debounceTime = debounceTime;
4585
4623
  this.leading = leading;
4586
4624
  this.trailing = trailing;
@@ -4603,6 +4641,7 @@ var DebounceTask = class extends Task {
4603
4641
  result = this.taskFunction(
4604
4642
  this.lastContext.getClonedContext(),
4605
4643
  this.lastEmitFunction,
4644
+ this.lastInquireFunction,
4606
4645
  this.lastProgressCallback
4607
4646
  );
4608
4647
  } catch (error) {
@@ -4618,6 +4657,11 @@ var DebounceTask = class extends Task {
4618
4657
  this.lastResolve(result);
4619
4658
  }
4620
4659
  }
4660
+ this.lastContext = null;
4661
+ this.lastTimeout = null;
4662
+ this.lastProgressCallback = null;
4663
+ this.lastEmitFunction = null;
4664
+ this.lastInquireFunction = null;
4621
4665
  }
4622
4666
  /**
4623
4667
  * Executes a debounced operation, ensuring controlled execution of functions
@@ -4629,10 +4673,11 @@ var DebounceTask = class extends Task {
4629
4673
  * @param {GraphContext} context - The execution context for the operation.
4630
4674
  * @param {NodeJS.Timeout} timeout - A timeout object for managing execution delays.
4631
4675
  * @param {Function} emit - A callback function to emit signals with a specific context.
4676
+ * @param inquire
4632
4677
  * @param {Function} progressCallback - A callback function to report progress during operation execution.
4633
4678
  * @return {void} Does not return a value but sets internal timers and invokes provided callbacks.
4634
4679
  */
4635
- debouncedTrigger(resolve, reject, context, timeout, emit, progressCallback) {
4680
+ debouncedTrigger(resolve, reject, context, timeout, emit, inquire, progressCallback) {
4636
4681
  const callNow = this.leading && this.timer === null;
4637
4682
  const isNewBurst = this.timer === null;
4638
4683
  if (this.timer !== null) {
@@ -4645,6 +4690,7 @@ var DebounceTask = class extends Task {
4645
4690
  this.lastTimeout = timeout;
4646
4691
  this.lastProgressCallback = progressCallback;
4647
4692
  this.lastEmitFunction = emit;
4693
+ this.lastInquireFunction = inquire;
4648
4694
  if (!callNow) {
4649
4695
  this.hasLaterCall = true;
4650
4696
  }
@@ -4682,10 +4728,11 @@ var DebounceTask = class extends Task {
4682
4728
  *
4683
4729
  * @param {GraphContext} context - The context containing relevant graph data for the execution.
4684
4730
  * @param {function(string, any): void} emit - A function used to emit signals with associated context.
4731
+ * @param inquire
4685
4732
  * @param {function(number): void} progressCallback - A callback function to report the progress of the task as a number between 0 and 1.
4686
4733
  * @return {Promise<TaskResult>} A promise that resolves with the task result upon completion or rejects on failure.
4687
4734
  */
4688
- execute(context, emit, progressCallback) {
4735
+ execute(context, emit, inquire, progressCallback) {
4689
4736
  return new Promise((resolve, reject) => {
4690
4737
  const timeout = setTimeout(() => {
4691
4738
  resolve(false);
@@ -4696,6 +4743,7 @@ var DebounceTask = class extends Task {
4696
4743
  context,
4697
4744
  timeout,
4698
4745
  emit,
4746
+ inquire,
4699
4747
  progressCallback
4700
4748
  );
4701
4749
  });
@@ -4735,12 +4783,19 @@ var EphemeralTask = class extends Task {
4735
4783
  *
4736
4784
  * @param {any} context - The execution context, carrying necessary parameters or states for the operation.
4737
4785
  * @param {function(string, AnyObject): void} emit - A function to emit signals with a string identifier and associated context.
4786
+ * @param inquire
4738
4787
  * @param {function(number): void} progressCallback - A callback function to report the progress of the execution as a numerical value.
4739
4788
  * @param {{ nodeId: string, routineExecId: string }} nodeData - An object containing details about the node ID and routine execution ID.
4740
4789
  * @return {any} The result of the execution, returned from the base implementation or processed internally.
4741
4790
  */
4742
- execute(context, emit, progressCallback, nodeData) {
4743
- const result = super.execute(context, emit, progressCallback, nodeData);
4791
+ execute(context, emit, inquire, progressCallback, nodeData) {
4792
+ const result = super.execute(
4793
+ context,
4794
+ emit,
4795
+ inquire,
4796
+ progressCallback,
4797
+ nodeData
4798
+ );
4744
4799
  if (this.once || this.condition(result)) {
4745
4800
  this.destroy();
4746
4801
  }
@@ -5487,6 +5542,187 @@ var GraphStandardRun = class extends GraphRunStrategy {
5487
5542
  }
5488
5543
  };
5489
5544
 
5545
+ // src/engine/InquiryBroker.ts
5546
+ var import_uuid7 = require("uuid");
5547
+ var InquiryBroker = class _InquiryBroker extends SignalEmitter {
5548
+ constructor() {
5549
+ super(...arguments);
5550
+ this.debug = false;
5551
+ this.verbose = false;
5552
+ this.inquiryObservers = /* @__PURE__ */ new Map();
5553
+ this.intents = /* @__PURE__ */ new Map();
5554
+ }
5555
+ static get instance() {
5556
+ if (!this.instance_) {
5557
+ this.instance_ = new _InquiryBroker();
5558
+ }
5559
+ return this.instance_;
5560
+ }
5561
+ setDebug(value) {
5562
+ this.debug = value;
5563
+ }
5564
+ setVerbose(value) {
5565
+ this.verbose = value;
5566
+ }
5567
+ validateInquiryName(inquiryName) {
5568
+ if (inquiryName.length > 100) {
5569
+ throw new Error(
5570
+ `Inquiry name must be less than 100 characters: ${inquiryName}`
5571
+ );
5572
+ }
5573
+ if (inquiryName.includes(" ")) {
5574
+ throw new Error(`Inquiry name must not contain spaces: ${inquiryName}"`);
5575
+ }
5576
+ if (inquiryName.includes("\\")) {
5577
+ throw new Error(
5578
+ `Inquiry name must not contain backslashes: ${inquiryName}`
5579
+ );
5580
+ }
5581
+ if (inquiryName.includes(".")) {
5582
+ throw new Error(`Inquiry name must not contain dots: ${inquiryName}`);
5583
+ }
5584
+ }
5585
+ /**
5586
+ * Initializes with runners.
5587
+ * @param runner Standard runner for user signals.
5588
+ * @param metaRunner Meta runner for 'meta.' signals (suppresses further meta-emits).
5589
+ */
5590
+ bootstrap(runner, metaRunner) {
5591
+ this.runner = runner;
5592
+ this.metaRunner = metaRunner;
5593
+ }
5594
+ init() {
5595
+ }
5596
+ /**
5597
+ * Observes an inquiry with a routine/task.
5598
+ * @param inquiry The inquiry (e.g., 'domain.action', 'domain.*' for wildcards).
5599
+ * @param task The observer.
5600
+ * @edge Duplicates ignored; supports wildcards for broad listening.
5601
+ */
5602
+ observe(inquiry, task) {
5603
+ this.addInquiry(inquiry);
5604
+ this.inquiryObservers.get(inquiry).tasks.add(task);
5605
+ }
5606
+ /**
5607
+ * Unsubscribes a routine/task from an inquiry.
5608
+ * @param inquiry The inquiry.
5609
+ * @param task The observer.
5610
+ * @edge Removes all instances if duplicate; deletes if empty.
5611
+ */
5612
+ unsubscribe(inquiry, task) {
5613
+ const obs = this.inquiryObservers.get(inquiry);
5614
+ if (obs) {
5615
+ obs.tasks.delete(task);
5616
+ if (obs.tasks.size === 0) {
5617
+ this.inquiryObservers.delete(inquiry);
5618
+ }
5619
+ }
5620
+ }
5621
+ addInquiry(inquiry) {
5622
+ if (!this.inquiryObservers.has(inquiry)) {
5623
+ this.validateInquiryName(inquiry);
5624
+ this.inquiryObservers.set(inquiry, {
5625
+ fn: (runner, tasks, context) => runner.run(tasks, context),
5626
+ tasks: /* @__PURE__ */ new Set(),
5627
+ registered: false
5628
+ });
5629
+ this.addIntent({
5630
+ name: inquiry,
5631
+ description: "",
5632
+ input: void 0,
5633
+ output: void 0
5634
+ });
5635
+ this.emit("meta.inquiry_broker.added", { inquiryName: inquiry });
5636
+ }
5637
+ }
5638
+ addIntent(intent) {
5639
+ if (!this.intents.has(intent.name)) {
5640
+ this.validateInquiryName(intent.name);
5641
+ this.intents.set(intent.name, intent);
5642
+ } else {
5643
+ const currentIntent = this.intents.get(intent.name);
5644
+ if (currentIntent.description !== intent.description) {
5645
+ currentIntent.description = intent.description;
5646
+ }
5647
+ if (intent.input && currentIntent.input !== intent.input) {
5648
+ currentIntent.input = intent.input;
5649
+ }
5650
+ if (intent.output && currentIntent.output !== intent.output) {
5651
+ currentIntent.output = intent.output;
5652
+ }
5653
+ if (this.inquiryObservers.has(intent.name)) {
5654
+ for (const task of this.inquiryObservers.get(intent.name).tasks) {
5655
+ task.respondsTo(intent.name);
5656
+ }
5657
+ }
5658
+ }
5659
+ }
5660
+ inquire(inquiry, context, options = {
5661
+ timeout: 0
5662
+ }) {
5663
+ const tasks = this.inquiryObservers.get(inquiry)?.tasks;
5664
+ if (!tasks) {
5665
+ return Promise.resolve({});
5666
+ }
5667
+ return new Promise((resolve) => {
5668
+ let joinedContext = {};
5669
+ const pendingTasks = Array.from(tasks).map((task) => task.name);
5670
+ const resolveTasks = [];
5671
+ let timeoutId;
5672
+ if (options.timeout > 0) {
5673
+ timeoutId = setTimeout(() => {
5674
+ for (const resolveTask of resolveTasks) {
5675
+ resolveTask.destroy();
5676
+ }
5677
+ resolve({
5678
+ __error: "Inquire timeout",
5679
+ errored: true,
5680
+ pendingTasks,
5681
+ ...joinedContext
5682
+ });
5683
+ }, options.timeout);
5684
+ }
5685
+ for (const task of tasks) {
5686
+ const inquiryId = (0, import_uuid7.v4)();
5687
+ resolveTasks.push(
5688
+ Cadenza.createEphemeralMetaTask(
5689
+ `Resolve inquiry for ${inquiry}`,
5690
+ (ctx) => {
5691
+ joinedContext = { ...joinedContext, ...ctx };
5692
+ pendingTasks.splice(pendingTasks.indexOf(task.name), 1);
5693
+ if (pendingTasks.length === 0) {
5694
+ resolve(joinedContext);
5695
+ }
5696
+ if (timeoutId) {
5697
+ clearTimeout(timeoutId);
5698
+ timeoutId = void 0;
5699
+ }
5700
+ },
5701
+ "",
5702
+ {
5703
+ once: true,
5704
+ register: false
5705
+ }
5706
+ ).doOn(`meta.node.graph_completed:${inquiryId}`)
5707
+ );
5708
+ if (task.isMeta) {
5709
+ this.metaRunner?.run(task, {
5710
+ ...context,
5711
+ __routineExecId: inquiryId,
5712
+ __isInquiry: true
5713
+ });
5714
+ } else {
5715
+ this.runner?.run(task, {
5716
+ ...context,
5717
+ __routineExecId: inquiryId,
5718
+ __isInquiry: true
5719
+ });
5720
+ }
5721
+ }
5722
+ });
5723
+ }
5724
+ };
5725
+
5490
5726
  // src/Cadenza.ts
5491
5727
  var Cadenza = class {
5492
5728
  /**
@@ -5499,17 +5735,21 @@ var Cadenza = class {
5499
5735
  static bootstrap() {
5500
5736
  if (this.isBootstrapped) return;
5501
5737
  this.isBootstrapped = true;
5502
- this.broker = SignalBroker.instance;
5738
+ this.signalBroker = SignalBroker.instance;
5739
+ this.inquiryBroker = InquiryBroker.instance;
5503
5740
  this.runner = new GraphRunner();
5504
5741
  this.metaRunner = new GraphRunner(true);
5505
- this.broker.bootstrap(this.runner, this.metaRunner);
5742
+ this.signalBroker.bootstrap(this.runner, this.metaRunner);
5743
+ this.inquiryBroker.bootstrap(this.runner, this.metaRunner);
5506
5744
  if (this.mode === "debug" || this.mode === "dev") {
5507
- this.broker.setDebug(true);
5745
+ this.signalBroker.setDebug(true);
5746
+ this.inquiryBroker.setDebug(true);
5508
5747
  this.runner.setDebug(true);
5509
5748
  this.metaRunner.setDebug(true);
5510
5749
  }
5511
5750
  this.registry = GraphRegistry.instance;
5512
- this.broker.init();
5751
+ this.signalBroker.init();
5752
+ this.inquiryBroker.init();
5513
5753
  }
5514
5754
  /**
5515
5755
  * Retrieves the available strategies for running graphs.
@@ -5536,18 +5776,18 @@ var Cadenza = class {
5536
5776
  this.mode = mode;
5537
5777
  this.bootstrap();
5538
5778
  if (mode === "debug" || mode === "dev") {
5539
- this.broker.setDebug(true);
5779
+ this.signalBroker.setDebug(true);
5540
5780
  this.runner.setDebug(true);
5541
5781
  }
5542
5782
  if (mode === "verbose") {
5543
- this.broker.setDebug(true);
5544
- this.broker.setVerbose(true);
5783
+ this.signalBroker.setDebug(true);
5784
+ this.signalBroker.setVerbose(true);
5545
5785
  this.runner.setDebug(true);
5546
5786
  this.runner.setVerbose(true);
5547
5787
  }
5548
5788
  if (mode === "production") {
5549
- this.broker.setDebug(false);
5550
- this.broker.setVerbose(false);
5789
+ this.signalBroker.setDebug(false);
5790
+ this.signalBroker.setVerbose(false);
5551
5791
  this.runner.setDebug(false);
5552
5792
  this.runner.setVerbose(false);
5553
5793
  }
@@ -5604,13 +5844,13 @@ var Cadenza = class {
5604
5844
  * ```
5605
5845
  */
5606
5846
  static emit(event, data = {}, options = {}) {
5607
- this.broker?.emit(event, data, options);
5847
+ this.signalBroker?.emit(event, data, options);
5608
5848
  }
5609
5849
  static schedule(taskName, context, delayMs, exactDateTime) {
5610
- this.broker?.schedule(taskName, context, { delayMs, exactDateTime });
5850
+ this.signalBroker?.schedule(taskName, context, { delayMs, exactDateTime });
5611
5851
  }
5612
5852
  static interval(taskName, context, intervalMs, leading = false, startDateTime) {
5613
- this.broker?.interval(
5853
+ this.signalBroker?.interval(
5614
5854
  taskName,
5615
5855
  context,
5616
5856
  intervalMs,
@@ -5619,7 +5859,7 @@ var Cadenza = class {
5619
5859
  );
5620
5860
  }
5621
5861
  static debounce(signalName, context, delayMs) {
5622
- this.broker?.debounce(signalName, context, { delayMs });
5862
+ this.signalBroker?.debounce(signalName, context, { delayMs });
5623
5863
  }
5624
5864
  static get(taskName) {
5625
5865
  return this.registry?.tasks.get(taskName);
@@ -5627,6 +5867,13 @@ var Cadenza = class {
5627
5867
  static getRoutine(routineName) {
5628
5868
  return this.registry?.routines.get(routineName);
5629
5869
  }
5870
+ static defineIntent(intent) {
5871
+ this.inquiryBroker?.intents.set(intent.name, intent);
5872
+ return intent;
5873
+ }
5874
+ static async inquire(inquiry, context, options) {
5875
+ return this.inquiryBroker?.inquire(inquiry, context, options);
5876
+ }
5630
5877
  /**
5631
5878
  * Creates and registers a new task with the specified parameters and options.
5632
5879
  * Tasks are the basic building blocks of Cadenza graphs and are responsible for executing logic.
@@ -6155,7 +6402,7 @@ var Cadenza = class {
6155
6402
  return new GraphRoutine(name, tasks, description, true);
6156
6403
  }
6157
6404
  static reset() {
6158
- this.broker?.reset();
6405
+ this.signalBroker?.reset();
6159
6406
  this.registry?.reset();
6160
6407
  this.isBootstrapped = false;
6161
6408
  }
@@ -6163,14 +6410,6 @@ var Cadenza = class {
6163
6410
  Cadenza.isBootstrapped = false;
6164
6411
  Cadenza.mode = "production";
6165
6412
 
6166
- // src/graph/definition/SignalTask.ts
6167
- var SignalTask = class extends Task {
6168
- constructor(signal, description = "") {
6169
- super(signal, () => true, description);
6170
- this.signalsToEmitAfter.add(signal);
6171
- }
6172
- };
6173
-
6174
6413
  // src/index.ts
6175
6414
  var index_default = Cadenza;
6176
6415
  // Annotate the CommonJS export names for ESM import in node:
@@ -6184,7 +6423,6 @@ var index_default = Cadenza;
6184
6423
  GraphRunner,
6185
6424
  SignalBroker,
6186
6425
  SignalEmitter,
6187
- SignalTask,
6188
6426
  Task
6189
6427
  });
6190
6428
  /*! Bundled license information: