{"_id":"@aientry/chat","name":"@aientry/chat","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@aientry/chat","version":"0.1.0","description":"AIEntry embeddable chat widget SDK","main":"dist/module/chat-sdk.umd.js","module":"dist/module/chat-sdk.es.js","types":"dist/module/types/index.d.ts","exports":{".":{"types":"./dist/module/types/index.d.ts","import":"./dist/module/chat-sdk.es.js","require":"./dist/module/chat-sdk.umd.js"},"./module":{"types":"./dist/module/types/index.d.ts","import":"./dist/module/chat-sdk.es.js","require":"./dist/module/chat-sdk.umd.js"},"./sdk":{"types":"./dist/module/types/sdk.d.ts","import":"./dist/sdk/chat-sdk.es.js","require":"./dist/sdk/chat-sdk.umd.js"},"./style.css":{"default":"./dist/module/style.css"},"./dist/*":"./dist/*"},"peerDependencies":{"react":"^19.1.1","react-dom":"^19.1.1","@aientry/ui-components":"0.2.0"},"publishConfig":{"access":"public"},"dependencies":{"@assistant-ui/react":"^0.11.53","@assistant-ui/react-markdown":"^0.11.9","@radix-ui/react-alert-dialog":"^1.1.6","@radix-ui/react-dialog":"^1.1.15","@radix-ui/react-slot":"^1.2.3","@radix-ui/react-tooltip":"^1.1.8","class-variance-authority":"^0.7.1","clsx":"^2.1.1","lucide-react":"^0.487.0","nanoid":"^5.1.6","react":"^19.1.1","react-dom":"^19.1.1","react-draggable":"^4.5.0","react-markdown":"^10.1.0","remark-gfm":"^4.0.1","tailwind-merge":"^2.6.0","zustand":"^5.0.10","@aientry/agui-ui":"0.1.0","@aientry/ui-components":"0.2.0"},"devDependencies":{"@tailwindcss/typography":"^0.5.19","@tailwindcss/vite":"^4.1.14","@types/react":"^19.1.16","@types/react-dom":"^19.1.9","@typescript-eslint/eslint-plugin":"^8.45.0","@typescript-eslint/parser":"^8.45.0","@vitejs/plugin-react":"^4.0.3","eslint":"^9.36.0","eslint-plugin-react-hooks":"^4.6.0","eslint-plugin-react-refresh":"^0.4.3","globals":"^14.0.0","tailwindcss":"^4","terser":"^5.44.1","typescript":"^5.2.2","vite":"^7.1.7","vite-plugin-css-injected-by-js":"^3.5.2","vite-plugin-dts":"^4.2.4","vite-plugin-externals":"^0.6.2","@aientry/eslint-config":"0.0.0","@aientry/tsconfig":"0.0.0"},"scripts":{"dev":"vite","dev:sdk":"vite --config vite.config.sdk.ts --open /test/sdk/index.html","build":"pnpm run build:sdk && pnpm run build:module","build:sdk":"NODE_ENV=production vite build --config vite.config.sdk.ts","build:module":"NODE_ENV=production vite build --config vite.config.module.ts","lint":"eslint . --ext ts,tsx --report-unused-disable-directives","preview:sdk":"vite preview --config vite.config.sdk.ts --open /test/sdk/index.html","preview:module":"vite preview --config vite.config.module.ts","type-check":"tsc --noEmit"},"_id":"@aientry/chat@0.1.0","_integrity":"sha512-5e6mBf5MuPVW/5JDPraY0srptprbW+bNr+JyokttcITf7bU46eQ+SleoK44Hfxj2rTcu5M4bSr9+vBjXovmC6w==","_resolved":"/tmp/adee63215d939be94e355f21e4817e0b/aientry-chat-0.1.0.tgz","_from":"file:aientry-chat-0.1.0.tgz","_nodeVersion":"23.9.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-5e6mBf5MuPVW/5JDPraY0srptprbW+bNr+JyokttcITf7bU46eQ+SleoK44Hfxj2rTcu5M4bSr9+vBjXovmC6w==","shasum":"1191a63026d6e3f6d268dab5cdb3819a407fd1a0","tarball":"https://registry.npmjs.org/@aientry/chat/-/chat-0.1.0.tgz","fileCount":106,"unpackedSize":7619235,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIHhtgdE4kceehuZfhXlK/3LZAGLlzgaEYX0rhPjlESdXAiEApCbA80ZQjsP/AQOcj8oFycFFxp3/FYM/kUESDJh6478="}]},"_npmUser":{"name":"kevinbrother2","email":"1299178488@qq.com"},"directories":{},"maintainers":[{"name":"kevinbrother2","email":"1299178488@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/chat_0.1.0_1781080802133_0.5674776564704895"},"_hasShrinkwrap":false}},"time":{"created":"2026-06-10T08:40:01.923Z","0.1.0":"2026-06-10T08:40:02.351Z","modified":"2026-06-10T08:40:02.619Z"},"maintainers":[{"name":"kevinbrother2","email":"1299178488@qq.com"}],"description":"AIEntry embeddable chat widget SDK","readme":"# AIEntry Chat Widget\n\n嵌入式聊天组件，支持两种构建模式。\n\n## 构建\n\n```bash\n# 构建所有模式\npnpm build\n\n# 或分别构建\npnpm build:sdk      # SDK 模式（CSS 打包到 JS）\npnpm build:module   # Module 模式（CSS 独立输出）\n```\n\n## 使用方式\n\n### 1. SDK 模式（推荐用于嵌入到网页）\n\n**特点：**\n\n- CSS 已打包到 JS 文件中\n- 只需引入一个 JS 文件\n- 适合通过 `<script>` 标签直接引入\n\n**HTML 使用：**\n\n```html\n<!DOCTYPE html>\n<html>\n<head>\n  <meta charset=\"UTF-8\">\n  <title>Chat Widget Demo</title>\n</head>\n<body>\n  <!-- Chat widget will be mounted here -->\n  <div id=\"chat-widget-app\"></div>\n\n  <!-- 引入 SDK（CSS 已内置） -->\n  <script src=\"path/to/dist/sdk/chat-sdk.umd.js\"></script>\n\n  <script>\n    // SDK 会自动初始化并挂载到 #chat-widget-app\n    // 或者手动控制\n    const widget = AientryChatSDK.initChatApp({\n      kbId: 'your-kb-id',\n      autoMount: true,\n      mode: 'bubble',\n      launcher: true\n    });\n  </script>\n</body>\n</html>\n```\n\n**NPM 使用：**\n\n```typescript\nimport '@aientry/chat/sdk'\n// 或\nimport { initChatApp } from '@aientry/chat/sdk'\n\nconst widget = initChatApp({\n  kbId: 'your-kb-id',\n  autoMount: true\n})\n```\n\n### 2. Module 模式（推荐用于 React 项目）\n\n**特点：**\n\n- CSS 独立输出为 `.css` 文件\n- 需要同时引入 JS 和 CSS\n- 适合作为 npm 包在 React 项目中使用\n\n**使用方式：**\n\n```typescript\n// 1. 导入 CSS（必须）\nimport '@aientry/chat/style.css'\n\n// 2. 导入组件\nimport { ChatApp } from '@aientry/chat/module'\n// 或使用默认导入\nimport { initChatApp } from '@aientry/chat'\n\nfunction App() {\n  return (\n    <ChatApp kbId=\"your-kb-id\" />\n  )\n}\n```\n\n**或者使用命令式 API：**\n\n```typescript\nimport '@aientry/chat/style.css'\nimport { initChatApp } from '@aientry/chat'\n\nconst widget = initChatApp({\n  kbId: 'your-kb-id',\n  autoMount: true,\n  mode: 'bubble',\n  launcher: true,\n  position: 'fixed',\n  zIndex: 9999\n})\n\n// 控制 widget\nwidget.open()\nwidget.close()\nwidget.unmount()\n```\n\n## 两种模式的输出\n\n### SDK 模式输出\n\n```\ndist/sdk/\n├── chat-sdk.es.js      # ES Module（包含 CSS）\n└── chat-sdk.umd.js     # UMD（包含 CSS）\n```\n\n### Module 模式输出\n\n```\ndist/module/\n├── chat-sdk.es.js      # ES Module\n├── chat-sdk.umd.js     # UMD\n├── style.css           # 独立的 CSS 文件\n└── types/                      # TypeScript 类型定义\n```\n\n## Package.json Exports\n\n```json\n{\n  \"exports\": {\n    \".\": \"./dist/module/...\",           // 默认是 Module 模式\n    \"./sdk\": \"./dist/sdk/...\",          // SDK 模式\n    \"./module\": \"./dist/module/...\"     // Module 模式（显式）\n  }\n}\n```\n\n## API\n\n详见 TypeScript 类型定义。\n\n主要导出：\n\n- `initChatApp(options)` - 初始化聊天组件\n- `ChatApp` - React 组件\n- `createChatWidget(options)` - 创建聊天组件实例\n- `initChatSDK(config)` - 配置 SDK\n\n## 开发\n\n```bash\npnpm dev          # 开发模式\npnpm dev:test     # 测试页面开发模式\npnpm preview      # 预览构建结果\npnpm lint         # 代码检查\n```\n\n## 近期更新 (2025-01-07)\n\n### 组件重构\n\n重构了聊天界面以提高可复用性和响应式体验：\n\n**新增组件**:\n- `ChatCore` - 核心聊天组件（不含头部和徽章）\n- `ResizableChatWindow` - 可调整大小的聊天窗口包装器\n\n**更新组件**:\n- `ChatWindow` - 现在使用 `ChatCore`，支持 `showHeader` 和 `showBadge` props\n\n\n### 架构设计\n\n### 核心组件\n\n| 组件 | 职责 |\n|------|------|\n| `Chat` | 聊天主界面：消息列表、输入框、欢迎页 |\n| `FloatingChat` | 浮动聊天入口：管理浮窗按钮、聊天窗口、Portal 渲染 |\n| `createChatWidget` | SDK 工厂函数：创建 `ChatWidgetController` 实例 |\n| `FloatButton` | 浮动开关按钮 |\n| `FloatingChatWindow` | 可拖拽/调整大小的聊天窗口 |\n| `ChatContainer` | Chat 包装容器 |\n| `FloatingChatContext` | 浮动聊天状态共享（碰撞检测、视口检测） |\n\n### 构建配置\n\n- `vite.config.sdk.ts` - SDK 构建\n- `vite.config.module.ts` - Module 构建\n\n## 文档\n\n- [CHORE.md](./CHORE.md) - 完整的重构设计文档\n- [docs/MCP_TESTING.md](./docs/MCP_TESTING.md) - MCP 协议测试指南\n- [docs/PERFORMANCE_REPORT.md](./docs/PERFORMANCE_REPORT.md) - 性能测试报告\n","readmeFilename":"README.md","_rev":"1-6ee020ada9b9a9e226886fac2e372547"}