@iyulab/chat-components 0.6.0 → 0.7.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 (211) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/README.md +15 -39
  3. package/dist/_virtual/{_@oxc-project_runtime@0.130.0/helpers → _@oxc-project_runtime@0.138.0/helpers/esm}/decorate.js +2 -2
  4. package/dist/_virtual/{_@oxc-project_runtime@0.130.0/helpers → _@oxc-project_runtime@0.138.0/helpers/esm}/decorateMetadata.js +2 -2
  5. package/dist/_virtual/_glob-assets_raw/alert-triangle-fill.svg.4cfc4305.js +4 -0
  6. package/dist/_virtual/_glob-assets_raw/arrows-sort.svg.dda43a85.js +4 -0
  7. package/dist/_virtual/_glob-assets_raw/code.svg.c69bc144.js +4 -0
  8. package/dist/_virtual/_glob-assets_raw/download.svg.bce82177.js +4 -0
  9. package/dist/_virtual/_glob-assets_raw/element-prompt.md.7047ffcc.js +4 -0
  10. package/dist/_virtual/_glob-assets_raw/external-link.svg.a9f7f02d.js +4 -0
  11. package/dist/_virtual/_glob-assets_raw/file-code.svg.0e706f93.js +4 -0
  12. package/dist/_virtual/_glob-assets_raw/file-music.svg.b9970203.js +4 -0
  13. package/dist/_virtual/_glob-assets_raw/file-spreadsheet.svg.8c03bdfa.js +4 -0
  14. package/dist/_virtual/_glob-assets_raw/file-text.svg.85bdd923.js +4 -0
  15. package/dist/_virtual/_glob-assets_raw/file-type-pdf.svg.bc12db6d.js +4 -0
  16. package/dist/_virtual/_glob-assets_raw/file-zip.svg.76dde660.js +4 -0
  17. package/dist/_virtual/_glob-assets_raw/file.svg.28f5d6f1.js +4 -0
  18. package/dist/_virtual/_glob-assets_raw/photo.svg.cc273cc1.js +4 -0
  19. package/dist/_virtual/_glob-assets_raw/player-stop-fill.svg.5378b752.js +4 -0
  20. package/dist/_virtual/_glob-assets_raw/send.svg.02326253.js +4 -0
  21. package/dist/_virtual/_glob-assets_raw/sort-ascending-letters.svg.14a3df67.js +4 -0
  22. package/dist/_virtual/_glob-assets_raw/sort-descending-letters.svg.3e03647c.js +4 -0
  23. package/dist/_virtual/_glob-assets_raw/video.svg.c183f03c.js +4 -0
  24. package/dist/_virtual/_glob-assets_raw/world.svg.cd9903c8.js +4 -0
  25. package/dist/components/UDataElement.d.ts +44 -0
  26. package/dist/components/UDataElement.js +76 -0
  27. package/dist/components/blocks/UCodeBlock.d.ts +0 -4
  28. package/dist/components/blocks/UCodeBlock.js +6 -12
  29. package/dist/components/{views/UView.d.ts → blocks/UElementBlock.d.ts} +18 -8
  30. package/dist/components/{views/UView.js → blocks/UElementBlock.js} +31 -21
  31. package/dist/components/{views/UView.styles.js → blocks/UElementBlock.styles.js} +1 -1
  32. package/dist/components/blocks/UFileBlock.d.ts +15 -5
  33. package/dist/components/blocks/UFileBlock.js +81 -68
  34. package/dist/components/blocks/UFileBlock.styles.js +86 -29
  35. package/dist/components/blocks/UMarkedBlock.d.ts +3 -1
  36. package/dist/components/blocks/UMarkedBlock.js +23 -18
  37. package/dist/components/blocks/URefBlock.js +2 -2
  38. package/dist/components/blocks/UTableBlock.d.ts +2 -2
  39. package/dist/components/blocks/UTableBlock.js +9 -8
  40. package/dist/components/blocks/UTableBlock.styles.js +1 -1
  41. package/dist/components/blocks/UTextBlock.d.ts +2 -0
  42. package/dist/components/blocks/UTextBlock.js +4 -5
  43. package/dist/components/message/UMessage.js +2 -2
  44. package/dist/components/prompt/UPrompt.d.ts +0 -5
  45. package/dist/components/prompt/UPrompt.js +18 -27
  46. package/dist/components/prompt/UPrompt.styles.js +9 -10
  47. package/dist/components/references/URefCard.d.ts +2 -2
  48. package/dist/components/references/URefCard.js +8 -7
  49. package/dist/components/references/URefCardGroup.js +2 -2
  50. package/dist/components/references/URefTag.js +5 -4
  51. package/dist/{components/views/UChartView.d.ts → components-extra/UChartBlock.d.ts} +4 -4
  52. package/dist/{components/views/UChartView.js → components-extra/UChartBlock.js} +22 -34
  53. package/dist/components-extra/UChartBlock.schema.d.ts +3 -0
  54. package/dist/components-extra/UChartBlock.schema.js +34 -0
  55. package/dist/{components/views/UChartView.styles.js → components-extra/UChartBlock.styles.js} +1 -1
  56. package/dist/{components/views/UImagesView.d.ts → components-extra/UImagesBlock.d.ts} +4 -4
  57. package/dist/{components/views/UImagesView.js → components-extra/UImagesBlock.js} +15 -15
  58. package/dist/components-extra/UImagesBlock.schema.d.ts +3 -0
  59. package/dist/components-extra/UImagesBlock.schema.js +31 -0
  60. package/dist/{components/views/UImagesView.styles.js → components-extra/UImagesBlock.styles.js} +5 -5
  61. package/dist/{components/views/UMapView.d.ts → components-extra/UMapBlock.d.ts} +4 -4
  62. package/dist/{components/views/UMapView.js → components-extra/UMapBlock.js} +18 -18
  63. package/dist/components-extra/UMapBlock.schema.d.ts +3 -0
  64. package/dist/components-extra/UMapBlock.schema.js +33 -0
  65. package/dist/{components/views/UMapView.styles.js → components-extra/UMapBlock.styles.js} +1 -1
  66. package/dist/{components/views/UVideoView.d.ts → components-extra/UVideoBlock.d.ts} +4 -4
  67. package/dist/{components/views/UVideoView.js → components-extra/UVideoBlock.js} +10 -10
  68. package/dist/components-extra/UVideoBlock.schema.d.ts +3 -0
  69. package/dist/components-extra/UVideoBlock.schema.js +28 -0
  70. package/dist/{components/views/UVideoView.styles.js → components-extra/UVideoBlock.styles.js} +1 -1
  71. package/dist/events/SendEvent.d.ts +0 -5
  72. package/dist/events/StopEvent.d.ts +0 -5
  73. package/dist/extra.d.ts +6 -0
  74. package/dist/extra.js +14 -0
  75. package/dist/index.d.ts +5 -17
  76. package/dist/index.js +6 -16
  77. package/dist/react/UCodeBlock.js +2 -2
  78. package/dist/react/UElementBlock.d.ts +9 -0
  79. package/dist/react/UElementBlock.js +10 -0
  80. package/dist/react/UFileBlock.js +2 -2
  81. package/dist/react/UImagesBlock.d.ts +9 -0
  82. package/dist/react/UImagesBlock.js +10 -0
  83. package/dist/react/UMapBlock.d.ts +9 -0
  84. package/dist/react/UMapBlock.js +10 -0
  85. package/dist/react/UMarkedBlock.js +2 -2
  86. package/dist/react/UMessage.js +2 -2
  87. package/dist/react/UPrompt.js +2 -2
  88. package/dist/react/URefBlock.js +2 -2
  89. package/dist/react/URefCard.js +2 -2
  90. package/dist/react/URefCardGroup.js +2 -2
  91. package/dist/react/URefTag.js +2 -2
  92. package/dist/react/UTableBlock.js +2 -2
  93. package/dist/react/UTextBlock.d.ts +1 -0
  94. package/dist/react/UTextBlock.js +5 -3
  95. package/dist/react/UVideoBlock.d.ts +9 -0
  96. package/dist/react/UVideoBlock.js +10 -0
  97. package/dist/react/index.d.ts +4 -11
  98. package/dist/react/index.js +4 -11
  99. package/dist/types/BlockItem.d.ts +1 -24
  100. package/dist/types/{JsonSchema.d.ts → Schema.d.ts} +13 -0
  101. package/dist/utilities/HtmlBuilder.d.ts +28 -0
  102. package/dist/utilities/HtmlBuilder.js +41 -0
  103. package/dist/utilities/PromptBuilder.d.ts +21 -0
  104. package/dist/utilities/PromptBuilder.js +60 -0
  105. package/dist/utilities/icons.d.ts +1 -0
  106. package/dist/utilities/icons.js +52 -0
  107. package/dist/utilities/sanitizers.d.ts +35 -0
  108. package/dist/utilities/sanitizers.js +75 -0
  109. package/package.json +13 -18
  110. package/skills/iyulab-chat-components/SKILL.md +18 -33
  111. package/skills/iyulab-chat-components/references/components/{chart-view.md → chart-block.md} +16 -12
  112. package/skills/iyulab-chat-components/references/components/code-block.md +1 -5
  113. package/skills/iyulab-chat-components/references/components/element-block.md +57 -0
  114. package/skills/iyulab-chat-components/references/components/file-block.md +22 -25
  115. package/skills/iyulab-chat-components/references/components/{images-view.md → images-block.md} +10 -10
  116. package/skills/iyulab-chat-components/references/components/{map-view.md → map-block.md} +9 -9
  117. package/skills/iyulab-chat-components/references/components/marked-block.md +5 -4
  118. package/skills/iyulab-chat-components/references/components/message.md +1 -2
  119. package/skills/iyulab-chat-components/references/components/prompt.md +12 -21
  120. package/skills/iyulab-chat-components/references/components/{video-view.md → video-block.md} +10 -10
  121. package/skills/iyulab-chat-components/references/extra-system.md +95 -0
  122. package/skills/iyulab-chat-components/references/types.md +17 -31
  123. package/skills/iyulab-chat-components/references/usage.md +13 -81
  124. package/skills/iyulab-chat-components/references/utilities/html-builder.md +35 -0
  125. package/skills/iyulab-chat-components/references/utilities/prompt-builder.md +73 -0
  126. package/dist/_virtual/_glob-assets_raw/intent-prompt.md.1907474e.js +0 -4
  127. package/dist/_virtual/_glob-assets_raw/view-prompt.md.e0dbcffe.js +0 -4
  128. package/dist/chart.d.ts +0 -1
  129. package/dist/chart.js +0 -2
  130. package/dist/components/blocks/UJsonBlock.d.ts +0 -49
  131. package/dist/components/blocks/UJsonBlock.js +0 -130
  132. package/dist/components/blocks/UJsonBlock.styles.js +0 -115
  133. package/dist/components/blocks/UThinkBlock.d.ts +0 -35
  134. package/dist/components/blocks/UThinkBlock.js +0 -87
  135. package/dist/components/blocks/UThinkBlock.styles.js +0 -74
  136. package/dist/components/blocks/UToolBlock.d.ts +0 -24
  137. package/dist/components/blocks/UToolBlock.js +0 -70
  138. package/dist/components/blocks/UToolBlock.styles.js +0 -66
  139. package/dist/components/buttons/UAttachButton.d.ts +0 -26
  140. package/dist/components/buttons/UAttachButton.js +0 -63
  141. package/dist/components/buttons/UAttachButton.styles.js +0 -14
  142. package/dist/components/buttons/UCopyButton.d.ts +0 -24
  143. package/dist/components/buttons/UCopyButton.js +0 -59
  144. package/dist/components/buttons/UCopyButton.styles.js +0 -18
  145. package/dist/components/buttons/UVoteButton.d.ts +0 -19
  146. package/dist/components/buttons/UVoteButton.js +0 -64
  147. package/dist/components/buttons/UVoteButton.styles.d.ts +0 -1
  148. package/dist/components/buttons/UVoteButton.styles.js +0 -19
  149. package/dist/components/intents/UQuestionIntent.d.ts +0 -22
  150. package/dist/components/intents/UQuestionIntent.js +0 -41
  151. package/dist/components/intents/UQuestionIntent.styles.d.ts +0 -1
  152. package/dist/components/intents/UQuestionIntent.styles.js +0 -43
  153. package/dist/components/views/UChartView.styles.d.ts +0 -1
  154. package/dist/components/views/UImagesView.styles.d.ts +0 -1
  155. package/dist/components/views/UMapView.styles.d.ts +0 -1
  156. package/dist/components/views/UVideoView.styles.d.ts +0 -1
  157. package/dist/components/views/UView.styles.d.ts +0 -1
  158. package/dist/events/AttachEvent.d.ts +0 -9
  159. package/dist/events/ChoiceEvent.d.ts +0 -9
  160. package/dist/react/UAttachButton.d.ts +0 -11
  161. package/dist/react/UAttachButton.js +0 -12
  162. package/dist/react/UCopyButton.d.ts +0 -9
  163. package/dist/react/UCopyButton.js +0 -10
  164. package/dist/react/UImagesView.d.ts +0 -9
  165. package/dist/react/UImagesView.js +0 -10
  166. package/dist/react/UJsonBlock.d.ts +0 -9
  167. package/dist/react/UJsonBlock.js +0 -10
  168. package/dist/react/UMapView.d.ts +0 -9
  169. package/dist/react/UMapView.js +0 -10
  170. package/dist/react/UQuestionIntent.d.ts +0 -11
  171. package/dist/react/UQuestionIntent.js +0 -12
  172. package/dist/react/UThinkBlock.d.ts +0 -9
  173. package/dist/react/UThinkBlock.js +0 -10
  174. package/dist/react/UToolBlock.d.ts +0 -9
  175. package/dist/react/UToolBlock.js +0 -10
  176. package/dist/react/UVideoView.d.ts +0 -9
  177. package/dist/react/UVideoView.js +0 -10
  178. package/dist/react/UView.d.ts +0 -9
  179. package/dist/react/UView.js +0 -10
  180. package/dist/react/UVoteButton.d.ts +0 -9
  181. package/dist/react/UVoteButton.js +0 -10
  182. package/dist/types/Intents.d.ts +0 -26
  183. package/dist/types/Intents.js +0 -30
  184. package/dist/types/JsonNode.d.ts +0 -20
  185. package/dist/types/Views.d.ts +0 -34
  186. package/dist/types/Views.js +0 -148
  187. package/dist/utilities/IntentPromptBuilder.d.ts +0 -40
  188. package/dist/utilities/IntentPromptBuilder.js +0 -95
  189. package/dist/utilities/ViewPromptBuilder.d.ts +0 -28
  190. package/dist/utilities/ViewPromptBuilder.js +0 -78
  191. package/dist/utilities/dom-agent/DOMAgent.d.ts +0 -74
  192. package/dist/utilities/dom-agent/DOMController.d.ts +0 -78
  193. package/dist/utilities/dom-agent/DOMPromptBuilder.d.ts +0 -54
  194. package/dist/utilities/dom-agent/DOMScanner.d.ts +0 -83
  195. package/dist/utilities/dom-agent/index.d.ts +0 -9
  196. package/dist/utilities/dom-agent/types.d.ts +0 -209
  197. package/skills/iyulab-chat-components/references/components/attach-button.md +0 -69
  198. package/skills/iyulab-chat-components/references/components/copy-button.md +0 -46
  199. package/skills/iyulab-chat-components/references/components/json-block.md +0 -41
  200. package/skills/iyulab-chat-components/references/components/question-intent.md +0 -75
  201. package/skills/iyulab-chat-components/references/components/think-block.md +0 -48
  202. package/skills/iyulab-chat-components/references/components/tool-block.md +0 -57
  203. package/skills/iyulab-chat-components/references/components/view.md +0 -51
  204. package/skills/iyulab-chat-components/references/components/vote-button.md +0 -60
  205. package/skills/iyulab-chat-components/references/utilities/intent-prompt-builder.md +0 -123
  206. package/skills/iyulab-chat-components/references/utilities/view-prompt-builder.md +0 -112
  207. /package/dist/components/{buttons/UCopyButton.styles.d.ts → blocks/UElementBlock.styles.d.ts} +0 -0
  208. /package/dist/{components/blocks/UJsonBlock.styles.d.ts → components-extra/UChartBlock.styles.d.ts} +0 -0
  209. /package/dist/{components/blocks/UThinkBlock.styles.d.ts → components-extra/UImagesBlock.styles.d.ts} +0 -0
  210. /package/dist/{components/blocks/UToolBlock.styles.d.ts → components-extra/UMapBlock.styles.d.ts} +0 -0
  211. /package/dist/{components/buttons/UAttachButton.styles.d.ts → components-extra/UVideoBlock.styles.d.ts} +0 -0
