@xbrain-swe/nova-chat-widget 0.1.11 → 0.2.4-dev.15
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/dist/index.cjs +228 -55
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +42 -5
- package/dist/index.d.ts +42 -5
- package/dist/index.js +278 -105
- package/dist/index.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -29,6 +29,13 @@ type ChatMessage = {
|
|
|
29
29
|
role: "user" | "assistant";
|
|
30
30
|
parts: MessagePart[];
|
|
31
31
|
};
|
|
32
|
+
/** 서버에 저장된 메시지(`parts`는 AI SDK UIMessage.parts 원본) — 이어 연 대화의 이력. */
|
|
33
|
+
type StoredMessage = {
|
|
34
|
+
id: string;
|
|
35
|
+
role: "user" | "assistant";
|
|
36
|
+
sender?: string;
|
|
37
|
+
parts: Record<string, unknown>[];
|
|
38
|
+
};
|
|
32
39
|
|
|
33
40
|
/** `awaitResult` 핸들러가 구조화된 결과를 돌려줄 때의 모양. `text`는 모델이 읽는 결과(서버로
|
|
34
41
|
* 전송)고, `view`+`output`은 채팅 말풍선에 직접 그릴 정규화된 데이터다 — 서버에는 가지 않는다.
|
|
@@ -100,12 +107,22 @@ type XbNovaTheme = {
|
|
|
100
107
|
colorScheme: "light" | "dark" | "system";
|
|
101
108
|
};
|
|
102
109
|
|
|
103
|
-
declare function XbNovaProvider({ apiKey, botId, appId, screen, apiBaseUrl, clientActions, theme, children, }: {
|
|
110
|
+
declare function XbNovaProvider({ apiKey, botId, appId, screen, apiBaseUrl, clientActions, theme, userKey, threadKey, sessionKey, children, }: {
|
|
104
111
|
apiKey: string;
|
|
105
112
|
botId: string;
|
|
106
113
|
appId: string;
|
|
107
114
|
screen?: string;
|
|
108
115
|
apiBaseUrl?: string;
|
|
116
|
+
/** 이 방문자를 가리키는 호스트 쪽 키(예: GA4 user_pseudo_id). nova가 남기는 방문자 ID(대화·넛지
|
|
117
|
+
* 이벤트·피드백) 전부가 이 값이 되고, `threadKey`와 함께 이전 대화를 찾는 데도 쓴다. 공개 키로 조회하므로 추측하기 어려운 값이어야 한다 — 회원 ID를 그대로
|
|
118
|
+
* 넘기지 않는다. 안 주면 SDK가 브라우저에 만들어 둔 `visitorId`를 쓴다. */
|
|
119
|
+
userKey?: string;
|
|
120
|
+
/** 대화를 이어 붙일 단위(예: `vehicle:${매물ID}`). 같은 유저 키·스레드 키로 위젯이 다시 열리면
|
|
121
|
+
* 이전 대화와 이력을 복원한다. 안 주면 열 때마다 새 대화다. */
|
|
122
|
+
threadKey?: string;
|
|
123
|
+
/** 이 방문의 세션 키(예: GA4 session_id). nova가 남기는 이벤트(위젯 노출·넛지·상담 버튼)와 대화에 실려
|
|
124
|
+
* 콘솔에서 세션 단위로 집계된다. 값이 바뀌면(세션 갱신) 그 뒤 이벤트부터 새 값으로 실린다. 안 주면 세션은 비운다. */
|
|
125
|
+
sessionKey?: string;
|
|
109
126
|
/** 이 페이지가 AI에게 내어줄 client action tool — 이름별로 설명·스키마·실행 함수를
|
|
110
127
|
* 등록한다("SDK 초기화 시점에 등록"). 스펙은 App 레벨 레지스트리로 자동 동기화되고
|
|
111
128
|
* (`XbNovaClientActionSync`), 콘솔의 tool 목록에 반영된다. 핸들러는 여기서만 산다. */
|
|
@@ -133,17 +150,24 @@ type XbNovaFeedbackEvent = {
|
|
|
133
150
|
reason?: XbNovaFeedbackReason;
|
|
134
151
|
};
|
|
135
152
|
type XbNovaOnboarding = {
|
|
136
|
-
|
|
153
|
+
/** 이어 열 대화가 없으면 null — 첫 메시지를 보낼 때 서버가 만든다(지연 생성). */
|
|
154
|
+
conversation_id: string | null;
|
|
155
|
+
/** 이어 연 대화의 이력. 새 대화면 빈 배열. */
|
|
156
|
+
messages?: StoredMessage[];
|
|
137
157
|
greeting: string;
|
|
138
158
|
quick_replies: string[];
|
|
139
159
|
branding: {
|
|
140
160
|
title?: string;
|
|
141
161
|
logo_url?: string;
|
|
142
162
|
avatar_text?: string;
|
|
163
|
+
badge_text?: string;
|
|
164
|
+
disclaimer?: string;
|
|
143
165
|
};
|
|
144
166
|
};
|
|
145
167
|
type UseXbNovaChatResult = {
|
|
146
168
|
onboarding: XbNovaOnboarding | null;
|
|
169
|
+
/** 대화 맨 위에 그릴 첫 말풍선(넛지 문구·인사말). 이어 연 대화면 이력에 이미 있으니 null. */
|
|
170
|
+
opening: string | null;
|
|
147
171
|
messages: ChatMessage[];
|
|
148
172
|
busy: boolean;
|
|
149
173
|
error: string | null;
|
|
@@ -154,10 +178,12 @@ type UseXbNovaChatResult = {
|
|
|
154
178
|
feedback: Record<string, XbNovaFeedbackRating>;
|
|
155
179
|
/** 낙관적으로 반영하고 서버에 저장한다. 실패하면 되돌린다. */
|
|
156
180
|
setFeedback: (messageId: string, rating: XbNovaFeedbackRating, reason?: XbNovaFeedbackReason) => Promise<void>;
|
|
181
|
+
/** client action이 그린 버튼(상담신청 등)이 눌렸을 때 채팅 화면이 부른다 — nova 넛지 퍼널의 마지막 단계. */
|
|
182
|
+
trackClientActionClick: (action: string, label: string | null) => void;
|
|
157
183
|
};
|
|
158
184
|
/** `botId`를 넘기면 Provider의 기본 봇 대신 그 봇으로 새 대화를 연다 — 넛지 handoff가 쓴다.
|
|
159
185
|
* `nudgeNodeId`를 넘기면 이 대화가 그 넛지에서 시작됐다고 서버에 표시한다 — 넛지 전환
|
|
160
|
-
* 퍼널(
|
|
186
|
+
* 퍼널(노출→클릭→첫 질문→상담 버튼 노출→클릭)이 이 값이 채워진 대화를 넛지 대화로 본다.
|
|
161
187
|
* `onDismissSheet`는 `dismissSheet: true`인 client action이 실행될 때 호출된다 —
|
|
162
188
|
* `<XbNovaChat>`이 시트를 닫는 함수를 넘겨준다(모바일에서 시트가 페이지 대부분을 덮어서,
|
|
163
189
|
* 안 닫으면 그 밑에서 일어나는 일이 안 보인다). */
|
|
@@ -211,7 +237,14 @@ type ViewRenderer = (props: {
|
|
|
211
237
|
}) => React.ReactNode;
|
|
212
238
|
type ViewRendererMap = Partial<Record<ViewKind, ViewRenderer>>;
|
|
213
239
|
|
|
214
|
-
|
|
240
|
+
/** 바(AI 버튼)를 눌러 대화 시트를 열 때 `onOpen`으로 넘어오는 값. */
|
|
241
|
+
type XbNovaOpenEvent = {
|
|
242
|
+
/** 넛지 힌트 맥락으로 열었는지 — 힌트가 떠 있었거나, 방금 조용히 소멸한 힌트를 이어 열었으면 true. */
|
|
243
|
+
fromNudge: boolean;
|
|
244
|
+
/** `fromNudge`일 때 그 힌트 문구. */
|
|
245
|
+
hintText?: string;
|
|
246
|
+
};
|
|
247
|
+
declare function XbNovaChat({ viewRenderers, botId, barStyle, panelStyle, backdropStyle, defaultOpen, idleText, avatarSize, onVerdictAction, feedback: feedbackEnabled, onFeedback, onOpen, }: {
|
|
215
248
|
/** 특정 view만 자체 컴포넌트로 덮어쓰고 싶을 때 — 지정 안 한 view는 기본 렌더러를 쓴다. */
|
|
216
249
|
viewRenderers?: ViewRendererMap;
|
|
217
250
|
/** Provider의 기본 봇 대신 다른 봇과 고정적으로 대화하고 싶을 때. 힌트를 눌러 열면
|
|
@@ -240,6 +273,10 @@ declare function XbNovaChat({ viewRenderers, botId, barStyle, panelStyle, backdr
|
|
|
240
273
|
feedback?: boolean;
|
|
241
274
|
/** 만족도가 서버에 저장된 뒤 호출된다(분석 이벤트 전송용). `rating: null`은 평가 취소. */
|
|
242
275
|
onFeedback?: (e: XbNovaFeedbackEvent) => void;
|
|
276
|
+
/** 바를 눌러 대화 시트를 열 때 호출된다(분석 이벤트 전송용). 클릭이 Shadow DOM 안에서
|
|
277
|
+
* 일어나 호스트가 직접 잡을 수 없어서 여는 콜백이다. `defaultOpen`으로 처음부터 열린 경우엔
|
|
278
|
+
* 호출되지 않는다. */
|
|
279
|
+
onOpen?: (e: XbNovaOpenEvent) => void;
|
|
243
280
|
}): react.JSX.Element | null;
|
|
244
281
|
|
|
245
282
|
/** ref형 — 감싸는 엘리먼트를 늘리기 싫을 때. `<div ref={useXbNovaTrack("price", data)}>`. */
|
|
@@ -289,4 +326,4 @@ declare function useXbNovaSettings(): {
|
|
|
289
326
|
showBar: () => void;
|
|
290
327
|
};
|
|
291
328
|
|
|
292
|
-
export { type ChatMessage, type FactValue, type MessagePart, type ProductItem, type TextPart, type ToolPart, type UseXbNovaChatResult, type VerdictAction, type VerdictOutput, type ViewKind, type ViewRenderer, type ViewRendererMap, XbNovaChat, type XbNovaClientAction, type XbNovaClientActionResult, type XbNovaClientActions, type XbNovaContextEntry, XbNovaFact, XbNovaFacts, type XbNovaFeedbackEvent, type XbNovaFeedbackRating, type XbNovaFeedbackReason, type XbNovaOnboarding, XbNovaProvider, type XbNovaTheme, XbNovaTrack, trackXbNovaEvent, useXbNovaChat, useXbNovaContext, useXbNovaFact, useXbNovaFacts, useXbNovaSettings, useXbNovaTrack, useXbNovaVisitor };
|
|
329
|
+
export { type ChatMessage, type FactValue, type MessagePart, type ProductItem, type TextPart, type ToolPart, type UseXbNovaChatResult, type VerdictAction, type VerdictOutput, type ViewKind, type ViewRenderer, type ViewRendererMap, XbNovaChat, type XbNovaClientAction, type XbNovaClientActionResult, type XbNovaClientActions, type XbNovaContextEntry, XbNovaFact, XbNovaFacts, type XbNovaFeedbackEvent, type XbNovaFeedbackRating, type XbNovaFeedbackReason, type XbNovaOnboarding, type XbNovaOpenEvent, XbNovaProvider, type XbNovaTheme, XbNovaTrack, trackXbNovaEvent, useXbNovaChat, useXbNovaContext, useXbNovaFact, useXbNovaFacts, useXbNovaSettings, useXbNovaTrack, useXbNovaVisitor };
|
package/dist/index.d.ts
CHANGED
|
@@ -29,6 +29,13 @@ type ChatMessage = {
|
|
|
29
29
|
role: "user" | "assistant";
|
|
30
30
|
parts: MessagePart[];
|
|
31
31
|
};
|
|
32
|
+
/** 서버에 저장된 메시지(`parts`는 AI SDK UIMessage.parts 원본) — 이어 연 대화의 이력. */
|
|
33
|
+
type StoredMessage = {
|
|
34
|
+
id: string;
|
|
35
|
+
role: "user" | "assistant";
|
|
36
|
+
sender?: string;
|
|
37
|
+
parts: Record<string, unknown>[];
|
|
38
|
+
};
|
|
32
39
|
|
|
33
40
|
/** `awaitResult` 핸들러가 구조화된 결과를 돌려줄 때의 모양. `text`는 모델이 읽는 결과(서버로
|
|
34
41
|
* 전송)고, `view`+`output`은 채팅 말풍선에 직접 그릴 정규화된 데이터다 — 서버에는 가지 않는다.
|
|
@@ -100,12 +107,22 @@ type XbNovaTheme = {
|
|
|
100
107
|
colorScheme: "light" | "dark" | "system";
|
|
101
108
|
};
|
|
102
109
|
|
|
103
|
-
declare function XbNovaProvider({ apiKey, botId, appId, screen, apiBaseUrl, clientActions, theme, children, }: {
|
|
110
|
+
declare function XbNovaProvider({ apiKey, botId, appId, screen, apiBaseUrl, clientActions, theme, userKey, threadKey, sessionKey, children, }: {
|
|
104
111
|
apiKey: string;
|
|
105
112
|
botId: string;
|
|
106
113
|
appId: string;
|
|
107
114
|
screen?: string;
|
|
108
115
|
apiBaseUrl?: string;
|
|
116
|
+
/** 이 방문자를 가리키는 호스트 쪽 키(예: GA4 user_pseudo_id). nova가 남기는 방문자 ID(대화·넛지
|
|
117
|
+
* 이벤트·피드백) 전부가 이 값이 되고, `threadKey`와 함께 이전 대화를 찾는 데도 쓴다. 공개 키로 조회하므로 추측하기 어려운 값이어야 한다 — 회원 ID를 그대로
|
|
118
|
+
* 넘기지 않는다. 안 주면 SDK가 브라우저에 만들어 둔 `visitorId`를 쓴다. */
|
|
119
|
+
userKey?: string;
|
|
120
|
+
/** 대화를 이어 붙일 단위(예: `vehicle:${매물ID}`). 같은 유저 키·스레드 키로 위젯이 다시 열리면
|
|
121
|
+
* 이전 대화와 이력을 복원한다. 안 주면 열 때마다 새 대화다. */
|
|
122
|
+
threadKey?: string;
|
|
123
|
+
/** 이 방문의 세션 키(예: GA4 session_id). nova가 남기는 이벤트(위젯 노출·넛지·상담 버튼)와 대화에 실려
|
|
124
|
+
* 콘솔에서 세션 단위로 집계된다. 값이 바뀌면(세션 갱신) 그 뒤 이벤트부터 새 값으로 실린다. 안 주면 세션은 비운다. */
|
|
125
|
+
sessionKey?: string;
|
|
109
126
|
/** 이 페이지가 AI에게 내어줄 client action tool — 이름별로 설명·스키마·실행 함수를
|
|
110
127
|
* 등록한다("SDK 초기화 시점에 등록"). 스펙은 App 레벨 레지스트리로 자동 동기화되고
|
|
111
128
|
* (`XbNovaClientActionSync`), 콘솔의 tool 목록에 반영된다. 핸들러는 여기서만 산다. */
|
|
@@ -133,17 +150,24 @@ type XbNovaFeedbackEvent = {
|
|
|
133
150
|
reason?: XbNovaFeedbackReason;
|
|
134
151
|
};
|
|
135
152
|
type XbNovaOnboarding = {
|
|
136
|
-
|
|
153
|
+
/** 이어 열 대화가 없으면 null — 첫 메시지를 보낼 때 서버가 만든다(지연 생성). */
|
|
154
|
+
conversation_id: string | null;
|
|
155
|
+
/** 이어 연 대화의 이력. 새 대화면 빈 배열. */
|
|
156
|
+
messages?: StoredMessage[];
|
|
137
157
|
greeting: string;
|
|
138
158
|
quick_replies: string[];
|
|
139
159
|
branding: {
|
|
140
160
|
title?: string;
|
|
141
161
|
logo_url?: string;
|
|
142
162
|
avatar_text?: string;
|
|
163
|
+
badge_text?: string;
|
|
164
|
+
disclaimer?: string;
|
|
143
165
|
};
|
|
144
166
|
};
|
|
145
167
|
type UseXbNovaChatResult = {
|
|
146
168
|
onboarding: XbNovaOnboarding | null;
|
|
169
|
+
/** 대화 맨 위에 그릴 첫 말풍선(넛지 문구·인사말). 이어 연 대화면 이력에 이미 있으니 null. */
|
|
170
|
+
opening: string | null;
|
|
147
171
|
messages: ChatMessage[];
|
|
148
172
|
busy: boolean;
|
|
149
173
|
error: string | null;
|
|
@@ -154,10 +178,12 @@ type UseXbNovaChatResult = {
|
|
|
154
178
|
feedback: Record<string, XbNovaFeedbackRating>;
|
|
155
179
|
/** 낙관적으로 반영하고 서버에 저장한다. 실패하면 되돌린다. */
|
|
156
180
|
setFeedback: (messageId: string, rating: XbNovaFeedbackRating, reason?: XbNovaFeedbackReason) => Promise<void>;
|
|
181
|
+
/** client action이 그린 버튼(상담신청 등)이 눌렸을 때 채팅 화면이 부른다 — nova 넛지 퍼널의 마지막 단계. */
|
|
182
|
+
trackClientActionClick: (action: string, label: string | null) => void;
|
|
157
183
|
};
|
|
158
184
|
/** `botId`를 넘기면 Provider의 기본 봇 대신 그 봇으로 새 대화를 연다 — 넛지 handoff가 쓴다.
|
|
159
185
|
* `nudgeNodeId`를 넘기면 이 대화가 그 넛지에서 시작됐다고 서버에 표시한다 — 넛지 전환
|
|
160
|
-
* 퍼널(
|
|
186
|
+
* 퍼널(노출→클릭→첫 질문→상담 버튼 노출→클릭)이 이 값이 채워진 대화를 넛지 대화로 본다.
|
|
161
187
|
* `onDismissSheet`는 `dismissSheet: true`인 client action이 실행될 때 호출된다 —
|
|
162
188
|
* `<XbNovaChat>`이 시트를 닫는 함수를 넘겨준다(모바일에서 시트가 페이지 대부분을 덮어서,
|
|
163
189
|
* 안 닫으면 그 밑에서 일어나는 일이 안 보인다). */
|
|
@@ -211,7 +237,14 @@ type ViewRenderer = (props: {
|
|
|
211
237
|
}) => React.ReactNode;
|
|
212
238
|
type ViewRendererMap = Partial<Record<ViewKind, ViewRenderer>>;
|
|
213
239
|
|
|
214
|
-
|
|
240
|
+
/** 바(AI 버튼)를 눌러 대화 시트를 열 때 `onOpen`으로 넘어오는 값. */
|
|
241
|
+
type XbNovaOpenEvent = {
|
|
242
|
+
/** 넛지 힌트 맥락으로 열었는지 — 힌트가 떠 있었거나, 방금 조용히 소멸한 힌트를 이어 열었으면 true. */
|
|
243
|
+
fromNudge: boolean;
|
|
244
|
+
/** `fromNudge`일 때 그 힌트 문구. */
|
|
245
|
+
hintText?: string;
|
|
246
|
+
};
|
|
247
|
+
declare function XbNovaChat({ viewRenderers, botId, barStyle, panelStyle, backdropStyle, defaultOpen, idleText, avatarSize, onVerdictAction, feedback: feedbackEnabled, onFeedback, onOpen, }: {
|
|
215
248
|
/** 특정 view만 자체 컴포넌트로 덮어쓰고 싶을 때 — 지정 안 한 view는 기본 렌더러를 쓴다. */
|
|
216
249
|
viewRenderers?: ViewRendererMap;
|
|
217
250
|
/** Provider의 기본 봇 대신 다른 봇과 고정적으로 대화하고 싶을 때. 힌트를 눌러 열면
|
|
@@ -240,6 +273,10 @@ declare function XbNovaChat({ viewRenderers, botId, barStyle, panelStyle, backdr
|
|
|
240
273
|
feedback?: boolean;
|
|
241
274
|
/** 만족도가 서버에 저장된 뒤 호출된다(분석 이벤트 전송용). `rating: null`은 평가 취소. */
|
|
242
275
|
onFeedback?: (e: XbNovaFeedbackEvent) => void;
|
|
276
|
+
/** 바를 눌러 대화 시트를 열 때 호출된다(분석 이벤트 전송용). 클릭이 Shadow DOM 안에서
|
|
277
|
+
* 일어나 호스트가 직접 잡을 수 없어서 여는 콜백이다. `defaultOpen`으로 처음부터 열린 경우엔
|
|
278
|
+
* 호출되지 않는다. */
|
|
279
|
+
onOpen?: (e: XbNovaOpenEvent) => void;
|
|
243
280
|
}): react.JSX.Element | null;
|
|
244
281
|
|
|
245
282
|
/** ref형 — 감싸는 엘리먼트를 늘리기 싫을 때. `<div ref={useXbNovaTrack("price", data)}>`. */
|
|
@@ -289,4 +326,4 @@ declare function useXbNovaSettings(): {
|
|
|
289
326
|
showBar: () => void;
|
|
290
327
|
};
|
|
291
328
|
|
|
292
|
-
export { type ChatMessage, type FactValue, type MessagePart, type ProductItem, type TextPart, type ToolPart, type UseXbNovaChatResult, type VerdictAction, type VerdictOutput, type ViewKind, type ViewRenderer, type ViewRendererMap, XbNovaChat, type XbNovaClientAction, type XbNovaClientActionResult, type XbNovaClientActions, type XbNovaContextEntry, XbNovaFact, XbNovaFacts, type XbNovaFeedbackEvent, type XbNovaFeedbackRating, type XbNovaFeedbackReason, type XbNovaOnboarding, XbNovaProvider, type XbNovaTheme, XbNovaTrack, trackXbNovaEvent, useXbNovaChat, useXbNovaContext, useXbNovaFact, useXbNovaFacts, useXbNovaSettings, useXbNovaTrack, useXbNovaVisitor };
|
|
329
|
+
export { type ChatMessage, type FactValue, type MessagePart, type ProductItem, type TextPart, type ToolPart, type UseXbNovaChatResult, type VerdictAction, type VerdictOutput, type ViewKind, type ViewRenderer, type ViewRendererMap, XbNovaChat, type XbNovaClientAction, type XbNovaClientActionResult, type XbNovaClientActions, type XbNovaContextEntry, XbNovaFact, XbNovaFacts, type XbNovaFeedbackEvent, type XbNovaFeedbackRating, type XbNovaFeedbackReason, type XbNovaOnboarding, type XbNovaOpenEvent, XbNovaProvider, type XbNovaTheme, XbNovaTrack, trackXbNovaEvent, useXbNovaChat, useXbNovaContext, useXbNovaFact, useXbNovaFacts, useXbNovaSettings, useXbNovaTrack, useXbNovaVisitor };
|