@aiquants/chat 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/CHANGELOG.md +87 -0
  2. package/README.md +234 -18
  3. package/dist/{ChatAnswerHtml-NBI6KBTM.js → ChatAnswerHtml-NAD7XPMQ.js} +1 -1
  4. package/dist/{chunk-NKHHXW42.js → chunk-44WLZMPZ.js} +1 -1
  5. package/dist/chunk-BTDHRYBO.js +1 -0
  6. package/dist/chunk-GSCTWGZT.js +1 -0
  7. package/dist/chunk-HC7HXC2K.js +1 -0
  8. package/dist/{chunk-PLNRET3Z.js → chunk-KNPMHSTQ.js} +1 -1
  9. package/dist/{chunk-7KWWXSGA.js → chunk-NWDLT2AZ.js} +1 -1
  10. package/dist/client.cjs +2 -2
  11. package/dist/client.d.cts +5 -5
  12. package/dist/client.d.ts +5 -5
  13. package/dist/client.js +1 -1
  14. package/dist/{httpTransport-BAaKwioS.d.ts → httpTransport-Cgj10OUn.d.ts} +1 -1
  15. package/dist/{httpTransport-D_JJABMq.d.cts → httpTransport-o7MkPUuY.d.cts} +1 -1
  16. package/dist/{index-iHWm67aF.d.cts → index-g-wjju1F.d.cts} +9518 -1785
  17. package/dist/{index-iHWm67aF.d.ts → index-g-wjju1F.d.ts} +9518 -1785
  18. package/dist/protocol.cjs +1 -1
  19. package/dist/protocol.d.cts +1 -1
  20. package/dist/protocol.d.ts +1 -1
  21. package/dist/protocol.js +1 -1
  22. package/dist/react.cjs +2 -2
  23. package/dist/react.d.cts +295 -56
  24. package/dist/react.d.ts +295 -56
  25. package/dist/react.js +2 -2
  26. package/dist/{runStream-7KHfaNOq.d.ts → runStream-Wn5F3RKe.d.ts} +1 -1
  27. package/dist/{runStream-CKisFztQ.d.cts → runStream-jp4rlkIw.d.cts} +1 -1
  28. package/dist/testing.cjs +6 -6
  29. package/dist/testing.d.cts +55 -4
  30. package/dist/testing.d.ts +55 -4
  31. package/dist/testing.js +6 -6
  32. package/dist/{transport-Clvkp7mW.d.ts → transport-CYd9hh42.d.cts} +23 -1
  33. package/dist/{transport-5ExGY_ti.d.cts → transport-DlhniH4C.d.ts} +23 -1
  34. package/package.json +7 -7
  35. package/dist/chunk-4NR4KSV6.js +0 -1
  36. package/dist/chunk-EEUIBWBF.js +0 -1
  37. package/dist/chunk-WGNEBS4H.js +0 -1
package/CHANGELOG.md CHANGED
@@ -3,6 +3,93 @@
3
3
  All notable changes to `@aiquants/chat` are documented here.
4
4
  Headings are version numbers. Unreleased changes go under `## Unreleased`; a release renames that heading to its version and publish date (`## 0.1.0 (YYYY-MM-DD)`).
5
5
 
