{"_id":"b-end-widget-sdk","_rev":"7-e3a430e59ab45bd6b60f1e1c818a9b03","name":"b-end-widget-sdk","dist-tags":{"latest":"1.0.7"},"versions":{"1.0.0":{"name":"b-end-widget-sdk","version":"1.0.0","keywords":["widget","sdk","assistant","react","b2b"],"license":"MIT","_id":"b-end-widget-sdk@1.0.0","maintainers":[{"name":"guoyuchang","email":"gm990114@163.com"}],"homepage":"https://github.com/guoyuchang1997/agent/tree/v1.0.1/frontend","bugs":{"url":"https://github.com/guoyuchang1997/agent/issues"},"dist":{"shasum":"cbe3a787894cc1c22b848100e6ad970e58f283f4","tarball":"https://registry.npmjs.org/b-end-widget-sdk/-/b-end-widget-sdk-1.0.0.tgz","fileCount":17,"integrity":"sha512-Dtt6UYOd8msse+pyAVC68NP8cgyCZUK2HBjaskmBE5BXNxVN+I4oL8JkxMnTL8RKJVIyAOylmuZvVqlJ02fdLA==","signatures":[{"sig":"MEQCIBgx08VLBTICwy4f8Evwk5Iomoc1U+xn3PmDOXbSnPhYAiBUrWodZcwdGvRMuaNS19v1yvVGnTb5QTpHXPN4fXVghg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":736134},"main":"dist/widget-sdk.umd.js","type":"module","types":"dist/types/sdk/index.d.ts","module":"dist/widget-sdk.es.js","exports":{".":{"types":"./dist/types/sdk/index.d.ts","import":"./dist/widget-sdk.es.js","default":"./dist/widget-sdk.es.js","require":"./dist/widget-sdk.umd.js"}},"gitHead":"7d1e36572b3b152d6f33c26ae261a31901048ae9","scripts":{"dev":"vite","build":"rm -rf dist && vite build && tsc -p tsconfig.build.json","prepare":"npm run build","preview":"vite preview"},"_npmUser":{"name":"guoyuchang","email":"gm990114@163.com"},"repository":{"url":"git+https://github.com/guoyuchang1997/agent.git","type":"git","directory":"frontend"},"_npmVersion":"10.9.2","description":"Embeddable intelligent assistant widget SDK for B-end applications.","directories":{},"_nodeVersion":"23.11.1","dependencies":{"axios":"^1.6.8","react":"^18.2.0","zustand":"^4.5.2","react-dom":"^18.2.0","lucide-react":"^0.364.0","react-markdown":"^10.1.0","react-hot-toast":"^2.6.0"},"_hasShrinkwrap":false,"devDependencies":{"vite":"^5.2.0","postcss":"^8.4.38","typescript":"^5.2.2","tailwindcss":"^3.4.3","@types/react":"^18.2.66","autoprefixer":"^10.4.19","@types/react-dom":"^18.2.22","@vitejs/plugin-react":"^4.2.1"},"_npmOperationalInternal":{"tmp":"tmp/b-end-widget-sdk_1.0.0_1775008116141_0.19761369854454625","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"b-end-widget-sdk","version":"1.0.2","keywords":["widget","sdk","assistant","react","b2b"],"license":"MIT","_id":"b-end-widget-sdk@1.0.2","maintainers":[{"name":"guoyuchang","email":"gm990114@163.com"}],"homepage":"https://github.com/guoyuchang1997/agent/tree/v1.0.1/frontend","bugs":{"url":"https://github.com/guoyuchang1997/agent/issues"},"dist":{"shasum":"a9fb837f31c84f1715fae00f0781ec241ba81b70","tarball":"https://registry.npmjs.org/b-end-widget-sdk/-/b-end-widget-sdk-1.0.2.tgz","fileCount":17,"integrity":"sha512-NMJMk1333HcGfv7eQrJdXqX2u+RLxUolZwdINPvCXs5hod/+/sJ1yDvahWQcegiWGXXOSX/8NCoeyUUyJoDRJQ==","signatures":[{"sig":"MEYCIQDln8r5LrEYdUdwwBkfdDh03EL38Wg47RRIqnZyBIEo+gIhALeM8735FS5H8Vm54akDuMx3fVvSAjVaNROOz7m2nUwA","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":739325},"main":"dist/widget-sdk.umd.js","type":"module","types":"dist/types/sdk/index.d.ts","module":"dist/widget-sdk.es.js","exports":{".":{"types":"./dist/types/sdk/index.d.ts","import":"./dist/widget-sdk.es.js","default":"./dist/widget-sdk.es.js","require":"./dist/widget-sdk.umd.js"}},"gitHead":"7d1e36572b3b152d6f33c26ae261a31901048ae9","scripts":{"dev":"vite","build":"rm -rf dist && vite build && tsc -p tsconfig.build.json","prepare":"npm run build","preview":"vite preview"},"_npmUser":{"name":"guoyuchang","email":"gm990114@163.com"},"repository":{"url":"git+https://github.com/guoyuchang1997/agent.git","type":"git","directory":"frontend"},"_npmVersion":"10.9.2","description":"Embeddable intelligent assistant widget SDK for B-end applications.","directories":{},"_nodeVersion":"23.11.1","dependencies":{"axios":"^1.6.8","react":"^18.2.0","zustand":"^4.5.2","react-dom":"^18.2.0","lucide-react":"^0.364.0","react-markdown":"^10.1.0","react-hot-toast":"^2.6.0"},"_hasShrinkwrap":false,"devDependencies":{"vite":"^5.2.0","postcss":"^8.4.38","typescript":"^5.2.2","tailwindcss":"^3.4.3","@types/react":"^18.2.66","autoprefixer":"^10.4.19","@types/react-dom":"^18.2.22","@vitejs/plugin-react":"^4.2.1"},"_npmOperationalInternal":{"tmp":"tmp/b-end-widget-sdk_1.0.2_1775010566314_0.6130404207721463","host":"s3://npm-registry-packages-npm-production"}},"1.0.3":{"name":"b-end-widget-sdk","version":"1.0.3","keywords":["widget","sdk","assistant","react","b2b"],"license":"MIT","_id":"b-end-widget-sdk@1.0.3","maintainers":[{"name":"guoyuchang","email":"gm990114@163.com"}],"homepage":"https://github.com/guoyuchang1997/agent/tree/v1.0.1/frontend","bugs":{"url":"https://github.com/guoyuchang1997/agent/issues"},"dist":{"shasum":"22ee0011b547d148654b9c82744ada17ea92e0d7","tarball":"https://registry.npmjs.org/b-end-widget-sdk/-/b-end-widget-sdk-1.0.3.tgz","fileCount":17,"integrity":"sha512-fPRu9O32AIZIdwzzHunauj1ujPpUjHXuIM9mAKAxYJCsj/E5P62p7/5NGj7keINVXKHChifyb1TC9WrG+ewKIw==","signatures":[{"sig":"MEQCIBunHqQWWFjy/E0GvoflCaLuhhpJas1gQNZyDyjS7dfjAiArRdq4Ek4xNdwn2RPtiRCMski9jLHwI7ePZQCP7+dEVg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":836565},"main":"dist/widget-sdk.umd.js","type":"module","types":"dist/types/sdk/index.d.ts","module":"dist/widget-sdk.es.js","exports":{".":{"types":"./dist/types/sdk/index.d.ts","import":"./dist/widget-sdk.es.js","default":"./dist/widget-sdk.es.js","require":"./dist/widget-sdk.umd.js"}},"gitHead":"7d1e36572b3b152d6f33c26ae261a31901048ae9","scripts":{"dev":"vite","build":"rm -rf dist && vite build && tsc -p tsconfig.build.json","prepare":"npm run build","preview":"vite preview"},"_npmUser":{"name":"guoyuchang","email":"gm990114@163.com"},"repository":{"url":"git+https://github.com/guoyuchang1997/agent.git","type":"git","directory":"frontend"},"_npmVersion":"10.9.2","description":"Embeddable intelligent assistant widget SDK for B-end applications.","directories":{},"_nodeVersion":"23.11.1","dependencies":{"axios":"^1.6.8","react":"^18.2.0","zustand":"^4.5.2","react-dom":"^18.2.0","lucide-react":"^0.364.0","react-markdown":"^10.1.0","react-hot-toast":"^2.6.0"},"_hasShrinkwrap":false,"devDependencies":{"vite":"^5.2.0","postcss":"^8.4.38","typescript":"^5.2.2","tailwindcss":"^3.4.3","@types/react":"^18.2.66","autoprefixer":"^10.4.19","@types/react-dom":"^18.2.22","@vitejs/plugin-react":"^4.2.1"},"_npmOperationalInternal":{"tmp":"tmp/b-end-widget-sdk_1.0.3_1775011269652_0.03721292592466163","host":"s3://npm-registry-packages-npm-production"}},"1.0.4":{"name":"b-end-widget-sdk","version":"1.0.4","keywords":["widget","sdk","assistant","react","b2b"],"license":"MIT","_id":"b-end-widget-sdk@1.0.4","maintainers":[{"name":"guoyuchang","email":"gm990114@163.com"}],"homepage":"https://github.com/guoyuchang1997/agent/tree/v1.0.1/frontend","bugs":{"url":"https://github.com/guoyuchang1997/agent/issues"},"dist":{"shasum":"07f3fb0a3c787007e4125f0cb81ad7bf0898923e","tarball":"https://registry.npmjs.org/b-end-widget-sdk/-/b-end-widget-sdk-1.0.4.tgz","fileCount":18,"integrity":"sha512-+mCdwslt6kXpRQilUuN481xn/BUGcwnftkaEF74zcv/jxNSRoN3+oyDgZsvMiGC54kColMWlsCkvYHHffNwMMw==","signatures":[{"sig":"MEUCICWL2ErntZqrit0f4JMXpYM3OSExtAkm8onz/Zt1Wu7xAiEAmSN51+Xi9TnvZIMMqBhHQrIvbQJQ8LpmZfqkV0k28Do=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":840741},"main":"dist/widget-sdk.umd.js","type":"module","types":"dist/types/sdk/index.d.ts","module":"dist/widget-sdk.es.js","exports":{".":{"types":"./dist/types/sdk/index.d.ts","import":"./dist/widget-sdk.es.js","default":"./dist/widget-sdk.es.js","require":"./dist/widget-sdk.umd.js"}},"gitHead":"f4c1647b3000bea6192ea1ab40a185e0a125aaee","scripts":{"dev":"vite","build":"rm -rf dist && vite build && tsc -p tsconfig.build.json","prepare":"npm run build","preview":"vite preview"},"_npmUser":{"name":"guoyuchang","email":"gm990114@163.com"},"repository":{"url":"git+https://github.com/guoyuchang1997/agent.git","type":"git","directory":"frontend"},"_npmVersion":"10.9.2","description":"Embeddable intelligent assistant widget SDK for B-end applications.","directories":{},"_nodeVersion":"23.11.1","dependencies":{"axios":"^1.6.8","react":"^18.2.0","zustand":"^4.5.2","react-dom":"^18.2.0","lucide-react":"^0.364.0","react-markdown":"^10.1.0","react-hot-toast":"^2.6.0"},"_hasShrinkwrap":false,"devDependencies":{"vite":"^5.2.0","postcss":"^8.4.38","typescript":"^5.2.2","tailwindcss":"^3.4.3","@types/react":"^18.2.66","autoprefixer":"^10.4.19","@types/react-dom":"^18.2.22","@vitejs/plugin-react":"^4.2.1"},"_npmOperationalInternal":{"tmp":"tmp/b-end-widget-sdk_1.0.4_1775030019268_0.5788005629078694","host":"s3://npm-registry-packages-npm-production"}},"1.0.5":{"name":"b-end-widget-sdk","version":"1.0.5","keywords":["widget","sdk","assistant","react","b2b"],"license":"MIT","_id":"b-end-widget-sdk@1.0.5","maintainers":[{"name":"guoyuchang","email":"gm990114@163.com"}],"homepage":"https://github.com/guoyuchang1997/agent/tree/v1.0.1/frontend","bugs":{"url":"https://github.com/guoyuchang1997/agent/issues"},"dist":{"shasum":"306769f78c87a65efeead218c129924ef0a2eeee","tarball":"https://registry.npmjs.org/b-end-widget-sdk/-/b-end-widget-sdk-1.0.5.tgz","fileCount":19,"integrity":"sha512-FrsloHeyFysrswwXKFWr5tttJS+4+CTGB09Zk0oYS41JuC8zUvmBJOIzMguRUYZwaG7o28/C1Nc9+rEWyg7c7A==","signatures":[{"sig":"MEQCIBjez2yx9lDf6Sjxkeloc7HcarFC0x2PyqvhfBsyjcObAiAjY2n9rcj4aXAyzbM+ncyz1mmv6VrP7LM9ksQhCqdCzw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":988698},"main":"dist/widget-sdk.umd.js","type":"module","types":"dist/types/sdk/index.d.ts","module":"dist/widget-sdk.es.js","exports":{".":{"types":"./dist/types/sdk/index.d.ts","import":"./dist/widget-sdk.es.js","default":"./dist/widget-sdk.es.js","require":"./dist/widget-sdk.umd.js"}},"gitHead":"9364f10cbdac79a76f682e0afc1eadde37a64d96","scripts":{"dev":"vite","build":"rm -rf dist && vite build && tsc -p tsconfig.build.json","prepare":"npm run build","preview":"vite preview"},"_npmUser":{"name":"guoyuchang","email":"gm990114@163.com"},"repository":{"url":"git+https://github.com/guoyuchang1997/agent.git","type":"git","directory":"frontend"},"_npmVersion":"10.9.2","description":"Embeddable intelligent assistant widget SDK for B-end applications.","directories":{},"_nodeVersion":"23.11.1","dependencies":{"axios":"^1.6.8","react":"^18.2.0","zustand":"^4.5.2","react-dom":"^18.2.0","lucide-react":"^0.364.0","react-markdown":"^10.1.0","react-hot-toast":"^2.6.0"},"_hasShrinkwrap":false,"devDependencies":{"vite":"^5.2.0","postcss":"^8.4.38","typescript":"^5.2.2","tailwindcss":"^3.4.3","@types/react":"^18.2.66","autoprefixer":"^10.4.19","@types/react-dom":"^18.2.22","@vitejs/plugin-react":"^4.2.1"},"_npmOperationalInternal":{"tmp":"tmp/b-end-widget-sdk_1.0.5_1775201361568_0.8907040598905558","host":"s3://npm-registry-packages-npm-production"}},"1.0.6":{"name":"b-end-widget-sdk","version":"1.0.6","keywords":["widget","sdk","assistant","react","b2b"],"license":"MIT","_id":"b-end-widget-sdk@1.0.6","maintainers":[{"name":"guoyuchang","email":"gm990114@163.com"}],"homepage":"https://github.com/guoyuchang1997/agent/tree/v1.0.1/frontend","bugs":{"url":"https://github.com/guoyuchang1997/agent/issues"},"dist":{"shasum":"4359c6f5012a68869533b35349203f15c86f5919","tarball":"https://registry.npmjs.org/b-end-widget-sdk/-/b-end-widget-sdk-1.0.6.tgz","fileCount":19,"integrity":"sha512-4ZWA+Y9HLcHOVfqT2DY9sdmTC9dy4yPlODF97X05dsNDPsmstWqVaIpmMHjFthzv061aJNkzS/vfEeof5c3J6A==","signatures":[{"sig":"MEUCIQD2JUUOqoFw+s+tRdazNGMA9+n8ty0marW8Qc8ngMMjUgIgDtDAf1pVvOqm33YKxmHwY4+LTGuxRYoPxH9QxypT72w=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":993786},"main":"dist/widget-sdk.umd.js","type":"module","types":"dist/types/sdk/index.d.ts","module":"dist/widget-sdk.es.js","exports":{".":{"types":"./dist/types/sdk/index.d.ts","import":"./dist/widget-sdk.es.js","default":"./dist/widget-sdk.es.js","require":"./dist/widget-sdk.umd.js"}},"gitHead":"0a512582f49c5da900a621f9f8749a45dba0f3d8","scripts":{"dev":"vite","build":"rm -rf dist && vite build && tsc -p tsconfig.build.json","prepare":"npm run build","preview":"vite preview"},"_npmUser":{"name":"guoyuchang","email":"gm990114@163.com"},"repository":{"url":"git+https://github.com/guoyuchang1997/agent.git","type":"git","directory":"frontend"},"_npmVersion":"10.9.2","description":"Embeddable intelligent assistant widget SDK for B-end applications.","directories":{},"_nodeVersion":"23.11.1","dependencies":{"axios":"^1.6.8","react":"^18.2.0","zustand":"^4.5.2","react-dom":"^18.2.0","lucide-react":"^0.364.0","react-markdown":"^10.1.0","react-hot-toast":"^2.6.0"},"_hasShrinkwrap":false,"devDependencies":{"vite":"^5.2.0","postcss":"^8.4.38","typescript":"^5.2.2","tailwindcss":"^3.4.3","@types/react":"^18.2.66","autoprefixer":"^10.4.19","@types/react-dom":"^18.2.22","@vitejs/plugin-react":"^4.2.1"},"_npmOperationalInternal":{"tmp":"tmp/b-end-widget-sdk_1.0.6_1775702831073_0.3390036868416597","host":"s3://npm-registry-packages-npm-production"}},"1.0.7":{"name":"b-end-widget-sdk","version":"1.0.7","description":"Embeddable intelligent assistant widget SDK for B-end applications.","type":"module","main":"dist/widget-sdk.umd.js","module":"dist/widget-sdk.es.js","types":"dist/types/sdk/index.d.ts","exports":{".":{"types":"./dist/types/sdk/index.d.ts","import":"./dist/widget-sdk.es.js","require":"./dist/widget-sdk.umd.js","default":"./dist/widget-sdk.es.js"}},"repository":{"type":"git","url":"git+https://github.com/guoyuchang1997/agent.git","directory":"frontend"},"homepage":"https://github.com/guoyuchang1997/agent/tree/v1.0.1/frontend","bugs":{"url":"https://github.com/guoyuchang1997/agent/issues"},"keywords":["widget","sdk","assistant","react","b2b"],"license":"MIT","scripts":{"prepare":"npm run build","dev":"vite","build":"rm -rf dist && vite build && tsc -p tsconfig.build.json","preview":"vite preview"},"dependencies":{"axios":"^1.6.8","lucide-react":"^0.364.0","react":"^18.2.0","react-dom":"^18.2.0","react-hot-toast":"^2.6.0","react-markdown":"^10.1.0","zustand":"^4.5.2"},"devDependencies":{"@types/react":"^18.2.66","@types/react-dom":"^18.2.22","@vitejs/plugin-react":"^4.2.1","autoprefixer":"^10.4.19","postcss":"^8.4.38","tailwindcss":"^3.4.3","typescript":"^5.2.2","vite":"^5.2.0"},"_id":"b-end-widget-sdk@1.0.7","gitHead":"0a512582f49c5da900a621f9f8749a45dba0f3d8","_nodeVersion":"23.11.1","_npmVersion":"10.9.2","dist":{"integrity":"sha512-zvIZ2aZJY80+SlRKc40+NcVJUF3Pkvfpx7CTtmkXm5GNSwn7dK4BYTQAhyrVJP4kWyU0QoKZCa63M8FhRW25rg==","shasum":"713a039e98b6e65a239408a87cc536344c596658","tarball":"https://registry.npmjs.org/b-end-widget-sdk/-/b-end-widget-sdk-1.0.7.tgz","fileCount":19,"unpackedSize":995155,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIF9jiDZ2WaoIne6O3+4vOXtY4L6sNBiPQJ1kjRH6za6ZAiBQ9x49eT764qo8G4iGwS7WqXhLksoyQNOWvBr2shupLA=="}]},"_npmUser":{"name":"guoyuchang","email":"gm990114@163.com"},"directories":{},"maintainers":[{"name":"guoyuchang","email":"gm990114@163.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/b-end-widget-sdk_1.0.7_1775703926803_0.5064675591103687"},"_hasShrinkwrap":false}},"time":{"created":"2026-04-01T01:48:36.139Z","modified":"2026-04-09T03:05:27.193Z","1.0.0":"2026-04-01T01:48:36.367Z","1.0.2":"2026-04-01T02:29:26.545Z","1.0.3":"2026-04-01T02:41:09.839Z","1.0.4":"2026-04-01T07:53:39.468Z","1.0.5":"2026-04-03T07:29:21.732Z","1.0.6":"2026-04-09T02:47:11.279Z","1.0.7":"2026-04-09T03:05:27.077Z"},"bugs":{"url":"https://github.com/guoyuchang1997/agent/issues"},"license":"MIT","homepage":"https://github.com/guoyuchang1997/agent/tree/v1.0.1/frontend","keywords":["widget","sdk","assistant","react","b2b"],"repository":{"type":"git","url":"git+https://github.com/guoyuchang1997/agent.git","directory":"frontend"},"description":"Embeddable intelligent assistant widget SDK for B-end applications.","maintainers":[{"name":"guoyuchang","email":"gm990114@163.com"}],"readme":"# b-end-widget-sdk\n\n`b-end-widget-sdk` is an embeddable assistant widget for B-end applications.\nThe widget is rendered only after an explicit `init(...)` call.\n\n## Install\n\n```bash\nnpm install b-end-widget-sdk\n```\n\n## Public API (frozen)\n\n- `init(config: WidgetConfig): void`\n- `setPageContext(context: PageContext): void`\n- `getPageContext(): PageContext | null`\n- `destroy(): void`\n\nExported types:\n\n- `WidgetConfig`\n- `PageContext`\n- `WidgetPublicAPI`\n\n## Integration Contract\n\n### 1) Initialization behavior\n\n- Importing the package alone does not render any UI.\n- You must call `init(...)` to create container + Shadow DOM and show the floating ball.\n- Calling `init(...)` repeatedly is ignored after first successful initialization.\n\n### 2) Required and optional config\n\n`WidgetConfig`:\n\n- required: `tenantId`\n- optional: `userId`, `theme`, `apiBaseUrl`, `authToken`, `defaultPageContext`\n\n> Default backend URL is `http://localhost:8000`. Always pass `apiBaseUrl` in production.\n\n### 3) Route/page updates\n\n- On route change, call `setPageContext(...)`.\n- Prefer sending stable `pageId` and `routePath`; attach `title` when available.\n- Use `systemPromptExtension` and `features` when you want assistant behavior to adapt per page.\n\n### 4) Lifecycle and teardown\n\n- On app unmount, tenant switch, or logout, call `destroy()` to unmount React and clean DOM.\n- Re-initialize with `init(...)` after destroy if needed.\n\n## Usage Examples\n\n### ESM (recommended)\n\n```ts\nimport {\n  init,\n  setPageContext,\n  getPageContext,\n  destroy,\n  type WidgetConfig,\n} from 'b-end-widget-sdk';\n\nconst config: WidgetConfig = {\n  tenantId: 'tenant-001',\n  userId: 'user-1008',\n  apiBaseUrl: 'https://api.example.com',\n  authToken: 'your-jwt-token',\n  defaultPageContext: {\n    pageId: 'dashboard',\n    routePath: '/dashboard',\n    title: 'Dashboard',\n  },\n};\n\ninit(config);\n\nsetPageContext({\n  pageId: 'orders',\n  routePath: '/orders',\n  title: 'Order List',\n});\n\nconsole.log(getPageContext());\n\n// Later when app is torn down:\ndestroy();\n```\n\n### UMD script (global `window.MyWidget`)\n\n```html\n<script src=\"https://unpkg.com/b-end-widget-sdk/dist/widget-sdk.umd.js\"></script>\n<script>\n  window.MyWidget.init({\n    tenantId: 'tenant-001',\n    userId: 'user-1008',\n    apiBaseUrl: 'https://api.example.com',\n  });\n\n  // Route change example\n  window.MyWidget.setPageContext({\n    pageId: 'reports',\n    routePath: '/reports',\n    title: 'Reports',\n  });\n</script>\n```\n\n### Framework integration (React)\n\n```tsx\nimport { useEffect } from 'react';\nimport { init, setPageContext, destroy } from 'b-end-widget-sdk';\nimport { useLocation } from 'react-router-dom';\n\nexport function WidgetBridge() {\n  const location = useLocation();\n\n  useEffect(() => {\n    init({\n      tenantId: 'tenant-001',\n      userId: 'user-1008',\n      apiBaseUrl: 'https://api.example.com',\n    });\n\n    return () => destroy();\n  }, []);\n\n  useEffect(() => {\n    setPageContext({\n      pageId: location.pathname || 'unknown',\n      routePath: location.pathname,\n      title: document.title,\n    });\n  }, [location.pathname]);\n\n  return null;\n}\n```\n\n## FAQ\n\n### I called `init` twice and nothing changed\n\n`init` is idempotent by design; call `destroy()` first if you need to re-create the widget.\n\n### Why does it still call localhost in production?\n\nBecause `apiBaseUrl` is optional and defaults to `http://localhost:8000`. Pass a production URL explicitly.\n\n### Chat stream issues (SSE/CORS/401/403)\n\n- Ensure backend supports `text/event-stream`.\n- Ensure CORS allows your origin and auth headers.\n- Ensure `authToken` is valid for protected endpoints.\n\n## Release Checklist\n\n### Before publish\n\n1. Clean and build:\n   - `npm run build`\n2. Inspect packed files:\n   - `npm pack --dry-run`\n   - Verify package includes expected `dist` artifacts and declarations\n\n### Publish\n\n1. Login:\n   - `npm login`\n2. Publish:\n   - `npm publish --access public`\n\n### Post-publish verification (external demo project)\n\n1. `npm install b-end-widget-sdk`\n2. Call `init(...)` and confirm floating ball appears\n3. Open chat and feedback tabs\n4. Trigger route changes and verify `setPageContext(...)` effects\n5. Call `destroy()` and verify DOM cleanup\n","readmeFilename":"README.md"}