@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.
- package/dist/budget-manager.d.ts +79 -0
- package/dist/budget-manager.d.ts.map +1 -0
- package/dist/budget-manager.js +155 -0
- package/dist/budget-manager.js.map +1 -0
- package/dist/confidence-extractor.d.ts +60 -0
- package/dist/confidence-extractor.d.ts.map +1 -0
- package/dist/confidence-extractor.js +251 -0
- package/dist/confidence-extractor.js.map +1 -0
- package/dist/consensus/synthesis.d.ts.map +1 -1
- package/dist/consensus/synthesis.js +2 -0
- package/dist/consensus/synthesis.js.map +1 -1
- package/dist/consensus/voting.d.ts +3 -0
- package/dist/consensus/voting.d.ts.map +1 -1
- package/dist/consensus/voting.js +15 -4
- package/dist/consensus/voting.js.map +1 -1
- package/dist/context-tracker.d.ts +77 -0
- package/dist/context-tracker.d.ts.map +1 -0
- package/dist/context-tracker.js +177 -0
- package/dist/context-tracker.js.map +1 -0
- package/dist/cost-tracker.d.ts +123 -0
- package/dist/cost-tracker.d.ts.map +1 -0
- package/dist/cost-tracker.js +196 -0
- package/dist/cost-tracker.js.map +1 -0
- package/dist/executor.d.ts.map +1 -1
- package/dist/executor.js +9 -0
- package/dist/executor.js.map +1 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -1
- package/dist/participant-resolver.d.ts +111 -0
- package/dist/participant-resolver.d.ts.map +1 -0
- package/dist/participant-resolver.js +160 -0
- package/dist/participant-resolver.js.map +1 -0
- package/dist/patterns/round-robin.d.ts +3 -0
- package/dist/patterns/round-robin.d.ts.map +1 -1
- package/dist/patterns/round-robin.js +41 -2
- package/dist/patterns/round-robin.js.map +1 -1
- package/dist/patterns/synthesis.d.ts +3 -0
- package/dist/patterns/synthesis.d.ts.map +1 -1
- package/dist/patterns/synthesis.js +77 -3
- package/dist/patterns/synthesis.js.map +1 -1
- package/dist/prompts/templates.d.ts +1 -0
- package/dist/prompts/templates.d.ts.map +1 -1
- package/dist/prompts/templates.js +3 -1
- package/dist/prompts/templates.js.map +1 -1
- package/dist/provider-bridge.d.ts +3 -1
- package/dist/provider-bridge.d.ts.map +1 -1
- package/dist/provider-bridge.js +48 -32
- package/dist/provider-bridge.js.map +1 -1
- package/dist/recursive-executor.d.ts +80 -0
- package/dist/recursive-executor.d.ts.map +1 -0
- package/dist/recursive-executor.js +354 -0
- package/dist/recursive-executor.js.map +1 -0
- package/dist/types.d.ts +83 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +2 -2
- package/src/budget-manager.ts +272 -0
- package/src/confidence-extractor.ts +321 -0
- package/src/consensus/synthesis.ts +2 -0
- package/src/consensus/voting.ts +22 -6
- package/src/context-tracker.ts +307 -0
- package/src/cost-tracker.ts +363 -0
- package/src/executor.ts +9 -0
- package/src/index.ts +72 -0
- package/src/participant-resolver.ts +297 -0
- package/src/patterns/round-robin.ts +48 -2
- package/src/patterns/synthesis.ts +89 -3
- package/src/prompts/templates.ts +4 -2
- package/src/provider-bridge.ts +52 -31
- package/src/recursive-executor.ts +510 -0
- 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
|
// ============================================================================
|