{"_id":"@agent-client/aa","_rev":"6-65e0526ee761fe6669f1dc36300a2e55","name":"@agent-client/aa","dist-tags":{"latest":"2.0.1"},"versions":{"0.1.0":{"name":"@agent-client/aa","version":"0.1.0","keywords":["ai","agent","chat","streaming","sse","client","sdk"],"author":{"name":"align","email":"contact@align.com"},"license":"Apache-2.0","_id":"@agent-client/aa@0.1.0","maintainers":[{"name":"wanghongxin","email":"wanghongxin@outlook.com"}],"homepage":"https://github.com/align-dev/align/tree/main/packages/agent-client","bugs":{"url":"https://github.com/align-dev/align/issues"},"dist":{"shasum":"3e1a6a58fe0d839f46254b0a2f43ed99f2b36d0d","tarball":"https://registry.npmjs.org/@agent-client/aa/-/aa-0.1.0.tgz","fileCount":9,"integrity":"sha512-JiA1Ht1+RvcDodtlNjLVOCtgigj/7eXdDmDzrDJjiQpSJDtLDVEdMfqQZpF1OlpEOQ77p9EzNJlgxnu+hpREEQ==","signatures":[{"sig":"MEYCIQDk79orCheWwVn1ppnHVa4ju+T4jgRGbhU84H+GPI2LfgIhANIzsrn43szMv9f/EtYydaCAaEe5oCYGugCkQh4OUW5r","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":42939},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","module":"./dist/index.mjs","engines":{"node":">=18.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"gitHead":"bb3c91b72e1b2ff335f27a854f3ca45d72f4fafe","scripts":{"dev":"tsup src/index.ts --format cjs,esm --dts --watch","pub":"npm publish --access public --registry=https://registry.npmjs.org/","build":"tsup src/index.ts --format cjs,esm --dts --clean","check":"node scripts/check.js","clean":"rm -rf node_modules dist","login":"npm login --registry=https://registry.npmjs.org/","release":"node scripts/publish.js","typecheck":"tsc --noEmit","publish:now":"node scripts/publish-now.js","release:major":"node scripts/publish.js major","release:minor":"node scripts/publish.js minor","release:patch":"node scripts/publish.js patch","prepublishOnly":"npm run build"},"_npmUser":{"name":"wanghongxin","email":"wanghongxin@outlook.com"},"repository":{"url":"git+https://github.com/align-dev/align.git","type":"git","directory":"packages/agent-client"},"_npmVersion":"11.6.0","description":"A streaming chat client SDK for AI Agent conversations","directories":{},"_nodeVersion":"24.8.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","typescript":"^5.3.0","@align/typescript":"*"},"_npmOperationalInternal":{"tmp":"tmp/aa_0.1.0_1763613556616_0.6763552879174743","host":"s3://npm-registry-packages-npm-production"}},"1.0.0":{"name":"@agent-client/aa","version":"1.0.0","keywords":["ai","agent","chat","streaming","sse","client","sdk"],"author":{"name":"align","email":"contact@align.com"},"license":"Apache-2.0","_id":"@agent-client/aa@1.0.0","maintainers":[{"name":"wanghongxin","email":"wanghongxin@outlook.com"}],"homepage":"https://github.com/align-dev/align/tree/main/packages/agent-client","bugs":{"url":"https://github.com/align-dev/align/issues"},"dist":{"shasum":"83b2a6553088e173812ae7fb15fd50d41324b53f","tarball":"https://registry.npmjs.org/@agent-client/aa/-/aa-1.0.0.tgz","fileCount":9,"integrity":"sha512-kP5OV2R0G2nZT5/mfAkgcEbKpR+XCxcN9LJYM7d86wZzJb9gZarX9Pr3bg40NeaRkEnl1eDdtiFw5mgYTWLPIA==","signatures":[{"sig":"MEYCIQDdj7MLcpfgLWx1z2cBcNGaKndf/NDfAYBtpTU4HKH4XAIhALgZmOq8h7qH3GkgI7L8xRN5YySUpD3Ixc0maeGSVBEe","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":44675},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","module":"./dist/index.mjs","engines":{"node":">=18.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"gitHead":"ad01c559a2ce6ce41a77a2fc07b70839f641f55d","scripts":{"dev":"tsup src/index.ts --format cjs,esm --dts --watch","pub":"npm publish --access public --registry=https://registry.npmjs.org/","build":"tsup src/index.ts --format cjs,esm --dts --clean","check":"node scripts/check.js","clean":"rm -rf node_modules dist","login":"npm login --registry=https://registry.npmjs.org/","release":"node scripts/publish.js","typecheck":"tsc --noEmit","publish:now":"node scripts/publish-now.js","release:major":"node scripts/publish.js major","release:minor":"node scripts/publish.js minor","release:patch":"node scripts/publish.js patch","prepublishOnly":"npm run build"},"_npmUser":{"name":"wanghongxin","email":"wanghongxin@outlook.com"},"repository":{"url":"git+https://github.com/align-dev/align.git","type":"git","directory":"packages/agent-client"},"_npmVersion":"11.6.0","description":"A streaming chat client SDK for AI Agent conversations","directories":{},"_nodeVersion":"24.8.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","typescript":"^5.3.0","@align/typescript":"*"},"_npmOperationalInternal":{"tmp":"tmp/aa_1.0.0_1763617315596_0.921845687444157","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@agent-client/aa","version":"1.0.1","keywords":["ai","agent","chat","streaming","sse","client","sdk"],"author":{"name":"align","email":"contact@align.com"},"license":"Apache-2.0","_id":"@agent-client/aa@1.0.1","maintainers":[{"name":"wanghongxin","email":"wanghongxin@outlook.com"}],"homepage":"https://github.com/align-dev/align/tree/main/packages/agent-client","bugs":{"url":"https://github.com/align-dev/align/issues"},"dist":{"shasum":"bc793fce81f377587495cb3afbc74df304a35e96","tarball":"https://registry.npmjs.org/@agent-client/aa/-/aa-1.0.1.tgz","fileCount":9,"integrity":"sha512-nlq71ysYHVpeR317DIwLzmo5TAU11UoEZ9G3fI35WaTBmwm0UQLYD5Oj4i1gYSObnvlPIvXy4A5zpX1uzKJoKw==","signatures":[{"sig":"MEUCIQCRRZgqAYUZrL3qmthTlrQadl57Kd/yQb3SA4Kuz3kRxAIgI5T1HzwwQ5n8W6EXMwaSeTSADUc7f3QLLDV6oaTE9sc=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":44620},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","module":"./dist/index.mjs","engines":{"node":">=18.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"gitHead":"38660ca8317d9c1668159697d3241827b352fae0","scripts":{"dev":"tsup src/index.ts --format cjs,esm --dts --watch","pub":"npm publish --access public --registry=https://registry.npmjs.org/","build":"tsup src/index.ts --format cjs,esm --dts --clean","check":"node scripts/check.js","clean":"rm -rf node_modules dist","login":"npm login --registry=https://registry.npmjs.org/","release":"node scripts/publish.js","typecheck":"tsc --noEmit","publish:now":"node scripts/publish-now.js","release:major":"node scripts/publish.js major","release:minor":"node scripts/publish.js minor","release:patch":"node scripts/publish.js patch","prepublishOnly":"npm run build"},"_npmUser":{"name":"wanghongxin","email":"wanghongxin@outlook.com"},"repository":{"url":"git+https://github.com/align-dev/align.git","type":"git","directory":"packages/agent-client"},"_npmVersion":"11.6.0","description":"A streaming chat client SDK for AI Agent conversations","directories":{},"_nodeVersion":"24.8.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","typescript":"^5.3.0","@align/typescript":"*"},"_npmOperationalInternal":{"tmp":"tmp/aa_1.0.1_1763617716094_0.07368825238920884","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@agent-client/aa","version":"1.0.2","keywords":["ai","agent","chat","streaming","sse","client","sdk"],"author":{"name":"align","email":"contact@align.com"},"license":"Apache-2.0","_id":"@agent-client/aa@1.0.2","maintainers":[{"name":"wanghongxin","email":"wanghongxin@outlook.com"}],"homepage":"https://github.com/align-dev/align/tree/main/packages/agent-client","bugs":{"url":"https://github.com/align-dev/align/issues"},"dist":{"shasum":"8b597888c20349f1438a1d1a9948157f44bcfde1","tarball":"https://registry.npmjs.org/@agent-client/aa/-/aa-1.0.2.tgz","fileCount":9,"integrity":"sha512-sAWppPTEQJTlyKFmIvxybNucX5HtU5lzXhNGz13Lwwrw40FAvy422UAlyD5dsFJ4KU7sgfti5CYFlktWRR6epg==","signatures":[{"sig":"MEQCIFCx/va3+xiVMeK0L4Wh6JxH5YxBpJ7dOzrBuHhkKtC8AiBAR81FUjshNccZDxhGuJmZOrgeIpwtmTwv1LXZ682yMg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":44627},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","module":"./dist/index.mjs","engines":{"node":">=18.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"gitHead":"c96801035dfd65517ee1d1b3a2b18f0ed3e474f6","scripts":{"dev":"tsup src/index.ts --format cjs,esm --dts --watch","pub":"npm publish --access public --registry=https://registry.npmjs.org/","build":"tsup src/index.ts --format cjs,esm --dts --clean","check":"node scripts/check.js","clean":"rm -rf node_modules dist","login":"npm login --registry=https://registry.npmjs.org/","release":"node scripts/publish.js","typecheck":"tsc --noEmit","publish:now":"node scripts/publish-now.js","release:major":"node scripts/publish.js major","release:minor":"node scripts/publish.js minor","release:patch":"node scripts/publish.js patch","prepublishOnly":"npm run build"},"_npmUser":{"name":"wanghongxin","email":"wanghongxin@outlook.com"},"repository":{"url":"git+https://github.com/align-dev/align.git","type":"git","directory":"packages/agent-client"},"_npmVersion":"11.6.0","description":"A streaming chat client SDK for AI Agent conversations","directories":{},"_nodeVersion":"24.8.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","typescript":"^5.3.0","@align/typescript":"*"},"_npmOperationalInternal":{"tmp":"tmp/aa_1.0.2_1763617846020_0.34553561661230736","host":"s3://npm-registry-packages-npm-production"}},"2.0.0":{"name":"@agent-client/aa","version":"2.0.0","keywords":["ai","agent","chat","streaming","sse","client","sdk"],"author":{"name":"align","email":"contact@align.com"},"license":"Apache-2.0","_id":"@agent-client/aa@2.0.0","maintainers":[{"name":"wanghongxin","email":"wanghongxin@outlook.com"}],"homepage":"https://github.com/align-dev/align/tree/main/packages/agent-client","bugs":{"url":"https://github.com/align-dev/align/issues"},"dist":{"shasum":"e27b30b6d316e151bf6f592c4449eb2b35c490a9","tarball":"https://registry.npmjs.org/@agent-client/aa/-/aa-2.0.0.tgz","fileCount":9,"integrity":"sha512-AnG9nWoPFhWLsfu9S5fOvtm3REPEvQffj45HwvgY1fbtiArj2jytcY5RpC/2uM64wp/bna+bvtZ6BQyAYX+bGw==","signatures":[{"sig":"MEUCIQC40gF3Ln8AqnBQxm7nXSu+8tAJA+7jPsGugA6XOs0CdwIgTx2/U+IDy1bWlE5r0OuzEKj7twmePSjCzKBJF/RLQtE=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":44200},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","module":"./dist/index.mjs","engines":{"node":">=18.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"gitHead":"9b9b3036814f5b2b57d481d79bae2bbfa7521295","scripts":{"dev":"tsup src/index.ts --format cjs,esm --dts --watch","pub":"npm publish --access public --registry=https://registry.npmjs.org/","build":"tsup src/index.ts --format cjs,esm --dts --clean","check":"node scripts/check.js","clean":"rm -rf node_modules dist","login":"npm login --registry=https://registry.npmjs.org/","release":"node scripts/publish.js","typecheck":"tsc --noEmit","publish:now":"node scripts/publish-now.js","release:major":"node scripts/publish.js major","release:minor":"node scripts/publish.js minor","release:patch":"node scripts/publish.js patch","prepublishOnly":"npm run build"},"_npmUser":{"name":"wanghongxin","email":"wanghongxin@outlook.com"},"repository":{"url":"git+https://github.com/align-dev/align.git","type":"git","directory":"packages/agent-client"},"_npmVersion":"11.6.0","description":"A streaming chat client SDK for AI Agent conversations","directories":{},"_nodeVersion":"24.8.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","typescript":"^5.3.0","@align/typescript":"*"},"_npmOperationalInternal":{"tmp":"tmp/aa_2.0.0_1763618440328_0.09158699861464803","host":"s3://npm-registry-packages-npm-production"}},"2.0.1":{"name":"@agent-client/aa","description":"A streaming chat client SDK for AI Agent conversations","version":"2.0.1","main":"./dist/index.js","module":"./dist/index.mjs","types":"./dist/index.d.ts","type":"module","exports":{".":{"import":"./dist/index.mjs","require":"./dist/index.js","types":"./dist/index.d.ts"}},"repository":{"type":"git","url":"git+https://github.com/align-dev/align.git","directory":"packages/agent-client"},"scripts":{"build":"tsup src/index.ts --format cjs,esm --dts --clean","dev":"tsup src/index.ts --format cjs,esm --dts --watch","clean":"rm -rf node_modules dist","typecheck":"tsc --noEmit","check":"node scripts/check.js","release":"node scripts/publish.js","release:patch":"node scripts/publish.js patch","release:minor":"node scripts/publish.js minor","release:major":"node scripts/publish.js major","prepublishOnly":"npm run build","login":"npm login --registry=https://registry.npmjs.org/","pub":"npm publish --access public --registry=https://registry.npmjs.org/","publish:now":"node scripts/publish-now.js"},"keywords":["ai","agent","chat","streaming","sse","client","sdk"],"author":{"name":"align","email":"contact@align.com"},"license":"Apache-2.0","homepage":"https://github.com/align-dev/align/tree/main/packages/agent-client","devDependencies":{"@align/typescript":"*","tsup":"^8.0.0","typescript":"^5.3.0"},"engines":{"node":">=18.0.0"},"publishConfig":{"access":"public"},"_id":"@agent-client/aa@2.0.1","gitHead":"40bf2958250abb3307e6e6ae5956219d3ff44bab","bugs":{"url":"https://github.com/align-dev/align/issues"},"_nodeVersion":"24.8.0","_npmVersion":"11.6.0","dist":{"integrity":"sha512-AfbUwk4vjaefOQvuouFENnXtHZVywwUqg1nyU7DDKqC6xa9VjoxVag0vVcnmx1KTxkRRc1zwWTQnCQ+HA1Q1nw==","shasum":"02a7ab6ac95efbc8f7a52431db9668dea79646ef","tarball":"https://registry.npmjs.org/@agent-client/aa/-/aa-2.0.1.tgz","fileCount":9,"unpackedSize":44200,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCx7/mD07HwNE0VwGjDNeqJ0Nx75t1koGq31S4kZMEeLgIhAIrR7YMdhkFLuTXVNPKPMuo9Myb5TPk62l9/Olg4FOat"}]},"_npmUser":{"name":"wanghongxin","email":"wanghongxin@outlook.com"},"directories":{},"maintainers":[{"name":"wanghongxin","email":"wanghongxin@outlook.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/aa_2.0.1_1763619286898_0.9692153671897124"},"_hasShrinkwrap":false}},"time":{"created":"2025-11-20T04:39:16.489Z","modified":"2025-11-20T06:14:47.294Z","0.1.0":"2025-11-20T04:39:16.828Z","1.0.0":"2025-11-20T05:41:55.777Z","1.0.1":"2025-11-20T05:48:36.270Z","1.0.2":"2025-11-20T05:50:46.222Z","2.0.0":"2025-11-20T06:00:40.526Z","2.0.1":"2025-11-20T06:14:47.092Z"},"bugs":{"url":"https://github.com/align-dev/align/issues"},"author":{"name":"align","email":"contact@align.com"},"license":"Apache-2.0","homepage":"https://github.com/align-dev/align/tree/main/packages/agent-client","keywords":["ai","agent","chat","streaming","sse","client","sdk"],"repository":{"type":"git","url":"git+https://github.com/align-dev/align.git","directory":"packages/agent-client"},"description":"A streaming chat client SDK for AI Agent conversations","maintainers":[{"name":"wanghongxin","email":"wanghongxin@outlook.com"}],"readme":"# @agent-client/aa\n\nA lightweight, type-safe streaming chat client SDK for AutoAgents (AA) conversations. Built with TypeScript and native Web APIs.\n\n## Features\n\n- 🔄 **Streaming Support** - Real-time SSE (Server-Sent Events) streaming\n- 🎯 **Type Safe** - Full TypeScript support with comprehensive type definitions\n- 🪶 **Zero Dependencies** - Uses native browser APIs only\n- ⚡️ **Async Generator** - Modern AsyncGenerator pattern for clean stream handling\n- 🎨 **Rich Metadata** - Supports reasoning content, thinking time, and custom metadata\n- 🛡️ **Error Handling** - Robust error handling and stream cleanup\n\n## Installation\n\n```bash\nnpm install @agent-client/aa\n```\n\n```bash\nyarn add @agent-client/aa\n```\n\n```bash\npnpm add @agent-client/aa\n```\n\n```bash\nbun add @agent-client/aa\n```\n\n## Quick Start\n\n```typescript\nimport { chat } from '@agent-client/aa';\n\n// Simple and clean API\nconst chatStream = chat('https://api.example.com/chat', {\n  token: 'your-auth-token',\n  body: {\n    agentId: 'agent-123',\n    userChatInput: 'Hello, how are you?',\n  },\n});\n\n// Process streaming messages\nfor await (const { messages, conversationId, chatId, chunk, rawChunk, sseLine } of chatStream) {\n  // Structured messages\n  console.log('Current messages:', messages);\n  console.log('Conversation ID:', conversationId);\n  console.log('Chat ID:', chatId);\n  \n  // Raw data access (optional, for advanced use)\n  if (chunk) console.log('Parsed chunk:', chunk);\n  if (rawChunk) console.log('Raw JSON:', rawChunk);\n  if (sseLine) console.log('SSE line:', sseLine);\n}\n```\n\n## API Reference\n\n### `chat(url, options)`\n\nMain function to initiate a streaming chat conversation. Simple, clean, and powerful.\n\n**Parameters:**\n- `url` (string): The API endpoint URL\n- `options` (object):\n  - `token` (string): Authentication token\n  - `body` (ChatRequestBody): Request payload\n  - `signal` (AbortSignal, optional): Abort signal for cancellation\n  - `onopen` (function, optional): Callback when connection opens\n\n**Returns:** `AsyncGenerator<GenerateMessagesYield>`\n\n### Types\n\n#### `ChatRequestBody`\n\n```typescript\ninterface ChatRequestBody {\n  agentId: string;\n  chatId?: string;\n  userChatInput: string;\n  files?: { fileId: string; fileName: string; fileUrl: string; }[];\n  images?: { url: string }[];\n  kbIdList?: number[];\n  database?: {\n    databaseUuid: string;\n    tableNames: string[];\n  };\n  state?: any;\n  trialOperation?: boolean;\n}\n```\n\n#### `ChatMessage`\n\n```typescript\ninterface ChatMessage {\n  content: string;\n  role: \"assistant\" | \"user\";\n  messageId: string;\n  loading: boolean;\n  contentType?: \"q_file\" | \"q_image\";\n  metadata?: Record<string, {\n    complete: boolean;\n    result?: any[];\n    type?: string;\n  }>;\n  type: \"text\" | \"table\" | \"buttons\" | \"result_file\";\n  reasoningContent?: string;\n  thinkingElapsedMillSecs?: number;\n  __raw?: any;\n}\n```\n\n#### `ChatMessageStreamYield`\n\n```typescript\ninterface ChatMessageStreamYield {\n  messages: ChatMessage[];       // Array of accumulated messages\n  conversationId?: string;        // Conversation identifier\n  chatId?: string;                // Chat identifier for continuation\n  chunk?: ChatStreamChunk;        // Parsed chunk object\n  rawChunk?: string;              // Raw JSON text (without \"data:\" prefix)\n  sseLine?: string;               // Complete SSE line (with \"data:\" prefix)\n}\n```\n\n**Note - Data Layers**: \n- `sseLine`: Complete SSE protocol line, e.g., `\"data: {\\\"content\\\":\\\"hello\\\"}\"`\n- `rawChunk`: JSON text only (without `data:` prefix), e.g., `\"{\\\"content\\\":\\\"hello\\\"}\"`\n- `chunk`: Parsed JSON object, e.g., `{content: \"hello\"}`\n\nUse `sseLine` for protocol-level debugging or logging, `rawChunk` for custom JSON parsing, and `chunk` for direct data access.\n\n## Advanced Usage\n\n### With Abort Signal\n\n```typescript\nconst controller = new AbortController();\nconst chatStream = chat('https://api.example.com/chat', {\n  token: 'your-token',\n  body: { agentId: 'agent-123', userChatInput: 'Hello!' },\n  signal: controller.signal,\n});\n\n// Cancel the request after 5 seconds\nsetTimeout(() => controller.abort(), 5000);\n```\n\n### With Connection Callback\n\n```typescript\nconst chatStream = chat('https://api.example.com/chat', {\n  token: 'your-token',\n  body: { agentId: 'agent-123', userChatInput: 'Hello!' },\n  onopen: () => {\n    console.log('Connection established!');\n  },\n});\n```\n\n### React Integration Example\n\n```typescript\nimport { useState, useEffect } from 'react';\nimport { chat, ChatMessage } from '@agent-client/aa';\n\nfunction ChatComponent() {\n  const [messages, setMessages] = useState<ChatMessage[]>([]);\n  const [conversationId, setConversationId] = useState<string>('');\n\n  const sendMessage = async (input: string) => {\n    const chatStream = chat('https://api.example.com/chat', {\n      token: 'your-token',\n      body: {\n        agentId: 'agent-123',\n        userChatInput: input,\n        chatId: conversationId,\n      },\n    });\n\n    for await (const { messages, conversationId: convId } of chatStream) {\n      setMessages(messages);\n      if (convId) setConversationId(convId);\n    }\n  };\n\n  return (\n    <div>\n      {messages.map((msg) => (\n        <div key={msg.messageId}>\n          <strong>{msg.role}:</strong> {msg.content}\n          {msg.loading && <span>...</span>}\n        </div>\n      ))}\n    </div>\n  );\n}\n```\n\n## Low-Level APIs\n\n### `createChatSSEStream(url, options)`\n\nCreates a ReadableStream for SSE data.\n\n```typescript\nimport { createChatSSEStream } from '@agent-client/aa';\n\nconst stream = await createChatSSEStream('https://api.example.com/chat', {\n  token: 'your-token',\n  body: { agentId: 'agent-123', userChatInput: 'Hello!' },\n});\n```\n\n### `createChatMessageStream(stream)`\n\nProcesses a ReadableStream and yields structured messages.\n\n```typescript\nimport { createChatSSEStream, createChatMessageStream } from '@agent-client/aa';\n\nconst stream = await createChatSSEStream(url, options);\nfor await (const result of createChatMessageStream(stream)) {\n  console.log(result.messages);\n}\n```\n\n## Protocol\n\nThe SDK expects Server-Sent Events (SSE) in the following format:\n\n```\ndata: {\"chatId\":\"123\",\"conversationId\":\"456\",\"content\":\"Hello\",\"complete\":false,\"finish\":false,...}\ndata: {\"chatId\":\"123\",\"conversationId\":\"456\",\"content\":\" World\",\"complete\":true,\"finish\":false,...}\ndata: [DONE]\n```\n\n### Stream Markers\n\n- `complete: true` - Current message is complete (may have more messages in conversation)\n- `finish: true` - Entire conversation stream is finished\n- `data: [DONE]` - Alternative stream termination marker\n\n## Browser Support\n\nThis package uses native browser APIs:\n- `fetch` API\n- `ReadableStream` API\n- `TextDecoder` API\n- `AsyncGenerator` support\n\nRequires modern browsers with ES2022 support. For older browsers, use appropriate polyfills.\n\n## Publishing\n\nTo publish this package to npm:\n\n```bash\n# First time: Login to npm\nnpm run login\n\n# Then: One-command publish\nnpm run publish:now\n```\n\n## License\n\nApache-2.0\n\n## Contributing\n\nContributions are welcome! Please read our contributing guidelines and code of conduct.\n\n## Support\n\n- GitHub Issues: [https://github.com/align-dev/align/issues](https://github.com/align-dev/align/issues)\n- Email: contact@align.com\n\n","readmeFilename":"README.md"}