@cadenza.io/core 1.0.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.
@@ -0,0 +1,843 @@
1
+ type AnyObject = {
2
+ [key: string | number]: any;
3
+ };
4
+
5
+ declare class GraphContext {
6
+ readonly id: string;
7
+ private readonly fullContext;
8
+ private readonly userData;
9
+ private readonly metaData;
10
+ constructor(context: AnyObject);
11
+ /**
12
+ * Gets frozen user data (read-only, no clone).
13
+ * @returns Frozen user context.
14
+ */
15
+ getContext(): AnyObject;
16
+ getClonedContext(): AnyObject;
17
+ /**
18
+ * Gets full raw context (cloned for safety).
19
+ * @returns Cloned full context.
20
+ */
21
+ getFullContext(): AnyObject;
22
+ /**
23
+ * Gets frozen metadata (read-only).
24
+ * @returns Frozen metadata object.
25
+ */
26
+ getMetaData(): AnyObject;
27
+ /**
28
+ * Clones this context (new instance).
29
+ * @returns New GraphContext.
30
+ */
31
+ clone(): GraphContext;
32
+ /**
33
+ * Creates new context from data (via registry).
34
+ * @param context New data.
35
+ * @returns New GraphContext.
36
+ */
37
+ mutate(context: AnyObject): GraphContext;
38
+ /**
39
+ * Combines with another for uniques (joins userData).
40
+ * @param otherContext The other.
41
+ * @returns New combined GraphContext.
42
+ * @edge Appends other.userData to joinedContexts in userData.
43
+ */
44
+ combine(otherContext: GraphContext): GraphContext;
45
+ /**
46
+ * Exports the context.
47
+ * @returns Exported object.
48
+ */
49
+ export(): {
50
+ __id: string;
51
+ __context: AnyObject;
52
+ };
53
+ }
54
+
55
+ declare abstract class Iterator {
56
+ abstract hasNext(): boolean;
57
+ abstract hasPrevious?(): boolean;
58
+ abstract next(): any;
59
+ abstract previous?(): any;
60
+ abstract getFirst?(): any;
61
+ abstract getLast?(): any;
62
+ }
63
+
64
+ declare abstract class Graph {
65
+ /**
66
+ * Executes this graph node/task.
67
+ * @param args Execution args (e.g., context).
68
+ * @returns Result.
69
+ */
70
+ abstract execute(...args: any[]): unknown;
71
+ /**
72
+ * Logs the graph node (debugging).
73
+ */
74
+ abstract log(): void;
75
+ /**
76
+ * Destroys the graph node.
77
+ */
78
+ abstract destroy(): void;
79
+ /**
80
+ * Exports the graph node.
81
+ * @returns Exported data.
82
+ */
83
+ abstract export(): any;
84
+ /**
85
+ * Accepts a visitor for traversal (e.g., debugging/exporters).
86
+ * @param visitor The visitor.
87
+ * @note Non-runtime use; pairs with iterator for data extraction.
88
+ */
89
+ abstract accept(visitor: GraphVisitor): void;
90
+ /**
91
+ * Gets an iterator for graph traversal (e.g., BFS/DFS).
92
+ * @returns Iterator.
93
+ * @note For debugging/exporters.
94
+ */
95
+ abstract getIterator(): Iterator;
96
+ }
97
+
98
+ declare class GraphNodeIterator implements Iterator {
99
+ currentNode: GraphNode | undefined;
100
+ currentLayer: GraphNode[];
101
+ nextLayer: GraphNode[];
102
+ index: number;
103
+ constructor(node: GraphNode);
104
+ hasNext(): boolean;
105
+ next(): any;
106
+ }
107
+
108
+ declare abstract class SignalEmitter {
109
+ protected silent: boolean;
110
+ /**
111
+ * Constructor for signal emitters.
112
+ * @param silent If true, suppresses all emissions (e.g., for meta-runners to avoid loops; affects all emits).
113
+ */
114
+ constructor(silent?: boolean);
115
+ /**
116
+ * Emits a signal via the broker if not silent.
117
+ * @param signal The signal name.
118
+ * @param data Optional payload (defaults to empty object).
119
+ * @edge No emission if silent; for metrics in silent mode, consider override or separate method.
120
+ */
121
+ emit(signal: string, data?: any): void;
122
+ /**
123
+ * Emits a signal via the broker even if silent.
124
+ * @param signal The signal name.
125
+ * @param data Optional payload (defaults to empty object).
126
+ */
127
+ emitMetric(signal: string, data?: any): void;
128
+ }
129
+
130
+ declare abstract class ExecutionChain {
131
+ protected next: ExecutionChain | undefined;
132
+ protected previous: ExecutionChain | undefined;
133
+ setNext(next: ExecutionChain): void;
134
+ get hasNext(): boolean;
135
+ get hasPreceding(): boolean;
136
+ getNext(): ExecutionChain | undefined;
137
+ getPreceding(): ExecutionChain | undefined;
138
+ decouple(): void;
139
+ }
140
+
141
+ declare class GraphLayerIterator implements Iterator {
142
+ graph: GraphLayer;
143
+ currentLayer: GraphLayer | undefined;
144
+ constructor(graph: GraphLayer);
145
+ hasNext(): boolean;
146
+ hasPrevious(): boolean;
147
+ next(): GraphLayer;
148
+ previous(): GraphLayer;
149
+ getFirst(): GraphLayer;
150
+ getLast(): GraphLayer;
151
+ }
152
+
153
+ declare abstract class GraphLayer extends ExecutionChain implements Graph {
154
+ protected readonly index: number;
155
+ protected nodes: GraphNode[];
156
+ private executionTime;
157
+ private executionStart;
158
+ constructor(index: number);
159
+ abstract execute(context?: GraphContext): unknown;
160
+ get hasPreceding(): boolean;
161
+ getNumberOfNodes(): number;
162
+ getNodesByRoutineExecId(routineExecId: string): GraphNode[];
163
+ isProcessed(): boolean;
164
+ graphDone(): boolean;
165
+ setNext(next: GraphLayer): void;
166
+ add(node: GraphNode): void;
167
+ start(): number;
168
+ end(): number;
169
+ destroy(): void;
170
+ getIterator(): GraphLayerIterator;
171
+ accept(visitor: GraphVisitor): void;
172
+ export(): {
173
+ __index: number;
174
+ __executionTime: number;
175
+ __numberOfNodes: number;
176
+ __hasNextLayer: boolean;
177
+ __hasPrecedingLayer: boolean;
178
+ __nodes: string[];
179
+ };
180
+ log(): void;
181
+ }
182
+
183
+ declare class GraphNode extends SignalEmitter implements Graph {
184
+ id: string;
185
+ routineExecId: string;
186
+ private task;
187
+ private context;
188
+ private layer;
189
+ private divided;
190
+ private splitGroupId;
191
+ private processing;
192
+ private subgraphComplete;
193
+ private graphComplete;
194
+ private result;
195
+ private previousNodes;
196
+ private nextNodes;
197
+ private executionTime;
198
+ private executionStart;
199
+ private failed;
200
+ private errored;
201
+ destroyed: boolean;
202
+ constructor(task: Task, context: GraphContext, routineExecId: string, prevNodes?: GraphNode[]);
203
+ isUnique(): boolean;
204
+ isMeta(): boolean;
205
+ isProcessed(): boolean;
206
+ isProcessing(): boolean;
207
+ subgraphDone(): boolean;
208
+ graphDone(): boolean;
209
+ isEqualTo(node: GraphNode): boolean;
210
+ isPartOfSameGraph(node: GraphNode): boolean;
211
+ sharesTaskWith(node: GraphNode): boolean;
212
+ sharesContextWith(node: GraphNode): boolean;
213
+ getLayerIndex(): number;
214
+ getConcurrency(): number;
215
+ getTag(): string;
216
+ scheduleOn(layer: GraphLayer): void;
217
+ start(): number;
218
+ end(): number;
219
+ execute(): GraphNode[] | Promise<GraphNode[]>;
220
+ private processAsync;
221
+ private work;
222
+ private onProgress;
223
+ private postProcess;
224
+ private onError;
225
+ private divide;
226
+ private generateNewNodes;
227
+ private differentiate;
228
+ private migrate;
229
+ private split;
230
+ clone(): GraphNode;
231
+ consume(node: GraphNode): void;
232
+ private changeIdentity;
233
+ private completeSubgraph;
234
+ private completeGraph;
235
+ destroy(): void;
236
+ getIterator(): GraphNodeIterator;
237
+ mapNext(callback: (node: GraphNode) => any): any[];
238
+ accept(visitor: GraphVisitor): void;
239
+ export(): {
240
+ __id: string;
241
+ __task: AnyObject;
242
+ __context: {
243
+ __id: string;
244
+ __context: AnyObject;
245
+ };
246
+ __result: unknown;
247
+ __executionTime: number;
248
+ __executionStart: number;
249
+ __executionEnd: number;
250
+ __nextNodes: string[];
251
+ __previousNodes: string[];
252
+ __routineExecId: string;
253
+ __isProcessing: boolean;
254
+ __isMeta: boolean;
255
+ __graphComplete: boolean;
256
+ __failed: boolean;
257
+ __errored: boolean;
258
+ __isUnique: boolean;
259
+ __splitGroupId: string;
260
+ __tag: string;
261
+ };
262
+ lightExport(): {
263
+ __id: string;
264
+ __task: {
265
+ __id: string;
266
+ __name: string;
267
+ };
268
+ __context: {
269
+ __id: string;
270
+ __context: AnyObject;
271
+ };
272
+ __executionTime: number;
273
+ __executionStart: number;
274
+ __nextNodes: string[];
275
+ __previousNodes: string[];
276
+ __routineExecId: string;
277
+ __isProcessing: boolean;
278
+ __graphComplete: boolean;
279
+ __isMeta: boolean;
280
+ __failed: boolean;
281
+ __errored: boolean;
282
+ __isUnique: boolean;
283
+ __splitGroupId: string;
284
+ __tag: string;
285
+ };
286
+ log(): void;
287
+ }
288
+
289
+ declare abstract class GraphVisitor {
290
+ abstract visitLayer(layer: GraphLayer): any;
291
+ abstract visitNode(node: GraphNode): any;
292
+ abstract visitTask(task: Task): any;
293
+ }
294
+
295
+ declare class TaskIterator implements Iterator {
296
+ private currentTask;
297
+ private currentLayer;
298
+ private nextLayer;
299
+ private iterator;
300
+ constructor(task: Task);
301
+ hasNext(): boolean;
302
+ next(): Task | undefined;
303
+ }
304
+
305
+ declare class SignalParticipant extends SignalEmitter {
306
+ protected signalsToEmit: Set<string>;
307
+ protected signalsToEmitOnFail: Set<string>;
308
+ protected observedSignals: Set<string>;
309
+ /**
310
+ * Subscribes to signals (chainable).
311
+ * @param signals The signal names.
312
+ * @returns This for chaining.
313
+ * @edge Duplicates ignored; assumes broker.observe binds this as handler.
314
+ */
315
+ doOn(...signals: string[]): this;
316
+ /**
317
+ * Sets signals to emit post-execution (chainable).
318
+ * @param signals The signal names.
319
+ * @returns This for chaining.
320
+ */
321
+ emits(...signals: string[]): this;
322
+ emitsOnFail(...signals: string[]): this;
323
+ /**
324
+ * Unsubscribes from all observed signals.
325
+ * @returns This for chaining.
326
+ */
327
+ unsubscribeAll(): this;
328
+ /**
329
+ * Unsubscribes from specific signals.
330
+ * @param signals The signals.
331
+ * @returns This for chaining.
332
+ * @edge No-op if not subscribed.
333
+ */
334
+ unsubscribe(...signals: string[]): this;
335
+ /**
336
+ * Detaches specific emitted signals.
337
+ * @param signals The signals.
338
+ * @returns This for chaining.
339
+ */
340
+ detachSignals(...signals: string[]): this;
341
+ /**
342
+ * Detaches all emitted signals.
343
+ * @returns This for chaining.
344
+ */
345
+ detachAllSignals(): this;
346
+ /**
347
+ * Emits attached signals.
348
+ * @param context The context for emission.
349
+ * @edge If isMeta (from Task), suppresses further "meta.*" to prevent loops.
350
+ */
351
+ emitSignals(context: GraphContext): void;
352
+ /**
353
+ * Emits attached fail signals.
354
+ * @param context The context for emission.
355
+ * @edge If isMeta (from Task), suppresses further "meta.*" to prevent loops.
356
+ */
357
+ emitOnFailSignals(context: GraphContext): void;
358
+ /**
359
+ * Destroys the participant (unsub/detach).
360
+ */
361
+ destroy(): void;
362
+ }
363
+
364
+ type TaskFunction = (context: AnyObject, progressCallback: (progress: number) => void) => TaskResult;
365
+ type TaskResult = boolean | object | Generator | Promise<any> | void;
366
+ declare class Task extends SignalParticipant implements Graph {
367
+ id: string;
368
+ readonly name: string;
369
+ readonly description: string;
370
+ concurrency: number;
371
+ timeout: number;
372
+ readonly isUnique: boolean;
373
+ readonly throttled: boolean;
374
+ readonly isSignal: boolean;
375
+ readonly isMeta: boolean;
376
+ readonly isDeputy: boolean;
377
+ readonly isEphemeral: boolean;
378
+ layerIndex: number;
379
+ progressWeight: number;
380
+ private nextTasks;
381
+ private onFailTasks;
382
+ private predecessorTasks;
383
+ destroyed: boolean;
384
+ protected readonly taskFunction: TaskFunction;
385
+ /**
386
+ * Constructs a Task (static definition).
387
+ * @param name Name.
388
+ * @param task Function.
389
+ * @param description Description.
390
+ * @param concurrency Limit.
391
+ * @param timeout ms.
392
+ * @param register Register via signal (default true).
393
+ * @edge Emits 'meta.task.created' with { __task: this } for seed.
394
+ */
395
+ constructor(name: string, task: TaskFunction, description?: string, concurrency?: number, timeout?: number, register?: boolean);
396
+ getTag(context?: AnyObject): string;
397
+ setGlobalId(id: string): void;
398
+ setTimeout(timeout: number): void;
399
+ setConcurrency(concurrency: number): void;
400
+ setProgressWeight(weight: number): void;
401
+ execute(context: GraphContext, progressCallback: (progress: number) => void): TaskResult;
402
+ doAfter(...tasks: Task[]): this;
403
+ then(...tasks: Task[]): this;
404
+ decouple(task: Task): void;
405
+ doOnFail(...tasks: Task[]): this;
406
+ private updateProgressWeights;
407
+ private getSubgraphLayers;
408
+ private updateLayerFromPredecessors;
409
+ private hasCycle;
410
+ mapNext(callback: (task: Task) => any, failed?: boolean): any[];
411
+ mapPrevious(callback: (task: Task) => any): any[];
412
+ destroy(): void;
413
+ export(): AnyObject;
414
+ getIterator(): TaskIterator;
415
+ accept(visitor: GraphVisitor): void;
416
+ log(): void;
417
+ }
418
+
419
+ declare class SyncGraphLayer extends GraphLayer {
420
+ execute(): GraphNode[];
421
+ }
422
+
423
+ declare abstract class GraphExporter {
424
+ abstract exportGraph(graph: SyncGraphLayer): any;
425
+ abstract exportStaticGraph(graph: Task[]): any;
426
+ }
427
+
428
+ declare abstract class GraphBuilder {
429
+ graph: GraphLayer | undefined;
430
+ topLayerIndex: number;
431
+ layers: GraphLayer[];
432
+ getResult(): GraphLayer;
433
+ compose(): void;
434
+ addNode(node: GraphNode): void;
435
+ protected addNodes(nodes: GraphNode[]): void;
436
+ protected addLayer(index: number): void;
437
+ protected createLayer(index: number): GraphLayer;
438
+ protected getLayer(layerIndex: number): GraphLayer;
439
+ reset(): void;
440
+ }
441
+
442
+ declare abstract class GraphRunStrategy {
443
+ protected graphBuilder: GraphBuilder;
444
+ protected runInstance?: GraphRun;
445
+ constructor();
446
+ setRunInstance(runInstance: GraphRun): void;
447
+ changeStrategy(builder: GraphBuilder): void;
448
+ protected reset(): void;
449
+ addNode(node: GraphNode): void;
450
+ updateRunInstance(): void;
451
+ abstract run(): void;
452
+ abstract export(): any;
453
+ }
454
+
455
+ interface RunJson {
456
+ __id: string;
457
+ __label: string;
458
+ __graph: any;
459
+ __data: any;
460
+ }
461
+ declare class GraphRun {
462
+ readonly id: string;
463
+ private graph;
464
+ private strategy;
465
+ private exporter;
466
+ constructor(strategy: GraphRunStrategy);
467
+ setGraph(graph: GraphLayer): void;
468
+ addNode(node: GraphNode): void;
469
+ run(): void | Promise<void>;
470
+ destroy(): void;
471
+ log(): void;
472
+ export(): RunJson;
473
+ setExporter(exporter: GraphExporter): void;
474
+ }
475
+
476
+ declare class GraphRoutine extends SignalParticipant {
477
+ id: string;
478
+ readonly name: string;
479
+ readonly description: string;
480
+ readonly isMeta: boolean;
481
+ private tasks;
482
+ constructor(name: string, tasks: Task[], description: string);
483
+ /**
484
+ * Applies callback to starting tasks.
485
+ * @param callBack The callback.
486
+ * @returns Promise if async.
487
+ */
488
+ forEachTask(callBack: (task: Task) => any): Promise<void>;
489
+ /**
490
+ * Sets global ID.
491
+ * @param id The ID.
492
+ */
493
+ setGlobalId(id: string): void;
494
+ /**
495
+ * Destroys the routine.
496
+ */
497
+ destroy(): void;
498
+ }
499
+
500
+ declare class GraphRunner extends SignalEmitter {
501
+ readonly id: string;
502
+ protected currentRun: GraphRun;
503
+ private debug;
504
+ protected isRunning: boolean;
505
+ private readonly isMeta;
506
+ protected strategy: GraphRunStrategy;
507
+ /**
508
+ * Constructs a runner.
509
+ * @param isMeta Meta flag (default false).
510
+ * @edge Creates 'Start run' meta-task chained to registry gets.
511
+ */
512
+ constructor(isMeta?: boolean);
513
+ init(): void;
514
+ /**
515
+ * Adds tasks/routines to current run.
516
+ * @param tasks Tasks/routines.
517
+ * @param context Context (defaults {}).
518
+ * @edge Flattens routines to tasks; generates routineExecId if not in context.
519
+ * @edge Emits 'meta.runner.added_tasks' with metadata.
520
+ * @edge Empty tasks warns no-op.
521
+ */
522
+ protected addTasks(tasks: Task | GraphRoutine | (Task | GraphRoutine)[], context: AnyObject): void;
523
+ /**
524
+ * Runs tasks/routines.
525
+ * @param tasks Optional tasks/routines.
526
+ * @param context Optional context.
527
+ * @returns Current/last run (Promise if async).
528
+ * @edge If running, returns current; else runs and resets.
529
+ */
530
+ run(tasks?: Task | GraphRoutine | (Task | GraphRoutine)[], context?: AnyObject): GraphRun | Promise<GraphRun>;
531
+ private runAsync;
532
+ protected reset(): GraphRun;
533
+ setDebug(value: boolean): void;
534
+ destroy(): void;
535
+ setStrategy(strategy: GraphRunStrategy): void;
536
+ private startRun;
537
+ }
538
+
539
+ declare class SignalBroker {
540
+ private static instance_;
541
+ /**
542
+ * Singleton instance for signal management.
543
+ * @returns The broker instance.
544
+ */
545
+ static get instance(): SignalBroker;
546
+ protected runner: GraphRunner | undefined;
547
+ protected metaRunner: GraphRunner | undefined;
548
+ protected signalObservers: Map<string, {
549
+ fn: (runner: GraphRunner, tasks: (Task | GraphRoutine)[], context: AnyObject) => void;
550
+ tasks: Set<Task | GraphRoutine>;
551
+ }>;
552
+ protected emitStacks: Map<string, Set<string>>;
553
+ protected constructor();
554
+ /**
555
+ * Initializes with runners.
556
+ * @param runner Standard runner for user signals.
557
+ * @param metaRunner Meta runner for 'meta.' signals (suppresses further meta-emits).
558
+ */
559
+ init(runner: GraphRunner, metaRunner: GraphRunner): void;
560
+ /**
561
+ * Observes a signal with a routine/task.
562
+ * @param signal The signal (e.g., 'domain.action', 'domain.*' for wildcards).
563
+ * @param routineOrTask The observer.
564
+ * @edge Duplicates ignored; supports wildcards for broad listening.
565
+ */
566
+ observe(signal: string, routineOrTask: Task | GraphRoutine): void;
567
+ /**
568
+ * Unsubscribes a routine/task from a signal.
569
+ * @param signal The signal.
570
+ * @param routineOrTask The observer.
571
+ * @edge Removes all instances if duplicate; deletes if empty.
572
+ */
573
+ unsubscribe(signal: string, routineOrTask: Task | GraphRoutine): void;
574
+ /**
575
+ * Emits a signal and bubbles to matching wildcards/parents (e.g., 'a.b.action' triggers 'a.b.action', 'a.b.*', 'a.*').
576
+ * @param signal The signal name.
577
+ * @param context The payload.
578
+ * @edge Fire-and-forget; guards against loops per execId (from context.__graphExecId).
579
+ * @edge For distribution, SignalTask can prefix and proxy remote.
580
+ * @throws Error on detected loop.
581
+ */
582
+ emit(signal: string, context?: AnyObject): void;
583
+ private executeListener;
584
+ private addSignal;
585
+ /**
586
+ * Lists all observed signals.
587
+ * @returns Array of signals.
588
+ */
589
+ listObservedSignals(): string[];
590
+ private getRunner;
591
+ reset(): void;
592
+ }
593
+
594
+ declare class MetaTask extends Task {
595
+ readonly isMeta: boolean;
596
+ }
597
+
598
+ declare class GraphRegistry {
599
+ private static _instance;
600
+ static get instance(): GraphRegistry;
601
+ private tasks;
602
+ private routines;
603
+ registerTask: MetaTask;
604
+ updateTaskId: MetaTask;
605
+ getTaskById: MetaTask;
606
+ getTaskByName: MetaTask;
607
+ getTasksByLayer: MetaTask;
608
+ getAllTasks: MetaTask;
609
+ doForEachTask: MetaTask;
610
+ deleteTask: MetaTask;
611
+ registerRoutine: MetaTask;
612
+ updateRoutineId: MetaTask;
613
+ getRoutineById: MetaTask;
614
+ getRoutineByName: MetaTask;
615
+ getAllRoutines: MetaTask;
616
+ doForEachRoutine: MetaTask;
617
+ deleteRoutine: MetaTask;
618
+ private constructor();
619
+ reset(): void;
620
+ }
621
+
622
+ declare class UniqueTask extends Task {
623
+ readonly isUnique: boolean;
624
+ }
625
+
626
+ declare class UniqueMetaTask extends UniqueTask {
627
+ readonly isMeta: boolean;
628
+ }
629
+
630
+ type ThrottleTagGetter = (context?: AnyObject, task?: Task) => string;
631
+ declare class ThrottledTask extends Task {
632
+ readonly throttled: boolean;
633
+ constructor(name: string, task: TaskFunction, description?: string, getTagCallback?: ThrottleTagGetter, concurrency?: number, timeout?: number, register?: boolean);
634
+ export(): {
635
+ __getTagCallback: string;
636
+ };
637
+ }
638
+
639
+ declare class ThrottledMetaTask extends ThrottledTask {
640
+ readonly isMeta: boolean;
641
+ }
642
+
643
+ interface DebounceOptions {
644
+ leading?: boolean;
645
+ trailing?: boolean;
646
+ }
647
+ declare class DebounceTask extends Task {
648
+ private readonly debounceTime;
649
+ private leading;
650
+ private trailing;
651
+ private timer;
652
+ private lastResolve;
653
+ private lastReject;
654
+ private lastContext;
655
+ private lastTimeout;
656
+ constructor(name: string, task: TaskFunction, description?: string, debounceTime?: number, leading?: boolean, trailing?: boolean, concurrency?: number, timeout?: number, register?: boolean);
657
+ private executeFunction;
658
+ private debouncedTrigger;
659
+ execute(context: GraphContext, progressCallback: (progress: number) => void): TaskResult;
660
+ }
661
+
662
+ declare class DebouncedMetaTask extends DebounceTask {
663
+ readonly isMeta: boolean;
664
+ }
665
+
666
+ declare class EphemeralTask extends Task {
667
+ private readonly once;
668
+ private readonly condition;
669
+ readonly isEphemeral: boolean;
670
+ constructor(name: string, task: TaskFunction, description?: string, once?: boolean, condition?: (context: any) => boolean, concurrency?: number, timeout?: number, register?: boolean);
671
+ execute(context: any, progressCallback: (progress: number) => void): TaskResult;
672
+ }
673
+
674
+ declare class EphemeralMetaTask extends EphemeralTask {
675
+ readonly isMeta: boolean;
676
+ }
677
+
678
+ declare class MetaRoutine extends GraphRoutine {
679
+ readonly isMeta: boolean;
680
+ }
681
+
682
+ declare class GraphAsyncRun extends GraphRunStrategy {
683
+ constructor();
684
+ run(): Promise<void>;
685
+ protected reset(): void;
686
+ export(): any;
687
+ }
688
+
689
+ declare class GraphStandardRun extends GraphRunStrategy {
690
+ run(): void;
691
+ export(): any;
692
+ }
693
+
694
+ interface TaskOptions {
695
+ concurrency?: number;
696
+ timeout?: number;
697
+ register?: boolean;
698
+ }
699
+ declare class Cadenza {
700
+ static broker: SignalBroker;
701
+ static runner: GraphRunner;
702
+ static metaRunner: GraphRunner;
703
+ static registry: GraphRegistry;
704
+ private static isBootstrapped;
705
+ private static bootstrap;
706
+ static get runStrategy(): {
707
+ PARALLEL: GraphAsyncRun;
708
+ SEQUENTIAL: GraphStandardRun;
709
+ };
710
+ /**
711
+ * Validates a name for uniqueness and non-emptiness.
712
+ * @param name The name to validate.
713
+ * @throws Error if invalid.
714
+ */
715
+ private static validateName;
716
+ /**
717
+ * Creates a standard Task and registers it in the GraphRegistry.
718
+ * @param name Unique identifier for the task.
719
+ * @param func The function or async generator to execute.
720
+ * @param description Optional human-readable description for introspection.
721
+ * @param options Optional task options.
722
+ * @returns The created Task instance.
723
+ * @throws Error if name is invalid or duplicate in registry.
724
+ */
725
+ static createTask(name: string, func: TaskFunction, description?: string, options?: TaskOptions): Task;
726
+ /**
727
+ * Creates a MetaTask (for meta-layer graphs) and registers it.
728
+ * MetaTasks suppress further meta-signal emissions to prevent loops.
729
+ * @param name Unique identifier for the meta-task.
730
+ * @param func The function or async generator to execute.
731
+ * @param description Optional description.
732
+ * @param options Optional task options.
733
+ * @returns The created MetaTask instance.
734
+ * @throws Error if name invalid or duplicate.
735
+ */
736
+ static createMetaTask(name: string, func: TaskFunction, description?: string, options?: TaskOptions): MetaTask;
737
+ /**
738
+ * Creates a UniqueTask (executes once per execution ID, merging parents) and registers it.
739
+ * Use for fan-in/joins after parallel branches.
740
+ * @param name Unique identifier.
741
+ * @param func Function receiving joinedContexts.
742
+ * @param description Optional description.
743
+ * @param options Optional task options.
744
+ * @returns The created UniqueTask.
745
+ * @throws Error if invalid.
746
+ */
747
+ static createUniqueTask(name: string, func: TaskFunction, description?: string, options?: TaskOptions): UniqueTask;
748
+ /**
749
+ * Creates a UniqueMetaTask for meta-layer joins.
750
+ * @param name Unique identifier.
751
+ * @param func Function.
752
+ * @param description Optional.
753
+ * @param options Optional task options.
754
+ * @returns The created UniqueMetaTask.
755
+ */
756
+ static createUniqueMetaTask(name: string, func: TaskFunction, description?: string, options?: TaskOptions): UniqueMetaTask;
757
+ /**
758
+ * Creates a ThrottledTask (rate-limited by concurrency or custom groups) and registers it.
759
+ * @param name Unique identifier.
760
+ * @param func Function.
761
+ * @param throttledIdGetter Optional getter for dynamic grouping (e.g., per-user).
762
+ * @param description Optional.
763
+ * @param options Optional task options.
764
+ * @returns The created ThrottledTask.
765
+ * @edge If no getter, throttles per task ID; use for resource protection.
766
+ */
767
+ static createThrottledTask(name: string, func: TaskFunction, throttledIdGetter?: ThrottleTagGetter, description?: string, options?: TaskOptions): ThrottledTask;
768
+ /**
769
+ * Creates a ThrottledMetaTask for meta-layer throttling.
770
+ * @param name Identifier.
771
+ * @param func Function.
772
+ * @param throttledIdGetter Optional getter.
773
+ * @param description Optional.
774
+ * @param options Optional task options.
775
+ * @returns The created ThrottledMetaTask.
776
+ */
777
+ static createThrottledMetaTask(name: string, func: TaskFunction, throttledIdGetter?: ThrottleTagGetter, description?: string, options?: TaskOptions): ThrottledMetaTask;
778
+ /**
779
+ * Creates a DebounceTask (delays exec until quiet period) and registers it.
780
+ * @param name Identifier.
781
+ * @param func Function.
782
+ * @param description Optional.
783
+ * @param debounceTime Delay in ms (default 1000).
784
+ * @param options Optional task options plus optional debounce config (e.g., leading/trailing).
785
+ * @returns The created DebounceTask.
786
+ * @edge Multiple triggers within time collapse to one exec.
787
+ */
788
+ static createDebounceTask(name: string, func: TaskFunction, description?: string, debounceTime?: number, options?: TaskOptions & DebounceOptions): DebounceTask;
789
+ /**
790
+ * Creates a DebouncedMetaTask for meta-layer debouncing.
791
+ * @param name Identifier.
792
+ * @param func Function.
793
+ * @param description Optional.
794
+ * @param debounceTime Delay in ms.
795
+ * @param options Optional task options plus optional debounce config (e.g., leading/trailing).
796
+ * @returns The created DebouncedMetaTask.
797
+ */
798
+ static createDebounceMetaTask(name: string, func: TaskFunction, description?: string, debounceTime?: number, options?: TaskOptions & DebounceOptions): DebouncedMetaTask;
799
+ /**
800
+ * Creates an EphemeralTask (self-destructs after exec or condition) without default registration.
801
+ * Useful for transients; optionally register if needed.
802
+ * @param name Identifier (may not be unique if not registered).
803
+ * @param func Function.
804
+ * @param description Optional.
805
+ * @param once Destroy after first exec (default true).
806
+ * @param destroyCondition Predicate for destruction (default always true).
807
+ * @param options Optional task options.
808
+ * @returns The created EphemeralTask.
809
+ * @edge Destruction triggered post-exec via Node/Builder; emits meta-signal for cleanup.
810
+ */
811
+ static createEphemeralTask(name: string, func: TaskFunction, description?: string, once?: boolean, destroyCondition?: (context: any) => boolean, options?: TaskOptions): EphemeralTask;
812
+ /**
813
+ * Creates an EphemeralMetaTask for meta-layer transients.
814
+ * @param name Identifier.
815
+ * @param func Function.
816
+ * @param description Optional.
817
+ * @param once Destroy after first (default true).
818
+ * @param destroyCondition Destruction predicate.
819
+ * @param options Optional task options.
820
+ * @returns The created EphemeralMetaTask.
821
+ */
822
+ static createEphemeralMetaTask(name: string, func: TaskFunction, description?: string, once?: boolean, destroyCondition?: (context: any) => boolean, options?: TaskOptions): EphemeralMetaTask;
823
+ /**
824
+ * Creates a GraphRoutine (named entry to starting tasks) and registers it.
825
+ * @param name Unique identifier.
826
+ * @param tasks Starting tasks (can be empty, but warns as no-op).
827
+ * @param description Optional.
828
+ * @returns The created GraphRoutine.
829
+ * @edge If tasks empty, routine is valid but inert.
830
+ */
831
+ static createRoutine(name: string, tasks: Task[], description?: string): GraphRoutine;
832
+ /**
833
+ * Creates a MetaRoutine for meta-layer entry points.
834
+ * @param name Identifier.
835
+ * @param tasks Starting tasks.
836
+ * @param description Optional.
837
+ * @returns The created MetaRoutine.
838
+ */
839
+ static createMetaRoutine(name: string, tasks: Task[], description?: string): MetaRoutine;
840
+ static reset(): void;
841
+ }
842
+
843
+ export { Cadenza as default };