agentic-qe 3.7.21 → 3.8.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.
Files changed (164) hide show
  1. package/.claude/helpers/brain-checkpoint.cjs +4 -1
  2. package/.claude/helpers/statusline-v3.cjs +3 -1
  3. package/.claude/skills/skills-manifest.json +1 -1
  4. package/CHANGELOG.md +45 -0
  5. package/README.md +2 -14
  6. package/assets/helpers/statusline-v3.cjs +3 -1
  7. package/dist/cli/brain-commands.js +6 -10
  8. package/dist/cli/bundle.js +7441 -4327
  9. package/dist/cli/commands/audit.d.ts +43 -0
  10. package/dist/cli/commands/audit.js +125 -0
  11. package/dist/cli/commands/hooks.js +29 -6
  12. package/dist/cli/commands/init.js +1 -73
  13. package/dist/cli/commands/learning.js +270 -13
  14. package/dist/cli/commands/ruvector-commands.d.ts +15 -0
  15. package/dist/cli/commands/ruvector-commands.js +271 -0
  16. package/dist/cli/handlers/init-handler.d.ts +0 -1
  17. package/dist/cli/handlers/init-handler.js +0 -6
  18. package/dist/cli/index.js +4 -2
  19. package/dist/context/sources/defect-source.js +2 -2
  20. package/dist/context/sources/memory-source.js +2 -2
  21. package/dist/context/sources/requirements-source.js +2 -2
  22. package/dist/coordination/behavior-tree/decorators.d.ts +108 -0
  23. package/dist/coordination/behavior-tree/decorators.js +251 -0
  24. package/dist/coordination/behavior-tree/index.d.ts +12 -0
  25. package/dist/coordination/behavior-tree/index.js +15 -0
  26. package/dist/coordination/behavior-tree/nodes.d.ts +165 -0
  27. package/dist/coordination/behavior-tree/nodes.js +338 -0
  28. package/dist/coordination/behavior-tree/qe-trees.d.ts +105 -0
  29. package/dist/coordination/behavior-tree/qe-trees.js +181 -0
  30. package/dist/coordination/coherence-action-gate.d.ts +284 -0
  31. package/dist/coordination/coherence-action-gate.js +512 -0
  32. package/dist/coordination/index.d.ts +4 -0
  33. package/dist/coordination/index.js +8 -0
  34. package/dist/coordination/reasoning-qec.d.ts +315 -0
  35. package/dist/coordination/reasoning-qec.js +585 -0
  36. package/dist/coordination/task-executor.d.ts +16 -0
  37. package/dist/coordination/task-executor.js +99 -0
  38. package/dist/coordination/workflow-orchestrator.d.ts +29 -0
  39. package/dist/coordination/workflow-orchestrator.js +42 -0
  40. package/dist/domains/visual-accessibility/cnn-visual-regression.d.ts +135 -0
  41. package/dist/domains/visual-accessibility/cnn-visual-regression.js +327 -0
  42. package/dist/domains/visual-accessibility/index.d.ts +1 -0
  43. package/dist/domains/visual-accessibility/index.js +4 -0
  44. package/dist/governance/coherence-validator.d.ts +112 -0
  45. package/dist/governance/coherence-validator.js +180 -0
  46. package/dist/governance/index.d.ts +1 -0
  47. package/dist/governance/index.js +2 -0
  48. package/dist/governance/witness-chain.d.ts +311 -0
  49. package/dist/governance/witness-chain.js +509 -0
  50. package/dist/init/index.d.ts +0 -2
  51. package/dist/init/index.js +0 -1
  52. package/dist/init/init-wizard-steps.d.ts +10 -0
  53. package/dist/init/init-wizard-steps.js +87 -1
  54. package/dist/init/init-wizard.d.ts +1 -9
  55. package/dist/init/init-wizard.js +3 -69
  56. package/dist/init/orchestrator.js +0 -1
  57. package/dist/init/phases/01-detection.js +0 -27
  58. package/dist/init/phases/07-hooks.js +6 -4
  59. package/dist/init/phases/phase-interface.d.ts +0 -1
  60. package/dist/init/settings-merge.js +1 -1
  61. package/dist/integrations/browser/qe-dashboard/clustering.d.ts +48 -0
  62. package/dist/integrations/browser/qe-dashboard/clustering.js +183 -0
  63. package/dist/integrations/browser/qe-dashboard/index.d.ts +12 -0
  64. package/dist/integrations/browser/qe-dashboard/index.js +15 -0
  65. package/dist/integrations/browser/qe-dashboard/pattern-explorer.d.ts +165 -0
  66. package/dist/integrations/browser/qe-dashboard/pattern-explorer.js +260 -0
  67. package/dist/integrations/browser/qe-dashboard/wasm-vector-store.d.ts +144 -0
  68. package/dist/integrations/browser/qe-dashboard/wasm-vector-store.js +277 -0
  69. package/dist/integrations/ruvector/cognitive-container-codec.d.ts +51 -0
  70. package/dist/integrations/ruvector/cognitive-container-codec.js +180 -0
  71. package/dist/integrations/ruvector/cognitive-container.d.ts +125 -0
  72. package/dist/integrations/ruvector/cognitive-container.js +306 -0
  73. package/dist/integrations/ruvector/coherence-gate.d.ts +309 -0
  74. package/dist/integrations/ruvector/coherence-gate.js +631 -0
  75. package/dist/integrations/ruvector/compressed-hnsw-integration.d.ts +176 -0
  76. package/dist/integrations/ruvector/compressed-hnsw-integration.js +301 -0
  77. package/dist/integrations/ruvector/dither-adapter.d.ts +122 -0
  78. package/dist/integrations/ruvector/dither-adapter.js +295 -0
  79. package/dist/integrations/ruvector/domain-transfer.d.ts +129 -0
  80. package/dist/integrations/ruvector/domain-transfer.js +220 -0
  81. package/dist/integrations/ruvector/feature-flags.d.ts +214 -2
  82. package/dist/integrations/ruvector/feature-flags.js +167 -2
  83. package/dist/integrations/ruvector/filter-adapter.d.ts +71 -0
  84. package/dist/integrations/ruvector/filter-adapter.js +285 -0
  85. package/dist/integrations/ruvector/gnn-wrapper.d.ts +20 -0
  86. package/dist/integrations/ruvector/gnn-wrapper.js +40 -0
  87. package/dist/integrations/ruvector/hnsw-health-monitor.d.ts +237 -0
  88. package/dist/integrations/ruvector/hnsw-health-monitor.js +394 -0
  89. package/dist/integrations/ruvector/index.d.ts +8 -2
  90. package/dist/integrations/ruvector/index.js +18 -2
  91. package/dist/integrations/ruvector/interfaces.d.ts +40 -0
  92. package/dist/integrations/ruvector/sona-persistence.d.ts +54 -0
  93. package/dist/integrations/ruvector/sona-persistence.js +162 -0
  94. package/dist/integrations/ruvector/sona-three-loop.d.ts +392 -0
  95. package/dist/integrations/ruvector/sona-three-loop.js +814 -0
  96. package/dist/integrations/ruvector/sona-wrapper.d.ts +97 -0
  97. package/dist/integrations/ruvector/sona-wrapper.js +147 -3
  98. package/dist/integrations/ruvector/spectral-math.d.ts +101 -0
  99. package/dist/integrations/ruvector/spectral-math.js +254 -0
  100. package/dist/integrations/ruvector/temporal-compression.d.ts +163 -0
  101. package/dist/integrations/ruvector/temporal-compression.js +318 -0
  102. package/dist/integrations/ruvector/thompson-sampler.d.ts +61 -0
  103. package/dist/integrations/ruvector/thompson-sampler.js +118 -0
  104. package/dist/integrations/ruvector/transfer-coherence-stub.d.ts +80 -0
  105. package/dist/integrations/ruvector/transfer-coherence-stub.js +63 -0
  106. package/dist/integrations/ruvector/transfer-verification.d.ts +119 -0
  107. package/dist/integrations/ruvector/transfer-verification.js +115 -0
  108. package/dist/kernel/hnsw-adapter.d.ts +52 -1
  109. package/dist/kernel/hnsw-adapter.js +139 -4
  110. package/dist/kernel/hnsw-index-provider.d.ts +5 -0
  111. package/dist/kernel/native-hnsw-backend.d.ts +110 -0
  112. package/dist/kernel/native-hnsw-backend.js +408 -0
  113. package/dist/kernel/unified-memory.js +5 -6
  114. package/dist/learning/aqe-learning-engine.d.ts +2 -0
  115. package/dist/learning/aqe-learning-engine.js +65 -0
  116. package/dist/learning/experience-capture-middleware.js +20 -0
  117. package/dist/learning/experience-capture.d.ts +10 -0
  118. package/dist/learning/experience-capture.js +34 -0
  119. package/dist/learning/index.d.ts +2 -2
  120. package/dist/learning/index.js +4 -4
  121. package/dist/learning/metrics-tracker.d.ts +11 -0
  122. package/dist/learning/metrics-tracker.js +29 -13
  123. package/dist/learning/pattern-lifecycle.d.ts +30 -1
  124. package/dist/learning/pattern-lifecycle.js +92 -20
  125. package/dist/learning/pattern-store.d.ts +8 -0
  126. package/dist/learning/pattern-store.js +8 -2
  127. package/dist/learning/qe-unified-memory.js +1 -28
  128. package/dist/learning/regret-tracker.d.ts +201 -0
  129. package/dist/learning/regret-tracker.js +361 -0
  130. package/dist/mcp/bundle.js +5915 -474
  131. package/dist/routing/index.d.ts +4 -2
  132. package/dist/routing/index.js +3 -1
  133. package/dist/routing/neural-tiny-dancer-router.d.ts +268 -0
  134. package/dist/routing/neural-tiny-dancer-router.js +514 -0
  135. package/dist/routing/queen-integration.js +5 -5
  136. package/dist/routing/routing-config.d.ts +6 -0
  137. package/dist/routing/routing-config.js +1 -0
  138. package/dist/routing/simple-neural-router.d.ts +76 -0
  139. package/dist/routing/simple-neural-router.js +202 -0
  140. package/dist/routing/tiny-dancer-router.d.ts +20 -1
  141. package/dist/routing/tiny-dancer-router.js +21 -2
  142. package/dist/test-scheduling/dag-attention-scheduler.d.ts +81 -0
  143. package/dist/test-scheduling/dag-attention-scheduler.js +358 -0
  144. package/dist/test-scheduling/dag-attention-types.d.ts +81 -0
  145. package/dist/test-scheduling/dag-attention-types.js +10 -0
  146. package/dist/test-scheduling/index.d.ts +1 -0
  147. package/dist/test-scheduling/index.js +4 -0
  148. package/dist/test-scheduling/pipeline.d.ts +8 -0
  149. package/dist/test-scheduling/pipeline.js +28 -0
  150. package/package.json +6 -2
  151. package/dist/cli/commands/migrate.d.ts +0 -9
  152. package/dist/cli/commands/migrate.js +0 -566
  153. package/dist/init/init-wizard-migration.d.ts +0 -52
  154. package/dist/init/init-wizard-migration.js +0 -345
  155. package/dist/init/migration/config-migrator.d.ts +0 -31
  156. package/dist/init/migration/config-migrator.js +0 -149
  157. package/dist/init/migration/data-migrator.d.ts +0 -72
  158. package/dist/init/migration/data-migrator.js +0 -232
  159. package/dist/init/migration/detector.d.ts +0 -44
  160. package/dist/init/migration/detector.js +0 -105
  161. package/dist/init/migration/index.d.ts +0 -8
  162. package/dist/init/migration/index.js +0 -8
  163. package/dist/learning/v2-to-v3-migration.d.ts +0 -86
  164. package/dist/learning/v2-to-v3-migration.js +0 -529
