@internetarchive/local-chat
v0.2.3
Published
A floating, resizable chat widget powered entirely by Chrome's on-device AI, grounded in context you provide.
Readme
Local Chat
Try it live → (docs and
a live demo, served straight from this repo's main branch)
<local-chat> is a floating, resizable chat widget powered entirely by
Chrome's built-in on-device AI, grounded in context you provide.
Status
Implemented per SPEC.md: Parent/Child on-device sessions, streamed
markdown responses, Follow-ups/Starters/Icebreakers (with a configurable
Empty message shown before either exists), persisted History, draggable/
resizable positioning with its own persisted Visual state, host-invokable
Triggers (trigger-selector or the expand()/collapse()/toggle()
methods), multi-line input, light/dark mode (auto-switching via
prefers-color-scheme, or forced either way via color-scheme), and
Shadow DOM theming via --local-chat-* custom properties. Requires a
Chrome build with the on-device Prompt API (window.LanguageModel)
available; the component is a no-op everywhere else.
Installation
npm install @internetarchive/local-chatimport '@internetarchive/local-chat'Importing the module is enough: it registers <local-chat> as a custom
element as a side effect. There's nothing to call to initialize it.
Development
npm install
npm run dev # serves index.html against the current source
npm test
npm run typecheck
npm run lint
npm run build # emits the npm package to ./dist
npm run build:site # assembles a deployable copy of index.html in ./siteindex.html (served by npm run dev) doubles as the project's
introduction/documentation page and a live demo — its own chat widget is
grounded in the page's documentation content and answers questions about
it. It is not part of the published package (dist only).
Docker
The Dockerfile is multi-stage: dev and build are for local development
and CI; runtime, the default target (what plain docker build . produces),
is the only one meant for an actual deployment.
Dev runs the Vite dev server in watch mode. Bind-mount the repo over
/app so edits on your machine take effect immediately; the extra anonymous
volume on /app/node_modules keeps the image's own install from being
shadowed by whatever (or whatever's missing) in your local node_modules:
docker build --target dev -t local-chat:dev .
docker run --rm -p 5173:5173 -v "$PWD":/app -v /app/node_modules local-chat:dev
# -> http://localhost:5173/Prod runs typecheck/lint/test/build:site in an intermediate
stage, then serves the result with nginx as an unprivileged user (no Node in
the final image at all, since local-chat is entirely client-side):
docker build -t local-chat .
docker run --rm -p 8080:8080 local-chat
# -> http://localhost:8080/License
Local Chat is licensed under the GNU Affero General Public License v3.0.