@@ -1,40 +0,0 @@
1
- import { PresetIntent, IntentDefinition, IntentSchema } from '../types/Intents.js';
2
- /**
3
- * Intent 등록, LLM 인스트럭션 빌드, 텍스트 추출을 통합 제공하는 유틸리티
4
- *
5
- * @example
6
- * IntentPromptBuilder.use(PresetIntent.All);
7
- * const prompt = IntentPromptBuilder.buildPrompt();
8
- * const [clean, templates] = IntentPromptBuilder.extractPrompt(llmText);
9
- */
10
- export declare class IntentPromptBuilder {
11
- private static _instance;
12
- private intents;
13
- /**
14
- * 싱글톤 인스턴스를 반환합니다. 최초 호출 시 인스턴스가 생성됩니다.
15
- */
16
- static get instance(): IntentPromptBuilder;
17
- /**
18
- * Intent 정의를 등록합니다. 같은 type이 이미 등록되어 있으면 에러를 던집니다.
19
- * @throws {Error} 같은 type의 intent가 이미 등록된 경우
20
- */
21
- add(definition: IntentDefinition): IntentPromptBuilder;
22
- /**
23
- * 미리 정의된 프리셋 Intent를 등록합니다.
24
- * @example
25
- * IntentPromptBuilder.use(PresetIntent.Questions);
26
- * IntentPromptBuilder.use(PresetIntent.All);
27
- */
28
- use(flags: PresetIntent): IntentPromptBuilder;
29
- /**
30
- * 등록된 intent들에 대한 LLM 시스템 프롬프트 인스트럭션을 생성합니다.
31
- */
32
- build(): string;
33
- /**
34
- * LLM 응답 텍스트에서 `intent-json` 코드블록을 추출합니다.
35
- *
36
- * @param value - LLM 응답 텍스트
37
- * @returns `[intents, rest]` — intents는 파싱된 JSON 객체 배열, rest는 블록이 제거된 나머지 텍스트
38
- */
39
- parse(value: string): [IntentSchema[], string];
40
- }
@@ -1,95 +0,0 @@
1
- import { PRESET_INTENT_DEFINITIONS, PRESET_INTENT_LIST } from "../types/Intents.js";
2
- import intent_prompt_md_default from "../_virtual/_glob-assets_raw/intent-prompt.md.1907474e.js";
3
- //#region src/utilities/IntentPromptBuilder.ts
4
- /**
5
- * Intent 등록, LLM 인스트럭션 빌드, 텍스트 추출을 통합 제공하는 유틸리티
6
- *
7
- * @example
8
- * IntentPromptBuilder.use(PresetIntent.All);
9
- * const prompt = IntentPromptBuilder.buildPrompt();
10
- * const [clean, templates] = IntentPromptBuilder.extractPrompt(llmText);
11
- */
12
- var IntentPromptBuilder = class IntentPromptBuilder {
13
- constructor() {
14
- this.intents = /* @__PURE__ */ new Map();
15
- }
16
- /**
17
- * 싱글톤 인스턴스를 반환합니다. 최초 호출 시 인스턴스가 생성됩니다.
18
- */
19
- static get instance() {
20
- if (!this._instance) this._instance = new IntentPromptBuilder();
21
- return this._instance;
22
- }
23
- /**
24
- * Intent 정의를 등록합니다. 같은 type이 이미 등록되어 있으면 에러를 던집니다.
25
- * @throws {Error} 같은 type의 intent가 이미 등록된 경우
26
- */
27
- add(definition) {
28
- if (this.intents.has(definition.type)) throw new Error(`Intent with type "${definition.type}" is already registered.`);
29
- this.intents.set(definition.type, definition);
30
- return this;
31
- }
32
- /**
33
- * 미리 정의된 프리셋 Intent를 등록합니다.
34
- * @example
35
- * IntentPromptBuilder.use(PresetIntent.Questions);
36
- * IntentPromptBuilder.use(PresetIntent.All);
37
- */
38
- use(flags) {
39
- for (const flag of PRESET_INTENT_LIST) if (flags & flag) {
40
- const definition = PRESET_INTENT_DEFINITIONS.get(flag);
41
- if (definition && !this.intents.has(definition.type)) this.intents.set(definition.type, definition);
42
- }
43
- return this;
44
- }
45
- /**
46
- * 등록된 intent들에 대한 LLM 시스템 프롬프트 인스트럭션을 생성합니다.
47
- */
48
- build() {
49
- if (this.intents.size === 0) return "";
50
- const docs = Array.from(this.intents.values()).map((def) => {
51
- return [
52
- `### ${def.type}`,
53
- "",
54
- "**JSON Schema:**",
55
- "```intent-json",
56
- JSON.stringify({
57
- type: "object",
58
- description: def.description,
59
- properties: {
60
- type: {
61
- type: "string",
62
- enum: [def.type]
63
- },
64
- properties: {
65
- type: "object",
66
- properties: def.properties || {},
67
- required: def.required || []
68
- }
69
- },
70
- required: ["type"]
71
- }, null, 2),
72
- "```"
73
- ].join("\n");
74
- }).join("\n\n---\n\n");
75
- return intent_prompt_md_default.replace("{{INTENT_DOCS}}", docs);
76
- }
77
- /**
78
- * LLM 응답 텍스트에서 `intent-json` 코드블록을 추출합니다.
79
- *
80
- * @param value - LLM 응답 텍스트
81
- * @returns `[intents, rest]` — intents는 파싱된 JSON 객체 배열, rest는 블록이 제거된 나머지 텍스트
82
- */
83
- parse(value) {
84
- const pattern = /```(?:intent-json)\s*([\s\S]*?)```/g;
85
- const intents = [];
86
- return [intents, value.replace(pattern, (_, json) => {
87
- try {
88
- intents.push(JSON.parse(json.trim()));
89
- } catch {}
90
- return "";
91
- }).trim()];
92
- }
93
- };
94
- //#endregion
95
- export { IntentPromptBuilder };
@@ -1,28 +0,0 @@
1
- import { PresetView, ViewDefinition } from '../types/Views.js';
2
- /**
3
- * 뷰 등록, LLM 인스트럭션 빌드, HTML 렌더링을 통합 제공하는 유틸리티
4
- */
5
- export declare class ViewPromptBuilder {
6
- private static _instance;
7
- private views;
8
- /**
9
- * 싱글톤 인스턴스를 반환합니다. 최초 호출 시 인스턴스가 생성됩니다.
10
- */
11
- static get instance(): ViewPromptBuilder;
12
- /**
13
- * 뷰 정의를 등록합니다. 같은 이름의 뷰이 이미 등록되어 있으면 에러를 던집니다.
14
- * @throws {Error} 같은 이름의 뷰이 이미 등록된 경우 또는 같은 태그의 커스텀 요소가 다른 클래스에 의해 정의된 경우
15
- */
16
- add(definition: ViewDefinition): ViewPromptBuilder;
17
- /**
18
- * 미리 정의된 프리셋 뷰을 사용합니다.
19
- * @example
20
- * ViewRegistry.use(View.Images | View.Chart);
21
- * ViewRegistry.use(View.All);
22
- */
23
- use(flags: PresetView): ViewPromptBuilder;
24
- /**
25
- * 등록된 뷰들에 대한 LLM 인스트럭션 문자열을 생성합니다.
26
- */
27
- build(): string;
28
- }
@@ -1,78 +0,0 @@
1
- import { PRESET_VIEW_DEFINITIONS, PRESET_VIEW_LIST } from "../types/Views.js";
2
- import view_prompt_md_default from "../_virtual/_glob-assets_raw/view-prompt.md.e0dbcffe.js";
3
- //#region src/utilities/ViewPromptBuilder.ts
4
- /**
5
- * 뷰 등록, LLM 인스트럭션 빌드, HTML 렌더링을 통합 제공하는 유틸리티
6
- */
7
- var ViewPromptBuilder = class ViewPromptBuilder {
8
- constructor() {
9
- this.views = /* @__PURE__ */ new Map();
10
- }
11
- /**
12
- * 싱글톤 인스턴스를 반환합니다. 최초 호출 시 인스턴스가 생성됩니다.
13
- */
14
- static get instance() {
15
- if (!this._instance) this._instance = new ViewPromptBuilder();
16
- return this._instance;
17
- }
18
- /**
19
- * 뷰 정의를 등록합니다. 같은 이름의 뷰이 이미 등록되어 있으면 에러를 던집니다.
20
- * @throws {Error} 같은 이름의 뷰이 이미 등록된 경우 또는 같은 태그의 커스텀 요소가 다른 클래스에 의해 정의된 경우
21
- */
22
- add(definition) {
23
- if (this.views.has(definition.tag)) throw new Error(`View with tag "${definition.tag}" is already registered.`);
24
- if (definition.element) {
25
- const constructor = customElements.get(definition.tag);
26
- if (constructor && constructor !== definition.element) throw new Error(`Custom element with tag "${definition.tag}" is already defined to a different class.`);
27
- }
28
- this.views.set(definition.tag, definition);
29
- return this;
30
- }
31
- /**
32
- * 미리 정의된 프리셋 뷰을 사용합니다.
33
- * @example
34
- * ViewRegistry.use(View.Images | View.Chart);
35
- * ViewRegistry.use(View.All);
36
- */
37
- use(flags) {
38
- for (const flag of PRESET_VIEW_LIST) if (flags & flag) {
39
- const definition = PRESET_VIEW_DEFINITIONS.get(flag);
40
- if (definition) this.add(definition);
41
- }
42
- return this;
43
- }
44
- /**
45
- * 등록된 뷰들에 대한 LLM 인스트럭션 문자열을 생성합니다.
46
- */
47
- build() {
48
- if (this.views.size === 0) return "";
49
- const docs = Array.from(this.views.values()).map((def) => {
50
- return [
51
- `### ${def.tag}`,
52
- "",
53
- "**JSON Schema:**",
54
- "```view-json",
55
- JSON.stringify({
56
- type: "object",
57
- description: def.description,
58
- properties: {
59
- tag: {
60
- type: "string",
61
- enum: [def.tag]
62
- },
63
- properties: {
64
- type: "object",
65
- properties: def.properties || {},
66
- required: def.required || []
67
- }
68
- },
69
- required: ["tag"]
70
- }, null, 2),
71
- "```"
72
- ].join("\n");
73
- }).join("\n\n---\n\n");
74
- return view_prompt_md_default.replace("{{VIEW_DOCS}}", docs);
75
- }
76
- };
77
- //#endregion
78
- export { ViewPromptBuilder };
@@ -1,74 +0,0 @@
1
- import { DOMScanner } from './DOMScanner.js';
2
- import { DOMController } from './DOMController.js';
3
- import { ScanResult, ScanOptions, DOMCommand, ExecutionResult, HistoryItem, AutomationOptions, LLMCallback, ScanDiff } from './types.js';
4
- /**
5
- * DOM Agent 통합 오케스트레이터
6
- * Scanner와 Controller를 조합하여 전체 워크플로우 관리
7
- */
8
- export declare class DOMAgent extends EventTarget {
9
- private scanner;
10
- private controller;
11
- private history;
12
- private currentScan;
13
- private lastScanRoot;
14
- constructor();
15
- /**
16
- * 초기 스캔 및 세션 시작
17
- */
18
- start(root?: Element | ShadowRoot, options?: ScanOptions & {
19
- includeScreenshot?: boolean;
20
- }): Promise<ScanResult>;
21
- /**
22
- * 명령 실행 후 재스캔
23
- */
24
- executeAndRescan(commands: DOMCommand | DOMCommand[], options?: ScanOptions & {
25
- includeScreenshot?: boolean;
26
- }): Promise<{
27
- execution: ExecutionResult[];
28
- scan: ScanResult;
29
- }>;
30
- /**
31
- * 현재 상태 가져오기
32
- */
33
- getCurrentState(): ScanResult | null;
34
- /**
35
- * 히스토리 조회
36
- */
37
- getHistory(): HistoryItem[];
38
- /**
39
- * 히스토리 초기화
40
- */
41
- clearHistory(): void;
42
- /**
43
- * 자동 모드: LLM 콜백과 함께 반복 실행
44
- */
45
- automate(llmCallback: LLMCallback, options?: AutomationOptions): Promise<void>;
46
- /**
47
- * 특정 요소 스캔
48
- */
49
- scanElement(elementId: string, options?: ScanOptions): Promise<ScanResult>;
50
- /**
51
- * 에러 이벤트 발생
52
- */
53
- private dispatchError;
54
- /**
55
- * 스크린샷 캡처 (html2canvas 사용)
56
- */
57
- private captureScreenshot;
58
- /**
59
- * Scanner 인스턴스 가져오기 (고급 사용)
60
- */
61
- getScanner(): DOMScanner;
62
- /**
63
- * Controller 인스턴스 가져오기 (고급 사용)
64
- */
65
- getController(): DOMController;
66
- /**
67
- * 이전 스캔과 현재 스캔 비교 (Diff)
68
- */
69
- scanDiff(previousScan: ScanResult, currentScan: ScanResult): ScanDiff;
70
- /**
71
- * 요소 변경 여부 확인
72
- */
73
- private isElementModified;
74
- }
@@ -1,78 +0,0 @@
1
- import { DOMCommand, ExecutionResult } from './types.js';
2
- import { DOMScanner } from './DOMScanner.js';
3
- /**
4
- * DOM 명령 실행 엔진
5
- * LLM의 명령을 파싱하고 실제 DOM 조작 수행
6
- */
7
- export declare class DOMController {
8
- private scanner;
9
- constructor(scanner: DOMScanner);
10
- /**
11
- * 단일 명령 실행
12
- */
13
- execute(command: DOMCommand): Promise<ExecutionResult>;
14
- /**
15
- * 여러 명령 순차 실행
16
- */
17
- executeMany(commands: DOMCommand[]): Promise<ExecutionResult[]>;
18
- /**
19
- * 명령 실행 (내부)
20
- */
21
- private executeCommand;
22
- /**
23
- * 클릭 이벤트 실행
24
- */
25
- private click;
26
- /**
27
- * 텍스트 입력 (자연스러운 타이핑 시뮬레이션)
28
- */
29
- private input;
30
- /**
31
- * 옵션 선택
32
- */
33
- private selectOption;
34
- /**
35
- * 포커스
36
- */
37
- private focus;
38
- /**
39
- * 블러 (포커스 해제)
40
- */
41
- private blur;
42
- /**
43
- * 스크롤
44
- */
45
- private scroll;
46
- /**
47
- * 요소로 스크롤
48
- */
49
- private scrollTo;
50
- /**
51
- * 마우스 오버 (호버)
52
- */
53
- private hover;
54
- /**
55
- * 입력 필드 초기화
56
- */
57
- private clear;
58
- /**
59
- * 체크박스/라디오 토글
60
- */
61
- private check;
62
- /**
63
- * 대기
64
- */
65
- private wait;
66
- /**
67
- * 페이지 네비게이션 대기
68
- */
69
- private waitForNavigation;
70
- /**
71
- * 사람처럼 보이는 랜덤 딜레이
72
- */
73
- private simulateHumanDelay;
74
- /**
75
- * ID로 요소 가져오기 (Scanner의 매핑 활용)
76
- */
77
- private getElement;
78
- }
@@ -1,54 +0,0 @@
1
- import { ScanResult, DOMCommand } from './types.js';
2
- /**
3
- * DOMPromptBuilder
4
- * ScanResult를 LLM이 이해하기 쉬운 프롬프트로 변환하고, LLM 응답에서 명령을 추출합니다.
5
- */
6
- export declare class DOMPromptBuilder {
7
- private template;
8
- constructor(template?: string);
9
- /**
10
- * 기본 프롬프트 템플릿
11
- */
12
- private getDefaultTemplate;
13
- /**
14
- * LLM 프롬프트 생성
15
- */
16
- buildPrompt(scan: ScanResult, options?: {
17
- maxElements?: number;
18
- includeInvisible?: boolean;
19
- contextHint?: string;
20
- template?: string;
21
- }): string;
22
- /**
23
- * LLM 응답에서 명령 추출
24
- */
25
- extractCommands(llmResponse: string): DOMCommand[];
26
- /**
27
- * 명령 객체 정규화
28
- */
29
- private normalizeCommand;
30
- /**
31
- * 요소 리스트를 LLM 친화적 텍스트로 변환
32
- */
33
- private summarizeElements;
34
- /**
35
- * 단일 요소를 텍스트로 표현
36
- */
37
- private elementToText;
38
- /**
39
- * 스크린샷을 멀티모달 메시지로 변환 (Anthropic Claude, OpenAI GPT-4V 형식)
40
- */
41
- formatMultimodalMessage(scan: ScanResult, options?: {
42
- maxElements?: number;
43
- contextHint?: string;
44
- screenshotFormat?: 'anthropic' | 'openai';
45
- }): any;
46
- /**
47
- * 템플릿 변경
48
- */
49
- setTemplate(template: string): void;
50
- /**
51
- * 현재 템플릿 가져오기
52
- */
53
- getTemplate(): string;
54
- }
@@ -1,83 +0,0 @@
1
- import { ScanResult, ScanOptions } from './types.js';
2
- /**
3
- * DOM 스캔 엔진
4
- * Shadow DOM을 포함한 전체 DOM 트리를 순회하며 인터랙티브 요소를 추출
5
- */
6
- export declare class DOMScanner {
7
- private elementMap;
8
- private idMap;
9
- private totalElementsScanned;
10
- private debug;
11
- private cachedScan;
12
- private prioritizeLandmarks;
13
- /**
14
- * DOM 스캔 수행 (Shadow DOM 포함)
15
- * @param root 스캔 시작 루트 (기본값 document.body)
16
- * @param options 스캔 옵션
17
- */
18
- scan(root?: Element | ShadowRoot, options?: ScanOptions): ScanResult;
19
- /**
20
- * ID로 요소 객체 가져오기 (빠른 조회)
21
- */
22
- getElement(id: string): Element | undefined;
23
- /**
24
- * 요소에서 ID 가져오기
25
- */
26
- getElementId(element: Element): string | undefined;
27
- /**
28
- * 단일 요소를 스캔하고 Shadow DOM도 탐색
29
- */
30
- private scanElement;
31
- /**
32
- * Shadow DOM 내부 스캔
33
- */
34
- private scanShadowRoot;
35
- /**
36
- * 인터랙티브 요소 여부 판단
37
- */
38
- private isInteractive;
39
- /**
40
- * 필터링 기준 충족 여부 (LLM에게 보여줄 가치가 있는지)
41
- */
42
- private shouldInclude;
43
- /**
44
- * 짧은 랜덤 ID 생성 (예: elm_a1b2c3)
45
- */
46
- private generateId;
47
- /**
48
- * 요소 정보 추출
49
- */
50
- private getElementInfo;
51
- /**
52
- * 요소의 레이블 가져오기
53
- */
54
- private getLabel;
55
- /**
56
- * 요소 타입 결정
57
- */
58
- private getElementType;
59
- /**
60
- * 요소가 시각적으로 보이는지 확인
61
- */
62
- private isVisible;
63
- /**
64
- * 우선순위 계산
65
- */
66
- private calculatePriority;
67
- /**
68
- * 요소 트리를 평탄화
69
- */
70
- private flattenElements;
71
- /**
72
- * 우선순위 기반 필터링
73
- */
74
- private filterByPriority;
75
- /**
76
- * DOM 해시 생성 (변경 감지용)
77
- */
78
- private generateDOMHash;
79
- /**
80
- * 디버그 로그 출력 (debug 모드일 때만)
81
- */
82
- private log;
83
- }
@@ -1,9 +0,0 @@
1
- /**
2
- * DOM Interaction Module
3
- * LLM이 웹 페이지를 스캔하고 인터랙션할 수 있게 하는 유틸리티
4
- */
5
- export { DOMScanner } from './DOMScanner.js';
6
- export { DOMController } from './DOMController.js';
7
- export { DOMAgent } from './DOMAgent.js';
8
- export { DOMPromptBuilder } from './DOMPromptBuilder.js';
9
- export type { ElementType, ScannedElement, ScanResult, FilterStrategy, ScanOptions, DOMAction, DOMCommand, ExecutionResult, DOMAgentEvents, AutomationOptions, HistoryItem, LLMCallback } from './types.js';