{"_id":"@ai-chat-ui-kit/core","_rev":"4-25603b0fd6eac7848628b89523cf91de","name":"@ai-chat-ui-kit/core","dist-tags":{"latest":"0.1.3"},"versions":{"0.1.0":{"name":"@ai-chat-ui-kit/core","version":"0.1.0","keywords":["ai","chat","headless","store"],"author":{"name":"edenxpzhang"},"license":"MIT","_id":"@ai-chat-ui-kit/core@0.1.0","maintainers":[{"name":"eden_zxpzhang","email":"1405051717@qq.com"}],"homepage":"https://edenxpzhang.github.io/ai-chat-ui-kit/","bugs":{"url":"https://github.com/edenxpzhang/ai-chat-ui-kit/issues"},"dist":{"shasum":"2921bad58839982bb2c18aa2cc14850c31e9f688","tarball":"https://registry.npmjs.org/@ai-chat-ui-kit/core/-/core-0.1.0.tgz","fileCount":143,"integrity":"sha512-e32+B0bKI865pUqr3whvKiC9YtJIhD0rZ0EoWGWu2TbuqIbOENX3SM7/yPR9dic9YgIS97YQ3qvQsuFCSVlsDA==","signatures":[{"sig":"MEQCIFT8LnjXFaq6z9blMq2/D01A0BEm/ogim+XWVpWCvvZAAiB9K64a4uhKRwKtMJkYjBP2Ex5x+lLuLjsncfsJXWdEqA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":473826},"main":"dist/index.cjs","type":"module","types":"dist/index.d.ts","module":"dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"},"./package.json":"./package.json"},"gitHead":"5ae682446fef02e6c0af919228fe3b3f218809f0","scripts":{"dev":"tsup --watch","test":"vitest run","build":"tsup","clean":"rimraf dist","test:watch":"vitest","type-check":"tsc --noEmit"},"_npmUser":{"name":"eden_zxpzhang","email":"1405051717@qq.com"},"repository":{"url":"git+https://github.com/edenxpzhang/ai-chat-ui-kit.git","type":"git","directory":"packages/core"},"_npmVersion":"10.9.2","description":"Core logic layer for AI Chat UI Kit (Headless)","directories":{},"_nodeVersion":"22.14.0","dependencies":{"katex":"^0.16.0","marked":"^12.0.0","mermaid":"^10.9.0","highlight.js":"^11.9.0","marked-highlight":"^2.0.0"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^7.0.0","typescript":"^5.0.0"},"_npmOperationalInternal":{"tmp":"tmp/core_0.1.0_1778672460434_0.8991085111127237","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@ai-chat-ui-kit/core","version":"0.1.1","keywords":["ai","chat","headless","store"],"author":{"name":"edenxpzhang"},"license":"MIT","_id":"@ai-chat-ui-kit/core@0.1.1","maintainers":[{"name":"eden_zxpzhang","email":"1405051717@qq.com"}],"homepage":"https://edenxpzhang.github.io/ai-chat-ui-kit/","bugs":{"url":"https://github.com/edenxpzhang/ai-chat-ui-kit/issues"},"dist":{"shasum":"225fed1265c3c29ea4069513152c87927bb86c72","tarball":"https://registry.npmjs.org/@ai-chat-ui-kit/core/-/core-0.1.1.tgz","fileCount":144,"integrity":"sha512-+owQvJBJCyM3KUISNs60TrUVm4Q+7mYeJbdpBddArfsY297GXbBNnUuofJ8zgCmgCc6xrWwCOK9RXEQyuD1nHA==","signatures":[{"sig":"MEQCIFc3NEvcsY96CZE9unxN7pwWDWEovRSrns2Dz/K5WbbKAiB9U7MKRRP4t3LL/+lKtGFMhixlzQcM35WwupRzMvv3lA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":479803},"main":"dist/index.cjs","type":"module","types":"dist/index.d.ts","module":"dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"},"./package.json":"./package.json"},"gitHead":"8af973f1f5af5167ed21ab181672168a433acf7e","scripts":{"dev":"tsup --watch","test":"vitest run","build":"tsup","clean":"rimraf dist","test:watch":"vitest","type-check":"tsc --noEmit"},"_npmUser":{"name":"eden_zxpzhang","email":"1405051717@qq.com"},"repository":{"url":"git+https://github.com/edenxpzhang/ai-chat-ui-kit.git","type":"git","directory":"packages/core"},"_npmVersion":"10.9.2","description":"Core logic layer for AI Chat UI Kit (Headless)","directories":{},"_nodeVersion":"22.14.0","dependencies":{"katex":"^0.16.0","marked":"^12.0.0","mermaid":"^10.9.0","highlight.js":"^11.9.0","marked-highlight":"^2.0.0"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^7.0.0","typescript":"^5.0.0"},"_npmOperationalInternal":{"tmp":"tmp/core_0.1.1_1778672984990_0.13718235399281142","host":"s3://npm-registry-packages-npm-production"}},"0.1.2":{"name":"@ai-chat-ui-kit/core","version":"0.1.2","keywords":["ai","chat","headless","store"],"author":{"name":"edenxpzhang"},"license":"MIT","_id":"@ai-chat-ui-kit/core@0.1.2","maintainers":[{"name":"eden_zxpzhang","email":"1405051717@qq.com"}],"homepage":"https://edenxpzhang.github.io/ai-chat-ui-kit/","bugs":{"url":"https://github.com/edenxpzhang/ai-chat-ui-kit/issues"},"dist":{"shasum":"f0f8cd709e9f98ec4293af69cc2396f89746a884","tarball":"https://registry.npmjs.org/@ai-chat-ui-kit/core/-/core-0.1.2.tgz","fileCount":145,"integrity":"sha512-AMLN+ehCAvYN+rNha4Dc+VZTKCAoV504EUpEKe76aod2CWAUTMxsbtn+cjXPG+sTw5j5rycNOnKc2yQSGgZcrA==","signatures":[{"sig":"MEQCIG4JmcsyHCFm4Oy0cvN4ZPyeQSKjrKHTWRxB6N+aj9gbAiAoZc8Tq0iA357bwW9qQpqHcSpH9+PzhlyS14gcHkHCPg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":480908},"main":"dist/index.cjs","type":"module","types":"dist/index.d.ts","module":"dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"},"./package.json":"./package.json"},"gitHead":"812d8a9533bb74ad15c109119653a27c8f92abe9","scripts":{"dev":"tsup --watch","test":"vitest run","build":"tsup","clean":"rimraf dist","test:watch":"vitest","type-check":"tsc --noEmit"},"_npmUser":{"name":"eden_zxpzhang","email":"1405051717@qq.com"},"repository":{"url":"git+https://github.com/edenxpzhang/ai-chat-ui-kit.git","type":"git","directory":"packages/core"},"_npmVersion":"10.9.2","description":"Core logic layer for AI Chat UI Kit (Headless)","directories":{},"_nodeVersion":"22.14.0","dependencies":{"katex":"^0.16.0","marked":"^12.0.0","mermaid":"^10.9.0","highlight.js":"^11.9.0","marked-highlight":"^2.0.0"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^7.0.0","typescript":"^5.0.0"},"_npmOperationalInternal":{"tmp":"tmp/core_0.1.2_1778811861621_0.02454068173476398","host":"s3://npm-registry-packages-npm-production"}},"0.1.3":{"name":"@ai-chat-ui-kit/core","version":"0.1.3","description":"Core logic layer for AI Chat UI Kit (Headless)","type":"module","main":"dist/index.cjs","module":"dist/index.js","types":"dist/index.d.ts","repository":{"type":"git","url":"git+https://github.com/edenxpzhang/ai-chat-ui-kit.git","directory":"packages/core"},"homepage":"https://edenxpzhang.github.io/ai-chat-ui-kit/","bugs":{"url":"https://github.com/edenxpzhang/ai-chat-ui-kit/issues"},"exports":{".":{"import":"./dist/index.js","require":"./dist/index.cjs","types":"./dist/index.d.ts"},"./package.json":"./package.json"},"scripts":{"dev":"tsup --watch","build":"tsup","test":"vitest run","test:watch":"vitest","clean":"rimraf dist","type-check":"tsc --noEmit"},"keywords":["ai","chat","headless","store"],"author":{"name":"edenxpzhang"},"license":"MIT","dependencies":{"marked":"^12.0.0","marked-highlight":"^2.0.0","highlight.js":"^11.9.0","mermaid":"^10.9.0","katex":"^0.16.0"},"devDependencies":{"tsup":"^7.0.0","typescript":"^5.0.0"},"_id":"@ai-chat-ui-kit/core@0.1.3","gitHead":"af057022ce9fcca43e128b8b8bda75ca5e7db9fa","_nodeVersion":"22.14.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-DtVXzqqJYIj5HqrNHUvnmfgSnlh0ljWvsG6CFNT/Jiurm21VmwOqlYZYOgVj7dN4wz9VS/DuTb/xbugnl194Ew==","shasum":"168798e16e9a8ca6499253de2b49027573e32286","tarball":"https://registry.npmjs.org/@ai-chat-ui-kit/core/-/core-0.1.3.tgz","fileCount":145,"unpackedSize":476500,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIAlaWjJm4ZHMY/ed7yRIULB7+GnRainMmgRio0fYbADBAiB1f+j4tGcMxoY0tdZVNwAnqJg/HM0eMxJxYVSrUmbpPQ=="}]},"_npmUser":{"name":"eden_zxpzhang","email":"1405051717@qq.com"},"directories":{},"maintainers":[{"name":"eden_zxpzhang","email":"1405051717@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/core_0.1.3_1778895829713_0.8686487756998611"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-13T11:41:00.352Z","modified":"2026-05-16T01:43:49.998Z","0.1.0":"2026-05-13T11:41:00.636Z","0.1.1":"2026-05-13T11:49:45.160Z","0.1.2":"2026-05-15T02:24:21.767Z","0.1.3":"2026-05-16T01:43:49.882Z"},"bugs":{"url":"https://github.com/edenxpzhang/ai-chat-ui-kit/issues"},"author":{"name":"edenxpzhang"},"license":"MIT","homepage":"https://edenxpzhang.github.io/ai-chat-ui-kit/","keywords":["ai","chat","headless","store"],"repository":{"type":"git","url":"git+https://github.com/edenxpzhang/ai-chat-ui-kit.git","directory":"packages/core"},"description":"Core logic layer for AI Chat UI Kit (Headless)","maintainers":[{"name":"eden_zxpzhang","email":"1405051717@qq.com"}],"readme":"# @ai-chat-ui-kit/core\r\n\r\nCore logic layer for AI Chat UI Kit - Headless mode state management, API adapters, and plugin system.\r\n\r\n![Version](https://img.shields.io/npm/v/@ai-chat-ui-kit/core.svg)\r\n![License](https://img.shields.io/npm/l/@ai-chat-ui-kit/core.svg)\r\n![TypeScript](https://img.shields.io/badge/TypeScript-5.0-blue.svg)\r\n\r\n## ✨ Features\r\n\r\n- 🎯 **Headless Mode** - Use only the logic layer, build your own UI\r\n- 📦 **State Management** - Predictable state container with `createChatStore()`\r\n- 🌐 **API Adapters** - Built-in adapters for OpenAI, Anthropic, and custom APIs\r\n- 🔌 **Plugin System** - Extend functionality with custom plugins\r\n- 🎯 **TypeScript Support** - Complete type definitions included\r\n\r\n## 📦 Installation\r\n\r\n```bash\r\npnpm add @ai-chat-ui-kit/core\r\n# or\r\nnpm install @ai-chat-ui-kit/core\r\n# or\r\nyarn add @ai-chat-ui-kit/core\r\n```\r\n\r\n## 🚀 Quick Start\r\n\r\n### Headless Mode (No UI)\r\n\r\n```typescript\r\nimport { createChatStore, createAPIAdapter } from '@ai-chat-ui-kit/core';\r\n\r\n// Create state store\r\nconst store = createChatStore({\r\n  initialState: {\r\n    messages: [],\r\n    loading: false\r\n  }\r\n});\r\n\r\n// Subscribe to state changes\r\nstore.subscribe((state) => {\r\n  console.log('Messages:', state.messages);\r\n  console.log('Loading:', state.loading);\r\n  // Update your custom UI here\r\n});\r\n\r\n// Create API adapter\r\nconst adapter = createAPIAdapter({\r\n  type: 'openai',\r\n  apiKey: process.env.OPENAI_API_KEY,\r\n  model: 'gpt-4'\r\n});\r\n\r\n// Handle user input\r\nasync function handleUserMessage(message: string) {\r\n  // Add user message\r\n  store.dispatch({\r\n    type: 'ADD_MESSAGE',\r\n    payload: { role: 'user', content: message }\r\n  });\r\n\r\n  // Set loading\r\n  store.dispatch({ type: 'SET_LOADING', payload: true });\r\n\r\n  // Get AI response\r\n  const response = await adapter.sendMessage(message);\r\n\r\n  // Add AI response\r\n  store.dispatch({\r\n    type: 'ADD_MESSAGE',\r\n    payload: { role: 'assistant', content: response }\r\n  });\r\n\r\n  // Clear loading\r\n  store.dispatch({ type: 'SET_LOADING', payload: false });\r\n}\r\n```\r\n\r\n## 📖 API Reference\r\n\r\n### `createChatStore(config?)`\r\n\r\nCreate a chat state management store.\r\n\r\n```typescript\r\nconst store = createChatStore({\r\n  initialState?: Partial<ChatState>,\r\n  middleware?: Middleware[]\r\n});\r\n\r\ninterface ChatState {\r\n  messages: Message[];\r\n  loading: boolean;\r\n  error: string | null;\r\n  theme: string;\r\n}\r\n\r\ninterface ChatStore {\r\n  getState(): ChatState;\r\n  dispatch(action: Action): void;\r\n  subscribe(listener: (state: ChatState) => void): () => void;\r\n}\r\n```\r\n\r\n### `createAPIAdapter(config)`\r\n\r\nCreate an API adapter for different AI backends.\r\n\r\n```typescript\r\n// OpenAI\r\nconst openai = createAPIAdapter({\r\n  type: 'openai',\r\n  apiKey: 'your-api-key',\r\n  model: 'gpt-4'\r\n});\r\n\r\n// Anthropic (Claude)\r\nconst anthropic = createAPIAdapter({\r\n  type: 'anthropic',\r\n  apiKey: 'your-api-key',\r\n  model: 'claude-3-opus'\r\n});\r\n\r\n// Custom API\r\nconst custom = createAPIAdapter({\r\n  type: 'custom',\r\n  endpoint: 'https://your-api.com/chat',\r\n  headers: { 'Authorization': 'Bearer token' }\r\n});\r\n\r\ninterface APIAdapter {\r\n  sendMessage(message: string, history?: Message[]): Promise<string>;\r\n  streamMessage?(message: string, history?: Message[]): AsyncIterable<string>;\r\n}\r\n```\r\n\r\n### `createPluginSystem()`\r\n\r\nCreate a plugin system to extend functionality.\r\n\r\n```typescript\r\nimport { createPluginSystem, Plugin } from '@ai-chat-ui-kit/core';\r\n\r\nconst myPlugin: Plugin = {\r\n  name: 'my-plugin',\r\n  install: (context) => {\r\n    const store = context.getStore();\r\n    store.subscribe((state) => {\r\n      console.log('State changed:', state);\r\n    });\r\n  }\r\n};\r\n\r\nconst pluginSystem = createPluginSystem();\r\npluginSystem.register(myPlugin);\r\n```\r\n\r\n## 📖 Examples\r\n\r\n### Custom UI with React\r\n\r\n```tsx\r\nimport React, { useState, useEffect } from 'react';\r\nimport { createChatStore } from '@ai-chat-ui-kit/core';\r\n\r\nconst ChatApp: React.FC = () => {\r\n  const [store] = useState(() => createChatStore());\r\n  const [messages, setMessages] = useState<Message[]>([]);\r\n  const [loading, setLoading] = useState(false);\r\n\r\n  useEffect(() => {\r\n    const unsubscribe = store.subscribe((state) => {\r\n      setMessages([...state.messages]);\r\n      setLoading(state.loading);\r\n    });\r\n    return unsubscribe;\r\n  }, [store]);\r\n\r\n  const sendMessage = async (content: string) => {\r\n    await handleUserMessage(content);\r\n  };\r\n\r\n  return (\r\n    <div>\r\n      {messages.map((msg, i) => (\r\n        <div key={i} className={msg.role}>\r\n          {msg.content}\r\n        </div>\r\n      ))}\r\n      {loading && <div>Loading...</div>}\r\n    </div>\r\n  );\r\n};\r\n```\r\n\r\n### Persistence Plugin\r\n\r\n```typescript\r\nconst persistencePlugin: Plugin = {\r\n  name: 'persistence',\r\n  install: (context) => {\r\n    const store = context.getStore();\r\n    \r\n    // Load saved messages\r\n    const saved = localStorage.getItem('chat-messages');\r\n    if (saved) {\r\n      JSON.parse(saved).forEach((msg: Message) => {\r\n        store.dispatch({ type: 'ADD_MESSAGE', payload: msg });\r\n      });\r\n    }\r\n    \r\n    // Save messages on change\r\n    store.subscribe((state) => {\r\n      localStorage.setItem('chat-messages', JSON.stringify(state.messages));\r\n    });\r\n  }\r\n};\r\n```\r\n\r\n## 📦 Dependencies\r\n\r\n- `marked` - Markdown parsing\r\n- `marked-highlight` - Code highlighting\r\n- `highlight.js` - Syntax highlighting\r\n- `mermaid` - Mermaid diagram support\r\n- `katex` - LaTeX math rendering\r\n\r\n## 🤝 Contributing\r\n\r\nContributions welcome! Please read our [contributing guidelines](https://github.com/edenxpzhang/ai-chat-ui-kit/blob/master/CONTRIBUTING.md).\r\n\r\n## 📄 License\r\n\r\n[MIT License](https://github.com/edenxpzhang/ai-chat-ui-kit/blob/master/LICENSE)\r\n\r\n## 👤 Author\r\n\r\nedenxpzhang\r\n\r\n## 🔗 Links\r\n\r\n- [GitHub Repository](https://github.com/edenxpzhang/ai-chat-ui-kit)\r\n- [Documentation](https://edenxpzhang.github.io/ai-chat-ui-kit/)\r\n- [Issues](https://github.com/edenxpzhang/ai-chat-ui-kit/issues)\r\n","readmeFilename":"README.md"}