6
+ ## 0.4.0 (2026-11-23)
7
+
8
+ ### Breaking
9
+
10
+ - **The optional peer `@aiquants/markdown` of `./react` rises to ^15.0.0.** Version 15.0.0 makes a parse result's `deck`
11
+ required (`null` for a document that is not a slide deck) and turns a block's full screen from a `<dialog>` into a `div`
12
+ that becomes a modal popover. This package builds no parse result, so a host upgrades `@aiquants/markdown` to 15.0.0
13
+ with this release; a host's own converter, or a test's fake converter, that answers parse results adds `deck: null`.
14
+ - **The open conversation's window (`ChatConversationWindow`) answers `path`, `goTo`, `chooseBranch`, `returnToChosen` and `pathChange`**, and `useChatSend` reads the window's `path` and `pathChange` and answers `pathBlock` (`ChatSendPathBlock`: `branch` while the window shows a branch it did not choose, `going` while it goes to a message from the chosen path, or `null`), so a host's own window or send in its tests adds them. `rewrite.block` may be `branch` or `going`.
15
+ - **`ChatComposer` takes `pathBlock`**, why the window's path stops sends now (`useChatSend`'s `pathBlock`); a host hands the hook's value.
16
+ - **`ChatMessageList` takes `landing` and `messageHrefOf`**: the landing the host asks for (`ChatMessageLanding`, or `null`) and the function that builds a message's href for "Copy link".
17
+ - **Every message's actions end with "Copy link"**, so the toolbar holds one more button after the role's action.
18
+
19
+ ### Added
20
+
21
+ - **Going to a message and showing another branch** (`./react`, the contract's §9.3.2): the window's `goTo` reads the conversation's tree and shows the branch through a message without writing a choice (the chosen path when the message is on it, or the branch read by `getMessagePath`), its page replacing the window's messages and their cursor, and reading earlier pages until the message comes (the list's earlier pages wait while a change of the path runs).
22
+ While the window shows another branch, or goes to a message from the chosen path, nothing is sent, and while it shows another branch its reads read that branch and a switch shows the sibling's branch. `chooseBranch` writes the branch's choices from the end's side and the root last; `returnToChosen` reads the chosen path.
23
+ - **`ChatShownBranchBand`**: the band over the messages while the window shows a branch it did not choose, with "Choose this branch", "Back to the chosen branch" and the paragraph of a failed change.
24
+ - **The list's landing and "Copy link"**: the list lands at a message the host names, once per occurrence, moving focus or not and marking the message a link opened ("Linked message"); "Copy link" writes the message's absolute link to the clipboard and says whether it could.
25
+ - The labels' sections `messageLink` and `shownBranch`, the composer's `branchShown` and `going`, and the message actions' `branchReason` and `goingReason`.
26
+
27
+ ## 0.3.0 (2026-11-22)
28
+
29
+ ### Breaking
30
+
31
+ - **The peer floor on `@aiquants/console-ui` rises from `^0.10.0` to `^0.11.0`** (an optional peer that only `./react` reads):
32
+ console-ui 0.11.0 tells an ARIA modal (role `dialog` or `alertdialog` with `aria-modal="true"`) as an open modal, routes the
33
+ root's announcements to the topmost modal before it checks the root's region, and widens `TopmostModal` and the
34
+ `foreignModalAnnouncer` argument to `HTMLElement`, which this package does not use. Migration: a host that loads
35
+ `./react` installs `@aiquants/console-ui` 0.11.0 or a later release within its range.
36
+ - **`ChatMessageList` takes `onEditMessage`, `onRegenerateMessage`, `rewrite`, `messageActionsDisplay` and `sendKey`, and its `limits` take `CHAT_USER_MESSAGE_MAX_CHARS`**: the send hook's `edit`, `regenerate` and `rewrite`, the person's `message_actions_display` and `send_key`, and the limit of a message's length; a host hands them, and a host's own list messages (`ChatListMessage`) add `sourceText`, the window's text before the marks of invisible characters, which `chatListMessage` sets
37
+ - **Every message's actions are one toolbar** (`<article's testId>-actions-bar`, console-ui's `Toolbar`): the Tab order stops once per article and the arrow keys, Home and End move between the branch buttons and the role's action, so a host's test that tabs from one branch button to the other presses an arrow; the reason that a switch is under way is the list's note (`<testId>-actions-note-switching`, drawn once after the scroll box) instead of `-branch-busy-reason`, and a failed switch's paragraph stays `-branch-problem`, now under the toolbar
38
+ - **`useChatSend` reads the window's `branchSwitch` and answers `edit`, `regenerate` and `rewrite`**, so a host's own window in its tests adds `branchSwitch` and a host's own send adds the three
39
+ - **`ChatMessageList` takes `onSwitchBranch` and `branchSwitch`**, the open conversation's window's `switchBranch` and `branchSwitch`, and a message it lists (`ChatListMessage`) holds its `branch` (`ChatMessageBranch`: its place and the count among its siblings in the order they were made, with the previous and the next sibling, or `null` for a message without another sibling); a host hands the window's two, and a host's own list messages add `branch`
40
+ - **`ChatComposer` takes `runElsewhere`**, whether the conversation's unfinished answer is on another branch than the one shown (`useChatSend`'s `runElsewhere`); a host hands the hook's
41
+ - **The open conversation's window (`ChatConversationWindow`) answers `switchBranch`, `branchSwitch` and `runElsewhere`, and `useChatSend` answers `runElsewhere`**, so a host's own window or send in its tests adds them; the send's phase is `running` while the conversation's unfinished run writes on another branch, since the server refuses a send meanwhile, and the stop goes to that run
42
+ - **`ChatComposer` takes `inputRef`**, the ref object the host is handed the text area by (or `null`), so a host can move focus into it, as after the open conversation is deleted; a host passes `null` when it does not.
43
+ - **The level names moved to `confidentialityLevels`** (`./react`): the labels' `newConversation.levels` is gone, and the names of the contract's confidentiality levels are the catalog's own group `confidentialityLevels`, which the new conversation's level choice and the open conversation's band read. A host that overrides the labels moves its level names there.
44
+ - **A search text is at most `CHAT_SEARCH_TEXT_MAX_LENGTH` (400, from the source's `search_text_max_length`) UTF-16 code units**: `chatSearchTextSchema` refuses a longer text, so the `q` of `listConversations` and `searchConversation` is bounded (the server builds a `LIKE` pattern from it). `chatSearchText` never makes a text longer, so a screen bounds what a person types to the same length.
45
+ The conversations' list's search box takes at most that many units (`maxLength`), and `useChatConversationList` answers a longer search empty without a request, as it answers one holding a lone surrogate.
46
+ - **`ChatRequestInvalidType` has two more rule tags**, `declared_level_lowered` (a change of a conversation's row that lowers its declared level) and `title_invisible` (a title that shows nothing); a host that switches over the tags or writes a catalog of its own handles them, and each catalog's `refusals.rules` has their sentences.
47
+
48
+ ### Added
49
+
50
+ - **Asking for consent to the usage policy** (`./react`): `useChatPolicy` reads the policy and sends the person's consent, and answers a transport that reads the policy again when another endpoint asks for consent; `ChatPolicyGate` draws the screen's main place once the person consented to the current version, and the consent screen until then (the text, or the line-by-line difference from the version consented to, and the button that consents); `ChatConsentConversation` is the open conversation's band meanwhile, with its stop and delete.
51
+ The gate and the band take the host's `headingLevel`; the gate keeps its children mounted (hidden by `Activity`) while the person is asked again, so a draft waits for the consent; and a delete from the band that lands after the band left still calls the host's `onChanged` and `onDeleted`.
52
+ The labels have the groups `policy` and `consentConversation`, and the layout's rules place the consent screen's text, difference and band.
53
+ - **Editing a message and regenerating an answer** (`./react`): every message ends its article with one toolbar named "Message actions" that holds its branch switch (while it has siblings) and the action of its role, "Edit" for a user's message and "Regenerate" for an answer, shown as the person's `message_actions_display` says (`always`; `hover`, while the article is pointed at or holds focus, only transparent otherwise; `auto`, always on a device with a coarse pointer and otherwise as `hover`), while the switch always shows.
54
+ "Edit" opens the edit form in the article in place of its body: one visible label names the form and its input, which holds the message's text before the marks and takes focus at its end; the list holds the text, one edit at a time; the composer's send key and its rules of a message's text hold (its length, and no broken character); "Cancel" and Escape close it with focus back on "Edit", except while the edit is sent, when "Cancel" cannot be pressed and says why and Escape tells it (the edit goes on whatever the form does).
55
+ The feed's Control + Home and Control + End leave the feed from the toolbar and the form's buttons too, before the toolbar's own Home and End read them; inside the form's input they stay the caret's.
56
+ A focused element of the toolbar comes into view from below with the article's end when the rest of the row fits, and in the last message with the content's bottom inset too, so the list reaches its tail (no jump to the latest shows, and a following list keeps following) instead of stopping short by the article's padding; an element taller than the band stays only while its own box crosses the band, not while its ring alone reaches into it.
57
+ "Send the edit" sends `startRun` of kind `edit` with no attachments and "Regenerate" kind `regenerate` (`useChatSend`'s `edit` and `regenerate`, with the conversation's model and reasoning level), sharing the send's ID rule, phase, stop target and numbering of failures; the content an ID stands for also holds the count of the target's siblings the window lists, so once the window lists the sibling of a request that landed unseen, pressing again rewrites anew instead of the server answering the earlier acceptance.
58
+ An acceptance names the new user's message for an edit and none for a regeneration, else it breaks the contract.
59
+ An accepted one answers its new sibling once the window's read after the acceptance has settled, and lands as a switch does: the sibling takes the message's place, focus moves to its same button, and the branch shown is announced; when that read shows no sibling while the message stays, an edit's form closes with focus back on "Edit" (also from where the reader moved it inside the form). A failed one is a paragraph in the form or under the actions, told once per occurrence; a form shows only an edit that failed after it opened, and the next send, edit or regeneration clears the last failure.
60
+ A button blocked for the whole list names one note the list draws after the scroll box: a switch under way, an answer not written yet (from a send until its run ends), or another message being edited.
61
+ - **How a message's actions show is a setting the form shows** (`./react`): `ChatSettingsForm` offers `message_actions_display` (automatic, always, or while pointed at or focused) between the announcements of answers and the default model; collapsing the actions' labels at a narrow width still waits for icons the actions can show, and keeps its value.
62
+ - **The leaves of the requests that carry a person's text** (`./protocol`): the source's `human_texts` names them, as a request body's shape and field with a run request's kind between (`run_request.send.text`), and `CHAT_HUMAN_TEXT_LEAVES` holds them frozen: the `text` of a conversation's and a run's send and edit, a conversation's `title`, an attachment's `alt_text` on its update and its `file_name` and `alt_text` on its upload.
63
+ A server checks each as a person's text, and the Python copy marks the same leaves; every other field of a request body takes a closed type, and a search's `q` is no leaf. The requests' JSON does not change.
64
+ - **The switch of a message's branch** (`./react`): in the message list, a message with two siblings or more ends its article with the previous branch's button, its place ("Branch 2 of 3") and the next branch's button, as one group the place names; a button at an end does not wrap around and says why it cannot be pressed.
65
+ A press runs the window's `switchBranch` (the parent's `setActiveChild`, or the conversation's `setActiveRoot` for a message without a parent) in the place the window's reads take, one at a time, and the path it answers lands as one read; the list keeps the message the reader was looking at where it was (the sibling takes a message the switch took away, shown from its top), focus moves without scrolling to the same button of the sibling's article, and the root's announcer says the branch shown, once.
66
+ While a switch runs, its pressed button is busy and every other switch cannot be pressed, each reason drawn once per group and named by its buttons; a switch that failed is a paragraph under its group (`branchSwitch.problem`, numbered by its occurrence), which the list tells once, and the window reads again.
67
+ Focus moves only from the pressed button or the body; a landed path whose page does not hold the sibling sends focus to the earlier-messages button (or, with no earlier page, the last article).
68
+ The window reads again when the row read at focus shows another chosen root, and follows by its state read, to its end, an unfinished run whose answer is not on its path (`runElsewhere`; a run whose streamed answer a switch took off the path too), starting that read again when a switch moves the run's answer onto or off the path, while the composer says that an answer on another branch has not finished and describes its stop button and its input by it.
69
+ - **The open conversation's heading band** (`./react`): `ChatConversationHeading` draws the title (`ChatTalkHeading`, with the title's test ID), the declared level, and the conversation's rename (a dialog whose field is checked as the contract checks a title once the reader tried, with no `maxLength`), pin (the console's switch) and delete (a confirmation dialog, WCAG 3.3.6), which `useChatConversationActions` runs one at a time.
70
+ A rename and a pin send `updateConversation` and are ready again as soon as it answers, then the window reads again and `onChanged` lets the host read its list again; the answered row stays the hook's `landed` until a read of the window after it lands, and the band shows its title and pin over the window's row (`chatConversationShownRow`).
71
+ A delete stops the conversation's running run first (`cancelRun`, sent again while the admission is busy), waits until the window's row holds no running run, then sends `deleteConversation`, calls `onChanged` and `onDeleted`, and stays deleting until the host takes the band away. Failures are numbered by occurrence, told once through the announcer, and the window reads again after one. A refusal because an answer started elsewhere (`CHAT_RUN_ACTIVE`) stays deleting until that read lands, then offers to stop and delete.
72
+ `useChatConversationDeletedAnnouncer` answers the function a host calls, once focus has landed in the new conversation's composer, to say through the root's announcer that the conversation was deleted. The labels have the group `conversationHeading`.
73
+ - **The scenario's run streams** (`./testing`): `createChatScenarioRunStreams` makes the EventSources a host hands its run streams (`reopen.createEventSource`) in a server's place, so a screen draws a run's stream (an answer being written, stopped, failed or cut) with the package's own subscription.
74
+ A run's script plays events of the contract (checked by the contract's reader), `resync-required`, a dropped connection and a gate the host opens (`release`) on the host's timers; events carry stream IDs of the Redis form `<idBaseMs>-<seq>`, an open stream sends the host's heartbeat (`heartbeat`) until its last event so a stream held open never goes stale, a stream with a cursor continues after it, `endOf` answers the run's end once a stream has carried it, and a stream no script plans is a breach (`breaches()`).
75
+ - **The body that changes a conversation's row** (`./protocol`): `chatConversationUpdateSchema` (`conversation_update`: at least one of `title`, `pinned` and `declared_level`, none of them `null`), closed, with its type.
76
+ A title is at most `CHAT_CONVERSATION_TITLE_MAX_LENGTH` (400, from the source's `conversation_title_max_length`) UTF-16 code units and shows something (`chatTextShows`); the model and the reasoning level are not among its fields.
77
+ - **A conversation's tree and the hits of a search in it** (`./protocol`): `chatConversationTreeSchema` (`conversation_tree`: the chosen root and every message of every branch as a `chatTreeNodeSchema` node, a parent before its children) and `chatSearchHitsSchema` (`search_hits`: each found message once, with whether it is on the chosen path and the parts that hold the search's text, `chatSearchHitSchema`), closed, with their types.
78
+ A node holds the head of its message's text within `CHAT_TREE_PREVIEW_MAX_LENGTH` (80, from `tree_preview_max_length`) UTF-16 code units, never splitting a surrogate pair, and `preview_cut` when the text is longer. The new vocabulary `search_parts` (`text`, `attachment_alt`, `reasoning`) names the parts.
79
+ - **The tenant's policy and a person's consent to it** (`./protocol`): `chatPolicySchema` (`policy`: the current version and the state of the person's consent, `current`, `earlier` with the version last consented to, or `none`, its shapes `chatPolicyConsentSchemas`), `chatPolicyVersionSchema` (`policy_version`), `chatPolicyTextsSchema` (`policy_texts`: a text for each of `language_codes`) and `chatPolicyConsentRequestSchema` (`policy_consent_request`), closed, with their types.
80
+ A version's number runs from 1 to `CHAT_POLICY_VERSION_NO_MAX` (from `policy_version_no_max`). The new vocabulary `policy_consents` names the states.
81
+ - **The exchanges of a conversation's change, deletion, tree and search, and of the policy and a consent** (`./protocol`) are settled in `CHAT_EXCHANGES`, so the transport sends them.
82
+ `updateConversation` (`PATCH /conversations/{conversation_uid}`, 200, `conversation_update` → `conversation`), `deleteConversation` (`DELETE /conversations/{conversation_uid}`, 204), `getConversationTree` (`GET /conversations/{conversation_uid}/tree`, 200, → `conversation_tree`), `searchConversation` (`GET /conversations/{conversation_uid}/search` with its query `q`, 200, → `search_hits`), `getPolicy` (`GET /policy`, 200, → `policy`) and `consentPolicy` (`POST /policy-consents`, 204, `policy_consent_request`, the first 204 that takes a body).
83
+ - **The bodies and the answer of a switch of the chosen path** (`./protocol`, plan §2.5.2 and §2.6.2): `chatActiveRootUpdateSchema` (`active_root_update`: the message without a parent the path starts from), `chatActiveChildUpdateSchema` (`active_child_update`: the child of a message the path goes on to) and `chatActivePathSchema` (`active_path`: the conversation's row and the latest page of the path chosen now, read in the transaction that wrote the switch), all closed, with their types.
84
+ The exchanges of `setActiveRoot` (`PUT /conversations/{conversation_uid}/active-root`, 200, `active_root_update` → `active_path`) and `setActiveChild` (`PUT /messages/{message_uid}/active-child`, 200, `active_child_update` → `active_path`) are settled in `CHAT_EXCHANGES`, so the transport sends them.
85
+
86
+ ### Changed
87
+
88
+ - **The composer does not send a text with a broken character**: a text that holds a lone surrogate (a paste can carry one, half of a character outside the basic plane), which the contract refuses in every text, stops the send with its reason ("To send, delete the broken character in the message.", the labels' `composer.illFormedReason`) and marks the input invalid; before, the composer handed it on and `useChatSend`'s `send` refused it with a `RangeError`.
89
+ - **A send or a rewrite accepted while `Activity` hid the window stops waiting once the window shows again**: the hidden window answers its read after the acceptance as not landed, so `useChatSend` has the shown window read again and ends the accepted run's wait when that read lands; before, the phase stayed `running` until a stop showed the run's end.
90
+ - **An answer's document lets the conversation's surface show through**: the layout rule gives each answer's document root (`[data-aqmd-document]`) a transparent background and the surface's text colour, so the Markdown renderer's display style no longer paints its own background (in the dark scheme, a band darker than the conversation's surface) or text colour over the conversation. A page that draws the answers links the renderer's display stylesheets (`katex.min.css`, `message.css`, `details.css`, `github-markdown.css`; see the README).
91
+ - **A conversation's model and reasoning level are those of the last run accepted in it**: accepting a run writes its own to the conversation's row, so a screen starts its next send from the row; before, the row kept those the request that made the conversation named.
92
+
6
93
  ## 0.2.0 (2026-11-20)
7
94
 
8
95
  ### Breaking