@acorex-platform/module-ai-management-client 0.0.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (21) hide show
  1. package/fesm2022/acorex-platform-module-ai-management-client-agent-registry-tool-configurator-widget-column.component-BHdDG8z0.mjs +44 -0
  2. package/fesm2022/acorex-platform-module-ai-management-client-agent-registry-tool-configurator-widget-column.component-BHdDG8z0.mjs.map +1 -0
  3. package/fesm2022/acorex-platform-module-ai-management-client-agent-registry-tool-configurator-widget-edit.component-CMsc3P9O.mjs +259 -0
  4. package/fesm2022/acorex-platform-module-ai-management-client-agent-registry-tool-configurator-widget-edit.component-CMsc3P9O.mjs.map +1 -0
  5. package/fesm2022/acorex-platform-module-ai-management-client-assist-delegated-agent-configurator-widget-column.component-CWUhBvpf.mjs +62 -0
  6. package/fesm2022/acorex-platform-module-ai-management-client-assist-delegated-agent-configurator-widget-column.component-CWUhBvpf.mjs.map +1 -0
  7. package/fesm2022/acorex-platform-module-ai-management-client-assist-delegated-agent-configurator-widget-edit.component-Dmi8vzfr.mjs +293 -0
  8. package/fesm2022/acorex-platform-module-ai-management-client-assist-delegated-agent-configurator-widget-edit.component-Dmi8vzfr.mjs.map +1 -0
  9. package/fesm2022/acorex-platform-module-ai-management-client-contracts.mjs +1038 -0
  10. package/fesm2022/acorex-platform-module-ai-management-client-contracts.mjs.map +1 -0
  11. package/fesm2022/acorex-platform-module-ai-management-client-list-ai-command-registry-catalog.query-DHfiKVa2.mjs +106 -0
  12. package/fesm2022/acorex-platform-module-ai-management-client-list-ai-command-registry-catalog.query-DHfiKVa2.mjs.map +1 -0
  13. package/fesm2022/acorex-platform-module-ai-management-client-list-ai-query-registry-catalog.query-BX0uU1YX.mjs +107 -0
  14. package/fesm2022/acorex-platform-module-ai-management-client-list-ai-query-registry-catalog.query-BX0uU1YX.mjs.map +1 -0
  15. package/fesm2022/acorex-platform-module-ai-management-client-list-output-contract-transcript-segments.query-BQXySOH_.mjs +54 -0
  16. package/fesm2022/acorex-platform-module-ai-management-client-list-output-contract-transcript-segments.query-BQXySOH_.mjs.map +1 -0
  17. package/fesm2022/acorex-platform-module-ai-management-client.mjs +3642 -0
  18. package/fesm2022/acorex-platform-module-ai-management-client.mjs.map +1 -0
  19. package/package.json +28 -0
  20. package/types/acorex-platform-module-ai-management-client-contracts.d.ts +896 -0
  21. package/types/acorex-platform-module-ai-management-client.d.ts +797 -0
