{"_id":"@can_in_can/limkenion-ai","name":"@can_in_can/limkenion-ai","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@can_in_can/limkenion-ai","version":"1.0.0","description":"DeepSeek 模型接入层：消息类型与流式对话客户端","publishConfig":{"access":"public"},"type":"module","main":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./package.json":"./package.json"},"scripts":{"clean":"node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\"","build":"tsgo -p tsconfig.build.json","test":"vitest --run","prepublishOnly":"npm run clean && npm run build"},"keywords":["ai","llm","deepseek","streaming"],"author":{"name":"IamCanincan"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/IamCanincan/Limkenion-Agent.git","directory":"packages/ai"},"engines":{"node":">=22.19.0"},"devDependencies":{"@types/node":"22.19.19","typescript":"5.9.3","vitest":"4.1.9"},"gitHead":"67bd5fbf374e626b23fd1a12bcec7833ec6baef5","_id":"@can_in_can/limkenion-ai@1.0.0","bugs":{"url":"https://github.com/IamCanincan/Limkenion-Agent/issues"},"homepage":"https://github.com/IamCanincan/Limkenion-Agent#readme","_nodeVersion":"24.20.0","_npmVersion":"11.19.0","dist":{"integrity":"sha512-l7Tu5nGmKWUdtMXLCdVQwwFGtO6edOmSKrkYp3tf3VlOYSzpkfJ1ihp4K+uajQyyP4gnoK38yq9qsRLrB/pItg==","shasum":"34ce28c0cab3f27d5b3280763f25b7e9e0e71c7e","tarball":"https://registry.npmjs.org/@can_in_can/limkenion-ai/-/limkenion-ai-1.0.0.tgz","fileCount":23,"unpackedSize":71746,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDp5C8xE1MrA+aFhXLz8Sw1ZisLxtUqNLMFaZavrzHI6gIhAIXcBzJeD1LvbAaaZDTRcX0ivQAN07MXK1HV4znr3M9F"}]},"_npmUser":{"name":"can_in_can","email":"2065384887@qq.com"},"directories":{},"maintainers":[{"name":"can_in_can","email":"2065384887@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/limkenion-ai_1.0.0_1789144260534_0.9875447130704762"},"_hasShrinkwrap":false}},"time":{"created":"2026-09-11T16:31:00.350Z","1.0.0":"2026-09-11T16:31:00.678Z","modified":"2026-09-11T16:31:01.001Z"},"maintainers":[{"name":"can_in_can","email":"2065384887@qq.com"}],"description":"DeepSeek 模型接入层：消息类型与流式对话客户端","homepage":"https://github.com/IamCanincan/Limkenion-Agent#readme","keywords":["ai","llm","deepseek","streaming"],"repository":{"type":"git","url":"git+https://github.com/IamCanincan/Limkenion-Agent.git","directory":"packages/ai"},"author":{"name":"IamCanincan"},"bugs":{"url":"https://github.com/IamCanincan/Limkenion-Agent/issues"},"license":"MIT","readme":"# @can_in_can/limkenion-ai\n\nDeepSeek 模型接入层。只做一件事：把 DeepSeek 的流式 HTTP 接口翻译成带类型的异步事件流。\n\n## 安装\n\n```bash\nnpm install @can_in_can/limkenion-ai\n```\n\n## 使用\n\n```ts\nimport { readApiKey, resolveModel, streamChat } from \"@can_in_can/limkenion-ai\";\n\nconst events = streamChat({\n\tmodel: resolveModel(\"deepseek-flash\"),\n\tapiKey: readApiKey(),\n\tmessages: [{ role: \"user\", content: \"用一句话解释什么是闭包\" }],\n});\n\nfor await (const event of events) {\n\tif (event.type === \"text\") process.stdout.write(event.delta);\n\tif (event.type === \"error\") console.error(event.message);\n}\n```\n\n## 环境变量\n\n| 变量 | 作用 |\n|------|------|\n| `DEEPSEEK_API_KEY` | API Key，必填 |\n| `DEEPSEEK_BASE_URL` | 覆盖接口地址，默认 `https://api.deepseek.com` |\n| `LIMKENION_MODEL` | 覆盖默认模型 id，默认 `deepseek-flash` |\n\n## 设计说明\n\n- **零运行时依赖**：使用全局 `fetch` 与手写 SSE 解析，不引入 `openai` 等 SDK。\n- **工具参数在内部拼接**：工具调用参数分片到达，本包按 `index` 拼接完整后才发出\n  `tool_call` 事件，调用方不需要处理分片。\n- **模型 id 不设白名单**：`resolveModel` 接受任意 id，未知 id 按保守上限处理。DeepSeek\n  会调整型号命名，硬编码白名单会让 CLI 在对方改名当天失效。\n- **不含策略**：重试、会话持久化、工具执行都在上层，本包只负责传输与解析。\n\n## 事件流\n\n`streamChat` 产出的事件保证以 `done` 或 `error` 结尾：\n\n```ts\ntype ChatEvent =\n\t| { type: \"reasoning\"; delta: string }   // 思维链增量\n\t| { type: \"text\"; delta: string }        // 正文增量\n\t| { type: \"tool_call\"; call: ToolCall }  // 一条参数完整的工具调用\n\t| { type: \"done\"; reason: string; usage: Usage | null }\n\t| { type: \"error\"; message: string };\n```\n\n## 许可证\n\nMIT\n","readmeFilename":"README.md","_rev":"1-093ebe500436fad075a414e28ac901ee"}