konsilio 0.3.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.
Files changed (80) hide show
  1. package/LICENSE.md +24 -0
  2. package/README.md +170 -0
  3. package/build/cli/history.d.ts +2 -0
  4. package/build/cli/history.js +179 -0
  5. package/build/cli/history.js.map +1 -0
  6. package/build/config.d.ts +38 -0
  7. package/build/config.js +118 -0
  8. package/build/config.js.map +1 -0
  9. package/build/container.d.ts +32 -0
  10. package/build/container.js +102 -0
  11. package/build/container.js.map +1 -0
  12. package/build/db/schema.d.ts +1 -0
  13. package/build/db/schema.js +67 -0
  14. package/build/db/schema.js.map +1 -0
  15. package/build/index.d.ts +2 -0
  16. package/build/index.js +140 -0
  17. package/build/index.js.map +1 -0
  18. package/build/konsilio.json +25 -0
  19. package/build/konsilio.schema.json +140 -0
  20. package/build/logger.d.ts +84 -0
  21. package/build/logger.js +121 -0
  22. package/build/logger.js.map +1 -0
  23. package/build/personas/expert.d.ts +33 -0
  24. package/build/personas/expert.js +46 -0
  25. package/build/personas/expert.js.map +1 -0
  26. package/build/personas/index.d.ts +9 -0
  27. package/build/personas/index.js +11 -0
  28. package/build/personas/index.js.map +1 -0
  29. package/build/personas/lead.d.ts +33 -0
  30. package/build/personas/lead.js +51 -0
  31. package/build/personas/lead.js.map +1 -0
  32. package/build/personas/schemas.d.ts +313 -0
  33. package/build/personas/schemas.js +97 -0
  34. package/build/personas/schemas.js.map +1 -0
  35. package/build/prompts/consolidation/critique.md +59 -0
  36. package/build/prompts/consolidation/decision.md +51 -0
  37. package/build/prompts/consolidation/extraction.md +46 -0
  38. package/build/prompts/consolidation/synthesis.md +42 -0
  39. package/build/prompts/expert-rules.md +50 -0
  40. package/build/prompts/personas/dev-tooling.md +27 -0
  41. package/build/prompts/personas/devops.md +26 -0
  42. package/build/prompts/personas/distributed-systems.md +28 -0
  43. package/build/prompts/personas/graph-dba.md +27 -0
  44. package/build/prompts/personas/node-fullstack.md +27 -0
  45. package/build/prompts/personas/performance.md +26 -0
  46. package/build/prompts/personas/security.md +26 -0
  47. package/build/prompts/personas/test-architect.md +29 -0
  48. package/build/prompts/personas/test-quoted.md +14 -0
  49. package/build/prompts/personas/typescript.md +26 -0
  50. package/build/prompts/personas/ux-dx.md +29 -0
  51. package/build/prompts/workflow-rules.md +3 -0
  52. package/build/server.d.ts +24 -0
  53. package/build/server.js +181 -0
  54. package/build/server.js.map +1 -0
  55. package/build/services/cache.service.d.ts +49 -0
  56. package/build/services/cache.service.js +85 -0
  57. package/build/services/cache.service.js.map +1 -0
  58. package/build/services/council.service.d.ts +111 -0
  59. package/build/services/council.service.js +361 -0
  60. package/build/services/council.service.js.map +1 -0
  61. package/build/services/database.service.d.ts +70 -0
  62. package/build/services/database.service.js +221 -0
  63. package/build/services/database.service.js.map +1 -0
  64. package/build/services/formatter.service.d.ts +52 -0
  65. package/build/services/formatter.service.js +133 -0
  66. package/build/services/formatter.service.js.map +1 -0
  67. package/build/services/index.d.ts +18 -0
  68. package/build/services/index.js +13 -0
  69. package/build/services/index.js.map +1 -0
  70. package/build/services/openrouter.service.d.ts +58 -0
  71. package/build/services/openrouter.service.js +128 -0
  72. package/build/services/openrouter.service.js.map +1 -0
  73. package/build/services/persona.service.d.ts +43 -0
  74. package/build/services/persona.service.js +93 -0
  75. package/build/services/persona.service.js.map +1 -0
  76. package/build/services/prompt.service.d.ts +59 -0
  77. package/build/services/prompt.service.js +209 -0
  78. package/build/services/prompt.service.js.map +1 -0
  79. package/konsilio.schema.json +140 -0
  80. package/package.json +68 -0
