@iyulab/chat-components 0.2.0 → 0.4.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 (113) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/dist/assets/action-prompt.md.js +3 -0
  3. package/dist/assets/widget-prompt.md.js +3 -0
  4. package/dist/components/actions/UQuestionAction.component.d.ts +18 -0
  5. package/dist/components/actions/UQuestionAction.component.js +58 -0
  6. package/dist/components/actions/UQuestionAction.d.ts +7 -0
  7. package/dist/components/actions/UQuestionAction.js +5 -0
  8. package/dist/components/actions/UQuestionAction.styles.js +45 -0
  9. package/dist/components/blocks/UCodeBlock.component.d.ts +5 -3
  10. package/dist/components/blocks/UCodeBlock.component.js +14 -2
  11. package/dist/components/blocks/UCodeBlock.styles.js +6 -0
  12. package/dist/components/blocks/UFilesBlock.component.d.ts +22 -0
  13. package/dist/components/blocks/UFilesBlock.component.js +192 -0
  14. package/dist/components/blocks/UFilesBlock.d.ts +7 -0
  15. package/dist/components/blocks/UFilesBlock.js +5 -0
  16. package/dist/components/blocks/UFilesBlock.styles.d.ts +1 -0
  17. package/dist/components/blocks/UFilesBlock.styles.js +206 -0
  18. package/dist/components/blocks/UJsonBlock.component.d.ts +3 -3
  19. package/dist/components/blocks/UJsonBlock.component.js +2 -2
  20. package/dist/components/blocks/UMarkedBlock.component.d.ts +19 -24
  21. package/dist/components/blocks/UMarkedBlock.component.js +92 -62
  22. package/dist/components/blocks/URefBlock.component.d.ts +17 -0
  23. package/dist/components/blocks/URefBlock.component.js +73 -0
  24. package/dist/components/blocks/URefBlock.d.ts +7 -0
  25. package/dist/components/blocks/URefBlock.js +5 -0
  26. package/dist/components/blocks/URefBlock.styles.d.ts +1 -0
  27. package/dist/components/blocks/URefBlock.styles.js +75 -0
  28. package/dist/components/blocks/UTableBlock.component.d.ts +49 -0
  29. package/dist/components/blocks/UTableBlock.component.js +228 -0
  30. package/dist/components/blocks/UTableBlock.d.ts +7 -0
  31. package/dist/components/blocks/UTableBlock.js +5 -0
  32. package/dist/components/blocks/UTableBlock.styles.d.ts +1 -0
  33. package/dist/components/blocks/UTableBlock.styles.js +134 -0
  34. package/dist/components/blocks/UTextBlock.component.d.ts +3 -3
  35. package/dist/components/blocks/UTextBlock.component.js +2 -2
  36. package/dist/components/blocks/UThinkBlock.component.d.ts +3 -3
  37. package/dist/components/blocks/UThinkBlock.component.js +2 -2
  38. package/dist/components/blocks/UToolBlock.component.d.ts +3 -3
  39. package/dist/components/blocks/UToolBlock.component.js +2 -2
  40. package/dist/components/buttons/UAttachButton.component.d.ts +3 -3
  41. package/dist/components/buttons/UAttachButton.component.js +2 -2
  42. package/dist/components/buttons/UCopyButton.component.d.ts +3 -3
  43. package/dist/components/buttons/UCopyButton.component.js +2 -2
  44. package/dist/components/buttons/UReportButton.component.d.ts +3 -3
  45. package/dist/components/buttons/UReportButton.component.js +2 -2
  46. package/dist/components/buttons/URetryButton.component.d.ts +3 -3
  47. package/dist/components/buttons/URetryButton.component.js +2 -2
  48. package/dist/components/buttons/UShareButton.component.d.ts +3 -3
  49. package/dist/components/buttons/UShareButton.component.js +2 -2
  50. package/dist/components/buttons/UVoteButton.component.d.ts +3 -3
  51. package/dist/components/buttons/UVoteButton.component.js +7 -4
  52. package/dist/components/message/UMessage.component.d.ts +7 -7
  53. package/dist/components/message/UMessage.component.js +16 -44
  54. package/dist/components/message/UMessage.styles.js +38 -11
  55. package/dist/components/prompt/UPrompt.component.d.ts +3 -3
  56. package/dist/components/prompt/UPrompt.component.js +2 -2
  57. package/dist/components/prompt/UPrompt.styles.js +28 -0
  58. package/dist/components/references/URefCard.component.d.ts +12 -7
  59. package/dist/components/references/URefCard.component.js +25 -12
  60. package/dist/components/references/URefCardGroup.component.d.ts +4 -3
  61. package/dist/components/references/URefCardGroup.component.js +3 -3
  62. package/dist/components/references/URefTag.component.d.ts +6 -4
  63. package/dist/components/references/URefTag.component.js +12 -7
  64. package/dist/components/widgets/UChartWidget.component.d.ts +36 -0
  65. package/dist/components/widgets/UChartWidget.component.js +180 -0
  66. package/dist/components/widgets/UChartWidget.d.ts +7 -0
  67. package/dist/components/widgets/UChartWidget.js +5 -0
  68. package/dist/components/widgets/UChartWidget.styles.d.ts +1 -0
  69. package/dist/components/widgets/UChartWidget.styles.js +86 -0
  70. package/dist/components/widgets/UImagesWidget.component.d.ts +30 -0
  71. package/dist/components/widgets/UImagesWidget.component.js +164 -0
  72. package/dist/components/widgets/UImagesWidget.d.ts +7 -0
  73. package/dist/components/widgets/UImagesWidget.js +5 -0
  74. package/dist/components/widgets/UImagesWidget.styles.d.ts +1 -0
  75. package/dist/components/widgets/UImagesWidget.styles.js +218 -0
  76. package/dist/components/widgets/UMapWidget.component.d.ts +20 -0
  77. package/dist/components/widgets/UMapWidget.component.js +65 -0
  78. package/dist/components/widgets/UMapWidget.d.ts +7 -0
  79. package/dist/components/widgets/UMapWidget.js +5 -0
  80. package/dist/components/widgets/UMapWidget.styles.d.ts +1 -0
  81. package/dist/components/widgets/UMapWidget.styles.js +47 -0
  82. package/dist/components/widgets/UVideoWidget.component.d.ts +21 -0
  83. package/dist/components/widgets/UVideoWidget.component.js +106 -0
  84. package/dist/components/widgets/UVideoWidget.d.ts +7 -0
  85. package/dist/components/widgets/UVideoWidget.js +5 -0
  86. package/dist/components/widgets/UVideoWidget.styles.d.ts +1 -0
  87. package/dist/components/widgets/UVideoWidget.styles.js +36 -0
  88. package/dist/components/widgets/UWidget.component.d.ts +43 -0
  89. package/dist/components/widgets/UWidget.component.js +140 -0
  90. package/dist/components/widgets/UWidget.d.ts +7 -0
  91. package/dist/components/widgets/UWidget.js +5 -0
  92. package/dist/components/widgets/UWidget.styles.d.ts +1 -0
  93. package/dist/components/widgets/UWidget.styles.js +33 -0
  94. package/dist/index.d.ts +15 -2
  95. package/dist/index.js +32 -12
  96. package/dist/types/Actions.d.ts +24 -0
  97. package/dist/types/Actions.js +34 -0
  98. package/dist/types/BlockItem.d.ts +41 -4
  99. package/dist/types/JsonSchema.d.ts +59 -0
  100. package/dist/types/{BlockReference.d.ts → References.d.ts} +6 -10
  101. package/dist/types/Widgets.d.ts +34 -0
  102. package/dist/types/Widgets.js +115 -0
  103. package/dist/utilities/ActionPromptBuilder.d.ts +40 -0
  104. package/dist/utilities/ActionPromptBuilder.js +93 -0
  105. package/dist/utilities/WidgetPromptBuilder.d.ts +28 -0
  106. package/dist/utilities/WidgetPromptBuilder.js +87 -0
  107. package/package.json +13 -13
  108. package/dist/components/loaders/UDotLoader.component.d.ts +0 -9
  109. package/dist/components/loaders/UDotLoader.component.js +0 -23
  110. package/dist/components/loaders/UDotLoader.d.ts +0 -7
  111. package/dist/components/loaders/UDotLoader.js +0 -5
  112. package/dist/components/loaders/UDotLoader.styles.js +0 -50
  113. /package/dist/components/{loaders/UDotLoader.styles.d.ts → actions/UQuestionAction.styles.d.ts} +0 -0
