@praxisui/ai 0.0.1
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/.npmrc.npmjs +3 -0
- package/README.md +149 -0
- package/fesm2022/praxisui-ai.mjs +6407 -0
- package/fesm2022/praxisui-ai.mjs.map +1 -0
- package/index.d.ts +1216 -0
- package/package.json +24 -0
package/index.d.ts
ADDED
|
@@ -0,0 +1,1216 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { OnInit, ChangeDetectorRef, OnDestroy, ElementRef } from '@angular/core';
|
|
3
|
+
import * as _praxisui_core from '@praxisui/core';
|
|
4
|
+
import { AiValueKind, AiCapability, GlobalConfigService, GlobalAiConfig, RulePropertySchema } from '@praxisui/core';
|
|
5
|
+
import { Observable } from 'rxjs';
|
|
6
|
+
import { Schema } from '@google/generative-ai';
|
|
7
|
+
import { MatDialogRef } from '@angular/material/dialog';
|
|
8
|
+
import { MatSnackBar } from '@angular/material/snack-bar';
|
|
9
|
+
import { FunctionRegistry, ContextProvider, ValidationIssue } from '@praxisui/specification';
|
|
10
|
+
import { CdkOverlayOrigin } from '@angular/cdk/overlay';
|
|
11
|
+
|
|
12
|
+
declare class PraxisAi {
|
|
13
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<PraxisAi, never>;
|
|
14
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<PraxisAi, "lib-praxis-ai", never, {}, {}, never, never, true, never>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Models for Praxis AI (Centralized)
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Response structure expected from the AI model
|
|
23
|
+
*/
|
|
24
|
+
interface AiRuleResponse {
|
|
25
|
+
/** Descriptive name for the rule */
|
|
26
|
+
ruleName: string;
|
|
27
|
+
/** Type of target (scope) */
|
|
28
|
+
targetType: 'field' | 'section' | 'action' | 'row' | 'column';
|
|
29
|
+
/** IDs of the target elements */
|
|
30
|
+
targetIds: string[];
|
|
31
|
+
/** Condition in DSL format (e.g., "age >= 18") or null for always applied */
|
|
32
|
+
conditionDsl: string | null;
|
|
33
|
+
/** Effects to apply */
|
|
34
|
+
effects: {
|
|
35
|
+
/** Properties to apply when condition is true */
|
|
36
|
+
properties?: Record<string, any>;
|
|
37
|
+
/** Properties to apply when condition is false (else) */
|
|
38
|
+
propertiesWhenFalse?: Record<string, any>;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Minified field representation for AI context (token optimization)
|
|
43
|
+
*/
|
|
44
|
+
interface MinifiedField {
|
|
45
|
+
id: string;
|
|
46
|
+
label: string;
|
|
47
|
+
type: string;
|
|
48
|
+
category?: string;
|
|
49
|
+
allowedValues?: Array<{
|
|
50
|
+
value: any;
|
|
51
|
+
label: string;
|
|
52
|
+
}>;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Context structure sent to the AI
|
|
56
|
+
*/
|
|
57
|
+
interface PromptContext {
|
|
58
|
+
/** List of available fields formatted for the prompt */
|
|
59
|
+
fieldsText: string;
|
|
60
|
+
/** List of available properties for the selected target type */
|
|
61
|
+
propertiesText: string;
|
|
62
|
+
/** List of supported DSL operators */
|
|
63
|
+
operatorsText: string;
|
|
64
|
+
/** Selected target type */
|
|
65
|
+
targetType: string;
|
|
66
|
+
/** Structured list of fields for richer prompt suggestions */
|
|
67
|
+
minifiedFields?: MinifiedField[];
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Example pair for Few-Shot Learning
|
|
71
|
+
*/
|
|
72
|
+
interface AiExamplePair {
|
|
73
|
+
userPrompt: string;
|
|
74
|
+
expectedResponse: AiRuleResponse;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Configuration for the AI Service
|
|
78
|
+
*/
|
|
79
|
+
interface AiIntegrationConfig {
|
|
80
|
+
/** LLM provider (gemini/openai/xai/mock) */
|
|
81
|
+
provider?: string;
|
|
82
|
+
/** Gemini API Key (optional if using proxy/env) */
|
|
83
|
+
apiKey?: string;
|
|
84
|
+
/** Model version to use */
|
|
85
|
+
model: string;
|
|
86
|
+
/** Temperature (creativity vs determinism) */
|
|
87
|
+
temperature: number;
|
|
88
|
+
/** Max output tokens */
|
|
89
|
+
maxTokens: number;
|
|
90
|
+
/** Request timeout in ms */
|
|
91
|
+
timeout: number;
|
|
92
|
+
/** Number of retry attempts */
|
|
93
|
+
retryAttempts: number;
|
|
94
|
+
/** Optional: Backend gateway URL for Enterprise mode */
|
|
95
|
+
gatewayUrl?: string;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Result of validating an AI response
|
|
99
|
+
*/
|
|
100
|
+
interface AiValidationResult {
|
|
101
|
+
valid: boolean;
|
|
102
|
+
errors: AiValidationError[];
|
|
103
|
+
warnings: AiValidationWarning[];
|
|
104
|
+
correctedResponse?: AiRuleResponse;
|
|
105
|
+
}
|
|
106
|
+
interface AiValidationError {
|
|
107
|
+
field: string;
|
|
108
|
+
message: string;
|
|
109
|
+
severity: 'critical' | 'error' | 'warning';
|
|
110
|
+
code: string;
|
|
111
|
+
}
|
|
112
|
+
interface AiValidationWarning {
|
|
113
|
+
field: string;
|
|
114
|
+
message: string;
|
|
115
|
+
suggestion?: string;
|
|
116
|
+
}
|
|
117
|
+
interface AiModel {
|
|
118
|
+
name: string;
|
|
119
|
+
version: string;
|
|
120
|
+
displayName: string;
|
|
121
|
+
description: string;
|
|
122
|
+
inputTokenLimit: number;
|
|
123
|
+
outputTokenLimit: number;
|
|
124
|
+
supportedGenerationMethods: string[];
|
|
125
|
+
temperature?: number;
|
|
126
|
+
topP?: number;
|
|
127
|
+
topK?: number;
|
|
128
|
+
}
|
|
129
|
+
type ValueKind = AiValueKind;
|
|
130
|
+
type Capability = AiCapability;
|
|
131
|
+
|
|
132
|
+
declare class PraxisAiService {
|
|
133
|
+
private globalConfigService;
|
|
134
|
+
private genAI;
|
|
135
|
+
private config;
|
|
136
|
+
constructor(globalConfigService: GlobalConfigService);
|
|
137
|
+
private syncConfig;
|
|
138
|
+
classifyIntent(userInput: string, columns: string[]): Observable<any>;
|
|
139
|
+
answerQuestion(userInput: string, targetConfig: any): Observable<string>;
|
|
140
|
+
executeEnrichedPrompt(userInput: string, contextDescription: string, targetConfig: any, capabilities: any): Observable<any>;
|
|
141
|
+
private formatCapabilities;
|
|
142
|
+
private normalizeIntentClassification;
|
|
143
|
+
generateContent(prompt: string, modelName?: string): Observable<string>;
|
|
144
|
+
generateContentStream(prompt: string, modelName?: string): Observable<string>;
|
|
145
|
+
generateJson<T>(prompt: string, modelName?: string, schema?: any): Observable<T | null>;
|
|
146
|
+
isMockMode(): boolean;
|
|
147
|
+
private extractUserIntent;
|
|
148
|
+
private getMockPatch;
|
|
149
|
+
listModels(apiKey?: string): Observable<AiModel[]>;
|
|
150
|
+
testConnection(apiKey?: string, model?: string): Observable<boolean>;
|
|
151
|
+
private resolveProvider;
|
|
152
|
+
private isGeminiProvider;
|
|
153
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<PraxisAiService, [{ optional: true; }]>;
|
|
154
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<PraxisAiService>;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
declare class AiConfigService {
|
|
158
|
+
private globalConfig;
|
|
159
|
+
getConfig(): AiIntegrationConfig;
|
|
160
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<AiConfigService, never>;
|
|
161
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<AiConfigService>;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
interface PatchResult {
|
|
165
|
+
success: boolean;
|
|
166
|
+
warnings?: string[];
|
|
167
|
+
error?: string;
|
|
168
|
+
}
|
|
169
|
+
interface AiSuggestion {
|
|
170
|
+
id: string;
|
|
171
|
+
label: string;
|
|
172
|
+
description?: string;
|
|
173
|
+
icon?: string;
|
|
174
|
+
group?: string;
|
|
175
|
+
intent: string;
|
|
176
|
+
score?: number;
|
|
177
|
+
variantId?: string;
|
|
178
|
+
patch?: Record<string, unknown> | null;
|
|
179
|
+
contextHints?: Record<string, unknown> | null;
|
|
180
|
+
missingContext?: string[];
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Contrato fundamental para qualquer componente que suporte configuração via IA.
|
|
184
|
+
* O Agente de IA usa esta interface para Ler (Introspecção) e Escrever (Patching) no componente.
|
|
185
|
+
*/
|
|
186
|
+
interface AiConfigAdapter<TConfig = any> {
|
|
187
|
+
/**
|
|
188
|
+
* Nome legível do componente para o contexto do prompt (ex: "Data Table").
|
|
189
|
+
*/
|
|
190
|
+
componentName: string;
|
|
191
|
+
/**
|
|
192
|
+
* ID do componente (selector) usado pelo backend AI registry (ex: "praxis-table").
|
|
193
|
+
*/
|
|
194
|
+
componentId?: string;
|
|
195
|
+
/**
|
|
196
|
+
* Tipo lógico do componente para contexto (ex: "table", "form").
|
|
197
|
+
*/
|
|
198
|
+
componentType?: string;
|
|
199
|
+
/**
|
|
200
|
+
* Retorna o objeto de configuração serializável atual.
|
|
201
|
+
* Usado para que a IA entenda o estado inicial.
|
|
202
|
+
*/
|
|
203
|
+
getCurrentConfig(): TConfig;
|
|
204
|
+
/**
|
|
205
|
+
* Retorna o catálogo de capacidades (o que a IA pode mudar).
|
|
206
|
+
* Deve ser o conteúdo do arquivo `_ai-capabilities.ts`.
|
|
207
|
+
*/
|
|
208
|
+
getCapabilities(): Capability[];
|
|
209
|
+
/**
|
|
210
|
+
* Retorna exemplos de intenção ou presets de tarefas suportados.
|
|
211
|
+
* Útil para filtrar capabilities no prompt.
|
|
212
|
+
* @deprecated Use getSuggestions() for richer context.
|
|
213
|
+
*/
|
|
214
|
+
getTaskPresets?(): Record<string, string[]>;
|
|
215
|
+
/**
|
|
216
|
+
* Retorna sugestões contextuais baseadas na config atual e dados (Heurísticas).
|
|
217
|
+
* Substitui ou complementa os presets estáticos.
|
|
218
|
+
*/
|
|
219
|
+
getSuggestions?(forceReload?: boolean): Promise<AiSuggestion[]>;
|
|
220
|
+
/**
|
|
221
|
+
* Retorna contexto adicional para geração de sugestões (ex.: recursos disponíveis).
|
|
222
|
+
*/
|
|
223
|
+
getSuggestionContext?(): Record<string, any>;
|
|
224
|
+
/**
|
|
225
|
+
* Retorna o perfil de dados atual (ex.: estatísticas por coluna).
|
|
226
|
+
* Usado para sugestões determinísticas no backend.
|
|
227
|
+
*/
|
|
228
|
+
getDataProfile?(): Record<string, any>;
|
|
229
|
+
/**
|
|
230
|
+
* Retorna hints de schema por campo (ex.: controlType, numericFormat).
|
|
231
|
+
* Usado para sugestões heurísticas mais precisas no backend.
|
|
232
|
+
*/
|
|
233
|
+
getSchemaFields?(): Record<string, any>[];
|
|
234
|
+
/**
|
|
235
|
+
* Retorna um snapshot do estado de tempo de execução (volátil).
|
|
236
|
+
* Ex: { rowCount: 50, isLoading: false, sort: 'name:asc' }.
|
|
237
|
+
* Usado para responder perguntas do usuário ("Por que está vazio?").
|
|
238
|
+
*/
|
|
239
|
+
getRuntimeState?(): Record<string, any>;
|
|
240
|
+
/**
|
|
241
|
+
* Cria um snapshot do estado atual para fins de Undo.
|
|
242
|
+
* Retorna um token opaco (pode ser o config JSON completo ou um ID).
|
|
243
|
+
*/
|
|
244
|
+
createSnapshot(): any;
|
|
245
|
+
/**
|
|
246
|
+
* Restaura o estado para um snapshot anterior.
|
|
247
|
+
*/
|
|
248
|
+
restoreSnapshot(snapshot: any): Promise<void>;
|
|
249
|
+
/**
|
|
250
|
+
* Aplica um patch de configuração gerado pela IA.
|
|
251
|
+
* O Adapter deve validar, mesclar e garantir a reatividade do componente.
|
|
252
|
+
*
|
|
253
|
+
* @param patch O JSON parcial gerado pela IA.
|
|
254
|
+
* @param intent A intenção original do usuário (para logs ou decisões heurísticas).
|
|
255
|
+
*/
|
|
256
|
+
applyPatch(patch: Partial<TConfig>, intent?: string): Promise<PatchResult>;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
declare const AI_STREAM_EVENT_TYPES: readonly ["status", "thought.step", "heartbeat", "result", "error", "cancelled"];
|
|
260
|
+
type AiJsonPrimitive = string | number | boolean | null;
|
|
261
|
+
type AiJsonArray = AiJsonValue[];
|
|
262
|
+
interface AiJsonObject {
|
|
263
|
+
[key: string]: AiJsonValue;
|
|
264
|
+
}
|
|
265
|
+
type AiJsonValue = AiJsonPrimitive | AiJsonObject | AiJsonArray;
|
|
266
|
+
interface AiSchemaContextContract {
|
|
267
|
+
path?: string | null;
|
|
268
|
+
operation?: string | null;
|
|
269
|
+
schemaType?: string | null;
|
|
270
|
+
}
|
|
271
|
+
interface AiChatMessageContract {
|
|
272
|
+
role: 'user' | 'assistant' | 'system';
|
|
273
|
+
content: string;
|
|
274
|
+
}
|
|
275
|
+
interface AiUiContextRefContract {
|
|
276
|
+
componentType?: string | null;
|
|
277
|
+
componentId?: string | null;
|
|
278
|
+
routeKey?: string | null;
|
|
279
|
+
schemaHash?: string | null;
|
|
280
|
+
variantId?: string | null;
|
|
281
|
+
}
|
|
282
|
+
interface AiCurrentStateDigestContract {
|
|
283
|
+
columns?: string[] | null;
|
|
284
|
+
sort?: string | null;
|
|
285
|
+
rowCount?: number | null;
|
|
286
|
+
}
|
|
287
|
+
interface AiOrchestratorRequestContract {
|
|
288
|
+
componentId: string;
|
|
289
|
+
componentType: string;
|
|
290
|
+
userPrompt?: string;
|
|
291
|
+
sessionId?: string;
|
|
292
|
+
mode?: 'new' | 'continue';
|
|
293
|
+
clientTurnId?: string;
|
|
294
|
+
messages?: AiChatMessageContract[];
|
|
295
|
+
summary?: string;
|
|
296
|
+
uiContextRef?: AiUiContextRefContract;
|
|
297
|
+
currentStateDigest?: AiCurrentStateDigestContract;
|
|
298
|
+
currentState: AiJsonObject;
|
|
299
|
+
dataProfile?: AiJsonObject | null;
|
|
300
|
+
schemaFields?: AiJsonObject[] | null;
|
|
301
|
+
runtimeState?: AiJsonObject | null;
|
|
302
|
+
suggestedPatch?: AiJsonObject | null;
|
|
303
|
+
contextHints?: AiJsonObject | null;
|
|
304
|
+
aiMode?: string;
|
|
305
|
+
requireSchema?: boolean;
|
|
306
|
+
resourcePath?: string;
|
|
307
|
+
contractVersion?: string;
|
|
308
|
+
schemaHash?: string;
|
|
309
|
+
schemaContext?: AiSchemaContextContract | null;
|
|
310
|
+
variantId?: string;
|
|
311
|
+
apiMethod?: string;
|
|
312
|
+
apiTags?: string;
|
|
313
|
+
apiSearchLimit?: number;
|
|
314
|
+
}
|
|
315
|
+
type AiOrchestratorResponseType = 'patch' | 'clarification' | 'error' | 'info';
|
|
316
|
+
interface AiPatchDiffContract {
|
|
317
|
+
path: string;
|
|
318
|
+
before?: AiJsonValue;
|
|
319
|
+
after?: AiJsonValue;
|
|
320
|
+
}
|
|
321
|
+
interface AiOptionContract {
|
|
322
|
+
value?: string | null;
|
|
323
|
+
label?: string | null;
|
|
324
|
+
example?: string | null;
|
|
325
|
+
contextHints?: AiJsonObject | null;
|
|
326
|
+
}
|
|
327
|
+
interface AiClarificationUiContract {
|
|
328
|
+
responseType?: 'text' | 'choice' | 'confirm' | 'mixed' | 'context';
|
|
329
|
+
selectionMode?: 'single' | 'multiple';
|
|
330
|
+
presentation?: 'buttons' | 'list' | 'chips';
|
|
331
|
+
allowCustom?: boolean | null;
|
|
332
|
+
}
|
|
333
|
+
interface AiMemoryInfoContract {
|
|
334
|
+
summaryUpdated?: boolean | null;
|
|
335
|
+
windowSize?: number | null;
|
|
336
|
+
cached?: boolean | null;
|
|
337
|
+
}
|
|
338
|
+
interface AiOrchestratorResponseContract {
|
|
339
|
+
sessionId?: string | null;
|
|
340
|
+
code?: string | null;
|
|
341
|
+
type?: AiOrchestratorResponseType;
|
|
342
|
+
contractVersion?: string | null;
|
|
343
|
+
schemaHash?: string | null;
|
|
344
|
+
patch?: AiJsonObject | null;
|
|
345
|
+
diff?: AiPatchDiffContract[] | null;
|
|
346
|
+
explanation?: string | null;
|
|
347
|
+
warnings?: string[] | null;
|
|
348
|
+
message?: string | null;
|
|
349
|
+
options?: string[] | null;
|
|
350
|
+
optionPayloads?: AiOptionContract[] | null;
|
|
351
|
+
contextRequest?: number[] | null;
|
|
352
|
+
clarification?: AiClarificationUiContract;
|
|
353
|
+
componentId?: string | null;
|
|
354
|
+
componentType?: string | null;
|
|
355
|
+
path?: string | null;
|
|
356
|
+
providedValue?: AiJsonValue;
|
|
357
|
+
allowedValues?: string[] | null;
|
|
358
|
+
memory?: AiMemoryInfoContract;
|
|
359
|
+
}
|
|
360
|
+
interface AiPatchStreamStartResponseContract {
|
|
361
|
+
streamId: string;
|
|
362
|
+
threadId: string;
|
|
363
|
+
turnId: string;
|
|
364
|
+
eventSchemaVersion: string;
|
|
365
|
+
streamAuthMode?: 'cookie' | 'signed_url_token' | null;
|
|
366
|
+
streamAccessToken?: string | null;
|
|
367
|
+
expiresAt: string;
|
|
368
|
+
fallbackPatchUrl: string;
|
|
369
|
+
}
|
|
370
|
+
interface AiPatchStreamCancelResponseContract {
|
|
371
|
+
streamId?: string | null;
|
|
372
|
+
threadId?: string | null;
|
|
373
|
+
turnId?: string | null;
|
|
374
|
+
terminalState: 'cancelled' | 'completed' | 'not_found';
|
|
375
|
+
message?: string | null;
|
|
376
|
+
}
|
|
377
|
+
interface AiPatchStreamEnvelopeContract<TPayload extends AiJsonObject = AiJsonObject> {
|
|
378
|
+
eventId?: string | null;
|
|
379
|
+
streamId: string;
|
|
380
|
+
threadId: string;
|
|
381
|
+
turnId: string;
|
|
382
|
+
seq: number;
|
|
383
|
+
eventSchemaVersion: string;
|
|
384
|
+
timestamp: string;
|
|
385
|
+
type: AiPatchStreamEventType$1;
|
|
386
|
+
payload: TPayload;
|
|
387
|
+
}
|
|
388
|
+
type AiPatchStreamEventType$1 = (typeof AI_STREAM_EVENT_TYPES)[number];
|
|
389
|
+
|
|
390
|
+
declare const AI_INTENT_CONTRACT_VERSION: "v1.1";
|
|
391
|
+
declare const AI_INTENT_CONTRACT_SCHEMA_HASH: "51b7901f1df633d89fc019a2e41f675cc5b87b135dfc8335aa96e53205034b26";
|
|
392
|
+
type AiSchemaContext = AiSchemaContextContract;
|
|
393
|
+
interface AiSuggestionsRequest {
|
|
394
|
+
componentId: string;
|
|
395
|
+
componentType: string;
|
|
396
|
+
currentState: AiJsonObject;
|
|
397
|
+
dataProfile?: AiJsonObject | null;
|
|
398
|
+
variantId?: string;
|
|
399
|
+
maxSuggestions?: number;
|
|
400
|
+
forceRefresh?: boolean;
|
|
401
|
+
locale?: string;
|
|
402
|
+
}
|
|
403
|
+
interface AiSuggestionsResponse {
|
|
404
|
+
suggestions: AiSuggestion[];
|
|
405
|
+
source?: string;
|
|
406
|
+
cacheKey?: string;
|
|
407
|
+
cacheHit?: boolean;
|
|
408
|
+
warnings?: string[];
|
|
409
|
+
}
|
|
410
|
+
type AiOrchestratorRequest = AiOrchestratorRequestContract;
|
|
411
|
+
type AiChatMessage = AiChatMessageContract;
|
|
412
|
+
type AiUiContextRef = AiUiContextRefContract;
|
|
413
|
+
type AiCurrentStateDigest = AiCurrentStateDigestContract;
|
|
414
|
+
type AiPatchDiff = AiPatchDiffContract;
|
|
415
|
+
type AiOrchestratorResponse = AiOrchestratorResponseContract & {
|
|
416
|
+
riskLevel?: string;
|
|
417
|
+
requiresConfirmation?: boolean;
|
|
418
|
+
questions?: string[];
|
|
419
|
+
};
|
|
420
|
+
type AiPatchStreamEventType = AiPatchStreamEventType$1;
|
|
421
|
+
type AiPatchStreamStartResponse = AiPatchStreamStartResponseContract;
|
|
422
|
+
type AiPatchStreamCancelResponse = AiPatchStreamCancelResponseContract;
|
|
423
|
+
type AiPatchStreamEnvelope<TPayload extends AiJsonObject = AiJsonObject> = AiPatchStreamEnvelopeContract<TPayload>;
|
|
424
|
+
interface AiPatchStreamConnection {
|
|
425
|
+
events$: Observable<AiPatchStreamEnvelope>;
|
|
426
|
+
close: () => void;
|
|
427
|
+
}
|
|
428
|
+
type AiPatchStreamConnectionErrorKind = 'unsupported' | 'http_status' | 'transport' | 'parse' | 'schema';
|
|
429
|
+
declare class AiPatchStreamConnectionError extends Error {
|
|
430
|
+
readonly kind: AiPatchStreamConnectionErrorKind;
|
|
431
|
+
readonly status?: number | undefined;
|
|
432
|
+
constructor(kind: AiPatchStreamConnectionErrorKind, message: string, status?: number | undefined);
|
|
433
|
+
}
|
|
434
|
+
interface AiProviderModelsRequest {
|
|
435
|
+
provider?: string;
|
|
436
|
+
apiKey?: string;
|
|
437
|
+
}
|
|
438
|
+
interface AiProviderModelsResponse {
|
|
439
|
+
provider?: string;
|
|
440
|
+
success?: boolean;
|
|
441
|
+
message?: string;
|
|
442
|
+
models?: AiModel[];
|
|
443
|
+
}
|
|
444
|
+
interface AiProviderCatalogItem {
|
|
445
|
+
id: string;
|
|
446
|
+
label: string;
|
|
447
|
+
description?: string;
|
|
448
|
+
defaultModel?: string;
|
|
449
|
+
requiresApiKey?: boolean;
|
|
450
|
+
supportsModels?: boolean;
|
|
451
|
+
supportsEmbeddings?: boolean;
|
|
452
|
+
supportsTextStreaming?: boolean;
|
|
453
|
+
supportsTurnCancellation?: boolean;
|
|
454
|
+
iconKey?: string;
|
|
455
|
+
}
|
|
456
|
+
interface AiProviderCatalogResponse {
|
|
457
|
+
providers: AiProviderCatalogItem[];
|
|
458
|
+
}
|
|
459
|
+
interface AiProviderTestRequest {
|
|
460
|
+
provider?: string;
|
|
461
|
+
apiKey?: string;
|
|
462
|
+
model?: string;
|
|
463
|
+
}
|
|
464
|
+
interface AiProviderTestResponse {
|
|
465
|
+
provider?: string;
|
|
466
|
+
model?: string;
|
|
467
|
+
success?: boolean;
|
|
468
|
+
message?: string;
|
|
469
|
+
}
|
|
470
|
+
interface AiProviderStatusResponse {
|
|
471
|
+
provider?: string;
|
|
472
|
+
model?: string;
|
|
473
|
+
hasApiKey?: boolean;
|
|
474
|
+
source?: string;
|
|
475
|
+
success?: boolean;
|
|
476
|
+
message?: string;
|
|
477
|
+
}
|
|
478
|
+
interface AiContextTemplateMeta {
|
|
479
|
+
variants?: Array<{
|
|
480
|
+
id?: string;
|
|
481
|
+
registryKey?: string;
|
|
482
|
+
} | string>;
|
|
483
|
+
defaultVariantId?: string;
|
|
484
|
+
}
|
|
485
|
+
interface AiContextTemplate {
|
|
486
|
+
templateMeta?: AiContextTemplateMeta;
|
|
487
|
+
}
|
|
488
|
+
interface AiContextDTO {
|
|
489
|
+
componentId?: string;
|
|
490
|
+
componentType?: string;
|
|
491
|
+
template?: AiContextTemplate | null;
|
|
492
|
+
}
|
|
493
|
+
interface AiHeaderContext {
|
|
494
|
+
tenantId: string;
|
|
495
|
+
env: string;
|
|
496
|
+
userId: string;
|
|
497
|
+
missing: string[];
|
|
498
|
+
}
|
|
499
|
+
declare class AiBackendApiService {
|
|
500
|
+
private readonly http;
|
|
501
|
+
private readonly globalConfig;
|
|
502
|
+
private readonly storageOpts;
|
|
503
|
+
private readonly baseUrl;
|
|
504
|
+
private readonly contextUrl;
|
|
505
|
+
getSuggestions(request: AiSuggestionsRequest): Observable<AiSuggestionsResponse>;
|
|
506
|
+
getPatch(request: AiOrchestratorRequest): Observable<AiOrchestratorResponse>;
|
|
507
|
+
startPatchStream(request: AiOrchestratorRequest): Observable<AiPatchStreamStartResponse>;
|
|
508
|
+
connectPatchStream(streamId: string, lastEventId?: string, accessToken?: string): AiPatchStreamConnection;
|
|
509
|
+
cancelPatchStream(streamId: string, accessToken?: string): Observable<AiPatchStreamCancelResponse>;
|
|
510
|
+
listModels(request: AiProviderModelsRequest): Observable<AiProviderModelsResponse>;
|
|
511
|
+
listProviderCatalog(): Observable<AiProviderCatalogResponse>;
|
|
512
|
+
testProvider(request: AiProviderTestRequest): Observable<AiProviderTestResponse>;
|
|
513
|
+
getAiStatus(): Observable<AiProviderStatusResponse>;
|
|
514
|
+
getAiContext(componentId: string, componentType: string): Observable<AiContextDTO>;
|
|
515
|
+
loadGlobalAiConfig(): Observable<GlobalAiConfig | null>;
|
|
516
|
+
saveGlobalAiConfig(aiConfig: GlobalAiConfig): Observable<void>;
|
|
517
|
+
getHeaderContext(): AiHeaderContext;
|
|
518
|
+
private buildHeaders;
|
|
519
|
+
private normalizeContractVersion;
|
|
520
|
+
private normalizeContractSchemaHash;
|
|
521
|
+
private resolveHeaderMap;
|
|
522
|
+
private parsePatchStreamEnvelope;
|
|
523
|
+
private isPatchStreamEnvelope;
|
|
524
|
+
private isJsonObject;
|
|
525
|
+
private probePatchStreamEndpoint;
|
|
526
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<AiBackendApiService, never>;
|
|
527
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<AiBackendApiService>;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
interface FieldSchemaLike {
|
|
531
|
+
label: string;
|
|
532
|
+
type: string;
|
|
533
|
+
description?: string;
|
|
534
|
+
required?: boolean;
|
|
535
|
+
uiConfig?: {
|
|
536
|
+
category?: string;
|
|
537
|
+
};
|
|
538
|
+
allowedValues?: Array<{
|
|
539
|
+
value: any;
|
|
540
|
+
label: string;
|
|
541
|
+
}>;
|
|
542
|
+
}
|
|
543
|
+
declare class SchemaMinifierService {
|
|
544
|
+
/**
|
|
545
|
+
* Converts complete FieldSchemas into a minified version for AI context (Token optimized)
|
|
546
|
+
*/
|
|
547
|
+
minify(schemas: Record<string, FieldSchemaLike>): MinifiedField[];
|
|
548
|
+
/**
|
|
549
|
+
* Formats minified fields into a string for the AI prompt (Legacy/Text mode)
|
|
550
|
+
*/
|
|
551
|
+
toPromptFormat(fields: MinifiedField[]): string;
|
|
552
|
+
/**
|
|
553
|
+
* Transforms Praxis FieldSchemas into Google Gemini JSON Schema format.
|
|
554
|
+
* This enables "Response Schema" enforcement in the API.
|
|
555
|
+
*/
|
|
556
|
+
toGeminiSchema(fields: Record<string, FieldSchemaLike>): Schema;
|
|
557
|
+
private mapTypeToGemini;
|
|
558
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<SchemaMinifierService, never>;
|
|
559
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<SchemaMinifierService>;
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
declare class AiContextBuilderService {
|
|
563
|
+
private schemaMinifier;
|
|
564
|
+
constructor(schemaMinifier: SchemaMinifierService);
|
|
565
|
+
/**
|
|
566
|
+
* Builds the complete context for the AI prompt
|
|
567
|
+
*/
|
|
568
|
+
buildPromptContext(fieldSchemas: Record<string, FieldSchemaLike>, targetType: 'field' | 'section' | 'action' | 'row' | 'column', propertySchema: RulePropertySchema): PromptContext;
|
|
569
|
+
buildRulePrompt(userPrompt: string, context: PromptContext): string;
|
|
570
|
+
buildSuggestionPrompt(context: PromptContext): string;
|
|
571
|
+
/**
|
|
572
|
+
* Formats available properties by targetType
|
|
573
|
+
*/
|
|
574
|
+
private formatProperties;
|
|
575
|
+
/**
|
|
576
|
+
* Lists DSL operators with examples
|
|
577
|
+
*/
|
|
578
|
+
private formatOperators;
|
|
579
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<AiContextBuilderService, never>;
|
|
580
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<AiContextBuilderService>;
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
/**
|
|
584
|
+
* Normalize DSL expression by replacing aliases with standard operators
|
|
585
|
+
*/
|
|
586
|
+
declare function normalizeDsl(dsl: string): string;
|
|
587
|
+
/**
|
|
588
|
+
* Configuration for parsing DSL expressions
|
|
589
|
+
*/
|
|
590
|
+
interface DslParsingConfig {
|
|
591
|
+
/** Available function registry */
|
|
592
|
+
functionRegistry?: FunctionRegistry<any>;
|
|
593
|
+
/** Context provider for variable resolution */
|
|
594
|
+
contextProvider?: ContextProvider;
|
|
595
|
+
/** Known field names for validation */
|
|
596
|
+
knownFields?: string[];
|
|
597
|
+
/** Enable performance warnings */
|
|
598
|
+
enablePerformanceWarnings?: boolean;
|
|
599
|
+
/** Maximum expression complexity */
|
|
600
|
+
maxComplexity?: number;
|
|
601
|
+
}
|
|
602
|
+
/**
|
|
603
|
+
* Result of parsing a DSL expression
|
|
604
|
+
*/
|
|
605
|
+
interface DslParsingResult<T extends object = any> {
|
|
606
|
+
/** Whether parsing was successful */
|
|
607
|
+
success: boolean;
|
|
608
|
+
/** Parsed specification (if successful) */
|
|
609
|
+
specification?: any;
|
|
610
|
+
/** Validation issues found */
|
|
611
|
+
issues: ValidationIssue[];
|
|
612
|
+
/** Performance metrics */
|
|
613
|
+
metrics?: {
|
|
614
|
+
parseTime: number;
|
|
615
|
+
complexity: number;
|
|
616
|
+
};
|
|
617
|
+
}
|
|
618
|
+
/**
|
|
619
|
+
* Dedicated service for DSL parsing and validation
|
|
620
|
+
* Extracted from SpecificationBridgeService to follow SRP
|
|
621
|
+
*/
|
|
622
|
+
declare class DslParsingService {
|
|
623
|
+
constructor();
|
|
624
|
+
/**
|
|
625
|
+
* Parse a DSL expression into a specification
|
|
626
|
+
*/
|
|
627
|
+
parseDsl<T extends object = any>(dslExpression: string, config?: DslParsingConfig): DslParsingResult<T>;
|
|
628
|
+
/**
|
|
629
|
+
* Normalize DSL expression (delegates to utility)
|
|
630
|
+
*/
|
|
631
|
+
normalizeDsl(dsl: string): string;
|
|
632
|
+
/**
|
|
633
|
+
* Static wrapper for backward compatibility if needed
|
|
634
|
+
*/
|
|
635
|
+
static normalizeDsl(dsl: string): string;
|
|
636
|
+
/**
|
|
637
|
+
* Validate DSL syntax without parsing
|
|
638
|
+
*/
|
|
639
|
+
validateDsl(dslExpression: string, config?: DslParsingConfig): ValidationIssue[];
|
|
640
|
+
/**
|
|
641
|
+
* Get suggestions for DSL completion
|
|
642
|
+
*/
|
|
643
|
+
getDslSuggestions(partialExpression: string, cursorPosition: number, config?: DslParsingConfig): string[];
|
|
644
|
+
/**
|
|
645
|
+
* Format DSL expression for readability
|
|
646
|
+
*/
|
|
647
|
+
formatDsl(dslExpression: string): string;
|
|
648
|
+
/**
|
|
649
|
+
* Check if DSL expression is syntactically valid
|
|
650
|
+
*/
|
|
651
|
+
isValidDsl(dslExpression: string, config?: DslParsingConfig): boolean;
|
|
652
|
+
private calculateComplexity;
|
|
653
|
+
private getCurrentToken;
|
|
654
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<DslParsingService, never>;
|
|
655
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<DslParsingService>;
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
interface ValidationContext {
|
|
659
|
+
fieldSchemas: Record<string, FieldSchemaLike>;
|
|
660
|
+
targetSchemas?: any;
|
|
661
|
+
propertySchema: RulePropertySchema;
|
|
662
|
+
}
|
|
663
|
+
declare class AiResponseValidatorService {
|
|
664
|
+
private dslParsingService;
|
|
665
|
+
constructor(dslParsingService: DslParsingService);
|
|
666
|
+
/**
|
|
667
|
+
* Validates the complete AI response
|
|
668
|
+
*/
|
|
669
|
+
validate(response: AiRuleResponse, context: ValidationContext): AiValidationResult;
|
|
670
|
+
private validateStructure;
|
|
671
|
+
private validateTargetIds;
|
|
672
|
+
private isValidTargetId;
|
|
673
|
+
private findSimilarTargetId;
|
|
674
|
+
private calculateSimilarity;
|
|
675
|
+
private levenshteinDistance;
|
|
676
|
+
private validatePropertyType;
|
|
677
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<AiResponseValidatorService, never>;
|
|
678
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<AiResponseValidatorService>;
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
interface AiWizardData {
|
|
682
|
+
fieldSchemas: Record<string, FieldSchemaLike>;
|
|
683
|
+
targetSchemas?: any;
|
|
684
|
+
propertySchema: RulePropertySchema;
|
|
685
|
+
}
|
|
686
|
+
type WizardStep = 'prompt' | 'review';
|
|
687
|
+
declare class AiRuleWizardDialogComponent implements OnInit {
|
|
688
|
+
dialogRef: MatDialogRef<AiRuleWizardDialogComponent>;
|
|
689
|
+
data: AiWizardData;
|
|
690
|
+
private aiService;
|
|
691
|
+
private validator;
|
|
692
|
+
private snackBar;
|
|
693
|
+
private contextBuilder;
|
|
694
|
+
private cdr;
|
|
695
|
+
selectedTargetType: 'field' | 'section' | 'action' | 'row' | 'column';
|
|
696
|
+
userPrompt: string;
|
|
697
|
+
isGenerating: boolean;
|
|
698
|
+
validationError: string | null;
|
|
699
|
+
loadingSuggestions: boolean;
|
|
700
|
+
suggestions: string[];
|
|
701
|
+
private suggestionsCache;
|
|
702
|
+
private suggestionsRequestId;
|
|
703
|
+
currentStep: WizardStep;
|
|
704
|
+
generatedResponse: AiRuleResponse | null;
|
|
705
|
+
warnings: AiValidationWarning[];
|
|
706
|
+
loadingMessages: string[];
|
|
707
|
+
currentLoadingMessage: string;
|
|
708
|
+
streamingText: string;
|
|
709
|
+
private loadingInterval;
|
|
710
|
+
constructor(dialogRef: MatDialogRef<AiRuleWizardDialogComponent>, data: AiWizardData, aiService: PraxisAiService, validator: AiResponseValidatorService, snackBar: MatSnackBar, contextBuilder: AiContextBuilderService, cdr: ChangeDetectorRef);
|
|
711
|
+
ngOnInit(): void;
|
|
712
|
+
onTargetTypeChange(): void;
|
|
713
|
+
getAvailableProperties(): _praxisui_core.RulePropertyDefinition[];
|
|
714
|
+
loadSuggestions(forceRefresh?: boolean): Promise<void>;
|
|
715
|
+
reloadSuggestions(): void;
|
|
716
|
+
applySuggestion(text: string): void;
|
|
717
|
+
generate(): Promise<void>;
|
|
718
|
+
private startLoadingUX;
|
|
719
|
+
private stopLoadingUX;
|
|
720
|
+
backToPrompt(): void;
|
|
721
|
+
confirm(): void;
|
|
722
|
+
getProps(obj: any): {
|
|
723
|
+
key: string;
|
|
724
|
+
value: any;
|
|
725
|
+
}[];
|
|
726
|
+
hasProps(obj: any): boolean;
|
|
727
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<AiRuleWizardDialogComponent, never>;
|
|
728
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<AiRuleWizardDialogComponent, "praxis-ai-rule-wizard-dialog", never, {}, {}, never, never, true, never>;
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
declare class StreamingFeedbackComponent {
|
|
732
|
+
title: string;
|
|
733
|
+
displayText: string;
|
|
734
|
+
isThinking: boolean;
|
|
735
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<StreamingFeedbackComponent, never>;
|
|
736
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<StreamingFeedbackComponent, "praxis-ai-streaming-feedback", never, { "title": { "alias": "title"; "required": false; }; "displayText": { "alias": "displayText"; "required": false; }; "isThinking": { "alias": "isThinking"; "required": false; }; }, {}, never, never, true, never>;
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
interface ConfigAgentRequest {
|
|
740
|
+
adapter: AiConfigAdapter;
|
|
741
|
+
userIntent: string;
|
|
742
|
+
}
|
|
743
|
+
interface ConfigAgentResponse {
|
|
744
|
+
patch: any;
|
|
745
|
+
explanation: string;
|
|
746
|
+
applied: boolean;
|
|
747
|
+
mockMode: boolean;
|
|
748
|
+
}
|
|
749
|
+
declare class AiConfigAgentService {
|
|
750
|
+
private ai;
|
|
751
|
+
constructor(ai: PraxisAiService);
|
|
752
|
+
isMockMode(): boolean;
|
|
753
|
+
/**
|
|
754
|
+
* Legacy single-shot flow: builds a prompt with full config + capabilities.
|
|
755
|
+
* Two-step flow is preferred (see TableAiAdapter.processUserIntent), but this remains as fallback.
|
|
756
|
+
*/
|
|
757
|
+
generateConfigPatch(request: ConfigAgentRequest): Promise<ConfigAgentResponse>;
|
|
758
|
+
private buildPrompt;
|
|
759
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<AiConfigAgentService, never>;
|
|
760
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<AiConfigAgentService>;
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
/**
|
|
764
|
+
* Base implementation for AI Adapters.
|
|
765
|
+
* Provides common validation logic against the Capabilities Catalog.
|
|
766
|
+
*/
|
|
767
|
+
declare abstract class BaseAiAdapter<TConfig = any> implements AiConfigAdapter<TConfig> {
|
|
768
|
+
abstract componentName: string;
|
|
769
|
+
abstract getCurrentConfig(): TConfig;
|
|
770
|
+
abstract getCapabilities(): Capability[];
|
|
771
|
+
abstract applyPatch(patch: Partial<TConfig>, intent?: string): Promise<PatchResult>;
|
|
772
|
+
abstract createSnapshot(): any;
|
|
773
|
+
abstract restoreSnapshot(snapshot: any): Promise<void>;
|
|
774
|
+
getTaskPresets?(): Record<string, string[]>;
|
|
775
|
+
getSuggestions(_forceReload?: boolean): Promise<AiSuggestion[]>;
|
|
776
|
+
getSuggestionContext?(): Record<string, any>;
|
|
777
|
+
getRuntimeState?(): Record<string, any>;
|
|
778
|
+
/**
|
|
779
|
+
* Helper to validate a patch against the capabilities catalog.
|
|
780
|
+
* Removes keys that are not in the allowed paths.
|
|
781
|
+
*/
|
|
782
|
+
protected validatePatchAgainstCapabilities(patch: any): any;
|
|
783
|
+
/**
|
|
784
|
+
* Helper to check if a patch contains critical changes.
|
|
785
|
+
*/
|
|
786
|
+
protected getCriticalWarnings(patch: any): string[];
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
type AssistantMessageRole = 'user' | 'assistant' | 'system';
|
|
790
|
+
interface AssistantHistoryMessage {
|
|
791
|
+
id: string;
|
|
792
|
+
role: AssistantMessageRole;
|
|
793
|
+
text: string;
|
|
794
|
+
createdAt: string;
|
|
795
|
+
context?: {
|
|
796
|
+
componentId?: string;
|
|
797
|
+
componentType?: string;
|
|
798
|
+
variantId?: string;
|
|
799
|
+
suggestionId?: string;
|
|
800
|
+
usedRag?: boolean;
|
|
801
|
+
};
|
|
802
|
+
}
|
|
803
|
+
interface AssistantHistorySession {
|
|
804
|
+
id: string;
|
|
805
|
+
title: string;
|
|
806
|
+
tenantId: string;
|
|
807
|
+
env: string;
|
|
808
|
+
userId: string;
|
|
809
|
+
componentId?: string;
|
|
810
|
+
componentType?: string;
|
|
811
|
+
serverSessionId?: string | null;
|
|
812
|
+
createdAt: string;
|
|
813
|
+
updatedAt: string;
|
|
814
|
+
messages: AssistantHistoryMessage[];
|
|
815
|
+
summary?: string;
|
|
816
|
+
}
|
|
817
|
+
interface AssistantHistoryContext extends AiHeaderContext {
|
|
818
|
+
storageAvailable: boolean;
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
type AssistantState = 'idle' | 'listening' | 'clarification' | 'processing' | 'review' | 'applying' | 'success' | 'error';
|
|
822
|
+
|
|
823
|
+
interface ClarificationOption {
|
|
824
|
+
label: string;
|
|
825
|
+
value: string;
|
|
826
|
+
example?: string;
|
|
827
|
+
}
|
|
828
|
+
type ClarificationContextHints = AiJsonObject;
|
|
829
|
+
interface ClarificationRichOption extends ClarificationOption {
|
|
830
|
+
contextHints?: ClarificationContextHints;
|
|
831
|
+
}
|
|
832
|
+
interface PatchPathEdit {
|
|
833
|
+
path: string;
|
|
834
|
+
valueText: string;
|
|
835
|
+
error?: string;
|
|
836
|
+
}
|
|
837
|
+
type RiskPolicy = 'strict' | 'standard';
|
|
838
|
+
type ReviewRiskLevel = 'baixo' | 'médio' | 'alto';
|
|
839
|
+
declare class PraxisAiAssistantComponent implements OnDestroy {
|
|
840
|
+
adapter: AiConfigAdapter;
|
|
841
|
+
riskPolicy: RiskPolicy | null;
|
|
842
|
+
allowManualPatchEdit: boolean;
|
|
843
|
+
overlayOrigin: CdkOverlayOrigin;
|
|
844
|
+
triggerButton?: ElementRef<HTMLButtonElement>;
|
|
845
|
+
inputElement: ElementRef<HTMLInputElement>;
|
|
846
|
+
state: AssistantState | 'clarification';
|
|
847
|
+
activeTab: 'task' | 'chat' | 'suggestions';
|
|
848
|
+
private readonly tabOrder;
|
|
849
|
+
readonly flowSteps: readonly [{
|
|
850
|
+
readonly step: 1;
|
|
851
|
+
readonly label: "Pedido";
|
|
852
|
+
}, {
|
|
853
|
+
readonly step: 2;
|
|
854
|
+
readonly label: "Proposta";
|
|
855
|
+
}, {
|
|
856
|
+
readonly step: 3;
|
|
857
|
+
readonly label: "Impacto";
|
|
858
|
+
}, {
|
|
859
|
+
readonly step: 4;
|
|
860
|
+
readonly label: "Aplicação";
|
|
861
|
+
}];
|
|
862
|
+
private taskFlowActive;
|
|
863
|
+
processingInfoVisible: boolean;
|
|
864
|
+
isOpen: boolean;
|
|
865
|
+
loadingSuggestions: boolean;
|
|
866
|
+
userPrompt: string;
|
|
867
|
+
aiExplanation: string;
|
|
868
|
+
pendingPatch: Record<string, unknown> | null;
|
|
869
|
+
pendingDiff: AiPatchDiff[];
|
|
870
|
+
patchEditorText: string;
|
|
871
|
+
patchEditorError: string;
|
|
872
|
+
patchEditorExpanded: boolean;
|
|
873
|
+
patchPathEditorExpanded: boolean;
|
|
874
|
+
patchPathEdits: PatchPathEdit[];
|
|
875
|
+
patchPathEditorError: string;
|
|
876
|
+
applyWarnings: string[];
|
|
877
|
+
lastApplyAt: string | null;
|
|
878
|
+
lastSnapshot: unknown;
|
|
879
|
+
errorMsg: string;
|
|
880
|
+
warnings: string[];
|
|
881
|
+
private backendRiskLevel;
|
|
882
|
+
private backendRequiresConfirmation;
|
|
883
|
+
private effectiveRiskPolicy;
|
|
884
|
+
suggestionsWarnings: string[];
|
|
885
|
+
mockMode: boolean;
|
|
886
|
+
clarificationMessage: string;
|
|
887
|
+
clarificationOptions: ClarificationRichOption[];
|
|
888
|
+
clarificationQuestions: string[];
|
|
889
|
+
clarificationAnswers: string[];
|
|
890
|
+
clarificationFreeText: string;
|
|
891
|
+
showManualInput: boolean;
|
|
892
|
+
private clarificationBasePrompt;
|
|
893
|
+
private skipClarificationAppend;
|
|
894
|
+
clarificationResponseType: 'text' | 'choice' | 'confirm' | 'mixed' | 'context';
|
|
895
|
+
clarificationSelectionMode: 'single' | 'multiple';
|
|
896
|
+
clarificationAllowCustom: boolean;
|
|
897
|
+
clarificationPresentation: 'buttons' | 'list' | 'chips';
|
|
898
|
+
selectedClarificationOptions: ClarificationRichOption[];
|
|
899
|
+
richSuggestions: AiSuggestion[];
|
|
900
|
+
private dismissedSuggestionIds;
|
|
901
|
+
private readonly aiApi;
|
|
902
|
+
private readonly historyService;
|
|
903
|
+
private readonly dialog;
|
|
904
|
+
private readonly cdr;
|
|
905
|
+
private readonly suggestionsCache;
|
|
906
|
+
private readonly templateVariantsCache;
|
|
907
|
+
private activeVariantId;
|
|
908
|
+
private promptFromSuggestion;
|
|
909
|
+
private activeSuggestion;
|
|
910
|
+
private activeContextHints;
|
|
911
|
+
private activeResourcePath;
|
|
912
|
+
private activeServerSessionId;
|
|
913
|
+
private activeStreamId;
|
|
914
|
+
private activeStreamAccessToken;
|
|
915
|
+
private activeStreamConnection;
|
|
916
|
+
private streamSeenEventIds;
|
|
917
|
+
private streamLastSeqByStream;
|
|
918
|
+
private streamLastEventIdByStream;
|
|
919
|
+
private streamLastSeq;
|
|
920
|
+
private streamLastEventId;
|
|
921
|
+
private streamTerminalState;
|
|
922
|
+
private streamTimelineMode;
|
|
923
|
+
private streamFallbackActive;
|
|
924
|
+
private streamTimelineStepState;
|
|
925
|
+
private streamTimelineStepDetail;
|
|
926
|
+
private currentComponentId;
|
|
927
|
+
private currentComponentType;
|
|
928
|
+
private forceNewSession;
|
|
929
|
+
private readonly sessionStorageAvailable;
|
|
930
|
+
historyContext: AssistantHistoryContext | null;
|
|
931
|
+
historyWarnings: string[];
|
|
932
|
+
historySessions: Array<{
|
|
933
|
+
id: string;
|
|
934
|
+
title: string;
|
|
935
|
+
updatedAt: string;
|
|
936
|
+
componentId?: string;
|
|
937
|
+
componentType?: string;
|
|
938
|
+
}>;
|
|
939
|
+
activeHistorySession: AssistantHistorySession | null;
|
|
940
|
+
activeHistoryMessages: AssistantHistoryMessage[];
|
|
941
|
+
activeHistoryTotalMessages: number;
|
|
942
|
+
historyExpanded: boolean;
|
|
943
|
+
historyUndoDeleteSession: AssistantHistorySession | null;
|
|
944
|
+
private historyUndoTimerId;
|
|
945
|
+
highlightClarificationDetails: boolean;
|
|
946
|
+
highlightReviewDetails: boolean;
|
|
947
|
+
private thoughtDetailsHighlightTimerId;
|
|
948
|
+
showFullDiff: boolean;
|
|
949
|
+
private processingStartedAt;
|
|
950
|
+
private lastProcessingDurationMs;
|
|
951
|
+
private readonly westernTwoDigitFormatter;
|
|
952
|
+
private readonly maxHistoryMessages;
|
|
953
|
+
ngOnDestroy(): void;
|
|
954
|
+
open(): Promise<void>;
|
|
955
|
+
close(): void;
|
|
956
|
+
submitPrompt(overridePrompt?: string): Promise<void>;
|
|
957
|
+
isTaskMode(): boolean;
|
|
958
|
+
hasPendingClarification(): boolean;
|
|
959
|
+
isActiveTab(tab: 'task' | 'chat' | 'suggestions'): boolean;
|
|
960
|
+
setActiveTab(tab: 'task' | 'chat' | 'suggestions'): void;
|
|
961
|
+
onTabsKeydown(event: KeyboardEvent): void;
|
|
962
|
+
private focusTab;
|
|
963
|
+
getTaskTitle(): string;
|
|
964
|
+
getTaskSubtitle(): string;
|
|
965
|
+
getTaskPrimaryLabel(): string;
|
|
966
|
+
getTaskSecondaryLabel(): string;
|
|
967
|
+
getTaskCancelLabel(): string;
|
|
968
|
+
isTaskPrimaryDisabled(): boolean;
|
|
969
|
+
isBusyState(): boolean;
|
|
970
|
+
getSystemStatusLabel(): string;
|
|
971
|
+
getSystemStatusDetail(): string;
|
|
972
|
+
shouldShowSystemStatusDetail(): boolean;
|
|
973
|
+
getSystemStatusAriaLive(): 'polite' | 'assertive';
|
|
974
|
+
shouldShowSnapshotFallbackBadge(): boolean;
|
|
975
|
+
getRiskPolicyLabel(): string;
|
|
976
|
+
getRiskPolicyTooltip(): string;
|
|
977
|
+
isStrictRiskPolicy(): boolean;
|
|
978
|
+
getFlowStepState(step: number): 'done' | 'active' | 'pending';
|
|
979
|
+
getFlowStepDetail(step: number): string;
|
|
980
|
+
shouldShowTaskFlow(): boolean;
|
|
981
|
+
shouldShowThoughtCard(): boolean;
|
|
982
|
+
getThoughtTimingLabel(): string;
|
|
983
|
+
getThoughtSummary(): string;
|
|
984
|
+
getThoughtPlanTitle(): string;
|
|
985
|
+
getThoughtChecklist(): string[];
|
|
986
|
+
openThoughtDetails(): void;
|
|
987
|
+
openThoughtPreview(): void;
|
|
988
|
+
getThoughtDetailsTooltip(): string;
|
|
989
|
+
getThoughtDetailsLabel(): string;
|
|
990
|
+
getThoughtPreviewTooltip(): string;
|
|
991
|
+
getThoughtActionHint(): string;
|
|
992
|
+
shouldShowThoughtPreviewAction(): boolean;
|
|
993
|
+
shouldShowTaskTimeline(): boolean;
|
|
994
|
+
getTaskTimelineItems(): Array<{
|
|
995
|
+
step: number;
|
|
996
|
+
title: string;
|
|
997
|
+
detail: string;
|
|
998
|
+
state: 'done' | 'active' | 'pending';
|
|
999
|
+
}>;
|
|
1000
|
+
private getThoughtDurationSeconds;
|
|
1001
|
+
private formatDurationClock;
|
|
1002
|
+
private formatWesternTwoDigits;
|
|
1003
|
+
getReviewRiskLevel(): ReviewRiskLevel;
|
|
1004
|
+
getReviewSummary(): string;
|
|
1005
|
+
getDiffToggleLabel(): string;
|
|
1006
|
+
private getReviewChangeCount;
|
|
1007
|
+
private estimatePatchChangeCount;
|
|
1008
|
+
private getCurrentFlowStep;
|
|
1009
|
+
private resolveCurrentFlowStepFromStream;
|
|
1010
|
+
private shouldUseStreamTimeline;
|
|
1011
|
+
private initializeStreamTimeline;
|
|
1012
|
+
private markStreamStep;
|
|
1013
|
+
shouldShowTaskSteps(): boolean;
|
|
1014
|
+
getTaskSelectionSummary(): string | null;
|
|
1015
|
+
getHistorySessionTooltip(session: {
|
|
1016
|
+
componentType?: string;
|
|
1017
|
+
componentId?: string;
|
|
1018
|
+
}): string;
|
|
1019
|
+
getVisibleSuggestions(): AiSuggestion[];
|
|
1020
|
+
hasDismissedSuggestions(): boolean;
|
|
1021
|
+
getDismissedSuggestionCount(): number;
|
|
1022
|
+
restoreDismissedSuggestions(): void;
|
|
1023
|
+
isDatasetSelection(): boolean;
|
|
1024
|
+
hasClarificationSelection(): boolean;
|
|
1025
|
+
confirmTaskAction(): void;
|
|
1026
|
+
handleTaskSecondary(): void;
|
|
1027
|
+
onClarificationOptionClick(opt: ClarificationRichOption): void;
|
|
1028
|
+
toggleManualInput(): void;
|
|
1029
|
+
private toggleClarificationSelection;
|
|
1030
|
+
private setState;
|
|
1031
|
+
private flashThoughtDetails;
|
|
1032
|
+
private clearThoughtDetailsHighlightTimer;
|
|
1033
|
+
private focusTaskPanelTarget;
|
|
1034
|
+
toggleFullDiff(): void;
|
|
1035
|
+
getDiffSummaryLines(): string[];
|
|
1036
|
+
private summarizeDiff;
|
|
1037
|
+
shouldShowApplyDetails(): boolean;
|
|
1038
|
+
getApplyPaths(): string[];
|
|
1039
|
+
getEditablePatchPathEdits(): PatchPathEdit[];
|
|
1040
|
+
togglePatchEditor(): void;
|
|
1041
|
+
resetPatchEditor(): void;
|
|
1042
|
+
togglePatchPathEditor(): void;
|
|
1043
|
+
resetPatchPathEdits(): void;
|
|
1044
|
+
applyPathEditsToPatch(): boolean;
|
|
1045
|
+
reapplyPathEdits(): Promise<void>;
|
|
1046
|
+
reapplyEditedPatch(): Promise<void>;
|
|
1047
|
+
private confirmEditedPatchBeforeApply;
|
|
1048
|
+
getScopeLabel(): string;
|
|
1049
|
+
getScopeTooltip(): string;
|
|
1050
|
+
getConfidenceLabel(): string;
|
|
1051
|
+
getConfidenceTooltip(): string;
|
|
1052
|
+
isClarificationSelected(option: ClarificationRichOption): boolean;
|
|
1053
|
+
getClarificationOptionLayout(option: ClarificationRichOption): 'endpoint' | 'color' | 'description' | 'default';
|
|
1054
|
+
getClarificationOptionKindLabel(option: ClarificationRichOption): string;
|
|
1055
|
+
isEndpointOption(option: ClarificationRichOption): boolean;
|
|
1056
|
+
isColorOption(option: ClarificationRichOption): boolean;
|
|
1057
|
+
hasRichDescription(option: ClarificationRichOption): boolean;
|
|
1058
|
+
getEndpointIcon(option: ClarificationRichOption): string;
|
|
1059
|
+
getEndpointMethod(option: ClarificationRichOption): string | null;
|
|
1060
|
+
getEndpointPath(option: ClarificationRichOption): string | null;
|
|
1061
|
+
shouldShowClarificationTooltip(option: ClarificationRichOption): boolean;
|
|
1062
|
+
getClarificationTooltip(option: ClarificationRichOption): string;
|
|
1063
|
+
getSafeHexColor(option: ClarificationRichOption): string | null;
|
|
1064
|
+
shouldShowDescriptionTooltip(option: ClarificationRichOption): boolean;
|
|
1065
|
+
getDescriptionTooltip(option: ClarificationRichOption): string;
|
|
1066
|
+
shouldShowDescription(option: ClarificationRichOption): boolean;
|
|
1067
|
+
handleClarificationOption(option: ClarificationRichOption | string): Promise<void>;
|
|
1068
|
+
confirmPatch(): Promise<void>;
|
|
1069
|
+
private requiresApplyConfirmation;
|
|
1070
|
+
private confirmRiskApply;
|
|
1071
|
+
private buildRiskConfirmationMessage;
|
|
1072
|
+
private openConfirmationDialog;
|
|
1073
|
+
private normalizeRiskLevel;
|
|
1074
|
+
undoLastChange(): Promise<void>;
|
|
1075
|
+
retry(): void;
|
|
1076
|
+
private applyPatchPayload;
|
|
1077
|
+
private parsePatchEditorText;
|
|
1078
|
+
private collectPatchPaths;
|
|
1079
|
+
private serializePatch;
|
|
1080
|
+
private syncPatchPathEdits;
|
|
1081
|
+
private serializePathValue;
|
|
1082
|
+
private collectEditablePatchPaths;
|
|
1083
|
+
private parsePathEditValue;
|
|
1084
|
+
private getPatchValueAtPath;
|
|
1085
|
+
private setPatchValueAtPath;
|
|
1086
|
+
private tokenizePatchPath;
|
|
1087
|
+
private clonePatch;
|
|
1088
|
+
prepareSuggestionPrompt(sug: AiSuggestion, event?: Event): void;
|
|
1089
|
+
dismissSuggestion(sug: AiSuggestion, event?: Event): void;
|
|
1090
|
+
onSuggestionCardKeydown(event: KeyboardEvent, sug: AiSuggestion): void;
|
|
1091
|
+
selectSuggestion(sug: AiSuggestion): void;
|
|
1092
|
+
refreshSuggestions(): Promise<void>;
|
|
1093
|
+
submitClarificationSelection(): Promise<void>;
|
|
1094
|
+
startNewSession(resetUi?: boolean): void;
|
|
1095
|
+
clearHistory(): Promise<void>;
|
|
1096
|
+
removeHistorySession(sessionId: string, event?: Event): Promise<void>;
|
|
1097
|
+
onHistorySessionCardKeydown(event: KeyboardEvent, sessionId: string): void;
|
|
1098
|
+
reuseHistorySessionPrompt(sessionId: string, event?: Event): void;
|
|
1099
|
+
undoRemoveHistorySession(): void;
|
|
1100
|
+
selectHistorySession(sessionId: string): void;
|
|
1101
|
+
private loadSuggestions;
|
|
1102
|
+
private getPatchViaStreamWithFallback;
|
|
1103
|
+
private consumePatchStream;
|
|
1104
|
+
private applyStreamEvent;
|
|
1105
|
+
private resolveStreamTimeoutMs;
|
|
1106
|
+
private resolveStreamIdleTimeoutMs;
|
|
1107
|
+
private acceptStreamEvent;
|
|
1108
|
+
private resolveLastEventIdForStream;
|
|
1109
|
+
private extractStreamMessage;
|
|
1110
|
+
private requestStreamCancel;
|
|
1111
|
+
private closeActiveStreamConnection;
|
|
1112
|
+
private resetStreamTracking;
|
|
1113
|
+
private shouldFallbackToPatch;
|
|
1114
|
+
private handlePatchResponse;
|
|
1115
|
+
private initHistory;
|
|
1116
|
+
private buildHistoryWarnings;
|
|
1117
|
+
private matchesHistoryContext;
|
|
1118
|
+
private buildClientTurnId;
|
|
1119
|
+
private buildUiContextRef;
|
|
1120
|
+
private buildCurrentStateDigest;
|
|
1121
|
+
private inferAiMode;
|
|
1122
|
+
private resolveRouteKey;
|
|
1123
|
+
private resolveSchemaHash;
|
|
1124
|
+
private checkSessionStorage;
|
|
1125
|
+
private resolveSessionStorageKey;
|
|
1126
|
+
private restoreServerSessionId;
|
|
1127
|
+
private persistServerSessionId;
|
|
1128
|
+
private appendHistoryMessage;
|
|
1129
|
+
private appendHistoryAssistantResponse;
|
|
1130
|
+
private resolveAssistantSummary;
|
|
1131
|
+
private isProcessingMessage;
|
|
1132
|
+
retryProcessing(): Promise<void>;
|
|
1133
|
+
private cancelProcessing;
|
|
1134
|
+
private withSnapshotFallbackDetail;
|
|
1135
|
+
private resolveUsedRag;
|
|
1136
|
+
private sliceHistoryMessages;
|
|
1137
|
+
private applyClarificationUi;
|
|
1138
|
+
private resolveClarificationPresentation;
|
|
1139
|
+
private resetAssistantStateForSession;
|
|
1140
|
+
private setHistoryUndo;
|
|
1141
|
+
private clearPendingHistoryUndo;
|
|
1142
|
+
private clearHistoryUndoTimer;
|
|
1143
|
+
private pruneDismissedSuggestions;
|
|
1144
|
+
private confirmHistoryClear;
|
|
1145
|
+
private enterClarification;
|
|
1146
|
+
private enterClarificationWithOptions;
|
|
1147
|
+
private enterClarificationWithQuestions;
|
|
1148
|
+
private resolveClarificationOptions;
|
|
1149
|
+
private enrichClarification;
|
|
1150
|
+
private buildClarificationAnswers;
|
|
1151
|
+
private needsRuleClarification;
|
|
1152
|
+
private needsValueColorClarification;
|
|
1153
|
+
private needsBadgeValueClarification;
|
|
1154
|
+
private normalizeMissingContext;
|
|
1155
|
+
private resolveBadgeContextHints;
|
|
1156
|
+
private hasBadgeValues;
|
|
1157
|
+
private hasBadgeColors;
|
|
1158
|
+
private hasBadgeField;
|
|
1159
|
+
private mergeContextHints;
|
|
1160
|
+
private setResourcePathHint;
|
|
1161
|
+
private clearResourcePathHint;
|
|
1162
|
+
private matchClarificationOptionPath;
|
|
1163
|
+
private normalizeResourcePath;
|
|
1164
|
+
private extractResourcePath;
|
|
1165
|
+
private asRecord;
|
|
1166
|
+
private toAiJsonObject;
|
|
1167
|
+
private toAiJsonValue;
|
|
1168
|
+
private toClarificationContextHints;
|
|
1169
|
+
private firstNonBlank;
|
|
1170
|
+
private buildRuleClarificationPayloads;
|
|
1171
|
+
private buildValueColorClarificationPayloads;
|
|
1172
|
+
private resolveBadgeValuesContext;
|
|
1173
|
+
private resolveSchemaField;
|
|
1174
|
+
private extractSchemaValues;
|
|
1175
|
+
private extractOptionValueFromSchema;
|
|
1176
|
+
private normalizeOptionKey;
|
|
1177
|
+
private normalizeStringList;
|
|
1178
|
+
private buildValueColorMap;
|
|
1179
|
+
private findColumnInPrompt;
|
|
1180
|
+
private extractOptionValue;
|
|
1181
|
+
private buildMaskSelectionHints;
|
|
1182
|
+
private extractMaskFromText;
|
|
1183
|
+
private resolveComponentId;
|
|
1184
|
+
private resolveComponentType;
|
|
1185
|
+
private buildSuggestionsRequest;
|
|
1186
|
+
private resolveLocale;
|
|
1187
|
+
private resolveConfigRoot;
|
|
1188
|
+
private resolveMockMode;
|
|
1189
|
+
private resolveConfiguredRiskPolicy;
|
|
1190
|
+
private getEffectiveRiskPolicy;
|
|
1191
|
+
private normalizeRiskPolicy;
|
|
1192
|
+
private hasProviderOverride;
|
|
1193
|
+
private resolveMockModeFromStatus;
|
|
1194
|
+
private loadTemplateVariants;
|
|
1195
|
+
private extractVariantIds;
|
|
1196
|
+
private resolveVariantIdForSuggestion;
|
|
1197
|
+
private mapSuggestionToVariantId;
|
|
1198
|
+
private getTemplateVariants;
|
|
1199
|
+
private includesAny;
|
|
1200
|
+
private buildSuggestionsCacheKey;
|
|
1201
|
+
private stableStringify;
|
|
1202
|
+
private hashString;
|
|
1203
|
+
private isTable;
|
|
1204
|
+
private isForm;
|
|
1205
|
+
private extractColumnNames;
|
|
1206
|
+
private extractFieldNames;
|
|
1207
|
+
onKeydown(event: KeyboardEvent): void;
|
|
1208
|
+
private shouldSubmitFromKeydown;
|
|
1209
|
+
private restoreFocusToTrigger;
|
|
1210
|
+
private normalizeError;
|
|
1211
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<PraxisAiAssistantComponent, never>;
|
|
1212
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<PraxisAiAssistantComponent, "praxis-ai-assistant", never, { "adapter": { "alias": "adapter"; "required": true; }; "riskPolicy": { "alias": "riskPolicy"; "required": false; }; "allowManualPatchEdit": { "alias": "allowManualPatchEdit"; "required": false; }; }, {}, never, never, true, never>;
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
export { AI_INTENT_CONTRACT_SCHEMA_HASH, AI_INTENT_CONTRACT_VERSION, AiBackendApiService, AiConfigAgentService, AiConfigService, AiContextBuilderService, AiPatchStreamConnectionError, AiResponseValidatorService, AiRuleWizardDialogComponent, BaseAiAdapter, DslParsingService, PraxisAi, PraxisAiAssistantComponent, PraxisAiService, SchemaMinifierService, StreamingFeedbackComponent, normalizeDsl };
|
|
1216
|
+
export type { AiChatMessage, AiConfigAdapter, AiContextDTO, AiContextTemplate, AiContextTemplateMeta, AiCurrentStateDigest, AiExamplePair, AiHeaderContext, AiIntegrationConfig, AiModel, AiOrchestratorRequest, AiOrchestratorResponse, AiPatchDiff, AiPatchStreamCancelResponse, AiPatchStreamConnection, AiPatchStreamConnectionErrorKind, AiPatchStreamEnvelope, AiPatchStreamEventType, AiPatchStreamStartResponse, AiProviderCatalogItem, AiProviderCatalogResponse, AiProviderModelsRequest, AiProviderModelsResponse, AiProviderStatusResponse, AiProviderTestRequest, AiProviderTestResponse, AiRuleResponse, AiSchemaContext, AiSuggestion, AiSuggestionsRequest, AiSuggestionsResponse, AiUiContextRef, AiValidationError, AiValidationResult, AiValidationWarning, AiWizardData, Capability, ConfigAgentRequest, ConfigAgentResponse, DslParsingConfig, DslParsingResult, FieldSchemaLike, MinifiedField, PatchResult, PromptContext, ValidationContext, ValueKind };
|