package/dist/cli/index.js CHANGED
@@ -790,7 +790,6 @@ import { createCoverageCommand } from './commands/coverage.js';
790
790
  import { createQualityCommand } from './commands/quality.js';
791
791
  import { createSecurityCommand } from './commands/security.js';
792
792
  import { createCodeCommand } from './commands/code.js';
793
- import { createMigrateCommand } from './commands/migrate.js';
794
793
  import { createCompletionsCommand } from './commands/completions.js';
795
794
  import { createFleetCommand } from './commands/fleet.js';
796
795
  import { createValidateSwarmCommand } from './commands/validate-swarm.js';
@@ -803,7 +802,6 @@ program.addCommand(createCoverageCommand(context, cleanupAndExit, ensureInitiali
803
802
  program.addCommand(createQualityCommand(context, cleanupAndExit, ensureInitialized));
804
803
  program.addCommand(createSecurityCommand(context, cleanupAndExit, ensureInitialized));
805
804
  program.addCommand(createCodeCommand(context, cleanupAndExit, ensureInitialized));
806
- program.addCommand(createMigrateCommand(context, cleanupAndExit, ensureInitialized));
807
805
  program.addCommand(createCompletionsCommand(cleanupAndExit));
808
806
  program.addCommand(createFleetCommand(context, cleanupAndExit, ensureInitialized, registerDomainWorkflowActions));
809
807
  program.addCommand(createValidateSwarmCommand(context, cleanupAndExit, ensureInitialized));
@@ -821,6 +819,8 @@ import { createLearningCommand } from './commands/learning.js';
821
819
  import { createMcpCommand } from './commands/mcp.js';
822
820
  import { createPlatformCommand } from './commands/platform.js';
823
821
  import { createProveCommand } from './commands/prove.js';
822
+ import { createRuVectorCommand } from './commands/ruvector-commands.js';
823
+ import { createAuditCommand } from './commands/audit.js';
824
824
  program.addCommand(createTokenUsageCommand());
825
825
  program.addCommand(createLLMRouterCommand());
826
826
  program.addCommand(createSyncCommands());
@@ -829,6 +829,8 @@ program.addCommand(createLearningCommand());
829
829
  program.addCommand(createMcpCommand());
830
830
  program.addCommand(createPlatformCommand());
831
831
  program.addCommand(createProveCommand(context, cleanupAndExit, ensureInitialized));
832
+ program.addCommand(createRuVectorCommand());
833
+ program.addCommand(createAuditCommand(context, cleanupAndExit, ensureInitialized));
832
834
  // ============================================================================
833
835
  // Shutdown Handlers
834
836
  // ============================================================================
@@ -19,8 +19,8 @@ export class DefectContextSource {
19
19
  if (!existsSync(dbPath)) {
20
20
  return [];
21
21
  }
22
- const Database = (await import('better-sqlite3')).default;
23
- const db = new Database(dbPath, { readonly: true });
22
+ const { openDatabase } = await import('../../shared/safe-db.js');
23
+ const db = openDatabase(dbPath, { readonly: true });
24
24
  try {
25
25
  // Check if patterns table exists
26
26
  const tableCheck = db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='qe_patterns'").get();
@@ -20,8 +20,8 @@ export class MemoryContextSource {
20
20
  return this.fallbackGather(request);
21
21
  }
22
22
  // Dynamic import to avoid hard dependency
23
- const Database = (await import('better-sqlite3')).default;
24
- const db = new Database(dbPath, { readonly: true });
23
+ const { openDatabase } = await import('../../shared/safe-db.js');
24
+ const db = openDatabase(dbPath, { readonly: true });
25
25
  try {
26
26
  // Query patterns relevant to the task domain
27
27
  const domainKeywords = this.extractDomainKeywords(request.taskDescription);
@@ -18,8 +18,8 @@ export class RequirementsContextSource {
18
18
  if (!existsSync(dbPath)) {
19
19
  return this.fallbackGather(request);
20
20
  }
21
- const Database = (await import('better-sqlite3')).default;
22
- const db = new Database(dbPath, { readonly: true });
21
+ const { openDatabase } = await import('../../shared/safe-db.js');
22
+ const db = openDatabase(dbPath, { readonly: true });
23
23
  try {
24
24
  // Check if requirements table exists
25
25
  const tableCheck = db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='qe_patterns'").get();
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Behavior Tree Decorators
3
+ *
4
+ * Decorators wrap a single child node and modify its behavior.
5
+ * They act as middleware between the parent and child nodes.
6
+ *
7
+ * Decorator types:
8
+ * - Inverter: Flips SUCCESS/FAILURE
9
+ * - Repeat: Repeats child n times
10
+ * - UntilFail: Repeats child until it fails
11
+ * - Timeout: Fails if child takes too long
12
+ * - Retry: Retries child on failure up to n times
13
+ */
14
+ import type { BehaviorNode, NodeStatus, SerializedNode } from './nodes.js';
15
+ declare abstract class DecoratorNode implements BehaviorNode {
16
+ readonly name: string;
17
+ protected readonly child: BehaviorNode;
18
+ abstract readonly type: string;
19
+ constructor(name: string, child: BehaviorNode);
20
+ abstract tick(): Promise<NodeStatus>;
21
+ reset(): void;
22
+ serialize(): SerializedNode;
23
+ }
24
+ /**
25
+ * Inverter decorator - flips SUCCESS to FAILURE and vice versa.
26
+ *
27
+ * RUNNING is passed through unchanged.
28
+ * Useful for negating conditions (e.g., "if NOT ready, then ...").
29
+ */
30
+ export declare class InverterNode extends DecoratorNode {
31
+ readonly type = "Inverter";
32
+ constructor(name: string, child: BehaviorNode);
33
+ tick(): Promise<NodeStatus>;
34
+ }
35
+ /**
36
+ * Repeat decorator - repeats the child node n times.
37
+ *
38
+ * - Returns FAILURE immediately if child fails on any iteration
39
+ * - Returns RUNNING if child returns RUNNING
40
+ * - Returns SUCCESS after n successful completions
41
+ */
42
+ export declare class RepeatNode extends DecoratorNode {
43
+ readonly type = "Repeat";
44
+ private readonly count;
45
+ private currentIteration;
46
+ constructor(name: string, child: BehaviorNode, count: number);
47
+ tick(): Promise<NodeStatus>;
48
+ reset(): void;
49
+ serialize(): SerializedNode;
50
+ }
51
+ /**
52
+ * UntilFail decorator - repeats the child until it fails.
53
+ *
54
+ * - Returns RUNNING as long as child succeeds (will repeat on next tick)
55
+ * - Returns SUCCESS when child finally fails
56
+ * - Passes through RUNNING from child
57
+ *
58
+ * Note: When used with a single tick() call, this runs the child
59
+ * repeatedly in a loop until failure. Safeguard with a Timeout decorator
60
+ * to prevent infinite loops.
61
+ */
62
+ export declare class UntilFailNode extends DecoratorNode {
63
+ readonly type = "UntilFail";
64
+ constructor(name: string, child: BehaviorNode);
65
+ tick(): Promise<NodeStatus>;
66
+ }
67
+ /**
68
+ * Timeout decorator - fails if child takes too long.
69
+ *
70
+ * - Wraps the child's tick with a timeout
71
+ * - Returns FAILURE if the timeout is exceeded
72
+ * - Otherwise passes through the child's result
73
+ */
74
+ export declare class TimeoutNode extends DecoratorNode {
75
+ readonly type = "Timeout";
76
+ private readonly timeoutMs;
77
+ constructor(name: string, child: BehaviorNode, timeoutMs: number);
78
+ tick(): Promise<NodeStatus>;
79
+ serialize(): SerializedNode;
80
+ }
81
+ /**
82
+ * Retry decorator - retries the child on failure up to n times.
83
+ *
84
+ * - Returns SUCCESS immediately on child success
85
+ * - Returns RUNNING if child is running
86
+ * - On FAILURE, retries up to maxRetries times before returning FAILURE
87
+ */
88
+ export declare class RetryNode extends DecoratorNode {
89
+ readonly type = "Retry";
90
+ private readonly maxRetries;
91
+ private currentRetry;
92
+ constructor(name: string, child: BehaviorNode, maxRetries: number);
93
+ tick(): Promise<NodeStatus>;
94
+ reset(): void;
95
+ serialize(): SerializedNode;
96
+ }
97
+ /** Create an Inverter decorator */
98
+ export declare function inverter(name: string, child: BehaviorNode): InverterNode;
99
+ /** Create a Repeat decorator */
100
+ export declare function repeat(name: string, child: BehaviorNode, count: number): RepeatNode;
101
+ /** Create an UntilFail decorator */
102
+ export declare function untilFail(name: string, child: BehaviorNode): UntilFailNode;
103
+ /** Create a Timeout decorator */
104
+ export declare function timeout(name: string, child: BehaviorNode, timeoutMs: number): TimeoutNode;
105
+ /** Create a Retry decorator */
106
+ export declare function retry(name: string, child: BehaviorNode, maxRetries: number): RetryNode;
107
+ export {};
108
+ //# sourceMappingURL=decorators.d.ts.map
@@ -0,0 +1,251 @@
1
+ /**
2
+ * Behavior Tree Decorators
3
+ *
4
+ * Decorators wrap a single child node and modify its behavior.
5
+ * They act as middleware between the parent and child nodes.
6
+ *
7
+ * Decorator types:
8
+ * - Inverter: Flips SUCCESS/FAILURE
9
+ * - Repeat: Repeats child n times
10
+ * - UntilFail: Repeats child until it fails
11
+ * - Timeout: Fails if child takes too long
12
+ * - Retry: Retries child on failure up to n times
13
+ */
14
+ import { registerDecoratorFactory } from './nodes.js';
15
+ // ============================================================================
16
+ // Abstract Decorator Base
17
+ // ============================================================================
18
+ class DecoratorNode {
19
+ name;
20
+ child;
21
+ constructor(name, child) {
22
+ this.name = name;
23
+ this.child = child;
24
+ }
25
+ reset() {
26
+ this.child.reset();
27
+ }
28
+ serialize() {
29
+ return {
30
+ type: this.type,
31
+ name: this.name,
32
+ children: [this.child.serialize()],
33
+ };
34
+ }
35
+ }
36
+ // ============================================================================
37
+ // Decorators
38
+ // ============================================================================
39
+ /**
40
+ * Inverter decorator - flips SUCCESS to FAILURE and vice versa.
41
+ *
42
+ * RUNNING is passed through unchanged.
43
+ * Useful for negating conditions (e.g., "if NOT ready, then ...").
44
+ */
45
+ export class InverterNode extends DecoratorNode {
46
+ type = 'Inverter';
47
+ constructor(name, child) {
48
+ super(name, child);
49
+ }
50
+ async tick() {
51
+ const status = await this.child.tick();
52
+ if (status === 'SUCCESS')
53
+ return 'FAILURE';
54
+ if (status === 'FAILURE')
55
+ return 'SUCCESS';
56
+ return 'RUNNING';
57
+ }
58
+ }
59
+ /**
60
+ * Repeat decorator - repeats the child node n times.
61
+ *
62
+ * - Returns FAILURE immediately if child fails on any iteration
63
+ * - Returns RUNNING if child returns RUNNING
64
+ * - Returns SUCCESS after n successful completions
65
+ */
66
+ export class RepeatNode extends DecoratorNode {
67
+ type = 'Repeat';
68
+ count;
69
+ currentIteration = 0;
70
+ constructor(name, child, count) {
71
+ super(name, child);
72
+ this.count = Math.max(1, Math.floor(count));
73
+ }
74
+ async tick() {
75
+ while (this.currentIteration < this.count) {
76
+ const status = await this.child.tick();
77
+ if (status === 'FAILURE') {
78
+ return 'FAILURE';
79
+ }
80
+ if (status === 'RUNNING') {
81
+ return 'RUNNING';
82
+ }
83
+ // SUCCESS - increment and reset child for next iteration
84
+ this.currentIteration++;
85
+ if (this.currentIteration < this.count) {
86
+ this.child.reset();
87
+ }
88
+ }
89
+ return 'SUCCESS';
90
+ }
91
+ reset() {
92
+ this.currentIteration = 0;
93
+ super.reset();
94
+ }
95
+ serialize() {
96
+ return {
97
+ type: this.type,
98
+ name: this.name,
99
+ children: [this.child.serialize()],
100
+ config: { count: this.count },
101
+ };
102
+ }
103
+ }
104
+ /**
105
+ * UntilFail decorator - repeats the child until it fails.
106
+ *
107
+ * - Returns RUNNING as long as child succeeds (will repeat on next tick)
108
+ * - Returns SUCCESS when child finally fails
109
+ * - Passes through RUNNING from child
110
+ *
111
+ * Note: When used with a single tick() call, this runs the child
112
+ * repeatedly in a loop until failure. Safeguard with a Timeout decorator
113
+ * to prevent infinite loops.
114
+ */
115
+ export class UntilFailNode extends DecoratorNode {
116
+ type = 'UntilFail';
117
+ constructor(name, child) {
118
+ super(name, child);
119
+ }
120
+ async tick() {
121
+ const status = await this.child.tick();
122
+ if (status === 'FAILURE') {
123
+ return 'SUCCESS';
124
+ }
125
+ if (status === 'RUNNING') {
126
+ return 'RUNNING';
127
+ }
128
+ // SUCCESS - reset and signal RUNNING so caller ticks again
129
+ this.child.reset();
130
+ return 'RUNNING';
131
+ }
132
+ }
133
+ /**
134
+ * Timeout decorator - fails if child takes too long.
135
+ *
136
+ * - Wraps the child's tick with a timeout
137
+ * - Returns FAILURE if the timeout is exceeded
138
+ * - Otherwise passes through the child's result
139
+ */
140
+ export class TimeoutNode extends DecoratorNode {
141
+ type = 'Timeout';
142
+ timeoutMs;
143
+ constructor(name, child, timeoutMs) {
144
+ super(name, child);
145
+ this.timeoutMs = Math.max(1, timeoutMs);
146
+ }
147
+ async tick() {
148
+ const timeoutPromise = new Promise((resolve) => {
149
+ setTimeout(() => resolve('FAILURE'), this.timeoutMs);
150
+ });
151
+ const childPromise = this.child.tick();
152
+ return Promise.race([childPromise, timeoutPromise]);
153
+ }
154
+ serialize() {
155
+ return {
156
+ type: this.type,
157
+ name: this.name,
158
+ children: [this.child.serialize()],
159
+ config: { timeoutMs: this.timeoutMs },
160
+ };
161
+ }
162
+ }
163
+ /**
164
+ * Retry decorator - retries the child on failure up to n times.
165
+ *
166
+ * - Returns SUCCESS immediately on child success
167
+ * - Returns RUNNING if child is running
168
+ * - On FAILURE, retries up to maxRetries times before returning FAILURE
169
+ */
170
+ export class RetryNode extends DecoratorNode {
171
+ type = 'Retry';
172
+ maxRetries;
173
+ currentRetry = 0;
174
+ constructor(name, child, maxRetries) {
175
+ super(name, child);
176
+ this.maxRetries = Math.max(0, Math.floor(maxRetries));
177
+ }
178
+ async tick() {
179
+ const status = await this.child.tick();
180
+ if (status === 'SUCCESS') {
181
+ return 'SUCCESS';
182
+ }
183
+ if (status === 'RUNNING') {
184
+ return 'RUNNING';
185
+ }
186
+ // FAILURE - check if we can retry
187
+ if (this.currentRetry < this.maxRetries) {
188
+ this.currentRetry++;
189
+ this.child.reset();
190
+ return this.tick();
191
+ }
192
+ return 'FAILURE';
193
+ }
194
+ reset() {
195
+ this.currentRetry = 0;
196
+ super.reset();
197
+ }
198
+ serialize() {
199
+ return {
200
+ type: this.type,
201
+ name: this.name,
202
+ children: [this.child.serialize()],
203
+ config: { maxRetries: this.maxRetries },
204
+ };
205
+ }
206
+ }
207
+ // ============================================================================
208
+ // Factory Helpers
209
+ // ============================================================================
210
+ /** Create an Inverter decorator */
211
+ export function inverter(name, child) {
212
+ return new InverterNode(name, child);
213
+ }
214
+ /** Create a Repeat decorator */
215
+ export function repeat(name, child, count) {
216
+ return new RepeatNode(name, child, count);
217
+ }
218
+ /** Create an UntilFail decorator */
219
+ export function untilFail(name, child) {
220
+ return new UntilFailNode(name, child);
221
+ }
222
+ /** Create a Timeout decorator */
223
+ export function timeout(name, child, timeoutMs) {
224
+ return new TimeoutNode(name, child, timeoutMs);
225
+ }
226
+ /** Create a Retry decorator */
227
+ export function retry(name, child, maxRetries) {
228
+ return new RetryNode(name, child, maxRetries);
229
+ }
230
+ // ============================================================================
231
+ // Self-Registration for Deserialization
232
+ // ============================================================================
233
+ registerDecoratorFactory('Inverter', (name, child) => {
234
+ return new InverterNode(name, child);
235
+ });
236
+ registerDecoratorFactory('Repeat', (name, child, config) => {
237
+ const count = config.count ?? 1;
238
+ return new RepeatNode(name, child, count);
239
+ });
240
+ registerDecoratorFactory('UntilFail', (name, child) => {
241
+ return new UntilFailNode(name, child);
242
+ });
243
+ registerDecoratorFactory('Timeout', (name, child, config) => {
244
+ const timeoutMs = config.timeoutMs ?? 30000;
245
+ return new TimeoutNode(name, child, timeoutMs);
246
+ });
247
+ registerDecoratorFactory('Retry', (name, child, config) => {
248
+ const maxRetries = config.maxRetries ?? 1;
249
+ return new RetryNode(name, child, maxRetries);
250
+ });
251
+ //# sourceMappingURL=decorators.js.map
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Behavior Tree Orchestration
3
+ *
4
+ * Composable behavior trees for agent orchestration.
5
+ * Provides core nodes, decorators, and pre-built QE workflow trees.
6
+ */
7
+ export type { NodeStatus, SerializedNode, BehaviorNode, ActionFunction, ConditionPredicate, ParallelConfig, NodeHandlerRegistry, } from './nodes.js';
8
+ export { SequenceNode, SelectorNode, ParallelNode, ActionNode, ConditionNode, deserializeNode, registerDecoratorFactory, sequence, selector, parallel, action, condition, } from './nodes.js';
9
+ export { InverterNode, RepeatNode, UntilFailNode, TimeoutNode, RetryNode, inverter, repeat, untilFail, timeout, retry, } from './decorators.js';
10
+ export type { QETreeHandlers } from './qe-trees.js';
11
+ export { QEActionIds, QEConditionIds, buildTestGenerationPipeline, buildRegressionSuite, buildSecurityAudit, createQEHandlerRegistry, serializeQETree, deserializeQETree, } from './qe-trees.js';
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Behavior Tree Orchestration
3
+ *
4
+ * Composable behavior trees for agent orchestration.
5
+ * Provides core nodes, decorators, and pre-built QE workflow trees.
6
+ */
7
+ export { SequenceNode, SelectorNode, ParallelNode, ActionNode, ConditionNode, deserializeNode, registerDecoratorFactory,
8
+ // Factory helpers
9
+ sequence, selector, parallel, action, condition, } from './nodes.js';
10
+ // Decorators
11
+ export { InverterNode, RepeatNode, UntilFailNode, TimeoutNode, RetryNode,
12
+ // Factory helpers
13
+ inverter, repeat, untilFail, timeout, retry, } from './decorators.js';
14
+ export { QEActionIds, QEConditionIds, buildTestGenerationPipeline, buildRegressionSuite, buildSecurityAudit, createQEHandlerRegistry, serializeQETree, deserializeQETree, } from './qe-trees.js';
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,165 @@
1
+ /**
2
+ * Behavior Tree Core Nodes
3
+ *
4
+ * Composable behavior tree nodes for agent orchestration.
5
+ * Each node implements a tick-based evaluation model returning
6
+ * SUCCESS, FAILURE, or RUNNING.
7
+ */
8
+ /** Result status of a behavior tree node tick */
9
+ export type NodeStatus = 'SUCCESS' | 'FAILURE' | 'RUNNING';
10
+ /** Serialized representation of a behavior tree node */
11
+ export interface SerializedNode {
12
+ type: string;
13
+ name: string;
14
+ children?: SerializedNode[];
15
+ config?: Record<string, unknown>;
16
+ }
17
+ /** Base interface for all behavior tree nodes */
18
+ export interface BehaviorNode {
19
+ /** Node type identifier */
20
+ readonly type: string;
21
+ /** Human-readable name */
22
+ readonly name: string;
23
+ /** Evaluate this node and return its status */
24
+ tick(): Promise<NodeStatus>;
25
+ /** Reset this node (and children) to initial state */
26
+ reset(): void;
27
+ /** Serialize this node to a JSON-compatible structure */
28
+ serialize(): SerializedNode;
29
+ }
30
+ /** Function signature for Action node handlers */
31
+ export type ActionFunction = () => Promise<NodeStatus>;
32
+ /** Function signature for Condition node predicates */
33
+ export type ConditionPredicate = () => Promise<boolean>;
34
+ /** Configuration for Parallel node */
35
+ export interface ParallelConfig {
36
+ /** Number of children that must succeed for this node to succeed */
37
+ successThreshold: number;
38
+ /** Whether to wait for all children or return early */
39
+ waitForAll?: boolean;
40
+ }
41
+ declare abstract class BaseNode implements BehaviorNode {
42
+ readonly name: string;
43
+ abstract readonly type: string;
44
+ constructor(name: string);
45
+ abstract tick(): Promise<NodeStatus>;
46
+ abstract reset(): void;
47
+ serialize(): SerializedNode;
48
+ }
49
+ declare abstract class CompositeNode extends BaseNode {
50
+ protected readonly children: BehaviorNode[];
51
+ constructor(name: string, children: BehaviorNode[]);
52
+ reset(): void;
53
+ serialize(): SerializedNode;
54
+ }
55
+ /**
56
+ * Sequence node - AND logic.
57
+ *
58
+ * Runs children in order from left to right:
59
+ * - Returns FAILURE immediately when any child fails
60
+ * - Returns RUNNING if a child is still running
61
+ * - Returns SUCCESS only when all children succeed
62
+ */
63
+ export declare class SequenceNode extends CompositeNode {
64
+ readonly type = "Sequence";
65
+ private currentIndex;
66
+ constructor(name: string, children: BehaviorNode[]);
67
+ tick(): Promise<NodeStatus>;
68
+ reset(): void;
69
+ }
70
+ /**
71
+ * Selector node - OR logic.
72
+ *
73
+ * Runs children in order from left to right:
74
+ * - Returns SUCCESS immediately when any child succeeds
75
+ * - Returns RUNNING if a child is still running
76
+ * - Returns FAILURE only when all children fail
77
+ */
78
+ export declare class SelectorNode extends CompositeNode {
79
+ readonly type = "Selector";
80
+ private currentIndex;
81
+ constructor(name: string, children: BehaviorNode[]);
82
+ tick(): Promise<NodeStatus>;
83
+ reset(): void;
84
+ }
85
+ /**
86
+ * Parallel node - concurrent execution.
87
+ *
88
+ * Runs all children concurrently:
89
+ * - Returns SUCCESS when successThreshold children succeed
90
+ * - Returns FAILURE when it becomes impossible to meet the threshold
91
+ * - Returns RUNNING while children are still executing
92
+ */
93
+ export declare class ParallelNode extends CompositeNode {
94
+ readonly type = "Parallel";
95
+ private readonly config;
96
+ constructor(name: string, children: BehaviorNode[], config: ParallelConfig);
97
+ tick(): Promise<NodeStatus>;
98
+ serialize(): SerializedNode;
99
+ }
100
+ /**
101
+ * Action node - leaf node that executes a function.
102
+ *
103
+ * Wraps an async function that returns a NodeStatus.
104
+ * Use for side-effectful operations like running tests or generating code.
105
+ */
106
+ export declare class ActionNode extends BaseNode {
107
+ readonly type = "Action";
108
+ private readonly action;
109
+ private readonly actionId;
110
+ constructor(name: string, action: ActionFunction, actionId?: string);
111
+ tick(): Promise<NodeStatus>;
112
+ reset(): void;
113
+ serialize(): SerializedNode;
114
+ }
115
+ /**
116
+ * Condition node - leaf node that checks a predicate.
117
+ *
118
+ * Wraps an async predicate that returns boolean.
119
+ * Returns SUCCESS if predicate is true, FAILURE if false.
120
+ * Use for checking preconditions or guard clauses.
121
+ */
122
+ export declare class ConditionNode extends BaseNode {
123
+ readonly type = "Condition";
124
+ private readonly predicate;
125
+ private readonly conditionId;
126
+ constructor(name: string, predicate: ConditionPredicate, conditionId?: string);
127
+ tick(): Promise<NodeStatus>;
128
+ reset(): void;
129
+ serialize(): SerializedNode;
130
+ }
131
+ /** Registry of action/condition handlers for deserialization */
132
+ export interface NodeHandlerRegistry {
133
+ actions: Map<string, ActionFunction>;
134
+ conditions: Map<string, ConditionPredicate>;
135
+ }
136
+ /**
137
+ * Deserialize a serialized node tree back into executable BehaviorNodes.
138
+ *
139
+ * Requires a handler registry to reconstruct Action and Condition nodes
140
+ * since functions cannot be serialized directly.
141
+ *
142
+ * Supports both core nodes (Sequence, Selector, Parallel, Action, Condition)
143
+ * and decorator nodes (Inverter, Repeat, UntilFail, Timeout, Retry).
144
+ * Decorator classes must be registered via registerDecoratorTypes() before
145
+ * deserialization of trees containing decorators.
146
+ */
147
+ export declare function deserializeNode(data: SerializedNode, registry: NodeHandlerRegistry): BehaviorNode;
148
+ type DecoratorFactory = (name: string, child: BehaviorNode, config: Record<string, unknown>) => BehaviorNode;
149
+ /**
150
+ * Register decorator type factories for deserialization.
151
+ * Called automatically when decorators module is imported via the barrel export.
152
+ */
153
+ export declare function registerDecoratorFactory(type: string, factory: DecoratorFactory): void;
154
+ /** Create a Sequence node */
155
+ export declare function sequence(name: string, children: BehaviorNode[]): SequenceNode;
156
+ /** Create a Selector node */
157
+ export declare function selector(name: string, children: BehaviorNode[]): SelectorNode;
158
+ /** Create a Parallel node */
159
+ export declare function parallel(name: string, children: BehaviorNode[], config: ParallelConfig): ParallelNode;
160
+ /** Create an Action node */
161
+ export declare function action(name: string, fn: ActionFunction, actionId?: string): ActionNode;
162
+ /** Create a Condition node */
163
+ export declare function condition(name: string, predicate: ConditionPredicate, conditionId?: string): ConditionNode;
164
+ export {};
165
+ //# sourceMappingURL=nodes.d.ts.map