@logan-jun/cd1-rag-chat 0.1.0 → 0.2.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/README.md CHANGED
@@ -1,25 +1,92 @@
1
1
  # @logan-jun/cd1-rag-chat
2
2
 
3
- 폐쇄망 Vue 2.7 + Vuetify 호스트에 iframe 격리로 통합되는 **BDP Agent (RAG 챗봇)** 모듈.
3
+ 폐쇄망 호스트에 iframe 으로 임베드하는 **BDP Agent (RAG 챗봇)** UI 모듈.
4
4
 
5
- cd1-agent 의 `/agents/hdsp_rag/chat/stream` SSE 엔드포인트를 호출해 사내 가이드·테이블 메타데이터를 RAG 검색하고 답변을 스트리밍합니다. 현 버전은 **mockup 모드**(`VITE_USE_MOCK=true` 기본)로 백엔드 없이도 UI 검증이 가능합니다.
5
+ cd1-agent 의 `/agents/hdsp_rag/chat/stream` SSE 엔드포인트를 호출해 답변을 스트리밍합니다. 현 버전은 **mockup 모드** (백엔드 없이도 동작) 입니다.
6
6
 
7
- ## 호스트 통합 (한 줄)
7
+ ## 패키지 내용
8
+
9
+ | 파일 | 용도 |
10
+ |---|---|
11
+ | `dist/index.html`, `dist/assets/*` | iframe 으로 로드되는 빌드된 정적 자산 |
12
+ | `host-integration/RemoteModule.vue` | 호스트(Vue 2.7)에서 iframe + postMessage(토큰/높이) 처리하는 래퍼 컴포넌트 (선택) |
13
+
14
+ 라우트/메뉴 정의는 호스트 코드에서 직접 합니다.
15
+
16
+ ## 호스트 통합
8
17
 
9
- 호스트 프로젝트 `package.json` 에 dep 한 줄만 추가하면 자동 등록 스크립트(`scripts/sync-modules.cjs`) 라우트/메뉴를 알아서 잡습니다:
18
+ ### 1) 정적 자산 배포
19
+ `dist/*` 를 호스트 정적 서버 경로에 풀어둡니다. 권장 경로: `/embedded/rag-chat/`.
10
20
 
