LibreChat/packages/chat/package.json
Marco Beretta f177bed175
🚦 refactor: Add the Core Chat Class With a Serial Job Executor and React Query State (#17030)
* refactor: Add the Core Chat Class With a Serial Job Executor and React Query State

* fix: Report an Attachment's HTTP Failure as a Disconnect and the Turn's Conversation on Finish

* fix: Report a Stream That Fails While It Is Read as a Disconnect

* fix: Keep an Attachment Failure a Disconnect When the Host Reducer Throws on It

* fix: Treat a Resumed Start as an Attachment and Drop a Replaced Start's Optimistic Rows

* fix: Undo the Whole Optimistic Write of a Start the Server Replaced

* fix: Give Each Optimistic Write One Rollback Record and Stop a Disposed Chat Writing State

A turn keeps its optimistic write on the active request, so a disposal before the start was sent undoes those rows as a replaced start already did, and a removed row is restored next to its surviving neighbors instead of at its old index. A disposed chat no longer moves the shared status or connection, so a listener that disposes on a rollback notice cannot leave the state reconnecting. A start that fails with ERR_INTERNET_DISCONNECTED is a disconnect like ERR_NETWORK, and the React Query state rechecks a host store that changed between a version read and its subscription.

* fix: Roll Back the Rows a Store Committed, Not the Rows the Chat Handed It

A React Query cache with structural sharing commits a changed row as a copy, so a replaced start compared its rollback record against objects the cache never held and kept the optimistic edit. The record now takes the list as the state reads it back after the write.

* fix: Record the Optimistic Rows a Store Committed Before Telling Subscribers

A listener that writes the shared state when the chat announces its optimistic write no longer lands in that write's rollback record, so a replaced start keeps the listener's rows. The record is taken before anyone is notified, and a store's report of the chat's own write waits for the chat's announcement instead of running inside the write.

* fix: Stop a Stream Event Once a Listener Disposed the Chat on Its Write

A listener that disposes the chat while an event's write is announced no longer lets that event move the shared status to streaming or reach onEvent after teardown.

* fix: Scope Optimistic Rollback to the Rows the Write Itself Changed

The rollback record kept the whole list the store committed, so a row a store subscriber appended while the write was committed was undone with the turn, and a subscriber that disposed the chat inside the write left the turn's rows behind because no record existed yet. The record now holds, by message id, only the rows the write added, replaced or removed, each under the identity the store committed it with; undo restores or drops those and leaves every other row. A dispose inside the write is undone once the record exists.

* fix: Leave a Turn Row a Store Subscriber Edited Inside the Write Out of Its Rollback

A store that notifies its subscribers synchronously can hand back one of the turn's rows already edited by a subscriber, and the rollback of a replaced start then deleted or overwrote that edit. The record now claims a committed row only when it is the written row or a structural copy of it.
2026-10-28 08:43:17 +01:00

97 lines
2.5 KiB
JSON

{
"name": "@librechat/chat",
"version": "0.1.0",
"private": true,
"description": "Chat state, transport and message components for LibreChat",
"repository": {
"type": "git",
"url": "https://github.com/LibreChat-AI/LibreChat"
},
"sideEffects": false,
"main": "dist/index.cjs",
"module": "dist/index.mjs",
"types": "./dist/index.d.cts",
"exports": {
".": {
"import": {
"types": "./dist/index.d.mts",
"default": "./dist/index.mjs"
},
"require": {
"types": "./dist/index.d.cts",
"default": "./dist/index.cjs"
}
},
"./react": {
"import": {
"types": "./dist/react.d.mts",
"default": "./dist/react.mjs"
},
"require": {
"types": "./dist/react.d.cts",
"default": "./dist/react.cjs"
}
},
"./components": {
"import": {
"types": "./dist/components.d.mts",
"default": "./dist/components.mjs"
},
"require": {
"types": "./dist/components.d.cts",
"default": "./dist/components.cjs"
}
},
"./package.json": "./package.json"
},
"files": [
"dist"
],
"scripts": {
"clean": "rimraf dist",
"b:clean": "bun run rimraf dist",
"build": "npm run clean && tsdown",
"b:build": "bun run b:clean && bun run tsdown",
"build:watch": "tsdown --watch",
"typecheck": "node ../../scripts/typecheck.mts",
"test": "jest",
"test:ci": "jest --ci"
},
"peerDependencies": {
"@librechat/client": "*",
"@tanstack/react-query": "^4.28.0",
"jotai": "^2.12.5",
"librechat-data-provider": "*",
"lucide": "^0.528.0",
"lucide-react": "^0.528.0",
"react": "^18.2.0 || ^19.1.0",
"uuid": "^11.1.1"
},
"dependencies": {
"sse.js": "^2.8.0"
},
"devDependencies": {
"@babel/preset-env": "^7.29.5",
"@babel/preset-react": "^7.22.15",
"@babel/preset-typescript": "^7.21.0",
"@librechat/client": "*",
"@tanstack/react-query": "^4.28.0",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^14.0.0",
"@types/jest": "^29.5.2",
"@types/react": "^18.2.11",
"babel-plugin-replace-ts-export-assignment": "^0.0.2",
"jest": "^30.2.0",
"jest-environment-jsdom": "^30.2.0",
"jotai": "^2.12.5",
"librechat-data-provider": "*",
"lucide": "^0.528.0",
"lucide-react": "^0.528.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"rimraf": "^6.1.3",
"tsdown": "0.22.2",
"typescript": "^5.9.3",
"uuid": "^11.1.1"
}
}