@defai.digital/discussion-domain 13.0.3 → 13.1.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.
Files changed (73) hide show
  1. package/dist/budget-manager.d.ts +79 -0
  2. package/dist/budget-manager.d.ts.map +1 -0
  3. package/dist/budget-manager.js +155 -0
  4. package/dist/budget-manager.js.map +1 -0
  5. package/dist/confidence-extractor.d.ts +60 -0
  6. package/dist/confidence-extractor.d.ts.map +1 -0
  7. package/dist/confidence-extractor.js +251 -0
  8. package/dist/confidence-extractor.js.map +1 -0
  9. package/dist/consensus/synthesis.d.ts.map +1 -1
  10. package/dist/consensus/synthesis.js +2 -0
  11. package/dist/consensus/synthesis.js.map +1 -1
  12. package/dist/consensus/voting.d.ts +3 -0
  13. package/dist/consensus/voting.d.ts.map +1 -1
  14. package/dist/consensus/voting.js +15 -4
  15. package/dist/consensus/voting.js.map +1 -1
  16. package/dist/context-tracker.d.ts +77 -0
  17. package/dist/context-tracker.d.ts.map +1 -0
  18. package/dist/context-tracker.js +177 -0
  19. package/dist/context-tracker.js.map +1 -0
  20. package/dist/cost-tracker.d.ts +123 -0
  21. package/dist/cost-tracker.d.ts.map +1 -0
  22. package/dist/cost-tracker.js +196 -0
  23. package/dist/cost-tracker.js.map +1 -0
  24. package/dist/executor.d.ts.map +1 -1
  25. package/dist/executor.js +9 -0
  26. package/dist/executor.js.map +1 -1
  27. package/dist/index.d.ts +7 -1
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/index.js +12 -0
  30. package/dist/index.js.map +1 -1
  31. package/dist/participant-resolver.d.ts +111 -0
  32. package/dist/participant-resolver.d.ts.map +1 -0
  33. package/dist/participant-resolver.js +160 -0
  34. package/dist/participant-resolver.js.map +1 -0
  35. package/dist/patterns/round-robin.d.ts +3 -0
  36. package/dist/patterns/round-robin.d.ts.map +1 -1
  37. package/dist/patterns/round-robin.js +41 -2
  38. package/dist/patterns/round-robin.js.map +1 -1
  39. package/dist/patterns/synthesis.d.ts +3 -0
  40. package/dist/patterns/synthesis.d.ts.map +1 -1
  41. package/dist/patterns/synthesis.js +77 -3
  42. package/dist/patterns/synthesis.js.map +1 -1
  43. package/dist/prompts/templates.d.ts +1 -0
  44. package/dist/prompts/templates.d.ts.map +1 -1
  45. package/dist/prompts/templates.js +3 -1
  46. package/dist/prompts/templates.js.map +1 -1
  47. package/dist/provider-bridge.d.ts +3 -1
  48. package/dist/provider-bridge.d.ts.map +1 -1
  49. package/dist/provider-bridge.js +48 -32
  50. package/dist/provider-bridge.js.map +1 -1
  51. package/dist/recursive-executor.d.ts +80 -0
  52. package/dist/recursive-executor.d.ts.map +1 -0
  53. package/dist/recursive-executor.js +354 -0
  54. package/dist/recursive-executor.js.map +1 -0
  55. package/dist/types.d.ts +83 -0
  56. package/dist/types.d.ts.map +1 -1
  57. package/dist/types.js.map +1 -1
  58. package/package.json +2 -2
  59. package/src/budget-manager.ts +272 -0
  60. package/src/confidence-extractor.ts +321 -0
  61. package/src/consensus/synthesis.ts +2 -0
  62. package/src/consensus/voting.ts +22 -6
  63. package/src/context-tracker.ts +307 -0
  64. package/src/cost-tracker.ts +363 -0
  65. package/src/executor.ts +9 -0
  66. package/src/index.ts +72 -0
  67. package/src/participant-resolver.ts +297 -0
  68. package/src/patterns/round-robin.ts +48 -2
  69. package/src/patterns/synthesis.ts +89 -3
  70. package/src/prompts/templates.ts +4 -2
  71. package/src/provider-bridge.ts +52 -31
  72. package/src/recursive-executor.ts +510 -0
  73. package/src/types.ts +120 -0