@@ -0,0 +1,140 @@
1
+ import { html, nothing } from 'lit';
2
+ import { property, state } from 'lit/decorators.js';
3
+ import { UJsonElement } from '@iyulab/components/dist/components/UJsonElement.js';
4
+ import { USkeleton } from '@iyulab/components/dist/components/skeleton/USkeleton.component.js';
5
+ import { styles } from './UWidget.styles.js';
6
+
7
+ var __defProp = Object.defineProperty;
8
+ var __decorateClass = (decorators, target, key, kind) => {
9
+ var result = void 0 ;
10
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
11
+ if (decorator = decorators[i])
12
+ result = (decorator(target, key, result) ) || result;
13
+ if (result) __defProp(target, key, result);
14
+ return result;
15
+ };
16
+ const DEFAULT_BLACKLIST = ["innerHTML", "outerHTML", "textContent", "innerText", "outerText", "srcdoc"];
17
+ class UWidget extends UJsonElement {
18
+ constructor() {
19
+ super(...arguments);
20
+ this.loading = false;
21
+ this.blacklist = DEFAULT_BLACKLIST;
22
+ this.element = null;
23
+ }
24
+ static {
25
+ this.styles = [super.styles, styles];
26
+ }
27
+ static {
28
+ this.dependencies = {
29
+ "u-skeleton": USkeleton
30
+ };
31
+ }
32
+ willUpdate(changedProperties) {
33
+ super.willUpdate(changedProperties);
34
+ if (changedProperties.has("tag")) {
35
+ this.updateElement(this.tag);
36
+ }
37
+ if (changedProperties.has("properties") && this.element) {
38
+ this.updateProperties(this.element, this.properties);
39
+ }
40
+ if (changedProperties.has("blacklist") && this.element && this.properties) {
41
+ this.updateProperties(this.element, this.properties);
42
+ }
43
+ }
44
+ render() {
45
+ if (this.loading === true) {
46
+ return html`
47
+ <div class="sk-container">
48
+ <div class="sk-card">
49
+ <u-skeleton effect="shimmer" width="100%" height="5em" shape="default"></u-skeleton>
50
+ <u-skeleton effect="shimmer" width="80%" height="0.8em" shape="rounded"></u-skeleton>
51
+ <u-skeleton effect="shimmer" width="40%" height="0.75em" shape="rounded"></u-skeleton>
52
+ </div>
53
+ <div class="sk-doc">
54
+ <u-skeleton effect="shimmer" width="40%" height="0.75em" shape="rounded"></u-skeleton>
55
+ <u-skeleton effect="shimmer" width="80%" height="0.75em" shape="rounded"></u-skeleton>
56
+ <u-skeleton effect="shimmer" width="60%" height="0.8em" shape="rounded"></u-skeleton>
57
+ <u-skeleton effect="shimmer" width="100%" height="0.8em" shape="rounded"></u-skeleton>
58
+ <u-skeleton effect="shimmer" width="80%" height="0.8em" shape="rounded"></u-skeleton>
59
+ </div>
60
+ </div>`;
61
+ }
62
+ if (this.element != null) {
63
+ return this.element;
64
+ }
65
+ return nothing;
66
+ }
67
+ /**
68
+ * `loading`이 `true`인 경우, 에러 UI로 대체하지 않습니다.
69
+ */
70
+ async error(error) {
71
+ if (this.loading) return;
72
+ await super.error(error);
73
+ }
74
+ /**
75
+ * `tag` 프로퍼티에 등록된 커스텀 엘리먼트를 렌더링하는 컴포넌트입니다.
76
+ * `tag`가 변경될 때마다 등록된 커스텀 엘리먼트를 새로 생성하여 렌더링합니다.
77
+ * `tag`가 유효하지 않거나 등록된 커스텀 엘리먼트가 아닌 경우, 에러 처리합니다.
78
+ */
79
+ updateElement(tag) {
80
+ tag = tag?.trim();
81
+ if (!tag) {
82
+ this.element = null;
83
+ void super.error(new Error("Tag is required"));
84
+ return;
85
+ }
86
+ if (!customElements.get(tag)) {
87
+ this.element = null;
88
+ void super.error(new Error(`Unknown tag: ${tag}`));
89
+ return;
90
+ }
91
+ this.element = document.createElement(tag);
92
+ }
93
+ /**
94
+ * `properties` 객체의 키가 렌더링된 엘리먼트의 프로퍼티 이름과 일치하면 자동으로 할당됩니다.
95
+ * `properties` 객체에 위험한 프로퍼티가 포함되어 있는지 검증하여, 유효한 경우에만 할당합니다.
96
+ * 할당 중 오류가 발생한 경우, 에러 처리합니다.
97
+ */
98
+ updateProperties(element, props) {
99
+ if (this.validateProperties(props)) {
100
+ try {
101
+ Object.assign(element, props);
102
+ } catch (error) {
103
+ void super.error(error);
104
+ }
105
+ } else {
106
+ void super.error(new Error(`Not allowed properties: ${JSON.stringify(props)}`));
107
+ }
108
+ }
109
+ /**
110
+ * `properties` 객체에 위험한 프로퍼티가 포함되어 있는지 검증합니다.
111
+ * DOM 조작이나 이벤트 핸들러로 악용될 수 있는 프로퍼티를 최소한으로 차단합니다.
112
+ */
113
+ validateProperties(props) {
114
+ if (typeof props !== "object" || props === null || Array.isArray(props)) {
115
+ return false;
116
+ }
117
+ const obj = props;
118
+ for (const key of Object.keys(obj)) {
119
+ if (this.blacklist.includes(key)) return false;
120
+ }
121
+ return true;
122
+ }
123
+ }
124
+ __decorateClass([
125
+ property({ type: Boolean, reflect: true })
126
+ ], UWidget.prototype, "loading");
127
+ __decorateClass([
128
+ property({ type: String })
129
+ ], UWidget.prototype, "tag");
130
+ __decorateClass([
131
+ property({ type: Object })
132
+ ], UWidget.prototype, "properties");
133
+ __decorateClass([
134
+ property({ type: Array })
135
+ ], UWidget.prototype, "blacklist");
136
+ __decorateClass([
137
+ state()
138
+ ], UWidget.prototype, "element");
139
+
140
+ export { UWidget };
@@ -0,0 +1,7 @@
1
+ import { UWidget } from './UWidget.component.js';
2
+ declare global {
3
+ interface HTMLElementTagNameMap {
4
+ "u-widget": UWidget;
5
+ }
6
+ }
7
+ export { UWidget };
@@ -0,0 +1,5 @@
1
+ import { UWidget } from './UWidget.component.js';
2
+
3
+ UWidget.define("u-widget");
4
+
5
+ export { UWidget };
@@ -0,0 +1 @@
1
+ export declare const styles: import('lit').CSSResult;
@@ -0,0 +1,33 @@
1
+ import { css } from 'lit';
2
+
3
+ const styles = css`
4
+ :host {
5
+ display: contents;
6
+ }
7
+
8
+ /* ── 스켈레톤: 카드(좌) + 문서(우) ── */
9
+ .sk-container {
10
+ display: flex;
11
+ flex-direction: row;
12
+ align-items: stretch;
13
+ gap: 1em;
14
+ margin: 0.75em 0;
15
+ width: 100%;
16
+ }
17
+
18
+ .sk-card {
19
+ flex: 0 0 40%;
20
+ display: flex;
21
+ flex-direction: column;
22
+ gap: 0.55em;
23
+ }
24
+
25
+ .sk-doc {
26
+ flex: 1;
27
+ display: flex;
28
+ flex-direction: column;
29
+ justify-content: space-between;
30
+ }
31
+ `;
32
+
33
+ export { styles };
package/dist/index.d.ts CHANGED
@@ -1,23 +1,36 @@
1
1
  export * from './components/blocks/UCodeBlock.js';
