@ankh-studio/ai-enablement 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/LICENSE +21 -0
- package/README.md +243 -0
- package/dist/analyzers/tech-stack-analyzer.d.ts +63 -0
- package/dist/analyzers/tech-stack-analyzer.d.ts.map +1 -0
- package/dist/analyzers/tech-stack-analyzer.js +401 -0
- package/dist/analyzers/tech-stack-analyzer.js.map +1 -0
- package/dist/cli/index.d.ts +9 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +347 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/collectors/evidence-collector.d.ts +57 -0
- package/dist/collectors/evidence-collector.d.ts.map +1 -0
- package/dist/collectors/evidence-collector.js +386 -0
- package/dist/collectors/evidence-collector.js.map +1 -0
- package/dist/core/assessment-engine.d.ts +76 -0
- package/dist/core/assessment-engine.d.ts.map +1 -0
- package/dist/core/assessment-engine.js +310 -0
- package/dist/core/assessment-engine.js.map +1 -0
- package/dist/generators/adr-generator.d.ts +35 -0
- package/dist/generators/adr-generator.d.ts.map +1 -0
- package/dist/generators/adr-generator.js +339 -0
- package/dist/generators/adr-generator.js.map +1 -0
- package/dist/generators-backup-phase-2/adr-generator.d.ts +31 -0
- package/dist/generators-backup-phase-2/adr-generator.d.ts.map +1 -0
- package/dist/generators-backup-phase-2/adr-generator.js +309 -0
- package/dist/generators-backup-phase-2/adr-generator.js.map +1 -0
- package/dist/llm/coalescer.d.ts +45 -0
- package/dist/llm/coalescer.d.ts.map +1 -0
- package/dist/llm/coalescer.js +258 -0
- package/dist/llm/coalescer.js.map +1 -0
- package/dist/llm/copilot-client.d.ts +53 -0
- package/dist/llm/copilot-client.d.ts.map +1 -0
- package/dist/llm/copilot-client.js +198 -0
- package/dist/llm/copilot-client.js.map +1 -0
- package/dist/llm/prompt-templates.d.ts +24 -0
- package/dist/llm/prompt-templates.d.ts.map +1 -0
- package/dist/llm/prompt-templates.js +255 -0
- package/dist/llm/prompt-templates.js.map +1 -0
- package/dist/llm/response-processor.d.ts +50 -0
- package/dist/llm/response-processor.d.ts.map +1 -0
- package/dist/llm/response-processor.js +321 -0
- package/dist/llm/response-processor.js.map +1 -0
- package/dist/llm/structured-types.d.ts +184 -0
- package/dist/llm/structured-types.d.ts.map +1 -0
- package/dist/llm/structured-types.js +61 -0
- package/dist/llm/structured-types.js.map +1 -0
- package/dist/llm/validation.d.ts +57 -0
- package/dist/llm/validation.d.ts.map +1 -0
- package/dist/llm/validation.js +273 -0
- package/dist/llm/validation.js.map +1 -0
- package/dist/llm-backup-phase-1/coalescer.d.ts +40 -0
- package/dist/llm-backup-phase-1/coalescer.d.ts.map +1 -0
- package/dist/llm-backup-phase-1/coalescer.js +209 -0
- package/dist/llm-backup-phase-1/coalescer.js.map +1 -0
- package/dist/llm-backup-phase-1/copilot-client.d.ts +53 -0
- package/dist/llm-backup-phase-1/copilot-client.d.ts.map +1 -0
- package/dist/llm-backup-phase-1/copilot-client.js +198 -0
- package/dist/llm-backup-phase-1/copilot-client.js.map +1 -0
- package/dist/llm-backup-phase-1/prompt-templates.d.ts +23 -0
- package/dist/llm-backup-phase-1/prompt-templates.d.ts.map +1 -0
- package/dist/llm-backup-phase-1/prompt-templates.js +197 -0
- package/dist/llm-backup-phase-1/prompt-templates.js.map +1 -0
- package/dist/llm-backup-phase-1/response-processor.d.ts +44 -0
- package/dist/llm-backup-phase-1/response-processor.d.ts.map +1 -0
- package/dist/llm-backup-phase-1/response-processor.js +200 -0
- package/dist/llm-backup-phase-1/response-processor.js.map +1 -0
- package/dist/llm-backup-phase-1/validation.d.ts +57 -0
- package/dist/llm-backup-phase-1/validation.d.ts.map +1 -0
- package/dist/llm-backup-phase-1/validation.js +273 -0
- package/dist/llm-backup-phase-1/validation.js.map +1 -0
- package/dist/personas/base-persona.d.ts +28 -0
- package/dist/personas/base-persona.d.ts.map +1 -0
- package/dist/personas/base-persona.js +140 -0
- package/dist/personas/base-persona.js.map +1 -0
- package/dist/personas/consultant-persona.d.ts +25 -0
- package/dist/personas/consultant-persona.d.ts.map +1 -0
- package/dist/personas/consultant-persona.js +288 -0
- package/dist/personas/consultant-persona.js.map +1 -0
- package/dist/personas/persona-factory.d.ts +17 -0
- package/dist/personas/persona-factory.d.ts.map +1 -0
- package/dist/personas/persona-factory.js +53 -0
- package/dist/personas/persona-factory.js.map +1 -0
- package/dist/personas/research-backed-consultant.d.ts +12 -0
- package/dist/personas/research-backed-consultant.d.ts.map +1 -0
- package/dist/personas/research-backed-consultant.js +100 -0
- package/dist/personas/research-backed-consultant.js.map +1 -0
- package/dist/personas-backup-phase-1/base-persona.d.ts +28 -0
- package/dist/personas-backup-phase-1/base-persona.d.ts.map +1 -0
- package/dist/personas-backup-phase-1/base-persona.js +140 -0
- package/dist/personas-backup-phase-1/base-persona.js.map +1 -0
- package/dist/personas-backup-phase-1/consultant-persona.d.ts +24 -0
- package/dist/personas-backup-phase-1/consultant-persona.d.ts.map +1 -0
- package/dist/personas-backup-phase-1/consultant-persona.js +197 -0
- package/dist/personas-backup-phase-1/consultant-persona.js.map +1 -0
- package/dist/personas-backup-phase-1/persona-factory.d.ts +17 -0
- package/dist/personas-backup-phase-1/persona-factory.d.ts.map +1 -0
- package/dist/personas-backup-phase-1/persona-factory.js +53 -0
- package/dist/personas-backup-phase-1/persona-factory.js.map +1 -0
- package/dist/scanners/copilot-feature-scanner.d.ts +55 -0
- package/dist/scanners/copilot-feature-scanner.d.ts.map +1 -0
- package/dist/scanners/copilot-feature-scanner.js +259 -0
- package/dist/scanners/copilot-feature-scanner.js.map +1 -0
- package/dist/scorers/readiness-scorer.d.ts +42 -0
- package/dist/scorers/readiness-scorer.d.ts.map +1 -0
- package/dist/scorers/readiness-scorer.js +279 -0
- package/dist/scorers/readiness-scorer.js.map +1 -0
- package/dist/types/persona.d.ts +69 -0
- package/dist/types/persona.d.ts.map +1 -0
- package/dist/types/persona.js +9 -0
- package/dist/types/persona.js.map +1 -0
- package/package.json +77 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copilot SDK Client for LLM Coalescing
|
|
3
|
+
*
|
|
4
|
+
* Provides integration with GitHub Copilot SDK for adversarial
|
|
5
|
+
* fuzzy comprehension of deterministic analysis results
|
|
6
|
+
*/
|
|
7
|
+
export interface CopilotConfig {
|
|
8
|
+
apiKey: string;
|
|
9
|
+
model?: string;
|
|
10
|
+
timeoutMs?: number;
|
|
11
|
+
maxRetries?: number;
|
|
12
|
+
clientName?: string;
|
|
13
|
+
reasoningEffort?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface CopilotRequest {
|
|
16
|
+
prompt: string;
|
|
17
|
+
context?: any;
|
|
18
|
+
maxTokens?: number;
|
|
19
|
+
temperature?: number;
|
|
20
|
+
}
|
|
21
|
+
export interface CopilotResponse {
|
|
22
|
+
content: string;
|
|
23
|
+
tokensUsed: number;
|
|
24
|
+
confidence: number;
|
|
25
|
+
processingTime: number;
|
|
26
|
+
}
|
|
27
|
+
export interface ClientMetrics {
|
|
28
|
+
isInitialized: boolean;
|
|
29
|
+
config: Omit<CopilotConfig, 'apiKey'>;
|
|
30
|
+
requestCount: number;
|
|
31
|
+
failureCount: number;
|
|
32
|
+
fallbackCount: number;
|
|
33
|
+
averageLatency: number;
|
|
34
|
+
}
|
|
35
|
+
export declare class CopilotClient {
|
|
36
|
+
private config;
|
|
37
|
+
private isInitialized;
|
|
38
|
+
private sdkClient;
|
|
39
|
+
private metrics;
|
|
40
|
+
constructor(config: CopilotConfig);
|
|
41
|
+
initialize(): Promise<void>;
|
|
42
|
+
analyze(request: CopilotRequest): Promise<CopilotResponse>;
|
|
43
|
+
private getSystemMessage;
|
|
44
|
+
private updateAverageLatency;
|
|
45
|
+
private extractContent;
|
|
46
|
+
private estimateTokens;
|
|
47
|
+
private calculateConfidence;
|
|
48
|
+
private getFallbackResponse;
|
|
49
|
+
healthCheck(): Promise<boolean>;
|
|
50
|
+
getMetrics(): ClientMetrics;
|
|
51
|
+
shutdown(): Promise<void>;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=copilot-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copilot-client.d.ts","sourceRoot":"","sources":["../../src/llm/copilot-client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,aAAa;IAC5B,aAAa,EAAE,OAAO,CAAC;IACvB,MAAM,EAAE,IAAI,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC;IACtC,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,aAAa,CAAkB;IACvC,OAAO,CAAC,SAAS,CAAiC;IAClD,OAAO,CAAC,OAAO,CAOb;gBAEU,MAAM,EAAE,aAAa;IAoB3B,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IA8B3B,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC;IAwDhE,OAAO,CAAC,gBAAgB;IAWxB,OAAO,CAAC,oBAAoB;IAK5B,OAAO,CAAC,cAAc;IAOtB,OAAO,CAAC,cAAc;IAKtB,OAAO,CAAC,mBAAmB;IAW3B,OAAO,CAAC,mBAAmB;IAarB,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAwBrC,UAAU,IAAI,aAAa;IAIrB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAYhC"}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copilot SDK Client for LLM Coalescing
|
|
4
|
+
*
|
|
5
|
+
* Provides integration with GitHub Copilot SDK for adversarial
|
|
6
|
+
* fuzzy comprehension of deterministic analysis results
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.CopilotClient = void 0;
|
|
10
|
+
const copilot_sdk_1 = require("@github/copilot-sdk");
|
|
11
|
+
class CopilotClient {
|
|
12
|
+
constructor(config) {
|
|
13
|
+
this.isInitialized = false;
|
|
14
|
+
this.sdkClient = null;
|
|
15
|
+
this.metrics = {
|
|
16
|
+
isInitialized: false,
|
|
17
|
+
config: {},
|
|
18
|
+
requestCount: 0,
|
|
19
|
+
failureCount: 0,
|
|
20
|
+
fallbackCount: 0,
|
|
21
|
+
averageLatency: 0,
|
|
22
|
+
};
|
|
23
|
+
this.config = {
|
|
24
|
+
model: process.env["COPILOT_MODEL"] || "gpt-4",
|
|
25
|
+
timeoutMs: parseInt(process.env["COPILOT_TIMEOUT_MS"] || "325"),
|
|
26
|
+
maxRetries: parseInt(process.env["COPILOT_MAX_RETRIES"] || "3"),
|
|
27
|
+
clientName: process.env["COPILOT_CLIENT_NAME"] || "ai-enable-platform",
|
|
28
|
+
reasoningEffort: process.env["COPILOT_REASONING_EFFORT"] || "low",
|
|
29
|
+
...config,
|
|
30
|
+
};
|
|
31
|
+
// Initialize metrics config
|
|
32
|
+
this.metrics.config = {
|
|
33
|
+
model: this.config.model,
|
|
34
|
+
timeoutMs: this.config.timeoutMs,
|
|
35
|
+
maxRetries: this.config.maxRetries,
|
|
36
|
+
clientName: this.config.clientName,
|
|
37
|
+
reasoningEffort: this.config.reasoningEffort,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
async initialize() {
|
|
41
|
+
if (this.isInitialized)
|
|
42
|
+
return;
|
|
43
|
+
try {
|
|
44
|
+
console.log("🤖 Initializing Copilot SDK client...");
|
|
45
|
+
if (!this.config.apiKey) {
|
|
46
|
+
throw new Error("Copilot API key is required");
|
|
47
|
+
}
|
|
48
|
+
// Initialize real Copilot SDK client
|
|
49
|
+
const clientOptions = {
|
|
50
|
+
useStdio: true,
|
|
51
|
+
// Add other options as needed from environment
|
|
52
|
+
};
|
|
53
|
+
this.sdkClient = new copilot_sdk_1.CopilotClient(clientOptions);
|
|
54
|
+
this.isInitialized = true;
|
|
55
|
+
this.metrics.isInitialized = true;
|
|
56
|
+
// Warm up the client - CopilotClient doesn't have initialize method
|
|
57
|
+
// Client is ready after construction
|
|
58
|
+
console.log("✅ Copilot SDK client initialized");
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
console.error("❌ Failed to initialize Copilot SDK:", error);
|
|
62
|
+
this.metrics.failureCount++;
|
|
63
|
+
throw error;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
async analyze(request) {
|
|
67
|
+
if (!this.isInitialized) {
|
|
68
|
+
await this.initialize();
|
|
69
|
+
}
|
|
70
|
+
const startTime = Date.now();
|
|
71
|
+
try {
|
|
72
|
+
this.metrics.requestCount++;
|
|
73
|
+
console.log("🧠 Sending request to Copilot SDK...");
|
|
74
|
+
if (!this.sdkClient) {
|
|
75
|
+
throw new Error("SDK client not initialized");
|
|
76
|
+
}
|
|
77
|
+
// Create a session for the request
|
|
78
|
+
const session = await this.sdkClient.createSession({
|
|
79
|
+
model: this.config.model || "gpt-4",
|
|
80
|
+
systemMessage: { mode: "replace", content: this.getSystemMessage() },
|
|
81
|
+
onPermissionRequest: () => Promise.resolve({ kind: "approved" }),
|
|
82
|
+
});
|
|
83
|
+
// Send the prompt with timeout
|
|
84
|
+
const timeoutPromise = new Promise((_, reject) => {
|
|
85
|
+
setTimeout(() => reject(new Error("Request timeout")), this.config.timeoutMs || 325);
|
|
86
|
+
});
|
|
87
|
+
const requestPromise = session.sendAndWait({
|
|
88
|
+
prompt: request.prompt,
|
|
89
|
+
});
|
|
90
|
+
const response = await Promise.race([requestPromise, timeoutPromise]);
|
|
91
|
+
const processingTime = Date.now() - startTime;
|
|
92
|
+
this.updateAverageLatency(processingTime);
|
|
93
|
+
// Parse the response
|
|
94
|
+
const content = this.extractContent(response);
|
|
95
|
+
const tokensUsed = this.estimateTokens(content, request.prompt);
|
|
96
|
+
const confidence = this.calculateConfidence(content, response);
|
|
97
|
+
return {
|
|
98
|
+
content,
|
|
99
|
+
tokensUsed,
|
|
100
|
+
confidence,
|
|
101
|
+
processingTime,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
console.error("❌ Copilot SDK analysis failed:", error);
|
|
106
|
+
this.metrics.failureCount++;
|
|
107
|
+
// Fallback to deterministic response
|
|
108
|
+
return this.getFallbackResponse(request, Date.now() - startTime);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
getSystemMessage() {
|
|
112
|
+
return `You are an adversarial AI analyst for an AI enablement platform. Your role is to:
|
|
113
|
+
1. Challenge deterministic findings with evidence-grounded skepticism
|
|
114
|
+
2. Identify hidden patterns and connections
|
|
115
|
+
3. Provide alternative interpretations
|
|
116
|
+
4. Maintain professional consultant perspective
|
|
117
|
+
5. Never hallucinate - base all insights on provided evidence
|
|
118
|
+
|
|
119
|
+
Respond in structured JSON format with enhanced insights and adversarial challenges.`;
|
|
120
|
+
}
|
|
121
|
+
updateAverageLatency(latency) {
|
|
122
|
+
const totalLatency = this.metrics.averageLatency * (this.metrics.requestCount - 1) + latency;
|
|
123
|
+
this.metrics.averageLatency = totalLatency / this.metrics.requestCount;
|
|
124
|
+
}
|
|
125
|
+
extractContent(response) {
|
|
126
|
+
if (typeof response === 'string')
|
|
127
|
+
return response;
|
|
128
|
+
if (response?.content)
|
|
129
|
+
return response.content;
|
|
130
|
+
if (response?.text)
|
|
131
|
+
return response.text;
|
|
132
|
+
return JSON.stringify(response);
|
|
133
|
+
}
|
|
134
|
+
estimateTokens(content, prompt) {
|
|
135
|
+
const totalText = content + prompt;
|
|
136
|
+
return Math.floor(totalText.length / 4); // Rough estimation
|
|
137
|
+
}
|
|
138
|
+
calculateConfidence(content, response) {
|
|
139
|
+
// Base confidence on response structure and content quality
|
|
140
|
+
let confidence = 0.7; // Base confidence
|
|
141
|
+
if (content.length > 100)
|
|
142
|
+
confidence += 0.1;
|
|
143
|
+
if (content.includes('evidence') || content.includes('analysis'))
|
|
144
|
+
confidence += 0.1;
|
|
145
|
+
if (response?.model)
|
|
146
|
+
confidence += 0.05;
|
|
147
|
+
return Math.min(confidence, 0.95);
|
|
148
|
+
}
|
|
149
|
+
getFallbackResponse(request, processingTime) {
|
|
150
|
+
this.metrics.fallbackCount++;
|
|
151
|
+
const fallbackContent = "Based on deterministic analysis, I can see patterns that suggest strategic opportunities for AI enablement. The evidence indicates areas where adversarial thinking reveals hidden risks and opportunities.";
|
|
152
|
+
return {
|
|
153
|
+
content: fallbackContent,
|
|
154
|
+
tokensUsed: this.estimateTokens(fallbackContent, request.prompt),
|
|
155
|
+
confidence: 0.6, // Lower confidence for fallback
|
|
156
|
+
processingTime,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
async healthCheck() {
|
|
160
|
+
try {
|
|
161
|
+
if (!this.isInitialized) {
|
|
162
|
+
await this.initialize();
|
|
163
|
+
}
|
|
164
|
+
if (!this.sdkClient) {
|
|
165
|
+
return false;
|
|
166
|
+
}
|
|
167
|
+
// Simple health check - try to create a session
|
|
168
|
+
const session = await this.sdkClient.createSession({
|
|
169
|
+
model: this.config.model || "gpt-4",
|
|
170
|
+
systemMessage: { mode: "replace", content: "Health check" },
|
|
171
|
+
onPermissionRequest: () => Promise.resolve({ kind: "approved" }),
|
|
172
|
+
});
|
|
173
|
+
return !!session;
|
|
174
|
+
}
|
|
175
|
+
catch (error) {
|
|
176
|
+
console.error("❌ Copilot SDK health check failed:", error);
|
|
177
|
+
return false;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
getMetrics() {
|
|
181
|
+
return { ...this.metrics };
|
|
182
|
+
}
|
|
183
|
+
async shutdown() {
|
|
184
|
+
if (this.sdkClient) {
|
|
185
|
+
try {
|
|
186
|
+
// Clean up SDK client if needed
|
|
187
|
+
this.sdkClient = null;
|
|
188
|
+
}
|
|
189
|
+
catch (error) {
|
|
190
|
+
console.error("Error during shutdown:", error);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
this.isInitialized = false;
|
|
194
|
+
this.metrics.isInitialized = false;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
exports.CopilotClient = CopilotClient;
|
|
198
|
+
//# sourceMappingURL=copilot-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copilot-client.js","sourceRoot":"","sources":["../../src/llm/copilot-client.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,qDAAmG;AAiCnG,MAAa,aAAa;IAaxB,YAAY,MAAqB;QAXzB,kBAAa,GAAY,KAAK,CAAC;QAC/B,cAAS,GAA4B,IAAI,CAAC;QAC1C,YAAO,GAAkB;YAC/B,aAAa,EAAE,KAAK;YACpB,MAAM,EAAE,EAAmC;YAC3C,YAAY,EAAE,CAAC;YACf,YAAY,EAAE,CAAC;YACf,aAAa,EAAE,CAAC;YAChB,cAAc,EAAE,CAAC;SAClB,CAAC;QAGA,IAAI,CAAC,MAAM,GAAG;YACZ,KAAK,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ACD,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC;QAC3B,IAAI,CAAC,OAAO,CAAC,aAAa,GAAG,KAAK,CAAC;IACrC,CAAC;CACF;AAnND,sCAmNC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Persona-Specific Prompt Templates for LLM Coalescing
|
|
3
|
+
*
|
|
4
|
+
* Provides adversarial prompting strategies tailored to each expert persona
|
|
5
|
+
* while maintaining their unique perspective and voice
|
|
6
|
+
*/
|
|
7
|
+
import { PersonaContext, PersonaInsight } from "../types/persona";
|
|
8
|
+
export interface PromptTemplate {
|
|
9
|
+
systemPrompt: string;
|
|
10
|
+
adversarialContext: string;
|
|
11
|
+
outputFormat: string;
|
|
12
|
+
constraints: string[];
|
|
13
|
+
}
|
|
14
|
+
export declare class PromptTemplateManager {
|
|
15
|
+
private static templates;
|
|
16
|
+
static getTemplate(personaType: string): PromptTemplate;
|
|
17
|
+
static buildCoalescingPrompt(personaType: string, deterministicInsights: PersonaInsight[], context: PersonaContext): string;
|
|
18
|
+
static buildValidationPrompt(enhancedInsights: PersonaInsight[], adversarialChallenges: string[], personaType: string): string;
|
|
19
|
+
static getStructuredTemplate(personaType: string): PromptTemplate;
|
|
20
|
+
static getAllPersonaTypes(): string[];
|
|
21
|
+
static addTemplate(personaType: string, template: PromptTemplate): void;
|
|
22
|
+
static updateTemplate(personaType: string, updates: Partial<PromptTemplate>): void;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=prompt-templates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-templates.d.ts","sourceRoot":"","sources":["../../src/llm/prompt-templates.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElE,MAAM,WAAW,cAAc;IAC7B,YAAY,EAAE,MAAM,CAAC;IACrB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAED,qBAAa,qBAAqB;IAChC,OAAO,CAAC,MAAM,CAAC,SAAS,CAmHrB;IAEH,MAAM,CAAC,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,cAAc;IAQvD,MAAM,CAAC,qBAAqB,CAC1B,WAAW,EAAE,MAAM,EACnB,qBAAqB,EAAE,cAAc,EAAE,EACvC,OAAO,EAAE,cAAc,GACtB,MAAM;IAmCT,MAAM,CAAC,qBAAqB,CAC1B,gBAAgB,EAAE,cAAc,EAAE,EAClC,qBAAqB,EAAE,MAAM,EAAE,EAC/B,WAAW,EAAE,MAAM,GAClB,MAAM;IAiCT,MAAM,CAAC,qBAAqB,CAAC,WAAW,EAAE,MAAM,GAAG,cAAc;IA6DjE,MAAM,CAAC,kBAAkB,IAAI,MAAM,EAAE;IAIrC,MAAM,CAAC,WAAW,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,GAAG,IAAI;IAIvE,MAAM,CAAC,cAAc,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,IAAI;CAOnF"}
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Persona-Specific Prompt Templates for LLM Coalescing
|
|
4
|
+
*
|
|
5
|
+
* Provides adversarial prompting strategies tailored to each expert persona
|
|
6
|
+
* while maintaining their unique perspective and voice
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.PromptTemplateManager = void 0;
|
|
10
|
+
class PromptTemplateManager {
|
|
11
|
+
static getTemplate(personaType) {
|
|
12
|
+
const template = this.templates.get(personaType);
|
|
13
|
+
if (!template) {
|
|
14
|
+
throw new Error(`No prompt template found for persona type: ${personaType}`);
|
|
15
|
+
}
|
|
16
|
+
return template;
|
|
17
|
+
}
|
|
18
|
+
static buildCoalescingPrompt(personaType, deterministicInsights, context) {
|
|
19
|
+
const template = this.getTemplate(personaType);
|
|
20
|
+
const insightsText = deterministicInsights
|
|
21
|
+
.map((insight, index) => `${index + 1}. ${insight.title} (${insight.priority}): ${insight.description}`)
|
|
22
|
+
.join("\n");
|
|
23
|
+
const scoresText = `
|
|
24
|
+
Repository Readiness: ${context.scores.repoReadiness}/100
|
|
25
|
+
Team Readiness: ${context.scores.teamReadiness}/100
|
|
26
|
+
Organization Readiness: ${context.scores.orgReadiness}/100
|
|
27
|
+
Overall Maturity: ${context.scores.overallMaturity}/8
|
|
28
|
+
`.trim();
|
|
29
|
+
return `${template.systemPrompt}
|
|
30
|
+
|
|
31
|
+
${template.adversarialContext}
|
|
32
|
+
|
|
33
|
+
DETERMINISTIC INSIGHTS TO ANALYZE:
|
|
34
|
+
${insightsText}
|
|
35
|
+
|
|
36
|
+
ASSESSMENT SCORES:
|
|
37
|
+
${scoresText}
|
|
38
|
+
|
|
39
|
+
${template.outputFormat}
|
|
40
|
+
|
|
41
|
+
CONSTRAINTS:
|
|
42
|
+
${template.constraints.map(constraint => `- ${constraint}`).join("\n")}
|
|
43
|
+
|
|
44
|
+
Remember: Your role is to be constructively critical while maintaining evidence-based reasoning. Do not hallucinate - base all challenges on the provided evidence and your persona's unique perspective.`;
|
|
45
|
+
}
|
|
46
|
+
static buildValidationPrompt(enhancedInsights, adversarialChallenges, personaType) {
|
|
47
|
+
const template = this.getTemplate(personaType);
|
|
48
|
+
const insightsText = enhancedInsights
|
|
49
|
+
.map((insight, index) => `${index + 1}. ${insight.title}: ${insight.description}`)
|
|
50
|
+
.join("\n");
|
|
51
|
+
const challengesText = adversarialChallenges
|
|
52
|
+
.map((challenge, index) => `${index + 1}. ${challenge}`)
|
|
53
|
+
.join("\n");
|
|
54
|
+
return `${template.systemPrompt}
|
|
55
|
+
|
|
56
|
+
VALIDATION TASK:
|
|
57
|
+
Review your enhanced insights and adversarial challenges for consistency and quality.
|
|
58
|
+
|
|
59
|
+
ENHANCED INSIGHTS:
|
|
60
|
+
${insightsText}
|
|
61
|
+
|
|
62
|
+
ADVERSARIAL CHALLENGES:
|
|
63
|
+
${challengesText}
|
|
64
|
+
|
|
65
|
+
Please validate:
|
|
66
|
+
1. Are all enhanced insights grounded in the original evidence?
|
|
67
|
+
2. Do adversarial challenges provide meaningful criticism?
|
|
68
|
+
3. Is the perspective consistent with your persona?
|
|
69
|
+
4. Are confidence levels realistic?
|
|
70
|
+
|
|
71
|
+
Respond with:
|
|
72
|
+
VALIDATION_RESULT: [PASS/FAIL]
|
|
73
|
+
VALIDATION_NOTES: [Specific feedback on quality and consistency]`;
|
|
74
|
+
}
|
|
75
|
+
static getStructuredTemplate(personaType) {
|
|
76
|
+
const baseTemplate = this.getTemplate(personaType);
|
|
77
|
+
return {
|
|
78
|
+
...baseTemplate,
|
|
79
|
+
outputFormat: `${baseTemplate.outputFormat}
|
|
80
|
+
|
|
81
|
+
IMPORTANT: You must also provide a structured JSON response with the following format:
|
|
82
|
+
|
|
83
|
+
{
|
|
84
|
+
"insights": [
|
|
85
|
+
{
|
|
86
|
+
"id": "insight-1",
|
|
87
|
+
"title": "Brief title of the insight",
|
|
88
|
+
"description": "Detailed description of the insight",
|
|
89
|
+
"priority": "critical|high|medium|low",
|
|
90
|
+
"confidence": 0.8,
|
|
91
|
+
"evidenceIds": ["evidence-id-1", "evidence-id-2"],
|
|
92
|
+
"adversarialChallenge": "Specific challenge to assumptions",
|
|
93
|
+
"strategicImplication": "Strategic business implication",
|
|
94
|
+
"category": "strategy|risk|opportunity|implementation",
|
|
95
|
+
"timeframe": "immediate|short-term|medium-term|long-term",
|
|
96
|
+
"effort": "small|medium|large"
|
|
97
|
+
}
|
|
98
|
+
],
|
|
99
|
+
"confidence": 0.75,
|
|
100
|
+
"evidenceValidation": {
|
|
101
|
+
"totalInsights": 3,
|
|
102
|
+
"groundedInsights": 2,
|
|
103
|
+
"missingEvidence": ["evidence-id-3"],
|
|
104
|
+
"invalidEvidence": [],
|
|
105
|
+
"groundingScore": 0.67
|
|
106
|
+
},
|
|
107
|
+
"processingTime": 150,
|
|
108
|
+
"metadata": {
|
|
109
|
+
"model": "gpt-4",
|
|
110
|
+
"tokensUsed": 450,
|
|
111
|
+
"temperature": 0.3,
|
|
112
|
+
"reasoningEffort": "low",
|
|
113
|
+
"sessionId": "session-123",
|
|
114
|
+
"timestamp": 1642694400000
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
Requirements for JSON response:
|
|
119
|
+
1. All insights MUST cite valid evidence IDs from the provided evidence
|
|
120
|
+
2. Confidence scores (0-1) must be realistic and evidence-based
|
|
121
|
+
3. Evidence validation must accurately reflect grounding quality
|
|
122
|
+
4. Processing time should be estimated in milliseconds
|
|
123
|
+
5. Metadata should reflect the analysis parameters`,
|
|
124
|
+
constraints: [
|
|
125
|
+
...baseTemplate.constraints,
|
|
126
|
+
"JSON response must be valid and complete",
|
|
127
|
+
"All evidence IDs must reference actual evidence provided",
|
|
128
|
+
"Confidence scores must be evidence-based",
|
|
129
|
+
"Evidence validation must be accurate"
|
|
130
|
+
]
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
static getAllPersonaTypes() {
|
|
134
|
+
return Array.from(this.templates.keys());
|
|
135
|
+
}
|
|
136
|
+
static addTemplate(personaType, template) {
|
|
137
|
+
this.templates.set(personaType, template);
|
|
138
|
+
}
|
|
139
|
+
static updateTemplate(personaType, updates) {
|
|
140
|
+
const existing = this.templates.get(personaType);
|
|
141
|
+
if (!existing) {
|
|
142
|
+
throw new Error(`Cannot update non-existent template: ${personaType}`);
|
|
143
|
+
}
|
|
144
|
+
this.templates.set(personaType, { ...existing, ...updates });
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
exports.PromptTemplateManager = PromptTemplateManager;
|
|
148
|
+
PromptTemplateManager.templates = new Map([
|
|
149
|
+
[
|
|
150
|
+
"consultant",
|
|
151
|
+
{
|
|
152
|
+
systemPrompt: `You are an experienced AI Strategy Consultant with deep expertise in business transformation and organizational change management. Your perspective: "AI adoption succeeds when business value drives technology decisions, not the other way around."
|
|
153
|
+
|
|
154
|
+
Your role is to provide adversarial analysis that challenges assumptions while maintaining focus on business outcomes, ROI, and organizational readiness.`,
|
|
155
|
+
adversarialContext: `Apply your consultant's skepticism and business acumen to:
|
|
156
|
+
- Question whether technical solutions address real business problems
|
|
157
|
+
- Challenge assumptions about ROI and business value
|
|
158
|
+
- Identify organizational risks that technical analysis might miss
|
|
159
|
+
- Assess whether the proposed approach aligns with business strategy
|
|
160
|
+
- Consider change management and stakeholder implications`,
|
|
161
|
+
outputFormat: `Provide your analysis in this exact format:
|
|
162
|
+
|
|
163
|
+
ENHANCED_INSIGHTS:
|
|
164
|
+
- [Business-focused insight with strategic implications]
|
|
165
|
+
- [ROI assessment with measurable outcomes]
|
|
166
|
+
- [Risk analysis with business impact]
|
|
167
|
+
|
|
168
|
+
ADVERSARIAL_CHALLENGES:
|
|
169
|
+
- [Challenge to business assumptions]
|
|
170
|
+
- [Question about value proposition]
|
|
171
|
+
- [Organizational readiness concern]
|
|
172
|
+
|
|
173
|
+
CONFIDENCE_ASSESSMENT:
|
|
174
|
+
[Business confidence level and key uncertainties]`,
|
|
175
|
+
constraints: [
|
|
176
|
+
"Always ground insights in business value and measurable outcomes",
|
|
177
|
+
"Challenge technical solutions that don't address clear business problems",
|
|
178
|
+
"Consider executive sponsorship and organizational change requirements",
|
|
179
|
+
"Focus on ROI and stakeholder alignment",
|
|
180
|
+
"Maintain consultant's strategic perspective",
|
|
181
|
+
],
|
|
182
|
+
},
|
|
183
|
+
],
|
|
184
|
+
[
|
|
185
|
+
"evangelist",
|
|
186
|
+
{
|
|
187
|
+
systemPrompt: `You are a Technology Evangelist passionate about innovation and cutting-edge AI capabilities. Your perspective: "The future is already here, it's just not evenly distributed yet."
|
|
188
|
+
|
|
189
|
+
Your role is to provide adversarial analysis that identifies opportunities for innovation while ensuring technical excellence and best practices.`,
|
|
190
|
+
adversarialContext: `Apply your evangelist's enthusiasm and technical expertise to:
|
|
191
|
+
- Identify innovative opportunities that deterministic analysis might miss
|
|
192
|
+
- Challenge conservative approaches that limit potential
|
|
193
|
+
- Assess whether the technology stack is future-ready
|
|
194
|
+
- Highlight opportunities for thought leadership and innovation
|
|
195
|
+
- Consider industry trends and competitive advantages`,
|
|
196
|
+
outputFormat: `Provide your analysis in this exact format:
|
|
197
|
+
|
|
198
|
+
ENHANCED_INSIGHTS:
|
|
199
|
+
- [Innovation opportunity with technical details]
|
|
200
|
+
- [Cutting-edge approach with implementation guidance]
|
|
201
|
+
- [Future-ready assessment with technology roadmap]
|
|
202
|
+
|
|
203
|
+
ADVERSARIAL_CHALLENGES:
|
|
204
|
+
- [Challenge to conservative technical choices]
|
|
205
|
+
- [Question about innovation potential]
|
|
206
|
+
- [Technology trend concern]
|
|
207
|
+
|
|
208
|
+
CONFIDENCE_ASSESSMENT:
|
|
209
|
+
[Technical confidence level and innovation risks]`,
|
|
210
|
+
constraints: [
|
|
211
|
+
"Always ground insights in technical excellence and innovation",
|
|
212
|
+
"Challenge approaches that miss emerging opportunities",
|
|
213
|
+
"Consider future-readiness and scalability",
|
|
214
|
+
"Focus on technical innovation and best practices",
|
|
215
|
+
"Maintain evangelist's passion for cutting-edge solutions",
|
|
216
|
+
],
|
|
217
|
+
},
|
|
218
|
+
],
|
|
219
|
+
[
|
|
220
|
+
"teamlead",
|
|
221
|
+
{
|
|
222
|
+
systemPrompt: `You are an experienced Team Lead focused on practical implementation, team dynamics, and delivery excellence. Your perspective: "Success is determined by what gets shipped and how the team grows together."
|
|
223
|
+
|
|
224
|
+
Your role is to provide adversarial analysis that assesses practical implementation challenges while ensuring team readiness and sustainable delivery.`,
|
|
225
|
+
adversarialContext: `Apply your team lead's practical experience to:
|
|
226
|
+
- Question implementation feasibility and team capacity
|
|
227
|
+
- Challenge assumptions about team skills and readiness
|
|
228
|
+
- Assess whether the approach supports sustainable delivery
|
|
229
|
+
- Identify practical obstacles and coordination challenges
|
|
230
|
+
- Consider team dynamics and skill development needs`,
|
|
231
|
+
outputFormat: `Provide your analysis in this exact format:
|
|
232
|
+
|
|
233
|
+
ENHANCED_INSIGHTS:
|
|
234
|
+
- [Implementation insight with practical steps]
|
|
235
|
+
- [Team readiness assessment with skill gaps]
|
|
236
|
+
- [Delivery plan with realistic timelines]
|
|
237
|
+
|
|
238
|
+
ADVERSARIAL_CHALLENGES:
|
|
239
|
+
- [Challenge to implementation assumptions]
|
|
240
|
+
- [Question about team capacity]
|
|
241
|
+
- [Delivery feasibility concern]
|
|
242
|
+
|
|
243
|
+
CONFIDENCE_ASSESSMENT:
|
|
244
|
+
[Implementation confidence level and execution risks]`,
|
|
245
|
+
constraints: [
|
|
246
|
+
"Always ground insights in practical implementation and team reality",
|
|
247
|
+
"Challenge approaches that ignore team capacity or skill gaps",
|
|
248
|
+
"Consider sustainable delivery and team health",
|
|
249
|
+
"Focus on execution and measurable progress",
|
|
250
|
+
"Maintain team lead's focus on shipping and team growth",
|
|
251
|
+
],
|
|
252
|
+
},
|
|
253
|
+
],
|
|
254
|
+
]);
|
|
255
|
+
//# sourceMappingURL=prompt-templates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-templates.js","sourceRoot":"","sources":["../../src/llm/prompt-templates.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAWH,MAAa,qBAAqB;IAsHhC,MAAM,CAAC,WAAW,CAAC,WAAmB;QACpC,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QACjD,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,IAAI,KAAK,CAAC,8CAA8C,WAAW,EAAE,CAAC,CAAC;QAC/E,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,MAAM,CAAC,qBAAqB,CAC1B,WAAmB,EACnB,qBAAuC,EACvC,OAAuB;QAE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AI,GAAG,CAAC;IAC9D;QACE,YAAY;QACZ;YACE,YAAY,EAAE;;0JAEoI;YAElJ,kBAAkB,EAAE;;;;;0DAK8B;YAElD,YAAY,EAAE;;;;;;;;;;;;;kDAa4B;YAE1C,WAAW,EAAE;gBACX,kEAAkE;gBAClE,0EAA0E;gBAC1E,uEAAuE;gBACvE,wCAAwC;gBACxC,6CAA6C;aAC9C;SACF;KACF;IACD;QACE,YAAY;QACZ;YACE,YAAY,EAAE;;kJAE4H;YAE1I,kBAAkB,EAAE;;;;;sDAK0B;YAE9C,YAAY,EAAE;;;;;;;;;;;;;kDAa4B;YAE1C,WAAW,EAAE;gBACX,+DAA+D;gBAC/D,uDAAuD;gBACvD,2CAA2C;gBAC3C,kDAAkD;gBAClD,0DAA0D;aAC3D;SACF;KACF;IACD;QACE,UAAU;QACV;YACE,YAAY,EAAE;;uJAEiI;YAE/I,kBAAkB,EAAE;;;;;qDAKyB;YAE7C,YAAY,EAAE;;;;;;;;;;;;;sDAagC;YAE9C,WAAW,EAAE;gBACX,qEAAqE;gBACrE,8DAA8D;gBAC9D,+CAA+C;gBAC/C,4CAA4C;gBAC5C,wDAAwD;aACzD;SACF;KACF;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LLM Response Processor
|
|
3
|
+
*
|
|
4
|
+
* Handles structured parsing and validation of LLM responses
|
|
5
|
+
* for adversarial coalescing with deterministic analysis
|
|
6
|
+
*/
|
|
7
|
+
import { PersonaInsight } from "../types/persona";
|
|
8
|
+
import { AdversarialInsight, CoalescingValidationResult, EvidenceReference, EvidenceValidation, StructuredAdversarialResponse } from "./structured-types";
|
|
9
|
+
export interface ParsedLLMResponse {
|
|
10
|
+
enhancedInsights: string[];
|
|
11
|
+
adversarialChallenges: string[];
|
|
12
|
+
confidenceAssessment: string;
|
|
13
|
+
rawContent: string;
|
|
14
|
+
structuredResponse?: StructuredAdversarialResponse | undefined;
|
|
15
|
+
}
|
|
16
|
+
export interface ValidationResult {
|
|
17
|
+
isValid: boolean;
|
|
18
|
+
confidence: number;
|
|
19
|
+
issues: string[];
|
|
20
|
+
suggestions: string[];
|
|
21
|
+
}
|
|
22
|
+
export declare class ResponseProcessor {
|
|
23
|
+
private static readonly SECTION_PATTERNS;
|
|
24
|
+
private static readonly VALIDATION_RESULT_PATTERN;
|
|
25
|
+
private static readonly VALIDATION_NOTES_PATTERN;
|
|
26
|
+
static parseCoalescingResponse(llmContent: string): ParsedLLMResponse;
|
|
27
|
+
static parseValidationResponse(llmContent: string): ValidationResult;
|
|
28
|
+
static processEnhancedInsights(enhancedTexts: string[], deterministicInsights: PersonaInsight[]): PersonaInsight[];
|
|
29
|
+
static validateResponseStructure(parsed: ParsedLLMResponse): ValidationResult;
|
|
30
|
+
private static extractSection;
|
|
31
|
+
private static extractIssues;
|
|
32
|
+
private static extractSuggestions;
|
|
33
|
+
private static calculateValidationConfidence;
|
|
34
|
+
private static createEnhancedInsight;
|
|
35
|
+
private static createNewInsight;
|
|
36
|
+
private static extractTitleFromText;
|
|
37
|
+
static sanitizeResponse(content: string): string;
|
|
38
|
+
static extractMetrics(parsed: ParsedLLMResponse): {
|
|
39
|
+
insightCount: number;
|
|
40
|
+
challengeCount: number;
|
|
41
|
+
averageInsightLength: number;
|
|
42
|
+
averageChallengeLength: number;
|
|
43
|
+
hasConfidenceAssessment: boolean;
|
|
44
|
+
};
|
|
45
|
+
static parseStructuredResponse(llmContent: string): ParsedLLMResponse;
|
|
46
|
+
static validateStructuredResponse(response: StructuredAdversarialResponse): CoalescingValidationResult;
|
|
47
|
+
static validateEvidenceGrounding(insights: AdversarialInsight[], availableEvidence: EvidenceReference[]): EvidenceValidation;
|
|
48
|
+
private static generateSuggestions;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=response-processor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response-processor.d.ts","sourceRoot":"","sources":["../../src/llm/response-processor.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