package/src/types.ts CHANGED
@@ -100,6 +100,20 @@ export interface ProviderExecuteResult {
100
100
  // Pattern Executor Interface
101
101
  // ============================================================================
102
102
 
103
+ /**
104
+ * Cascading confidence configuration for early exit
105
+ */
106
+ export interface CascadingConfidenceOptions {
107
+ /** Whether cascading confidence is enabled */
108
+ enabled: boolean;
109
+
110
+ /** Confidence threshold for early exit (0-1) */
111
+ threshold: number;
112
+
113
+ /** Minimum providers before early exit allowed */
114
+ minProviders: number;
115
+ }
116
+
103
117
  /**
104
118
  * Context passed to pattern executors
105
119
  */
@@ -121,6 +135,9 @@ export interface PatternExecutionContext {
121
135
 
122
136
  /** Callback for progress updates */
123
137
  onProgress?: ((event: DiscussionProgressEvent) => void) | undefined;
138
+
139
+ /** Cascading confidence configuration for early exit */
140
+ cascadingConfidence?: CascadingConfidenceOptions | undefined;
124
141
  }
125
142
 
126
143
  /**
@@ -134,6 +151,23 @@ export interface DiscussionProgressEvent {
134
151
  timestamp: string;
135
152
  }
136
153
 
154
+ /**
155
+ * Early exit information
156
+ */
157
+ export interface EarlyExitInfo {
158
+ /** Whether early exit was triggered */
159
+ triggered: boolean;
160
+
161
+ /** Reason for early exit decision */
162
+ reason?: string | undefined;
163
+
164
+ /** Number of providers at exit point */
165
+ atProviderCount?: number | undefined;
166
+
167
+ /** Confidence score that triggered exit */
168
+ confidenceScore?: number | undefined;
169
+ }
170
+
137
171
  /**
138
172
  * Result from pattern execution
139
173
  */
@@ -155,6 +189,9 @@ export interface PatternExecutionResult {
155
189
 
156
190
  /** Error if execution failed */
157
191
  error?: string | undefined;
192
+
193
+ /** Early exit information */
194
+ earlyExit?: EarlyExitInfo | undefined;
158
195
  }
159
196
 
160
197
  /**
@@ -190,6 +227,9 @@ export interface ConsensusExecutionContext {
190
227
  /** Consensus configuration */
191
228
  config: DiscussStepConfig['consensus'];
192
229
 
230
+ /** Agent weight multiplier for consensus (INV-DISC-642) */
231
+ agentWeightMultiplier?: number | undefined;
232
+
193
233
  /** Provider executor for synthesis calls */
194
234
  providerExecutor: DiscussionProviderExecutor;
195
235
 
@@ -257,6 +297,86 @@ export interface DiscussionExecutorOptions {
257
297
  traceId?: string | undefined;
258
298
  }
259
299
 
300
+ // ============================================================================
301
+ // Recursive Discussion Types
302
+ // ============================================================================
303
+
304
+ import type {
305
+ DiscussionContext,
306
+ TimeoutConfig,
307
+ RecursiveConfig,
308
+ CostControlConfig,
309
+ SubDiscussionResult,
310
+ } from '@defai.digital/contracts';
311
+
312
+ /**
313
+ * Extended options for recursive discussion executor
314
+ */
315
+ export interface RecursiveDiscussionExecutorOptions extends DiscussionExecutorOptions {
316
+ /** Recursive discussion configuration */
317
+ recursive?: RecursiveConfig | undefined;
318
+
319
+ /** Timeout configuration */
320
+ timeout?: TimeoutConfig | undefined;
321
+
322
+ /** Cost control configuration */
323
+ cost?: CostControlConfig | undefined;
324
+
325
+ /** Parent context for nested discussions */
326
+ parentContext?: DiscussionContext | undefined;
327
+
328
+ /** Callback when sub-discussion is spawned */
329
+ onSubDiscussionSpawn?: ((context: DiscussionContext, topic: string) => void) | undefined;
330
+
331
+ /** Callback when sub-discussion completes */
332
+ onSubDiscussionComplete?: ((result: SubDiscussionResult) => void) | undefined;
333
+ }
334
+
335
+ /**
336
+ * Extended pattern execution context for recursive discussions
337
+ */
338
+ export interface RecursivePatternExecutionContext extends PatternExecutionContext {
339
+ /** Discussion context for recursion tracking */
340
+ discussionContext?: DiscussionContext | undefined;
341
+
342
+ /** Whether sub-discussions are allowed */
343
+ allowSubDiscussions?: boolean | undefined;
344
+
345
+ /** Function to spawn a sub-discussion */
346
+ spawnSubDiscussion?: ((topic: string, providers?: string[]) => Promise<SubDiscussionResult | null>) | undefined;
347
+ }
348
+
349
+ /**
350
+ * Extended pattern execution result with sub-discussion info
351
+ */
352
+ export interface RecursivePatternExecutionResult extends PatternExecutionResult {
353
+ /** Sub-discussions spawned during execution */
354
+ subDiscussions?: SubDiscussionResult[] | undefined;
355
+
356
+ /** Total calls including sub-discussions */
357
+ totalProviderCalls?: number | undefined;
358
+ }
359
+
360
+ /**
361
+ * Sub-discussion request
362
+ */
363
+ export interface SubDiscussionRequest {
364
+ /** Topic for sub-discussion */
365
+ topic: string;
366
+
367
+ /** Providers to use (optional, uses parent's allowed providers) */
368
+ providers?: string[] | undefined;
369
+
370
+ /** Pattern to use (defaults to synthesis) */
371
+ pattern?: DiscussionPattern | undefined;
372
+
373
+ /** Maximum rounds (defaults to 1 for sub-discussions) */
374
+ rounds?: number | undefined;
375
+
376
+ /** Requesting provider ID */
377
+ requestedBy: string;
378
+ }
379
+
260
380
  // ============================================================================
261
381
  // Stub Provider Executor (for testing/development)
262
382
  // ============================================================================