2
+ export * from './components/blocks/UFilesBlock.js';
2
3
  export * from './components/blocks/UJsonBlock.js';
3
4
  export * from './components/blocks/UMarkedBlock.js';
4
5
  export * from './components/blocks/UTextBlock.js';
5
6
  export * from './components/blocks/UThinkBlock.js';
6
7
  export * from './components/blocks/UToolBlock.js';
8
+ export * from './components/blocks/URefBlock.js';
9
+ export * from './components/blocks/UTableBlock.js';
7
10
  export * from './components/buttons/UAttachButton.js';
8
11
  export * from './components/buttons/UCopyButton.js';
9
12
  export * from './components/buttons/UVoteButton.js';
10
13
  export * from './components/buttons/UReportButton.js';
11
14
  export * from './components/buttons/URetryButton.js';
12
15
  export * from './components/buttons/UShareButton.js';
13
- export * from './components/loaders/UDotLoader.js';
14
16
  export * from './components/message/UMessage.js';
15
17
  export * from './components/prompt/UPrompt.js';
16
18
  export * from './components/references/URefTag.js';
17
19
  export * from './components/references/URefCard.js';
18
20
  export * from './components/references/URefCardGroup.js';
21
+ export * from './components/actions/UQuestionAction.js';
22
+ export * from './components/widgets/UImagesWidget.js';
23
+ export * from './components/widgets/UVideoWidget.js';
24
+ export * from './components/widgets/UMapWidget.js';
25
+ export * from './components/widgets/UChartWidget.js';
26
+ export * from './components/widgets/UWidget.js';
19
27
  export type * from './types/BlockItem';
