ai-consensus-core 0.9.0 → 0.11.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/README.md +117 -21
- package/dist/engine.d.ts +3 -1
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +186 -22
- package/dist/engine.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/parser.d.ts +12 -1
- package/dist/parser.d.ts.map +1 -1
- package/dist/parser.js +55 -16
- package/dist/parser.js.map +1 -1
- package/dist/personas.d.ts +0 -6
- package/dist/personas.d.ts.map +1 -1
- package/dist/personas.js +11 -72
- package/dist/personas.js.map +1 -1
- package/dist/types.d.ts +184 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +34 -0
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,iCAAiC;AACjC,gEAAgE;AAEhE,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,iCAAiC;AACjC,gEAAgE;AAEhE,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,uBAAuB,GACxB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C,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,oBAAoB,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/parser.d.ts
CHANGED
|
@@ -1,16 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Extract the trailing `CONFIDENCE: N` value. Clamps to [0, 100] and
|
|
3
|
-
* defaults to 50 when the marker is absent
|
|
3
|
+
* defaults to 50 when the marker is absent or the following value is
|
|
4
|
+
* malformed.
|
|
4
5
|
*
|
|
5
6
|
* The default is intentional: an absent marker is a model compliance
|
|
6
7
|
* issue, not a "low-confidence" signal, so we treat it as neutral rather
|
|
7
8
|
* than letting it skew the consensus score downward.
|
|
9
|
+
*
|
|
10
|
+
* Implemented with linear-time string parsing (no regex, no ReDoS). A
|
|
11
|
+
* prefix with no digits after it yields `parseInt("")` → NaN, which
|
|
12
|
+
* `clampConfidence` collapses to the 50 default — the single invalid-
|
|
13
|
+
* input path.
|
|
8
14
|
*/
|
|
9
15
|
export declare function extractConfidence(text: string): number;
|
|
10
16
|
/**
|
|
11
17
|
* Extract the judge's self-reported synthesis confidence. Tolerates both
|
|
12
18
|
* `JUDGE_CONFIDENCE: 87` and `JUDGE_CONFIDENCE: [87]` forms, since the
|
|
13
19
|
* JUDGE_PERSONA prompt wraps the placeholder in brackets.
|
|
20
|
+
*
|
|
21
|
+
* Implemented with linear-time string parsing (no regex, no ReDoS). A
|
|
22
|
+
* prefix with no digits after it yields `parseInt("")` → NaN, which
|
|
23
|
+
* `clampConfidence` collapses to the 50 default — the single invalid-
|
|
24
|
+
* input path.
|
|
14
25
|
*/
|
|
15
26
|
export declare function extractJudgeConfidence(text: string): number;
|
|
16
27
|
/**
|
package/dist/parser.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AAiBA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CActD;AAED;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAmB3D;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAMzE;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAExD"}
|
package/dist/parser.js
CHANGED
|
@@ -1,38 +1,75 @@
|
|
|
1
1
|
// ─────────────────────────────────────────────────────────────
|
|
2
2
|
// Parser — extractors for confidence and judge sections
|
|
3
3
|
// ─────────────────────────────────────────────────────────────
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
function clampConfidence(n) {
|
|
5
|
+
if (Number.isNaN(n))
|
|
6
|
+
return 50;
|
|
7
|
+
return Math.min(100, Math.max(0, n));
|
|
8
|
+
}
|
|
9
|
+
function isWhitespace(ch) {
|
|
10
|
+
return ch === " " || ch === "\t" || ch === "\n" || ch === "\r" || ch === "\f" || ch === "\v";
|
|
11
|
+
}
|
|
12
|
+
function isDigit(ch) {
|
|
13
|
+
return ch >= "0" && ch <= "9";
|
|
14
|
+
}
|
|
6
15
|
/**
|
|
7
16
|
* Extract the trailing `CONFIDENCE: N` value. Clamps to [0, 100] and
|
|
8
|
-
* defaults to 50 when the marker is absent
|
|
17
|
+
* defaults to 50 when the marker is absent or the following value is
|
|
18
|
+
* malformed.
|
|
9
19
|
*
|
|
10
20
|
* The default is intentional: an absent marker is a model compliance
|
|
11
21
|
* issue, not a "low-confidence" signal, so we treat it as neutral rather
|
|
12
22
|
* than letting it skew the consensus score downward.
|
|
23
|
+
*
|
|
24
|
+
* Implemented with linear-time string parsing (no regex, no ReDoS). A
|
|
25
|
+
* prefix with no digits after it yields `parseInt("")` → NaN, which
|
|
26
|
+
* `clampConfidence` collapses to the 50 default — the single invalid-
|
|
27
|
+
* input path.
|
|
13
28
|
*/
|
|
14
29
|
export function extractConfidence(text) {
|
|
15
|
-
const
|
|
16
|
-
|
|
30
|
+
const lower = text.toLowerCase();
|
|
31
|
+
const prefix = "confidence:";
|
|
32
|
+
const idx = lower.indexOf(prefix);
|
|
33
|
+
if (idx === -1)
|
|
17
34
|
return 50;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
35
|
+
let i = idx + prefix.length;
|
|
36
|
+
while (i < text.length && isWhitespace(text[i]))
|
|
37
|
+
i++;
|
|
38
|
+
const start = i;
|
|
39
|
+
while (i < text.length && isDigit(text[i]))
|
|
40
|
+
i++;
|
|
41
|
+
const n = Number.parseInt(text.slice(start, i), 10);
|
|
42
|
+
return clampConfidence(n);
|
|
22
43
|
}
|
|
23
44
|
/**
|
|
24
45
|
* Extract the judge's self-reported synthesis confidence. Tolerates both
|
|
25
46
|
* `JUDGE_CONFIDENCE: 87` and `JUDGE_CONFIDENCE: [87]` forms, since the
|
|
26
47
|
* JUDGE_PERSONA prompt wraps the placeholder in brackets.
|
|
48
|
+
*
|
|
49
|
+
* Implemented with linear-time string parsing (no regex, no ReDoS). A
|
|
50
|
+
* prefix with no digits after it yields `parseInt("")` → NaN, which
|
|
51
|
+
* `clampConfidence` collapses to the 50 default — the single invalid-
|
|
52
|
+
* input path.
|
|
27
53
|
*/
|
|
28
54
|
export function extractJudgeConfidence(text) {
|
|
29
|
-
const
|
|
30
|
-
|
|
55
|
+
const lower = text.toLowerCase();
|
|
56
|
+
const prefix = "judge_confidence:";
|
|
57
|
+
const idx = lower.indexOf(prefix);
|
|
58
|
+
if (idx === -1)
|
|
31
59
|
return 50;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
60
|
+
let i = idx + prefix.length;
|
|
61
|
+
while (i < text.length && isWhitespace(text[i]))
|
|
62
|
+
i++;
|
|
63
|
+
if (i < text.length && text[i] === "[") {
|
|
64
|
+
i++;
|
|
65
|
+
while (i < text.length && isWhitespace(text[i]))
|
|
66
|
+
i++;
|
|
67
|
+
}
|
|
68
|
+
const start = i;
|
|
69
|
+
while (i < text.length && isDigit(text[i]))
|
|
70
|
+
i++;
|
|
71
|
+
const n = Number.parseInt(text.slice(start, i), 10);
|
|
72
|
+
return clampConfidence(n);
|
|
36
73
|
}
|
|
37
74
|
/**
|
|
38
75
|
* Extract a named `## Heading`-style section from a judge synthesis.
|
|
@@ -42,7 +79,9 @@ export function extractJudgeSection(text, heading) {
|
|
|
42
79
|
const escaped = heading.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
43
80
|
const pattern = new RegExp(`##\\s*${escaped}\\s*\\n([\\s\\S]*?)(?=\\n##\\s|$)`, "i");
|
|
44
81
|
const m = pattern.exec(text);
|
|
45
|
-
|
|
82
|
+
if (!m)
|
|
83
|
+
return "";
|
|
84
|
+
return (m[1] ?? "").trim();
|
|
46
85
|
}
|
|
47
86
|
/**
|
|
48
87
|
* Strip the trailing `CONFIDENCE: N` line from a body. Used when quoting
|
package/dist/parser.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,wDAAwD;AACxD,gEAAgE;AAEhE,MAAM,
|
|
1
|
+
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,wDAAwD;AACxD,gEAAgE;AAEhE,SAAS,eAAe,CAAC,CAAS;IAChC,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QAAE,OAAO,EAAE,CAAC;IAC/B,OAAO,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AAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7B,IAAI,CAAC,CAAC;QAAE,OAAO,EAAE,CAAC;IAClB,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;AAC7B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAY;IAC9C,OAAO,IAAI,CAAC,OAAO,CAAC,0BAA0B,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;AAC7D,CAAC"}
|
package/dist/personas.d.ts
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import type { Persona } from "./types.js";
|
|
2
|
-
export declare const PERSONAS: readonly Persona[];
|
|
3
|
-
/** Look up a persona by id. Returns `undefined` if not found. */
|
|
4
|
-
export declare function getPersonaById(id: string): Persona | undefined;
|
|
5
|
-
/** Look up a persona by id, falling back to the first persona if the id is unknown. */
|
|
6
|
-
export declare function getPersonaOrDefault(id: string): Persona;
|
|
7
2
|
/**
|
|
8
3
|
* The Judge persona — used by the non-voting synthesizer.
|
|
9
|
-
* Not exposed via the participant selector.
|
|
10
4
|
*
|
|
11
5
|
* The output contract is exact: four markdown sections followed by a
|
|
12
6
|
* `JUDGE_CONFIDENCE: [0-100]` line. `parser.extractJudgeSection` and
|
package/dist/personas.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"personas.d.ts","sourceRoot":"","sources":["../src/personas.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"personas.d.ts","sourceRoot":"","sources":["../src/personas.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,EAAE,OA2B3B,CAAC"}
|
package/dist/personas.js
CHANGED
|
@@ -1,79 +1,18 @@
|
|
|
1
1
|
// ─────────────────────────────────────────────────────────────
|
|
2
|
-
//
|
|
2
|
+
// Judge persona — the only persona shipped by the library
|
|
3
3
|
// ─────────────────────────────────────────────────────────────
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
description: "Identifies risks, failure modes, tail risks, and worst-case scenarios",
|
|
15
|
-
systemPrompt: `You are a rigorous Risk Analyst. Your role is to surface hidden dangers, second-order effects, tail risks, and plausible failure modes. You are not cynical — you are protective. Be precise, evidence-based, and constructive. Highlight what could go wrong and why, so the group can make more robust decisions.`,
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
id: "first-principles",
|
|
19
|
-
name: "First-Principles Engineer",
|
|
20
|
-
emoji: "⚙️",
|
|
21
|
-
color: "#3b82f6",
|
|
22
|
-
description: "Breaks every claim down to fundamental truths and reasons from the ground up",
|
|
23
|
-
systemPrompt: `You are a First-Principles Engineer. Ruthlessly decompose every claim into its most fundamental axioms. Reject analogies and conventional wisdom. Question every assumption. Structure your thinking clearly and expose hidden premises that others are taking for granted.`,
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
id: "vc-specialist",
|
|
27
|
-
name: "VC Funds Specialist",
|
|
28
|
-
emoji: "💰",
|
|
29
|
-
color: "#10b981",
|
|
30
|
-
description: "Evaluates through market dynamics, scalability, moats, and investment viability",
|
|
31
|
-
systemPrompt: `You are a battle-tested Venture Capital Specialist. Analyze everything through the lens of market opportunity, scalable business models, competitive moats, unit economics, network effects, and capital efficiency. Think in terms of TAM/SAM/SOM, defensibility, and long-term value creation.`,
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
id: "scientific-skeptic",
|
|
35
|
-
name: "Scientific Skeptic",
|
|
36
|
-
emoji: "🔬",
|
|
37
|
-
color: "#f59e0b",
|
|
38
|
-
description: "Demands rigorous evidence and applies scientific scrutiny to every claim",
|
|
39
|
-
systemPrompt: `You are a Scientific Skeptic. Demand high-quality evidence for every assertion. Question methodology, sample size, selection bias, statistical power, and reproducibility. Distinguish correlation from causation. Call out logical fallacies and over-extrapolation without mercy.`,
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
id: "optimistic-futurist",
|
|
43
|
-
name: "Optimistic Futurist",
|
|
44
|
-
emoji: "🚀",
|
|
45
|
-
color: "#8b5cf6",
|
|
46
|
-
description: "Sees transformative potential and identifies exponential upside opportunities",
|
|
47
|
-
systemPrompt: `You are an Optimistic Futurist. Identify exponential trends, paradigm shifts, and breakthrough opportunities. Paint compelling visions of positive futures while remaining grounded. Focus on how obstacles can be overcome and how the idea could scale into something transformative.`,
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
id: "devils-advocate",
|
|
51
|
-
name: "Devil's Advocate",
|
|
52
|
-
emoji: "⚖️",
|
|
53
|
-
color: "#ec4899",
|
|
54
|
-
description: "Stress-tests ideas by arguing the strongest possible counter-position",
|
|
55
|
-
systemPrompt: `You are the Devil's Advocate. Your job is to construct the strongest possible counter-arguments to whatever position is emerging. Do this constructively — not to win, but to expose weaknesses and make the final consensus more robust. Be sharp, logical, and relentless.`,
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
id: "domain-expert",
|
|
59
|
-
name: "Domain Expert",
|
|
60
|
-
emoji: "🧠",
|
|
61
|
-
color: "#06b6d4",
|
|
62
|
-
description: "Brings deep technical and practical implementation knowledge with concrete examples",
|
|
63
|
-
systemPrompt: `You are a seasoned Domain Expert with years of hands-on experience. Ground your analysis in real-world implementation details, known patterns, anti-patterns, edge cases, and practical constraints. Be specific, cite concrete examples, and provide reality-checks that only deep domain knowledge can offer.`,
|
|
64
|
-
},
|
|
65
|
-
];
|
|
66
|
-
/** Look up a persona by id. Returns `undefined` if not found. */
|
|
67
|
-
export function getPersonaById(id) {
|
|
68
|
-
return PERSONAS.find((p) => p.id === id);
|
|
69
|
-
}
|
|
70
|
-
/** Look up a persona by id, falling back to the first persona if the id is unknown. */
|
|
71
|
-
export function getPersonaOrDefault(id) {
|
|
72
|
-
return getPersonaById(id) ?? PERSONAS[0];
|
|
73
|
-
}
|
|
4
|
+
// The seven debate personas that used to live here were moved to
|
|
5
|
+
// `docs/personas.md` as a copy-paste reference. They're opinionated
|
|
6
|
+
// content, not mechanics — the engine never read from them, so
|
|
7
|
+
// bundling them into the library's public API added weight without
|
|
8
|
+
// benefit. Callers construct their own `Persona` objects.
|
|
9
|
+
//
|
|
10
|
+
// JUDGE_PERSONA stays in code because its system prompt is coupled
|
|
11
|
+
// to the parser's output contract (`extractJudgeSection` /
|
|
12
|
+
// `extractJudgeConfidence`) and serves as the engine's runtime
|
|
13
|
+
// default when `ConsensusOptions.judge.systemPrompt` is omitted.
|
|
74
14
|
/**
|
|
75
15
|
* The Judge persona — used by the non-voting synthesizer.
|
|
76
|
-
* Not exposed via the participant selector.
|
|
77
16
|
*
|
|
78
17
|
* The output contract is exact: four markdown sections followed by a
|
|
79
18
|
* `JUDGE_CONFIDENCE: [0-100]` line. `parser.extractJudgeSection` and
|
package/dist/personas.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"personas.js","sourceRoot":"","sources":["../src/personas.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,
|
|
1
|
+
{"version":3,"file":"personas.js","sourceRoot":"","sources":["../src/personas.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,0DAA0D;AAC1D,gEAAgE;AAChE,iEAAiE;AACjE,oEAAoE;AACpE,+DAA+D;AAC/D,mEAAmE;AACnE,0DAA0D;AAC1D,EAAE;AACF,mEAAmE;AACnE,2DAA2D;AAC3D,+DAA+D;AAC/D,iEAAiE;AAIjE;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,aAAa,GAAY;IACpC,EAAE,EAAE,OAAO;IACX,IAAI,EAAE,iBAAiB;IACvB,KAAK,EAAE,IAAI;IACX,KAAK,EAAE,SAAS;IAChB,WAAW,EACT,wEAAwE;IAC1E,YAAY,EAAE;;;;;;;;;;;;;;;;;;;kFAmBkE;CACjF,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -48,6 +48,30 @@ export declare const ParticipantSchema: z.ZodObject<{
|
|
|
48
48
|
color?: string | undefined;
|
|
49
49
|
}>;
|
|
50
50
|
label: z.ZodOptional<z.ZodString>;
|
|
51
|
+
/**
|
|
52
|
+
* Tools this participant is allowed to invoke during its turn. The library
|
|
53
|
+
* forwards the list to the ModelCaller verbatim — semantics (dispatch,
|
|
54
|
+
* loop, error handling) live in the engine when `ConsensusOptions.toolExecutor`
|
|
55
|
+
* is provided. Empty/undefined ⇒ classic text-only debate (0.10 behaviour).
|
|
56
|
+
*/
|
|
57
|
+
tools: z.ZodOptional<z.ZodArray<z.ZodLazy<z.ZodObject<{
|
|
58
|
+
name: z.ZodString;
|
|
59
|
+
description: z.ZodString;
|
|
60
|
+
/**
|
|
61
|
+
* JSON Schema (object). The library does not validate or interpret the
|
|
62
|
+
* schema — it forwards verbatim to the ModelCaller, which is responsible
|
|
63
|
+
* for translating it into whatever the underlying provider expects.
|
|
64
|
+
*/
|
|
65
|
+
parameters: z.ZodUnknown;
|
|
66
|
+
}, "strip", z.ZodTypeAny, {
|
|
67
|
+
name: string;
|
|
68
|
+
description: string;
|
|
69
|
+
parameters?: unknown;
|
|
70
|
+
}, {
|
|
71
|
+
name: string;
|
|
72
|
+
description: string;
|
|
73
|
+
parameters?: unknown;
|
|
74
|
+
}>>, "many">>;
|
|
51
75
|
}, "strip", z.ZodTypeAny, {
|
|
52
76
|
id: string;
|
|
53
77
|
modelId: string;
|
|
@@ -60,6 +84,11 @@ export declare const ParticipantSchema: z.ZodObject<{
|
|
|
60
84
|
color?: string | undefined;
|
|
61
85
|
};
|
|
62
86
|
label?: string | undefined;
|
|
87
|
+
tools?: {
|
|
88
|
+
name: string;
|
|
89
|
+
description: string;
|
|
90
|
+
parameters?: unknown;
|
|
91
|
+
}[] | undefined;
|
|
63
92
|
}, {
|
|
64
93
|
id: string;
|
|
65
94
|
modelId: string;
|
|
@@ -72,6 +101,11 @@ export declare const ParticipantSchema: z.ZodObject<{
|
|
|
72
101
|
color?: string | undefined;
|
|
73
102
|
};
|
|
74
103
|
label?: string | undefined;
|
|
104
|
+
tools?: {
|
|
105
|
+
name: string;
|
|
106
|
+
description: string;
|
|
107
|
+
parameters?: unknown;
|
|
108
|
+
}[] | undefined;
|
|
75
109
|
}>;
|
|
76
110
|
export type Participant = z.infer<typeof ParticipantSchema>;
|
|
77
111
|
export declare const PHASES: readonly ["initial-analysis", "counterarguments", "evidence-assessment", "synthesis"];
|
|
@@ -81,6 +115,68 @@ export interface TokenUsage {
|
|
|
81
115
|
outputTokens: number;
|
|
82
116
|
totalTokens: number;
|
|
83
117
|
}
|
|
118
|
+
/** OpenAI-style tool definition (function-call shape). */
|
|
119
|
+
export declare const ToolDefinitionSchema: z.ZodObject<{
|
|
120
|
+
name: z.ZodString;
|
|
121
|
+
description: z.ZodString;
|
|
122
|
+
/**
|
|
123
|
+
* JSON Schema (object). The library does not validate or interpret the
|
|
124
|
+
* schema — it forwards verbatim to the ModelCaller, which is responsible
|
|
125
|
+
* for translating it into whatever the underlying provider expects.
|
|
126
|
+
*/
|
|
127
|
+
parameters: z.ZodUnknown;
|
|
128
|
+
}, "strip", z.ZodTypeAny, {
|
|
129
|
+
name: string;
|
|
130
|
+
description: string;
|
|
131
|
+
parameters?: unknown;
|
|
132
|
+
}, {
|
|
133
|
+
name: string;
|
|
134
|
+
description: string;
|
|
135
|
+
parameters?: unknown;
|
|
136
|
+
}>;
|
|
137
|
+
export type ToolDefinition = z.infer<typeof ToolDefinitionSchema>;
|
|
138
|
+
/** A tool-call request emitted by an assistant turn. */
|
|
139
|
+
export interface ToolCall {
|
|
140
|
+
/** Unique id assigned by the model — round-trip back in tool results. */
|
|
141
|
+
id: string;
|
|
142
|
+
/** Tool name; must match a `ToolDefinition.name` from the request. */
|
|
143
|
+
name: string;
|
|
144
|
+
/**
|
|
145
|
+
* Already JSON-parsed arguments. Callers MUST parse the model's raw
|
|
146
|
+
* argument string before populating this; the library never parses.
|
|
147
|
+
*/
|
|
148
|
+
arguments: unknown;
|
|
149
|
+
}
|
|
150
|
+
/** Result of executing a tool call. Either a content string or an error. */
|
|
151
|
+
export type ToolExecutionResult = {
|
|
152
|
+
content: string;
|
|
153
|
+
} | {
|
|
154
|
+
error: string;
|
|
155
|
+
};
|
|
156
|
+
/**
|
|
157
|
+
* One turn of tool-call dispatch. The engine appends one entry per iteration
|
|
158
|
+
* of the tool loop, in order, and forwards the accumulated history on each
|
|
159
|
+
* follow-up `ModelCallRequest`.
|
|
160
|
+
*/
|
|
161
|
+
export interface ToolCallTurn {
|
|
162
|
+
/** The tool calls the assistant requested in this turn. */
|
|
163
|
+
toolCalls: readonly ToolCall[];
|
|
164
|
+
/** Results, in the same order as `toolCalls`. */
|
|
165
|
+
toolResults: readonly ToolExecutionResult[];
|
|
166
|
+
}
|
|
167
|
+
/** Context passed to the host's `ToolExecutor` so it knows what's running. */
|
|
168
|
+
export interface ToolCallContext {
|
|
169
|
+
participantId: string;
|
|
170
|
+
round: number;
|
|
171
|
+
phase: Phase;
|
|
172
|
+
signal?: AbortSignal;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Host-supplied tool executor. The engine awaits this once per tool call.
|
|
176
|
+
* Throw on unrecoverable errors; return `{ error }` to feed an error string
|
|
177
|
+
* back into the conversation as a normal tool result (model can recover).
|
|
178
|
+
*/
|
|
179
|
+
export type ToolExecutor = (call: ToolCall, ctx: ToolCallContext) => Promise<ToolExecutionResult>;
|
|
84
180
|
export interface ModelCallRequest {
|
|
85
181
|
/** Participant that originated the request, or "judge" for the synthesizer. */
|
|
86
182
|
participantId: string;
|
|
@@ -102,12 +198,40 @@ export interface ModelCallRequest {
|
|
|
102
198
|
signal?: AbortSignal;
|
|
103
199
|
/** Optional streaming sink; callers MAY call this with partial tokens. */
|
|
104
200
|
onToken?: (token: string) => void;
|
|
201
|
+
/**
|
|
202
|
+
* Tools available for this turn. Forwarded verbatim from `Participant.tools`
|
|
203
|
+
* (and only for participant calls — judge calls never carry tools). Absent
|
|
204
|
+
* when the participant declares no tools.
|
|
205
|
+
*/
|
|
206
|
+
tools?: readonly ToolDefinition[];
|
|
207
|
+
/**
|
|
208
|
+
* Tool-call history for this single participant turn, populated by the
|
|
209
|
+
* engine when re-invoking the caller after dispatching tool calls. Each
|
|
210
|
+
* entry is one round-trip through the tool loop. Absent on the first call
|
|
211
|
+
* of a turn.
|
|
212
|
+
*
|
|
213
|
+
* Callers MUST translate this into whatever the provider expects (e.g.
|
|
214
|
+
* for OpenAI, append assistant + tool messages to the conversation).
|
|
215
|
+
*/
|
|
216
|
+
toolCallTurns?: readonly ToolCallTurn[];
|
|
105
217
|
}
|
|
106
218
|
export interface ModelCallResponse {
|
|
107
219
|
/** Full assistant content, including the trailing `CONFIDENCE: N` line. */
|
|
108
220
|
content: string;
|
|
109
221
|
/** Optional token usage, if the provider surfaces it. */
|
|
110
222
|
usage?: TokenUsage;
|
|
223
|
+
/**
|
|
224
|
+
* Tool calls the model wants to dispatch this turn. If non-empty AND the
|
|
225
|
+
* engine has a `toolExecutor`, the engine runs each call and re-invokes
|
|
226
|
+
* the caller with the results in `ModelCallRequest.toolCallTurns`. If empty
|
|
227
|
+
* or absent, the engine treats `content` as the participant's final turn.
|
|
228
|
+
*
|
|
229
|
+
* If the engine has no `toolExecutor` configured but the response carries
|
|
230
|
+
* `toolCalls`, they are ignored and `content` is used as-is — preserves
|
|
231
|
+
* 0.10 backward compatibility for callers that opt into tool streaming
|
|
232
|
+
* but don't wire an executor.
|
|
233
|
+
*/
|
|
234
|
+
toolCalls?: readonly ToolCall[];
|
|
111
235
|
}
|
|
112
236
|
export type ModelCaller = (request: ModelCallRequest) => Promise<ModelCallResponse>;
|
|
113
237
|
export interface ParticipantResponse {
|
|
@@ -216,11 +340,40 @@ export interface ConsensusOptions {
|
|
|
216
340
|
temperature?: number;
|
|
217
341
|
/** Max output tokens for judge. Defaults to 1500. */
|
|
218
342
|
maxOutputTokens?: number;
|
|
343
|
+
/**
|
|
344
|
+
* Override the judge system prompt. Defaults to `JUDGE_PERSONA.systemPrompt`.
|
|
345
|
+
*
|
|
346
|
+
* Contract: the override must instruct the model to emit the same four
|
|
347
|
+
* `## Majority Position` / `## Minority Positions` / `## Unresolved Disputes`
|
|
348
|
+
* / `## Synthesis Confidence` headings and a trailing `JUDGE_CONFIDENCE: N`
|
|
349
|
+
* line. `extractJudgeSection` and `extractJudgeConfidence` key off those
|
|
350
|
+
* markers — break the contract and the corresponding fields on
|
|
351
|
+
* `SynthesisResult` will come back empty / default to 50.
|
|
352
|
+
*/
|
|
353
|
+
systemPrompt?: string;
|
|
219
354
|
};
|
|
220
355
|
/** Non-negative integer. If set, uses a seeded PRNG so round-order randomization is deterministic. */
|
|
221
356
|
randomSeed?: number;
|
|
222
357
|
/** Propagates cancellation to every ModelCaller and aborts the loop. */
|
|
223
358
|
signal?: AbortSignal;
|
|
359
|
+
/**
|
|
360
|
+
* Host-supplied tool executor. When set, the engine drives the tool-call
|
|
361
|
+
* loop for participants whose `tools` list is non-empty: dispatches each
|
|
362
|
+
* `ToolCall` returned by the model, feeds results back via
|
|
363
|
+
* `ModelCallRequest.toolCallTurns`, and emits `toolCallStart` /
|
|
364
|
+
* `toolCallComplete` / `toolError` events.
|
|
365
|
+
*
|
|
366
|
+
* When omitted, the engine ignores any `toolCalls` in `ModelCallResponse`
|
|
367
|
+
* and treats `content` as the participant's final turn — exact 0.10 behaviour.
|
|
368
|
+
*/
|
|
369
|
+
toolExecutor?: ToolExecutor;
|
|
370
|
+
/**
|
|
371
|
+
* Maximum tool-loop iterations per participant turn. After this many
|
|
372
|
+
* round-trips through the executor, the engine breaks out and uses the
|
|
373
|
+
* last response's `content` as the participant's turn — even if the model
|
|
374
|
+
* still wants to call more tools. Defaults to 8. Bounded to [1, 32].
|
|
375
|
+
*/
|
|
376
|
+
maxToolIterations?: number;
|
|
224
377
|
}
|
|
225
378
|
export interface RoundStartEvent {
|
|
226
379
|
round: number;
|
|
@@ -284,6 +437,34 @@ export interface SynthesisCompleteEvent {
|
|
|
284
437
|
export interface FinalResultEvent {
|
|
285
438
|
result: ConsensusResult;
|
|
286
439
|
}
|
|
440
|
+
export interface ToolCallStartEvent {
|
|
441
|
+
participantId: string;
|
|
442
|
+
round: number;
|
|
443
|
+
phase: Phase;
|
|
444
|
+
/** 1-based iteration counter within this participant's tool loop. */
|
|
445
|
+
iteration: number;
|
|
446
|
+
call: ToolCall;
|
|
447
|
+
}
|
|
448
|
+
export interface ToolCallCompleteEvent {
|
|
449
|
+
participantId: string;
|
|
450
|
+
round: number;
|
|
451
|
+
phase: Phase;
|
|
452
|
+
iteration: number;
|
|
453
|
+
call: ToolCall;
|
|
454
|
+
durationMs: number;
|
|
455
|
+
/** True when the executor returned `{ content }`; false when it returned `{ error }`. */
|
|
456
|
+
ok: boolean;
|
|
457
|
+
/** Truncated preview of the result payload (first 200 chars). */
|
|
458
|
+
preview: string;
|
|
459
|
+
}
|
|
460
|
+
export interface ToolErrorEvent {
|
|
461
|
+
participantId: string;
|
|
462
|
+
round: number;
|
|
463
|
+
phase: Phase;
|
|
464
|
+
iteration: number;
|
|
465
|
+
call: ToolCall;
|
|
466
|
+
error: string;
|
|
467
|
+
}
|
|
287
468
|
export interface ConsensusEventMap {
|
|
288
469
|
roundStart: (event: RoundStartEvent) => void;
|
|
289
470
|
participantStart: (event: ParticipantStartEvent) => void;
|
|
@@ -297,6 +478,9 @@ export interface ConsensusEventMap {
|
|
|
297
478
|
synthesisToken: (event: SynthesisTokenEvent) => void;
|
|
298
479
|
synthesisComplete: (event: SynthesisCompleteEvent) => void;
|
|
299
480
|
finalResult: (event: FinalResultEvent) => void;
|
|
481
|
+
toolCallStart: (event: ToolCallStartEvent) => void;
|
|
482
|
+
toolCallComplete: (event: ToolCallCompleteEvent) => void;
|
|
483
|
+
toolError: (event: ToolErrorEvent) => void;
|
|
300
484
|
error: (error: Error) => void;
|
|
301
485
|
}
|
|
302
486
|
export type ConsensusEventName = keyof ConsensusEventMap;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;EAOxB,CAAC;AAEH,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAMpD,eAAO,MAAM,iBAAiB
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;EAOxB,CAAC;AAEH,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAMpD,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;IAK5B;;;;;OAKG;;;;QAkDH;;;;WAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EApDH,CAAC;AAEH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAM5D,eAAO,MAAM,MAAM,uFAKT,CAAC;AAEX,MAAM,MAAM,KAAK,GAAG,CAAC,OAAO,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC;AAM5C,MAAM,WAAW,UAAU;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;CACrB;AAmBD,0DAA0D;AAC1D,eAAO,MAAM,oBAAoB;;;IAG/B;;;;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I,CAAC;IACzD,mBAAmB,EAAE,CAAC,KAAK,EAAE,wBAAwB,KAAK,IAAI,CAAC;IAC/D,gBAAgB,EAAE,CAAC,KAAK,EAAE,qBAAqB,KAAK,IAAI,CAAC;IACzD,oBAAoB,EAAE,CAAC,KAAK,EAAE,yBAAyB,KAAK,IAAI,CAAC;IACjE,aAAa,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI,CAAC;IACnD,SAAS,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;IAC3C,cAAc,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,IAAI,CAAC;IACrD,cAAc,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,IAAI,CAAC;IACrD,iBAAiB,EAAE,CAAC,KAAK,EAAE,sBAAsB,KAAK,IAAI,CAAC;IAC3D,WAAW,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAC/C,aAAa,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI,CAAC;IACnD,gBAAgB,EAAE,CAAC,KAAK,EAAE,qBAAqB,KAAK,IAAI,CAAC;IACzD,SAAS,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;IAC3C,KAAK,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAC/B;AAED,MAAM,MAAM,kBAAkB,GAAG,MAAM,iBAAiB,CAAC"}
|
package/dist/types.js
CHANGED
|
@@ -18,6 +18,13 @@ export const ParticipantSchema = z.object({
|
|
|
18
18
|
modelId: z.string().min(1),
|
|
19
19
|
persona: PersonaSchema,
|
|
20
20
|
label: z.string().optional(),
|
|
21
|
+
/**
|
|
22
|
+
* Tools this participant is allowed to invoke during its turn. The library
|
|
23
|
+
* forwards the list to the ModelCaller verbatim — semantics (dispatch,
|
|
24
|
+
* loop, error handling) live in the engine when `ConsensusOptions.toolExecutor`
|
|
25
|
+
* is provided. Empty/undefined ⇒ classic text-only debate (0.10 behaviour).
|
|
26
|
+
*/
|
|
27
|
+
tools: z.array(z.lazy(() => ToolDefinitionSchema)).optional(),
|
|
21
28
|
});
|
|
22
29
|
// ─────────────────────────────────────────────────────────────
|
|
23
30
|
// Phases
|
|
@@ -28,4 +35,31 @@ export const PHASES = [
|
|
|
28
35
|
"evidence-assessment",
|
|
29
36
|
"synthesis",
|
|
30
37
|
];
|
|
38
|
+
// ─────────────────────────────────────────────────────────────
|
|
39
|
+
// Tool calling
|
|
40
|
+
// ─────────────────────────────────────────────────────────────
|
|
41
|
+
// Engine-orchestrated tool calling sits between the ModelCaller and the
|
|
42
|
+
// host. The library never parses tool arguments, never invokes a tool, and
|
|
43
|
+
// never decides what tools a participant has — it just plumbs:
|
|
44
|
+
//
|
|
45
|
+
// 1. `Participant.tools` flows into each `ModelCallRequest.tools`.
|
|
46
|
+
// 2. If the response carries `toolCalls`, the engine dispatches each one
|
|
47
|
+
// to `ConsensusOptions.toolExecutor` (host-supplied) and feeds results
|
|
48
|
+
// back into a follow-up call via `ModelCallRequest.toolCallTurns`.
|
|
49
|
+
// 3. The loop terminates when the model returns a response with no
|
|
50
|
+
// `toolCalls`, or when `maxToolIterations` is hit.
|
|
51
|
+
//
|
|
52
|
+
// Hosts that don't supply a `toolExecutor` see no behaviour change — every
|
|
53
|
+
// new field is optional and the engine's flow degrades to 0.10 verbatim.
|
|
54
|
+
/** OpenAI-style tool definition (function-call shape). */
|
|
55
|
+
export const ToolDefinitionSchema = z.object({
|
|
56
|
+
name: z.string().min(1),
|
|
57
|
+
description: z.string(),
|
|
58
|
+
/**
|
|
59
|
+
* JSON Schema (object). The library does not validate or interpret the
|
|
60
|
+
* schema — it forwards verbatim to the ModelCaller, which is responsible
|
|
61
|
+
* for translating it into whatever the underlying provider expects.
|
|
62
|
+
*/
|
|
63
|
+
parameters: z.unknown(),
|
|
64
|
+
});
|
|
31
65
|
//# sourceMappingURL=types.js.map
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,gEAAgE;AAChE,UAAU;AACV,gEAAgE;AAEhE,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC;IACpC,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACrB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACvB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC5B,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC5B,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;IACvB,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CAChC,CAAC,CAAC;AAIH,gEAAgE;AAChE,cAAc;AACd,gEAAgE;AAEhE,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC;IACxC,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACrB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC1B,OAAO,EAAE,aAAa;IACtB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,gEAAgE;AAChE,UAAU;AACV,gEAAgE;AAEhE,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC;IACpC,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC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AM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3C,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACvB,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;IACvB;;;;OAIG;IACH,UAAU,EAAE,CAAC,CAAC,OAAO,EAAE;CACxB,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ai-consensus-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "Dependency-light TypeScript implementation of the Consensus Validation Protocol (CVP): multi-model debate with confidence-weighted scoring, disagreement detection, and optional judge synthesis.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"consensus",
|