@@ -0,0 +1,121 @@
1
+ /**
2
+ * Pino-based Structured Logger with correlation ID support
3
+ *
4
+ * Outputs structured JSON logs to stderr for observability and debugging.
5
+ * IMPORTANT: MCP servers MUST use stderr for logs - stdout is reserved for JSON-RPC protocol.
6
+ */
7
+ import pino from 'pino';
8
+ /**
9
+ * Get the log level from environment variables
10
+ * Defaults to 'info' if not set or invalid
11
+ */
12
+ function getLogLevelFromEnv() {
13
+ const envLevel = process.env.LOG_LEVEL?.toLowerCase();
14
+ const validLevels = ['debug', 'info', 'warn', 'error'];
15
+ if (envLevel && validLevels.includes(envLevel)) {
16
+ return envLevel;
17
+ }
18
+ return 'info';
19
+ }
20
+ /**
21
+ * Pino-backed Logger implementation
22
+ */
23
+ class PinoLogger {
24
+ pino;
25
+ constructor(level) {
26
+ this.pino = pino({
27
+ level: level ?? getLogLevelFromEnv(),
28
+ base: {
29
+ service: 'konsilio',
30
+ },
31
+ timestamp: pino.stdTimeFunctions.isoTime,
32
+ },
33
+ // MCP servers MUST log to stderr - stdout is reserved for JSON-RPC protocol
34
+ pino.destination({ dest: 2, sync: true }));
35
+ }
36
+ debug(message, data, correlationId) {
37
+ if (correlationId) {
38
+ this.pino.child({ correlationId }).debug(data ?? {}, message);
39
+ }
40
+ else {
41
+ this.pino.debug(data ?? {}, message);
42
+ }
43
+ }
44
+ info(message, data, correlationId) {
45
+ if (correlationId) {
46
+ this.pino.child({ correlationId }).info(data ?? {}, message);
47
+ }
48
+ else {
49
+ this.pino.info(data ?? {}, message);
50
+ }
51
+ }
52
+ warn(message, data, correlationId) {
53
+ if (correlationId) {
54
+ this.pino.child({ correlationId }).warn(data ?? {}, message);
55
+ }
56
+ else {
57
+ this.pino.warn(data ?? {}, message);
58
+ }
59
+ }
60
+ error(message, data, correlationId) {
61
+ if (correlationId) {
62
+ this.pino.child({ correlationId }).error(data ?? {}, message);
63
+ }
64
+ else {
65
+ this.pino.error(data ?? {}, message);
66
+ }
67
+ }
68
+ withCorrelationId(correlationId) {
69
+ return new PinoCorrelatedLogger(this.pino.child({ correlationId }));
70
+ }
71
+ }
72
+ /**
73
+ * Correlated logger implementation using Pino child logger
74
+ */
75
+ class PinoCorrelatedLogger {
76
+ childLogger;
77
+ constructor(childLogger) {
78
+ this.childLogger = childLogger;
79
+ }
80
+ debug(message, data) {
81
+ this.childLogger.debug(data ?? {}, message);
82
+ }
83
+ info(message, data) {
84
+ this.childLogger.info(data ?? {}, message);
85
+ }
86
+ warn(message, data) {
87
+ this.childLogger.warn(data ?? {}, message);
88
+ }
89
+ error(message, data) {
90
+ this.childLogger.error(data ?? {}, message);
91
+ }
92
+ }
93
+ /**
94
+ * Singleton logger instance configured from LOG_LEVEL env var
95
+ */
96
+ export const logger = new PinoLogger();
97
+ /**
98
+ * Create a logger instance with the specified log level
99
+ * @param level - Optional log level (defaults to LOG_LEVEL env var or 'info')
100
+ */
101
+ export function createLogger(level) {
102
+ return new PinoLogger(level);
103
+ }
104
+ /**
105
+ * Get a child logger with correlation ID embedded in all log entries
106
+ * Convenience function equivalent to logger.withCorrelationId()
107
+ *
108
+ * @param correlationId - The correlation ID to include in all log entries
109
+ * @returns A logger instance with the correlation ID
110
+ */
111
+ export function getLogger(correlationId) {
112
+ return logger.withCorrelationId(correlationId);
113
+ }
114
+ // Export convenience methods for direct use without correlation ID
115
+ export const log = {
116
+ debug: (message, data) => logger.debug(message, data),
117
+ info: (message, data) => logger.info(message, data),
118
+ warn: (message, data) => logger.warn(message, data),
119
+ error: (message, data) => logger.error(message, data),
120
+ };
121
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,IAAI,MAAM,MAAM,CAAC;AAMxB;;;GAGG;AACH,SAAS,kBAAkB;IACzB,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,WAAW,EAAE,CAAC;IACtD,MAAM,WAAW,GAAe,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAEnE,IAAI,QAAQ,IAAI,WAAW,CAAC,QAAQ,CAAC,QAAoB,CAAC,EAAE,CAAC;QAC3D,OAAO,QAAoB,CAAC;IAC9B,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AA6CD;;GAEG;AACH,MAAM,UAAU;IACK,IA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C,CAAC;IAC9C,CAAC;CACF;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;AAEvC;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,KAAgB;IAC3C,OAAO,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC;AAC/B,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CAAC,aAAqB;IAC7C,OAAO,MAAM,CAAC,iBAAiB,CAAC,aAAa,CAAC,CAAC;AACjD,CAAC;AAED,mEAAmE;AACnE,MAAM,CAAC,MAAM,GAAG,GAAG;IACjB,KAAK,EAAE,CAAC,OAAe,EAAE,IAA8B,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC;IACvF,IAAI,EAAE,CAAC,OAAe,EAAE,IAA8B,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC;IACrF,IAAI,EAAE,CAAC,OAAe,EAAE,IAA8B,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC;IACrF,KAAK,EAAE,CAAC,OAAe,EAAE,IAA8B,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC;CACxF,CAAC"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Expert Class
3
+ *
4
+ * Runtime persona construction from markdown files.
5
+ * Replaces individual persona TypeScript files.
6
+ */
7
+ import type { PersonaPromptData } from '../services/prompt.service.js';
8
+ import type { Persona } from './schemas.js';
9
+ export interface ExpertConfig {
10
+ personaId: string;
11
+ model: string;
12
+ expertRules: string;
13
+ workflowRules?: string;
14
+ promptService: {
15
+ loadPersonaPromptData: (id: string) => PersonaPromptData;
16
+ };
17
+ }
18
+ /**
19
+ * Expert - Runtime persona construction
20
+ */
21
+ export declare class Expert implements Persona {
22
+ readonly id: string;
23
+ readonly name: string;
24
+ readonly emoji: string;
25
+ readonly focusAreas: string[];
26
+ readonly domains?: string[];
27
+ readonly systemPrompt: string;
28
+ constructor(config: ExpertConfig);
29
+ /**
30
+ * Build the system prompt for the expert
31
+ */
32
+ private buildSystemPrompt;
33
+ }
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Expert Class
3
+ *
4
+ * Runtime persona construction from markdown files.
5
+ * Replaces individual persona TypeScript files.
6
+ */
7
+ /**
8
+ * Expert - Runtime persona construction
9
+ */
10
+ export class Expert {
11
+ id;
12
+ name;
13
+ emoji;
14
+ focusAreas;
15
+ domains;
16
+ systemPrompt;
17
+ constructor(config) {
18
+ const personaData = config.promptService.loadPersonaPromptData(config.personaId);
19
+ this.id = personaData.id;
20
+ this.name = personaData.name;
21
+ this.emoji = personaData.emoji;
22
+ this.focusAreas = personaData.focusAreas;
23
+ this.domains = personaData.domains;
24
+ this.systemPrompt = this.buildSystemPrompt(personaData, config);
25
+ }
26
+ /**
27
+ * Build the system prompt for the expert
28
+ */
29
+ buildSystemPrompt(data, config) {
30
+ const parts = [];
31
+ // Expert rules (always included for experts)
32
+ parts.push(config.expertRules);
33
+ // Workflow rules (optional)
34
+ if (config.workflowRules) {
35
+ parts.push('\n' + config.workflowRules);
36
+ }
37
+ // Persona-specific content
38
+ parts.push(`\nYou are a ${data.name}. Review the draft plan for architecture issues within your domain.\n`);
39
+ // Anti-patterns
40
+ if (data.antiPatterns.length > 0) {
41
+ parts.push('## Anti-Patterns\n\n' + data.antiPatterns.map((ap, i) => `${i + 1}. ${ap}`).join('\n') + '\n');
42
+ }
43
+ return parts.join('\n');
44
+ }
45
+ }
46
+ //# sourceMappingURL=expert.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"expert.js","sourceRoot":"","sources":["../../src/personas/expert.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAeH;;GAEG;AACH,MAAM,OAAO,MAAM;IACD,EAAE,CAAS;IACX,IAAI,CAAS;IACb,KAAK,CAAS;IACd,UAAU,CA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QAC7G,CAAC;QAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;CACF"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Persona Index - Types and Classes
3
+ *
4
+ * This module exports persona types and classes.
5
+ * Persona creation is handled by PersonaService.
6
+ */
7
+ export * from './schemas.js';
8
+ export { Expert, type ExpertConfig } from './expert.js';
9
+ export { Lead, type LeadConfig } from './lead.js';
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Persona Index - Types and Classes
3
+ *
4
+ * This module exports persona types and classes.
5
+ * Persona creation is handled by PersonaService.
6
+ */
7
+ // Export schemas and types
8
+ export * from './schemas.js';
9
+ export { Expert } from './expert.js';
10
+ export { Lead } from './lead.js';
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/personas/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,2BAA2B;AAC3B,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,MAAM,EAAqB,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,IAAI,EAAmB,MAAM,WAAW,CAAC"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Lead Class
3
+ *
4
+ * Runtime lead construction for consolidation phases.
5
+ * Loads phase-specific prompts from markdown files.
6
+ */
7
+ import type { Persona } from './schemas.js';
8
+ export interface LeadConfig {
9
+ phase: 'extraction' | 'critique' | 'decision' | 'synthesis';
10
+ workflowRules?: string;
11
+ promptService: {
12
+ loadConsolidationPhase: (phase: 'extraction' | 'critique' | 'decision' | 'synthesis') => string;
13
+ };
14
+ }
15
+ /**
16
+ * Lead - Runtime lead construction for consolidation phases
17
+ */
18
+ export declare class Lead implements Persona {
19
+ readonly id: string;
20
+ readonly name: string;
21
+ readonly emoji: string;
22
+ readonly focusAreas: string[];
23
+ readonly systemPrompt: string;
24
+ constructor(config: LeadConfig);
25
+ /**
26
+ * Get human-readable phase name
27
+ */
28
+ private getPhaseName;
29
+ /**
30
+ * Build the system prompt for the lead
31
+ */
32
+ private buildSystemPrompt;
33
+ }
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Lead Class
3
+ *
4
+ * Runtime lead construction for consolidation phases.
5
+ * Loads phase-specific prompts from markdown files.
6
+ */
7
+ /**
8
+ * Lead - Runtime lead construction for consolidation phases
9
+ */
10
+ export class Lead {
11
+ id;
12
+ name;
13
+ emoji;
14
+ focusAreas;
15
+ systemPrompt;
16
+ constructor(config) {
17
+ this.id = `lead-${config.phase}`;
18
+ this.name = this.getPhaseName(config.phase);
19
+ this.emoji = '👑';
20
+ this.focusAreas = [config.phase];
21
+ this.systemPrompt = this.buildSystemPrompt(config);
22
+ }
23
+ /**
24
+ * Get human-readable phase name
25
+ */
26
+ getPhaseName(phase) {
27
+ const names = {
28
+ extraction: 'Extraction Lead',
29
+ critique: 'Critique Lead',
30
+ decision: 'Decision Lead',
31
+ synthesis: 'Synthesis Lead',
32
+ };
33
+ return names[phase] ?? 'Lead';
34
+ }
35
+ /**
36
+ * Build the system prompt for the lead
37
+ */
38
+ buildSystemPrompt(config) {
39
+ const parts = [];
40
+ // Workflow rules (optional)
41
+ if (config.workflowRules) {
42
+ parts.push(config.workflowRules);
43
+ parts.push('\n');
44
+ }
45
+ // Phase-specific prompt
46
+ const phasePrompt = config.promptService.loadConsolidationPhase(config.phase);
47
+ parts.push(phasePrompt);
48
+ return parts.join('\n');
49
+ }
50
+ }
51
+ //# sourceMappingURL=lead.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lead.js","sourceRoot":"","sources":["../../src/personas/lead.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAYH;;GAEG;AACH,MAAM,OAAO,IAAI;IACC,EAAE,CAAS;IACX,IAAI,CAAS;IACb,KAAK,CAAS;IACd,UAAU,CAAW;IACrB,YAAY,CAAS;IAErC,YAAY,MAAkB;QAC5B,IAAI,CAAC,EAAE,GAAG,QAAQ,MAAM,CAAC,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
10
+ component: z.ZodString;
11
+ issue: z.ZodString;
12
+ mitigation: z.ZodString;
13
+ }, z.core.$strip>;
14
+ export declare const StructuredRiskSchema: z.ZodObject<{
15
+ id: z.ZodString;
16
+ category: z.ZodEnum<{
17
+ security: "security";
18
+ performance: "performance";
19
+ operational: "operational";
20
+ ux: "ux";
21
+ "technical-debt": "technical-debt";
22
+ }>;
23
+ probability: z.ZodEnum<{
24
+ high: "high";
25
+ medium: "medium";
26
+ low: "low";
27
+ }>;
28
+ impact: z.ZodEnum<{
29
+ high: "high";
30
+ medium: "medium";
31
+ low: "low";
32
+ }>;
33
+ description: z.ZodString;
34
+ }, z.core.$strip>;
35
+ export declare const StructuredExpertOutputSchema: z.ZodObject<{
36
+ personaId: z.ZodString;
37
+ findings: z.ZodArray<z.ZodObject<{
38
+ id: z.ZodString;
39
+ severity: z.ZodEnum<{
40
+ CRITICAL: "CRITICAL";
41
+ HIGH: "HIGH";
42
+ MEDIUM: "MEDIUM";
43
+ LOW: "LOW";
44
+ }>;
45
+ component: z.ZodString;
46
+ issue: z.ZodString;
47
+ mitigation: z.ZodString;
48
+ }, z.core.$strip>>;
49
+ risks: z.ZodArray<z.ZodObject<{
50
+ id: z.ZodString;
51
+ category: z.ZodEnum<{
52
+ security: "security";
53
+ performance: "performance";
54
+ operational: "operational";
55
+ ux: "ux";
56
+ "technical-debt": "technical-debt";
57
+ }>;
58
+ probability: z.ZodEnum<{
59
+ high: "high";
60
+ medium: "medium";
61
+ low: "low";
62
+ }>;
63
+ impact: z.ZodEnum<{
64
+ high: "high";
65
+ medium: "medium";
66
+ low: "low";
67
+ }>;
68
+ description: z.ZodString;
69
+ }, z.core.$strip>>;
70
+ missingAssumptions: z.ZodArray<z.ZodString>;
71
+ dependencies: z.ZodArray<z.ZodString>;
72
+ }, z.core.$strip>;
73
+ export declare const ExtractedClaimSchema: z.ZodObject<{
74
+ id: z.ZodString;
75
+ personaId: z.ZodString;
76
+ findingId: z.ZodString;
77
+ claim: z.ZodString;
78
+ context: z.ZodRecord<z.ZodString, z.ZodUnknown>;
79
+ }, z.core.$strip>;
80
+ export declare const ExtractionPhaseOutputSchema: z.ZodObject<{
81
+ claims: z.ZodArray<z.ZodObject<{
82
+ id: z.ZodString;
83
+ personaId: z.ZodString;
84
+ findingId: z.ZodString;
85
+ claim: z.ZodString;
86
+ context: z.ZodRecord<z.ZodString, z.ZodUnknown>;
87
+ }, z.core.$strip>>;
88
+ totalFindings: z.ZodNumber;
89
+ }, z.core.$strip>;
90
+ export declare const ContradictionSchema: z.ZodObject<{
91
+ id: z.ZodString;
92
+ personaA: z.ZodString;
93
+ personaB: z.ZodString;
94
+ findingA: z.ZodString;
95
+ findingB: z.ZodString;
96
+ description: z.ZodString;
97
+ }, z.core.$strip>;
98
+ export declare const UnsupportedClaimSchema: z.ZodObject<{
99
+ id: z.ZodString;
100
+ personaId: z.ZodString;
101
+ findingId: z.ZodString;
102
+ claim: z.ZodString;
103
+ reason: z.ZodString;
104
+ }, z.core.$strip>;
105
+ export declare const ReasoningScoreSchema: z.ZodObject<{
106
+ personaId: z.ZodString;
107
+ score: z.ZodNumber;
108
+ reasoning: z.ZodString;
109
+ }, z.core.$strip>;
110
+ export declare const CritiquePhaseOutputSchema: z.ZodObject<{
111
+ contradictions: z.ZodArray<z.ZodObject<{
112
+ id: z.ZodString;
113
+ personaA: z.ZodString;
114
+ personaB: z.ZodString;
115
+ findingA: z.ZodString;
116
+ findingB: z.ZodString;
117
+ description: z.ZodString;
118
+ }, z.core.$strip>>;
119
+ unsupportedClaims: z.ZodArray<z.ZodObject<{
120
+ id: z.ZodString;
121
+ personaId: z.ZodString;
122
+ findingId: z.ZodString;
123
+ claim: z.ZodString;
124
+ reason: z.ZodString;
125
+ }, z.core.$strip>>;
126
+ reasoningScores: z.ZodArray<z.ZodObject<{
127
+ personaId: z.ZodString;
128
+ score: z.ZodNumber;
129
+ reasoning: z.ZodString;
130
+ }, z.core.$strip>>;
131
+ consensusRisks: z.ZodArray<z.ZodString>;
132
+ }, z.core.$strip>;
133
+ export declare const DecisionSchema: z.ZodObject<{
134
+ findingId: z.ZodString;
135
+ personaId: z.ZodString;
136
+ action: z.ZodEnum<{
137
+ ACCEPT: "ACCEPT";
138
+ REJECT: "REJECT";
139
+ }>;
140
+ reasoning: z.ZodString;
141
+ }, z.core.$strip>;
142
+ export declare const ConflictResolutionSchema: z.ZodObject<{
143
+ contradictionId: z.ZodString;
144
+ selectedPersona: z.ZodString;
145
+ selectedFindingId: z.ZodString;
146
+ reasoning: z.ZodString;
147
+ }, z.core.$strip>;
148
+ export declare const DecisionPhaseOutputSchema: z.ZodObject<{
149
+ decisions: z.ZodArray<z.ZodObject<{
150
+ findingId: z.ZodString;
151
+ personaId: z.ZodString;
152
+ action: z.ZodEnum<{
153
+ ACCEPT: "ACCEPT";
154
+ REJECT: "REJECT";
155
+ }>;
156
+ reasoning: z.ZodString;
157
+ }, z.core.$strip>>;
158
+ resolutions: z.ZodArray<z.ZodObject<{
159
+ contradictionId: z.ZodString;
160
+ selectedPersona: z.ZodString;
161
+ selectedFindingId: z.ZodString;
162
+ reasoning: z.ZodString;
163
+ }, z.core.$strip>>;
164
+ acceptedCount: z.ZodNumber;
165
+ rejectedCount: z.ZodNumber;
166
+ }, z.core.$strip>;
167
+ export declare const SynthesisPhaseOutputSchema: z.ZodObject<{
168
+ blueprint: z.ZodString;
169
+ acceptedFindings: z.ZodArray<z.ZodObject<{
170
+ id: z.ZodString;
171
+ severity: z.ZodEnum<{
172
+ CRITICAL: "CRITICAL";
173
+ HIGH: "HIGH";
174
+ MEDIUM: "MEDIUM";
175
+ LOW: "LOW";
176
+ }>;
177
+ component: z.ZodString;
178
+ issue: z.ZodString;
179
+ mitigation: z.ZodString;
180
+ }, z.core.$strip>>;
181
+ attributions: z.ZodRecord<z.ZodString, z.ZodString>;
182
+ }, z.core.$strip>;
183
+ export interface Persona {
184
+ id: string;
185
+ name: string;
186
+ emoji: string;
187
+ systemPrompt: string;
188
+ focusAreas: string[];
189
+ domains?: string[];
190
+ }
191
+ export interface ExpertReport {
192
+ personaId: string;
193
+ personaName: string;
194
+ personaEmoji: string;
195
+ structuredOutput: StructuredExpertOutput;
196
+ rawContent: string;
197
+ durationMs: number;
198
+ modelUsed: string;
199
+ }
200
+ export interface CouncilResult {
201
+ sessionId: string;
202
+ expertReports: ExpertReport[];
203
+ extractionOutput: ExtractionPhaseOutput;
204
+ critiqueOutput: CritiquePhaseOutput;
205
+ decisionOutput: DecisionPhaseOutput;
206
+ synthesisOutput: SynthesisPhaseOutput;
207
+ finalBlueprint: string;
208
+ consolidationModel: string;
209
+ totalDurationMs: number;
210
+ formattingDetails?: {
211
+ totalFormattingTimeMs: number;
212
+ formattingSuccessRate: number;
213
+ formattingErrors: string[];
214
+ };
215
+ }
216
+ export interface ProseExpertOutput {
217
+ personaId: string;
218
+ analysis: string;
219
+ confidence: number;
220
+ keyInsights: string[];
221
+ }
222
+ export interface FormattedExpertOutput extends StructuredExpertOutput {
223
+ formattingConfidence: number;
224
+ originalProse: string;
225
+ }
226
+ export type StructuredFinding = z.infer<typeof StructuredFindingSchema>;
227
+ export type StructuredRisk = z.infer<typeof StructuredRiskSchema>;
228
+ export type StructuredExpertOutput = z.infer<typeof StructuredExpertOutputSchema>;
229
+ export type ExtractedClaim = z.infer<typeof ExtractedClaimSchema>;
230
+ export type ExtractionPhaseOutput = z.infer<typeof ExtractionPhaseOutputSchema>;
231
+ export type Contradiction = z.infer<typeof ContradictionSchema>;
232
+ export type UnsupportedClaim = z.infer<typeof UnsupportedClaimSchema>;
233
+ export type ReasoningScore = z.infer<typeof ReasoningScoreSchema>;
234
+ export type CritiquePhaseOutput = z.infer<typeof CritiquePhaseOutputSchema>;
235
+ export type Decision = z.infer<typeof DecisionSchema>;
236
+ export type ConflictResolution = z.infer<typeof ConflictResolutionSchema>;
237
+ export type DecisionPhaseOutput = z.infer<typeof DecisionPhaseOutputSchema>;
238
+ export type SynthesisPhaseOutput = z.infer<typeof SynthesisPhaseOutputSchema>;
239
+ /**
240
+ * Convert a Zod schema to OpenAI response_format structure.
241
+ * Strips the $schema key and produces clean JSON Schema for strict mode.
242
+ */
243
+ export declare function toResponseFormat(schema: z.ZodType, name: string): {
244
+ type: "json_schema";
245
+ json_schema: {
246
+ name: string;
247
+ strict: boolean;
248
+ schema: {
249
+ [k: string]: unknown;
250
+ "~standard": z.core.ZodStandardSchemaWithJSON<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
251
+ $id?: string;
252
+ $anchor?: string;
253
+ $ref?: string;
254
+ $dynamicRef?: string;
255
+ $dynamicAnchor?: string;
256
+ $vocabulary?: Record<string, boolean>;
257
+ $comment?: string;
258
+ $defs?: Record<string, z.core.JSONSchema.JSONSchema>;
259
+ type?: "object" | "array" | "string" | "number" | "boolean" | "null" | "integer";
260
+ additionalItems?: z.core.JSONSchema._JSONSchema;
261
+ unevaluatedItems?: z.core.JSONSchema._JSONSchema;
262
+ prefixItems?: z.core.JSONSchema._JSONSchema[];
263
+ items?: z.core.JSONSchema._JSONSchema | z.core.JSONSchema._JSONSchema[];
264
+ contains?: z.core.JSONSchema._JSONSchema;
265
+ additionalProperties?: z.core.JSONSchema._JSONSchema;
266
+ unevaluatedProperties?: z.core.JSONSchema._JSONSchema;
267
+ properties?: Record<string, z.core.JSONSchema._JSONSchema>;
268
+ patternProperties?: Record<string, z.core.JSONSchema._JSONSchema>;
269
+ dependentSchemas?: Record<string, z.core.JSONSchema._JSONSchema>;
270
+ propertyNames?: z.core.JSONSchema._JSONSchema;
271
+ if?: z.core.JSONSchema._JSONSchema;
272
+ then?: z.core.JSONSchema._JSONSchema;
273
+ else?: z.core.JSONSchema._JSONSchema;
274
+ allOf?: z.core.JSONSchema.JSONSchema[];
275
+ anyOf?: z.core.JSONSchema.JSONSchema[];
276
+ oneOf?: z.core.JSONSchema.JSONSchema[];
277
+ not?: z.core.JSONSchema._JSONSchema;
278
+ multipleOf?: number;
279
+ maximum?: number;
280
+ exclusiveMaximum?: number | boolean;
281
+ minimum?: number;
282
+ exclusiveMinimum?: number | boolean;
283
+ maxLength?: number;
284
+ minLength?: number;
285
+ pattern?: string;
286
+ maxItems?: number;
287
+ minItems?: number;
288
+ uniqueItems?: boolean;
289
+ maxContains?: number;
290
+ minContains?: number;
291
+ maxProperties?: number;
292
+ minProperties?: number;
293
+ required?: string[];
294
+ dependentRequired?: Record<string, string[]>;
295
+ enum?: Array<string | number | boolean | null>;
296
+ const?: string | number | boolean | null;
297
+ id?: string;
298
+ title?: string;
299
+ description?: string;
300
+ default?: unknown;
301
+ deprecated?: boolean;
302
+ readOnly?: boolean;
303
+ writeOnly?: boolean;
304
+ nullable?: boolean;
305
+ examples?: unknown[];
306
+ format?: string;
307
+ contentMediaType?: string;
308
+ contentEncoding?: string;
309
+ contentSchema?: z.core.JSONSchema.JSONSchema;
310
+ _prefault?: unknown;
311
+ };
312
+ };
313
+ };