20
- export type * from './types/BlockReference';
21
28
  export type * from './types/JsonNode';
29
+ export type * from './types/JsonSchema';
30
+ export type * from './types/References';
31
+ export * from './types/Actions';
32
+ export * from './types/Widgets';
22
33
  export type * from './events/UCancelEvent';
23
34
  export type * from './events/USubmitEvent';
35
+ export * from './utilities/ActionPromptBuilder.js';
36
+ export * from './utilities/WidgetPromptBuilder.js';
package/dist/index.js CHANGED
@@ -1,36 +1,56 @@
1
1
  import './components/blocks/UCodeBlock.js';
2
+ import './components/blocks/UFilesBlock.js';
2
3
  import './components/blocks/UJsonBlock.js';
3
4
  import './components/blocks/UMarkedBlock.js';
4
5
  import './components/blocks/UTextBlock.js';
5
6
  import './components/blocks/UThinkBlock.js';
6
7
  import './components/blocks/UToolBlock.js';
8
+ import './components/blocks/URefBlock.js';
9
+ import './components/blocks/UTableBlock.js';
7
10
  import './components/buttons/UAttachButton.js';
8
11
  import './components/buttons/UCopyButton.js';
9
12
  import './components/buttons/UVoteButton.js';
10
13
  import './components/buttons/UReportButton.js';
11
14
  import './components/buttons/URetryButton.js';
12
15
  import './components/buttons/UShareButton.js';
13
- import './components/loaders/UDotLoader.js';
14
16
  import './components/message/UMessage.js';
15
17
  import './components/prompt/UPrompt.js';
16
18
  import './components/references/URefTag.js';
17
19
  import './components/references/URefCard.js';
