@digipair/skill-web-chatbot 0.89.0 → 0.91.0-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.
Files changed (136) hide show
  1. package/.swcrc +28 -0
  2. package/README.md +7 -0
  3. package/eslint.config.mjs +22 -0
  4. package/package.json +22 -7
  5. package/rollup.config.cjs +28 -0
  6. package/src/digipair__engine.d.ts +2 -0
  7. package/src/handlebars.d.ts +1 -0
  8. package/src/index.html +18 -0
  9. package/src/lib/chat.element.ts +603 -0
  10. package/src/lib/common.data.ts +1 -0
  11. package/src/lib/config.ts +30 -0
  12. package/src/lib/digipair-full.data.ts +101 -0
  13. package/src/lib/digipair-full.element.ts +358 -0
  14. package/src/lib/digipair.data.ts +103 -0
  15. package/src/lib/digipair.element.ts +446 -0
  16. package/src/lib/inputs.element.ts +46 -0
  17. package/src/lib/mermaid.d.ts +1 -0
  18. package/src/lib/message.interface.ts +10 -0
  19. package/src/lib/pins/chatbot.actions.ts +32 -0
  20. package/src/lib/tools/css-selector.ts +12 -0
  21. package/tsconfig.json +13 -0
  22. package/tsconfig.lib.json +19 -0
  23. package/SAP-icons.cjs.js +0 -2489
  24. package/SAP-icons.cjs2.js +0 -2489
  25. package/SAP-icons.esm.js +0 -2482
  26. package/SAP-icons.esm2.js +0 -2482
  27. package/Tableau10-558cc280.cjs.js +0 -9
  28. package/Tableau10-558cc280.esm.js +0 -7
  29. package/arc-d1f6357e.cjs.js +0 -88
  30. package/arc-d1f6357e.esm.js +0 -86
  31. package/array-2ff2c7a6.cjs.js +0 -7
  32. package/array-2ff2c7a6.esm.js +0 -5
  33. package/blockDiagram-5dc23a45.cjs.js +0 -2921
  34. package/blockDiagram-5dc23a45.esm.js +0 -2919
  35. package/c4Diagram-1e775db3.cjs.js +0 -4387
  36. package/c4Diagram-1e775db3.esm.js +0 -4385
  37. package/channel-ebbc4130.cjs.js +0 -9
  38. package/channel-ebbc4130.esm.js +0 -7
  39. package/classDiagram-f52caa06.cjs.js +0 -209
  40. package/classDiagram-f52caa06.esm.js +0 -207
  41. package/classDiagram-v2-640c694e.cjs.js +0 -401
  42. package/classDiagram-v2-640c694e.esm.js +0 -399
  43. package/clone-afc2f047.cjs.js +0 -10
  44. package/clone-afc2f047.esm.js +0 -8
  45. package/createText-03b82060.cjs.js +0 -2936
  46. package/createText-03b82060.esm.js +0 -2933
  47. package/edges-16357fde.cjs.js +0 -1998
  48. package/edges-16357fde.esm.js +0 -1981
  49. package/erDiagram-c7ff1bec.cjs.js +0 -1807
  50. package/erDiagram-c7ff1bec.esm.js +0 -1805
  51. package/flowDb-9a89ea33.cjs.js +0 -5542
  52. package/flowDb-9a89ea33.esm.js +0 -5538
  53. package/flowDiagram-aadb13b0.cjs.js +0 -1351
  54. package/flowDiagram-aadb13b0.esm.js +0 -1349
  55. package/flowDiagram-v2-f2119625.cjs.js +0 -31
  56. package/flowDiagram-v2-f2119625.esm.js +0 -29
  57. package/flowchart-elk-definition-cf813a97.cjs.js +0 -50257
  58. package/flowchart-elk-definition-cf813a97.esm.js +0 -50255
  59. package/ganttDiagram-3c2fde2b.cjs.js +0 -3710
  60. package/ganttDiagram-3c2fde2b.esm.js +0 -3708
  61. package/gitGraphDiagram-c3a0619c.cjs.js +0 -3820
  62. package/gitGraphDiagram-c3a0619c.esm.js +0 -3818
  63. package/graph-0ee63739.cjs.js +0 -961
  64. package/graph-0ee63739.esm.js +0 -938
  65. package/index-bb6d8841.cjs.js +0 -648
  66. package/index-bb6d8841.esm.js +0 -646
  67. package/index.cjs.d.ts +0 -1
  68. package/index.cjs.js +0 -17
  69. package/index.cjs2.js +0 -60723
  70. package/index.esm.js +0 -1
  71. package/index.esm2.js +0 -60574
  72. package/infoDiagram-2f5c50c0.cjs.js +0 -460
  73. package/infoDiagram-2f5c50c0.esm.js +0 -458
  74. package/init-f9637058.cjs.js +0 -17
  75. package/init-f9637058.esm.js +0 -15
  76. package/journeyDiagram-14fe341a.cjs.js +0 -1061
  77. package/journeyDiagram-14fe341a.esm.js +0 -1059
  78. package/katex-d90b6d29.cjs.js +0 -25690
  79. package/katex-d90b6d29.esm.js +0 -25688
  80. package/layout-fd473db2.cjs.js +0 -1626
  81. package/layout-fd473db2.esm.js +0 -1619
  82. package/libs/engine/src/index.d.ts +0 -2
  83. package/libs/engine/src/lib/alias.interface.d.ts +0 -9
  84. package/libs/engine/src/lib/engine.d.ts +0 -13
  85. package/libs/engine/src/lib/pins-settings.interface.d.ts +0 -15
  86. package/libs/skill-web-chatbot/src/lib/chat.element.d.ts +0 -28
  87. package/libs/skill-web-chatbot/src/lib/common.data.d.ts +0 -1
  88. package/libs/skill-web-chatbot/src/lib/config.d.ts +0 -9
  89. package/libs/skill-web-chatbot/src/lib/digipair-full.data.d.ts +0 -1
  90. package/libs/skill-web-chatbot/src/lib/digipair-full.element.d.ts +0 -36
  91. package/libs/skill-web-chatbot/src/lib/digipair.data.d.ts +0 -1
  92. package/libs/skill-web-chatbot/src/lib/digipair.element.d.ts +0 -44
  93. package/libs/skill-web-chatbot/src/lib/inputs.element.d.ts +0 -10
  94. package/libs/skill-web-chatbot/src/lib/message.interface.d.ts +0 -10
  95. package/libs/skill-web-chatbot/src/lib/pins/chatbot.actions.d.ts +0 -1
  96. package/libs/skill-web-chatbot/src/lib/tools/css-selector.d.ts +0 -1
  97. package/line-24d93f1b.cjs.js +0 -34
  98. package/line-24d93f1b.esm.js +0 -32
  99. package/linear-9bcf74c4.cjs.js +0 -537
  100. package/linear-9bcf74c4.esm.js +0 -531
  101. package/mindmap-definition-9399c7e6.cjs.js +0 -20489
  102. package/mindmap-definition-9399c7e6.esm.js +0 -20487
  103. package/ordinal-5695958c.cjs.js +0 -331
  104. package/ordinal-5695958c.esm.js +0 -329
  105. package/path-428ebac9.cjs.js +0 -317
  106. package/path-428ebac9.esm.js +0 -314
  107. package/pieDiagram-828dae43.cjs.js +0 -951
  108. package/pieDiagram-828dae43.esm.js +0 -949
  109. package/quadrantDiagram-5fa00455.cjs.js +0 -2410
  110. package/quadrantDiagram-5fa00455.esm.js +0 -2408
  111. package/requirementDiagram-03163dc4.cjs.js +0 -2267
  112. package/requirementDiagram-03163dc4.esm.js +0 -2265
  113. package/sankeyDiagram-52ec8976.cjs.js +0 -1848
  114. package/sankeyDiagram-52ec8976.esm.js +0 -1846
  115. package/sequenceDiagram-b517d154.cjs.js +0 -5949
  116. package/sequenceDiagram-b517d154.esm.js +0 -5947
  117. package/stateDiagram-fca82b5b.cjs.js +0 -283
  118. package/stateDiagram-fca82b5b.esm.js +0 -281
  119. package/stateDiagram-v2-ed04200a.cjs.js +0 -373
  120. package/stateDiagram-v2-ed04200a.esm.js +0 -371
  121. package/styles-11e81fdd.cjs.js +0 -3944
  122. package/styles-11e81fdd.esm.js +0 -3940
  123. package/styles-cacbff60.cjs.js +0 -2120
  124. package/styles-cacbff60.esm.js +0 -2111
  125. package/styles-e75131e4.cjs.js +0 -671
  126. package/styles-e75131e4.esm.js +0 -661
  127. package/svgDrawCommon-ecc5f780.cjs.js +0 -68
  128. package/svgDrawCommon-ecc5f780.esm.js +0 -60
  129. package/timeline-definition-4ee9bff4.cjs.js +0 -1161
  130. package/timeline-definition-4ee9bff4.esm.js +0 -1159
  131. package/xychartDiagram-e5e6b652.cjs.js +0 -3150
  132. package/xychartDiagram-e5e6b652.esm.js +0 -3148
  133. /package/{index.d.ts → src/index.d.ts} +0 -0
  134. /package/{libs/skill-web-chatbot/src/index.d.ts → src/index.ts} +0 -0
  135. /package/{schema.fr.json → src/schema.fr.json} +0 -0
  136. /package/{schema.json → src/schema.json} +0 -0