@@ -0,0 +1,797 @@
1
+ import * as i0 from '@angular/core';
2
+ import { OnInit, OnDestroy } from '@angular/core';
3
+ import * as i1 from '@acorex-platform/framework-client/core';
4
+ import { AXPModuleManifest } from '@acorex-platform/framework-client/core';
5
+ import * as i2 from '@acorex-platform/framework-client/layout/widgets';
6
+ import * as i3 from '@acorex-platform/framework-client/runtime';
7
+ import { AXPAiAgentOutputKind, AXPAiChatFollowUpItem, AXPAiChatMessage, AXPAiAgentOutputContract, AXPAiChatResponse, AXPAiDelegatedAgentResultSegment, AXPAiEffectiveAssistRow, AXPAiPlatformRuntimeContext, AXPAiChatTransport, AXPAiEngineLastProviderPayload, AXPAiEngineRunOptions, AXPAiDelegatedAgentTranscriptRunInput, AXPAiEngineRunResult, AXPAiChatModelListRequest, AXPAiChatModelListItem } from '@acorex-platform/module-ai-management-contracts';
8
+ export * from '@acorex-platform/module-ai-management-contracts';
9
+ import { AXPMenuProvider, AXPMenuProviderContext, AXPFileStorageService } from '@acorex-platform/framework-client/common';
10
+ import { AXPEntityService } from '@acorex-platform/framework-client/layout/entity';
11
+ import { AXPPermissionDefinitionProvider, AXPPermissionDefinitionProviderContext } from '@acorex-platform/framework-client/auth';
12
+ import { AXPMultiLanguageString } from '@acorex-platform/framework-shared/core';
13
+ import { AXMAiManagementAssistEntityModel } from '@acorex-platform/module-ai-management-client/contracts';
14
+
15
+ declare class AXMAiManagementModule {
16
+ static ɵfac: i0.ɵɵFactoryDeclaration<AXMAiManagementModule, never>;
17
+ static ɵmod: i0.ɵɵNgModuleDeclaration<AXMAiManagementModule, never, [typeof i1.AXPComponentSlotModule, typeof i2.AXPWidgetsModule, typeof i3.AXPRuntimeModule], never>;
18
+ static ɵinj: i0.ɵɵInjectorDeclaration<AXMAiManagementModule>;
19
+ }
20
+
21
+ interface AXPAiAssistValidationError {
22
+ phase: 'parse' | 'validator';
23
+ message: string;
24
+ details?: unknown;
25
+ }
26
+ interface AXPAiAssistCannotComplete {
27
+ reason: 'missingInput' | 'unsafe' | 'unsupported';
28
+ missing?: string[];
29
+ message?: string;
30
+ }
31
+ /**
32
+ * Normalized result of an assist run or structured-output pipeline session.
33
+ */
34
+ interface AXPAiAssistExecutionResult<TData = unknown> {
35
+ success: boolean;
36
+ outputKind: AXPAiAgentOutputKind;
37
+ text: string;
38
+ data?: TData;
39
+ followUp?: {
40
+ items: AXPAiChatFollowUpItem[];
41
+ };
42
+ followUpRequired?: boolean;
43
+ followUpQuestion?: string;
44
+ validationErrors?: AXPAiAssistValidationError[];
45
+ cannotComplete?: AXPAiAssistCannotComplete;
46
+ raw?: unknown;
47
+ messages?: AXPAiChatMessage[];
48
+ }
49
+
50
+ /** Default max completion tokens when the AiModel row has no `maxOutputTokens` and the caller omits `maxTokens`. */
51
+ declare const AXPAiAssistDefaultStructuredMaxTokens = 128000;
52
+ /** Default maximum follow-up turns after the first model response when validating structured JSON (implementation may use this). */
53
+ declare const AXPAiAssistDefaultMaxStructuredRetries = 3;
54
+ /**
55
+ * Validates parsed JSON from the assistant. Return the validated value (possibly narrowed), or throw with a message
56
+ * the pipeline can send back to the model on retry.
57
+ */
58
+ type AXPAiStructuredValidator<T = unknown> = (parsed: unknown) => T | Promise<T>;
59
+ /**
60
+ * Thrown when {@link AXPAiAssistRunInput.expectStructuredOutput} is true but the assistant output could not be
61
+ * parsed and optionally validated after all attempts.
62
+ */
63
+ declare class AXPAiStructuredOutputError extends Error {
64
+ /** 1-based count of engine runs performed for this structured-output session. */
65
+ readonly attempts: number;
66
+ /** Truncated snapshot of the last assistant plain text (for debugging). */
67
+ readonly lastAssistantText: string;
68
+ /** Human-readable validation or parse failure detail. */
69
+ readonly validationMessage: string;
70
+ /** Why the pipeline stopped. */
71
+ readonly code?: 'duplicate_assistant_output' | 'validation_exhausted';
72
+ constructor(options: {
73
+ message: string;
74
+ attempts: number;
75
+ lastAssistantText: string;
76
+ validationMessage: string;
77
+ cause?: unknown;
78
+ code?: 'duplicate_assistant_output' | 'validation_exhausted';
79
+ });
80
+ }
81
+ /** One persisted user attachment (same storage contract as the AI chat composer). */
82
+ interface AXPAiAssistUserMediaAttachment {
83
+ /** `image` / `audio` / `file` (PDF, text, spreadsheets, and other document MIME types). */
84
+ kind: 'image' | 'audio' | 'file';
85
+ fileId: string;
86
+ mimeType: string;
87
+ name?: string;
88
+ }
89
+ /**
90
+ * Payload when submitting the assist prompt box (text, optional target assist/agent, optional media).
91
+ */
92
+ interface AXPAiAssistPromptSubmitPayload {
93
+ prompt: string;
94
+ assistId?: string;
95
+ directAgentId?: string;
96
+ userMediaAttachments: AXPAiAssistUserMediaAttachment[];
97
+ }
98
+ /**
99
+ * Optional structured hints for a single assist run (serialized into the user message by the implementation).
100
+ */
101
+ interface AXPAiAssistRunContext {
102
+ /** Short bullet hints appended to the prompt for the model. */
103
+ hints?: string[];
104
+ /** Extra system-level instruction for this run (implementation may emit a system message). */
105
+ systemInstruction?: string;
106
+ /** Arbitrary structured payload (JSON-serialized in the user message when present). */
107
+ structuredContext?: unknown;
108
+ }
109
+ /**
110
+ * Input for the AI assist `run` API (implemented in ai-management).
111
+ */
112
+ interface AXPAiAssistRunInput {
113
+ prompt: string;
114
+ /**
115
+ * Optional images, audio, or documents (`fileId` from tenant storage). When non-empty, the implementation builds one multimodal
116
+ * user message (same shape as the AI chat composer) plus the serialized prompt body as text segments.
117
+ */
118
+ userMediaAttachments?: AXPAiAssistUserMediaAttachment[];
119
+ context?: AXPAiAssistRunContext;
120
+ /**
121
+ * Catalog assist id. When omitted together with {@link directAgentId}, the platform default assist is used.
122
+ */
123
+ assistId?: string;
124
+ directAgentId?: string;
125
+ maxSteps?: number;
126
+ temperature?: number;
127
+ /**
128
+ * Max completion tokens for this engine run (when the provider supports it). Structured JSON runs apply a higher
129
+ * default unless {@link structuredOutputMaxTokens} is set.
130
+ */
131
+ maxTokens?: number;
132
+ /**
133
+ * Declarative output contract for this run (preferred over legacy {@link expectStructuredOutput} flags).
134
+ * Resolved with agent/assist defaults via {@link resolveEffectiveOutputContract}.
135
+ */
136
+ outputContract?: AXPAiAgentOutputContract;
137
+ /** When true, implementation tries to parse assistant text as JSON into {@link AXPAiAssistRunResult.structured}. */
138
+ expectStructuredOutput?: boolean;
139
+ /** Extra instruction appended so the model returns JSON (used when {@link expectStructuredOutput} is true). */
140
+ structuredOutputInstruction?: string;
141
+ /**
142
+ * Shallow merge over built-in platform runtime context fields (see ai-management implementation).
143
+ */
144
+ platformRuntimeNotes?: Record<string, unknown>;
145
+ /**
146
+ * Max extra engine turns after the first response when structured output is invalid (default {@link AXPAiAssistDefaultMaxStructuredRetries}).
147
+ * Total attempts = 1 + maxStructuredRetries.
148
+ */
149
+ maxStructuredRetries?: number;
150
+ /** Optional schema or domain validation after JSON parse. */
151
+ structuredValidator?: AXPAiStructuredValidator;
152
+ /**
153
+ * When false, only one engine run is performed; invalid structured output throws {@link AXPAiStructuredOutputError}.
154
+ * When true (default for {@link expectStructuredOutput}), invalid output triggers follow-up user messages in the same transcript.
155
+ */
156
+ retryOnInvalidStructure?: boolean;
157
+ /**
158
+ * Optional description of the expected JSON shape (TypeScript-style or JSON schema summary), appended to the first
159
+ * user message and to retry prompts so the model stays aligned and retries are more accurate.
160
+ */
161
+ structuredOutputSchemaSummary?: string;
162
+ /**
163
+ * Overrides {@link maxTokens} for {@link expectStructuredOutput} runs only. Prefer setting this or leaving defaults so
164
+ * the implementation can apply {@link AXPAiAssistDefaultStructuredMaxTokens} and avoid truncated JSON.
165
+ */
166
+ structuredOutputMaxTokens?: number;
167
+ }
168
+ /**
169
+ * Result of the AI assist `run` API.
170
+ */
171
+ interface AXPAiAssistRunResult {
172
+ /** When false, structured validation exhausted or cannotComplete (future). */
173
+ success?: boolean;
174
+ /** Effective output contract kind for this run. */
175
+ outputKind?: AXPAiAgentOutputKind;
176
+ /** Primary assistant reply text (extracted from the engine transcript). */
177
+ text: string;
178
+ /**
179
+ * Present when {@link AXPAiAssistRunInput.expectStructuredOutput} is true: validated structured payload
180
+ * (parse + optional {@link AXPAiAssistRunInput.structuredValidator}). On failure the implementation throws
181
+ * {@link AXPAiStructuredOutputError} instead of returning.
182
+ */
183
+ structured?: unknown;
184
+ /** Same as {@link structured} when using the execution-result envelope. */
185
+ data?: unknown;
186
+ /** Validation failures when returned without throwing (reserved). */
187
+ validationErrors?: AXPAiAssistValidationError[];
188
+ /** Full normalized transcript when available. */
189
+ messages?: AXPAiChatMessage[];
190
+ /**
191
+ * When {@link AXPAiAssistRunInput.expectStructuredOutput} is false: engine usage / provider payload for that single run.
192
+ * When true: {@link AXPAiAssistStructuredOutputRunRaw} with per-attempt usage and totals for debugging.
193
+ */
194
+ raw?: unknown;
195
+ }
196
+ /**
197
+ * Token usage for a single engine run; numeric fields align with {@link AXPAiEngineUsageTotals} in this module
198
+ * for stable client-side debugging contracts.
199
+ */
200
+ interface AXPAiAssistTokenUsageSnapshot {
201
+ promptTokens: number;
202
+ completionTokens: number;
203
+ totalTokens: number;
204
+ cachedPromptTokens?: number;
205
+ }
206
+ /**
207
+ * One engine execution within a structured-output session.
208
+ */
209
+ interface AXPAiAssistStructuredOutputAttemptRecord {
210
+ /** 1-based index of this engine run. */
211
+ attemptIndex: number;
212
+ /** Usage reported for this run only. */
213
+ usage?: AXPAiAssistTokenUsageSnapshot;
214
+ /** Whether a last-provider payload was present for this run. */
215
+ hasLastProviderResult: boolean;
216
+ }
217
+ /**
218
+ * Explicit `raw` shape for {@link AXPAiAssistRunResult} when {@link AXPAiAssistRunInput.expectStructuredOutput} is true.
219
+ */
220
+ interface AXPAiAssistStructuredOutputRunRaw {
221
+ kind: 'structured-output';
222
+ /** One entry per engine call (`runEngine` / structured-output retries). */
223
+ attempts: AXPAiAssistStructuredOutputAttemptRecord[];
224
+ /** Cumulative usage across all attempts. */
225
+ totalUsage?: AXPAiAssistTokenUsageSnapshot;
226
+ /** Count of engine runs in this session (same as the last `attemptIndex`). */
227
+ finalAttempt: number;
228
+ lastProviderResult?: unknown;
229
+ }
230
+ /**
231
+ * Typical max width of the prompt box column inside the bottom overlay (maps to `contentMaxWidthPx`).
232
+ */
233
+ type AXPAiAssistPopupSize = 'sm' | 'md' | 'lg' | 'xl' | 'full';
234
+ /**
235
+ * Indeterminate loading dialog shown while the prompt box executes an assist run after Send (model work /
236
+ * structured-output retries).
237
+ */
238
+ interface AXPAiAssistRunLoadingDialogSpec {
239
+ title: string;
240
+ text: string;
241
+ }
242
+ /**
243
+ * Options for the AI assist `show` prompt API: same run-related fields as {@link AXPAiAssistRunInput} except `prompt`,
244
+ * plus UI chrome. The user-entered prompt from the surface is merged on Send.
245
+ */
246
+ interface AXPAiAssistShowOptions {
247
+ /**
248
+ * Prompt box header; must be translated by the caller. Entity list assist uses
249
+ * `@extensions-ai-entity:assist.dialog-title.{type-level|selected|individual}`.
250
+ */
251
+ title: string;
252
+ placeholder?: string;
253
+ initialPrompt?: string;
254
+ size?: AXPAiAssistPopupSize;
255
+ context?: AXPAiAssistRunContext;
256
+ /**
257
+ * Optional catalog assist. When omitted (and {@link directAgentId} is not set), the tenant/platform default assist applies.
258
+ */
259
+ assistId?: string;
260
+ directAgentId?: string;
261
+ maxSteps?: number;
262
+ temperature?: number;
263
+ maxTokens?: number;
264
+ outputContract?: AXPAiAgentOutputContract;
265
+ expectStructuredOutput?: boolean;
266
+ structuredOutputInstruction?: string;
267
+ platformRuntimeNotes?: Record<string, unknown>;
268
+ maxStructuredRetries?: number;
269
+ structuredValidator?: AXPAiStructuredValidator;
270
+ retryOnInvalidStructure?: boolean;
271
+ structuredOutputSchemaSummary?: string;
272
+ structuredOutputMaxTokens?: number;
273
+ /**
274
+ * When set, shows an indeterminate loading dialog for the duration of each submitted run until `run` settles.
275
+ * Callers supply translated strings.
276
+ */
277
+ runLoadingDialog?: AXPAiAssistRunLoadingDialogSpec;
278
+ }
279
+
280
+ /**
281
+ * AI Management Module Manifest.
282
+ * Defines module metadata for AI provider and API key management.
283
+ */
284
+ declare const AiManagementManifest: AXPModuleManifest;
285
+
286
+ declare class AXMAiManagementMenuProvider implements AXPMenuProvider {
287
+ private readonly entityService;
288
+ provide(context: AXPMenuProviderContext): Promise<void>;
289
+ static ɵfac: i0.ɵɵFactoryDeclaration<AXMAiManagementMenuProvider, never>;
290
+ static ɵprov: i0.ɵɵInjectableDeclaration<AXMAiManagementMenuProvider>;
291
+ }
292
+
293
+ /** One assist row mapped for permission definition children. */
294
+ interface AXMAiAssistPermissionRow {
295
+ name: string;
296
+ title: string;
297
+ description?: string;
298
+ }
299
+ /**
300
+ * Loads assist catalog rows for dynamic permission definitions.
301
+ * Skips rows without a stable programmatic `name`.
302
+ */
303
+ declare function loadAssistPermissionRows(entityService: AXPEntityService, localeId: string): Promise<AXMAiAssistPermissionRow[]>;
304
+
305
+ /**
306
+ * Registers AI section capabilities under Administration (including assist children).
307
+ */
308
+ declare class AXMPermissionDefinitionProvider implements AXPPermissionDefinitionProvider {
309
+ private readonly entityService;
310
+ private readonly localeId;
311
+ define(context: AXPPermissionDefinitionProviderContext): Promise<void>;
312
+ static ɵfac: i0.ɵɵFactoryDeclaration<AXMPermissionDefinitionProvider, never>;
313
+ static ɵprov: i0.ɵɵInjectableDeclaration<AXMPermissionDefinitionProvider>;
314
+ }
315
+
316
+ /**
317
+ * Human-readable specialist prompt from delegated-agent tool arguments (conversation / mini-chat UI).
318
+ */
319
+ declare function axpAiDelegatedAgentPromptPreview(argumentsValue: unknown): string;
320
+
321
+ declare function axpAiChatUserMessage(responses: AXPAiChatResponse[]): AXPAiChatMessage;
322
+ declare function axpAiChatMessageIsDelegatedReflectionExcluded(message: AXPAiChatMessage): boolean;
323
+ /** Reads typed specialist segments from a normalized {@code agent_result} payload. */
324
+ declare function axpAiDelegatedAgentResultSegments(payload: {
325
+ success?: boolean;
326
+ data?: {
327
+ responses?: AXPAiDelegatedAgentResultSegment[];
328
+ };
329
+ }): AXPAiDelegatedAgentResultSegment[];
330
+ /** Plain text from specialist segments (text + think) for debug / preview UI. */
331
+ declare function axpAiDelegatedAgentOutcomeResponsesPlainText(segments: AXPAiDelegatedAgentResultSegment[]): string;
332
+ declare function axpAiChatToolResultBodyJson(message: AXPAiChatMessage): string;
333
+ declare function axpAiChatToolOrAgentResultBodyJson(message: AXPAiChatMessage): string;
334
+
335
+ /**
336
+ * Strips HTML tags and decodes a few common entities for safe plain-text transcript lines.
337
+ * Used for Assist `initialMessages` (may be stored as rich text HTML).
338
+ */
339
+ declare function axpAiStripAssistInitialHtmlToPlain(raw: string): string;
340
+ /**
341
+ * Converts assist `initialMessages` (HTML or plain) into one or more `assistant` transcript lines.
342
+ * Non-empty paragraphs (split by blank lines) become separate messages; single block stays one message.
343
+ */
344
+ declare function axpAiAssistInitialMessagesToTranscript(raw: string | null | undefined): AXPAiChatMessage[];
345
+
346
+ type AssistStarterPromptsSource = Pick<AXMAiManagementAssistEntityModel, 'starterPrompts'> | Pick<AXPAiEffectiveAssistRow, 'starterPrompts'> | null | undefined;
347
+ /**
348
+ * Returns non-empty starter prompt labels, preserving repeater order.
349
+ * Resolve locale in the template via the translate pipe.
350
+ */
351
+ declare function axpAiAssistStarterPromptLabels(source: AssistStarterPromptsSource): Array<string | AXPMultiLanguageString>;
352
+ /**
353
+ * Returns non-empty starter prompt strings for the active locale, preserving repeater order.
354
+ */
355
+ declare function axpAiAssistStarterPromptTexts(source: AssistStarterPromptsSource, locale: string): string[];
356
+
357
+ /**
358
+ * Builds {@link AXPAiPlatformRuntimeContext} from session and user-scoped regional settings.
359
+ */
360
+ declare class AXPAiPlatformRuntimeContextBuilder {
361
+ private readonly session;
362
+ private readonly settings;
363
+ private readonly translation;
364
+ /**
365
+ * Resolves current user, tenant, application, UI language, and regional preferences from storage.
366
+ */
367
+ build(): Promise<AXPAiPlatformRuntimeContext>;
368
+ static ɵfac: i0.ɵɵFactoryDeclaration<AXPAiPlatformRuntimeContextBuilder, never>;
369
+ static ɵprov: i0.ɵɵInjectableDeclaration<AXPAiPlatformRuntimeContextBuilder>;
370
+ }
371
+
372
+ interface AXPAiChatToolRunContext {
373
+ assistId: string;
374
+ chatTransport: AXPAiChatTransport;
375
+ /** AiModel catalog row id for the active chat model (when resolved). */
376
+ modelEntityId?: string;
377
+ /** Set during a delegated agent sub-run (specialist executing registry tools). */
378
+ agentId?: string;
379
+ /** Assist or AiAgent catalog `name` (Demisco `agent_uuid` for Demis transport). */
380
+ agentName?: string;
381
+ /** Optional Demisco chat session id (`session_uuid` in multipart). */
382
+ demisSessionUuid?: string;
383
+ }
384
+ /**
385
+ * Per chat run: stores which assist and chat transport are active.
386
+ * Injected commands (e.g. image generation) read this instead of receiving assist/transport inside tool args.
387
+ */
388
+ declare class AXPAiChatToolRunContextService {
389
+ private readonly runContext;
390
+ setContext(ctx: AXPAiChatToolRunContext | null): void;
391
+ getContext(): AXPAiChatToolRunContext | null;
392
+ static ɵfac: i0.ɵɵFactoryDeclaration<AXPAiChatToolRunContextService, never>;
393
+ static ɵprov: i0.ɵɵInjectableDeclaration<AXPAiChatToolRunContextService>;
394
+ }
395
+
396
+ /**
397
+ * Registry rows map inputs to string-typed JSON schemas. Override parameters for AI chat tools
398
+ * so models receive accurate types (arrays, booleans, nested objects).
399
+ */
400
+ declare function getAiChatCommandLlmParametersOverride(commandName: string): Record<string, unknown> | null;
401
+
402
+ /** Max length for relaying an https image URL in tool_result when persistence fails (CORS, etc.). */
403
+ declare const AI_GENERATED_IMAGE_MAX_REMOTE_URL_IN_TOOL = 2048;
404
+ /** refType for files created from in-chat image tool output. */
405
+ declare const AI_CHAT_GENERATED_IMAGE_REF_TYPE: string;
406
+ /** refType for files created from in-chat text-to-speech tool output. */
407
+ declare const AI_CHAT_GENERATED_SPEECH_REF_TYPE: string;
408
+ /** refType for user-attached images in AI chat; {@link persistAiChatAttachmentImage} uses a batch ref id. */
409
+ declare const AI_CHAT_ATTACHMENT_REF_TYPE: string;
410
+ /** File storage category for user chat image attachments. */
411
+ declare const AI_CHAT_ATTACHMENT_CATEGORY = "ai-chat-attachment";
412
+ /**
413
+ * Builds a File from a vendor image URL (https) or data URL (base64 image).
414
+ */
415
+ declare function blobOrFileFromImageResult(imageUrl: string, defaultName?: string): Promise<File>;
416
+ /**
417
+ * Saves the file and commits it so it appears in storage queries as committed.
418
+ */
419
+ declare function persistAiGeneratedImage(fileStorage: AXPFileStorageService, file: File, ref: {
420
+ refId: string;
421
+ refType: string;
422
+ }): Promise<{
423
+ fileId: string;
424
+ }>;
425
+ /**
426
+ * Persists a user-selected chat image; refId groups files uploaded in the same composer batch.
427
+ */
428
+ declare function persistAiChatAttachmentImage(fileStorage: AXPFileStorageService, file: File, refId: string): Promise<{
429
+ fileId: string;
430
+ }>;
431
+ /**
432
+ * Saves synthesized speech bytes and commits so the file id can be replayed in chat.
433
+ */
434
+ declare function persistAiGeneratedSpeech(fileStorage: AXPFileStorageService, file: File, ref: {
435
+ refId: string;
436
+ refType: string;
437
+ }): Promise<{
438
+ fileId: string;
439
+ }>;
440
+
441
+ /** OpenAI / OpenRouter `pcm` TTS output: 16-bit signed LE, mono, 24 kHz. */
442
+ declare const AI_CHAT_TTS_PCM_SAMPLE_RATE = 24000;
443
+ declare function isRawPcmMimeType(mimeType: string): boolean;
444
+ /**
445
+ * Wraps raw 16-bit signed little-endian PCM in a RIFF WAV container for HTML5 audio playback.
446
+ */
447
+ declare function wrapPcm16LeInWav(pcmBytes: ArrayBuffer, sampleRate?: number, numChannels?: number): ArrayBuffer;
448
+ interface AiChatTtsPlaybackBytes {
449
+ audioBytes: ArrayBuffer;
450
+ mimeType: string;
451
+ extension: string;
452
+ }
453
+ /** Normalizes synthesized speech bytes to a browser-playable container (PCM → WAV). */
454
+ declare function prepareTtsBytesForBrowserPlayback(audioBytes: ArrayBuffer, mimeType: string): AiChatTtsPlaybackBytes;
455
+ /**
456
+ * Builds a blob URL for chat voice playback, wrapping legacy PCM TTS files when needed.
457
+ */
458
+ declare function createBrowserPlayableTtsBlobUrl(binary: Blob, mimeType: string, fileName?: string): Promise<string>;
459
+
460
+ /**
461
+ * Removes ephemeral SSE chunk arrays from provider `rawResponse` objects.
462
+ * Assistant text is accumulated during streaming; chunk blobs must not be persisted or exported.
463
+ */
464
+ declare function axpStripEphemeralStreamChunksFromProviderRaw(raw: unknown): unknown;
465
+ /** Strips stream chunks from {@link AXPAiEngineLastProviderPayload} before message metadata / debug export. */
466
+ declare function axpSanitizeLastProviderPayloadForPersistence(payload: AXPAiEngineLastProviderPayload | undefined): AXPAiEngineLastProviderPayload | undefined;
467
+
468
+ /** Builds a JSON-serializable delegated specialist {@link AXPAiEngineRunOptions} snapshot (no callbacks). */
469
+ declare function axpBuildDelegatedAgentRunInputSnapshot(delegationCallId: string, agentId: string, agentName: string | undefined, specialistArguments: unknown, runOptions: AXPAiEngineRunOptions): AXPAiDelegatedAgentTranscriptRunInput;
470
+
471
+ interface ResolveEffectiveOutputContractInput {
472
+ /** Highest priority: per engine run (programmatic / automation). */
473
+ runtime?: AXPAiAgentOutputContract | null;
474
+ /** Assist `run` / `show` input. */
475
+ input?: AXPAiAgentOutputContract | null;
476
+ /** Active AiAgent catalog row. */
477
+ agent?: AXPAiAgentOutputContract | unknown | null;
478
+ /** Active Assist catalog row. */
479
+ assist?: AXPAiAgentOutputContract | unknown | null;
480
+ }
481
+
482
+ declare class AXPAiOutputContractResolveService {
483
+ private readonly segmentService;
484
+ /**
485
+ * Resolves a persisted agent/assist `outputContract` value (segment id string)
486
+ * or a full contract object (runtime / programmatic).
487
+ */
488
+ resolveFromPersisted(raw: unknown): Promise<AXPAiAgentOutputContract | null>;
489
+ /**
490
+ * Effective contract for one engine turn.
491
+ * Priority: runtime > input > agent > assist > `{ kind: 'string' }`.
492
+ */
493
+ resolveEffective(params: ResolveEffectiveOutputContractInput): Promise<AXPAiAgentOutputContract>;
494
+ static ɵfac: i0.ɵɵFactoryDeclaration<AXPAiOutputContractResolveService, never>;
495
+ static ɵprov: i0.ɵɵInjectableDeclaration<AXPAiOutputContractResolveService>;
496
+ }
497
+
498
+ /**
499
+ * User follow-up appended to the transcript when structured JSON parse/validation fails.
500
+ *
501
+ * @param validationDetail - Parse or schema validation error text.
502
+ * @param schemaSummary - Optional expected shape (e.g. TypeScript-style) to improve retry quality.
503
+ * @param failurePhase - Parse failures get stronger anti-truncation wording; validator failures focus on schema/rules.
504
+ */
505
+ declare function buildStructuredOutputRetryUserText(validationDetail: string, schemaSummary?: string, failurePhase?: 'parse' | 'validator'): string;
506
+
507
+ type StructuredAssistantValidation = {
508
+ ok: true;
509
+ value: unknown;
510
+ } | {
511
+ ok: false;
512
+ errorMessage: string;
513
+ failurePhase: 'parse' | 'validator';
514
+ };
515
+ /**
516
+ * Parses JSON from assistant text (including lightweight local repair), then optionally runs a custom validator.
517
+ *
518
+ * @param textSegmentsFallback - When provided, each segment is tried after combined text (last segment first); helps when prose and JSON sit in separate assistant text blocks.
519
+ */
520
+ declare function validateStructuredAssistantResponse(assistantPlainText: string, structuredValidator: AXPAiStructuredValidator | undefined, textSegmentsFallback?: readonly string[]): Promise<StructuredAssistantValidation>;
521
+
522
+ interface ContractValidationError {
523
+ phase: 'parse' | 'validator';
524
+ message: string;
525
+ details?: unknown;
526
+ }
527
+ type ContractValidationResult = {
528
+ ok: true;
529
+ value: unknown;
530
+ } | {
531
+ ok: false;
532
+ errors: ContractValidationError[];
533
+ };
534
+ interface ValidateAgainstContractCommandExecutor {
535
+ execute(commandName: string, args: Record<string, unknown>): Promise<unknown>;
536
+ }
537
+ interface ValidateAgainstContractParams {
538
+ contract: AXPAiAgentOutputContract;
539
+ assistantPlainText: string;
540
+ textSegmentsFallback?: readonly string[];
541
+ structuredValidator?: AXPAiStructuredValidator;
542
+ commandExecutor?: ValidateAgainstContractCommandExecutor;
543
+ /**
544
+ * When the command returns `{ success, data: { valid, errors?, normalizedJson? } }` envelope shape.
545
+ */
546
+ parseCommandEnvelope?: (raw: unknown) => {
547
+ valid: boolean;
548
+ errorMessage?: string;
549
+ normalizedJson?: string;
550
+ };
551
+ }
552
+ /**
553
+ * Parses assistant text and validates against contract schema, registry command, and optional custom validator.
554
+ */
555
+ declare function validateAgainstContract(params: ValidateAgainstContractParams): Promise<ContractValidationResult>;
556
+
557
+ /**
558
+ * Minimal JSON-Schema-like object for native provider hints and local validation.
559
+ * Aligns with shapes emitted by {@link inputOptionDefinitionsToJsonSchema} in connectivity mock support.
560
+ */
561
+ interface AXPAiJsonSchemaLike {
562
+ type?: 'object' | 'array' | 'string' | 'number' | 'integer' | 'boolean' | 'null';
563
+ properties?: Record<string, AXPAiJsonSchemaLike>;
564
+ items?: AXPAiJsonSchemaLike | AXPAiJsonSchemaLike[];
565
+ required?: string[];
566
+ enum?: unknown[];
567
+ additionalProperties?: boolean | AXPAiJsonSchemaLike;
568
+ description?: string;
569
+ [key: string]: unknown;
570
+ }
571
+
572
+ interface JsonSchemaMiniValidationError {
573
+ path: string;
574
+ message: string;
575
+ }
576
+ type JsonSchemaMiniValidationResult = {
577
+ ok: true;
578
+ } | {
579
+ ok: false;
580
+ errors: JsonSchemaMiniValidationError[];
581
+ };
582
+ /**
583
+ * Validates a value against a minimal JSON Schema subset (types, required, enum, properties, items).
584
+ */
585
+ declare function validateJsonSchemaMini(schema: AXPAiJsonSchemaLike, value: unknown): JsonSchemaMiniValidationResult;
586
+
587
+ /**
588
+ * Backend boundary for AI assist runs (chat + tool rounds). Connectivity implementations execute registry
589
+ * commands/queries during the run loop.
590
+ * Wire a concrete implementation via Angular providers (for example `provide: AXPAiEngine` with `useClass`).
591
+ */
592
+ declare abstract class AXPAiEngine {
593
+ /**
594
+ * Sends the conversation to the AI backend and returns updated messages (including tool rounds).
595
+ */
596
+ abstract run(options: AXPAiEngineRunOptions): Promise<AXPAiEngineRunResult>;
597
+ static ɵfac: i0.ɵɵFactoryDeclaration<AXPAiEngine, never>;
598
+ static ɵprov: i0.ɵɵInjectableDeclaration<AXPAiEngine>;
599
+ }
600
+
601
+ /**
602
+ * Optional cross-cutting AI assist: programmatic {@link run} and dialog {@link show}.
603
+ * Implemented by {@link AXPAiManagerService}. Consumers outside ai-management should prefer hooks or optional injection.
604
+ */
605
+ declare abstract class AXPAiAssistService {
606
+ abstract run(input: AXPAiAssistRunInput): Promise<AXPAiAssistRunResult>;
607
+ /** Opens prompt UI; on Send runs {@link run} and closes the dialog. Cancel resolves `null`. */
608
+ abstract show(options: AXPAiAssistShowOptions): Promise<AXPAiAssistRunResult | null>;
609
+ static ɵfac: i0.ɵɵFactoryDeclaration<AXPAiAssistService, never>;
610
+ static ɵprov: i0.ɵɵInjectableDeclaration<AXPAiAssistService>;
611
+ }
612
+
613
+ /**
614
+ * Frontend facade for AI: assist catalog, tenant defaults, engine runs, structured assist runs, and prompt UI.
615
+ */
616
+ declare class AXPAiManagerService extends AXPAiAssistService {
617
+ private readonly aiEngine;
618
+ private readonly outputContractResolve;
619
+ private readonly entityService;
620
+ private readonly settings;
621
+ private readonly runtimeContextBuilder;
622
+ private readonly assistPromptBox;
623
+ private readonly localeId;
624
+ private readonly loadingDialog;
625
+ private readonly assistData;
626
+ private readonly modelEntityData;
627
+ private readonly agentEntityData;
628
+ /**
629
+ * Loads the effective assist from `DefaultAssistId` (tenant setting), or the assist named `platform-assistant`.
630
+ */
631
+ getEffectiveAssist(): Promise<AXPAiEffectiveAssistRow>;
632
+ private findAssistByName;
633
+ /**
634
+ * Resolves the assist row for chat: explicit primary key, otherwise the effective default from settings.
635
+ */
636
+ getAssistForChat(assistId?: string | null): Promise<AXPAiEffectiveAssistRow>;
637
+ /**
638
+ * Primary catalog model transport for an assist (`modelId` row).
639
+ */
640
+ getAssistPrimaryChatTransport(assistId?: string | null): Promise<AXPAiChatTransport | undefined>;
641
+ /**
642
+ * Low-level engine run (chat streaming and tool orchestration).
643
+ */
644
+ runEngine(options: AXPAiEngineRunOptions): Promise<AXPAiEngineRunResult>;
645
+ /**
646
+ * Normalizes AiModel.maxOutputTokens from the catalog.
647
+ */
648
+ private normalizeMaxOutputTokens;
649
+ /**
650
+ * Reads {@link AXMAiModelMaxTokensRow.maxOutputTokens} for the model bound to the assist or direct agent.
651
+ */
652
+ private resolveCatalogMaxOutputTokens;
653
+ /** @inheritdoc */
654
+ run(input: AXPAiAssistRunInput): Promise<AXPAiAssistRunResult>;
655
+ /** @inheritdoc */
656
+ show(options: AXPAiAssistShowOptions): Promise<AXPAiAssistRunResult | null>;
657
+ static ɵfac: i0.ɵɵFactoryDeclaration<AXPAiManagerService, never>;
658
+ static ɵprov: i0.ɵɵInjectableDeclaration<AXPAiManagerService>;
659
+ }
660
+
661
+ /**
662
+ * Lists chat-purpose AI models (catalog), without using {@link AXPAiEngine}.
663
+ */
664
+ declare class AXPAiAssistChatModelCatalogService {
665
+ private readonly entityService;
666
+ private readonly localeId;
667
+ private readonly modelData;
668
+ /**
669
+ * All active chat-purpose models in the catalog (assist / agent policy is applied at engine runtime).
670
+ */
671
+ listModels(_request?: AXPAiChatModelListRequest): Promise<AXPAiChatModelListItem[]>;
672
+ /**
673
+ * Chat pickers only use enabled models. Endpoint disabled state is denormalized on the
674
+ * model (`openAiEndpointIsDisabled`) so tenants never need OpenAI endpoint entity reads.
675
+ */
676
+ private filterModelsActiveForChat;
677
+ static ɵfac: i0.ɵɵFactoryDeclaration<AXPAiAssistChatModelCatalogService, never>;
678
+ static ɵprov: i0.ɵɵInjectableDeclaration<AXPAiAssistChatModelCatalogService>;
679
+ }
680
+
681
+ declare class AXPAiDefaultModelPickerService {
682
+ /**
683
+ * Picks a model from chat/vision catalog candidates.
684
+ * Prefers {@link preferredModelId} when it supports the purpose; otherwise the first
685
+ * purpose-capable entry; otherwise the first candidate.
686
+ */
687
+ pickFromChatCatalogForPurpose(models: AXPAiChatModelListItem[], purpose: 'chat' | 'vision', preferredModelId?: string | null): AXPAiChatModelListItem | undefined;
688
+ static ɵfac: i0.ɵɵFactoryDeclaration<AXPAiDefaultModelPickerService, never>;
689
+ static ɵprov: i0.ɵɵInjectableDeclaration<AXPAiDefaultModelPickerService>;
690
+ }
691
+
692
+ /**
693
+ * Opens the AI assist prompt box in a bottom overlay using {@link AXOverlayService} (`centered: false`, panel CSS).
694
+ */
695
+ declare class AXMAiAssistPromptBoxService {
696
+ private readonly overlayService;
697
+ private overlayRef;
698
+ private pendingResolve;
699
+ private settled;
700
+ /**
701
+ * Presents the assist prompt box and resolves when the user submits, cancels, or dismisses the overlay.
702
+ */
703
+ open(options: AXPAiAssistShowOptions, executeRun: (payload: AXPAiAssistPromptSubmitPayload) => Promise<AXPAiAssistRunResult>): Promise<AXPAiAssistRunResult | null>;
704
+ private settle;
705
+ private disposeOverlayOnly;
706
+ static ɵfac: i0.ɵɵFactoryDeclaration<AXMAiAssistPromptBoxService, never>;
707
+ static ɵprov: i0.ɵɵInjectableDeclaration<AXMAiAssistPromptBoxService>;
708
+ }
709
+
710
+ interface AXMAiAssistDraftImage {
711
+ clientId: string;
712
+ previewUrl: string;
713
+ mimeType: string;
714
+ name?: string;
715
+ fileId?: string;
716
+ }
717
+ interface AXMAiAssistDraftAudio {
718
+ clientId: string;
719
+ mimeType: string;
720
+ name?: string;
721
+ fileId?: string;
722
+ }
723
+ interface AXMAiAssistDraftFile {
724
+ clientId: string;
725
+ mimeType: string;
726
+ name?: string;
727
+ fileId?: string;
728
+ }
729
+ /**
730
+ * Floating prompt UI for AI assist: gradient chrome, inner composer, and image/audio/document attachments. Target assist/agent comes from optional initial ids on open.
731
+ */
732
+ declare class AXMAiAssistPromptBoxComponent implements OnInit, OnDestroy {
733
+ private readonly toastService;
734
+ private readonly translation;
735
+ private readonly fileStorage;
736
+ private readonly fileService;
737
+ private readonly platformId;
738
+ readonly title: i0.InputSignal<string>;
739
+ readonly placeholder: i0.InputSignal<string>;
740
+ readonly initialPrompt: i0.InputSignal<string>;
741
+ readonly contentMaxWidthPx: i0.InputSignal<number>;
742
+ readonly initialAssistId: i0.InputSignal<string | undefined>;
743
+ readonly initialDirectAgentId: i0.InputSignal<string | undefined>;
744
+ readonly runPrompt: i0.InputSignal<(payload: AXPAiAssistPromptSubmitPayload) => Promise<AXPAiAssistRunResult>>;
745
+ readonly requestClose: i0.InputSignal<(result: AXPAiAssistRunResult | null) => void>;
746
+ readonly promptDraft: i0.WritableSignal<string>;
747
+ readonly busy: i0.WritableSignal<boolean>;
748
+ readonly isComposerSaving: i0.WritableSignal<boolean>;
749
+ readonly draftAttachmentGroupId: i0.WritableSignal<string | null>;
750
+ readonly draftComposerImages: i0.WritableSignal<AXMAiAssistDraftImage[]>;
751
+ readonly draftComposerAudios: i0.WritableSignal<AXMAiAssistDraftAudio[]>;
752
+ readonly draftComposerFiles: i0.WritableSignal<AXMAiAssistDraftFile[]>;
753
+ readonly assistTargetKey: i0.WritableSignal<string>;
754
+ readonly canSend: i0.Signal<boolean>;
755
+ ngOnInit(): Promise<void>;
756
+ ngOnDestroy(): void;
757
+ onPromptDraftChange(value: string | null | undefined): void;
758
+ /**
759
+ * Enter sends; Shift+Enter inserts a newline. IME composition Enter is left unchanged.
760
+ */
761
+ onPromptKeydown(event: KeyboardEvent): void;
762
+ onCancel(): void;
763
+ onMenuCancel(panel: {
764
+ close: () => void;
765
+ }): void;
766
+ /**
767
+ * Dismisses the prompt box like Cancel (disabled while a run is in flight, same as footer Cancel).
768
+ */
769
+ onDocumentEscape(): void;
770
+ openImagePicker(): void;
771
+ openAudioPicker(): void;
772
+ openDocumentPicker(): void;
773
+ onSend(): Promise<void>;
774
+ removeDraftImage(clientId: string): void;
775
+ removeDraftAudio(clientId: string): void;
776
+ removeDraftFile(clientId: string): void;
777
+ private pickComposerImages;
778
+ private pickComposerAudios;
779
+ private pickComposerDocuments;
780
+ private processComposerImageFiles;
781
+ private processComposerAudioFiles;
782
+ private processComposerDocumentFiles;
783
+ private showUploadWarning;
784
+ static ɵfac: i0.ɵɵFactoryDeclaration<AXMAiAssistPromptBoxComponent, never>;
785
+ static ɵcmp: i0.ɵɵComponentDeclaration<AXMAiAssistPromptBoxComponent, "axm-ai-assist-prompt-box", never, { "title": { "alias": "title"; "required": true; "isSignal": true; }; "placeholder": { "alias": "placeholder"; "required": false; "isSignal": true; }; "initialPrompt": { "alias": "initialPrompt"; "required": false; "isSignal": true; }; "contentMaxWidthPx": { "alias": "contentMaxWidthPx"; "required": false; "isSignal": true; }; "initialAssistId": { "alias": "initialAssistId"; "required": false; "isSignal": true; }; "initialDirectAgentId": { "alias": "initialDirectAgentId"; "required": false; "isSignal": true; }; "runPrompt": { "alias": "runPrompt"; "required": true; "isSignal": true; }; "requestClose": { "alias": "requestClose"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
786
+ }
787
+
788
+ /**
789
+ * Combined text for structured JSON extraction (text segments only).
790
+ */
791
+ declare function extractLastAssistantStructuredParts(messages: AXPAiChatMessage[]): {
792
+ combined: string;
793
+ segments: string[];
794
+ };
795
+
796
+ export { AI_CHAT_ATTACHMENT_CATEGORY, AI_CHAT_ATTACHMENT_REF_TYPE, AI_CHAT_GENERATED_IMAGE_REF_TYPE, AI_CHAT_GENERATED_SPEECH_REF_TYPE, AI_CHAT_TTS_PCM_SAMPLE_RATE, AI_GENERATED_IMAGE_MAX_REMOTE_URL_IN_TOOL, AXMAiAssistPromptBoxComponent, AXMAiAssistPromptBoxService, AXMAiManagementMenuProvider, AXMAiManagementModule, AXMPermissionDefinitionProvider, AXPAiAssistChatModelCatalogService, AXPAiAssistDefaultMaxStructuredRetries, AXPAiAssistDefaultStructuredMaxTokens, AXPAiAssistService, AXPAiChatToolRunContextService, AXPAiDefaultModelPickerService, AXPAiEngine, AXPAiManagerService, AXPAiOutputContractResolveService, AXPAiPlatformRuntimeContextBuilder, AXPAiStructuredOutputError, AiManagementManifest, axpAiAssistInitialMessagesToTranscript, axpAiAssistStarterPromptLabels, axpAiAssistStarterPromptTexts, axpAiChatMessageIsDelegatedReflectionExcluded, axpAiChatToolOrAgentResultBodyJson, axpAiChatToolResultBodyJson, axpAiChatUserMessage, axpAiDelegatedAgentOutcomeResponsesPlainText, axpAiDelegatedAgentPromptPreview, axpAiDelegatedAgentResultSegments, axpAiStripAssistInitialHtmlToPlain, axpBuildDelegatedAgentRunInputSnapshot, axpSanitizeLastProviderPayloadForPersistence, axpStripEphemeralStreamChunksFromProviderRaw, blobOrFileFromImageResult, buildStructuredOutputRetryUserText, createBrowserPlayableTtsBlobUrl, extractLastAssistantStructuredParts, getAiChatCommandLlmParametersOverride, isRawPcmMimeType, loadAssistPermissionRows, persistAiChatAttachmentImage, persistAiGeneratedImage, persistAiGeneratedSpeech, prepareTtsBytesForBrowserPlayback, validateAgainstContract, validateJsonSchemaMini, validateStructuredAssistantResponse, wrapPcm16LeInWav };
797
+ export type { AXMAiAssistPermissionRow, AXPAiAssistCannotComplete, AXPAiAssistExecutionResult, AXPAiAssistPopupSize, AXPAiAssistPromptSubmitPayload, AXPAiAssistRunContext, AXPAiAssistRunInput, AXPAiAssistRunLoadingDialogSpec, AXPAiAssistRunResult, AXPAiAssistShowOptions, AXPAiAssistStructuredOutputAttemptRecord, AXPAiAssistStructuredOutputRunRaw, AXPAiAssistTokenUsageSnapshot, AXPAiAssistUserMediaAttachment, AXPAiAssistValidationError, AXPAiChatToolRunContext, AXPAiStructuredValidator, AiChatTtsPlaybackBytes };