18
20
  import './components/references/URefCardGroup.js';
21
+ import './components/actions/UQuestionAction.js';
22
+ import './components/widgets/UImagesWidget.js';
23
+ import './components/widgets/UVideoWidget.js';
24
+ import './components/widgets/UMapWidget.js';
25
+ import './components/widgets/UChartWidget.js';
26
+ import './components/widgets/UWidget.js';
27
+ export { PRESET_ACTION_DEFINITIONS, PRESET_ACTION_LIST, PresetAction } from './types/Actions.js';
28
+ export { PRESET_WIDGET_DEFINITIONS, PRESET_WIDGET_LIST, PresetWidget } from './types/Widgets.js';
29
+ export { ActionPromptBuilder } from './utilities/ActionPromptBuilder.js';
30
+ export { WidgetPromptBuilder } from './utilities/WidgetPromptBuilder.js';
31
+ export { UAttachButton } from './components/buttons/UAttachButton.component.js';
32
+ export { UChartWidget } from './components/widgets/UChartWidget.component.js';
19
33
  export { UCodeBlock } from './components/blocks/UCodeBlock.component.js';
34
+ export { UCopyButton } from './components/buttons/UCopyButton.component.js';
35
+ export { UFilesBlock } from './components/blocks/UFilesBlock.component.js';
36
+ export { UImagesWidget } from './components/widgets/UImagesWidget.component.js';
20
37
  export { UJsonBlock } from './components/blocks/UJsonBlock.component.js';
38
+ export { UMapWidget } from './components/widgets/UMapWidget.component.js';
21
39
  export { UMarkedBlock } from './components/blocks/UMarkedBlock.component.js';
22
- export { UTextBlock } from './components/blocks/UTextBlock.component.js';
23
- export { UThinkBlock } from './components/blocks/UThinkBlock.component.js';
24
- export { UToolBlock } from './components/blocks/UToolBlock.component.js';
25
- export { UAttachButton } from './components/buttons/UAttachButton.component.js';
26
- export { UCopyButton } from './components/buttons/UCopyButton.component.js';
27
- export { UVoteButton } from './components/buttons/UVoteButton.component.js';
28
- export { UReportButton } from './components/buttons/UReportButton.component.js';
29
- export { URetryButton } from './components/buttons/URetryButton.component.js';
30
- export { UShareButton } from './components/buttons/UShareButton.component.js';
31
- export { UDotLoader } from './components/loaders/UDotLoader.component.js';
32
40
  export { UMessage } from './components/message/UMessage.component.js';
33
41
  export { UPrompt } from './components/prompt/UPrompt.component.js';
34
- export { URefTag } from './components/references/URefTag.component.js';
42
+ export { UQuestionAction } from './components/actions/UQuestionAction.component.js';
43
+ export { URefBlock } from './components/blocks/URefBlock.component.js';
35
44
  export { URefCard } from './components/references/URefCard.component.js';
36
45
  export { URefCardGroup } from './components/references/URefCardGroup.component.js';
46
+ export { URefTag } from './components/references/URefTag.component.js';
47
+ export { UReportButton } from './components/buttons/UReportButton.component.js';
48
+ export { URetryButton } from './components/buttons/URetryButton.component.js';
49
+ export { UShareButton } from './components/buttons/UShareButton.component.js';
50
+ export { UTableBlock } from './components/blocks/UTableBlock.component.js';
51
+ export { UTextBlock } from './components/blocks/UTextBlock.component.js';
52
+ export { UThinkBlock } from './components/blocks/UThinkBlock.component.js';
53
+ export { UToolBlock } from './components/blocks/UToolBlock.component.js';
54
+ export { UVideoWidget } from './components/widgets/UVideoWidget.component.js';
55
+ export { UVoteButton } from './components/buttons/UVoteButton.component.js';
56
+ export { UWidget } from './components/widgets/UWidget.component.js';
@@ -0,0 +1,24 @@
1
+ import { JsonSchema } from '../types/JsonSchema.js';
2
+ /** LLM에서 action-json 블록으로 출력되는 구조입니다.*/
3
+ export interface ActionSchema {
4
+ type: string;
5
+ properties?: Record<string, unknown>;
6
+ }
7
+ /** Action 정의 구조체 */
8
+ export interface ActionDefinition {
9
+ /** action 식별자 (action-json의 "type" 필드와 매칭) */
10
+ type: string;
11
+ /** LLM용 설명 */
12
+ description: string;
13
+ /** LLM용 속성 스키마 */
14
+ properties?: Record<string, JsonSchema>;
15
+ }
16
+ /** 프리셋 Action 비트 플래그 */
17
+ export declare enum PresetAction {
18
+ Questions = 1,
19
+ All = 1
20
+ }
21
+ /** 프리셋 Action 목록 (비트 플래그 순서대로) */
22
+ export declare const PRESET_ACTION_LIST: readonly [PresetAction];
23
+ /** 프리셋 Action 정의 매핑 */
24
+ export declare const PRESET_ACTION_DEFINITIONS: Map<PresetAction, ActionDefinition>;
@@ -0,0 +1,34 @@
1
+ var PresetAction = /* @__PURE__ */ ((PresetAction2) => {
2
+ PresetAction2[PresetAction2["Questions"] = 1] = "Questions";
3
+ PresetAction2[PresetAction2["All"] = 1 /* Questions */] = "All";
4
+ return PresetAction2;
5
+ })(PresetAction || {});
6
+ const PRESET_ACTION_LIST = [
7
+ 1 /* Questions */
8
+ ];
9
+ const PRESET_ACTION_DEFINITIONS = /* @__PURE__ */ new Map([
10
+ [
11
+ 1 /* Questions */,
12
+ {
13
+ type: "question",
14
+ description: "Present a question to the user with clickable choices",
15
+ properties: {
16
+ question: {
17
+ type: "string",
18
+ description: 'Optional question text displayed above the choices (e.g. "What would you like to explore?")',
19
+ examples: ["What would you like to do next?"]
20
+ },
21
+ choices: {
22
+ type: "array",
23
+ items: { type: "string" },
24
+ minItems: 1,
25
+ maxItems: 5,
26
+ description: "Clickable choice buttons (1–5 items)",
27
+ examples: [["What are the main differences?", "Can you show me an example?", "What should I learn next?"]]
28
+ }
29
+ }
30
+ }
31
+ ]
32
+ ]);
33
+
34
+ export { PRESET_ACTION_DEFINITIONS, PRESET_ACTION_LIST, PresetAction };
@@ -1,4 +1,4 @@
1
- import { BlockReference } from './BlockReference';
1
+ import { ReferenceSource, ReferenceCitation } from './References';
2
2
  import { JsonNode } from './JsonNode';
