@gendive/chatllm 0.13.2 → 0.14.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.
@@ -444,6 +444,12 @@ interface ThemeConfig {
444
444
  borderRadius?: 'none' | 'sm' | 'md' | 'lg' | 'xl';
445
445
  }
446
446
  interface ChatUIProps {
447
+ /**
448
+ * @description 외부에서 생성한 useChatUI 상태 주입
449
+ * @Todo vibecode - 레이아웃 수준에서 hook 초기화 후 ChatUI와 ChatSidebar에 공유할 때 사용
450
+ * 제공 시 ChatUI 내부에서 useChatUI를 호출하지 않고 이 상태를 직접 사용
451
+ */
452
+ chatState?: UseChatUIReturn;
447
453
  /** 사용 가능한 모델 목록 (기본값 제공) */
448
454
  models?: ModelConfig[];
449
455
  /** 사용 가능한 Actions */
@@ -478,6 +484,8 @@ interface ChatUIProps {
478
484
  keepRecentMessages?: number;
479
485
  /** 스토리지 키 (로컬 저장용) */
480
486
  storageKey?: string;
487
+ /** @Todo vibecode - 초기 선택 세션 ID (미제공 시 sessions[0] 자동 선택) */
488
+ initialSessionId?: string;
481
489
  /** CSS 클래스 */
482
490
  className?: string;
483
491
  /** 메시지 전송 핸들러 (커스텀 API 사용 시) */
@@ -887,6 +895,10 @@ interface UseChatUIReturn {
887
895
  * 풀 기능 채팅 UI
888
896
  */
889
897
 
898
+ /**
899
+ * @description ChatUI 메인 컴포넌트
900
+ * @Todo vibecode - chatState 제공 시 외부 상태 사용, 미제공 시 내부 useChatUI 호출
901
+ */
890
902
  declare const ChatUI: React$1.FC<ChatUIProps>;
891
903
 
892
904
  /**
@@ -903,6 +915,8 @@ interface UseChatUIOptions {
903
915
  initialPersonalization?: Partial<PersonalizationConfig>;
904
916
  /** @Todo vibecode - 개인화 설정 변경 콜백 (백엔드 저장용) */
905
917
  onPersonalizationChange?: (config: PersonalizationConfig) => void;
918
+ /** @Todo vibecode - 초기 선택 세션 ID (미제공 시 sessions[0] 자동 선택) */
919
+ initialSessionId?: string;
906
920
  /** API 키 */
907
921
  apiKey?: string;
908
922
  /** API 엔드포인트 */
@@ -444,6 +444,12 @@ interface ThemeConfig {
444
444
  borderRadius?: 'none' | 'sm' | 'md' | 'lg' | 'xl';
445
445
  }
446
446
  interface ChatUIProps {
447
+ /**
448
+ * @description 외부에서 생성한 useChatUI 상태 주입
449
+ * @Todo vibecode - 레이아웃 수준에서 hook 초기화 후 ChatUI와 ChatSidebar에 공유할 때 사용
450
+ * 제공 시 ChatUI 내부에서 useChatUI를 호출하지 않고 이 상태를 직접 사용
451
+ */
452
+ chatState?: UseChatUIReturn;
447
453
  /** 사용 가능한 모델 목록 (기본값 제공) */
448
454
  models?: ModelConfig[];
449
455
  /** 사용 가능한 Actions */
@@ -478,6 +484,8 @@ interface ChatUIProps {
478
484
  keepRecentMessages?: number;
479
485
  /** 스토리지 키 (로컬 저장용) */
480
486
  storageKey?: string;
487
+ /** @Todo vibecode - 초기 선택 세션 ID (미제공 시 sessions[0] 자동 선택) */
488
+ initialSessionId?: string;
481
489
  /** CSS 클래스 */
482
490
  className?: string;
483
491
  /** 메시지 전송 핸들러 (커스텀 API 사용 시) */
@@ -887,6 +895,10 @@ interface UseChatUIReturn {
887
895
  * 풀 기능 채팅 UI
888
896
  */
889
897
 
898
+ /**
899
+ * @description ChatUI 메인 컴포넌트
900
+ * @Todo vibecode - chatState 제공 시 외부 상태 사용, 미제공 시 내부 useChatUI 호출
901
+ */
890
902
  declare const ChatUI: React$1.FC<ChatUIProps>;
891
903
 
892
904
  /**
@@ -903,6 +915,8 @@ interface UseChatUIOptions {
903
915
  initialPersonalization?: Partial<PersonalizationConfig>;
904
916
  /** @Todo vibecode - 개인화 설정 변경 콜백 (백엔드 저장용) */
905
917
  onPersonalizationChange?: (config: PersonalizationConfig) => void;
918
+ /** @Todo vibecode - 초기 선택 세션 ID (미제공 시 sessions[0] 자동 선택) */
919
+ initialSessionId?: string;
906
920
  /** API 키 */
907
921
  apiKey?: string;
908
922
  /** API 엔드포인트 */
@@ -1369,7 +1369,8 @@ var useChatUI = (options) => {
1369
1369
  }));
1370
1370
  setSessions(sessionsWithoutMessages);
1371
1371
  if (sessionsWithoutMessages.length > 0) {
1372
- setCurrentSessionId(sessionsWithoutMessages[0].id);
1372
+ const targetId = options.initialSessionId && sessionsWithoutMessages.some((s) => s.id === options.initialSessionId) ? options.initialSessionId : sessionsWithoutMessages[0].id;
1373
+ setCurrentSessionId(targetId);
1373
1374
  }
1374
1375
  }).catch((error) => {
1375
1376
  onError?.(error instanceof Error ? error : new Error("Failed to load sessions"));
@@ -1391,8 +1392,10 @@ var useChatUI = (options) => {
1391
1392
  const parsed = JSON.parse(saved);
1392
1393
  setSessions(parsed);
1393
1394
  if (parsed.length > 0) {
1394
- setCurrentSessionId(parsed[0].id);
1395
- setSelectedModel(parsed[0].model);
1395
+ const targetSession = options.initialSessionId ? parsed.find((s) => s.id === options.initialSessionId) : null;
1396
+ const selected = targetSession || parsed[0];
1397
+ setCurrentSessionId(selected.id);
1398
+ setSelectedModel(selected.model);
1396
1399
  }
1397
1400
  } catch {
1398
1401
  }
@@ -7888,76 +7891,23 @@ var injectStyles = () => {
7888
7891
  `;
7889
7892
  document.head.appendChild(style);
7890
7893
  };
7891
- var ChatUI = ({
7892
- models = DEFAULT_MODELS,
7893
- actions = DEFAULT_ACTIONS,
7894
- templates = DEFAULT_TEMPLATES,
7895
- personalization,
7896
- onPersonalizationChange,
7894
+ var ChatUIView = ({
7895
+ state,
7896
+ models,
7897
+ actions,
7898
+ templates,
7899
+ showSidebar,
7900
+ sidebarWidth,
7901
+ showSettings,
7902
+ showModelSelector,
7903
+ showThinking,
7904
+ thinkingDefaultOpen,
7905
+ theme,
7906
+ className,
7897
7907
  apiKey,
7898
7908
  onApiKeyChange,
7899
- apiEndpoint = "/api/chat",
7900
- theme,
7901
- showSidebar = true,
7902
- sidebarWidth,
7903
- showSettings = true,
7904
- showModelSelector = true,
7905
- systemPrompt,
7906
- contextCompressionThreshold = 20,
7907
- keepRecentMessages = 6,
7908
- storageKey = "chatllm_sessions",
7909
- className = "",
7910
- onSendMessage,
7911
- onSessionChange,
7912
- onError,
7913
- onTitleChange,
7914
- generateTitle: generateTitle2,
7915
- // External Storage Props
7916
- useExternalStorage = false,
7917
- onLoadSessions,
7918
- onCreateSession,
7919
- onLoadSession,
7920
- onDeleteSession,
7921
- onUpdateSessionTitle,
7922
- onSaveMessages,
7923
- // Thinking Block Props
7924
- showThinking = true,
7925
- thinkingDefaultOpen = false,
7926
- // Deep Research Props
7927
- deepResearch,
7928
- // Skills Props
7929
- skills
7909
+ deepResearchEnabled
7930
7910
  }) => {
7931
- injectStyles();
7932
- const hookOptions = {
7933
- models,
7934
- actions,
7935
- initialPersonalization: personalization,
7936
- onPersonalizationChange,
7937
- apiKey,
7938
- apiEndpoint,
7939
- initialModel: models[0]?.id,
7940
- storageKey,
7941
- contextCompressionThreshold,
7942
- keepRecentMessages,
7943
- onSendMessage,
7944
- onSessionChange,
7945
- onError,
7946
- onTitleChange,
7947
- generateTitle: generateTitle2,
7948
- // External Storage Options
7949
- useExternalStorage,
7950
- onLoadSessions,
7951
- onCreateSession,
7952
- onLoadSession,
7953
- onDeleteSession,
7954
- onUpdateSessionTitle,
7955
- onSaveMessages,
7956
- // Deep Research Options
7957
- deepResearch,
7958
- // Skills Options
7959
- skills
7960
- };
7961
7911
  const {
7962
7912
  sessions,
7963
7913
  currentSession,
@@ -7988,8 +7938,6 @@ var ChatUI = ({
7988
7938
  setSelectedAction,
7989
7939
  copyMessage,
7990
7940
  startEdit,
7991
- cancelEdit,
7992
- saveEdit,
7993
7941
  regenerate,
7994
7942
  askOtherModel,
7995
7943
  setActiveAlternative,
@@ -7997,19 +7945,15 @@ var ChatUI = ({
7997
7945
  loadingAlternativeFor,
7998
7946
  updatePersonalization,
7999
7947
  models: hookModels,
8000
- // Deep Research
8001
7948
  isDeepResearchMode,
8002
7949
  toggleDeepResearchMode,
8003
- // Poll
8004
7950
  handlePollSubmit,
8005
- // Memory
8006
7951
  globalMemory,
8007
7952
  compressionState,
8008
- // Skills
8009
7953
  manualSkills,
8010
7954
  activeSkillExecution,
8011
7955
  executeManualSkill
8012
- } = useChatUI(hookOptions);
7956
+ } = state;
8013
7957
  const greeting = currentPersonalization.userProfile.nickname ? `\uC548\uB155\uD558\uC138\uC694, ${currentPersonalization.userProfile.nickname}\uB2D8` : "\uC548\uB155\uD558\uC138\uC694";
8014
7958
  const handleTemplateClick = (template) => {
8015
7959
  setInput(template.prompt);
@@ -8140,7 +8084,7 @@ var ChatUI = ({
8140
8084
  actions,
8141
8085
  onDeepResearch: toggleDeepResearchMode,
8142
8086
  isDeepResearchMode,
8143
- deepResearchEnabled: !!deepResearch?.onWebSearch,
8087
+ deepResearchEnabled,
8144
8088
  manualSkills,
8145
8089
  onSkillSelect: executeManualSkill,
8146
8090
  activeSkillExecution
@@ -8173,6 +8117,134 @@ var ChatUI = ({
8173
8117
  }
8174
8118
  );
8175
8119
  };
8120
+ var ChatUIWithHook = ({
8121
+ models = DEFAULT_MODELS,
8122
+ actions = DEFAULT_ACTIONS,
8123
+ templates = DEFAULT_TEMPLATES,
8124
+ personalization,
8125
+ onPersonalizationChange,
8126
+ apiKey,
8127
+ onApiKeyChange,
8128
+ apiEndpoint = "/api/chat",
8129
+ theme,
8130
+ showSidebar = true,
8131
+ sidebarWidth,
8132
+ showSettings = true,
8133
+ showModelSelector = true,
8134
+ systemPrompt,
8135
+ contextCompressionThreshold = 20,
8136
+ keepRecentMessages = 6,
8137
+ storageKey = "chatllm_sessions",
8138
+ initialSessionId,
8139
+ className = "",
8140
+ onSendMessage,
8141
+ onSessionChange,
8142
+ onError,
8143
+ onTitleChange,
8144
+ generateTitle: generateTitle2,
8145
+ useExternalStorage = false,
8146
+ onLoadSessions,
8147
+ onCreateSession,
8148
+ onLoadSession,
8149
+ onDeleteSession,
8150
+ onUpdateSessionTitle,
8151
+ onSaveMessages,
8152
+ showThinking = true,
8153
+ thinkingDefaultOpen = false,
8154
+ deepResearch,
8155
+ skills
8156
+ }) => {
8157
+ const hookOptions = {
8158
+ models,
8159
+ actions,
8160
+ initialPersonalization: personalization,
8161
+ onPersonalizationChange,
8162
+ initialSessionId,
8163
+ apiKey,
8164
+ apiEndpoint,
8165
+ initialModel: models[0]?.id,
8166
+ storageKey,
8167
+ contextCompressionThreshold,
8168
+ keepRecentMessages,
8169
+ onSendMessage,
8170
+ onSessionChange,
8171
+ onError,
8172
+ onTitleChange,
8173
+ generateTitle: generateTitle2,
8174
+ useExternalStorage,
8175
+ onLoadSessions,
8176
+ onCreateSession,
8177
+ onLoadSession,
8178
+ onDeleteSession,
8179
+ onUpdateSessionTitle,
8180
+ onSaveMessages,
8181
+ deepResearch,
8182
+ skills
8183
+ };
8184
+ const state = useChatUI(hookOptions);
8185
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
8186
+ ChatUIView,
8187
+ {
8188
+ state,
8189
+ models,
8190
+ actions,
8191
+ templates,
8192
+ showSidebar,
8193
+ sidebarWidth,
8194
+ showSettings,
8195
+ showModelSelector,
8196
+ showThinking,
8197
+ thinkingDefaultOpen,
8198
+ theme,
8199
+ className,
8200
+ apiKey,
8201
+ onApiKeyChange,
8202
+ deepResearchEnabled: !!deepResearch?.onWebSearch
8203
+ }
8204
+ );
8205
+ };
8206
+ var ChatUI = (props) => {
8207
+ injectStyles();
8208
+ if (props.chatState) {
8209
+ const {
8210
+ models = DEFAULT_MODELS,
8211
+ actions = DEFAULT_ACTIONS,
8212
+ templates = DEFAULT_TEMPLATES,
8213
+ showSidebar = true,
8214
+ sidebarWidth,
8215
+ showSettings = true,
8216
+ showModelSelector = true,
8217
+ showThinking = true,
8218
+ thinkingDefaultOpen = false,
8219
+ theme,
8220
+ className = "",
8221
+ apiKey,
8222
+ onApiKeyChange,
8223
+ deepResearch
8224
+ } = props;
8225
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
8226
+ ChatUIView,
8227
+ {
8228
+ state: props.chatState,
8229
+ models,
8230
+ actions,
8231
+ templates,
8232
+ showSidebar,
8233
+ sidebarWidth,
8234
+ showSettings,
8235
+ showModelSelector,
8236
+ showThinking,
8237
+ thinkingDefaultOpen,
8238
+ theme,
8239
+ className,
8240
+ apiKey,
8241
+ onApiKeyChange,
8242
+ deepResearchEnabled: !!deepResearch?.onWebSearch
8243
+ }
8244
+ );
8245
+ }
8246
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ChatUIWithHook, { ...props });
8247
+ };
8176
8248
 
8177
8249
  // src/react/hooks/useDeepResearch.ts
8178
8250
  var import_react16 = require("react");