@praxisui/ai 8.0.0-beta.8 → 8.0.0-beta.80
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/README.md +78 -9
- package/fesm2022/praxisui-ai.mjs +2705 -491
- package/package.json +13 -7
- package/{index.d.ts → types/praxisui-ai.d.ts} +826 -24
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: "AI"
|
|
3
3
|
slug: "ai-overview"
|
|
4
|
-
description: "Overview of @praxisui/ai with backend-orchestrated provider flows,
|
|
4
|
+
description: "Overview of @praxisui/ai with backend-orchestrated provider flows, governed assistant UX, structured configuration proposals, and tenant-aware risk policy."
|
|
5
5
|
doc_type: "guide"
|
|
6
6
|
document_kind: "component-overview"
|
|
7
7
|
component: "ai"
|
|
@@ -27,13 +27,13 @@ related_docs:
|
|
|
27
27
|
|
|
28
28
|
# @praxisui/ai
|
|
29
29
|
|
|
30
|
-
AI building blocks and assistant integration for Praxis UI applications. The package is designed for Angular hosts that need
|
|
30
|
+
AI building blocks and assistant integration for Praxis UI applications. The package is designed for Angular hosts that need AI to understand existing runtime materializers, ask for clarification, answer consultative questions, and propose governed configuration changes without turning the browser into a free-form code generator.
|
|
31
31
|
|
|
32
32
|
Short mental model:
|
|
33
33
|
|
|
34
34
|
- `@praxisui/ai` is not a direct wrapper around external LLM providers.
|
|
35
35
|
- the canonical path is backend orchestration through Praxis Config endpoints under `/api/praxis/config/ai/**`.
|
|
36
|
-
- the library helps the host compose suggestions, clarifications, risk policy, and
|
|
36
|
+
- the library helps the host compose suggestions, clarifications, risk policy, and governed apply flows without turning AI into a host-local sidecar or disposable screen generator.
|
|
37
37
|
|
|
38
38
|
## Documentation
|
|
39
39
|
|
|
@@ -54,15 +54,15 @@ Peer dependencies (Angular v20):
|
|
|
54
54
|
|
|
55
55
|
## When to use
|
|
56
56
|
|
|
57
|
-
- Add AI-assisted
|
|
57
|
+
- Add AI-assisted consultation, clarification, and governed configuration proposals to Praxis UI components
|
|
58
58
|
- Centralize provider and model validation behind backend-controlled endpoints
|
|
59
59
|
- Apply tenant-aware confirmation and risk policies in enterprise environments
|
|
60
60
|
|
|
61
61
|
## What this package is responsible for
|
|
62
62
|
|
|
63
63
|
- assistant UX surfaces and interaction flow
|
|
64
|
-
- reusable assistant shell primitives such as conversation messages, quick replies, prompt composer,
|
|
65
|
-
- backend API orchestration for provider catalog, suggestions, and
|
|
64
|
+
- reusable assistant shell primitives such as conversation messages, quick replies, prompt composer, governed actions, viewport-level drag/resize chrome, layout restore and minimized-session dock
|
|
65
|
+
- backend API orchestration for provider catalog, suggestions, structured proposals, and governed apply flows
|
|
66
66
|
- local lightweight session history with tenant/env/user scoping
|
|
67
67
|
- confirmation and risk policy integration for sensitive changes
|
|
68
68
|
|
|
@@ -72,13 +72,36 @@ Peer dependencies (Angular v20):
|
|
|
72
72
|
|
|
73
73
|
`PraxisAiAssistantShellComponent` is the canonical chrome for Praxis assistant experiences that need a conversational surface. Hosts should prefer it for new specialized flows instead of creating component-local assistant UI.
|
|
74
74
|
|
|
75
|
+
`PraxisAiAssistantComponent` remains exported only as a compatibility surface for older configuration-assistant integrations. New Praxis components, demos and cockpit flows should use `PraxisAiAssistantShellComponent` with `PraxisAssistantTurnOrchestratorService` and, when the assistant can be minimized or resumed, `PraxisAssistantSessionRegistryService`.
|
|
76
|
+
|
|
75
77
|
The shell owns the shared UX primitives:
|
|
76
78
|
- conversation messages and message actions such as edit/resend/custom actions
|
|
77
79
|
- prompt composer, Enter-to-submit behavior, pasted or selected file attachments, submit/apply actions and attach/remove attachment events
|
|
78
80
|
- active context chips for component, schema, selection, route, tenant or custom context
|
|
81
|
+
- rich quick reply chips with optional description, icon, tone and structured context hints
|
|
79
82
|
- attached context metadata for files, images, JSON, schema and text payloads
|
|
80
83
|
- mode and state labels for `config`, `agentic-authoring`, `chat`, `diagnostic`, `review` and `inline-help`
|
|
81
|
-
- draggable/resizable panel layout and accessibility labels
|
|
84
|
+
- viewport-level draggable/resizable panel layout, pointer-only resize handles, layout restore, minimize affordance and accessibility labels
|
|
85
|
+
|
|
86
|
+
The shell is a viewport-level assistant surface, not a component-bounded popover. A component trigger opens the assistant with local semantic context, but the panel can move across the page, resize from any edge or corner, and be restored to its initial safe layout through the shared "Restaurar posição do assistente" affordance. The default close affordance is "Minimizar assistente" because specialized hosts usually preserve the governed session through `PraxisAssistantSessionRegistryService`; hosts that truly close/discard the session may override the label.
|
|
87
|
+
|
|
88
|
+
The assistant chrome belongs to the platform, not to the component that opened it. Hosts should provide contextual labels, mode, state and context chips, while `PraxisAiAssistantShellComponent` keeps the shared visual hierarchy: assistant identity first, contextual title/subtitle second, and operational mode/state as compact metadata. Component-specific styling should not make the shell look owned by Page Builder, Table, Dynamic Form or any other individual runtime.
|
|
89
|
+
|
|
90
|
+
Composer actions are state-aware. The primary action changes from "Interpretar pedido" to clarification, review, applying, success or error labels according to the current turn state. Secondary recovery actions such as retry and cancel are surfaced by the shell when the active turn can be recovered, while hosts still own the flow-specific semantics.
|
|
91
|
+
|
|
92
|
+
Hosts can render the primary action as icon-only with `iconOnly=true` when that matches modern LLM chat composer conventions. The action must still provide a semantic `label` or `ariaLabel`; the shell uses it for accessibility and tooltip text while omitting the visible label.
|
|
93
|
+
|
|
94
|
+
Message-level actions can also be rendered as icon-only controls by setting `icon` or `iconOnly=true` on `PraxisAssistantShellMessageAction`. Built-in `edit`, `resend` and `copy` actions use `edit`, `replay` and `content_copy` icons by default, with the visible label moved to tooltip and `aria-label`.
|
|
95
|
+
|
|
96
|
+
`PraxisAiAssistantDockComponent` is the companion minimized-session surface for the same assistant identity. Hosts use it when a specialized assistant session remains active but the full shell is minimized. The dock owns the shared visual language for assistant presence, state badges and reopen affordance; hosts still provide the semantic session summary and decide what reopening means.
|
|
97
|
+
|
|
98
|
+
`PraxisAssistantSessionRegistryService` is the canonical in-memory registry for assistant sessions opened by different Praxis components in the same application shell. Component hosts register their active or minimized sessions with stable `ownerId`/`ownerType` metadata so a global assistant host can present one shared experience while preserving each component's semantic context. Sessions can use the default `presence: 'global-dock'` when the App Shell should render the minimized card, or `presence: 'origin-anchor'` when the owning component keeps the minimized affordance on its original trigger. The registry accepts an optional `PraxisAssistantContextSnapshot`, normalizes it before storage and rejects snapshots whose `identity.sessionId`, `identity.ownerId` or `identity.ownerType` do not match the session descriptor. Components that already have a canonical context snapshot should prefer the context helpers: `upsertContextSession`, `openContextSession`, `minimizeContextSession`, `getContextSession` and `removeContextSession`.
|
|
99
|
+
|
|
100
|
+
`PraxisAiAssistantSessionHostComponent` is the canonical presence host for minimized assistant sessions in an application or page shell. It reads `PraxisAssistantSessionRegistryService`, renders the shared dock for each minimized `global-dock` session, and emits the opened session snapshot after promoting that session to active in the registry. Hosts can opt into `includeOriginAnchored=true` for diagnostics or custom shells, but the default respects owner-local minimized affordances. Specialized components still own the full shell events until their authoring action contracts are promoted to shared platform contracts.
|
|
101
|
+
|
|
102
|
+
`PraxisAssistantContextSnapshot` is the canonical, UI-agnostic context contract for intelligent Praxis components. It represents safe assistant context: stable identity, current target, context chips, manifest reference, resource/schema hints, digests, governance hints, attachment summaries and declarative action contracts. It is intentionally not a raw component payload. Hosts should normalize snapshots with `normalizePraxisAssistantContextSnapshot` before storing them in a registry, passing them between components or using them as a handoff boundary.
|
|
103
|
+
|
|
104
|
+
Context snapshots must not contain full configs, form values, table rows, `currentState`, `runtimeState`, `pendingPatch`, arbitrary diagnostics, `File`, bytes, base64 or local `blob:` preview URLs. Use `dataProfileDigest`, `runtimeStateDigest`, `schemaFields` and `PraxisAssistantAttachmentSummary` instead. `@praxisui/ai` can declare handoff actions such as `shared-rule-handoff`, `governed-publication-handoff`, `materialization-handoff` and `enforcement-validation-handoff`, but the executable semantics of approving, publishing, materializing or enforcing domain rules belong to Praxis Config/domain-rules contracts.
|
|
82
105
|
|
|
83
106
|
The shell intentionally does not own component semantics. Specialized flows still own their adapter/service contract:
|
|
84
107
|
- configuration assistants continue to use `AiConfigAdapter`, capabilities, suggestions and patch review
|
|
@@ -87,13 +110,24 @@ The shell intentionally does not own component semantics. Specialized flows stil
|
|
|
87
110
|
|
|
88
111
|
This keeps a single assistant identity across Praxis components while preserving the canonical owner of each config or authoring document.
|
|
89
112
|
|
|
113
|
+
### Component Authoring Context
|
|
114
|
+
|
|
115
|
+
Configurable components that support AI authoring should expose a safe `authoringContract` through `AiConfigAdapter.getAuthoringContext()`. The contract lives at component level, not per capability, and can declare the response modes the component supports:
|
|
116
|
+
|
|
117
|
+
- `consult/answer` for questions about the current component, such as active resource path, endpoint, schema fields, styling capabilities or how-to guidance.
|
|
118
|
+
- `edit/componentEditPlan` for governed changes that must be compiled and reviewed before they become a patch.
|
|
119
|
+
|
|
120
|
+
When a component exposes factual grounding for consultative answers, include a `consultativeContext` with the minimal safe facts, such as `resourcePath` and `answerableQuestionKinds`. The frontend must not classify intent through local keywords; it sends this context to the backend/LLM orchestrator, which decides whether the turn is `consult/answer` or `edit/componentEditPlan`. Do not duplicate this declaration on every operation. Individual operations should still describe their own target, effects, validators and materialization through the component manifest or edit-plan contract.
|
|
121
|
+
|
|
122
|
+
Use `createComponentAuthoringContext(...)` from `@praxisui/ai` when returning the adapter context. The helper normalizes the contract into a JSON-safe object, drops `undefined` fields and rejects non-JSON values before they leak into `contextHints`.
|
|
123
|
+
|
|
90
124
|
The shell ships with centralized PT-BR default labels and accepts the `labels` input for a flow-specific override. The override is partial: omitted labels continue to come from the shared defaults.
|
|
91
125
|
|
|
92
126
|
By default, the prompt composer submits with `Enter` and keeps `Shift+Enter` for multiline prompts. Hosts with custom composer behavior can set `submitOnEnter` to `false`.
|
|
93
127
|
|
|
94
128
|
When a user pastes an image into the prompt composer, the shell emits `attachmentsPasted` with `PraxisAssistantShellAttachment` items containing the original `File`, image metadata, `source: 'paste'` and a local preview URL.
|
|
95
129
|
|
|
96
|
-
Hosts can also enable button-based file selection with `enableFileAttachments`, `attachmentAccept` and `attachmentMultiple`. In that mode, the attach button opens the native file picker and emits `attachmentsSelected` with `source: 'file-picker'`. When file selection is disabled, the legacy `attach` event remains available for host-defined context actions. The shell does not upload or persist files; the host owns storage, redaction and backend forwarding.
|
|
130
|
+
Hosts can also enable button-based file selection with `enableFileAttachments`, `attachmentAccept` and `attachmentMultiple`. In that mode, the attach button opens the native file picker and emits `attachmentsSelected` with `source: 'file-picker'`. When file selection is disabled, the legacy `attach` event remains available for host-defined context actions. Hosts that do not support attachment semantics should set `showAttachAction=false`; hosts that do not support pasted image context should set `enablePastedAttachments=false`. The shell does not upload or persist files; the host owns storage, redaction and backend forwarding.
|
|
97
131
|
|
|
98
132
|
Flows that forward attachments to backend authoring endpoints should send only serializable attachment summaries, such as `id`, `name`, `kind`, `mimeType`, `sizeBytes`, `source` and `hasPreview`. Do not send `File`, bytes, base64 payloads or local `blob:` URLs to the assistant contract. When a backend clarification needs to keep attachment context for the next turn, the flow can return those summaries inside `pendingClarification.diagnostics.attachmentSummaries`; the turn orchestrator preserves that pending clarification state and sends it back with the next `clarify` action.
|
|
99
133
|
|
|
@@ -106,7 +140,7 @@ The orchestrator owns the turn lifecycle:
|
|
|
106
140
|
- stable `sessionId` creation per controller when the host does not provide one
|
|
107
141
|
- fresh `clientTurnId` creation for each executable submit/apply/retry/cancel turn
|
|
108
142
|
- LLM-assisted clarification as a first-class `clarification` state
|
|
109
|
-
- structured clarification questions and quick replies
|
|
143
|
+
- structured clarification questions and quick replies, including rich chip metadata from backend flows
|
|
110
144
|
- edit/resend actions for user messages, including conversation fork semantics
|
|
111
145
|
- attached context add/remove state
|
|
112
146
|
- apply/retry/cancel dispatch when the active flow supports it
|
|
@@ -118,6 +152,8 @@ When a flow asks for clarification, direct user input while the controller is in
|
|
|
118
152
|
|
|
119
153
|
`pendingClarification.diagnostics` is opaque flow state. It is preserved across the next clarification answer so backend-owned semantics can keep metadata-only context, including attachment summaries, without the shell understanding the domain or retaining local file payloads.
|
|
120
154
|
|
|
155
|
+
Backend-owned flows may return quick replies as clickable chips for candidate resources, catalog follow-ups or clarification options. Hosts should keep the full quick reply object: `description`, `icon` and `tone` are presentation hints, while `contextHints` carries structured values such as `resourcePath`, `submitUrl`, `operation` and `schemaUrl` for the next turn. Do not downcast these replies to label/prompt pairs or recompute the options in the UI.
|
|
156
|
+
|
|
121
157
|
When a user edits or resends an earlier user message, the controller forks the conversation from that message before invoking the flow again. Downstream assistant/user messages, quick replies, pending clarification and preview state are cleared so the backend receives the revised conversation branch instead of stale follow-up context. Hosts that expose an edit composer should call `submitEditedMessage(messageId, text)` when the revised prompt is submitted.
|
|
122
158
|
|
|
123
159
|
## What this package does not own
|
|
@@ -144,9 +180,18 @@ Hosts configure tenant/env/user headers and global AI config through the `@praxi
|
|
|
144
180
|
|
|
145
181
|
- `AI_BACKEND_STORAGE_OPTIONS`: provides `headersFactory`, optional `defaultHeaders`, and the explicit `allowLocalIdentityFallback` demo mode.
|
|
146
182
|
- `AI_BACKEND_CONFIG_STORE`: provides `getAiConfigSnapshot`, `aiConfigChanges$`, and `saveAiConfig` for provider/model/global AI settings.
|
|
183
|
+
- `AI_BACKEND_ENDPOINTS`: optional explicit endpoint override for hosts that serve AI orchestration from a gateway different from the canonical application API.
|
|
147
184
|
|
|
148
185
|
The library does not consume `@praxisui/core` storage tokens as a hidden fallback. Host applications should wire the AI tokens directly when integrating with `/api/praxis/config/ai/**`.
|
|
149
186
|
|
|
187
|
+
Endpoint resolution follows the same platform boundary used by the rest of the metadata-driven runtime:
|
|
188
|
+
|
|
189
|
+
1. `AI_BACKEND_ENDPOINTS.aiBaseUrl` and `AI_BACKEND_ENDPOINTS.aiContextBaseUrl`, when the host explicitly routes AI through a distinct gateway.
|
|
190
|
+
2. `API_URL.default.baseUrl` from `@praxisui/core`, deriving `/praxis/config/ai/**` and `/praxis/config/ai-context/**` below that API root.
|
|
191
|
+
3. Relative fallbacks `/api/praxis/config/ai` and `/api/praxis/config/ai-context` for proxied local hosts and existing integrations.
|
|
192
|
+
|
|
193
|
+
Static hosts such as the Praxis landing page should normally configure `API_URL.default.baseUrl` to the Quickstart or production API origin and let `@praxisui/ai` derive the AI endpoints. This keeps the AI assistant aligned with the same backend origin used by metadata, config and dynamic examples.
|
|
194
|
+
|
|
150
195
|
### Provider catalog and validation
|
|
151
196
|
- `GET /api/praxis/config/ai/providers/catalog`
|
|
152
197
|
- `POST /api/praxis/config/ai/providers/models`
|
|
@@ -192,6 +237,30 @@ Payload:
|
|
|
192
237
|
Notes:
|
|
193
238
|
- `currentState` must be the config root (not wrapped under `config`).
|
|
194
239
|
- Clarifications may return `{ type: "clarification", message, options }`.
|
|
240
|
+
- Responses may include `observationId`. `PraxisAiAssistantShellComponent` uses it to send write-only quality feedback to the backend triage endpoint without exposing prompt listings in public clients.
|
|
241
|
+
|
|
242
|
+
### Assistant observation feedback
|
|
243
|
+
- `POST /api/praxis/config/ai/triage/observations/{observationId}/feedback`
|
|
244
|
+
|
|
245
|
+
`AiBackendApiService.sendAssistantObservationFeedback` posts `rating`, `reasonCode` and optional `comment` to the governed triage endpoint. The shell renders positive/negative feedback controls only when an assistant message has an `observationId`; listing observations remains an administrative backend capability, not a public UI concern.
|
|
246
|
+
|
|
247
|
+
### Agentic authoring manifest tools
|
|
248
|
+
- `GET /api/praxis/config/ai/authoring/manifests/{componentId}`
|
|
249
|
+
- `GET /api/praxis/config/ai/authoring/manifests/{componentId}/editable-targets`
|
|
250
|
+
- `GET /api/praxis/config/ai/authoring/manifests/{componentId}/operations`
|
|
251
|
+
- `POST /api/praxis/config/ai/authoring/manifests/{componentId}/resolve-target`
|
|
252
|
+
- `POST /api/praxis/config/ai/authoring/manifests/{componentId}/validate-plan`
|
|
253
|
+
- `POST /api/praxis/config/ai/authoring/manifests/{componentId}/compile-patch`
|
|
254
|
+
|
|
255
|
+
`AiBackendApiService` exposes these endpoints through typed methods so hosts can inspect the executable manifest, resolve targets, validate a component edit plan and compile a backend-owned patch without routing by local keywords.
|
|
256
|
+
|
|
257
|
+
### Agentic authoring turn streaming
|
|
258
|
+
- `POST /api/praxis/config/ai/authoring/turn/stream/start`
|
|
259
|
+
- `GET /api/praxis/config/ai/authoring/turn/stream/{streamId}`
|
|
260
|
+
- `GET /api/praxis/config/ai/authoring/turn/stream/{streamId}/probe`
|
|
261
|
+
- `POST /api/praxis/config/ai/authoring/turn/stream/{streamId}/cancel`
|
|
262
|
+
|
|
263
|
+
`AiBackendApiService.startAgenticAuthoringTurnStream`, `connectAgenticAuthoringTurnStream` and `cancelAgenticAuthoringTurnStream` use the same SSE envelope contract as patch streaming. Browser `EventSource` cannot send custom headers, so signed stream tokens returned by the backend should be passed to `connectAgenticAuthoringTurnStream` and `cancelAgenticAuthoringTurnStream` when the backend uses signed-url stream auth.
|
|
195
264
|
|
|
196
265
|
## Assistant local history (UI)
|
|
197
266
|
|