@iyulab/chat-components 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +146 -0
- package/README.md +133 -16
- package/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/decorate.js +9 -0
- package/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/decorateMetadata.js +6 -0
- package/dist/_virtual/_glob-assets_raw/intent-prompt.md.1907474e.js +4 -0
- package/dist/_virtual/_glob-assets_raw/view-prompt.md.e0dbcffe.js +4 -0
- package/dist/components/blocks/UCodeBlock.d.ts +24 -2
- package/dist/components/blocks/UCodeBlock.js +65 -2
- package/dist/components/blocks/UCodeBlock.styles.js +10 -4
- package/dist/components/blocks/UFileBlock.d.ts +33 -0
- package/dist/components/blocks/UFileBlock.js +154 -0
- package/dist/components/blocks/UFileBlock.styles.js +128 -0
- package/dist/components/blocks/UJsonBlock.d.ts +44 -2
- package/dist/components/blocks/UJsonBlock.js +128 -3
- package/dist/components/blocks/UJsonBlock.styles.js +4 -4
- package/dist/components/blocks/UMarkedBlock.d.ts +44 -2
- package/dist/components/blocks/UMarkedBlock.js +154 -4
- package/dist/components/blocks/UMarkedBlock.styles.js +4 -4
- package/dist/components/blocks/URefBlock.d.ts +16 -2
- package/dist/components/blocks/URefBlock.js +58 -3
- package/dist/components/blocks/URefBlock.styles.js +4 -4
- package/dist/components/blocks/UTableBlock.d.ts +52 -0
- package/dist/components/blocks/UTableBlock.js +198 -0
- package/dist/components/blocks/UTableBlock.styles.js +133 -0
- package/dist/components/blocks/UTextBlock.d.ts +36 -2
- package/dist/components/blocks/UTextBlock.js +94 -4
- package/dist/components/blocks/UTextBlock.styles.js +4 -4
- package/dist/components/blocks/UThinkBlock.d.ts +30 -2
- package/dist/components/blocks/UThinkBlock.js +86 -4
- package/dist/components/blocks/UThinkBlock.styles.js +4 -4
- package/dist/components/blocks/UToolBlock.d.ts +19 -2
- package/dist/components/blocks/UToolBlock.js +68 -3
- package/dist/components/blocks/UToolBlock.styles.js +4 -4
- package/dist/components/buttons/UAttachButton.d.ts +21 -2
- package/dist/components/buttons/UAttachButton.js +61 -3
- package/dist/components/buttons/UAttachButton.styles.js +4 -4
- package/dist/components/buttons/UCopyButton.d.ts +19 -2
- package/dist/components/buttons/UCopyButton.js +57 -3
- package/dist/components/buttons/UCopyButton.styles.js +4 -4
- package/dist/components/buttons/UVoteButton.d.ts +14 -3
- package/dist/components/buttons/UVoteButton.js +62 -3
- package/dist/components/buttons/UVoteButton.styles.js +4 -4
- package/dist/components/intents/UQuestionIntent.d.ts +22 -0
- package/dist/components/intents/UQuestionIntent.js +41 -0
- package/dist/components/intents/UQuestionIntent.styles.js +43 -0
- package/dist/components/message/UMessage.d.ts +18 -2
- package/dist/components/message/UMessage.js +47 -2
- package/dist/components/message/UMessage.styles.js +42 -15
- package/dist/components/prompt/UPrompt.d.ts +32 -2
- package/dist/components/prompt/UPrompt.js +118 -2
- package/dist/components/prompt/UPrompt.styles.js +43 -5
- package/dist/components/references/URefCard.d.ts +30 -2
- package/dist/components/references/URefCard.js +97 -2
- package/dist/components/references/URefCard.styles.js +4 -4
- package/dist/components/references/URefCardGroup.d.ts +25 -2
- package/dist/components/references/URefCardGroup.js +69 -4
- package/dist/components/references/URefCardGroup.styles.js +4 -4
- package/dist/components/references/URefTag.d.ts +12 -2
- package/dist/components/references/URefTag.js +37 -2
- package/dist/components/references/URefTag.styles.js +4 -4
- package/dist/components/views/UChartView.d.ts +39 -0
- package/dist/components/views/UChartView.js +167 -0
- package/dist/components/views/UChartView.styles.js +86 -0
- package/dist/components/views/UImagesView.d.ts +33 -0
- package/dist/components/views/UImagesView.js +144 -0
- package/dist/components/views/UImagesView.styles.d.ts +1 -0
- package/dist/components/views/UImagesView.styles.js +219 -0
- package/dist/components/views/UMapView.d.ts +24 -0
- package/dist/components/views/UMapView.js +45 -0
- package/dist/components/views/UMapView.styles.d.ts +1 -0
- package/dist/components/views/UMapView.styles.js +47 -0
- package/dist/components/views/UVideoView.d.ts +25 -0
- package/dist/components/views/UVideoView.js +81 -0
- package/dist/components/views/UVideoView.styles.d.ts +1 -0
- package/dist/components/views/UVideoView.styles.js +36 -0
- package/dist/components/views/UView.d.ts +46 -0
- package/dist/components/views/UView.js +113 -0
- package/dist/components/views/UView.styles.d.ts +1 -0
- package/dist/components/views/UView.styles.js +33 -0
- package/dist/events/AttachEvent.d.ts +9 -0
- package/dist/events/ChoiceEvent.d.ts +9 -0
- package/dist/events/SendEvent.d.ts +7 -0
- package/dist/events/StopEvent.d.ts +7 -0
- package/dist/index.d.ts +15 -6
- package/dist/index.js +28 -38
- package/dist/react/UAttachButton.d.ts +11 -0
- package/dist/react/UAttachButton.js +12 -0
- package/dist/react/UChartView.d.ts +9 -0
- package/dist/react/UChartView.js +10 -0
- package/dist/react/UCodeBlock.d.ts +9 -0
- package/dist/react/UCodeBlock.js +10 -0
- package/dist/react/UCopyButton.d.ts +9 -0
- package/dist/react/UCopyButton.js +10 -0
- package/dist/react/UFileBlock.d.ts +11 -0
- package/dist/react/UFileBlock.js +12 -0
- package/dist/react/UImagesView.d.ts +9 -0
- package/dist/react/UImagesView.js +10 -0
- package/dist/react/UJsonBlock.d.ts +9 -0
- package/dist/react/UJsonBlock.js +10 -0
- package/dist/react/UMapView.d.ts +9 -0
- package/dist/react/UMapView.js +10 -0
- package/dist/react/UMarkedBlock.d.ts +9 -0
- package/dist/react/UMarkedBlock.js +10 -0
- package/dist/react/UMessage.d.ts +9 -0
- package/dist/react/UMessage.js +10 -0
- package/dist/react/UPrompt.d.ts +13 -0
- package/dist/react/UPrompt.js +13 -0
- package/dist/react/UQuestionIntent.d.ts +11 -0
- package/dist/react/UQuestionIntent.js +12 -0
- package/dist/react/URefBlock.d.ts +9 -0
- package/dist/react/URefBlock.js +10 -0
- package/dist/react/URefCard.d.ts +9 -0
- package/dist/react/URefCard.js +10 -0
- package/dist/react/URefCardGroup.d.ts +9 -0
- package/dist/react/URefCardGroup.js +10 -0
- package/dist/react/URefTag.d.ts +9 -0
- package/dist/react/URefTag.js +10 -0
- package/dist/react/UTableBlock.d.ts +9 -0
- package/dist/react/UTableBlock.js +10 -0
- package/dist/react/UTextBlock.d.ts +9 -0
- package/dist/react/UTextBlock.js +10 -0
- package/dist/react/UThinkBlock.d.ts +9 -0
- package/dist/react/UThinkBlock.js +10 -0
- package/dist/react/UToolBlock.d.ts +9 -0
- package/dist/react/UToolBlock.js +10 -0
- package/dist/react/UVideoView.d.ts +9 -0
- package/dist/react/UVideoView.js +10 -0
- package/dist/react/UView.d.ts +9 -0
- package/dist/react/UView.js +10 -0
- package/dist/react/UVoteButton.d.ts +9 -0
- package/dist/react/UVoteButton.js +10 -0
- package/dist/react/index.d.ts +23 -0
- package/dist/react/index.js +23 -0
- package/dist/types/BlockItem.d.ts +21 -1
- package/dist/types/Intents.d.ts +26 -0
- package/dist/types/Intents.js +30 -0
- package/dist/types/JsonSchema.d.ts +59 -0
- package/dist/types/Views.d.ts +34 -0
- package/dist/types/Views.js +150 -0
- package/dist/utilities/IntentPromptBuilder.d.ts +40 -0
- package/dist/utilities/IntentPromptBuilder.js +95 -0
- package/dist/utilities/ViewPromptBuilder.d.ts +28 -0
- package/dist/utilities/ViewPromptBuilder.js +76 -0
- package/dist/utilities/dom-agent/DOMAgent.d.ts +74 -0
- package/dist/utilities/dom-agent/DOMController.d.ts +78 -0
- package/dist/utilities/dom-agent/DOMPromptBuilder.d.ts +54 -0
- package/dist/utilities/dom-agent/DOMScanner.d.ts +83 -0
- package/dist/utilities/dom-agent/index.d.ts +9 -0
- package/dist/utilities/dom-agent/types.d.ts +209 -0
- package/package.json +34 -18
- package/dist/components/blocks/UCodeBlock.component.d.ts +0 -23
- package/dist/components/blocks/UCodeBlock.component.js +0 -76
- package/dist/components/blocks/UJsonBlock.component.d.ts +0 -45
- package/dist/components/blocks/UJsonBlock.component.js +0 -140
- package/dist/components/blocks/UMarkedBlock.component.d.ts +0 -45
- package/dist/components/blocks/UMarkedBlock.component.js +0 -129
- package/dist/components/blocks/URefBlock.component.d.ts +0 -17
- package/dist/components/blocks/URefBlock.component.js +0 -74
- package/dist/components/blocks/UTextBlock.component.d.ts +0 -37
- package/dist/components/blocks/UTextBlock.component.js +0 -123
- package/dist/components/blocks/UThinkBlock.component.d.ts +0 -23
- package/dist/components/blocks/UThinkBlock.component.js +0 -90
- package/dist/components/blocks/UToolBlock.component.d.ts +0 -20
- package/dist/components/blocks/UToolBlock.component.js +0 -80
- package/dist/components/buttons/UAttachButton.component.d.ts +0 -22
- package/dist/components/buttons/UAttachButton.component.js +0 -89
- package/dist/components/buttons/UCopyButton.component.d.ts +0 -20
- package/dist/components/buttons/UCopyButton.component.js +0 -81
- package/dist/components/buttons/UReportButton.component.d.ts +0 -9
- package/dist/components/buttons/UReportButton.component.js +0 -36
- package/dist/components/buttons/UReportButton.d.ts +0 -7
- package/dist/components/buttons/UReportButton.js +0 -5
- package/dist/components/buttons/UReportButton.styles.js +0 -14
- package/dist/components/buttons/URetryButton.component.d.ts +0 -11
- package/dist/components/buttons/URetryButton.component.js +0 -53
- package/dist/components/buttons/URetryButton.d.ts +0 -7
- package/dist/components/buttons/URetryButton.js +0 -5
- package/dist/components/buttons/URetryButton.styles.js +0 -26
- package/dist/components/buttons/UShareButton.component.d.ts +0 -9
- package/dist/components/buttons/UShareButton.component.js +0 -36
- package/dist/components/buttons/UShareButton.d.ts +0 -7
- package/dist/components/buttons/UShareButton.js +0 -5
- package/dist/components/buttons/UShareButton.styles.js +0 -14
- package/dist/components/buttons/UVoteButton.component.d.ts +0 -15
- package/dist/components/buttons/UVoteButton.component.js +0 -70
- package/dist/components/loaders/UDotLoader.component.d.ts +0 -9
- package/dist/components/loaders/UDotLoader.component.js +0 -23
- package/dist/components/loaders/UDotLoader.d.ts +0 -7
- package/dist/components/loaders/UDotLoader.js +0 -5
- package/dist/components/loaders/UDotLoader.styles.js +0 -50
- package/dist/components/message/UMessage.component.d.ts +0 -19
- package/dist/components/message/UMessage.component.js +0 -90
- package/dist/components/prompt/UPrompt.component.d.ts +0 -25
- package/dist/components/prompt/UPrompt.component.js +0 -113
- package/dist/components/references/URefCard.component.d.ts +0 -24
- package/dist/components/references/URefCard.component.js +0 -105
- package/dist/components/references/URefCardGroup.component.d.ts +0 -25
- package/dist/components/references/URefCardGroup.component.js +0 -88
- package/dist/components/references/URefTag.component.d.ts +0 -13
- package/dist/components/references/URefTag.component.js +0 -54
- package/dist/events/UCancelEvent.d.ts +0 -6
- package/dist/events/USubmitEvent.d.ts +0 -6
- package/dist/utilities/converters.d.ts +0 -9
- package/dist/utilities/converters.js +0 -19
- /package/dist/components/{buttons/UReportButton.styles.d.ts → blocks/UFileBlock.styles.d.ts} +0 -0
- /package/dist/components/{buttons/URetryButton.styles.d.ts → blocks/UTableBlock.styles.d.ts} +0 -0
- /package/dist/components/{buttons/UShareButton.styles.d.ts → intents/UQuestionIntent.styles.d.ts} +0 -0
- /package/dist/components/{loaders/UDotLoader.styles.d.ts → views/UChartView.styles.d.ts} +0 -0
|
@@ -0,0 +1,54 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
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';
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DOM Interaction Types
|
|
3
|
+
* LLM이 웹 페이지를 스캔하고 인터랙션할 수 있게 하는 타입 정의
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* 스캔된 요소의 타입
|
|
7
|
+
*/
|
|
8
|
+
export type ElementType = 'button' | 'input' | 'link' | 'select' | 'textarea' | 'checkbox' | 'radio' | 'custom' | 'other';
|
|
9
|
+
/**
|
|
10
|
+
* 스캔된 DOM 요소
|
|
11
|
+
*/
|
|
12
|
+
export interface ScannedElement {
|
|
13
|
+
/** 랜덤 생성된 고유 식별자 (예: elm_a1b2c3) */
|
|
14
|
+
id: string;
|
|
15
|
+
/** 요소 타입 */
|
|
16
|
+
type: ElementType;
|
|
17
|
+
/** HTML 태그명 */
|
|
18
|
+
tag: string;
|
|
19
|
+
/** 텍스트 콘텐츠 */
|
|
20
|
+
text?: string;
|
|
21
|
+
/** input 값 */
|
|
22
|
+
value?: string;
|
|
23
|
+
/** placeholder 텍스트 */
|
|
24
|
+
placeholder?: string;
|
|
25
|
+
/** aria-label 또는 연결된 label */
|
|
26
|
+
label?: string;
|
|
27
|
+
/** data-llm-description 값 (LLM을 위한 설명) */
|
|
28
|
+
description?: string;
|
|
29
|
+
/** ARIA role */
|
|
30
|
+
role?: string;
|
|
31
|
+
/** disabled 상태 */
|
|
32
|
+
disabled: boolean;
|
|
33
|
+
/** 시각적으로 보이는지 여부 */
|
|
34
|
+
visible: boolean;
|
|
35
|
+
/** 포커스 상태 */
|
|
36
|
+
focused: boolean;
|
|
37
|
+
/** 체크 상태 (checkbox/radio) */
|
|
38
|
+
checked?: boolean;
|
|
39
|
+
/** Shadow DOM 내부 요소 여부 */
|
|
40
|
+
inShadowDom: boolean;
|
|
41
|
+
/** 화면 상 x 위치 */
|
|
42
|
+
x: number;
|
|
43
|
+
/** 화면 상 y 위치 */
|
|
44
|
+
y: number;
|
|
45
|
+
/** 너비 */
|
|
46
|
+
width: number;
|
|
47
|
+
/** 높이 */
|
|
48
|
+
height: number;
|
|
49
|
+
/** 우선순위 점수 (필터링용) */
|
|
50
|
+
priority: number;
|
|
51
|
+
/** 자식 요소들 (필터링된) */
|
|
52
|
+
children?: ScannedElement[];
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* DOM 스캔 결과
|
|
56
|
+
*/
|
|
57
|
+
export interface ScanResult {
|
|
58
|
+
/** 스캔 타임스탬프 */
|
|
59
|
+
timestamp: number;
|
|
60
|
+
/** 현재 URL */
|
|
61
|
+
url: string;
|
|
62
|
+
/** 페이지 제목 */
|
|
63
|
+
title: string;
|
|
64
|
+
/** 스캔된 요소들 */
|
|
65
|
+
elements: ScannedElement[];
|
|
66
|
+
/** Base64 인코딩된 스크린샷 (optional) */
|
|
67
|
+
screenshot?: string;
|
|
68
|
+
/** 스크롤 위치 */
|
|
69
|
+
scrollPosition: {
|
|
70
|
+
x: number;
|
|
71
|
+
y: number;
|
|
72
|
+
};
|
|
73
|
+
/** 뷰포트 크기 */
|
|
74
|
+
viewport: {
|
|
75
|
+
width: number;
|
|
76
|
+
height: number;
|
|
77
|
+
};
|
|
78
|
+
/** 전체 DOM 요소 수 */
|
|
79
|
+
totalElements: number;
|
|
80
|
+
/** LLM에게 제공되는 필터링된 요소 수 */
|
|
81
|
+
filteredElements: number;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* 필터링 전략
|
|
85
|
+
*/
|
|
86
|
+
export type FilterStrategy = 'all' | 'interactive' | 'described' | 'visible';
|
|
87
|
+
/**
|
|
88
|
+
* 스캔 옵션
|
|
89
|
+
*/
|
|
90
|
+
export interface ScanOptions {
|
|
91
|
+
/** 스크린샷 포함 여부 */
|
|
92
|
+
includeScreenshot?: boolean;
|
|
93
|
+
/** 최대 요소 수 제한 */
|
|
94
|
+
maxElements?: number;
|
|
95
|
+
/** 최대 깊이 제한 */
|
|
96
|
+
maxDepth?: number;
|
|
97
|
+
/** 필터링 전략 */
|
|
98
|
+
filterStrategy?: FilterStrategy;
|
|
99
|
+
/** 디버그 로그 활성화 (기본값: false) */
|
|
100
|
+
debug?: boolean;
|
|
101
|
+
/** 캐싱 사용 여부 (기본값: true) */
|
|
102
|
+
useCache?: boolean;
|
|
103
|
+
/** iframe 포함 여부 (기본값: false) */
|
|
104
|
+
includeIframes?: boolean;
|
|
105
|
+
/** ARIA Landmark 우선순위 증가 (기본값: true) */
|
|
106
|
+
prioritizeLandmarks?: boolean;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* DOM 명령 액션
|
|
110
|
+
*/
|
|
111
|
+
export type DOMAction = 'click' | 'input' | 'select' | 'focus' | 'blur' | 'scroll' | 'scrollTo' | 'hover' | 'clear' | 'check' | 'wait';
|
|
112
|
+
/**
|
|
113
|
+
* DOM 명령
|
|
114
|
+
*/
|
|
115
|
+
export interface DOMCommand {
|
|
116
|
+
/** 실행할 액션 */
|
|
117
|
+
action: DOMAction;
|
|
118
|
+
/** 대상 요소 ID (DOMScanner가 생성한 랜덤 ID) */
|
|
119
|
+
target?: string;
|
|
120
|
+
/** 명령 값 (input 텍스트, select 옵션 등) */
|
|
121
|
+
value?: string | number | boolean;
|
|
122
|
+
/** 추가 옵션 */
|
|
123
|
+
options?: {
|
|
124
|
+
/** 명령 실행 전 대기 시간 (ms) */
|
|
125
|
+
delay?: number;
|
|
126
|
+
/** 네비게이션 대기 여부 */
|
|
127
|
+
waitForNavigation?: boolean;
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* 명령 실행 결과
|
|
132
|
+
*/
|
|
133
|
+
export interface ExecutionResult {
|
|
134
|
+
/** 성공 여부 */
|
|
135
|
+
success: boolean;
|
|
136
|
+
/** 실행된 명령 */
|
|
137
|
+
command: DOMCommand;
|
|
138
|
+
/** 에러 메시지 (실패 시) */
|
|
139
|
+
error?: string;
|
|
140
|
+
/** 실행 타임스탬프 */
|
|
141
|
+
timestamp: number;
|
|
142
|
+
/** 페이지 네비게이션 발생 여부 */
|
|
143
|
+
navigationOccurred?: boolean;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* DOMAgent 이벤트 타입
|
|
147
|
+
*/
|
|
148
|
+
export interface DOMAgentEvents {
|
|
149
|
+
/** 스캔 완료 */
|
|
150
|
+
scan: ScanResult;
|
|
151
|
+
/** 명령 수신 */
|
|
152
|
+
command: DOMCommand;
|
|
153
|
+
/** 명령 실행 완료 */
|
|
154
|
+
execute: ExecutionResult;
|
|
155
|
+
/** 에러 발생 */
|
|
156
|
+
error: Error;
|
|
157
|
+
/** 반복 횟수 */
|
|
158
|
+
iteration: number;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* 자동화 옵션
|
|
162
|
+
*/
|
|
163
|
+
export interface AutomationOptions {
|
|
164
|
+
/** 최대 반복 횟수 */
|
|
165
|
+
maxIterations?: number;
|
|
166
|
+
/** 중지 조건 함수 */
|
|
167
|
+
stopCondition?: (scan: ScanResult) => boolean;
|
|
168
|
+
/** 스크린샷 포함 여부 */
|
|
169
|
+
includeScreenshot?: boolean;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* 히스토리 항목
|
|
173
|
+
*/
|
|
174
|
+
export interface HistoryItem {
|
|
175
|
+
/** 스캔 결과 */
|
|
176
|
+
scan: ScanResult;
|
|
177
|
+
/** 실행된 명령들 */
|
|
178
|
+
commands: DOMCommand[];
|
|
179
|
+
/** 실행 결과들 */
|
|
180
|
+
results: ExecutionResult[];
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* LLM 콜백 함수 타입
|
|
184
|
+
*/
|
|
185
|
+
export type LLMCallback = (scan: ScanResult) => Promise<DOMCommand[]>;
|
|
186
|
+
/**
|
|
187
|
+
* 캐시 항목
|
|
188
|
+
*/
|
|
189
|
+
export interface CachedScan {
|
|
190
|
+
/** 캐시된 스캔 결과 */
|
|
191
|
+
result: ScanResult;
|
|
192
|
+
/** 캐시 생성 시간 */
|
|
193
|
+
timestamp: number;
|
|
194
|
+
/** DOM 해시 (변경 감지용) */
|
|
195
|
+
domHash: string;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Diff 결과
|
|
199
|
+
*/
|
|
200
|
+
export interface ScanDiff {
|
|
201
|
+
/** 추가된 요소 */
|
|
202
|
+
added: ScannedElement[];
|
|
203
|
+
/** 제거된 요소 */
|
|
204
|
+
removed: ScannedElement[];
|
|
205
|
+
/** 변경된 요소 */
|
|
206
|
+
modified: ScannedElement[];
|
|
207
|
+
/** 변경되지 않은 요소 */
|
|
208
|
+
unchanged: ScannedElement[];
|
|
209
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iyulab/chat-components",
|
|
3
3
|
"description": "llm chat components for building chat interfaces",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.5.0",
|
|
5
5
|
"author": "iyulab",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"keywords": [
|
|
@@ -31,34 +31,50 @@
|
|
|
31
31
|
"types": "./dist/index.d.ts",
|
|
32
32
|
"import": "./dist/index.js"
|
|
33
33
|
},
|
|
34
|
-
"./dist/*":
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
34
|
+
"./dist/*": "./dist/*",
|
|
35
|
+
"./react": "./dist/react/index.js",
|
|
36
|
+
"./react/*": "./dist/react/*"
|
|
38
37
|
},
|
|
39
38
|
"scripts": {
|
|
40
39
|
"test": "vite",
|
|
41
40
|
"build": "eslint && vite build"
|
|
42
41
|
},
|
|
43
42
|
"dependencies": {
|
|
44
|
-
"@iyulab/components": "0.
|
|
45
|
-
"dompurify": "^3.3.1",
|
|
43
|
+
"@iyulab/components": "^1.0.1",
|
|
46
44
|
"highlight.js": "^11.11.1",
|
|
45
|
+
"html2canvas": "^1.4.1",
|
|
47
46
|
"lit": "^3.3.2",
|
|
48
|
-
"marked": "^17.0.
|
|
49
|
-
"marked-katex-extension": "^5.1.
|
|
47
|
+
"marked": "^17.0.5",
|
|
48
|
+
"marked-katex-extension": "^5.1.7"
|
|
49
|
+
},
|
|
50
|
+
"peerDependencies": {
|
|
51
|
+
"@lit/react": ">=1.0.8",
|
|
52
|
+
"chart.js": ">=4.5.1",
|
|
53
|
+
"react": ">=18.0.0"
|
|
54
|
+
},
|
|
55
|
+
"peerDependenciesMeta": {
|
|
56
|
+
"@lit/react": {
|
|
57
|
+
"optional": true
|
|
58
|
+
},
|
|
59
|
+
"chart.js": {
|
|
60
|
+
"optional": true
|
|
61
|
+
},
|
|
62
|
+
"react": {
|
|
63
|
+
"optional": true
|
|
64
|
+
}
|
|
50
65
|
},
|
|
51
66
|
"devDependencies": {
|
|
52
|
-
"@eslint/js": "^9.39.
|
|
53
|
-
"@
|
|
54
|
-
"
|
|
55
|
-
"eslint": "^9.39.
|
|
56
|
-
"eslint-plugin-lit": "^2.
|
|
57
|
-
"
|
|
58
|
-
"
|
|
67
|
+
"@eslint/js": "^9.39.4",
|
|
68
|
+
"@types/node": "^25.5.0",
|
|
69
|
+
"chart.js": "^4.5.1",
|
|
70
|
+
"eslint": "^9.39.4",
|
|
71
|
+
"eslint-plugin-lit": "^2.2.1",
|
|
72
|
+
"glob": "^13.0.6",
|
|
73
|
+
"globals": "^17.4.0",
|
|
74
|
+
"openai": "^6.33.0",
|
|
59
75
|
"typescript": "^5.9.3",
|
|
60
|
-
"typescript-eslint": "^8.
|
|
61
|
-
"vite": "^
|
|
76
|
+
"typescript-eslint": "^8.57.2",
|
|
77
|
+
"vite": "^8.0.3",
|
|
62
78
|
"vite-plugin-dts": "^4.5.4"
|
|
63
79
|
}
|
|
64
80
|
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { BaseElement } from '@iyulab/components/dist/components/BaseElement.js';
|
|
2
|
-
/**
|
|
3
|
-
* 코드 블록을 렌더링하는 컴포넌트입니다.
|
|
4
|
-
* 언어와 코드를 받아 syntax highlighting을 적용합니다.
|
|
5
|
-
*/
|
|
6
|
-
export declare class UCodeBlock extends BaseElement {
|
|
7
|
-
static styles: import('lit').CSSResultGroup[];
|
|
8
|
-
static dependencies: Record<string, typeof BaseElement>;
|
|
9
|
-
/** 클립보드 복사 상태를 나타내는 플래그입니다. */
|
|
10
|
-
isCopied: boolean;
|
|
11
|
-
/** 코드 블록의 헤더를 숨길지 여부를 지정합니다. */
|
|
12
|
-
headless: boolean;
|
|
13
|
-
/** 코드 언어를 지정합니다. */
|
|
14
|
-
lang: string;
|
|
15
|
-
/** 표시할 코드 내용입니다. */
|
|
16
|
-
value?: string;
|
|
17
|
-
render(): import('lit-html').TemplateResult<1>;
|
|
18
|
-
/**
|
|
19
|
-
* slot에 할당된 코드를 value로 설정합니다.
|
|
20
|
-
* 이 기능을 통해 HTML 내에 직접 코드를 작성할 수 있습니다.
|
|
21
|
-
*/
|
|
22
|
-
private handleSlotChange;
|
|
23
|
-
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { html } from 'lit';
|
|
2
|
-
import { state, property } from 'lit/decorators.js';
|
|
3
|
-
import { unsafeHTML } from 'lit/directives/unsafe-html.js';
|
|
4
|
-
import hljs from 'highlight.js';
|
|
5
|
-
import { BaseElement } from '@iyulab/components/dist/components/BaseElement.js';
|
|
6
|
-
import { UCopyButton } from '../buttons/UCopyButton.component.js';
|
|
7
|
-
import { styles } from './UCodeBlock.styles.js';
|
|
8
|
-
|
|
9
|
-
var __defProp = Object.defineProperty;
|
|
10
|
-
var __decorateClass = (decorators, target, key, kind) => {
|
|
11
|
-
var result = void 0 ;
|
|
12
|
-
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
13
|
-
if (decorator = decorators[i])
|
|
14
|
-
result = (decorator(target, key, result) ) || result;
|
|
15
|
-
if (result) __defProp(target, key, result);
|
|
16
|
-
return result;
|
|
17
|
-
};
|
|
18
|
-
class UCodeBlock extends BaseElement {
|
|
19
|
-
constructor() {
|
|
20
|
-
super(...arguments);
|
|
21
|
-
this.isCopied = false;
|
|
22
|
-
this.headless = false;
|
|
23
|
-
this.lang = "plaintext";
|
|
24
|
-
/**
|
|
25
|
-
* slot에 할당된 코드를 value로 설정합니다.
|
|
26
|
-
* 이 기능을 통해 HTML 내에 직접 코드를 작성할 수 있습니다.
|
|
27
|
-
*/
|
|
28
|
-
this.handleSlotChange = (e) => {
|
|
29
|
-
const slot = e.target;
|
|
30
|
-
const nodes = slot.assignedNodes({ flatten: true });
|
|
31
|
-
this.value = nodes.map((node) => node.textContent).join("\n\n");
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
static {
|
|
35
|
-
this.styles = [super.styles, styles];
|
|
36
|
-
}
|
|
37
|
-
static {
|
|
38
|
-
this.dependencies = {
|
|
39
|
-
"u-copy-button": UCopyButton
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
render() {
|
|
43
|
-
const lang = hljs.getLanguage(this.lang) ? this.lang : "plaintext";
|
|
44
|
-
const value = this.value || "";
|
|
45
|
-
return html`
|
|
46
|
-
<div class="header" ?hidden=${this.headless}>
|
|
47
|
-
<span class="lang">
|
|
48
|
-
${lang}
|
|
49
|
-
</span>
|
|
50
|
-
<u-copy-button
|
|
51
|
-
.value=${value}
|
|
52
|
-
></u-copy-button>
|
|
53
|
-
</div>
|
|
54
|
-
|
|
55
|
-
<pre class="hljs">${unsafeHTML(hljs.highlight(value, {
|
|
56
|
-
language: lang
|
|
57
|
-
}).value)}</pre>
|
|
58
|
-
|
|
59
|
-
<slot hidden @slotchange=${this.handleSlotChange}></slot>
|
|
60
|
-
`;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
__decorateClass([
|
|
64
|
-
state()
|
|
65
|
-
], UCodeBlock.prototype, "isCopied");
|
|
66
|
-
__decorateClass([
|
|
67
|
-
property({ type: Boolean, reflect: true })
|
|
68
|
-
], UCodeBlock.prototype, "headless");
|
|
69
|
-
__decorateClass([
|
|
70
|
-
property({ type: String, reflect: true })
|
|
71
|
-
], UCodeBlock.prototype, "lang");
|
|
72
|
-
__decorateClass([
|
|
73
|
-
property({ type: String })
|
|
74
|
-
], UCodeBlock.prototype, "value");
|
|
75
|
-
|
|
76
|
-
export { UCodeBlock };
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { PropertyValues, TemplateResult } from 'lit';
|
|
2
|
-
import { BaseElement } from '@iyulab/components/dist/components/BaseElement.js';
|
|
3
|
-
import { JsonNode } from '../../types/JsonNode.js';
|
|
4
|
-
/**
|
|
5
|
-
* json 데이터를 트리 형태로 시각화하는 컴포넌트입니다.
|
|
6
|
-
*/
|
|
7
|
-
export declare class UJsonBlock extends BaseElement {
|
|
8
|
-
static styles: import('lit').CSSResultGroup[];
|
|
9
|
-
static dependencies: Record<string, typeof BaseElement>;
|
|
10
|
-
state: Record<string, boolean>;
|
|
11
|
-
/** 초기 확장 상태를 관리하는 속성입니다. */
|
|
12
|
-
expanded: boolean;
|
|
13
|
-
/** JSON 데이터 (속성으로 전달 가능) */
|
|
14
|
-
value: JsonNode;
|
|
15
|
-
connectedCallback(): void;
|
|
16
|
-
protected willUpdate(changedProperties: PropertyValues): void;
|
|
17
|
-
render(): TemplateResult<1>;
|
|
18
|
-
/**
|
|
19
|
-
* JsonNode를 렌더링합니다.
|
|
20
|
-
* @param value - JsonNode (JsonObject, JsonArray, 또는 JsonValue)
|
|
21
|
-
* @param parent - 부모 노드의 경로
|
|
22
|
-
*/
|
|
23
|
-
private renderNode;
|
|
24
|
-
/**
|
|
25
|
-
* JsonValue를 렌더링합니다.
|
|
26
|
-
* @param node - JsonValue (string, number, boolean, null 등)
|
|
27
|
-
*/
|
|
28
|
-
private renderValue;
|
|
29
|
-
/**
|
|
30
|
-
* JsonObject 또는 JsonArray를 렌더링합니다.
|
|
31
|
-
* @param node - JsonObject 또는 JsonArray
|
|
32
|
-
* @param depth - 현재 깊이
|
|
33
|
-
*/
|
|
34
|
-
private renderObject;
|
|
35
|
-
/**
|
|
36
|
-
* 노드의 미리보기를 렌더링합니다.
|
|
37
|
-
* @param node - JsonObject 또는 JsonArray
|
|
38
|
-
*/
|
|
39
|
-
private renderPreview;
|
|
40
|
-
/** JSON 데이터를 순회하며 각 경로의 확장 상태를 설정합니다. */
|
|
41
|
-
private setState;
|
|
42
|
-
private isValueType;
|
|
43
|
-
/** 노드 확장/축소 클릭 핸들러 */
|
|
44
|
-
private handlePropertyKeyClick;
|
|
45
|
-
}
|