3
3
  /** LLM 추론 텍스트 블록입니다. */
4
4
  export interface ThinkingBlockItem {
@@ -17,8 +17,8 @@ export interface MarkdownBlockItem {
17
17
  type: "markdown";
18
18
  /** 마크다운 텍스트 */
19
19
  value?: string;
20
- /** 마크다운 내 인용 출처들 */
21
- refs?: BlockReference[];
20
+ /** 마크다운 내 인용 정보 */
21
+ refs?: ReferenceCitation[];
22
22
  }
23
23
  /** 툴 사용 블록입니다. */
24
24
  export interface ToolBlockItem {
@@ -30,7 +30,44 @@ export interface ToolBlockItem {
30
30
  /** 도구 블록 출력값(json) */
31
31
  output?: JsonNode;
32
32
  }
33
+ /** 출처 정보 */
34
+ export interface ReferenceBlockItem {
35
+ type: "reference";
36
+ /** 출처 목록 */
37
+ sources: ReferenceSource[];
38
+ }
39
+ /** 파일 첨부 블록입니다. */
40
+ export type FileUploadStatus = {
41
+ phase: "uploading";
42
+ progress?: number;
43
+ } | {
44
+ phase: "done";
45
+ } | {
46
+ phase: "error";
47
+ message?: string;
48
+ };
49
+ /** 파일 하나의 데이터 구조입니다. */
50
+ export interface FileItem {
51
+ /** 파일 ID (옵션) */
52
+ fileId?: string;
53
+ /** 파일 이름 */
54
+ name: string;
55
+ /** MIME 타입 (예: "image/png", "application/pdf") */
56
+ type?: string;
57
+ /** 파일 크기 (bytes) */
58
+ size?: number;
59
+ /** 파일 업로드 상태 */
60
+ upload?: FileUploadStatus;
61
+ /** 다운로드 URL */
62
+ downloadUrl?: string;
63
+ }
64
+ /** 복수 파일 첨부 블록입니다. */
65
+ export interface FilesBlockItem {
66
+ type: "files";
67
+ /** 파일 목록 */
68
+ files: FileItem[];
69
+ }
33
70
  /**
34
71
  * 타입별 메시지 컨텐츠 아이템
35
72
  */
36
- export type BlockItem = (ThinkingBlockItem | TextBlockItem | MarkdownBlockItem | ToolBlockItem);
73
+ export type BlockItem = (ThinkingBlockItem | TextBlockItem | MarkdownBlockItem | ToolBlockItem | ReferenceBlockItem | FilesBlockItem);
@@ -0,0 +1,59 @@
1
+ /**
2
+ * 위젯 정의용 JSON Schema 타입
3
+ *
4
+ * 위젯의 속성을 LLM에게 설명하기 위한 최소한의 스키마 정의만 포함.
5
+ * 복잡한 검증 기능이나 메타 정보는 제외하여 단순화함.
6
+ *
7
+ * 제외된 기능들:
8
+ * - $schema, $id 등 메타 정보 (위젯 정의에 불필요)
9
+ * - pattern, format 등 고급 검증 (LLM이 직접 생성하므로 불필요)
10
+ * - allOf, anyOf 등 조합 스키마 (복잡도 증가, 위젯에 과도함)
11
+ * - 조건부 스키마 if/then/else (위젯 속성에 불필요)
12
+ * - 고급 object/array 검증들 (단순한 구조만으로 충분)
13
+ */
14
+ export interface BaseJsonSchema {
15
+ /** 속성에 대한 설명 (LLM용) */
16
+ description?: string;
17
+ /** 기본값 */
18
+ default?: any;
19
+ /** 허용 가능한 값들 (제한된 선택지) */
20
+ enum?: any[];
21
+ /** 예시 값들 (LLM이 이해하기 쉽도록) */
22
+ examples?: any[];
23
+ }
24
+ export interface BooleanJsonSchema extends BaseJsonSchema {
25
+ type: 'boolean';
26
+ }
27
+ export interface StringJsonSchema extends BaseJsonSchema {
28
+ type: 'string';
29
+ /** 최소 문자열 길이 */
30
+ minLength?: number;
31
+ /** 최대 문자열 길이 */
32
+ maxLength?: number;
33
+ }
34
+ export interface NumberJsonSchema extends BaseJsonSchema {
35
+ type: 'number' | 'integer';
36
+ /** 최솟값 */
37
+ minimum?: number;
38
+ /** 최댓값 */
39
+ maximum?: number;
40
+ }
41
+ export interface ArrayJsonSchema extends BaseJsonSchema {
42
+ type: 'array';
43
+ /** 배열 아이템의 스키마 */
44
+ items?: JsonSchema;
45
+ /** 최소 아이템 개수 */
46
+ minItems?: number;
47
+ /** 최대 아이템 개수 */
48
+ maxItems?: number;
49
+ }
50
+ export interface ObjectJsonSchema extends BaseJsonSchema {
51
+ type: 'object';
52
+ /** 객체의 속성들 */
53
+ properties?: Record<string, JsonSchema>;
54
+ /** 필수 속성 목록 */
55
+ required?: string[];
56
+ /** 정의되지 않은 추가 속성 허용 여부 */
57
+ additionalProperties?: boolean;
58
+ }
59
+ export type JsonSchema = BooleanJsonSchema | StringJsonSchema | NumberJsonSchema | ArrayJsonSchema | ObjectJsonSchema;
@@ -1,11 +1,11 @@
1
1
  /**
2
- * 블록 참조에서 사용되는 참조 내용입니다.
2
+ * 참조에서 사용되는 원본 내용입니다.
3
3
  */
4
4
  export interface ReferenceSource {
5
5
  /** 자료의 종류 입니다. */
6
6
  type: 'web' | 'document';
7
7
  /** 참조 링크 URL */
8
- url: string;
8
+ url?: string;
9
9
  /** 제목 */
10
10
  title?: string;
11
11
  /** 발췌 내용 */
@@ -14,19 +14,15 @@ export interface ReferenceSource {
14
14
  tags?: string[];
15
15
  }
16
16
  /**
17
- * 텍스트 컨텐츠 내 인용 참조 블록
17
+ * 본문참조 인용 정보입니다.
18
18
  */
19
- export interface TextBlockReference {
20
- /** 인용 출처 이름 */
21
- name: string;
19
+ export interface ReferenceCitation {
22
20
  /** 참조 텍스트 시작 위치 (문자 인덱스) */
23
21
  startIndex: number;
24
22
  /** 참조 텍스트 종료 위치 (문자 인덱스) */
25
23
  endIndex: number;
24
+ /** 본문에 표시될 참조 라벨 (예: [1], (Smith et al., 2023)) */
25
+ label?: string;
26
26
  /** 원본 참조 내용 */
27
27
  sources: ReferenceSource[];
28
28
  }
29
- /**
30
- * 메시지 컨텐츠 내에서 인용 참조 블록
31
- */
32
- export type BlockReference = TextBlockReference;
@@ -0,0 +1,34 @@
1
+ import { JsonSchema } from './JsonSchema.js';
2
+ /**
3
+ * 위젯을 정의하는 구조체
4
+ */
5
+ export interface WidgetDefinition {
6
+ /** 등록할 커스텀 엘리먼트 클래스 */
7
+ element: CustomElementConstructor;
8
+ /** 등록할 커스텀 엘리먼트 태그명 */
9
+ tag: string;
10
+ /** LLM용 설명 */
11
+ description: string;
12
+ /** LLM용 속성 스키마 */
13
+ properties?: Record<string, JsonSchema>;
14
+ /** 필수 속성 목록 */
15
+ required?: string[];
16
+ }
17
+ /**
18
+ * 프리셋 위젯 비트 플래그
19
+ */
20
+ export declare enum PresetWidget {
21
+ Images = 1,
22
+ Video = 2,
23
+ Map = 8,
24
+ Chart = 16,
25
+ All = 27
26
+ }
27
+ /**
28
+ * 전체 프리셋 위젯 플래그 목록
29
+ */
30
+ export declare const PRESET_WIDGET_LIST: readonly [PresetWidget.Images, PresetWidget.Video, PresetWidget.Map, PresetWidget.Chart];
31
+ /**
32
+ * 프리셋 위젯 정의
33
+ */
34
+ export declare const PRESET_WIDGET_DEFINITIONS: Map<PresetWidget, WidgetDefinition>;
@@ -0,0 +1,115 @@
1
+ import { UImagesWidget } from '../components/widgets/UImagesWidget.component.js';
2
+ import { UVideoWidget } from '../components/widgets/UVideoWidget.component.js';
3
+ import { UMapWidget } from '../components/widgets/UMapWidget.component.js';
4
+ import { UChartWidget } from '../components/widgets/UChartWidget.component.js';
5
+
6
+ var PresetWidget = /* @__PURE__ */ ((PresetWidget2) => {
7
+ PresetWidget2[PresetWidget2["Images"] = 1] = "Images";
8
+ PresetWidget2[PresetWidget2["Video"] = 2] = "Video";
9
+ PresetWidget2[PresetWidget2["Map"] = 8] = "Map";
10
+ PresetWidget2[PresetWidget2["Chart"] = 16] = "Chart";
11
+ PresetWidget2[PresetWidget2["All"] = 27] = "All";
12
+ return PresetWidget2;
13
+ })(PresetWidget || {});
14
+ const PRESET_WIDGET_LIST = [
15
+ 1 /* Images */,
16
+ 2 /* Video */,
17
+ 8 /* Map */,
18
+ 16 /* Chart */
19
+ ];
20
+ const PRESET_WIDGET_DEFINITIONS = /* @__PURE__ */ new Map([
21
+ [
22
+ 1 /* Images */,
23
+ {
24
+ element: UImagesWidget,
25
+ tag: "u-images-widget",
26
+ description: "Display multiple images in a scrollable gallery",
27
+ properties: {
28
+ items: {
29
+ type: "array",
30
+ items: {
31
+ type: "object",
32
+ properties: {
33
+ src: { type: "string", description: "Image URL" },
34
+ alt: { type: "string", description: "Alt text for accessibility" },
35
+ caption: { type: "string", description: "Image caption" }
36
+ },
37
+ required: ["src"]
38
+ },
39
+ minItems: 1,
40
+ description: "Array of image objects"
41
+ }
42
+ },
43
+ required: ["items"]
44
+ }
45
+ ],
46
+ [
47
+ 2 /* Video */,
48
+ {
49
+ element: UVideoWidget,
50
+ tag: "u-video-widget",
51
+ description: "Embed video from YouTube, Vimeo, or Others. Provide a direct video file URL or a platform URL.",
52
+ properties: {
53
+ src: { type: "string", description: "Video URL (YouTube, Vimeo, or direct video file URL)" },
54
+ poster: { type: "string", description: "Poster image URL" },
55
+ ratio: {
56
+ type: "string",
57
+ enum: ["16:9", "4:3", "1:1"],
58
+ default: "16:9",
59
+ description: "Video aspect ratio"
60
+ }
61
+ },
62
+ required: ["src"]
63
+ }
64
+ ],
65
+ [
66
+ 8 /* Map */,
67
+ {
68
+ element: UMapWidget,
69
+ tag: "u-map-widget",
70
+ description: "Display a map showing a single location",
71
+ properties: {
72
+ lat: { type: "number", description: "Latitude coordinate" },
73
+ lng: { type: "number", description: "Longitude coordinate" },
74
+ zoom: {
75
+ type: "integer",
76
+ minimum: 1,
77
+ maximum: 20,
78
+ default: 15,
79
+ description: "Map zoom level"
80
+ },
81
+ label: { type: "string", description: "Location title" },
82
+ description: { type: "string", description: "Location description" }
83
+ },
84
+ required: ["lat", "lng"]
85
+ }
86
+ ],
87
+ [
88
+ 16 /* Chart */,
89
+ {
90
+ element: UChartWidget,
91
+ tag: "u-chart-widget",
92
+ description: "Display charts using Chart.js v4 format. Use standard Chart.js configuration (type, data, options). The widget accepts the exact same structure as Chart.js - no conversion needed.",
93
+ properties: {
94
+ type: {
95
+ type: "string",
96
+ enum: ["bar", "line", "pie", "doughnut", "radar", "polarArea", "bubble", "scatter"],
97
+ description: "Chart.js chart type"
98
+ },
99
+ data: {
100
+ type: "object",
101
+ description: "Chart.js data configuration",
102
+ additionalProperties: true
103
+ },
104
+ options: {
105
+ type: "object",
106
+ description: "Chart.js options configuration (optional)",
107
+ additionalProperties: true
108
+ }
109
+ },
110
+ required: ["type", "data"]
111
+ }
112
+ ]
113
+ ]);
114
+
115
+ export { PRESET_WIDGET_DEFINITIONS, PRESET_WIDGET_LIST, PresetWidget };