11
- ```json
12
- "@logan-jun/cd1-rag-chat": "file:./vendor/cd1-rag-chat-0.1.0.tgz"
21
+ `scripts/sync-modules.cjs` (이미 셋업된 자동 동기화 스크립트) 사용 시 `npm install` + `npm run build` 만 하면 자동으로 `node_modules/@logan-jun/cd1-rag-chat/dist/*` → `public/embedded/rag-chat/` 복사됩니다.
22
+
23
+ ### 2) 라우트 (호스트에서 직접 작성)
24
+
25
+ ```ts
26
+ // router/index.ts
27
+ const routes: RouteConfig[] = [
28
+ // ...
29
+ {
30
+ path: '/agents',
31
+ component: () => import('@/components/Layout/default/Default.vue'),
32
+ children: [
33
+ {
34
+ path: '/agents/rag-chat',
35
+ name: 'agents-rag-chat',
36
+ component: () => import('@/views/embedded/BdpAgent.vue'),
37
+ },
38
+ ],
39
+ },
40
+ ]
13
41
  ```
14
42
 
15
- 세부 통합 절차는 동일 패키지 시리즈인 `@logan-jun/cd1-sample-feature` 의 `host-integration/host-tools/INTEGRATION.md` 참고.
43
+ ### 3) iframe 페이지 컴포넌트 (호스트에서 직접 작성)
16
44
 
17
- ## 동작
18
- - URL: `/agents/rag-chat`
19
- - 정적 자산: `/embedded/rag-chat/index.html`
20
- - 메뉴 항목: `BDP Agent`
45
+ **옵션 A (가장 단순)** — 토큰 전달 불필요한 경우:
46
+ ```vue
47
+ <!-- src/views/embedded/BdpAgent.vue -->
48
+ <template>
49
+ <iframe
50
+ src="/embedded/rag-chat/index.html"
51
+ style="width: 100%; height: calc(100vh - 64px); border: 0; display: block;"
52
+ />
53
+ </template>
54
+ ```
21
55
 
22
- ## 패키지 내용
23
- - `dist/` — iframe 으로 로드되는 빌드된 정적 자산 (Vue 2.7 + Vite)
24
- - `host-integration/RemoteModule.vue` — 호스트(Vue 2.7) iframe 래퍼
25
- - `host-integration/route.ts` — Vue Router 자동 등록 정의
56
+ **옵션 B** — 토큰 전달/높이 동기화 등이 필요한 경우, 패키지의 `RemoteModule.vue` 활용:
57
+ ```vue
58
+ <template>
59
+ <RemoteModule
60
+ src="/embedded/rag-chat/index.html"
61
+ :token="$store.state.auth.token"
62
+ :base-url="apiBase"
63
+ @request-token="$store.dispatch('auth/refresh')"
64
+ />
65
+ </template>
66
+
67
+ <script lang="ts">
68
+ import RemoteModule from '@logan-jun/cd1-rag-chat/host-integration/RemoteModule.vue'
69
+ // ...
70
+ </script>
71
+ ```
72
+
73
+ ### 4) 메뉴 (호스트에서 직접 작성)
74
+ ```vue
75
+ <v-list-item :to="{ name: 'agents-rag-chat' }">
76
+ <v-list-item-icon><v-icon>mdi-message-text</v-icon></v-list-item-icon>
77
+ <v-list-item-content>
78
+ <v-list-item-title>BDP Agent</v-list-item-title>
79
+ </v-list-item-content>
80
+ </v-list-item>
81
+ ```
82
+
83
+ ## 업데이트 흐름
84
+
85
+ ```bash
86
+ # .tgz 교체 + dep 한 줄만 수정
87
+ mv ~/Downloads/cd1-rag-chat-X.Y.Z.tgz vendor/
88
+ # package.json 의 "file:./vendor/..." 경로 새 버전으로
89
+ npm install && npm run build
90
+ ```
91
+
92
+ 호스트의 router/메뉴 코드는 그대로. 자산 경로(`/embedded/rag-chat/`)만 유지되면 됨.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logan-jun/cd1-rag-chat",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "CD1 Agent - RAG 검색 챗봇 모듈 (iframe 격리, Vue 2.7).",
5
5
  "license": "MIT",
6
6
  "author": "logan-jun",
@@ -1,80 +0,0 @@
1
- /**
2
- * 호스트 (Vue 2.7 + Vuetify) 자동 등록용 라우트/메뉴 정의.
3
- *
4
- * 호스트에서:
5
- * import ragChat from '@logan-jun/cd1-rag-chat/host-integration/route'
6
- * router.addRoute(ragChat.route)
7
- * menu.push(ragChat.menu)
8
- *
9
- * 또는 자동 수집 패턴(scripts/sync-modules.cjs 생성 파일)로 일괄 등록.
10
- */
11
-
12
- import type { RouteConfig } from 'vue-router'
13
- import RemoteModule from './RemoteModule.vue'
14
-
15
- // 정적 자산 위치 (호스트 nginx/public 경로)
16
- const ASSETS_PATH = '/embedded/rag-chat/index.html'
17
-
18
- // 사용자가 보는 URL prefix (Vue Router path)
19
- const ROUTE_PREFIX = '/agents/rag-chat'
20
-
21
- export const route: RouteConfig = {
22
- path: `${ROUTE_PREFIX}/:pathMatch(.*)*`,
23
- name: 'agents-rag-chat',
24
- component: {
25
- name: 'RagChatHost',
26
- components: { RemoteModule },
27
- computed: {
28
- token(): string {
29
- const s: any = (this as any).$store
30
- return s?.state?.auth?.token ?? ''
31
- },
32
- user(): Record<string, unknown> | null {
33
- const s: any = (this as any).$store
34
- return s?.state?.auth?.user ?? null
35
- },
36
- apiBase(): string {
37
- return window.location.origin
38
- },
39
- },
40
- methods: {
41
- async onTokenRequest(): Promise<void> {
42
- const s: any = (this as any).$store
43
- try {
44
- await s?.dispatch('auth/refresh')
45
- } catch {
46
- /* host store가 다른 경로면 호스트 측에서 직접 와이어링 권장 */
47
- }
48
- },
49
- },
50
- render(h: any) {
51
- return h(
52
- 'div',
53
- { style: { height: 'calc(100vh - 64px)', margin: 0, padding: 0 } },
54
- [
55
- h(RemoteModule, {
56
- props: {
57
- src: ASSETS_PATH,
58
- token: (this as any).token,
59
- baseUrl: (this as any).apiBase,
60
- user: (this as any).user,
61
- syncRoutePrefix: ROUTE_PREFIX,
62
- },
63
- on: {
64
- 'request-token': (this as any).onTokenRequest,
65
- },
66
- }),
67
- ],
68
- )
69
- },
70
- },
71
- }
72
-
73
- export const menu = {
74
- title: 'BDP Agent',
75
- icon: 'mdi-message-text',
76
- to: { name: 'agents-rag-chat' },
77
- order: 50,
78
- }
79
-
80
- export default { route, menu }