@genesislcap/ai-assistant 14.403.0-ai-assistant.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api-extractor.json +4 -0
- package/dist/ai-assistant.api.json +4028 -0
- package/dist/ai-assistant.d.ts +396 -0
- package/dist/dts/channel/ai-activity-channel.d.ts +32 -0
- package/dist/dts/channel/ai-activity-channel.d.ts.map +1 -0
- package/dist/dts/components/activity-halo/activity-halo.d.ts +31 -0
- package/dist/dts/components/activity-halo/activity-halo.d.ts.map +1 -0
- package/dist/dts/components/chat-bubble/chat-bubble.d.ts +52 -0
- package/dist/dts/components/chat-bubble/chat-bubble.d.ts.map +1 -0
- package/dist/dts/components/chat-bubble/chat-bubble.styles.d.ts +2 -0
- package/dist/dts/components/chat-bubble/chat-bubble.styles.d.ts.map +1 -0
- package/dist/dts/components/chat-bubble/chat-bubble.template.d.ts +4 -0
- package/dist/dts/components/chat-bubble/chat-bubble.template.d.ts.map +1 -0
- package/dist/dts/components/chat-bubble/index.d.ts +2 -0
- package/dist/dts/components/chat-bubble/index.d.ts.map +1 -0
- package/dist/dts/components/chat-driver/chat-driver.d.ts +49 -0
- package/dist/dts/components/chat-driver/chat-driver.d.ts.map +1 -0
- package/dist/dts/components/chat-driver/index.d.ts +2 -0
- package/dist/dts/components/chat-driver/index.d.ts.map +1 -0
- package/dist/dts/components/chat-interaction-wrapper/chat-interaction-wrapper.d.ts +19 -0
- package/dist/dts/components/chat-interaction-wrapper/chat-interaction-wrapper.d.ts.map +1 -0
- package/dist/dts/components/chat-interaction-wrapper/chat-interaction-wrapper.styles.d.ts +2 -0
- package/dist/dts/components/chat-interaction-wrapper/chat-interaction-wrapper.styles.d.ts.map +1 -0
- package/dist/dts/components/chat-interaction-wrapper/chat-interaction-wrapper.template.d.ts +3 -0
- package/dist/dts/components/chat-interaction-wrapper/chat-interaction-wrapper.template.d.ts.map +1 -0
- package/dist/dts/components/chat-interaction-wrapper/index.d.ts +4 -0
- package/dist/dts/components/chat-interaction-wrapper/index.d.ts.map +1 -0
- package/dist/dts/components/chat-markdown/chat-markdown.d.ts +6 -0
- package/dist/dts/components/chat-markdown/chat-markdown.d.ts.map +1 -0
- package/dist/dts/components/chat-markdown/index.d.ts +2 -0
- package/dist/dts/components/chat-markdown/index.d.ts.map +1 -0
- package/dist/dts/components/halo-overlay.d.ts +25 -0
- package/dist/dts/components/halo-overlay.d.ts.map +1 -0
- package/dist/dts/config/config.d.ts +51 -0
- package/dist/dts/config/config.d.ts.map +1 -0
- package/dist/dts/config/configure.d.ts +1 -0
- package/dist/dts/config/configure.d.ts.map +1 -0
- package/dist/dts/config/index.d.ts +2 -0
- package/dist/dts/config/index.d.ts.map +1 -0
- package/dist/dts/index.d.ts +10 -0
- package/dist/dts/index.d.ts.map +1 -0
- package/dist/dts/main/index.d.ts +5 -0
- package/dist/dts/main/index.d.ts.map +1 -0
- package/dist/dts/main/main.d.ts +103 -0
- package/dist/dts/main/main.d.ts.map +1 -0
- package/dist/dts/main/main.styles.d.ts +2 -0
- package/dist/dts/main/main.styles.d.ts.map +1 -0
- package/dist/dts/main/main.template.d.ts +4 -0
- package/dist/dts/main/main.template.d.ts.map +1 -0
- package/dist/dts/main/main.types.d.ts +54 -0
- package/dist/dts/main/main.types.d.ts.map +1 -0
- package/dist/dts/styles/index.d.ts +2 -0
- package/dist/dts/styles/index.d.ts.map +1 -0
- package/dist/dts/styles/styles.d.ts +5 -0
- package/dist/dts/styles/styles.d.ts.map +1 -0
- package/dist/dts/tags/index.d.ts +1 -0
- package/dist/dts/tags/index.d.ts.map +1 -0
- package/dist/dts/types/ai-chat-widget.d.ts +12 -0
- package/dist/dts/types/ai-chat-widget.d.ts.map +1 -0
- package/dist/dts/utils/index.d.ts +2 -0
- package/dist/dts/utils/index.d.ts.map +1 -0
- package/dist/dts/utils/logger.d.ts +2 -0
- package/dist/dts/utils/logger.d.ts.map +1 -0
- package/dist/esm/channel/ai-activity-channel.js +2 -0
- package/dist/esm/components/activity-halo/activity-halo.js +119 -0
- package/dist/esm/components/chat-bubble/chat-bubble.js +381 -0
- package/dist/esm/components/chat-bubble/chat-bubble.styles.js +193 -0
- package/dist/esm/components/chat-bubble/chat-bubble.template.js +50 -0
- package/dist/esm/components/chat-bubble/index.js +1 -0
- package/dist/esm/components/chat-driver/chat-driver.js +209 -0
- package/dist/esm/components/chat-driver/index.js +1 -0
- package/dist/esm/components/chat-interaction-wrapper/chat-interaction-wrapper.js +90 -0
- package/dist/esm/components/chat-interaction-wrapper/chat-interaction-wrapper.styles.js +6 -0
- package/dist/esm/components/chat-interaction-wrapper/chat-interaction-wrapper.template.js +4 -0
- package/dist/esm/components/chat-interaction-wrapper/index.js +3 -0
- package/dist/esm/components/chat-markdown/chat-markdown.js +95 -0
- package/dist/esm/components/chat-markdown/index.js +1 -0
- package/dist/esm/components/halo-overlay.js +118 -0
- package/dist/esm/config/config.js +16 -0
- package/dist/esm/config/configure.js +0 -0
- package/dist/esm/config/index.js +1 -0
- package/dist/esm/index.js +8 -0
- package/dist/esm/main/index.js +4 -0
- package/dist/esm/main/main.js +491 -0
- package/dist/esm/main/main.styles.js +356 -0
- package/dist/esm/main/main.template.js +272 -0
- package/dist/esm/main/main.types.js +22 -0
- package/dist/esm/styles/index.js +1 -0
- package/dist/esm/styles/styles.js +237 -0
- package/dist/esm/tags/index.js +0 -0
- package/dist/esm/types/ai-chat-widget.js +1 -0
- package/dist/esm/utils/index.js +1 -0
- package/dist/esm/utils/logger.js +2 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/tsdoc-metadata.json +11 -0
- package/docs/.gitattributes +2 -0
- package/docs/api/ai-assistant.ai_activity_channel_name.md +11 -0
- package/docs/api/ai-assistant.aiactivityevents.md +24 -0
- package/docs/api/ai-assistant.aiactivityhalo.channelname.md +16 -0
- package/docs/api/ai-assistant.aiactivityhalo.connectedcallback.md +18 -0
- package/docs/api/ai-assistant.aiactivityhalo.disconnectedcallback.md +18 -0
- package/docs/api/ai-assistant.aiactivityhalo.haloactive.md +14 -0
- package/docs/api/ai-assistant.aiactivityhalo.md +176 -0
- package/docs/api/ai-assistant.aiactivityhalo.minshowtime.md +16 -0
- package/docs/api/ai-assistant.aiactivityhalo.tools.md +16 -0
- package/docs/api/ai-assistant.aiassistantanimation.md +18 -0
- package/docs/api/ai-assistant.aiassistantanimationdef.label.md +16 -0
- package/docs/api/ai-assistant.aiassistantanimationdef.md +80 -0
- package/docs/api/ai-assistant.aiassistantanimationdef.tooltip.md +16 -0
- package/docs/api/ai-assistant.aiassistantconfig.chatconfig.md +16 -0
- package/docs/api/ai-assistant.aiassistantconfig.debugstatefactory.md +16 -0
- package/docs/api/ai-assistant.aiassistantconfig.headertitle.md +16 -0
- package/docs/api/ai-assistant.aiassistantconfig.md +157 -0
- package/docs/api/ai-assistant.aiassistantconfig.systemprompt.md +16 -0
- package/docs/api/ai-assistant.aiassistantconfig.tooldefinitions.md +16 -0
- package/docs/api/ai-assistant.aiassistantconfig.toolhandlers.md +16 -0
- package/docs/api/ai-assistant.aiassistantserializedstate.enabledanimations.md +14 -0
- package/docs/api/ai-assistant.aiassistantserializedstate.md +118 -0
- package/docs/api/ai-assistant.aiassistantserializedstate.messages.md +14 -0
- package/docs/api/ai-assistant.aiassistantserializedstate.showthinkingsteps.md +14 -0
- package/docs/api/ai-assistant.aiassistantserializedstate.showtoolcalls.md +14 -0
- package/docs/api/ai-assistant.aiassistantstate.md +16 -0
- package/docs/api/ai-assistant.aichatbubble.bubbleleft.md +11 -0
- package/docs/api/ai-assistant.aichatbubble.bubbletop.md +11 -0
- package/docs/api/ai-assistant.aichatbubble.channelname.md +11 -0
- package/docs/api/ai-assistant.aichatbubble.connectedcallback.md +15 -0
- package/docs/api/ai-assistant.aichatbubble.designsystemprefix.md +11 -0
- package/docs/api/ai-assistant.aichatbubble.dialogcontent.md +11 -0
- package/docs/api/ai-assistant.aichatbubble.dialogcontentchanged.md +64 -0
- package/docs/api/ai-assistant.aichatbubble.dialogheight.md +11 -0
- package/docs/api/ai-assistant.aichatbubble.dialogleft.md +11 -0
- package/docs/api/ai-assistant.aichatbubble.dialogopen.md +11 -0
- package/docs/api/ai-assistant.aichatbubble.dialogopenchanged.md +64 -0
- package/docs/api/ai-assistant.aichatbubble.dialogtop.md +11 -0
- package/docs/api/ai-assistant.aichatbubble.dialogwidth.md +11 -0
- package/docs/api/ai-assistant.aichatbubble.disconnectedcallback.md +15 -0
- package/docs/api/ai-assistant.aichatbubble.hovered.md +11 -0
- package/docs/api/ai-assistant.aichatbubble.imagesrc.md +11 -0
- package/docs/api/ai-assistant.aichatbubble.md +396 -0
- package/docs/api/ai-assistant.aichatbubble.onbubblemousedown.md +50 -0
- package/docs/api/ai-assistant.aichatbubble.onclosedialog.md +15 -0
- package/docs/api/ai-assistant.aichatbubble.ondialogheadermousedown.md +53 -0
- package/docs/api/ai-assistant.aichatbubble.onpopout.md +15 -0
- package/docs/api/ai-assistant.aichatbubble.title.md +11 -0
- package/docs/api/ai-assistant.aichatbubble.tooltipstyle.md +11 -0
- package/docs/api/ai-assistant.aichatwidget.data.md +14 -0
- package/docs/api/ai-assistant.aichatwidget.md +80 -0
- package/docs/api/ai-assistant.aichatwidget.resolved.md +16 -0
- package/docs/api/ai-assistant.animation_defs.md +25 -0
- package/docs/api/ai-assistant.chatdriver._constructor_.md +99 -0
- package/docs/api/ai-assistant.chatdriver.gethistory.md +18 -0
- package/docs/api/ai-assistant.chatdriver.isbusy.md +18 -0
- package/docs/api/ai-assistant.chatdriver.loadhistory.md +55 -0
- package/docs/api/ai-assistant.chatdriver.md +158 -0
- package/docs/api/ai-assistant.chatdriver.requestinteraction.md +73 -0
- package/docs/api/ai-assistant.chatdriver.resolveinteraction.md +69 -0
- package/docs/api/ai-assistant.chatdriver.sendmessage.md +69 -0
- package/docs/api/ai-assistant.chathistoryupdatedevent.md +16 -0
- package/docs/api/ai-assistant.defaultaiassistantconfig.md +16 -0
- package/docs/api/ai-assistant.foundationaiassistant.aiprovider.md +14 -0
- package/docs/api/ai-assistant.foundationaiassistant.applystate.md +55 -0
- package/docs/api/ai-assistant.foundationaiassistant.attachmenterrors.md +14 -0
- package/docs/api/ai-assistant.foundationaiassistant.attachments.md +14 -0
- package/docs/api/ai-assistant.foundationaiassistant.channelname.md +14 -0
- package/docs/api/ai-assistant.foundationaiassistant.chatconfig.md +14 -0
- package/docs/api/ai-assistant.foundationaiassistant.connectedcallback.md +18 -0
- package/docs/api/ai-assistant.foundationaiassistant.debugstatefactory.md +14 -0
- package/docs/api/ai-assistant.foundationaiassistant.designsystemprefix.md +14 -0
- package/docs/api/ai-assistant.foundationaiassistant.disconnectedcallback.md +18 -0
- package/docs/api/ai-assistant.foundationaiassistant.downloadhistory.md +18 -0
- package/docs/api/ai-assistant.foundationaiassistant.enabledanimations.md +16 -0
- package/docs/api/ai-assistant.foundationaiassistant.handlefileselect.md +53 -0
- package/docs/api/ai-assistant.foundationaiassistant.handleinteractioncompleted.md +53 -0
- package/docs/api/ai-assistant.foundationaiassistant.handlepopout.md +20 -0
- package/docs/api/ai-assistant.foundationaiassistant.handlesendclick.md +18 -0
- package/docs/api/ai-assistant.foundationaiassistant.hasactivependinginteraction.md +16 -0
- package/docs/api/ai-assistant.foundationaiassistant.headertitle.md +14 -0
- package/docs/api/ai-assistant.foundationaiassistant.imagesrc.md +14 -0
- package/docs/api/ai-assistant.foundationaiassistant.inputvalue.md +14 -0
- package/docs/api/ai-assistant.foundationaiassistant.md +826 -0
- package/docs/api/ai-assistant.foundationaiassistant.messages.md +14 -0
- package/docs/api/ai-assistant.foundationaiassistant.messageschanged.md +18 -0
- package/docs/api/ai-assistant.foundationaiassistant.onchatheadermousedown.md +53 -0
- package/docs/api/ai-assistant.foundationaiassistant.placeholder.md +14 -0
- package/docs/api/ai-assistant.foundationaiassistant.popoutmode.md +16 -0
- package/docs/api/ai-assistant.foundationaiassistant.removeattachment.md +53 -0
- package/docs/api/ai-assistant.foundationaiassistant.removeattachmenterror.md +53 -0
- package/docs/api/ai-assistant.foundationaiassistant.setenabledanimations.md +53 -0
- package/docs/api/ai-assistant.foundationaiassistant.settingsopen.md +16 -0
- package/docs/api/ai-assistant.foundationaiassistant.showhalo.md +16 -0
- package/docs/api/ai-assistant.foundationaiassistant.showhalochanged.md +18 -0
- package/docs/api/ai-assistant.foundationaiassistant.showloadingindicator.md +16 -0
- package/docs/api/ai-assistant.foundationaiassistant.showloadingindicatorchanged.md +18 -0
- package/docs/api/ai-assistant.foundationaiassistant.showthinkingsteps.md +16 -0
- package/docs/api/ai-assistant.foundationaiassistant.showtoolcalls.md +16 -0
- package/docs/api/ai-assistant.foundationaiassistant.state.md +14 -0
- package/docs/api/ai-assistant.foundationaiassistant.statechanged.md +18 -0
- package/docs/api/ai-assistant.foundationaiassistant.systemprompt.md +14 -0
- package/docs/api/ai-assistant.foundationaiassistant.togglesettings.md +18 -0
- package/docs/api/ai-assistant.foundationaiassistant.toggleshowthinkingsteps.md +18 -0
- package/docs/api/ai-assistant.foundationaiassistant.toggleshowtoolcalls.md +18 -0
- package/docs/api/ai-assistant.foundationaiassistant.tooldefinitions.md +14 -0
- package/docs/api/ai-assistant.foundationaiassistant.toolhandlers.md +14 -0
- package/docs/api/ai-assistant.foundationaiassistant.triggerfileinput.md +18 -0
- package/docs/api/ai-assistant.foundationaiassistant.visiblemessages.md +16 -0
- package/docs/api/ai-assistant.foundationaiassistanttemplate.md +50 -0
- package/docs/api/ai-assistant.md +262 -0
- package/docs/api/ai-assistant.popoutmode.md +16 -0
- package/docs/api/index.md +30 -0
- package/docs/api-report.md.api.md +280 -0
- package/license.txt +46 -0
- package/package.json +92 -0
- package/src/channel/ai-activity-channel.ts +30 -0
- package/src/components/activity-halo/activity-halo.ts +113 -0
- package/src/components/chat-bubble/chat-bubble.styles.ts +194 -0
- package/src/components/chat-bubble/chat-bubble.template.ts +63 -0
- package/src/components/chat-bubble/chat-bubble.ts +389 -0
- package/src/components/chat-bubble/index.ts +1 -0
- package/src/components/chat-driver/chat-driver.ts +254 -0
- package/src/components/chat-driver/index.ts +1 -0
- package/src/components/chat-interaction-wrapper/chat-interaction-wrapper.styles.ts +7 -0
- package/src/components/chat-interaction-wrapper/chat-interaction-wrapper.template.ts +6 -0
- package/src/components/chat-interaction-wrapper/chat-interaction-wrapper.ts +89 -0
- package/src/components/chat-interaction-wrapper/index.ts +3 -0
- package/src/components/chat-markdown/chat-markdown.ts +87 -0
- package/src/components/chat-markdown/index.ts +1 -0
- package/src/components/halo-overlay.ts +115 -0
- package/src/config/config.ts +59 -0
- package/src/config/configure.ts +0 -0
- package/src/config/index.ts +1 -0
- package/src/index.ts +9 -0
- package/src/main/index.ts +4 -0
- package/src/main/main.styles.ts +357 -0
- package/src/main/main.template.ts +364 -0
- package/src/main/main.ts +474 -0
- package/src/main/main.types.ts +58 -0
- package/src/styles/index.ts +1 -0
- package/src/styles/styles.ts +238 -0
- package/src/tags/index.ts +0 -0
- package/src/types/ai-chat-widget.ts +11 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/logger.ts +3 -0
- package/temp/api-report.md.api.md +280 -0
- package/tsconfig.json +11 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { InteractionResult } from '@genesislcap/foundation-ai';
|
|
2
|
+
import { customElement, GenesisElement, observable } from '@genesislcap/web-core';
|
|
3
|
+
import { logger } from '../../utils/logger';
|
|
4
|
+
import { AiChatInteractionWrapperStyles } from './chat-interaction-wrapper.styles';
|
|
5
|
+
import { AiChatInteractionWrapperTemplate } from './chat-interaction-wrapper.template';
|
|
6
|
+
|
|
7
|
+
export type ChatInteractionEventsMap = {
|
|
8
|
+
'interaction-completed': InteractionResult<unknown> & { interactionId: string };
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
@customElement({
|
|
12
|
+
name: 'ai-chat-interaction-wrapper',
|
|
13
|
+
template: AiChatInteractionWrapperTemplate,
|
|
14
|
+
styles: AiChatInteractionWrapperStyles,
|
|
15
|
+
})
|
|
16
|
+
export class AiChatInteractionWrapper extends GenesisElement {
|
|
17
|
+
@observable componentName: string = '';
|
|
18
|
+
@observable data: any;
|
|
19
|
+
@observable interactionId: string = '';
|
|
20
|
+
/** When true, the interaction has already been resolved. Forwarded to the rendered component. */
|
|
21
|
+
@observable resolved: boolean = false;
|
|
22
|
+
|
|
23
|
+
connectedCallback() {
|
|
24
|
+
super.connectedCallback();
|
|
25
|
+
this.renderComponent();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
componentNameChanged() {
|
|
29
|
+
this.renderComponent();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
resolvedChanged() {
|
|
33
|
+
// TODO: switch to FAST ref() or slotted children directives instead of querying the container
|
|
34
|
+
// imperatively — this would allow property bindings to flow naturally through the template.
|
|
35
|
+
const container = this.shadowRoot?.querySelector('.container');
|
|
36
|
+
const element = container?.firstElementChild as any;
|
|
37
|
+
if (element) {
|
|
38
|
+
element.resolved = this.resolved;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
private renderComponent() {
|
|
43
|
+
const container = this.shadowRoot?.querySelector('.container');
|
|
44
|
+
if (!container || !this.componentName) return;
|
|
45
|
+
|
|
46
|
+
// Clear children without using innerHTML
|
|
47
|
+
container.replaceChildren();
|
|
48
|
+
|
|
49
|
+
if (!customElements.get(this.componentName)) {
|
|
50
|
+
logger.warn(
|
|
51
|
+
`Interactive component "\${this.componentName}" is not registered in the customElements registry.`,
|
|
52
|
+
);
|
|
53
|
+
const errorDiv = document.createElement('div');
|
|
54
|
+
errorDiv.textContent = `Error: Component "\${this.componentName}" is not available in this application.`;
|
|
55
|
+
container.appendChild(errorDiv);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
try {
|
|
60
|
+
const element = document.createElement(this.componentName) as any;
|
|
61
|
+
|
|
62
|
+
// Pass data and resolved state to the component
|
|
63
|
+
if (this.data) {
|
|
64
|
+
element.data = this.data;
|
|
65
|
+
}
|
|
66
|
+
element.resolved = this.resolved;
|
|
67
|
+
|
|
68
|
+
// Handle completion from the inner component.
|
|
69
|
+
// Guard against re-emission if the interaction was already resolved
|
|
70
|
+
// (e.g. auto-resolve components fire on connectedCallback when rendering history).
|
|
71
|
+
element.addEventListener('interaction-completed', (e: CustomEvent) => {
|
|
72
|
+
e.stopPropagation();
|
|
73
|
+
if (this.resolved) return;
|
|
74
|
+
|
|
75
|
+
this.$emit('interaction-completed', {
|
|
76
|
+
interactionId: this.interactionId,
|
|
77
|
+
...e.detail,
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
container.appendChild(element);
|
|
82
|
+
} catch (e) {
|
|
83
|
+
logger.error(`Failed to create interactive component: \${this.componentName}`, e);
|
|
84
|
+
const errorDiv = document.createElement('div');
|
|
85
|
+
errorDiv.textContent = `Error: Could not load component \${this.componentName}`;
|
|
86
|
+
container.appendChild(errorDiv);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { css, customElement, GenesisElement, html, observable } from '@genesislcap/web-core';
|
|
2
|
+
import DOMPurify from 'dompurify';
|
|
3
|
+
import { marked } from 'marked';
|
|
4
|
+
|
|
5
|
+
const styles = css`
|
|
6
|
+
:host {
|
|
7
|
+
display: block;
|
|
8
|
+
font-size: var(--type-ramp-base-font-size);
|
|
9
|
+
line-height: var(--type-ramp-base-line-height);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
p {
|
|
13
|
+
margin: 0 0 calc(var(--design-unit, 4) * 2px);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
p:last-child {
|
|
17
|
+
margin-bottom: 0;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
ul,
|
|
21
|
+
ol {
|
|
22
|
+
margin: 0 0 calc(var(--design-unit, 4) * 2px);
|
|
23
|
+
padding-left: calc(var(--design-unit, 4) * 5px);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
code {
|
|
27
|
+
background-color: var(--neutral-fill-rest);
|
|
28
|
+
padding: 2px 4px;
|
|
29
|
+
border-radius: calc(var(--design-unit, 4) * 0.5px);
|
|
30
|
+
font-family: monospace;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
pre {
|
|
34
|
+
background-color: var(--neutral-fill-rest);
|
|
35
|
+
padding: calc(var(--design-unit, 4) * 2px);
|
|
36
|
+
border-radius: calc(var(--design-unit, 4) * 1px);
|
|
37
|
+
overflow-x: auto;
|
|
38
|
+
border: 1px solid var(--neutral-stroke-rest);
|
|
39
|
+
margin: calc(var(--design-unit, 4) * 2px) 0;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
pre code {
|
|
43
|
+
background-color: transparent;
|
|
44
|
+
padding: 0;
|
|
45
|
+
border-radius: 0;
|
|
46
|
+
border: none;
|
|
47
|
+
font-family: inherit;
|
|
48
|
+
color: inherit;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
table {
|
|
52
|
+
display: block;
|
|
53
|
+
overflow-x: auto;
|
|
54
|
+
border-collapse: collapse;
|
|
55
|
+
max-width: 100%;
|
|
56
|
+
margin: calc(var(--design-unit, 4) * 2px) 0;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
th,
|
|
60
|
+
td {
|
|
61
|
+
border: 1px solid var(--neutral-stroke-rest);
|
|
62
|
+
padding: calc(var(--design-unit, 4) * 1px) calc(var(--design-unit, 4) * 2.5px);
|
|
63
|
+
white-space: nowrap;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
th {
|
|
67
|
+
background-color: var(--neutral-fill-stealth-rest);
|
|
68
|
+
font-weight: 600;
|
|
69
|
+
}
|
|
70
|
+
`;
|
|
71
|
+
|
|
72
|
+
@customElement({
|
|
73
|
+
name: 'ai-chat-markdown',
|
|
74
|
+
template: html<AiChatMarkdown>`
|
|
75
|
+
<div :innerHTML="${(x) => x.renderMarkdown()}"></div>
|
|
76
|
+
`,
|
|
77
|
+
styles,
|
|
78
|
+
})
|
|
79
|
+
export class AiChatMarkdown extends GenesisElement {
|
|
80
|
+
@observable content: string = '';
|
|
81
|
+
|
|
82
|
+
renderMarkdown() {
|
|
83
|
+
if (!this.content) return '';
|
|
84
|
+
const rawHtml = marked.parse(this.content) as string;
|
|
85
|
+
return DOMPurify.sanitize(rawHtml);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './chat-markdown';
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { attr, css, customElement, GenesisElement, html } from '@genesislcap/web-core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Animated halo overlay — rotating conic-gradient border with an inward glow.
|
|
5
|
+
*
|
|
6
|
+
* Drop inside any `position: relative; overflow: hidden` container and toggle
|
|
7
|
+
* the `active` attribute to show/hide the effect.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```html
|
|
11
|
+
* <ai-halo-overlay ?active="${(x) => x.isLoading}"></ai-halo-overlay>
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* @beta
|
|
15
|
+
*/
|
|
16
|
+
@customElement({
|
|
17
|
+
name: 'ai-halo-overlay',
|
|
18
|
+
template: html`
|
|
19
|
+
<slot></slot>
|
|
20
|
+
`,
|
|
21
|
+
styles: css`
|
|
22
|
+
:host {
|
|
23
|
+
display: block;
|
|
24
|
+
position: absolute;
|
|
25
|
+
inset: 0;
|
|
26
|
+
border-radius: inherit;
|
|
27
|
+
pointer-events: none;
|
|
28
|
+
z-index: 1000;
|
|
29
|
+
opacity: 0;
|
|
30
|
+
transition: opacity 0.4s ease;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
:host([active]) {
|
|
34
|
+
opacity: 1;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/* Rotating solid border */
|
|
38
|
+
:host::before {
|
|
39
|
+
content: '';
|
|
40
|
+
position: absolute;
|
|
41
|
+
inset: 0;
|
|
42
|
+
border-radius: inherit;
|
|
43
|
+
padding: 3px;
|
|
44
|
+
background: repeating-conic-gradient(
|
|
45
|
+
from var(--halo-angle, 0deg),
|
|
46
|
+
#feb60a,
|
|
47
|
+
#ff0062,
|
|
48
|
+
#00dbf9,
|
|
49
|
+
#da00f7,
|
|
50
|
+
#feb60a
|
|
51
|
+
);
|
|
52
|
+
-webkit-mask:
|
|
53
|
+
linear-gradient(#000 0 0) content-box,
|
|
54
|
+
linear-gradient(#000 0 0);
|
|
55
|
+
mask:
|
|
56
|
+
linear-gradient(#000 0 0) content-box,
|
|
57
|
+
linear-gradient(#000 0 0);
|
|
58
|
+
-webkit-mask-composite: destination-out;
|
|
59
|
+
mask-composite: exclude;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/* Inward glow — radial mask makes centre transparent, edges coloured */
|
|
63
|
+
:host::after {
|
|
64
|
+
content: '';
|
|
65
|
+
position: absolute;
|
|
66
|
+
inset: 0;
|
|
67
|
+
border-radius: inherit;
|
|
68
|
+
background: repeating-conic-gradient(
|
|
69
|
+
from var(--halo-angle, 0deg),
|
|
70
|
+
#feb60a,
|
|
71
|
+
#ff0062,
|
|
72
|
+
#00dbf9,
|
|
73
|
+
#da00f7,
|
|
74
|
+
#feb60a
|
|
75
|
+
);
|
|
76
|
+
opacity: 0.35;
|
|
77
|
+
-webkit-mask-image: radial-gradient(ellipse at center, transparent 70%, black 100%);
|
|
78
|
+
mask-image: radial-gradient(ellipse at center, transparent 70%, black 100%);
|
|
79
|
+
}
|
|
80
|
+
`,
|
|
81
|
+
})
|
|
82
|
+
export class AiHaloOverlay extends GenesisElement {
|
|
83
|
+
@attr({ mode: 'boolean' }) active: boolean = false;
|
|
84
|
+
|
|
85
|
+
// TODO: The rAF loop is fine for demos but has two drawbacks vs a pure CSS @property animation:
|
|
86
|
+
// 1. It runs on the main thread, so heavy JS work can cause the animation to stutter.
|
|
87
|
+
// 2. The loop ticks even when `active` is false (idle cost is negligible but non-zero).
|
|
88
|
+
// Once @property inside Shadow DOM has solid cross-browser support, consider switching back
|
|
89
|
+
// to a CSS @keyframes approach and removing connectedCallback/disconnectedCallback/tick().
|
|
90
|
+
|
|
91
|
+
// 1.5° per frame @ 60 fps ≈ 4 s per full revolution
|
|
92
|
+
private static readonly DEG_PER_FRAME = 1.5;
|
|
93
|
+
private static readonly FULL_ROTATION_DEG = 360;
|
|
94
|
+
|
|
95
|
+
private angle = 0;
|
|
96
|
+
private animFrame?: number;
|
|
97
|
+
|
|
98
|
+
connectedCallback() {
|
|
99
|
+
super.connectedCallback();
|
|
100
|
+
this.tick();
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
disconnectedCallback() {
|
|
104
|
+
super.disconnectedCallback();
|
|
105
|
+
if (this.animFrame !== undefined) {
|
|
106
|
+
cancelAnimationFrame(this.animFrame);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
private tick() {
|
|
111
|
+
this.angle = (this.angle + AiHaloOverlay.DEG_PER_FRAME) % AiHaloOverlay.FULL_ROTATION_DEG;
|
|
112
|
+
this.style.setProperty('--halo-angle', `${this.angle}deg`);
|
|
113
|
+
this.animFrame = requestAnimationFrame(() => this.tick());
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { ChatConfig, ChatToolDefinition, ChatToolHandlers } from '@genesislcap/foundation-ai';
|
|
2
|
+
import { DI, PartialGenesisElementDefinition } from '@genesislcap/web-core';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Do not reference any ../main files here. We must avoid ../tags being referenced and
|
|
6
|
+
* therefore set up pre-configuration.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* AiAssistantConfig DI interface.
|
|
11
|
+
*
|
|
12
|
+
* @beta
|
|
13
|
+
*/
|
|
14
|
+
export interface AiAssistantConfig extends PartialGenesisElementDefinition {
|
|
15
|
+
/**
|
|
16
|
+
* Display title shown in the chat header (e.g. 'Trades Assistant').
|
|
17
|
+
*/
|
|
18
|
+
headerTitle?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Chat display and behaviour configuration.
|
|
21
|
+
*/
|
|
22
|
+
chatConfig: ChatConfig;
|
|
23
|
+
/**
|
|
24
|
+
* Tool handlers injected per-app at configure() time.
|
|
25
|
+
*/
|
|
26
|
+
toolHandlers?: ChatToolHandlers;
|
|
27
|
+
/**
|
|
28
|
+
* Tool definitions (JSON Schema) passed to the AI provider.
|
|
29
|
+
*/
|
|
30
|
+
toolDefinitions?: ChatToolDefinition[];
|
|
31
|
+
/**
|
|
32
|
+
* System prompt injected into every conversation.
|
|
33
|
+
*/
|
|
34
|
+
systemPrompt?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Optional factory called at download time to include extra app-specific debug state
|
|
37
|
+
* alongside the message history. Only used when `chatConfig.allowDebugDownload` is `true`.
|
|
38
|
+
*/
|
|
39
|
+
debugStateFactory?: () => unknown;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Default AiAssistantConfig DI implementation.
|
|
44
|
+
*
|
|
45
|
+
* @beta
|
|
46
|
+
*/
|
|
47
|
+
export const defaultAiAssistantConfig: AiAssistantConfig = {
|
|
48
|
+
name: 'foundation-ai-assistant',
|
|
49
|
+
chatConfig: {},
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* AiAssistantConfig DI key.
|
|
54
|
+
*
|
|
55
|
+
* @internal
|
|
56
|
+
*/
|
|
57
|
+
export const AiAssistantConfig = DI.createInterface<AiAssistantConfig>((x) =>
|
|
58
|
+
x.instance(defaultAiAssistantConfig),
|
|
59
|
+
);
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './config';
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './main/main';
|
|
2
|
+
export * from './main/main.types';
|
|
3
|
+
export * from './main/main.template';
|
|
4
|
+
export * from './components/chat-bubble';
|
|
5
|
+
export * from './components/chat-driver';
|
|
6
|
+
export * from './components/activity-halo/activity-halo';
|
|
7
|
+
export * from './channel/ai-activity-channel';
|
|
8
|
+
export * from './config/config';
|
|
9
|
+
export type { AiChatWidget } from './types/ai-chat-widget';
|