@manya-os/council 1.0.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/CHANGELOG.md +21 -0
- package/LICENSE +21 -0
- package/README.md +244 -0
- package/dist/cjs/index.js +4 -0
- package/dist/cjs/index.js.map +6 -0
- package/dist/cjs/package.json +1 -0
- package/dist/esm/index.mjs +4 -0
- package/dist/esm/index.mjs.map +6 -0
- package/dist/esm/package.json +1 -0
- package/dist/types/analysis/analysis.d.ts +53 -0
- package/dist/types/analysis/analysis.d.ts.map +1 -0
- package/dist/types/analysis/index.d.ts +8 -0
- package/dist/types/analysis/index.d.ts.map +1 -0
- package/dist/types/conflict/conflict.d.ts +63 -0
- package/dist/types/conflict/conflict.d.ts.map +1 -0
- package/dist/types/conflict/index.d.ts +8 -0
- package/dist/types/conflict/index.d.ts.map +1 -0
- package/dist/types/consensus/consensus.d.ts +72 -0
- package/dist/types/consensus/consensus.d.ts.map +1 -0
- package/dist/types/consensus/index.d.ts +9 -0
- package/dist/types/consensus/index.d.ts.map +1 -0
- package/dist/types/debate/debate.d.ts +75 -0
- package/dist/types/debate/debate.d.ts.map +1 -0
- package/dist/types/debate/index.d.ts +8 -0
- package/dist/types/debate/index.d.ts.map +1 -0
- package/dist/types/errors.d.ts +44 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/index.d.ts +42 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/logging.d.ts +40 -0
- package/dist/types/logging.d.ts.map +1 -0
- package/dist/types/minority/index.d.ts +8 -0
- package/dist/types/minority/index.d.ts.map +1 -0
- package/dist/types/minority/minority.d.ts +54 -0
- package/dist/types/minority/minority.d.ts.map +1 -0
- package/dist/types/reports/index.d.ts +9 -0
- package/dist/types/reports/index.d.ts.map +1 -0
- package/dist/types/reports/reports.d.ts +52 -0
- package/dist/types/reports/reports.d.ts.map +1 -0
- package/dist/types/router/index.d.ts +9 -0
- package/dist/types/router/index.d.ts.map +1 -0
- package/dist/types/router/router.d.ts +76 -0
- package/dist/types/router/router.d.ts.map +1 -0
- package/dist/types/scoring/index.d.ts +9 -0
- package/dist/types/scoring/index.d.ts.map +1 -0
- package/dist/types/scoring/scoring.d.ts +65 -0
- package/dist/types/scoring/scoring.d.ts.map +1 -0
- package/dist/types/synthesizer/index.d.ts +9 -0
- package/dist/types/synthesizer/index.d.ts.map +1 -0
- package/dist/types/synthesizer/synthesizer.d.ts +54 -0
- package/dist/types/synthesizer/synthesizer.d.ts.map +1 -0
- package/dist/types/types.d.ts +246 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/util.d.ts +45 -0
- package/dist/types/util.d.ts.map +1 -0
- package/package.json +48 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @manya-os/council — specialist routing.
|
|
3
|
+
*
|
|
4
|
+
* The router matches a {@link Problem} against a pool of {@link Specialist}s
|
|
5
|
+
* by computing a Jaccard-style token-overlap score between the problem's
|
|
6
|
+
* description+domain and each specialist's `expertise` tags. The free
|
|
7
|
+
* function `route(problem, specialists)` returns the specialists with
|
|
8
|
+
* positive match scores, sorted best-first; `routeAll` returns every
|
|
9
|
+
* specialist along with its score.
|
|
10
|
+
*
|
|
11
|
+
* The {@link SpecialistRegistry} is a stateful convenience wrapper that owns a
|
|
12
|
+
* pool of specialists and exposes `route(problem)` / `routeAll(problem)`.
|
|
13
|
+
*
|
|
14
|
+
* Copyright 2024 Manya Hael Foundation. All rights reserved.
|
|
15
|
+
* Licensed under the Apache License, Version 2.0.
|
|
16
|
+
*/
|
|
17
|
+
import type { Problem, Specialist } from '../types.js';
|
|
18
|
+
/** A specialist paired with its match score against a problem. */
|
|
19
|
+
export interface SpecialistMatch {
|
|
20
|
+
/** The specialist. */
|
|
21
|
+
specialist: Specialist;
|
|
22
|
+
/** Match score in `[0, 1]`. `0` means no overlap. */
|
|
23
|
+
score: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Validates a specialist structurally. Throws `RoutingError` on invalid fields.
|
|
27
|
+
*/
|
|
28
|
+
export declare function validateSpecialist(specialist: Specialist): void;
|
|
29
|
+
/**
|
|
30
|
+
* Computes a match score for `problem` against `specialist`. The score is the
|
|
31
|
+
* Jaccard similarity between the problem's description+domain tokens and the
|
|
32
|
+
* specialist's expertise tokens. Returns `0` when either side has no tokens.
|
|
33
|
+
*/
|
|
34
|
+
export declare function matchScore(problem: Problem, specialist: Specialist): number;
|
|
35
|
+
/**
|
|
36
|
+
* Returns the ranked list of specialists with positive match scores against
|
|
37
|
+
* `problem`, sorted best-first. Specialists with no overlap are excluded.
|
|
38
|
+
* Ties are broken by descending `weight`, then by registration order.
|
|
39
|
+
*/
|
|
40
|
+
export declare function route(problem: Problem, specialists: Specialist[]): Specialist[];
|
|
41
|
+
/**
|
|
42
|
+
* Returns every specialist paired with its match score, sorted best-first.
|
|
43
|
+
* Includes specialists with a score of `0`.
|
|
44
|
+
*/
|
|
45
|
+
export declare function routeAll(problem: Problem, specialists: Specialist[]): SpecialistMatch[];
|
|
46
|
+
/**
|
|
47
|
+
* Stateful registry of specialists. Callers `register` specialists, then use
|
|
48
|
+
* `route(problem)` to get the ranked list, or `routeAll(problem)` to get the
|
|
49
|
+
* ranked list with scores.
|
|
50
|
+
*
|
|
51
|
+
* Usage:
|
|
52
|
+
* ```ts
|
|
53
|
+
* const registry = new SpecialistRegistry()
|
|
54
|
+
* .register({ id: 'sec', name: 'Security', expertise: ['security', 'crypto'], weight: 1 })
|
|
55
|
+
* .register({ id: 'fin', name: 'Finance', expertise: ['finance', 'audit'], weight: 1 });
|
|
56
|
+
* const ranked = registry.route({ id: 'p1', description: 'audit the crypto', domain: 'security', createdAt: '' });
|
|
57
|
+
* // ranked = [sec, fin] (sec scores higher on 'crypto'/'security')
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export declare class SpecialistRegistry {
|
|
61
|
+
private readonly specialists;
|
|
62
|
+
private readonly order;
|
|
63
|
+
/** Registers a specialist. Throws `RoutingError` on duplicate id or invalid fields. */
|
|
64
|
+
register(specialist: Specialist): this;
|
|
65
|
+
/** Removes a specialist by id. No-op if not found. */
|
|
66
|
+
unregister(id: string): this;
|
|
67
|
+
/** Returns the specialist with the given id, or `undefined`. */
|
|
68
|
+
get(id: string): Specialist | undefined;
|
|
69
|
+
/** Returns all registered specialists in insertion order. */
|
|
70
|
+
list(): Specialist[];
|
|
71
|
+
/** Returns the ranked list of specialists with positive match scores. */
|
|
72
|
+
route(problem: Problem): Specialist[];
|
|
73
|
+
/** Returns every specialist with its match score, sorted best-first. */
|
|
74
|
+
routeAll(problem: Problem): SpecialistMatch[];
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=router.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../../src/router/router.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAIvD,kEAAkE;AAClE,MAAM,WAAW,eAAe;IAC9B,sBAAsB;IACtB,UAAU,EAAE,UAAU,CAAC;IACvB,qDAAqD;IACrD,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI,CAqB/D;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,GAAG,MAAM,CAkB3E;AAED;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,GAAG,UAAU,EAAE,CAkB/E;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,GAAG,eAAe,EAAE,CAiBvF;AAED;;;;;;;;;;;;;GAaG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAiC;IAC7D,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAgB;IAEtC,uFAAuF;IACvF,QAAQ,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI;IAUtC,sDAAsD;IACtD,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAO5B,gEAAgE;IAChE,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS;IAIvC,6DAA6D;IAC7D,IAAI,IAAI,UAAU,EAAE;IAIpB,yEAAyE;IACzE,KAAK,CAAC,OAAO,EAAE,OAAO,GAAG,UAAU,EAAE;IAIrC,wEAAwE;IACxE,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,eAAe,EAAE;CAG9C"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @manya-os/council — scoring barrel.
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2024 Manya Hael Foundation. All rights reserved.
|
|
5
|
+
* Licensed under the Apache License, Version 2.0.
|
|
6
|
+
*/
|
|
7
|
+
export { scoreAnalysis, aggregateScores, detectOutliers, DEFAULT_OUTLIER_THRESHOLD, } from './scoring.js';
|
|
8
|
+
export type { WeightedScore, AggregatedScore } from './scoring.js';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/scoring/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,aAAa,EAAE,eAAe,EAAE,cAAc,EAAE,yBAAyB,GAC1E,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @manya-os/council — weighted confidence scoring.
|
|
3
|
+
*
|
|
4
|
+
* Provides three free functions:
|
|
5
|
+
*
|
|
6
|
+
* - `scoreAnalysis(analysis, specialistWeight)` returns a single weighted
|
|
7
|
+
* score (`confidence × weight`).
|
|
8
|
+
* - `aggregateScores(analyses, weights)` returns the weighted mean of all
|
|
9
|
+
* confidences plus the variance and standard deviation of the raw
|
|
10
|
+
* confidences (so callers can gauge dispersion).
|
|
11
|
+
* - `detectOutliers(analyses, threshold)` returns analyses whose confidence
|
|
12
|
+
* deviates from the median by more than `threshold`.
|
|
13
|
+
*
|
|
14
|
+
* Copyright 2024 Manya Hael Foundation. All rights reserved.
|
|
15
|
+
* Licensed under the Apache License, Version 2.0.
|
|
16
|
+
*/
|
|
17
|
+
import type { Analysis } from '../types.js';
|
|
18
|
+
/** A single weighted score. */
|
|
19
|
+
export interface WeightedScore {
|
|
20
|
+
/** Id of the analysis this score is for. */
|
|
21
|
+
analysisId: string;
|
|
22
|
+
/** Raw confidence from the analysis. */
|
|
23
|
+
raw: number;
|
|
24
|
+
/** Specialist weight applied. */
|
|
25
|
+
weight: number;
|
|
26
|
+
/** `raw × weight`. */
|
|
27
|
+
weighted: number;
|
|
28
|
+
}
|
|
29
|
+
/** Result of `aggregateScores`: combined confidence plus dispersion. */
|
|
30
|
+
export interface AggregatedScore {
|
|
31
|
+
/** Weighted mean of confidences (`Σ confidence×weight / Σ weight`). */
|
|
32
|
+
combined: number;
|
|
33
|
+
/** Variance of the raw confidences (population variance). */
|
|
34
|
+
variance: number;
|
|
35
|
+
/** Standard deviation of the raw confidences. */
|
|
36
|
+
stddev: number;
|
|
37
|
+
/** Number of analyses aggregated. */
|
|
38
|
+
total: number;
|
|
39
|
+
/** Per-analysis weighted scores (`confidence×weight`), in input order. */
|
|
40
|
+
weighted: number[];
|
|
41
|
+
}
|
|
42
|
+
/** Default outlier deviation threshold. */
|
|
43
|
+
export declare const DEFAULT_OUTLIER_THRESHOLD = 0.25;
|
|
44
|
+
/**
|
|
45
|
+
* Returns a single weighted score: `analysis.confidence × specialistWeight`.
|
|
46
|
+
* Throws `ScoringError` when either input is invalid.
|
|
47
|
+
*/
|
|
48
|
+
export declare function scoreAnalysis(analysis: Analysis, specialistWeight: number): WeightedScore;
|
|
49
|
+
/**
|
|
50
|
+
* Aggregates a set of analyses into a combined confidence and dispersion
|
|
51
|
+
* statistics. `weights` is a map of `specialistId → weight`. Throws
|
|
52
|
+
* `ScoringError` when a specialist's weight is missing or invalid.
|
|
53
|
+
*
|
|
54
|
+
* Returns `{ combined: 0, variance: 0, stddev: 0, total: 0, weighted: [] }`
|
|
55
|
+
* when `analyses` is empty.
|
|
56
|
+
*/
|
|
57
|
+
export declare function aggregateScores(analyses: Analysis[], weights: Record<string, number>): AggregatedScore;
|
|
58
|
+
/**
|
|
59
|
+
* Returns analyses whose confidence deviates from the median by more than
|
|
60
|
+
* `threshold` (absolute difference). Returns `[]` when fewer than two
|
|
61
|
+
* analyses are provided. The default threshold is
|
|
62
|
+
* {@link DEFAULT_OUTLIER_THRESHOLD}.
|
|
63
|
+
*/
|
|
64
|
+
export declare function detectOutliers(analyses: Analysis[], threshold?: number): Analysis[];
|
|
65
|
+
//# sourceMappingURL=scoring.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scoring.d.ts","sourceRoot":"","sources":["../../../src/scoring/scoring.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAG5C,+BAA+B;AAC/B,MAAM,WAAW,aAAa;IAC5B,4CAA4C;IAC5C,UAAU,EAAE,MAAM,CAAC;IACnB,wCAAwC;IACxC,GAAG,EAAE,MAAM,CAAC;IACZ,iCAAiC;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,sBAAsB;IACtB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,wEAAwE;AACxE,MAAM,WAAW,eAAe;IAC9B,uEAAuE;IACvE,QAAQ,EAAE,MAAM,CAAC;IACjB,6DAA6D;IAC7D,QAAQ,EAAE,MAAM,CAAC;IACjB,iDAAiD;IACjD,MAAM,EAAE,MAAM,CAAC;IACf,qCAAqC;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,0EAA0E;IAC1E,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,2CAA2C;AAC3C,eAAO,MAAM,yBAAyB,OAAO,CAAC;AAuB9C;;;GAGG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,GAAG,aAAa,CAWzF;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,QAAQ,EAAE,EACpB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC9B,eAAe,CAiCjB;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,QAAQ,EAAE,EACpB,SAAS,GAAE,MAAkC,GAC5C,QAAQ,EAAE,CAaZ"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @manya-os/council — synthesizer barrel.
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2024 Manya Hael Foundation. All rights reserved.
|
|
5
|
+
* Licensed under the Apache License, Version 2.0.
|
|
6
|
+
*/
|
|
7
|
+
export { synthesize, classifyConsensus, DEFAULT_SYNTHESIS_THRESHOLD, STRONG_CONSENSUS_RATIO, } from './synthesizer.js';
|
|
8
|
+
export type { SynthesizeOptions } from './synthesizer.js';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/synthesizer/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,UAAU,EAAE,iBAAiB,EAC7B,2BAA2B,EAAE,sBAAsB,GACpD,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @manya-os/council — final decision synthesis.
|
|
3
|
+
*
|
|
4
|
+
* The {@link synthesize} function takes the {@link Consensus} (if any), the
|
|
5
|
+
* underlying analyses, the detected conflicts, and (optionally) the recorded
|
|
6
|
+
* minority opinions, and produces a {@link Decision} with an explicit
|
|
7
|
+
* confidence and rationale. The decision's `consensusLevel` summarizes the
|
|
8
|
+
* strength of the consensus:
|
|
9
|
+
*
|
|
10
|
+
* - `'unanimous'` — no dissent at all,
|
|
11
|
+
* - `'strong'` — weighted support ≥ 0.8,
|
|
12
|
+
* - `'majority'` — weighted support ≥ the threshold (default 0.6),
|
|
13
|
+
* - `'split'` — consensus exists but support is weak (below threshold),
|
|
14
|
+
* - `'none'` — no consensus was reached.
|
|
15
|
+
*
|
|
16
|
+
* Copyright 2024 Manya Hael Foundation. All rights reserved.
|
|
17
|
+
* Licensed under the Apache License, Version 2.0.
|
|
18
|
+
*/
|
|
19
|
+
import type { Analysis, Conflict, Consensus, ConsensusLevel, Decision, MinorityOpinion } from '../types.js';
|
|
20
|
+
/** Default threshold for distinguishing `'majority'` from `'split'`. */
|
|
21
|
+
export declare const DEFAULT_SYNTHESIS_THRESHOLD = 0.6;
|
|
22
|
+
/** Strong-consensus threshold (support ratio at or above this is `'strong'`). */
|
|
23
|
+
export declare const STRONG_CONSENSUS_RATIO = 0.8;
|
|
24
|
+
/** Options accepted by `synthesize`. */
|
|
25
|
+
export interface SynthesizeOptions {
|
|
26
|
+
/** Recorded minority opinions to fold into the rationale. */
|
|
27
|
+
minorityOpinions?: MinorityOpinion[];
|
|
28
|
+
/** Override the consensus-threshold for level classification. */
|
|
29
|
+
threshold?: number;
|
|
30
|
+
/** Override the generated decision id. */
|
|
31
|
+
decisionId?: string;
|
|
32
|
+
/** Override the generated-at timestamp (ISO 8601). */
|
|
33
|
+
generatedAt?: string;
|
|
34
|
+
/** Override the decision text (defaults to the consensus decision, or a no-consensus fallback). */
|
|
35
|
+
decision?: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Computes the {@link ConsensusLevel} for the given consensus and analyses.
|
|
39
|
+
* Returns `'none'` when `consensus` is `null`.
|
|
40
|
+
*/
|
|
41
|
+
export declare function classifyConsensus(consensus: Consensus | null, threshold?: number): ConsensusLevel;
|
|
42
|
+
/**
|
|
43
|
+
* Synthesizes a {@link Decision} from the consensus, analyses, conflicts, and
|
|
44
|
+
* (optionally) minority opinions. Throws `SynthesisError` on invalid inputs.
|
|
45
|
+
*
|
|
46
|
+
* Usage:
|
|
47
|
+
* ```ts
|
|
48
|
+
* const decision = synthesize('p1', consensus, analyses, conflicts, {
|
|
49
|
+
* minorityOpinions: tracker.getForProblem('p1'),
|
|
50
|
+
* });
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export declare function synthesize(problemId: string, consensus: Consensus | null, analyses: Analysis[], conflicts?: Conflict[], options?: SynthesizeOptions): Decision;
|
|
54
|
+
//# sourceMappingURL=synthesizer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"synthesizer.d.ts","sourceRoot":"","sources":["../../../src/synthesizer/synthesizer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EACV,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,cAAc,EAAE,QAAQ,EAAE,eAAe,EACzE,MAAM,aAAa,CAAC;AAGrB,wEAAwE;AACxE,eAAO,MAAM,2BAA2B,MAAM,CAAC;AAE/C,iFAAiF;AACjF,eAAO,MAAM,sBAAsB,MAAM,CAAC;AAE1C,wCAAwC;AACxC,MAAM,WAAW,iBAAiB;IAChC,6DAA6D;IAC7D,gBAAgB,CAAC,EAAE,eAAe,EAAE,CAAC;IACrC,iEAAiE;IACjE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0CAA0C;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,sDAAsD;IACtD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mGAAmG;IACnG,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,SAAS,GAAG,IAAI,EAC3B,SAAS,GAAE,MAAoC,GAC9C,cAAc,CAMhB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CACxB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,SAAS,GAAG,IAAI,EAC3B,QAAQ,EAAE,QAAQ,EAAE,EACpB,SAAS,GAAE,QAAQ,EAAO,EAC1B,OAAO,GAAE,iBAAsB,GAC9B,QAAQ,CA2EV"}
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @manya-os/council — shared type definitions.
|
|
3
|
+
*
|
|
4
|
+
* All cross-module type definitions live here so that modules can import the
|
|
5
|
+
* shape they need without circular dependencies. Per-module "value" interfaces
|
|
6
|
+
* (e.g. `Specialist`, `Analysis`, `Consensus`) are declared here for symmetry
|
|
7
|
+
* with other MANYA packages and to keep the public surface discoverable.
|
|
8
|
+
*
|
|
9
|
+
* Copyright 2024 Manya Hael Foundation. All rights reserved.
|
|
10
|
+
* Licensed under the Apache License, Version 2.0.
|
|
11
|
+
*/
|
|
12
|
+
import type { Logger, LogLevel } from './logging.js';
|
|
13
|
+
/**
|
|
14
|
+
* A problem under consideration by the council.
|
|
15
|
+
*
|
|
16
|
+
* The `domain` field is a free-form tag (e.g. `'security'`, `'finance'`) used
|
|
17
|
+
* by the {@link SpecialistRegistry} to route the problem to specialists whose
|
|
18
|
+
* `expertise` overlaps with the domain and the description tokens.
|
|
19
|
+
*/
|
|
20
|
+
export interface Problem {
|
|
21
|
+
/** Stable, unique problem id. */
|
|
22
|
+
id: string;
|
|
23
|
+
/** Human-readable description of the problem. */
|
|
24
|
+
description: string;
|
|
25
|
+
/** Free-form domain tag (e.g. `'security'`, `'finance'`). */
|
|
26
|
+
domain: string;
|
|
27
|
+
/** Optional structured context (e.g. payloads, metadata). */
|
|
28
|
+
context?: Record<string, unknown>;
|
|
29
|
+
/** ISO 8601 timestamp of when the problem was posed. */
|
|
30
|
+
createdAt: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* A specialist agent that may be routed a problem.
|
|
34
|
+
*
|
|
35
|
+
* `weight` is a non-negative number that influences how much this specialist's
|
|
36
|
+
* confidence contributes to aggregated scores and consensus. Higher weight
|
|
37
|
+
* means more influence. `reputation` is optional and may be used by callers to
|
|
38
|
+
* seed `weight` from historical performance.
|
|
39
|
+
*/
|
|
40
|
+
export interface Specialist {
|
|
41
|
+
/** Stable, unique specialist id. */
|
|
42
|
+
id: string;
|
|
43
|
+
/** Human-readable name. */
|
|
44
|
+
name: string;
|
|
45
|
+
/** Areas of expertise (free-form tags/keywords). */
|
|
46
|
+
expertise: string[];
|
|
47
|
+
/** Non-negative influence weight used by the scoring module. */
|
|
48
|
+
weight: number;
|
|
49
|
+
/** Optional reputation score (e.g. 0..1). Not used internally. */
|
|
50
|
+
reputation?: number;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* An independent analysis produced by a specialist for a problem.
|
|
54
|
+
*
|
|
55
|
+
* `confidence` is a number in `[0, 1]`. The `content` is the specialist's
|
|
56
|
+
* conclusion (used by the conflict detector to infer a polarity — `'positive'`
|
|
57
|
+
* vs `'negative'` stance — via simple keyword matching). `reasoning` is the
|
|
58
|
+
* chain of reasoning, and `caveats` is an optional list of reservations.
|
|
59
|
+
*/
|
|
60
|
+
export interface Analysis {
|
|
61
|
+
/** Stable, unique analysis id. */
|
|
62
|
+
id: string;
|
|
63
|
+
/** Id of the specialist who produced this analysis. */
|
|
64
|
+
specialistId: string;
|
|
65
|
+
/** Id of the problem this analysis addresses. */
|
|
66
|
+
problemId: string;
|
|
67
|
+
/** The specialist's conclusion (e.g. "I recommend we adopt the proposal."). */
|
|
68
|
+
content: string;
|
|
69
|
+
/** Confidence in the conclusion, in `[0, 1]`. */
|
|
70
|
+
confidence: number;
|
|
71
|
+
/** The chain of reasoning supporting the conclusion. */
|
|
72
|
+
reasoning: string;
|
|
73
|
+
/** Optional reservations or limitations. */
|
|
74
|
+
caveats?: string[];
|
|
75
|
+
}
|
|
76
|
+
/** Severity of a detected conflict. */
|
|
77
|
+
export type ConflictSeverity = 'low' | 'medium' | 'high';
|
|
78
|
+
/**
|
|
79
|
+
* The kind of disagreement detected between two or more analyses.
|
|
80
|
+
*
|
|
81
|
+
* - `opposing_conclusion` — high-confidence analyses on opposite sides of an
|
|
82
|
+
* issue (one positive, one negative, both > 0.6 confidence).
|
|
83
|
+
* - `factual_contradiction` — analyses that overlap substantially in subject
|
|
84
|
+
* matter but reach opposite polarities, suggesting a factual dispute.
|
|
85
|
+
* - `divergent_reasoning` — analyses that reach the same polarity but via
|
|
86
|
+
* very different reasoning paths, suggesting an unstated disagreement.
|
|
87
|
+
*/
|
|
88
|
+
export type ConflictType = 'opposing_conclusion' | 'factual_contradiction' | 'divergent_reasoning';
|
|
89
|
+
/** A conflict between two or more analyses. */
|
|
90
|
+
export interface Conflict {
|
|
91
|
+
/** Stable, unique conflict id. */
|
|
92
|
+
id: string;
|
|
93
|
+
/** The problem the conflict pertains to. */
|
|
94
|
+
problemId: string;
|
|
95
|
+
/** Ids of the analyses involved in the conflict. */
|
|
96
|
+
analysisIds: string[];
|
|
97
|
+
/** Human-readable description of the conflict. */
|
|
98
|
+
description: string;
|
|
99
|
+
/** Severity, based on the number of analyses involved and the confidence gap. */
|
|
100
|
+
severity: ConflictSeverity;
|
|
101
|
+
/** The kind of conflict. */
|
|
102
|
+
type: ConflictType;
|
|
103
|
+
}
|
|
104
|
+
/** Lifecycle status of a debate. */
|
|
105
|
+
export type DebateStatus = 'open' | 'concluded';
|
|
106
|
+
/** A single round of a structured debate. */
|
|
107
|
+
export interface DebateRound {
|
|
108
|
+
/** Stable, unique round id (within the debate). */
|
|
109
|
+
id: string;
|
|
110
|
+
/** Id of the analyst (typically a specialist) submitting the round. */
|
|
111
|
+
analystId: string;
|
|
112
|
+
/** The claim being made in this round. */
|
|
113
|
+
claim: string;
|
|
114
|
+
/** Evidence supporting the claim. */
|
|
115
|
+
evidence: string;
|
|
116
|
+
/** Optional id of the round this round rebuts. */
|
|
117
|
+
rebuttalTo?: string;
|
|
118
|
+
}
|
|
119
|
+
/** A structured debate over one or more conflicts. */
|
|
120
|
+
export interface Debate {
|
|
121
|
+
/** Stable, unique debate id. */
|
|
122
|
+
id: string;
|
|
123
|
+
/** The problem the debate pertains to. */
|
|
124
|
+
problemId: string;
|
|
125
|
+
/** Conflict ids that triggered this debate. */
|
|
126
|
+
conflictIds: string[];
|
|
127
|
+
/** Ordered list of debate rounds. */
|
|
128
|
+
rounds: DebateRound[];
|
|
129
|
+
/** Current status of the debate. */
|
|
130
|
+
status: DebateStatus;
|
|
131
|
+
/** ISO 8601 timestamp when the debate was opened. */
|
|
132
|
+
openedAt: string;
|
|
133
|
+
/** ISO 8601 timestamp when the debate was concluded, if any. */
|
|
134
|
+
concludedAt?: string;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* A minority opinion — a dissenting position recorded separately from the
|
|
138
|
+
* consensus decision. Minority opinions preserve dissent for audit and future
|
|
139
|
+
* reconsideration.
|
|
140
|
+
*/
|
|
141
|
+
export interface MinorityOpinion {
|
|
142
|
+
/** Stable, unique opinion id. */
|
|
143
|
+
id: string;
|
|
144
|
+
/** The problem the opinion pertains to. */
|
|
145
|
+
problemId: string;
|
|
146
|
+
/** Id of the analyst recording the opinion. */
|
|
147
|
+
analystId: string;
|
|
148
|
+
/** The dissenting position. */
|
|
149
|
+
position: string;
|
|
150
|
+
/** The reasoning supporting the position. */
|
|
151
|
+
reasoning: string;
|
|
152
|
+
/** Why this analyst dissents from the consensus. */
|
|
153
|
+
dissentReason: string;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* A consensus decision. Built by the consensus builder from a set of analyses
|
|
157
|
+
* and any detected conflicts. When consensus is not reached (weighted support
|
|
158
|
+
* below the threshold), the builder returns `null` instead.
|
|
159
|
+
*/
|
|
160
|
+
export interface Consensus {
|
|
161
|
+
/** The problem the consensus pertains to. */
|
|
162
|
+
problemId: string;
|
|
163
|
+
/** The decision text. */
|
|
164
|
+
decision: string;
|
|
165
|
+
/** The weighted support ratio, in `[0, 1]`. */
|
|
166
|
+
confidence: number;
|
|
167
|
+
/** Ids of specialists whose analyses support the decision. */
|
|
168
|
+
supportingAnalystIds: string[];
|
|
169
|
+
/** Ids of specialists whose analyses dissent from the decision. */
|
|
170
|
+
dissentingAnalystIds: string[];
|
|
171
|
+
/** Ids of conflicts that were considered (resolved or otherwise). */
|
|
172
|
+
conflictsResolved: string[];
|
|
173
|
+
/** Unresolved high-severity issues that the caller should address. */
|
|
174
|
+
openIssues: string[];
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* A full review report aggregating analyses, conflicts, debates, minority
|
|
178
|
+
* opinions, the consensus (if any), and recommendations for a single problem.
|
|
179
|
+
*/
|
|
180
|
+
export interface ReviewReport {
|
|
181
|
+
/** Stable, unique report id. */
|
|
182
|
+
id: string;
|
|
183
|
+
/** The problem the report pertains to. */
|
|
184
|
+
problemId: string;
|
|
185
|
+
/** ISO 8601 timestamp when the report was generated. */
|
|
186
|
+
generatedAt: string;
|
|
187
|
+
/** Short human-readable summary. */
|
|
188
|
+
summary: string;
|
|
189
|
+
/** All analyses included in the review. */
|
|
190
|
+
analyses: Analysis[];
|
|
191
|
+
/** All conflicts detected. */
|
|
192
|
+
conflicts: Conflict[];
|
|
193
|
+
/** All debates held. */
|
|
194
|
+
debates: Debate[];
|
|
195
|
+
/** All minority opinions recorded. */
|
|
196
|
+
minorityOpinions: MinorityOpinion[];
|
|
197
|
+
/** The consensus reached, if any. */
|
|
198
|
+
consensus: Consensus | null;
|
|
199
|
+
/** Actionable recommendations. */
|
|
200
|
+
recommendations: string[];
|
|
201
|
+
}
|
|
202
|
+
/** Strength of the consensus behind a synthesized decision. */
|
|
203
|
+
export type ConsensusLevel = 'unanimous' | 'strong' | 'majority' | 'split' | 'none';
|
|
204
|
+
/**
|
|
205
|
+
* The final, defensible decision synthesized from the consensus, analyses,
|
|
206
|
+
* conflicts, and minority opinions. Includes an explicit confidence and
|
|
207
|
+
* rationale.
|
|
208
|
+
*/
|
|
209
|
+
export interface Decision {
|
|
210
|
+
/** Stable, unique decision id. */
|
|
211
|
+
id: string;
|
|
212
|
+
/** The problem the decision pertains to. */
|
|
213
|
+
problemId: string;
|
|
214
|
+
/** The decision text. */
|
|
215
|
+
decision: string;
|
|
216
|
+
/** Rationale supporting the decision. */
|
|
217
|
+
rationale: string;
|
|
218
|
+
/** Confidence in the decision, in `[0, 1]`. */
|
|
219
|
+
confidence: number;
|
|
220
|
+
/** Strength of the consensus behind the decision. */
|
|
221
|
+
consensusLevel: ConsensusLevel;
|
|
222
|
+
/** Ids of the specialists who participated. */
|
|
223
|
+
participants: string[];
|
|
224
|
+
/** ISO 8601 timestamp when the decision was generated. */
|
|
225
|
+
generatedAt: string;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Configuration for the council and its sub-components. All fields are
|
|
229
|
+
* optional and have sensible defaults.
|
|
230
|
+
*/
|
|
231
|
+
export interface CouncilConfig {
|
|
232
|
+
/** Weighted support ratio required to reach consensus. Default `0.6`. */
|
|
233
|
+
consensusThreshold?: number;
|
|
234
|
+
/**
|
|
235
|
+
* Absolute deviation from the median confidence above which an analysis is
|
|
236
|
+
* considered an outlier. Default `0.25`.
|
|
237
|
+
*/
|
|
238
|
+
outlierThreshold?: number;
|
|
239
|
+
/** Maximum number of rounds per debate. Default `10`. */
|
|
240
|
+
maxDebateRounds?: number;
|
|
241
|
+
/** Log level for any logger created internally. Default `'info'`. */
|
|
242
|
+
logLevel?: LogLevel;
|
|
243
|
+
/** Logger to use. Defaults to a `ConsoleLogger` at `logLevel`. */
|
|
244
|
+
logger?: Logger;
|
|
245
|
+
}
|
|
246
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @manya-os/council — shared text utilities.
|
|
3
|
+
*
|
|
4
|
+
* Small, dependency-free helpers used by the router, conflict, and consensus
|
|
5
|
+
* modules to tokenize and compare short pieces of natural-language text. These
|
|
6
|
+
* are intentionally simple — they are NOT an NLP pipeline. Polarity inference
|
|
7
|
+
* is a keyword-counting heuristic (with light stemming) so that conflict
|
|
8
|
+
* detection and consensus building remain deterministic, explainable, and
|
|
9
|
+
* testable.
|
|
10
|
+
*
|
|
11
|
+
* Copyright 2024 Manya Hael Foundation. All rights reserved.
|
|
12
|
+
* Licensed under the Apache License, Version 2.0.
|
|
13
|
+
*/
|
|
14
|
+
/** Common English stop-words. Kept short and conservative. */
|
|
15
|
+
export declare const STOP_WORDS: ReadonlySet<string>;
|
|
16
|
+
/** Words that bias a text's polarity positive (recommend/approve/endorse …). */
|
|
17
|
+
export declare const POSITIVE_MARKERS: ReadonlySet<string>;
|
|
18
|
+
/** Words that bias a text's polarity negative (reject/oppose/forbid …). */
|
|
19
|
+
export declare const NEGATIVE_MARKERS: ReadonlySet<string>;
|
|
20
|
+
/**
|
|
21
|
+
* Naive suffix-stripper used to normalize tokens before marker matching.
|
|
22
|
+
* Strips `'ing'`, `'ed'`, and a trailing `'s'` from tokens of length > 4 so
|
|
23
|
+
* that `'recommends'` → `'recommend'`, `'rejected'` → `'reject'`, etc. Short
|
|
24
|
+
* tokens (length ≤ 4) are returned unchanged so that `'no'`, `'go'`, `'pass'`,
|
|
25
|
+
* `'stop'` are not corrupted.
|
|
26
|
+
*/
|
|
27
|
+
export declare function stem(token: string): string;
|
|
28
|
+
/** Splits text into lowercase alphanumeric tokens, dropping stop-words. */
|
|
29
|
+
export declare function tokenize(text: string): string[];
|
|
30
|
+
/** Returns the set of tokens in `text` (lowercased, stop-words removed). */
|
|
31
|
+
export declare function tokenSet(text: string): Set<string>;
|
|
32
|
+
/**
|
|
33
|
+
* Jaccard similarity between two token sets: `|A ∩ B| / |A ∪ B|`.
|
|
34
|
+
* Returns `0` when either set is empty.
|
|
35
|
+
*/
|
|
36
|
+
export declare function jaccard(a: Set<string>, b: Set<string>): number;
|
|
37
|
+
/**
|
|
38
|
+
* Infers a polarity from `text` by counting positive vs negative markers
|
|
39
|
+
* (after light stemming). Returns `'positive'` when positive markers strictly
|
|
40
|
+
* outnumber negative ones, `'negative'` when negative markers strictly
|
|
41
|
+
* outnumber positive ones, and `'neutral'` when the counts are equal or no
|
|
42
|
+
* markers are present.
|
|
43
|
+
*/
|
|
44
|
+
export declare function polarity(text: string): 'positive' | 'negative' | 'neutral';
|
|
45
|
+
//# sourceMappingURL=util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/util.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,8DAA8D;AAC9D,eAAO,MAAM,UAAU,EAAE,WAAW,CAAC,MAAM,CAUzC,CAAC;AAEH,gFAAgF;AAChF,eAAO,MAAM,gBAAgB,EAAE,WAAW,CAAC,MAAM,CAK/C,CAAC;AAEH,2EAA2E;AAC3E,eAAO,MAAM,gBAAgB,EAAE,WAAW,CAAC,MAAM,CAK/C,CAAC;AAEH;;;;;;GAMG;AACH,wBAAgB,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAO1C;AAED,2EAA2E;AAC3E,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAM/C;AAED,4EAA4E;AAC5E,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAElD;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,MAAM,CAQ9D;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,UAAU,GAAG,SAAS,CAY1E"}
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@manya-os/council",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Multi-agent consensus engine for the MANYA Intelligence OS — specialist routing, independent analyses, weighted confidence scoring, conflict detection, structured debate, minority opinions, consensus building, review reports, and final decision synthesis.",
|
|
5
|
+
"main": "dist/cjs/index.js",
|
|
6
|
+
"types": "dist/types/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "node ../../scripts/build-package.js council",
|
|
9
|
+
"test": "jest",
|
|
10
|
+
"clean": "rm -rf dist build node_modules",
|
|
11
|
+
"build:types": "node ../../scripts/build-types.js council",
|
|
12
|
+
"build:bundle": "node ../../scripts/build-package.js council --no-types && node ../../scripts/build-types.js council"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"manya",
|
|
16
|
+
"council",
|
|
17
|
+
"multi-agent",
|
|
18
|
+
"consensus",
|
|
19
|
+
"debate",
|
|
20
|
+
"specialist",
|
|
21
|
+
"routing",
|
|
22
|
+
"conflict-detection",
|
|
23
|
+
"minority-opinion",
|
|
24
|
+
"decision-synthesis",
|
|
25
|
+
"agent-council"
|
|
26
|
+
],
|
|
27
|
+
"author": "Uviwe Menyiwe (Azura Daemon) <foundation@manyahael.org>",
|
|
28
|
+
"license": "Apache-2.0",
|
|
29
|
+
"dependencies": {},
|
|
30
|
+
"devDependencies": {},
|
|
31
|
+
"module": "dist/esm/index.mjs",
|
|
32
|
+
"exports": {
|
|
33
|
+
".": {
|
|
34
|
+
"types": "./dist/types/index.d.ts",
|
|
35
|
+
"require": "./dist/cjs/index.js",
|
|
36
|
+
"import": "./dist/esm/index.mjs",
|
|
37
|
+
"default": "./dist/cjs/index.js"
|
|
38
|
+
},
|
|
39
|
+
"./package.json": "./package.json"
|
|
40
|
+
},
|
|
41
|
+
"sideEffects": false,
|
|
42
|
+
"files": [
|
|
43
|
+
"dist",
|
|
44
|
+
"README.md",
|
|
45
|
+
"CHANGELOG.md",
|
|
46
|
+
"LICENSE"
|
|
47
|
+
]
|
|
48
|
+
}
|