ai-consensus-core 0.9.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/LICENSE +21 -0
- package/README.md +415 -0
- package/dist/engine.d.ts +30 -0
- package/dist/engine.d.ts.map +1 -0
- package/dist/engine.js +428 -0
- package/dist/engine.js.map +1 -0
- package/dist/events.d.ts +29 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +46 -0
- package/dist/events.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/parser.d.ts +27 -0
- package/dist/parser.d.ts.map +1 -0
- package/dist/parser.js +55 -0
- package/dist/parser.js.map +1 -0
- package/dist/personas.d.ts +16 -0
- package/dist/personas.d.ts.map +1 -0
- package/dist/personas.js +109 -0
- package/dist/personas.js.map +1 -0
- package/dist/prompts.d.ts +60 -0
- package/dist/prompts.d.ts.map +1 -0
- package/dist/prompts.js +111 -0
- package/dist/prompts.js.map +1 -0
- package/dist/stats.d.ts +42 -0
- package/dist/stats.d.ts.map +1 -0
- package/dist/stats.js +108 -0
- package/dist/stats.js.map +1 -0
- package/dist/types.d.ts +303 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +31 -0
- package/dist/types.js.map +1 -0
- package/package.json +71 -0
package/dist/engine.js
ADDED
|
@@ -0,0 +1,428 @@
|
|
|
1
|
+
// ─────────────────────────────────────────────────────────────
|
|
2
|
+
// ConsensusEngine — CVP orchestrator
|
|
3
|
+
// ─────────────────────────────────────────────────────────────
|
|
4
|
+
// Drives the full protocol: round scheduling, phase prompts,
|
|
5
|
+
// blind/sequential dispatch, confidence extraction, stats,
|
|
6
|
+
// disagreement detection, early stopping, optional judge synthesis.
|
|
7
|
+
//
|
|
8
|
+
// Zero LLM-provider coupling. A `ModelCaller` is the single
|
|
9
|
+
// extension point — see `types.ts`.
|
|
10
|
+
import { TypedEventEmitter } from "./events.js";
|
|
11
|
+
import { JUDGE_PERSONA } from "./personas.js";
|
|
12
|
+
import { extractConfidence, extractJudgeConfidence, extractJudgeSection, } from "./parser.js";
|
|
13
|
+
import { buildJudgeSystemPrompt, buildJudgeUserPrompt, buildParticipantSystemPrompt, getRoundMeta, } from "./prompts.js";
|
|
14
|
+
import { average, consensusScore, detectDisagreements, mulberry32, shuffle, stddev, } from "./stats.js";
|
|
15
|
+
// ── Defaults ───────────────────────────────────────────────
|
|
16
|
+
const DEFAULTS = {
|
|
17
|
+
maxRounds: 4,
|
|
18
|
+
earlyStop: true,
|
|
19
|
+
convergenceDelta: 3,
|
|
20
|
+
disagreementThreshold: 20,
|
|
21
|
+
blindFirstRound: true,
|
|
22
|
+
randomizeOrder: true,
|
|
23
|
+
participantTemperature: 0.7,
|
|
24
|
+
maxOutputTokens: 1500,
|
|
25
|
+
judgeTemperature: 0.3,
|
|
26
|
+
judgeMaxOutputTokens: 1500,
|
|
27
|
+
};
|
|
28
|
+
const MAX_ROUNDS_CAP = 10;
|
|
29
|
+
const MIN_PARTICIPANTS = 2;
|
|
30
|
+
// ── Public engine ──────────────────────────────────────────
|
|
31
|
+
export class ConsensusEngine extends TypedEventEmitter {
|
|
32
|
+
#caller;
|
|
33
|
+
constructor(caller) {
|
|
34
|
+
super();
|
|
35
|
+
this.#caller = caller;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Run the Consensus Validation Protocol end-to-end.
|
|
39
|
+
*
|
|
40
|
+
* Emits events throughout (see {@link ConsensusEventMap}). Resolves with the
|
|
41
|
+
* final {@link ConsensusResult}. Rejects only on `AbortError` from a
|
|
42
|
+
* cancelled run — per-participant ModelCaller failures are captured into
|
|
43
|
+
* the per-response `error` field and do not abort the loop.
|
|
44
|
+
*/
|
|
45
|
+
async run(options) {
|
|
46
|
+
const opts = normalizeOptions(options);
|
|
47
|
+
const startedAt = Date.now();
|
|
48
|
+
const rng = opts.randomSeed !== undefined ? mulberry32(opts.randomSeed) : Math.random;
|
|
49
|
+
const allResponses = [];
|
|
50
|
+
const rounds = [];
|
|
51
|
+
const roundScores = [];
|
|
52
|
+
let stopReason = "max-rounds";
|
|
53
|
+
let earlyStopInfo;
|
|
54
|
+
try {
|
|
55
|
+
for (let round = 1; round <= opts.maxRounds; round++) {
|
|
56
|
+
throwIfAborted(opts.signal);
|
|
57
|
+
const { phase, label } = getRoundMeta(round, opts.maxRounds);
|
|
58
|
+
const blind = round === 1 && opts.blindFirstRound;
|
|
59
|
+
const order = !blind && opts.randomizeOrder && round > 1
|
|
60
|
+
? shuffle(opts.participants, rng)
|
|
61
|
+
: opts.participants.slice();
|
|
62
|
+
this.emit("roundStart", {
|
|
63
|
+
round,
|
|
64
|
+
phase,
|
|
65
|
+
label,
|
|
66
|
+
blind,
|
|
67
|
+
participantIds: order.map((p) => p.id),
|
|
68
|
+
});
|
|
69
|
+
const roundStartedAt = Date.now();
|
|
70
|
+
const previousResponses = allResponses.filter((r) => r.round < round);
|
|
71
|
+
const roundResponses = await this.#runRound({
|
|
72
|
+
round,
|
|
73
|
+
phase,
|
|
74
|
+
blind,
|
|
75
|
+
order,
|
|
76
|
+
previousResponses,
|
|
77
|
+
totalRounds: opts.maxRounds,
|
|
78
|
+
question: opts.question,
|
|
79
|
+
temperature: opts.participantTemperature,
|
|
80
|
+
maxOutputTokens: opts.maxOutputTokens,
|
|
81
|
+
signal: opts.signal,
|
|
82
|
+
});
|
|
83
|
+
const roundCompletedAt = Date.now();
|
|
84
|
+
allResponses.push(...roundResponses);
|
|
85
|
+
const scored = roundResponses.filter((r) => !r.error);
|
|
86
|
+
const confidences = scored.map((r) => r.confidence);
|
|
87
|
+
const avg = average(confidences);
|
|
88
|
+
const sd = stddev(confidences);
|
|
89
|
+
const score = consensusScore(confidences);
|
|
90
|
+
roundScores.push(score);
|
|
91
|
+
const disagreements = detectDisagreements({
|
|
92
|
+
round,
|
|
93
|
+
responses: roundResponses,
|
|
94
|
+
participants: opts.participants,
|
|
95
|
+
threshold: opts.disagreementThreshold,
|
|
96
|
+
});
|
|
97
|
+
for (const d of disagreements) {
|
|
98
|
+
this.emit("disagreementDetected", { round, disagreement: d });
|
|
99
|
+
}
|
|
100
|
+
const roundResult = {
|
|
101
|
+
round,
|
|
102
|
+
phase,
|
|
103
|
+
label,
|
|
104
|
+
blind,
|
|
105
|
+
responses: roundResponses,
|
|
106
|
+
averageConfidence: avg,
|
|
107
|
+
stddev: sd,
|
|
108
|
+
score,
|
|
109
|
+
disagreements,
|
|
110
|
+
startedAt: roundStartedAt,
|
|
111
|
+
completedAt: roundCompletedAt,
|
|
112
|
+
durationMs: roundCompletedAt - roundStartedAt,
|
|
113
|
+
};
|
|
114
|
+
rounds.push(roundResult);
|
|
115
|
+
this.emit("roundComplete", {
|
|
116
|
+
round,
|
|
117
|
+
phase,
|
|
118
|
+
averageConfidence: avg,
|
|
119
|
+
stddev: sd,
|
|
120
|
+
score,
|
|
121
|
+
disagreements,
|
|
122
|
+
responses: roundResponses,
|
|
123
|
+
durationMs: roundResult.durationMs,
|
|
124
|
+
});
|
|
125
|
+
if (opts.earlyStop &&
|
|
126
|
+
round >= 2 &&
|
|
127
|
+
round < opts.maxRounds &&
|
|
128
|
+
roundScores.length >= 2) {
|
|
129
|
+
const prev = roundScores[roundScores.length - 2];
|
|
130
|
+
const delta = Math.abs(score - prev);
|
|
131
|
+
if (delta <= opts.convergenceDelta) {
|
|
132
|
+
const reason = `Consensus score delta ${delta.toFixed(1)} between rounds ${round - 1} and ${round} is at or below the convergence threshold (${opts.convergenceDelta}).`;
|
|
133
|
+
earlyStopInfo = { round, delta, reason };
|
|
134
|
+
stopReason = "converged";
|
|
135
|
+
this.emit("earlyStop", { round, delta, reason });
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
// Judge synthesis (optional)
|
|
141
|
+
const lastRound = rounds[rounds.length - 1];
|
|
142
|
+
let synthesis;
|
|
143
|
+
if (opts.judge && lastRound) {
|
|
144
|
+
throwIfAborted(opts.signal);
|
|
145
|
+
synthesis = await this.#runJudge({
|
|
146
|
+
judgeModelId: opts.judge.modelId,
|
|
147
|
+
judgeCaller: opts.judge.caller ?? this.#caller,
|
|
148
|
+
judgeTemperature: opts.judge.temperature ?? DEFAULTS.judgeTemperature,
|
|
149
|
+
judgeMaxOutputTokens: opts.judge.maxOutputTokens ?? DEFAULTS.judgeMaxOutputTokens,
|
|
150
|
+
finalResponses: lastRound.responses,
|
|
151
|
+
participants: opts.participants,
|
|
152
|
+
question: opts.question,
|
|
153
|
+
lastRoundNumber: lastRound.round,
|
|
154
|
+
signal: opts.signal,
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
const completedAt = Date.now();
|
|
158
|
+
const finalConfidences = lastRound
|
|
159
|
+
? lastRound.responses.filter((r) => !r.error).map((r) => r.confidence)
|
|
160
|
+
: [];
|
|
161
|
+
const result = {
|
|
162
|
+
question: opts.question,
|
|
163
|
+
participants: opts.participants,
|
|
164
|
+
rounds,
|
|
165
|
+
roundsCompleted: rounds.length,
|
|
166
|
+
finalScore: lastRound?.score ?? 0,
|
|
167
|
+
finalAverageConfidence: average(finalConfidences),
|
|
168
|
+
finalStddev: stddev(finalConfidences),
|
|
169
|
+
stopReason,
|
|
170
|
+
earlyStop: earlyStopInfo,
|
|
171
|
+
synthesis,
|
|
172
|
+
startedAt,
|
|
173
|
+
completedAt,
|
|
174
|
+
durationMs: completedAt - startedAt,
|
|
175
|
+
};
|
|
176
|
+
this.emit("finalResult", { result });
|
|
177
|
+
return result;
|
|
178
|
+
}
|
|
179
|
+
catch (err) {
|
|
180
|
+
if (isAbortError(err)) {
|
|
181
|
+
const completedAt = Date.now();
|
|
182
|
+
const lastRound = rounds[rounds.length - 1];
|
|
183
|
+
const finalConfidences = lastRound
|
|
184
|
+
? lastRound.responses.filter((r) => !r.error).map((r) => r.confidence)
|
|
185
|
+
: [];
|
|
186
|
+
const result = {
|
|
187
|
+
question: opts.question,
|
|
188
|
+
participants: opts.participants,
|
|
189
|
+
rounds,
|
|
190
|
+
roundsCompleted: rounds.length,
|
|
191
|
+
finalScore: lastRound?.score ?? 0,
|
|
192
|
+
finalAverageConfidence: average(finalConfidences),
|
|
193
|
+
finalStddev: stddev(finalConfidences),
|
|
194
|
+
stopReason: "aborted",
|
|
195
|
+
earlyStop: earlyStopInfo,
|
|
196
|
+
startedAt,
|
|
197
|
+
completedAt,
|
|
198
|
+
durationMs: completedAt - startedAt,
|
|
199
|
+
};
|
|
200
|
+
this.emit("finalResult", { result });
|
|
201
|
+
return result;
|
|
202
|
+
}
|
|
203
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
204
|
+
this.emit("error", error);
|
|
205
|
+
throw error;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
// ── Round orchestration ──────────────────────────────────
|
|
209
|
+
async #runRound(args) {
|
|
210
|
+
const { round, phase, blind, order, previousResponses, totalRounds, question, temperature, maxOutputTokens, signal, } = args;
|
|
211
|
+
if (blind) {
|
|
212
|
+
const promises = order.map((participant) => this.#callParticipant({
|
|
213
|
+
participant,
|
|
214
|
+
round,
|
|
215
|
+
phase,
|
|
216
|
+
totalRounds,
|
|
217
|
+
question,
|
|
218
|
+
previousResponses: [],
|
|
219
|
+
temperature,
|
|
220
|
+
maxOutputTokens,
|
|
221
|
+
signal,
|
|
222
|
+
runningConfidences: [],
|
|
223
|
+
}));
|
|
224
|
+
return Promise.all(promises);
|
|
225
|
+
}
|
|
226
|
+
const collected = [];
|
|
227
|
+
for (const participant of order) {
|
|
228
|
+
throwIfAborted(signal);
|
|
229
|
+
const visible = [...previousResponses, ...collected];
|
|
230
|
+
const confidencesSoFar = collected
|
|
231
|
+
.filter((r) => !r.error)
|
|
232
|
+
.map((r) => r.confidence);
|
|
233
|
+
const response = await this.#callParticipant({
|
|
234
|
+
participant,
|
|
235
|
+
round,
|
|
236
|
+
phase,
|
|
237
|
+
totalRounds,
|
|
238
|
+
question,
|
|
239
|
+
previousResponses: visible,
|
|
240
|
+
temperature,
|
|
241
|
+
maxOutputTokens,
|
|
242
|
+
signal,
|
|
243
|
+
runningConfidences: confidencesSoFar,
|
|
244
|
+
});
|
|
245
|
+
collected.push(response);
|
|
246
|
+
}
|
|
247
|
+
return collected;
|
|
248
|
+
}
|
|
249
|
+
// ── Single participant call ──────────────────────────────
|
|
250
|
+
async #callParticipant(args) {
|
|
251
|
+
const { participant, round, phase, totalRounds, question, previousResponses, temperature, maxOutputTokens, signal, runningConfidences, } = args;
|
|
252
|
+
const system = buildParticipantSystemPrompt({
|
|
253
|
+
personaSystemPrompt: participant.persona.systemPrompt,
|
|
254
|
+
phase,
|
|
255
|
+
round,
|
|
256
|
+
totalRounds,
|
|
257
|
+
previousResponses,
|
|
258
|
+
});
|
|
259
|
+
this.emit("participantStart", {
|
|
260
|
+
round,
|
|
261
|
+
phase,
|
|
262
|
+
participantId: participant.id,
|
|
263
|
+
modelId: participant.modelId,
|
|
264
|
+
personaId: participant.persona.id,
|
|
265
|
+
});
|
|
266
|
+
const startedAt = Date.now();
|
|
267
|
+
let content = "";
|
|
268
|
+
let error;
|
|
269
|
+
let usage;
|
|
270
|
+
try {
|
|
271
|
+
const result = await this.#caller({
|
|
272
|
+
participantId: participant.id,
|
|
273
|
+
modelId: participant.modelId,
|
|
274
|
+
round,
|
|
275
|
+
phase,
|
|
276
|
+
system,
|
|
277
|
+
user: question,
|
|
278
|
+
temperature,
|
|
279
|
+
maxOutputTokens,
|
|
280
|
+
signal,
|
|
281
|
+
onToken: (token) => {
|
|
282
|
+
this.emit("participantToken", {
|
|
283
|
+
round,
|
|
284
|
+
participantId: participant.id,
|
|
285
|
+
token,
|
|
286
|
+
});
|
|
287
|
+
},
|
|
288
|
+
});
|
|
289
|
+
content = result.content;
|
|
290
|
+
usage = result.usage;
|
|
291
|
+
}
|
|
292
|
+
catch (err) {
|
|
293
|
+
if (isAbortError(err))
|
|
294
|
+
throw err;
|
|
295
|
+
error = err instanceof Error ? err.message : String(err);
|
|
296
|
+
content = content || `[Error from ${participant.modelId}: ${error}]`;
|
|
297
|
+
}
|
|
298
|
+
const completedAt = Date.now();
|
|
299
|
+
const confidence = error ? 0 : extractConfidence(content);
|
|
300
|
+
const response = {
|
|
301
|
+
participantId: participant.id,
|
|
302
|
+
modelId: participant.modelId,
|
|
303
|
+
personaId: participant.persona.id,
|
|
304
|
+
round,
|
|
305
|
+
phase,
|
|
306
|
+
content,
|
|
307
|
+
confidence,
|
|
308
|
+
error,
|
|
309
|
+
usage,
|
|
310
|
+
startedAt,
|
|
311
|
+
completedAt,
|
|
312
|
+
durationMs: completedAt - startedAt,
|
|
313
|
+
};
|
|
314
|
+
this.emit("participantComplete", { round, phase, response });
|
|
315
|
+
if (!error) {
|
|
316
|
+
const withSelf = [...runningConfidences, confidence];
|
|
317
|
+
this.emit("confidenceUpdate", {
|
|
318
|
+
round,
|
|
319
|
+
participantId: participant.id,
|
|
320
|
+
confidence,
|
|
321
|
+
runningAverage: average(withSelf),
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
return response;
|
|
325
|
+
}
|
|
326
|
+
// ── Judge synthesizer ────────────────────────────────────
|
|
327
|
+
async #runJudge(args) {
|
|
328
|
+
const { judgeModelId, judgeCaller, judgeTemperature, judgeMaxOutputTokens, finalResponses, participants, question, lastRoundNumber, signal, } = args;
|
|
329
|
+
this.emit("synthesisStart", { modelId: judgeModelId });
|
|
330
|
+
const system = buildJudgeSystemPrompt({
|
|
331
|
+
judgeSystemPrompt: JUDGE_PERSONA.systemPrompt,
|
|
332
|
+
question,
|
|
333
|
+
});
|
|
334
|
+
const user = buildJudgeUserPrompt({
|
|
335
|
+
finalResponses,
|
|
336
|
+
participants,
|
|
337
|
+
});
|
|
338
|
+
const startedAt = Date.now();
|
|
339
|
+
let content = "";
|
|
340
|
+
let usage;
|
|
341
|
+
try {
|
|
342
|
+
const result = await judgeCaller({
|
|
343
|
+
participantId: "judge",
|
|
344
|
+
modelId: judgeModelId,
|
|
345
|
+
round: lastRoundNumber,
|
|
346
|
+
phase: "synthesis",
|
|
347
|
+
system,
|
|
348
|
+
user,
|
|
349
|
+
temperature: judgeTemperature,
|
|
350
|
+
maxOutputTokens: judgeMaxOutputTokens,
|
|
351
|
+
signal,
|
|
352
|
+
onToken: (token) => {
|
|
353
|
+
this.emit("synthesisToken", { token });
|
|
354
|
+
},
|
|
355
|
+
});
|
|
356
|
+
content = result.content;
|
|
357
|
+
usage = result.usage;
|
|
358
|
+
}
|
|
359
|
+
catch (err) {
|
|
360
|
+
if (isAbortError(err))
|
|
361
|
+
throw err;
|
|
362
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
363
|
+
content = content || `[Judge error from ${judgeModelId}: ${msg}]`;
|
|
364
|
+
}
|
|
365
|
+
const completedAt = Date.now();
|
|
366
|
+
const synthesis = {
|
|
367
|
+
modelId: judgeModelId,
|
|
368
|
+
content,
|
|
369
|
+
majorityPosition: extractJudgeSection(content, "Majority Position"),
|
|
370
|
+
minorityPositions: extractJudgeSection(content, "Minority Positions"),
|
|
371
|
+
unresolvedDisputes: extractJudgeSection(content, "Unresolved Disputes"),
|
|
372
|
+
judgeConfidence: extractJudgeConfidence(content),
|
|
373
|
+
usage,
|
|
374
|
+
startedAt,
|
|
375
|
+
completedAt,
|
|
376
|
+
durationMs: completedAt - startedAt,
|
|
377
|
+
};
|
|
378
|
+
this.emit("synthesisComplete", { synthesis });
|
|
379
|
+
return synthesis;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
function normalizeOptions(options) {
|
|
383
|
+
if (!options.question || options.question.trim().length === 0) {
|
|
384
|
+
throw new Error("ConsensusEngine: `question` must be a non-empty string.");
|
|
385
|
+
}
|
|
386
|
+
if (!Array.isArray(options.participants) || options.participants.length < MIN_PARTICIPANTS) {
|
|
387
|
+
throw new Error(`ConsensusEngine: at least ${MIN_PARTICIPANTS} participants are required (got ${options.participants?.length ?? 0}).`);
|
|
388
|
+
}
|
|
389
|
+
const ids = new Set();
|
|
390
|
+
for (const p of options.participants) {
|
|
391
|
+
if (ids.has(p.id)) {
|
|
392
|
+
throw new Error(`ConsensusEngine: duplicate participant id "${p.id}".`);
|
|
393
|
+
}
|
|
394
|
+
ids.add(p.id);
|
|
395
|
+
}
|
|
396
|
+
const maxRounds = clampInt(options.maxRounds ?? DEFAULTS.maxRounds, 1, MAX_ROUNDS_CAP);
|
|
397
|
+
return {
|
|
398
|
+
question: options.question,
|
|
399
|
+
participants: options.participants.slice(),
|
|
400
|
+
maxRounds,
|
|
401
|
+
earlyStop: options.earlyStop ?? DEFAULTS.earlyStop,
|
|
402
|
+
convergenceDelta: options.convergenceDelta ?? DEFAULTS.convergenceDelta,
|
|
403
|
+
disagreementThreshold: options.disagreementThreshold ?? DEFAULTS.disagreementThreshold,
|
|
404
|
+
blindFirstRound: options.blindFirstRound ?? DEFAULTS.blindFirstRound,
|
|
405
|
+
randomizeOrder: options.randomizeOrder ?? DEFAULTS.randomizeOrder,
|
|
406
|
+
participantTemperature: options.participantTemperature ?? DEFAULTS.participantTemperature,
|
|
407
|
+
maxOutputTokens: options.maxOutputTokens ?? DEFAULTS.maxOutputTokens,
|
|
408
|
+
judge: options.judge,
|
|
409
|
+
randomSeed: options.randomSeed,
|
|
410
|
+
signal: options.signal,
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
function clampInt(n, lo, hi) {
|
|
414
|
+
return Math.max(lo, Math.min(hi, Math.trunc(n)));
|
|
415
|
+
}
|
|
416
|
+
function throwIfAborted(signal) {
|
|
417
|
+
if (signal?.aborted) {
|
|
418
|
+
const reason = signal.reason;
|
|
419
|
+
if (reason instanceof Error)
|
|
420
|
+
throw reason;
|
|
421
|
+
throw new DOMException("Aborted", "AbortError");
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
function isAbortError(err) {
|
|
425
|
+
return (err instanceof DOMException && err.name === "AbortError") || (err instanceof Error && err.name === "AbortError");
|
|
426
|
+
}
|
|
427
|
+
export { DEFAULTS as CONSENSUS_DEFAULTS, MAX_ROUNDS_CAP };
|
|
428
|
+
//# sourceMappingURL=engine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,qCAAqC;AACrC,gEAAgE;AAChE,6DAA6D;AAC7D,2DAA2D;AAC3D,oEAAoE;AACpE,EAAE;AACF,4DAA4D;AAC5D,oCAAoC;AAEpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EACL,iBAAiB,EACjB,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,sBAAsB,EACtB,oBAAoB,EACpB,4BAA4B,EAC5B,YAAY,GACb,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,OAAO,EACP,cAAc,EACd,mBAAmB,EACnB,UAAU,EACV,OAAO,EACP,MAAM,GACP,MAAM,YAAY,CAAC;AAepB,8DAA8D;AAE9D,MAAM,QAAQ,GAAG;IACf,SAAS,EAAE,CAAC;IACZ,SAAS,EAAE,IAAI;IACf,gBAAgB,EAAE,CAAC;IACnB,qBAAqB,EAAE,EAAE;IACzB,eAAe,EAAE,IAAI;IACrB,cAAc,EAAE,IAAI;IACpB,sBAAsB,EAAE,GAAG;IAC3B,eAAe,EAAE,IAAI;IACrB,gBAAgB,EAAE,GAAG;IACrB,oBAAoB,EAAE,IAAI;CAClB,CAAC;AAEX,MAAM,cAAc,GAAG,EAAE,CAAC;AAC1B,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAE3B,8DAA8D;AAE9D,MAAM,OAAO,eAAgB,SAAQ,iBAAoC;IAC9D,OAAO,CAAc;IAE9B,YAAY,MAAmB;QAC7B,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAED;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kBAAkB,EAAE,cAAc,EAAE,CAAC"}
|
package/dist/events.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ConsensusEventMap } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Thin, strictly-typed wrapper around Node's EventEmitter.
|
|
4
|
+
*
|
|
5
|
+
* We don't rely on Node 22+'s generic `EventEmitter<T>` so this works on every
|
|
6
|
+
* Node 20+ release. The shape is intentionally narrow — if you need `prependListener`
|
|
7
|
+
* or `rawListeners` for this, add them here and keep the types honest.
|
|
8
|
+
*
|
|
9
|
+
* The constraint is a self-referential mapped type rather than a bare
|
|
10
|
+
* `Record<string, (...args: never[]) => void>` so that interface-based event
|
|
11
|
+
* maps (which lack an implicit string index signature) satisfy it.
|
|
12
|
+
*/
|
|
13
|
+
export declare class TypedEventEmitter<Events extends {
|
|
14
|
+
[K in keyof Events]: (...args: never[]) => void;
|
|
15
|
+
}> {
|
|
16
|
+
private readonly emitter;
|
|
17
|
+
constructor();
|
|
18
|
+
on<K extends keyof Events & string>(event: K, listener: Events[K]): this;
|
|
19
|
+
once<K extends keyof Events & string>(event: K, listener: Events[K]): this;
|
|
20
|
+
off<K extends keyof Events & string>(event: K, listener: Events[K]): this;
|
|
21
|
+
removeAllListeners<K extends keyof Events & string>(event?: K): this;
|
|
22
|
+
listenerCount<K extends keyof Events & string>(event: K): number;
|
|
23
|
+
protected emit<K extends keyof Events & string>(event: K, ...args: Parameters<Events[K]>): boolean;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* A narrower alias for consumers who want the concrete engine event map.
|
|
27
|
+
*/
|
|
28
|
+
export type ConsensusEmitter = TypedEventEmitter<ConsensusEventMap>;
|
|
29
|
+
//# sourceMappingURL=events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YA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on Node 22+'s generic `EventEmitter<T>` so this works on every
|
|
6
|
+
* Node 20+ release. The shape is intentionally narrow — if you need `prependListener`
|
|
7
|
+
* or `rawListeners` for this, add them here and keep the types honest.
|
|
8
|
+
*
|
|
9
|
+
* The constraint is a self-referential mapped type rather than a bare
|
|
10
|
+
* `Record<string, (...args: never[]) => void>` so that interface-based event
|
|
11
|
+
* maps (which lack an implicit string index signature) satisfy it.
|
|
12
|
+
*/
|
|
13
|
+
export class TypedEventEmitter {
|
|
14
|
+
emitter = new EventEmitter();
|
|
15
|
+
constructor() {
|
|
16
|
+
// Consensus runs can fan out to many observers (UI, logs, MCP progress…).
|
|
17
|
+
// Default cap of 10 is too low for real-world use.
|
|
18
|
+
this.emitter.setMaxListeners(0);
|
|
19
|
+
}
|
|
20
|
+
on(event, listener) {
|
|
21
|
+
this.emitter.on(event, listener);
|
|
22
|
+
return this;
|
|
23
|
+
}
|
|
24
|
+
once(event, listener) {
|
|
25
|
+
this.emitter.once(event, listener);
|
|
26
|
+
return this;
|
|
27
|
+
}
|
|
28
|
+
off(event, listener) {
|
|
29
|
+
this.emitter.off(event, listener);
|
|
30
|
+
return this;
|
|
31
|
+
}
|
|
32
|
+
removeAllListeners(event) {
|
|
33
|
+
if (event)
|
|
34
|
+
this.emitter.removeAllListeners(event);
|
|
35
|
+
else
|
|
36
|
+
this.emitter.removeAllListeners();
|
|
37
|
+
return this;
|
|
38
|
+
}
|
|
39
|
+
listenerCount(event) {
|
|
40
|
+
return this.emitter.listenerCount(event);
|
|
41
|
+
}
|
|
42
|
+
emit(event, ...args) {
|
|
43
|
+
return this.emitter.emit(event, ...args);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAK3C;;;;;;;;;;GA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getPersonaById, getPersonaOrDefault, } from "./personas.js";
|
|
3
|
+
export { buildParticipantSystemPrompt, buildJudgeSystemPrompt, buildJudgeUserPrompt, formatPreviousResponses, getRoundMeta, } from "./prompts.js";
|
|
4
|
+
export { extractConfidence, extractJudgeConfidence, extractJudgeSection, stripConfidenceLine, } from "./parser.js";
|
|
5
|
+
export { average, stddev, consensusScore, detectDisagreements, shuffle, mulberry32, } from "./stats.js";
|
|
6
|
+
export { TypedEventEmitter } from "./events.js";
|
|
7
|
+
export type { ConsensusEmitter } from "./events.js";
|
|
8
|
+
export { PersonaSchema, ParticipantSchema, PHASES } from "./types.js";
|
|
9
|
+
export type { Persona, Participant, Phase, TokenUsage, ModelCaller, ModelCallRequest, ModelCallResponse, ParticipantResponse, Disagreement, RoundResult, SynthesisResult, ConsensusResult, ConsensusOptions, StopReason, ConsensusEventMap, ConsensusEventName, RoundStartEvent, ParticipantStartEvent, ParticipantTokenEvent, ParticipantCompleteEvent, ConfidenceUpdateEvent, DisagreementDetectedEvent, RoundCompleteEvent, EarlyStopEvent, SynthesisStartEvent, SynthesisTokenEvent, SynthesisCompleteEvent, FinalResultEvent, } from "./types.js";
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElF,OAAO,EACL,QAAQ,EACR,aAAa,EACb,cAAc,EACd,mBAAmB,GACpB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,4BAA4B,EAC5B,sBAAsB,EACtB,oBAAoB,EACpB,uBAAuB,EACvB,YAAY,GACb,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,iBAAiB,EACjB,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,OAAO,EACP,MAAM,EACN,cAAc,EACd,mBAAmB,EACnB,OAAO,EACP,UAAU,GACX,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAGpD,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAGtE,YAAY,EACV,OAAO,EACP,WAAW,EACX,KAAK,EACL,UAAU,EACV,WAAW,EACX,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,YAAY,EACZ,WAAW,EACX,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,UAAU,EAEV,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,qBAAqB,EACrB,qBAAqB,EACrB,wBAAwB,EACxB,qBAAqB,EACrB,yBAAyB,EACzB,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,mBAAmB,EACnB,sBAAsB,EACtB,gBAAgB,GACjB,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// ─────────────────────────────────────────────────────────────
|
|
2
|
+
// ai-consensus-core — public API
|
|
3
|
+
// ─────────────────────────────────────────────────────────────
|
|
4
|
+
export { ConsensusEngine, CONSENSUS_DEFAULTS, MAX_ROUNDS_CAP } from "./engine.js";
|
|
5
|
+
export { PERSONAS, JUDGE_PERSONA, getPersonaById, getPersonaOrDefault, } from "./personas.js";
|
|
6
|
+
export { buildParticipantSystemPrompt, buildJudgeSystemPrompt, buildJudgeUserPrompt, formatPreviousResponses, getRoundMeta, } from "./prompts.js";
|
|
7
|
+
export { extractConfidence, extractJudgeConfidence, extractJudgeSection, stripConfidenceLine, } from "./parser.js";
|
|
8
|
+
export { average, stddev, consensusScore, detectDisagreements, shuffle, mulberry32, } from "./stats.js";
|
|
9
|
+
export { TypedEventEmitter } from "./events.js";
|
|
10
|
+
// Schemas (zod) — exported for callers that want boundary validation.
|
|
11
|
+
export { PersonaSchema, ParticipantSchema, PHASES } from "./types.js";
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,iCAAiC;AACjC,gEAAgE;AAEhE,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElF,OAAO,EACL,QAAQ,EACR,aAAa,EACb,cAAc,EACd,mBAAmB,GACpB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,4BAA4B,EAC5B,sBAAsB,EACtB,oBAAoB,EACpB,uBAAuB,EACvB,YAAY,GACb,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,iBAAiB,EACjB,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,OAAO,EACP,MAAM,EACN,cAAc,EACd,mBAAmB,EACnB,OAAO,EACP,UAAU,GACX,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGhD,sEAAsE;AACtE,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/parser.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extract the trailing `CONFIDENCE: N` value. Clamps to [0, 100] and
|
|
3
|
+
* defaults to 50 when the marker is absent.
|
|
4
|
+
*
|
|
5
|
+
* The default is intentional: an absent marker is a model compliance
|
|
6
|
+
* issue, not a "low-confidence" signal, so we treat it as neutral rather
|
|
7
|
+
* than letting it skew the consensus score downward.
|
|
8
|
+
*/
|
|
9
|
+
export declare function extractConfidence(text: string): number;
|
|
10
|
+
/**
|
|
11
|
+
* Extract the judge's self-reported synthesis confidence. Tolerates both
|
|
12
|
+
* `JUDGE_CONFIDENCE: 87` and `JUDGE_CONFIDENCE: [87]` forms, since the
|
|
13
|
+
* JUDGE_PERSONA prompt wraps the placeholder in brackets.
|
|
14
|
+
*/
|
|
15
|
+
export declare function extractJudgeConfidence(text: string): number;
|
|
16
|
+
/**
|
|
17
|
+
* Extract a named `## Heading`-style section from a judge synthesis.
|
|
18
|
+
* Returns the trimmed section body, or "" if not found.
|
|
19
|
+
*/
|
|
20
|
+
export declare function extractJudgeSection(text: string, heading: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* Strip the trailing `CONFIDENCE: N` line from a body. Used when quoting
|
|
23
|
+
* a participant response back to a downstream model, so the marker from
|
|
24
|
+
* an earlier round doesn't bleed into the next round's parser pass.
|
|
25
|
+
*/
|
|
26
|
+
export declare function stripConfidenceLine(text: string): string;
|
|
27
|
+
//# sourceMappingURL=parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AAOA;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMtD;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAM3D;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAKzE;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAExD"}
|