@aparte/core 0.2.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +53 -0
- package/dist/client/aparte-client.d.ts +326 -0
- package/dist/client/aparte-client.d.ts.map +1 -0
- package/dist/client/stream-adapter.d.ts +197 -0
- package/dist/client/stream-adapter.d.ts.map +1 -0
- package/dist/components/bubble/aparte-chat-bubble.d.ts +153 -0
- package/dist/components/bubble/aparte-chat-bubble.d.ts.map +1 -0
- package/dist/components/bubble/bubble-sync.d.ts +44 -0
- package/dist/components/bubble/bubble-sync.d.ts.map +1 -0
- package/dist/components/bubble/index.d.ts +4 -0
- package/dist/components/bubble/index.d.ts.map +1 -0
- package/dist/components/chat/aparte-chat.d.ts +49 -0
- package/dist/components/chat/aparte-chat.d.ts.map +1 -0
- package/dist/components/chat/index.d.ts +2 -0
- package/dist/components/chat/index.d.ts.map +1 -0
- package/dist/components/composer/aparte-composer-action.d.ts +37 -0
- package/dist/components/composer/aparte-composer-action.d.ts.map +1 -0
- package/dist/components/composer/aparte-composer-add-attachment.d.ts +27 -0
- package/dist/components/composer/aparte-composer-add-attachment.d.ts.map +1 -0
- package/dist/components/composer/aparte-composer-attachments.d.ts +26 -0
- package/dist/components/composer/aparte-composer-attachments.d.ts.map +1 -0
- package/dist/components/composer/aparte-composer-cancel.d.ts +21 -0
- package/dist/components/composer/aparte-composer-cancel.d.ts.map +1 -0
- package/dist/components/composer/aparte-composer-input.d.ts +63 -0
- package/dist/components/composer/aparte-composer-input.d.ts.map +1 -0
- package/dist/components/composer/aparte-composer-send.d.ts +25 -0
- package/dist/components/composer/aparte-composer-send.d.ts.map +1 -0
- package/dist/components/composer/aparte-composer.d.ts +150 -0
- package/dist/components/composer/aparte-composer.d.ts.map +1 -0
- package/dist/components/composer/index.d.ts +9 -0
- package/dist/components/composer/index.d.ts.map +1 -0
- package/dist/components/conversation-list/aparte-conversation-list.d.ts +50 -0
- package/dist/components/conversation-list/aparte-conversation-list.d.ts.map +1 -0
- package/dist/components/conversation-list/index.d.ts +2 -0
- package/dist/components/conversation-list/index.d.ts.map +1 -0
- package/dist/components/elicitation/aparte-elicitation.d.ts +29 -0
- package/dist/components/elicitation/aparte-elicitation.d.ts.map +1 -0
- package/dist/components/index.d.ts +10 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/status/aparte-chat-status.d.ts +34 -0
- package/dist/components/status/aparte-chat-status.d.ts.map +1 -0
- package/dist/components/status/index.d.ts +2 -0
- package/dist/components/status/index.d.ts.map +1 -0
- package/dist/components/viewport/aparte-chat-viewport.d.ts +358 -0
- package/dist/components/viewport/aparte-chat-viewport.d.ts.map +1 -0
- package/dist/components/viewport/index.d.ts +2 -0
- package/dist/components/viewport/index.d.ts.map +1 -0
- package/dist/config/action-provider.d.ts +59 -0
- package/dist/config/action-provider.d.ts.map +1 -0
- package/dist/config/aparte-config.d.ts +490 -0
- package/dist/config/aparte-config.d.ts.map +1 -0
- package/dist/config/attachment-renderer.d.ts +28 -0
- package/dist/config/attachment-renderer.d.ts.map +1 -0
- package/dist/config/avatar-provider.d.ts +35 -0
- package/dist/config/avatar-provider.d.ts.map +1 -0
- package/dist/config/bubble-shell-renderer.d.ts +41 -0
- package/dist/config/bubble-shell-renderer.d.ts.map +1 -0
- package/dist/config/config-context.d.ts +47 -0
- package/dist/config/config-context.d.ts.map +1 -0
- package/dist/config/error-renderer.d.ts +26 -0
- package/dist/config/error-renderer.d.ts.map +1 -0
- package/dist/config/icon-provider.d.ts +63 -0
- package/dist/config/icon-provider.d.ts.map +1 -0
- package/dist/config/index.d.ts +19 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/locale.d.ts +60 -0
- package/dist/config/locale.d.ts.map +1 -0
- package/dist/config/sanitize.d.ts +31 -0
- package/dist/config/sanitize.d.ts.map +1 -0
- package/dist/config/sibling-nav-renderer.d.ts +27 -0
- package/dist/config/sibling-nav-renderer.d.ts.map +1 -0
- package/dist/config/skeleton-provider.d.ts +26 -0
- package/dist/config/skeleton-provider.d.ts.map +1 -0
- package/dist/config/status-renderer.d.ts +23 -0
- package/dist/config/status-renderer.d.ts.map +1 -0
- package/dist/conversations/conversation-controller.d.ts +126 -0
- package/dist/conversations/conversation-controller.d.ts.map +1 -0
- package/dist/conversations/conversation-manager.d.ts +98 -0
- package/dist/conversations/conversation-manager.d.ts.map +1 -0
- package/dist/conversations/index.d.ts +5 -0
- package/dist/conversations/index.d.ts.map +1 -0
- package/dist/conversations/types.d.ts +172 -0
- package/dist/conversations/types.d.ts.map +1 -0
- package/dist/custom-elements.json +15833 -0
- package/dist/elicitation/index.d.ts +20 -0
- package/dist/elicitation/index.d.ts.map +1 -0
- package/dist/elicitation/panel.d.ts +18 -0
- package/dist/elicitation/panel.d.ts.map +1 -0
- package/dist/elicitation/types.d.ts +98 -0
- package/dist/elicitation/types.d.ts.map +1 -0
- package/dist/host/aparte-chat-host.d.ts +176 -0
- package/dist/host/aparte-chat-host.d.ts.map +1 -0
- package/dist/host/index.d.ts +2 -0
- package/dist/host/index.d.ts.map +1 -0
- package/dist/index-D89k-n2Q.js +6294 -0
- package/dist/index-D89k-n2Q.js.map +1 -0
- package/dist/index.css +2554 -0
- package/dist/index.d.ts +62 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3763 -0
- package/dist/index.js.map +1 -0
- package/dist/index.node.d.ts +53 -0
- package/dist/index.node.d.ts.map +1 -0
- package/dist/index.node.js +49 -0
- package/dist/index.node.js.map +1 -0
- package/dist/interop/element-props.d.ts +23 -0
- package/dist/interop/element-props.d.ts.map +1 -0
- package/dist/parsers/aparte-event-stream.d.ts +13 -0
- package/dist/parsers/aparte-event-stream.d.ts.map +1 -0
- package/dist/parsers/aparte-stream-parser.d.ts +137 -0
- package/dist/parsers/aparte-stream-parser.d.ts.map +1 -0
- package/dist/parsers/index.d.ts +4 -0
- package/dist/parsers/index.d.ts.map +1 -0
- package/dist/primitives/index.d.ts +8 -0
- package/dist/primitives/index.d.ts.map +1 -0
- package/dist/primitives/progress-spinner/aparte-progress-spinner.d.ts +25 -0
- package/dist/primitives/progress-spinner/aparte-progress-spinner.d.ts.map +1 -0
- package/dist/primitives/progress-spinner/index.d.ts +2 -0
- package/dist/primitives/progress-spinner/index.d.ts.map +1 -0
- package/dist/primitives/select/aparte-optgroup.d.ts +32 -0
- package/dist/primitives/select/aparte-optgroup.d.ts.map +1 -0
- package/dist/primitives/select/aparte-option.d.ts +30 -0
- package/dist/primitives/select/aparte-option.d.ts.map +1 -0
- package/dist/primitives/select/aparte-select.d.ts +74 -0
- package/dist/primitives/select/aparte-select.d.ts.map +1 -0
- package/dist/primitives/select/index.d.ts +9 -0
- package/dist/primitives/select/index.d.ts.map +1 -0
- package/dist/renderers/index.d.ts +5 -0
- package/dist/renderers/index.d.ts.map +1 -0
- package/dist/renderers/segment-renderers.d.ts +31 -0
- package/dist/renderers/segment-renderers.d.ts.map +1 -0
- package/dist/runtime/message-repository.d.ts +111 -0
- package/dist/runtime/message-repository.d.ts.map +1 -0
- package/dist/transport/backend-handler.d.ts +50 -0
- package/dist/transport/backend-handler.d.ts.map +1 -0
- package/dist/transport/backend-transport.d.ts +39 -0
- package/dist/transport/backend-transport.d.ts.map +1 -0
- package/dist/transport/direct-transport.d.ts +36 -0
- package/dist/transport/direct-transport.d.ts.map +1 -0
- package/dist/transport/index.d.ts +6 -0
- package/dist/transport/index.d.ts.map +1 -0
- package/dist/transport/types.d.ts +73 -0
- package/dist/transport/types.d.ts.map +1 -0
- package/dist/types/chat.d.ts +223 -0
- package/dist/types/chat.d.ts.map +1 -0
- package/dist/types/errors.d.ts +25 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/event-map.d.ts +41 -0
- package/dist/types/event-map.d.ts.map +1 -0
- package/dist/types/events.d.ts +290 -0
- package/dist/types/events.d.ts.map +1 -0
- package/dist/types/imperative-api.d.ts +38 -0
- package/dist/types/imperative-api.d.ts.map +1 -0
- package/dist/types/index.d.ts +22 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/model-provider.d.ts +229 -0
- package/dist/types/model-provider.d.ts.map +1 -0
- package/dist/types/models.d.ts +173 -0
- package/dist/types/models.d.ts.map +1 -0
- package/dist/types/parsers.d.ts +42 -0
- package/dist/types/parsers.d.ts.map +1 -0
- package/dist/types/providers.d.ts +93 -0
- package/dist/types/providers.d.ts.map +1 -0
- package/dist/types/segments.d.ts +221 -0
- package/dist/types/segments.d.ts.map +1 -0
- package/dist/types/theming.d.ts +44 -0
- package/dist/types/theming.d.ts.map +1 -0
- package/dist/types/tools.d.ts +98 -0
- package/dist/types/tools.d.ts.map +1 -0
- package/dist/utils/assert-never.d.ts +9 -0
- package/dist/utils/assert-never.d.ts.map +1 -0
- package/dist/utils/css-escape.d.ts +15 -0
- package/dist/utils/css-escape.d.ts.map +1 -0
- package/package.json +68 -0
|
@@ -0,0 +1,490 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AparteConfig
|
|
3
|
+
*
|
|
4
|
+
* Central configuration singleton for Aparte.
|
|
5
|
+
* Manages providers for Markdown rendering, Syntax Highlighting, Icons, and Skeleton loading.
|
|
6
|
+
*
|
|
7
|
+
* "Invisible but Flexible": Works out-of-the-box with sensible defaults,
|
|
8
|
+
* but allows complete customization via dependency injection.
|
|
9
|
+
*/
|
|
10
|
+
import { AparteIconProvider, AparteIconName } from './icon-provider.js';
|
|
11
|
+
import { AparteAvatarProvider } from './avatar-provider.js';
|
|
12
|
+
import { AparteLocale } from './locale.js';
|
|
13
|
+
import { AparteAction, AparteActionZone } from './action-provider.js';
|
|
14
|
+
import { AparteSkeletonProvider, AparteSkeletonType } from './skeleton-provider.js';
|
|
15
|
+
import type { AparteStatusRenderer } from './status-renderer.js';
|
|
16
|
+
import type { AparteErrorRenderer } from './error-renderer.js';
|
|
17
|
+
import type { AparteAttachmentRenderer } from './attachment-renderer.js';
|
|
18
|
+
import type { AparteSiblingNavRenderer } from './sibling-nav-renderer.js';
|
|
19
|
+
import type { AparteBubbleShellRenderer } from './bubble-shell-renderer.js';
|
|
20
|
+
import type { AparteAIProvider, AparteAIModel, AparteModelConfig } from '../types/model-provider.js';
|
|
21
|
+
import type { AparteTransport } from '../transport/index.js';
|
|
22
|
+
import type { AparteTool, AparteToolHandler, AparteToolRenderer } from '../types/tools.js';
|
|
23
|
+
import type { AparteBubbleActionsConfig, AparteBubbleActionName } from '../types/models.js';
|
|
24
|
+
import type { ConversationManager } from '../conversations/conversation-manager.js';
|
|
25
|
+
import { type AparteSanitizer } from './sanitize.js';
|
|
26
|
+
import type { AparteElicitationPresenter, AparteElicitationRequest, AparteElicitationResult } from '../elicitation/types.js';
|
|
27
|
+
export type AparteMarkdownProvider = (raw: string) => string;
|
|
28
|
+
export type AparteHighlightProvider = ((code: string, lang: string) => string) | ((code: string, lang: string) => Promise<string>);
|
|
29
|
+
export type AparteSystemPromptVarsProvider = () => Record<string, string>;
|
|
30
|
+
export type AparteLocaleProvider = AparteLocale;
|
|
31
|
+
export type AparteKeyProvider = (providerId: string) => string | Promise<string | undefined> | undefined;
|
|
32
|
+
export interface AparteModelPreference {
|
|
33
|
+
provider: string;
|
|
34
|
+
model: string;
|
|
35
|
+
}
|
|
36
|
+
export interface AparteModelPreferenceProvider {
|
|
37
|
+
/** Called whenever the selected provider+model changes */
|
|
38
|
+
save: (provider: string, model: string) => void;
|
|
39
|
+
/** Called on init to restore the previously saved selection. Return null if nothing stored. */
|
|
40
|
+
load: () => AparteModelPreference | null;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Incremental Markdown renderer bound to a target element. Created once per
|
|
44
|
+
* streaming message: tokens are fed via `write()` and parsed + appended to the
|
|
45
|
+
* DOM incrementally (O(n) total — no full re-parse / innerHTML rebuild on every
|
|
46
|
+
* token). `end()` flushes any pending text when the stream completes.
|
|
47
|
+
*/
|
|
48
|
+
export interface AparteStreamingMarkdownRenderer {
|
|
49
|
+
/** Append a chunk of Markdown text — parsed incrementally, appended as DOM nodes. */
|
|
50
|
+
write(chunk: string): void;
|
|
51
|
+
/** Finalize the stream (flush any pending text). */
|
|
52
|
+
end(): void;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Factory for an {@link AparteStreamingMarkdownRenderer}: given a target element,
|
|
56
|
+
* returns a renderer that appends parsed Markdown into it. Supplied by an
|
|
57
|
+
* opt-in provider package (e.g. `@aparte/provider-streaming-markdown`); when none
|
|
58
|
+
* is registered the chat falls back to the one-shot `AparteMarkdownProvider`.
|
|
59
|
+
*/
|
|
60
|
+
export type AparteStreamingMarkdownProvider = (target: HTMLElement) => AparteStreamingMarkdownRenderer;
|
|
61
|
+
/**
|
|
62
|
+
* Builds the HTML document used as an artifact preview iframe `srcdoc` for a
|
|
63
|
+
* given artifact kind (react/html/svg/js/css/…). Supplied by the consuming app
|
|
64
|
+
* — e.g. a React/Babel/Tailwind live preview that loads those libs from a CDN.
|
|
65
|
+
* Core ships only a CDN-free fallback (svg/css/html/js render offline; other
|
|
66
|
+
* kinds degrade to a read-only code view), so the engine stays zero-network and
|
|
67
|
+
* framework-agnostic. The app opts into richer previews via
|
|
68
|
+
* {@link AparteConfigClass.setArtifactPreviewBuilder}.
|
|
69
|
+
*/
|
|
70
|
+
export type AparteArtifactPreviewBuilder = (kind: string, body: string, title: string) => string;
|
|
71
|
+
export declare class AparteConfigClass {
|
|
72
|
+
private _markdownProvider?;
|
|
73
|
+
private _streamingMarkdownProvider?;
|
|
74
|
+
private _highlightProvider?;
|
|
75
|
+
private _sanitizer;
|
|
76
|
+
private _systemPromptTemplate?;
|
|
77
|
+
private _systemPromptVarsProvider?;
|
|
78
|
+
private _skeletonProvider?;
|
|
79
|
+
private _statusRenderer?;
|
|
80
|
+
private _errorRenderer?;
|
|
81
|
+
private _attachmentRenderer?;
|
|
82
|
+
private _siblingNavRenderer?;
|
|
83
|
+
private _bubbleShellRenderer?;
|
|
84
|
+
private _iconProvider?;
|
|
85
|
+
private _avatarProvider?;
|
|
86
|
+
private _keyProvider?;
|
|
87
|
+
private _artifactPreviewBuilder?;
|
|
88
|
+
private _locale;
|
|
89
|
+
private _actions;
|
|
90
|
+
private _listeners;
|
|
91
|
+
private _aiProviders;
|
|
92
|
+
private _modelConfig;
|
|
93
|
+
/** Opt-in: gate the composer (block send + grey out) until a model is selected. */
|
|
94
|
+
private _requireModelSelection;
|
|
95
|
+
private _transport;
|
|
96
|
+
private _modelPreferenceProvider?;
|
|
97
|
+
private _conversationManager?;
|
|
98
|
+
private _elicitationPresenter?;
|
|
99
|
+
private _tools;
|
|
100
|
+
private _toolRenderers;
|
|
101
|
+
private _bubbleActionsConfig;
|
|
102
|
+
/**
|
|
103
|
+
* Register a custom action button. `zones` places it in the composer toolbar
|
|
104
|
+
* and/or the message (bubble) toolbar. Re-registering the same id overwrites
|
|
105
|
+
* it. Notifies mounted elements so they re-render.
|
|
106
|
+
*/
|
|
107
|
+
registerAction(action: AparteAction): void;
|
|
108
|
+
/** All registered actions for a zone, sorted by `order` (lower first). */
|
|
109
|
+
getActions(zone: AparteActionZone): AparteAction[];
|
|
110
|
+
/** Remove a custom action by id (from every zone); notifies mounted elements if it existed. */
|
|
111
|
+
unregisterAction(id: string): void;
|
|
112
|
+
/**
|
|
113
|
+
* Show or hide a composer action button by id.
|
|
114
|
+
* Triggers a config update so all mounted composer elements react immediately.
|
|
115
|
+
*/
|
|
116
|
+
setActionHidden(id: string, hidden: boolean): void;
|
|
117
|
+
/**
|
|
118
|
+
* Configure which action buttons appear in message bubbles.
|
|
119
|
+
* Unset keys keep their defaults (copy=true, retry=true, edit=true, feedback=false).
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* AparteConfig.setBubbleActions({ feedback: true }) // enable feedback, keep rest
|
|
123
|
+
* AparteConfig.setBubbleActions({ retry: false }) // disable retry only
|
|
124
|
+
* AparteConfig.setBubbleActions({ copy: false, retry: false, edit: false }) // hide all
|
|
125
|
+
* // Explicit per-role ordered sets (replace the flag defaults for that role):
|
|
126
|
+
* AparteConfig.setBubbleActions({ user: ['edit', 'copy'], assistant: ['copy', 'thumbUp', 'thumbDown', 'retry'] })
|
|
127
|
+
*/
|
|
128
|
+
setBubbleActions(config: AparteBubbleActionsConfig): void;
|
|
129
|
+
/** Returns the resolved bubble actions config (flag defaults applied; per-role sets passed through). */
|
|
130
|
+
getBubbleActions(): {
|
|
131
|
+
copy: boolean;
|
|
132
|
+
retry: boolean;
|
|
133
|
+
edit: boolean;
|
|
134
|
+
feedback: boolean;
|
|
135
|
+
user?: AparteBubbleActionName[];
|
|
136
|
+
assistant?: AparteBubbleActionName[];
|
|
137
|
+
};
|
|
138
|
+
/**
|
|
139
|
+
* Set a custom Markdown renderer (e.g., marked, maritime-it)
|
|
140
|
+
*/
|
|
141
|
+
setMarkdownProvider(fn: AparteMarkdownProvider): void;
|
|
142
|
+
/**
|
|
143
|
+
* Set an incremental (streaming) Markdown renderer provider. Optional —
|
|
144
|
+
* when set, the chat bubble uses it to render the assistant message
|
|
145
|
+
* token-by-token DURING streaming (incremental parse + DOM append, O(n)),
|
|
146
|
+
* instead of re-parsing the whole string on every token. The one-shot
|
|
147
|
+
* `setMarkdownProvider` is still used for finished / re-rendered messages.
|
|
148
|
+
*/
|
|
149
|
+
setStreamingMarkdownProvider(fn: AparteStreamingMarkdownProvider): void;
|
|
150
|
+
/**
|
|
151
|
+
* Create an incremental Markdown renderer bound to `target`, or `null` when
|
|
152
|
+
* no streaming-markdown provider is registered (the caller then falls back
|
|
153
|
+
* to the one-shot `renderMarkdown`).
|
|
154
|
+
*/
|
|
155
|
+
createStreamingMarkdownRenderer(target: HTMLElement): AparteStreamingMarkdownRenderer | null;
|
|
156
|
+
/**
|
|
157
|
+
* Set a custom Syntax Highlighter (e.g., prism, highlight.js, shiki)
|
|
158
|
+
* Supports both synchronous and asynchronous renderers.
|
|
159
|
+
*/
|
|
160
|
+
setHighlightProvider(fn: AparteHighlightProvider): void;
|
|
161
|
+
/**
|
|
162
|
+
* Whether a syntax-highlight provider is registered. Lets consumers (e.g.
|
|
163
|
+
* the bubble) skip the highlight pass — and avoid replacing already-rendered
|
|
164
|
+
* code blocks with the plain fallback — when no highlighter is installed.
|
|
165
|
+
*/
|
|
166
|
+
hasHighlightProvider(): boolean;
|
|
167
|
+
/**
|
|
168
|
+
* Replace or disable the HTML sanitizer applied to markdown/highlight
|
|
169
|
+
* provider output before it is injected into the DOM. Defaults to a built-in
|
|
170
|
+
* zero-dependency allowlist sanitizer.
|
|
171
|
+
*
|
|
172
|
+
* @param sanitizer A sanitizer function (e.g. a DOMPurify wrapper) for
|
|
173
|
+
* hardened coverage, or `null` to DISABLE sanitization. Disabling exposes
|
|
174
|
+
* you to XSS from LLM-authored content — only do so for content you fully
|
|
175
|
+
* trust and have already sanitized upstream.
|
|
176
|
+
* @example AparteConfig.setHtmlSanitizer((html) => DOMPurify.sanitize(html));
|
|
177
|
+
*/
|
|
178
|
+
setHtmlSanitizer(sanitizer: AparteSanitizer | null): void;
|
|
179
|
+
/**
|
|
180
|
+
* Run the active sanitizer over provider-produced HTML. Public so a
|
|
181
|
+
* streaming-markdown provider (which appends DOM directly, bypassing
|
|
182
|
+
* `renderMarkdown`) can apply the same policy. Returns the input unchanged
|
|
183
|
+
* only when sanitization was disabled via `setHtmlSanitizer(null)`.
|
|
184
|
+
*/
|
|
185
|
+
sanitizeHtml(html: string): string;
|
|
186
|
+
/**
|
|
187
|
+
* Set the system prompt template. Supports `{{key}}` placeholders resolved via setSystemPromptVarsProvider.
|
|
188
|
+
* Pass undefined to clear.
|
|
189
|
+
*/
|
|
190
|
+
setSystemPrompt(template: string | undefined): void;
|
|
191
|
+
/** Get the raw system prompt template (with unresolved placeholders). */
|
|
192
|
+
getSystemPromptTemplate(): string | undefined;
|
|
193
|
+
/**
|
|
194
|
+
* Register a function that returns a map of variable name → value.
|
|
195
|
+
* Called at request time to resolve `{{key}}` placeholders in the system prompt.
|
|
196
|
+
* Example: () => ({ 'settings.lang': 'French' })
|
|
197
|
+
*/
|
|
198
|
+
setSystemPromptVarsProvider(fn: AparteSystemPromptVarsProvider): void;
|
|
199
|
+
/**
|
|
200
|
+
* Resolve the system prompt template by substituting all `{{key}}` placeholders.
|
|
201
|
+
* Returns null if no template is set or the template is empty after trimming.
|
|
202
|
+
*/
|
|
203
|
+
resolveSystemPrompt(): string | null;
|
|
204
|
+
/**
|
|
205
|
+
* Set a custom Skeleton generator for loading states
|
|
206
|
+
* @param provider Object implementing AparteSkeletonProvider interface
|
|
207
|
+
*/
|
|
208
|
+
setSkeletonProvider(provider: AparteSkeletonProvider): void;
|
|
209
|
+
/**
|
|
210
|
+
* Set a custom Icon provider (e.g., Lucide, FontAwesome, Material)
|
|
211
|
+
* @param provider Object implementing AparteIconProvider interface
|
|
212
|
+
*/
|
|
213
|
+
setIconProvider(provider: AparteIconProvider): void;
|
|
214
|
+
/**
|
|
215
|
+
* Register an artifact preview builder (app-level). When set, the artifact
|
|
216
|
+
* renderer uses it to build the preview iframe `srcdoc`; when unset, core's
|
|
217
|
+
* CDN-free fallback is used. This is how the product opts into a
|
|
218
|
+
* React/Babel/Tailwind live preview without leaking those into core.
|
|
219
|
+
*/
|
|
220
|
+
setArtifactPreviewBuilder(builder: AparteArtifactPreviewBuilder): void;
|
|
221
|
+
/** The registered artifact preview builder, or undefined for the core fallback. */
|
|
222
|
+
getArtifactPreviewBuilder(): AparteArtifactPreviewBuilder | undefined;
|
|
223
|
+
/**
|
|
224
|
+
* Get the current icon provider, or a proxy that falls back to DEFAULT_ICON_FALLBACKS
|
|
225
|
+
*/
|
|
226
|
+
getIconProvider(): AparteIconProvider;
|
|
227
|
+
/**
|
|
228
|
+
* Set a custom avatar renderer. Lets framework consumers (Angular,
|
|
229
|
+
* React, Vue, …) mount live components in place of the default
|
|
230
|
+
* avatar text/image. Cleared by passing `null`.
|
|
231
|
+
*/
|
|
232
|
+
setAvatarProvider(provider: AparteAvatarProvider | null): void;
|
|
233
|
+
/** Returns the registered avatar provider, or null if none. */
|
|
234
|
+
getAvatarProvider(): AparteAvatarProvider | null;
|
|
235
|
+
/**
|
|
236
|
+
* Set a custom typing-indicator renderer. Replaces the inner markup of
|
|
237
|
+
* `<aparte-chat-status>` (avatar + animated dots + text) while the element keeps
|
|
238
|
+
* owning show/hide. Return a string or an HTMLElement. Cleared by passing
|
|
239
|
+
* `null`. Notifies mounted components so a live skin switch re-renders.
|
|
240
|
+
*/
|
|
241
|
+
setStatusRenderer(renderer: AparteStatusRenderer | null): void;
|
|
242
|
+
/** Returns the registered status renderer, or null if none. */
|
|
243
|
+
getStatusRenderer(): AparteStatusRenderer | null;
|
|
244
|
+
/**
|
|
245
|
+
* Set a custom error renderer. Drives the content of error bubbles (the
|
|
246
|
+
* built-in `error` segment) — return a string or an HTMLElement, e.g. a
|
|
247
|
+
* friendly message with a retry button. The bubble also carries `data-error`
|
|
248
|
+
* on its `.aparte-message` while errored, for CSS theming. Cleared with `null`.
|
|
249
|
+
* Notifies mounted components so a live change re-renders.
|
|
250
|
+
*/
|
|
251
|
+
setErrorRenderer(renderer: AparteErrorRenderer | null): void;
|
|
252
|
+
/** Returns the registered error renderer, or null if none. */
|
|
253
|
+
getErrorRenderer(): AparteErrorRenderer | null;
|
|
254
|
+
/**
|
|
255
|
+
* Set a custom attachment renderer. Replaces the chip rendered for each
|
|
256
|
+
* attachment on a user message (default: image thumbnail / file chip) — return
|
|
257
|
+
* a string or an HTMLElement, e.g. a PDF preview. You own the interactions for
|
|
258
|
+
* custom output (see {@link AparteAttachmentRenderer}). Cleared with `null`.
|
|
259
|
+
* Notifies mounted components so a live change re-renders.
|
|
260
|
+
*/
|
|
261
|
+
setAttachmentRenderer(renderer: AparteAttachmentRenderer | null): void;
|
|
262
|
+
/** Returns the registered attachment renderer, or null if none. */
|
|
263
|
+
getAttachmentRenderer(): AparteAttachmentRenderer | null;
|
|
264
|
+
/**
|
|
265
|
+
* Set a custom sibling (branch) position indicator. Replaces the `‹ N / M ›`
|
|
266
|
+
* counter between the prev/next arrows — e.g. dots. Return a string or an
|
|
267
|
+
* HTMLElement (see {@link AparteSiblingNavRenderer}); the arrows keep their
|
|
268
|
+
* behavior. Cleared with `null`. Notifies mounted components.
|
|
269
|
+
*/
|
|
270
|
+
setSiblingNavRenderer(renderer: AparteSiblingNavRenderer | null): void;
|
|
271
|
+
/** Returns the registered sibling-nav renderer, or null if none. */
|
|
272
|
+
getSiblingNavRenderer(): AparteSiblingNavRenderer | null;
|
|
273
|
+
/**
|
|
274
|
+
* Set a custom bubble shell renderer (advanced) — replaces the structural
|
|
275
|
+
* skeleton of `<aparte-chat-bubble>` while keeping its behavior. The shell must
|
|
276
|
+
* honor the class-hook contract (root `.aparte-message`, region hooks) — see
|
|
277
|
+
* {@link AparteBubbleShellRenderer}. For a fully custom element use `renderBubble`
|
|
278
|
+
* (wrapper) instead. Cleared with `null`. Notifies mounted components.
|
|
279
|
+
*/
|
|
280
|
+
setBubbleShellRenderer(renderer: AparteBubbleShellRenderer | null): void;
|
|
281
|
+
/** Returns the registered bubble-shell renderer, or null if none. */
|
|
282
|
+
getBubbleShellRenderer(): AparteBubbleShellRenderer | null;
|
|
283
|
+
/**
|
|
284
|
+
* Set the current locale
|
|
285
|
+
* @param locale AparteLocale object defining all strings
|
|
286
|
+
*/
|
|
287
|
+
setLocale(locale: AparteLocale): void;
|
|
288
|
+
/**
|
|
289
|
+
* Get the current locale
|
|
290
|
+
*/
|
|
291
|
+
getLocale(): AparteLocale;
|
|
292
|
+
/**
|
|
293
|
+
* Extend the current locale with partial translations.
|
|
294
|
+
* Useful for plugins to register their own strings.
|
|
295
|
+
* @param translations Partial locale object to merge
|
|
296
|
+
*/
|
|
297
|
+
extendLocale(translations: Partial<AparteLocale>): void;
|
|
298
|
+
/**
|
|
299
|
+
* Get icon HTML string by name
|
|
300
|
+
* Falls back to textual representation if no provider is set
|
|
301
|
+
*/
|
|
302
|
+
getIcon(name: AparteIconName): string;
|
|
303
|
+
/**
|
|
304
|
+
* Set a custom Key provider (e.g., AparteVault override)
|
|
305
|
+
*/
|
|
306
|
+
setKeyProvider(provider: AparteKeyProvider): void;
|
|
307
|
+
/**
|
|
308
|
+
* Get API key for a provider
|
|
309
|
+
*/
|
|
310
|
+
getKey(providerId: string): Promise<string | undefined>;
|
|
311
|
+
/**
|
|
312
|
+
* Refresh models for a specific provider
|
|
313
|
+
* Orchestrates: Key Retrieval -> Fetch -> Return
|
|
314
|
+
* This keeps UI components unaware of keys.
|
|
315
|
+
*/
|
|
316
|
+
refreshProviderModels(providerId: string): Promise<AparteAIModel[]>;
|
|
317
|
+
/**
|
|
318
|
+
* Register one or more AI providers (e.g., OpenRouter, Gemini, Anthropic)
|
|
319
|
+
* @param providers AparteAIProvider implementations
|
|
320
|
+
* @example
|
|
321
|
+
* AparteConfig.registerAIProvider(OpenRouterProvider);
|
|
322
|
+
* AparteConfig.registerAIProvider(GeminiProvider, AnthropicProvider);
|
|
323
|
+
*/
|
|
324
|
+
registerAIProvider(...providers: AparteAIProvider[]): void;
|
|
325
|
+
/**
|
|
326
|
+
* Unregister an AI provider
|
|
327
|
+
*/
|
|
328
|
+
unregisterAIProvider(id: string): void;
|
|
329
|
+
/**
|
|
330
|
+
* Get all registered AI providers
|
|
331
|
+
* Optionally filtered by enabled providers in config
|
|
332
|
+
*/
|
|
333
|
+
getAIProviders(): AparteAIProvider[];
|
|
334
|
+
/**
|
|
335
|
+
* Get a specific AI provider by ID
|
|
336
|
+
*/
|
|
337
|
+
getAIProvider(id: string): AparteAIProvider | undefined;
|
|
338
|
+
/**
|
|
339
|
+
* Set the transport that decides where chat requests go and how auth is
|
|
340
|
+
* handled. Defaults to {@link DirectTransport} (browser-direct — BYOK/local).
|
|
341
|
+
* Use a `BackendTransport` to keep API keys server-side (recommended for
|
|
342
|
+
* production).
|
|
343
|
+
*/
|
|
344
|
+
setTransport(transport: AparteTransport): void;
|
|
345
|
+
/** Get the active transport (DirectTransport by default). */
|
|
346
|
+
getTransport(): AparteTransport;
|
|
347
|
+
/**
|
|
348
|
+
* Register a model preference provider for agnostic persistence.
|
|
349
|
+
* The host app decides how/where to store the selected provider & model.
|
|
350
|
+
* @example
|
|
351
|
+
* AparteConfig.setModelPreferenceProvider({
|
|
352
|
+
* save: (p, m) => localStorage.setItem('model', JSON.stringify({p, m})),
|
|
353
|
+
* load: () => JSON.parse(localStorage.getItem('model') ?? 'null')
|
|
354
|
+
* });
|
|
355
|
+
*/
|
|
356
|
+
setModelPreferenceProvider(provider: AparteModelPreferenceProvider): void;
|
|
357
|
+
/**
|
|
358
|
+
* Restore previously saved model preference via the registered provider.
|
|
359
|
+
* Should be called once at app startup, before any component mounts.
|
|
360
|
+
* No-op if no provider is registered or nothing was saved.
|
|
361
|
+
*/
|
|
362
|
+
restoreModelPreference(): AparteModelPreference | null;
|
|
363
|
+
/**
|
|
364
|
+
* Set model selection configuration
|
|
365
|
+
*/
|
|
366
|
+
setModelConfig(config: AparteModelConfig): void;
|
|
367
|
+
/**
|
|
368
|
+
* Subscribe to configuration changes
|
|
369
|
+
* @returns Unsubscribe function
|
|
370
|
+
*/
|
|
371
|
+
subscribe(callback: () => void): () => void;
|
|
372
|
+
private _notify;
|
|
373
|
+
/**
|
|
374
|
+
* Get current model configuration
|
|
375
|
+
*/
|
|
376
|
+
getModelConfig(): AparteModelConfig;
|
|
377
|
+
/**
|
|
378
|
+
* True when the model config has BOTH a provider and a model selected — i.e.
|
|
379
|
+
* the chat can actually send. Used by the composer's `require-model` gate.
|
|
380
|
+
*/
|
|
381
|
+
hasSelectedModel(): boolean;
|
|
382
|
+
/**
|
|
383
|
+
* Opt-in UX: when enabled, `<aparte-composer>` blocks sending and greys out
|
|
384
|
+
* until {@link hasSelectedModel} is true (e.g. while the model selector is
|
|
385
|
+
* still fetching its list). Off by default so single-model / backend setups
|
|
386
|
+
* that never select a model are unaffected.
|
|
387
|
+
*/
|
|
388
|
+
setRequireModelSelection(required: boolean): void;
|
|
389
|
+
/** Whether the composer should gate on model selection (see {@link setRequireModelSelection}). */
|
|
390
|
+
getRequireModelSelection(): boolean;
|
|
391
|
+
/**
|
|
392
|
+
* Get the currently selected model object, if available synchronously.
|
|
393
|
+
* Returns undefined if no provider/model is selected, or if the provider's
|
|
394
|
+
* models are only available asynchronously (fetchModels).
|
|
395
|
+
*/
|
|
396
|
+
getCurrentModel(): AparteAIModel | undefined;
|
|
397
|
+
/**
|
|
398
|
+
* Get translated string by key
|
|
399
|
+
*/
|
|
400
|
+
t(key: keyof AparteLocale): string;
|
|
401
|
+
/**
|
|
402
|
+
* Render Markdown to HTML
|
|
403
|
+
* Fallback: Escapes HTML and converts newlines to <br>
|
|
404
|
+
*/
|
|
405
|
+
renderMarkdown(raw: string): string;
|
|
406
|
+
/**
|
|
407
|
+
* Highlight code block
|
|
408
|
+
* Fallback: Returns raw code wrapped in <pre><code>
|
|
409
|
+
* Supports Promise if provider is async/streaming
|
|
410
|
+
*/
|
|
411
|
+
highlightCode(code: string, lang: string): Promise<string>;
|
|
412
|
+
/**
|
|
413
|
+
* Get HTML for a skeleton loader
|
|
414
|
+
* Fallback: Simple CSS-animated box
|
|
415
|
+
*/
|
|
416
|
+
getSkeleton(type: AparteSkeletonType): string;
|
|
417
|
+
/**
|
|
418
|
+
* Register a tool and its handler together.
|
|
419
|
+
* The handler is called when the AI invokes the tool during streaming.
|
|
420
|
+
* @example
|
|
421
|
+
* AparteConfig.registerTool(askQuestionTool, askQuestionHandler);
|
|
422
|
+
*/
|
|
423
|
+
registerTool(tool: AparteTool, handler: AparteToolHandler): void;
|
|
424
|
+
/** Unregister a tool by name */
|
|
425
|
+
unregisterTool(name: string): void;
|
|
426
|
+
/** Get all registered tool definitions (to pass in AparteChatRequest) */
|
|
427
|
+
getTools(): AparteTool[];
|
|
428
|
+
/** Get the handler for a tool by name */
|
|
429
|
+
getToolHandler(name: string): AparteToolHandler | undefined;
|
|
430
|
+
/**
|
|
431
|
+
* Register a per-tool segment renderer.
|
|
432
|
+
* Controls what appears in the chat bubble when the AI calls this tool.
|
|
433
|
+
* Use this instead of the generic `tool_call` segment renderer for tool-specific UI.
|
|
434
|
+
*
|
|
435
|
+
* @example
|
|
436
|
+
* // Hide the segment entirely (UI-only tool like ask_question)
|
|
437
|
+
* AparteConfig.registerToolRenderer('ask_question', { render: () => '' });
|
|
438
|
+
*
|
|
439
|
+
* @example
|
|
440
|
+
* // Custom pill for a web-search tool
|
|
441
|
+
* AparteConfig.registerToolRenderer('web_search', { render: (seg) => `<div class="tool-pill">Searching...</div>` });
|
|
442
|
+
*/
|
|
443
|
+
registerToolRenderer(toolName: string, renderer: AparteToolRenderer): void;
|
|
444
|
+
/** Unregister a per-tool renderer */
|
|
445
|
+
unregisterToolRenderer(toolName: string): void;
|
|
446
|
+
/** Get the renderer for a specific tool name. Returns undefined if none registered. */
|
|
447
|
+
getToolRenderer(toolName: string): AparteToolRenderer | undefined;
|
|
448
|
+
/**
|
|
449
|
+
* Register a ConversationManager so any UI controller can persist & load
|
|
450
|
+
* conversations without coupling to a framework wrapper.
|
|
451
|
+
*/
|
|
452
|
+
setConversationManager(manager: ConversationManager): void;
|
|
453
|
+
/** Returns the registered ConversationManager, or undefined if none. */
|
|
454
|
+
getConversationManager(): ConversationManager | undefined;
|
|
455
|
+
/**
|
|
456
|
+
* Register the presenter that renders typed input requests (a choice, a
|
|
457
|
+
* confirmation, a text field, a form) and resolves with the user's answer.
|
|
458
|
+
* The `<aparte-elicitation>` Web Component registers itself here; an app can
|
|
459
|
+
* override with its own framework-native presenter. Pass `null` to clear.
|
|
460
|
+
*/
|
|
461
|
+
setElicitationPresenter(presenter: AparteElicitationPresenter | null): void;
|
|
462
|
+
/** The registered elicitation presenter, or undefined if none. */
|
|
463
|
+
getElicitationPresenter(): AparteElicitationPresenter | undefined;
|
|
464
|
+
/**
|
|
465
|
+
* Ask the user for typed input mid-run and await their response. This is the
|
|
466
|
+
* generic primitive behind `ask_question` and tool approval — the KIND of
|
|
467
|
+
* question is the schema, not a bespoke tool. Resolves `accept` with the
|
|
468
|
+
* value, `decline` when the user declines, or `cancel` when the turn is
|
|
469
|
+
* cancelled. With no presenter registered it resolves `cancel` (nothing can
|
|
470
|
+
* present it) rather than hanging.
|
|
471
|
+
*/
|
|
472
|
+
requestUserInput(request: AparteElicitationRequest): Promise<AparteElicitationResult>;
|
|
473
|
+
/**
|
|
474
|
+
* Reset ALL configuration back to defaults — providers, registries, model
|
|
475
|
+
* selection and bubble actions. Previously left `_aiProviders` / `_tools` /
|
|
476
|
+
* `_toolRenderers` / `_modelConfig` behind, which leaked across SPA
|
|
477
|
+
* navigations (registries only ever grew). Now a full reset.
|
|
478
|
+
*/
|
|
479
|
+
reset(): void;
|
|
480
|
+
private _defaultMarkdownRenderer;
|
|
481
|
+
private _defaultHighlightRenderer;
|
|
482
|
+
private _defaultSkeletonRenderer;
|
|
483
|
+
private _escapeHtml;
|
|
484
|
+
}
|
|
485
|
+
/**
|
|
486
|
+
* Global configuration singleton for Aparte.
|
|
487
|
+
* Use this to register providers and configure behavior.
|
|
488
|
+
*/
|
|
489
|
+
export declare const AparteConfig: AparteConfigClass;
|
|
490
|
+
//# sourceMappingURL=aparte-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aparte-config.d.ts","sourceRoot":"","sources":["../../src/config/aparte-config.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAA0B,MAAM,oBAAoB,CAAC;AAChG,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAkB,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACpF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,KAAK,EAAE,mBAAmB,EAAE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IAIlC,yEAAyE;IACzE,QAAQ,IAAI,UAAU,EAAE;IAIxB,yCAAyC;IACzC,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS;IAI3D;;;;;;;;;;;;OAYG;IACH,oBAAoB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,kBAAkB,GAAG,IAAI;IAI1E,qCAAqC;IACrC,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAI9C,uFAAuF;IACvF,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS;IAQjE;;;OAGG;IACH,sBAAsB,CAAC,OAAO,EAAE,mBAAmB,GAAG,IAAI;IAI1D,wEAAwE;IACxE,sBAAsB,IAAI,mBAAmB,GAAG,SAAS;IAQzD;;;;;OAKG;IACH,uBAAuB,CAAC,SAAS,EAAE,0BAA0B,GAAG,IAAI,GAAG,IAAI;IAI3E,kEAAkE;IAClE,uBAAuB,IAAI,0BAA0B,GAAG,SAAS;IAIjE;;;;;;;OAOG;IACH,gBAAgB,CAAC,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAKrF;;;;;OAKG;IACH,KAAK,IAAI,IAAI;IAoCb,OAAO,CAAC,wBAAwB;IAOhC,OAAO,CAAC,yBAAyB;IAIjC,OAAO,CAAC,wBAAwB;IAchC,OAAO,CAAC,WAAW;CAQtB;AAmBD;;;GAGG;AACH,eAAO,MAAM,YAAY,mBAAoB,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { AparteAttachment } from '../types/models.js';
|
|
2
|
+
/**
|
|
3
|
+
* Attachment Renderer
|
|
4
|
+
*
|
|
5
|
+
* Replace the chip rendered for each attachment on a user message — the default
|
|
6
|
+
* is an image thumbnail or a file chip (extension + name). Return an HTML
|
|
7
|
+
* **string** or a ready **HTMLElement** (charter §6 render hooks:
|
|
8
|
+
* `string | HTMLElement`), e.g. a PDF page preview, an audio player, or a richer
|
|
9
|
+
* card. Called once per attachment.
|
|
10
|
+
*
|
|
11
|
+
* When you provide a renderer you own the markup AND the interactions: the
|
|
12
|
+
* built-in image-tile click that dispatches `aparte-attachment-preview` is NOT
|
|
13
|
+
* wired for custom output — dispatch it yourself (bubbles, composed) or handle
|
|
14
|
+
* clicks your own way.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* AparteConfig.setAttachmentRenderer((att) => {
|
|
18
|
+
* if (att.type === 'application/pdf') {
|
|
19
|
+
* const el = document.createElement('div');
|
|
20
|
+
* el.className = 'my-pdf-chip';
|
|
21
|
+
* el.textContent = att.name;
|
|
22
|
+
* return el;
|
|
23
|
+
* }
|
|
24
|
+
* return `<div class="my-file">${att.name}</div>`;
|
|
25
|
+
* });
|
|
26
|
+
*/
|
|
27
|
+
export type AparteAttachmentRenderer = (attachment: AparteAttachment) => string | HTMLElement;
|
|
28
|
+
//# sourceMappingURL=attachment-renderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment-renderer.d.ts","sourceRoot":"","sources":["../../src/config/attachment-renderer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3D;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,MAAM,wBAAwB,GAAG,CAAC,UAAU,EAAE,gBAAgB,KAAK,MAAM,GAAG,WAAW,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Avatar Provider Interface
|
|
3
|
+
*
|
|
4
|
+
* Defines the contract for plugging custom avatar rendering into chat
|
|
5
|
+
* messages. Unlike the icon provider (which returns HTML strings), the
|
|
6
|
+
* avatar provider receives the live host element and fills it with
|
|
7
|
+
* whatever DOM the consumer wants — including framework components
|
|
8
|
+
* mounted via createComponent (Angular), createRoot (React), etc.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* AparteConfig.setAvatarProvider({
|
|
12
|
+
* render: (role, host) => {
|
|
13
|
+
* if (role === 'assistant') {
|
|
14
|
+
* const ref = createComponent(MascotComponent, { hostElement: host });
|
|
15
|
+
* ref.setInput('variant', 'classic');
|
|
16
|
+
* return () => ref.destroy();
|
|
17
|
+
* }
|
|
18
|
+
* host.textContent = 'You';
|
|
19
|
+
* },
|
|
20
|
+
* });
|
|
21
|
+
*/
|
|
22
|
+
export interface AparteAvatarProvider {
|
|
23
|
+
/**
|
|
24
|
+
* Fill the avatar host element with custom DOM.
|
|
25
|
+
*
|
|
26
|
+
* @param role - The message role this avatar represents.
|
|
27
|
+
* @param host - The `.aparte-avatar` element. Already styled (size, radius)
|
|
28
|
+
* via CSS variables. The provider owns its inner content.
|
|
29
|
+
* @returns - Optional cleanup function. Called when the message is
|
|
30
|
+
* detached or re-rendered, so live components can be
|
|
31
|
+
* disposed cleanly.
|
|
32
|
+
*/
|
|
33
|
+
render(role: 'user' | 'assistant', host: HTMLElement): void | (() => void);
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=avatar-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"avatar-provider.d.ts","sourceRoot":"","sources":["../../src/config/avatar-provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,WAAW,oBAAoB;IACjC;;;;;;;;;OASG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,EAAE,IAAI,EAAE,WAAW,GAAG,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC;CAC9E"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bubble-Shell Renderer (advanced)
|
|
3
|
+
*
|
|
4
|
+
* Replace the *structural skeleton* of `<aparte-chat-bubble>` — the markup the
|
|
5
|
+
* bubble renders once and then populates — while keeping all of its behavior
|
|
6
|
+
* (segments, streaming, action bar, avatar, branch picker). This is the
|
|
7
|
+
* whole-structure override that {@link https://…} `renderBubble` (wrapper-level,
|
|
8
|
+
* replaces the element entirely) is not: here the native bubble stays in charge.
|
|
9
|
+
*
|
|
10
|
+
* Return an HTML **string** or a ready **HTMLElement** (charter §6:
|
|
11
|
+
* `string | HTMLElement`). Because the bubble queries known class hooks after
|
|
12
|
+
* rendering the shell, your shell MUST honor this contract:
|
|
13
|
+
*
|
|
14
|
+
* - Root element **must** be `.aparte-message` (it carries `data-role` and receives
|
|
15
|
+
* `data-streaming` / `data-error`; the styles target it).
|
|
16
|
+
* - Include the region hooks you want the bubble to populate. Any you omit simply
|
|
17
|
+
* stay empty (every lookup is null-guarded — graceful degradation):
|
|
18
|
+
* - `.aparte-avatar` — filled by the avatar provider / initial
|
|
19
|
+
* - `.aparte-name` — the display name (you set it from `ctx.name`)
|
|
20
|
+
* - `.aparte-timestamp` — the formatted time
|
|
21
|
+
* - `.aparte-attachments` — user-message attachment chips
|
|
22
|
+
* - `.aparte-segments` — streamed/structured segments
|
|
23
|
+
* - `.aparte-content` — simple markdown content
|
|
24
|
+
* - `.aparte-action-bar` — copy/retry/edit/… + custom actions
|
|
25
|
+
* - `.aparte-branch-picker` — with `.aparte-branch-prev` / `.aparte-branch-label` /
|
|
26
|
+
* `.aparte-branch-next` for sibling navigation
|
|
27
|
+
*
|
|
28
|
+
* Prefer `renderBubble` (wrapper) when you want a fully custom element; use this
|
|
29
|
+
* when you want to keep the native bubble's machinery but reshape its layout.
|
|
30
|
+
*
|
|
31
|
+
* @param ctx.role - 'user' | 'assistant'.
|
|
32
|
+
* @param ctx.name - Display name for the header.
|
|
33
|
+
* @param ctx.avatarInitial - Default one-letter avatar fallback.
|
|
34
|
+
* @returns HTML string or a DOM element whose root is `.aparte-message`.
|
|
35
|
+
*/
|
|
36
|
+
export type AparteBubbleShellRenderer = (ctx: {
|
|
37
|
+
role: 'user' | 'assistant';
|
|
38
|
+
name: string;
|
|
39
|
+
avatarInitial: string;
|
|
40
|
+
}) => string | HTMLElement;
|
|
41
|
+
//# sourceMappingURL=bubble-shell-renderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bubble-shell-renderer.d.ts","sourceRoot":"","sources":["../../src/config/bubble-shell-renderer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,MAAM,yBAAyB,GAAG,CAAC,GAAG,EAAE;IAC1C,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,MAAM,CAAC;CACzB,KAAK,MAAM,GAAG,WAAW,CAAC"}
|