@@ -0,0 +1,446 @@
1
+ import { fetchEventSource } from '@microsoft/fetch-event-source';
2
+ import '@ui5/webcomponents-icons/dist/AllIcons';
3
+ import '@ui5/webcomponents/dist/BusyIndicator';
4
+ import '@ui5/webcomponents/dist/Icon';
5
+ import { html, LitElement, TemplateResult } from 'lit';
6
+ import { customElement, property, query, state } from 'lit/decorators.js';
7
+ import { executePinsList } from '@digipair/engine';
8
+ import './chat.element';
9
+ import { ChatElement } from './chat.element';
10
+ import { styles } from './digipair.data';
11
+ import getCssSelector from './tools/css-selector';
12
+ import { _config } from './config';
13
+ import { Message } from './message.interface';
14
+
15
+ @customElement('digipair-chatbot')
16
+ export class ChatbotElement extends LitElement {
17
+ @property()
18
+ code = 'common';
19
+
20
+ @property()
21
+ firstOpenDelay = 60000;
22
+
23
+ @property()
24
+ apiUrl = _config.API_URL;
25
+
26
+ @property()
27
+ userId: string | null = null;
28
+
29
+ @state()
30
+ private boosters: any[] = [];
31
+
32
+ @state()
33
+ private loading = false;
34
+
35
+ @state()
36
+ private resultState = 'open';
37
+
38
+ @state()
39
+ private currentBoost: any = null;
40
+
41
+ @state()
42
+ private messages: Message[] = [];
43
+
44
+ @state()
45
+ private loadingStep = '';
46
+
47
+ @query('digipair-chatbot-chat')
48
+ private chatbot!: ChatElement;
49
+ private alreadyOpened = false;
50
+ private isDigipairLoading = false;
51
+ private newUser!: boolean;
52
+ private metadata!: {
53
+ id: string;
54
+ config: { VERSIONS: { [key: string]: string } };
55
+ variables: { [key: string]: any };
56
+ avatar: string;
57
+ primary: string;
58
+ secondary: string;
59
+ textPrimary: string;
60
+ textSecondary: string;
61
+ };
62
+
63
+ private CHAT_COMMAND(digipair: string, reasoning: string) {
64
+ return {
65
+ library: '@digipair/actions-chatbot',
66
+ element: 'executeRemoteReasoning',
67
+ properties: {
68
+ digipair,
69
+ reasoning: reasoning ?? 'conversation',
70
+ apiUrl: this.apiUrl,
71
+ },
72
+ };
73
+ }
74
+
75
+ private blurEvent = (event: Event) => {
76
+ const path = event.composedPath();
77
+ if (!path.includes(this)) {
78
+ // L'événement a été déclenché en dehors du composant
79
+ this.closeResult();
80
+ }
81
+ };
82
+
83
+ override connectedCallback(): void {
84
+ super.connectedCallback();
85
+
86
+ this.loadUser();
87
+ this.boostListener();
88
+ this.externalBoostListener();
89
+ this.initializeSSE();
90
+ document.addEventListener('click', this.blurEvent);
91
+ }
92
+
93
+ override disconnectedCallback(): void {
94
+ document.removeEventListener('click', this.blurEvent);
95
+ }
96
+
97
+ private externalBoostListener() {
98
+ this.addEventListener('executeBoost', ({ detail }: any) => {
99
+ setTimeout(() => this.executeBoost({ context: {}, ...detail }), 1);
100
+ });
101
+ }
102
+
103
+ private initializeSSE() {
104
+ const digipair = this.code;
105
+ const reasoning = 'notification';
106
+
107
+ fetchEventSource(`${this.apiUrl}/${digipair}/${reasoning}`, {
108
+ method: 'POST',
109
+ headers: {
110
+ 'Content-Type': 'application/json',
111
+ },
112
+ onmessage: (message: any) => {
113
+ if (message.event !== 'message') {
114
+ return;
115
+ }
116
+
117
+ const data = JSON.parse(message.data);
118
+
119
+ if (data.type === 'step') {
120
+ this.loadingStep = data.content;
121
+ }
122
+
123
+ if (data.type === 'message') {
124
+ this.pushMessage(data.content);
125
+ }
126
+ },
127
+ body: JSON.stringify({
128
+ userId: this.userId,
129
+ }),
130
+ onerror(err) {
131
+ console.error('[Digipair] SSE Error:', err);
132
+ },
133
+ });
134
+ }
135
+
136
+ private loadUser(): void {
137
+ this.newUser = false;
138
+
139
+ if (this.userId) {
140
+ return;
141
+ }
142
+
143
+ this.userId = localStorage.getItem('digipair-user');
144
+ if (!this.userId) {
145
+ // set uuid
146
+ this.userId = Math.random().toString(36).substring(2, 15);
147
+ localStorage.setItem('digipair-user', this.userId);
148
+
149
+ this.newUser = true;
150
+ }
151
+ }
152
+
153
+ private async boostListener() {
154
+ const boosts = (await this.executeScene('boosts'))
155
+ .map((boost: any) => ({
156
+ ...boost,
157
+ checkUrl: new RegExp(boost.url),
158
+ }))
159
+ .filter((boost: any) => boost.selector);
160
+ let lastSelectedBoosts: any[] | null = [];
161
+
162
+ document.addEventListener(
163
+ 'mouseover',
164
+ (event: any) => {
165
+ lastSelectedBoosts = event.target.closest('digipair-chatbot')
166
+ ? null
167
+ : this.getBoostsFromTarget(event.target, boosts);
168
+
169
+ setTimeout(async () => {
170
+ // si on est sur le chatbot, on ne fait rien
171
+ if (!lastSelectedBoosts) {
172
+ return;
173
+ }
174
+
175
+ const selectedBoosts = this.getBoostsFromTarget(event.target, boosts);
176
+
177
+ // garder les boosts communs entre les deux listes
178
+ this.boosters = selectedBoosts
179
+ .filter(boost => lastSelectedBoosts?.includes(boost))
180
+ .map(boost => ({
181
+ ...boost,
182
+ context: {
183
+ ...(boost.context || {}),
184
+ element: getCssSelector(event.target.closest(boost.selector)),
185
+ },
186
+ }));
187
+ }, 1000);
188
+ },
189
+ true,
190
+ );
191
+ }
192
+
193
+ private getBoostsFromTarget(target: any, boosts: any[]): any[] {
194
+ return boosts.filter(
195
+ boost => boost.checkUrl.test(window.location.href) && !!target.closest(boost.selector),
196
+ );
197
+ }
198
+
199
+ private async loadDigipair(): Promise<void> {
200
+ this.isDigipairLoading = true;
201
+
202
+ const digipair = this.code;
203
+ const reasoning = 'metadata';
204
+ const metadata = await this.executeScene(reasoning);
205
+
206
+ this.metadata = { ...metadata, id: digipair, config: { VERSIONS: metadata.config.VERSIONS } };
207
+ await this.loadHistory();
208
+
209
+ setTimeout(() => {
210
+ this.scrollDown();
211
+ setTimeout(() => {
212
+ this.closeResult();
213
+ }, 1);
214
+ }, 1);
215
+
216
+ this.isDigipairLoading = false;
217
+
218
+ if (this.newUser) {
219
+ this.manageNewUser();
220
+ }
221
+ }
222
+
223
+ private manageNewUser(): void {
224
+ if (!this.firstOpenDelay) {
225
+ return;
226
+ }
227
+
228
+ setTimeout(() => {
229
+ if (this.alreadyOpened) {
230
+ return;
231
+ }
232
+
233
+ this.openResult();
234
+ }, this.firstOpenDelay);
235
+ }
236
+
237
+ private async loadHistory(): Promise<void> {
238
+ const userId = this.userId;
239
+ const reasoning = 'history';
240
+ const messages = (
241
+ await this.executeScene(reasoning, {
242
+ userId,
243
+ })
244
+ ).map((message: any) => ({
245
+ ...message,
246
+ boost: message.boost
247
+ ? {
248
+ ...message.boost,
249
+ checkUrl: message.boost.url ? new RegExp(message.boost.url) : null,
250
+ }
251
+ : null,
252
+ }));
253
+
254
+ if (messages.length > 0) {
255
+ this.messages = messages;
256
+ }
257
+ }
258
+
259
+ private scrollDown(): void {
260
+ const container = (this.shadowRoot as unknown as HTMLElement).querySelector(
261
+ '.container',
262
+ ) as HTMLElement;
263
+ container.scrollTop = container.scrollHeight;
264
+ }
265
+
266
+ async execute(boost: any, message?: string): Promise<void> {
267
+ this.loadingStep = '';
268
+ this.loading = true;
269
+
270
+ if (message || boost?.command?.properties?.input?.prompt) {
271
+ this.messages.push({
272
+ role: 'user',
273
+ content: message || boost.command.properties.input.prompt,
274
+ });
275
+ }
276
+ this.chatbot.requestUpdate();
277
+
278
+ const command = boost?.command ? boost.command : this.CHAT_COMMAND(this.code, boost?.reasoning);
279
+ try {
280
+ const pins = JSON.parse(JSON.stringify(command));
281
+ pins.properties = pins.properties || {};
282
+ pins.properties.input = {
283
+ ...(pins.properties.input || {}),
284
+ prompt: message || pins.properties.input?.prompt,
285
+ inputs: this.chatbot.inputs,
286
+ userId: this.userId,
287
+ step: boost?.step,
288
+ parent_history: boost?.parent_history,
289
+ parent_conversation: boost?.parent_conversation,
290
+ context: boost?.context || {},
291
+ };
292
+
293
+ const detail = await executePinsList(
294
+ [pins],
295
+ {
296
+ config: {
297
+ VERSIONS: this.metadata.config.VERSIONS,
298
+ },
299
+ },
300
+ 'boost',
301
+ );
302
+ this.currentBoost = detail.boost
303
+ ? {
304
+ parent_history: detail.uuid,
305
+ parent_conversation: detail.parent_conversation || detail.uuid,
306
+ ...detail.boost,
307
+ }
308
+ : null;
309
+ this.pushMessage({
310
+ role: 'assistant',
311
+ content: detail.assistant,
312
+ uuid: detail.uuid,
313
+ boost: detail.boost,
314
+ boosts: detail.boosts,
315
+ sources: detail.sources,
316
+ parent_conversation: detail.parent_conversation,
317
+ parent_history: detail.parent_history,
318
+ });
319
+
320
+ if (detail.command && detail.command.length > 0) {
321
+ await executePinsList(
322
+ detail.command,
323
+ { config: { VERSIONS: this.metadata.config.VERSIONS } },
324
+ 'boost.command',
325
+ );
326
+ }
327
+ } catch (error) {
328
+ this.pushMessage({
329
+ role: 'assistant',
330
+ content: 'Oops...',
331
+ });
332
+ }
333
+
334
+ this.loadingStep = '';
335
+ this.loading = false;
336
+ }
337
+
338
+ private executeBoost(boost: any): void {
339
+ this.execute(boost);
340
+ this.openResult();
341
+
342
+ setTimeout(() => {
343
+ (this.chatbot?.shadowRoot?.querySelector('#messageInput') as any).focus();
344
+ }, 1);
345
+ }
346
+
347
+ private pushMessage(message: Message): void {
348
+ this.openResult();
349
+ this.messages.push(message);
350
+ this.chatbot.requestUpdate();
351
+ }
352
+
353
+ private openResult(): void {
354
+ this.resultState = 'open';
355
+ setTimeout(() => {
356
+ (this.chatbot?.shadowRoot?.querySelector('#messageInput') as any).focus();
357
+ this.chatbot.requestUpdate();
358
+ }, 1);
359
+
360
+ this.alreadyOpened = true;
361
+ }
362
+
363
+ private closeResult(): void {
364
+ this.resultState = 'closed';
365
+ }
366
+
367
+ private setBoost(boost: any): void {
368
+ this.currentBoost = boost;
369
+ this.boosters = [];
370
+ }
371
+
372
+ private executeScene = async (reasoning: string, input: any = {}): Promise<any> => {
373
+ const digipair = this.code;
374
+ const response = await fetch(`${this.apiUrl}/${digipair}/${reasoning}`, {
375
+ method: 'POST',
376
+ headers: {
377
+ 'Content-Type': 'application/json',
378
+ },
379
+ body: JSON.stringify(input),
380
+ });
381
+
382
+ return await response.json();
383
+ };
384
+
385
+ static override styles = styles;
386
+ override render(): TemplateResult {
387
+ if (this.metadata?.id !== this.code) {
388
+ if (!this.isDigipairLoading) {
389
+ this.loadDigipair();
390
+ }
391
+ return html``;
392
+ }
393
+
394
+ return html`
395
+ <style>
396
+ @import url('https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap');
397
+ font-family: 'Poppins', sans-serif;
398
+ font-weight: 300;
399
+ font-style: normal;
400
+
401
+ --digipair-color-primary: ${this.metadata.primary};
402
+ --digipair-color-text-primary: ${this.metadata.textPrimary};
403
+ --digipair-color-secondary: ${this.metadata.secondary};
404
+ --digipair-color-text-secondary: ${this.metadata.textSecondary};
405
+ </style>
406
+
407
+ <section class="container result-${this.resultState}">
408
+ <section class="result" style="border: 1px solid var(--digipair-color-primary, #52DFDB)">
409
+ <digipair-chatbot-chat
410
+ ?loading=${this.loading}
411
+ .messages=${this.messages}
412
+ .currentBoost=${this.currentBoost}
413
+ .context=${{ config: this.metadata.config, variables: this.metadata.variables }}
414
+ loadingStep=${this.loadingStep}
415
+ @prompt=${(event: any) => this.execute(this.currentBoost, event.detail.prompt)}
416
+ @executeboost=${(event: any) => this.executeBoost(event.detail)}
417
+ @boost=${(event: any) => this.setBoost(event.detail)}
418
+ ></digipair-chatbot-chat>
419
+ </section>
420
+
421
+ <section class="actions ${this.loading ? 'loading' : ''}">
422
+ ${this.boosters.map(
423
+ boost => html`
424
+ <span
425
+ class="action"
426
+ style="border: 1px solid var(--digipair-color-primary, #52DFDB)"
427
+ @click=${() => this.executeBoost(boost)}
428
+ >${boost.summary}</span
429
+ >
430
+ `,
431
+ )}
432
+ </section>
433
+
434
+ <section
435
+ class="panel"
436
+ style="border: 1px solid var(--digipair-color-primary, #52DFDB)"
437
+ ></section>
438
+ <img
439
+ @click=${() => (this.resultState !== 'closed' ? this.closeResult() : this.openResult())}
440
+ class="logo ${this.loading ? 'loading' : ''}"
441
+ src=${this.metadata.avatar}
442
+ />
443
+ </section>
444
+ `;
445
+ }
446
+ }
@@ -0,0 +1,46 @@
1
+ import { LitElement, html, noChange, nothing } from 'lit';
2
+ import { customElement, property } from 'lit/decorators.js';
3
+ import { until } from 'lit/directives/until.js';
4
+ import { generateElementFromPins } from '@digipair/engine';
5
+
6
+ @customElement('digipair-chatbot-inputs')
7
+ export class InputsElement extends LitElement {
8
+ @property({ type: Array })
9
+ inputs: any[] = [];
10
+
11
+ @property({ type: Object })
12
+ context: any = {};
13
+
14
+ private cache = '';
15
+
16
+ get values(): { [key: string]: any }[] {
17
+ return Array.from((this.shadowRoot as unknown as HTMLElement).children).map((el: any) => ({
18
+ value: el.value,
19
+ content: el.content,
20
+ required: el.required,
21
+ }));
22
+ }
23
+
24
+ override render() {
25
+ const cache = JSON.stringify(this.inputs);
26
+
27
+ if (this.cache === cache) {
28
+ return noChange;
29
+ }
30
+ this.cache = cache;
31
+
32
+ return html`
33
+ ${(this.inputs || []).map(
34
+ (pins: PinsSettings) =>
35
+ html`${until(
36
+ generateElementFromPins(pins, null, this.context).then((el: Element) => {
37
+ setTimeout(() => this.dispatchEvent(new CustomEvent('change')), 1);
38
+ el.addEventListener('change', () => this.dispatchEvent(new CustomEvent('change')));
39
+ return el;
40
+ }),
41
+ nothing,
42
+ )}`,
43
+ )}
44
+ `;
45
+ }
46
+ }
@@ -0,0 +1 @@
1
+ declare module 'mermaid/dist/mermaid.esm.min.mjs';
@@ -0,0 +1,10 @@
1
+ export interface Message {
2
+ role: 'assistant' | 'user';
3
+ content: string;
4
+ uuid?: string;
5
+ boost?: any;
6
+ boosts?: any[];
7
+ sources?: any[];
8
+ parent_conversation?: string;
9
+ parent_history?: string;
10
+ }
@@ -0,0 +1,32 @@
1
+ class DomService {
2
+ async executeRemoteReasoning(
3
+ { digipair, reasoning, input, apiUrl }: any,
4
+ _pinsSettingsList: PinsSettings[],
5
+ context: any,
6
+ ): Promise<any> {
7
+ const response = await fetch(`${apiUrl}/${digipair}/${reasoning}`, {
8
+ method: 'POST',
9
+ headers: {
10
+ 'Content-Type': 'application/json',
11
+ },
12
+ body: JSON.stringify({
13
+ ...context.input,
14
+ ...input,
15
+ }),
16
+ });
17
+
18
+ const result = await response.json();
19
+
20
+ if (response.status >= 400) {
21
+ throw new Error(result.message);
22
+ }
23
+
24
+ return result;
25
+ }
26
+ }
27
+
28
+ export const executeRemoteReasoning = (
29
+ params: any,
30
+ pinsSettingsList: PinsSettings[],
31
+ context: any,
32
+ ) => new DomService().executeRemoteReasoning(params, pinsSettingsList, context);
@@ -0,0 +1,12 @@
1
+ import getCssSelectorOrigin from 'css-selector-generator';
2
+
3
+ function unescapeCSS(cssEscapedString: string) {
4
+ return cssEscapedString.replace(/\\([0-9A-Fa-f]{1,6})\s?/g, (_match: any, charCode: any) =>
5
+ String.fromCharCode(parseInt(charCode, 16))
6
+ ).replace(/\\/g, '');
7
+ }
8
+
9
+ export default function getCssSelector(element: any, options: any = {}) {
10
+ const selector = getCssSelectorOrigin(element, options);
11
+ return unescapeCSS(selector);
12
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "files": [],
4
+ "include": [],
5
+ "references": [
6
+ {
7
+ "path": "../engine"
8
+ },
9
+ {
10
+ "path": "./tsconfig.lib.json"
11
+ }
12
+ ]
13
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "rootDir": "src",
5
+ "outDir": "dist",
6
+ "tsBuildInfoFile": "dist/tsconfig.lib.tsbuildinfo",
7
+ "emitDeclarationOnly": true,
8
+ "module": "esnext",
9
+ "moduleResolution": "node",
10
+ "forceConsistentCasingInFileNames": true,
11
+ "types": ["node"]
12
+ },
13
+ "include": ["src/**/*.ts"],
14
+ "references": [
15
+ {
16
+ "path": "../engine/tsconfig.lib.json"
17
+ }
18
+ ]
19
+ }