@aiquants/chat 0.0.0-stage → 0.1.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.
package/CHANGELOG.md ADDED
@@ -0,0 +1,199 @@
1
+ # Changelog
2
+
3
+ All notable changes to `@aiquants/chat` are documented here.
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
+
6
+ ## 0.1.0 (2026-11-20)
7
+
8
+ The first release: the chat's wire contract, the subscription to a run's stream with the notice of its connection, the fold of the stream into a window's view, the transport of the endpoints' exchanges,
9
+ the arithmetic, frame, composer (with its recording through the host's microphone) and attachment rules of the chat's screen, the stream layer and the message list of the screen with the window of an open conversation that feeds them, the screen's reading of a refused JSON answer, the names of a diagram a window saves and of a recording, the authorization resources its endpoints guard with, and the scenario that answers the transport in the server's place in tests.
10
+
11
+ ### Added
12
+
13
+ - **The contract's source** (`./protocol`): `CHAT_PROTOCOL`, the frozen `chatProtocol.json` (version `CHAT_PROTOCOL_VERSION`), which the server's Python implementation reads too: the stream events with their fields and whether each begins or ends a stream, the ways a frame is refused, the failure codes with the closed fields of their detail, the business codes with the closed fields of their detail,
14
+ the chat's own rule tags of a refused request, the host refusal roles, the paths with the queries they take, the keys of the screen's tunables, the attachments, the closed vocabularies, the resources of the JSON endpoints, the exchange of each endpoint the contract settles, the characters a reader cannot see,
15
+ and the types of Mermaid diagram the screen draws in an answer (`CHAT_DRAWABLE_DIAGRAMS`, each with its first word; a copy of `@aiquants/markdown`'s `MERMAID_DRAWABLE_TYPES`, which a test holds equal to it, so that the server knows the same types).
16
+ Every array and plain object `./protocol` exports, its `CHAT_` constants and its records of zod types among them, is frozen down to every array and plain object inside, so no reader in the process can add, remove or replace an entry of these lists and records, or a value of these constants, for another; the zod types themselves are not, their own members included, as zod writes its caches into them, so a zod type stays open to whoever holds it.
17
+ - **The events** (`./protocol`): the strict zod types of every event's fields (`chatEventSchemas`), `run.failed` taking the shape of its failure code, and the value types they share (`chatUidSchema`, `chatInstantSchema`, `chatCountSchema`, `chatStepSchema`, `chatTextSchema`, `chatCallOutcomeSchema`, `chatFailureCodeSchema`, `chatFailureDetailSchemas`).
18
+ An instant is written in ASCII digits, a text is not empty (`chatTextOrEmptySchema` takes the empty one), and no text of the contract holds a lone surrogate, the names in a refused member's path and in an object detail at any depth included.
19
+ - **The frame reader** (`./protocol`): `parseChatEvent` reads one SSE frame against its event's strict shape, or throws `ChatEventRefusedError` with the way it is refused (`CHAT_EVENT_REFUSALS`: `unknown_event`, `reserved_data`, `too_deep`, `not_json` and `shape`, checked in that order) and a message that never holds the data. Data that opens more than `CHAT_EVENT_DATA_MAX_DEPTH` (8) arrays and objects inside one another is refused before it is parsed. Also `isChatEventName`, `isTerminalChatEvent`, `CHAT_START_EVENTS`, `CHAT_TERMINAL_EVENTS` and `RESYNC_REQUIRED_EVENT`.
20
+ - **The golden samples of stream frames** (`tests/fixtures/chat-events-golden.json`, not shipped): every sample states the answer both languages give it, in three sections: `accepted` (every event, every failure code and every value of their details, written back byte for byte), `rewritten` (another spelling of the same value, written in its canonical form) and `refused` (refused the way named). The writer in the server's Python package (`aiquants-chat-core`) refuses to write a sample its own reader answers otherwise.
21
+ - **The business codes' details** (`./protocol`): `chatBusinessDetailSchemas` holds the closed detail of every business code, one strict object or the union of the shapes a code takes (`CONFIGURATION_ERROR`: nothing, the refused members, or the reading whose provider is outside the deployment; `CHAT_STATE_CONFLICT`: what the request's basis differs in, and for an attachment why its state does not allow the request, `processing`, `failed` or `already_bound`).
22
+ A refused request names its members in the platform's shape (`chatRequestErrorSchema`: `loc`, whose names may be empty, `msg` and `type`; `chatRequestErrorsSchema`: one entry or more), and `CHAT_REQUEST_INVALID_TYPES` lists the chat's own rule tags in `type`, the platform's tags staying open.
23
+ The chat's eight business codes have their numbers: `CHAT_POLICY_CONSENT_REQUIRED` 40310, `CHAT_POLICY_NOT_PUBLISHED` 40311, `CHAT_STATE_CONFLICT` 40910, `CHAT_RUN_ACTIVE` 4233, `CHAT_ADMISSION_BUSY` 4234, `CHAT_CONCURRENCY_LIMIT` 4290, `CHAT_RATE_LIMIT` 4291 and `CHAT_BUDGET_EXCEEDED` 4292.
24
+ - **The body of a failed answer** (`./protocol`): `chatErrorBodySchema` reads the platform's body of every failed answer (the business code's number, the name the failure was raised as, the request's ID, a text detail that may be empty or an object detail, and the stage a failure is put on).
25
+ An object detail of any code is a JSON object every language reads alike, read once into a copy without recursion: no lone surrogate in a name or a text, numbers within ±`Number.MAX_SAFE_INTEGER` (the counts' bound, within which every number is one value in every language), JSON values only (a member `JSON.parse` never makes, an accessor among them, is refused without being run), no array or object held twice, and at most `CHAT_EVENT_DATA_MAX_DEPTH` arrays and objects open inside one another.
26
+ One the walk refuses is one issue at the detail with the first problem's reason, naming none of the detail's names, which are data (zod's `format()` would write a name such as `__proto__` there onto shared objects).
27
+ That of one of the chat's business codes holds the code's closed fields besides, and the body holds the copy; the closed fields' issues are zod's own, as when zod reads the detail as a field: zod words the issues it makes by its global or default error map, never by a contextual one handed to the reading, and the package's own words, a closed field's refinement among them, stay under every map. `readChatBusinessError` reads a body as one of the chat's business codes with its closed detail.
28
+ A detail's values are the same in every language, while a number's spelling and the order of the members whose names are array indices may differ when a body is written back.
29
+ Every refused body is aborted, whether refused for another field or for its detail, whose issues carry zod's `fatal: true`: no refinement layered over the body runs on it, a union holding it, when none of its options takes the value, answers one `invalid_union` (or the issues of another option refused without being aborted), and a host forwarding the issues into its own reading forwards `{ ...issue, fatal: false }` to read on.
30
+ - **The paths** (`./protocol`): `chatJsonEndpoint`, `chatUploadEndpoint` (an upload with a multipart body), `chatContentPath` (content a screen shows or saves as it is, always `GET`) and `chatStreamPath` fill a path's parameters, one encoded segment each, and refuse a missing, empty or unnamed parameter.
31
+ - **The attachments** (`./protocol`): the kinds an attachment is (`CHAT_ATTACHMENT_KINDS`: an image, a PDF and an audio) with the model flag each needs (`CHAT_ATTACHMENT_KIND_FLAGS`) and the content types each is accepted as (`CHAT_ATTACHMENT_ACCEPTED_TYPES`), where an attachment comes from, its states, its failure tags with the ones each kind fails with and how a model takes a PDF (`CHAT_ATTACHMENT_ORIGINS`, `CHAT_ATTACHMENT_STATES`, `CHAT_ATTACHMENT_FAILURE_TAGS`, `CHAT_ATTACHMENT_KIND_FAILURE_TAGS`, `CHAT_PDF_DELIVERIES`).
32
+ `chatAttachmentSchema` reads an attachment resource by its kind (`chatAttachmentKindSchemas`) with the rules across its fields: a failure tag exactly when it failed and one its kind fails with, read text (`parts`: `chatAttachmentImageTextSchema`, `chatAttachmentPageSchema`, `chatAttachmentSegmentSchema`), a PDF's unread pages and an image's mark of unread text (`text_unread`) only when ready, one read text of an image at most and none when its text is unread, a PDF's pages in order and within the document, none both read and unread,
33
+ and an audio's segments in the order of their starts and within the audio.
34
+ `chatMessageAttachmentSchema` reads a message's attachment, the summary of a bound one, `chatMessageAttachmentsSchema` and `chatAttachmentIdsSchema` refuse an attachment given twice, `chatAttachmentFragments` holds the fields a message, the request that creates one and a model take for attachments, `checkChatModelAttachmentFlags` holds how a model takes a PDF to its flag for PDFs, and `chatAttachmentUpdateSchema` reads the body of an attachment's update. `chatSha256Schema` reads a digest in lower-case hexadecimal.
35
+ - **The golden samples of attachments** (`tests/fixtures/chat-attachments-golden.json`, not shipped): JSON texts of a resource, a message's attachment, the fields other resources take and an update's body, each `accepted` (written back byte for byte) or `refused`, a refused one breaking one rule of an accepted one. The writer in the server's Python package (`aiquants-chat-core`) refuses to write a sample its own reader answers otherwise.
36
+ - **The closed vocabularies** (`./protocol`): `CHAT_VOCABULARIES` holds, each in its order, a run's states with the active ones, the ways a run starts, the reasons a step ends with (which the stream's events and a completed run take), a message's roles, the reasoning levels, a title's origins, the confidentiality levels, the reasons a model the list shows cannot be chosen, where a model runs, the formats a conversation is exported in and the words of a person's settings.
37
+ Of the reasons a model cannot be chosen, `model_upstream_unavailable_reasons` holds the ones that are the upstream's state of the moment rather than whether the person may choose the model: a send is refused as the upstream's unavailability, and a person's settings may keep such a model as the default.
38
+ - **The resources of the JSON endpoints** (`./protocol`): a conversation's row (`chatConversationSchema`) and its page (`chatConversationPageSchema`), a message of either role (`chatMessageSchema`)
39
+ with the run an answer carries (`chatMessageRunSchema`: the model that writes the answer `chatMessageRunModelSchema` (its uid, and its name now or `null` when the reader may not read it), its finish reason only when it completed, its failure only when it failed, who cancelled it only when it was cancelled, whether its stream is open `stream_open`, and its view at the mark `chatRunSeedSchema`) and its page (`chatMessagePageSchema`),
40
+ the request that starts a run of each kind (`chatRunRequestSchema`) with the answer accepting it (`chatRunAcceptedSchema`), the request that makes a conversation with its first message (`chatConversationRequestSchema`) with the answer holding the conversation and its first run (`chatConversationAcceptedSchema`), the read of a run (`chatRunSchema`),
41
+ the settings (`chatSettingsSchema`) with what a new conversation starts with (`chatConversationDefaultsSchema`) and the screen's tunables (`chatLimitsSchema`),
42
+ the body that changes a person's settings (`chatUserSettingsUpdateSchema`: one setting at least, each one left out keeping its value, and `null` for the default model alone, which leaves the model to the deployment), and the list of models (`chatModelListSchema`, each shown model with the reasoning level a choice of it starts at) with a hidden row first. `chatCursorSchema` reads a page's cursor and `chatRequestIdSchema` the ID of a request that starts a run.
43
+ A seed on the wire is held to the order of its steps alone, since a run whose stream is no longer open (its writer stopped it, or fenced it off) may write its answer without a mark; the message's run holds its view to the mark rule too (a seed without a mark holds no step's text or reasoning) while its stream is open, and `chatOpenStreamRunSeedSchema` reads the seed of such a run with both rules.
44
+ - **The queries** (`./protocol`): `chatQuerySchemas` holds the query of every endpoint that takes one (the models' names a conversation or a new conversation's declared level, not both), and `chatQueryString` writes it in the source's order.
45
+ The conversations' list with `until` instead of `cursor` (a cursor it answered, never both) answers every row from its head before that cursor, not cut by the page's size, its `next_cursor` being `until` while a row follows. A query's `q` is a search text (`chatSearchTextSchema`: a text of the contract without white space at either end), which `chatSearchText` makes of a typed text.
46
+ - **The exchanges of the endpoints** (`./protocol`): `CHAT_EXCHANGES` holds, for each JSON or upload endpoint the contract settles, the status of its success and the shapes of its request's and its answer's bodies (`null` for none, and only a 204 answers none), `chatExchangeShapeSchemas` binds every shape it names to its type, and `ChatExchangeBody` and `ChatExchangeAnswer` type an endpoint's body and answer.
47
+ `chatAttachmentUploadSchema` reads the upload's multipart body as a screen hands it over, its fields in the order of the body's parts with the file last (the source's `attachments.upload`), so that the server checks the model and the name before it reads the file.
48
+ - **The golden samples of resources** (`tests/fixtures/chat-resources-golden.json`, not shipped): JSON texts of every resource, the request that starts a run, the request that makes a conversation, the body that changes a person's settings and the body of a failed answer, each `accepted` or `refused` as the attachments' are, with a failed answer of every exception the Python package answers with a business code and every shape of every business code's detail.
49
+ A refused sample of every shape of every business code's detail holds a member outside the shape's closed fields.
50
+ - **The characters a reader cannot see** (`./protocol`): `markChatInvisible` replaces every character of the contract's invisible set (`CHAT_PROTOCOL.invisible`: every Default_Ignorable_Code_Point, the controls other than TAB, LF and CR, the line and paragraph separators, the interlinear annotation characters and the noncharacters)
51
+ outside its three exceptions (one variation selector right after a visible character, one ZWNJ or ZWJ between visible characters, the left one possibly such a kept selector, and the RGI tag flags each whole) with its mark `⟦U+XXXX⟧`, one for each character, and counts the marks (`ChatMarkedText`);
52
+ for a stream's text not yet complete, it holds back the end a later delta may still turn into an exception, so the marked text only grows. `chatTextShows` tells whether a text holds a visible character, one neither in the set nor white space. `chatSearchText` makes a query's search text of a typed text, removing the white space at both ends (`null` when nothing is left).
53
+ The tables are read from the source and checked when the module loads, so no answer leans on the engine's Unicode version, and the Python package answers alike from its twin of them.
54
+ - **The golden samples of the characters a reader cannot see** (`tests/fixtures/chat-invisible-golden.json`, not shipped): texts, each with the text a screen shows for it, the number of its marks, whether it shows anything and its search text: both ends of every range of the set between spaces, with the code points next to them outside it, both ends of every range of the white space, the exceptions kept and not kept, the spelling of the marks, the texts that show nothing and the white space a search text removes or keeps.
55
+ - **The refusals** (`./client`, `./react`, `./testing`): every function and part refuses a value a host hands it where it is handed, before anything depends on it, with one form of message, `<caller>: <field> must <rule>, got <what was given>`: a `TypeError` for a value of the wrong type and a `RangeError` for a value outside its rule, a closed word, a tunable and a value of the contract being refused with a `RangeError` whatever its type.
56
+ The rule is most often `be …` (`be null or …` for a field that also takes `null`), and what was given is the value, with the words that place it when the rule is about a part of the value (such as `the key "x"` or `"x" twice`) or words for a value of the right type whose shape breaks the rule (such as `an empty array`).
57
+ Two refusals have another form: `@aiquants/sse`'s of the run streams' reopening options, after the package's words, and that of a string base, which names no value (below).
58
+ One writer writes every refused value (a string quoted, a number, a boolean and `undefined` as they are, a bigint with its `n`, `null` as it is and any other value by its type), running none of its code. A value of the contract is checked by its own schema, the message ending with the schema's first issue in parentheses and holding the schema's error as its cause; an object or a function a schema accepted is not checked by it again.
59
+ A run's view and an item of its stream are checked the same way, by the package's schemas built from the contract's (`reduceChatEvent` names `view` or `item`), and the views and the items the package makes are never parsed again, so a view that grows over a long run is not read at every item. `nextChatStreamNotice` checks the previous notice (`null` or a notice) and the status (an object, a kind the subscription has, and the fields its kind reads).
60
+ - **The subscription to a run's stream** (`./client`): `openChatRunStream` subscribes to one run's stream through the host's run streams (`ChatRunStreams`: the base the contract's paths are joined to, the query parameter a reopen carries the cursor in, the host's own terminal events, and its reopening fields `ChatStreamReopen`, every one required) on `@aiquants/sse`'s reopening EventSource.
61
+ Every frame is read by the contract's reader and passed as an item with the frame's own ID. A frame without an event name, a refused frame, a frame without an ID of its own and a `run.started` of another contract version close the stream and end the subscription as `broken` (`ChatStreamBreak`: `refused`, `id` or `protocol`). A contract's terminal event is passed as the last item before its `terminated`, and a host's ends the subscription without an item.
62
+ `assertValidChatRunStreams` refuses the host's run streams with the same rules and messages as at open (naming itself as the caller), before anything depends on them: every field is read once, the runtime's members and the terminal events (by index) included, and its type refused in the package's form, running none of a refused value's code, and a refusal of `@aiquants/sse`'s check of the numbers' rules and the terminal events' names on the values read, every one of the right type, is thrown as a `RangeError` that names the caller and holds it as its cause.
63
+ The subscription uses the streams as read (the runtime's functions read are called as its methods), so a change the host makes to them after the open changes nothing.
64
+ Every base the contract's paths are joined to follows one rule (the composer's `contentBaseUrl` and the transport's two bases too), whose refusal names the caller and the field and never repeats a string base.
65
+ It refuses a base holding credentials (the package never carries them in a URL, and `fetch` refuses such a URL), a query, a fragment, a backslash, a space, a control character or a `.` or `..` between slashes, a base ending with `/`, and an absolute URL not written as `http(s)://` and a non-empty authority, whose path begins with `//` (what follows its origin is the target a write's stamp receives) or that the URL parser refuses (a port outside its range, a host holding a character no host may hold).
66
+ A `.` or `..` is refused whether written with dots or `%2e`, since the URL parser resolves either, so the joined URL would not be the base as written, and a `..` takes the paths appended after it out of the base's path; the rule checks the base's form, not whether a request can reach it.
67
+ - **The notice of a stream's connection** (`./client`): `nextChatStreamNotice` decides from the previous notice and the subscription's status the notice a window shows near its input (`ChatStreamNotice`: `reconnecting`, `unreachable` with a button that connects at once or one that reads the conversation again (`ChatStreamNoticeAction`), and `incompatible`), one of four frozen values, so an unchanged notice is the very object returned before.
68
+ - **`@aiquants/sse`** is an optional peer dependency (`workspace:^0.4.0`, the first release with `assertValidReopeningOptions`), read by `./client` and by `./react`, whose open conversation's window subscribes to its runs' streams, their modules and their declarations alike: the window's declarations take the stream notice's types from a chunk that reads no peer, and reach no declaration of the `./client` entry.
69
+ - **The fold of a run's stream** (`./client`): `seedChatRunView` starts a window's view of a run from the view at the mark that the read of the run's answer message gives, refusing a seed the contract's schema refuses (fields outside the contract, steps out of order and, without a mark, a step's text or reasoning).
70
+ The seed is the contract's (`ChatRunSeed`), of a run whose stream is open, read by `chatOpenStreamRunSeedSchema`, which names every break of its two rules in the steps' order; so is the seed part of a view the fold takes.
71
+ `reduceChatEvent` applies one stream item without changing the view in place: items at or below the mark and after the view's end change nothing, a view without a mark that does not begin with a start event ends with `resync-required`, the events a takeover can write again are put by key, `step.reset` drops its step's state, and an event naming a step the view lacks moves only the mark. A view or an item the package's schemas refuse is refused with a `RangeError` (`view` first).
72
+ `compareChatStreamIds` orders two stream IDs as numbers, the contract reading a stream ID with `chatStreamIdSchema` (`<ms>-<seq>`, two unsigned 64-bit numbers).
73
+ - **The transport of the endpoints' exchanges** (`./client`): `ChatTransport` is the port between the screen and the endpoints whose exchanges the contract settles, with one operation, `exchange(endpoint, request)`, keyed by `CHAT_EXCHANGES` and typed for one endpoint as `ChatSingleEndpoint<Endpoint>` (a union of several, whose requests' fields would merge, is refused; a function that hands on an endpoint held in a type parameter declares its endpoint the same way and hands it on with no type argument).
74
+ A request (`ChatExchangeRequest`) has the parameters of the endpoint's path (`ChatExchangeParams`), its query and its body exactly where the endpoint has them, and a signal.
75
+ An outcome (`ChatExchangeOutcome`) is `answered`, `refused` (a status from 400 to 599 with the failed answer's body, which `chatRefusal` reads, a business code only at its own status), `unreached` or `incompatible` (`ChatExchangeBreach`: `status`, `content-type`, `json`, `shape` or `business-status`), frozen, its answer and body held as accepted by the shapes that read them.
76
+ An answer of 401, 408, 429 or a 5xx without the failed answer's body, such as a relay's in front of the endpoints or the edge's, is `refused` with no body (`null`), read by the status's class alone; another 4xx without it stays one that breaks the contract, which reloading the page mends.
77
+ Every transport of the package shares the check of a request, which reads its fields once and refuses one that breaks the endpoint's exchange before anything is sent, in the order of its fields, naming `ChatTransport.exchange`; the query and the body are sent as their schemas read them and an upload's file as the copy the browser's readers of a `Blob` make, so no getter, `toJSON` or prototype of the caller's runs.
78
+ `createHttpChatTransport` sends through the host's `fetch` (`ChatFetch`) to a base for the JSON endpoints and one for the uploads (`ChatHttpTransportOptions`, read once), with `Accept: application/json`, a JSON body or an upload's multipart body, no redirect followed and no HTTP cache, once, and reads the answer once with the browser's own readers of a `Response`, its `Headers` and its body's stream (a `Content-Type` holding one value that declares `application/json`, a comma outside a quoted string separating values), cancelling a body it does not read.
79
+ It writes an upload's multipart body itself: its parts in the upload's order, every text byte for byte, the file's name escaped as browsers do, and a boundary of 16 bytes from `crypto.getRandomValues` for each sending.
80
+ Every write (a request of any method but `GET` and `HEAD`) carries the host's stamp: the transport hands its target (its path and query after the base's origin) once to the host's required `stampWrite` (`ChatStampWrite`, with no default; a host whose server checks no reader passes the identity) and sends it to the base's origin as written followed by the target the stamp answers, whose name and form the host decides; a read never goes through it.
81
+ A stamp that throws, answers a value that is not a string, or answers a string that is not a path of the same origin that begins with one `/` (one the URL parser resolves as a path of whatever origin it is joined to) is refused naming `stampWrite` before anything is sent, the string it answered never repeated.
82
+ When it is made, after its options, it checks that the runtime has the members of `Response`, `Headers`, `ReadableStream`, `Blob` and `AbortSignal` it reads through their prototypes (an attribute as an accessor of its interface's own prototype, as Web IDL makes it) and refuses a runtime lacking one, naming it, such as happy-dom or vitest's jsdom environment in a VM pool, which has no `ReadableStream`.
83
+ - **The arithmetic of the screen** (`./react`): `CHAT_LAYOUT` holds every length of the chat's screen, solved from console-ui's lattice, 44 px target and `body-lg` type role (the measure of 40 characters, the gutter, the talk and side columns, the column thresholds, the composer with its input's width beside its buttons, and the gaps between messages and paragraphs).
84
+ `chatLayoutPlan` plans the columns, the gutter, the talk's measure and the outer margin of a container width, `chatFrameBlockSizePx` solves the page's part of the frame's height F_p = max(V − y₀, V / φ), and `chatLayoutRule` writes the container-query rules from the same lengths, in rem, under a key the lengths decide, laying the screen out as the plan does (the talk's column is never wider than C, so the talk alone keeps the measure).
85
+ The frame takes F_p as its least height and grows to its content's least height, the page scrolling the rest, so its content never spills over what follows it; the composer stays at its bottom, and the scrolling regions (a side column's body, and above the composer the message list's scroll box or the talk's flow) keep at least R = 2T and count none of their content toward the frame's height.
86
+ The composer's list of attachments grows to the larger of F_p / φ³ and R before it scrolls inside, so a short window (as at 400 % zoom) never scrolls it in a slice thinner than R.
87
+ The rules space a message body's flow by the paragraph gap p (1.5 ℓ, and 1.5 ℓ_r for a body with readings; WCAG 1.4.8).
88
+ A drawn answer's document, its `aside` and `details` elements and the holders of its flow take its body's type and line (ℓ_r with readings) over the renderer's own sheets, which write a message, a details and the footnotes smaller, and a text shown as it is is written in the body's type (`body-lg`).
89
+ The blocks of a drawn answer (the children of the renderer's document and the blocks inside the converter's list items, quotations, description details, footnotes' list, alerts and contents of messages and details, over the renderer's own margins, the inline ones of its code blocks included) and the paragraphs of a text shown as it is, which its blank lines part, each stand p after the block before it only.
90
+ So do the items of a loose list (one whose item holds a paragraph) whatever block they start with; a tight list's items, the text's inline elements and the inside of the renderer's parts keep their own.
91
+ A text beside such a block in one of those holders (a tight list item's text before its code block, quotation or table) is wrapped as a block of its own when the answer is converted, so the rules space it too; a list is never wrapped (the renderer's sheet numbers an ordered list that is a `div`'s child as a top-level one), so a tight item's text and nested list stay together.
92
+ - **The frame of the screen** (`./react`): `ChatFrame` lays out the conversations, the talk and the process with its sources in one, two or three columns by the container's width, opens a hidden side column as a modal drawer from its toggle in the talk's bar, scrolls what stands above the composer in place of a message list in the talk's flow (`ChatTalkFlow`), draws a side column's content only where it can be seen, and never leaves focus on what a width change hides (a side column, or a drawer toggle hidden as its column shows), moving it without scrolling.
93
+ It names its side columns in the console root's language (`ja` or `en`) with headings at the level the host gives (`headingLevel`, the screen's heading origin, which the talk's heading shares), and refuses a drag of files that no part of it took, so the browser does not open a file dropped beside the composer in place of the page.
94
+ - **The composer of the talk** (`./react`): `ChatComposer` is the talk body's last item, a form named by its visible label that holds the notice of the run's stream, the paragraph of a failed send, the message's attachments, the recording row, the label line with the reason it cannot send (and the button that changes the model back while the chosen model does not take an attachment), the input that grows with its text beside the attach button, the record button and the send or stop button, the guide to the send key, the guide to what the chosen model takes, and the disclaimer.
95
+ The host holds the text, the phase, the failed send (`ChatComposerProblem`: `unreached`, `refused` with the endpoint's refusal (`ChatRefusal`) or `incompatible` for an answer that breaks the contract, with the number of its occurrence) and the attachments in their stages of upload (`ChatComposerAttachment`, an upload's or a reread's answer that breaks the contract among them, which is never tried again).
96
+ The host also hands the tunables the composer reads (`limits`, `ChatComposerLimits`, as `GET /settings` answers them), and the composer throws a `RangeError` naming the key and the value of a tunable that is not a positive safe integer, as it does naming the value of an occurrence that is a number but not one (a `TypeError` for one that is not a number).
97
+ The composer writes the failed send's paragraph itself in the root's language (for an answer that breaks the contract, that whether the message was sent is not known, with the stream's `Reload the page.`), and marks the input invalid when the refusal names the text. It reads the failed send and each attachment once where it checks them and shows the frozen copies it read; the endpoint's attachment of an `uploaded` or `expired` one, a value of the contract, is kept as handed, as the package treats every value of the contract as read-only.
98
+ The composer reads each attachment's condition from its stage and the chosen model's flags, and shows it in a row: the endpoint's preview of a ready image or PDF read from `contentBaseUrl`, the name, the kind with a PDF's pages or a recording's length and the size (console-ui's `formatByteSize`), the condition's sentence, and the try-again, details and remove buttons naming the attachment.
99
+ The details button of an uploaded attachment that has not failed opens a modal dialog named by its name and described by its facts: the field of its alternative text, which follows the endpoint's text until the operator changes it, and the text read from it (an image's text, a PDF's pages under a heading each, a recording's segments with their clocks) with the notes of the reading.
100
+ Every name the composer shows (an attachment's on its row, in its buttons' names and as the dialog's name, and the model's on the button that changes it back) and the read text carry the marks of the characters a reader cannot see (`markChatInvisible`), and the read text's notes end with how many it holds; each paragraph of the read text carries the language of its text, decided before the marks; the input and the field of the alternative text keep what the operator writes.
101
+ The host saves the text (`onSaveAltText`, `ChatComposerSaveAltText`) without ever rejecting, and answers the outcome (`ChatComposerAltTextOutcome`: `saved`, `refused` with the endpoint's refusal (`ChatRefusal`), `unreached` or `incompatible`), which the dialog shows and announces once, as it read the answer once (its refusal with it); a save that throws, rejects or answers outside the outcomes shows as `incompatible`, and the composer reports its breach, named, through `reportError`.
102
+ It sends only while it is ready and no text longer than the limit of a message (`CHAT_USER_MESSAGE_MAX_CHARS`, counted in UTF-16 code units as the contract counts a text's length), attachment that cannot be sent, that the chosen model does not take, a recording under way or an attachment not ready stops the send, ready attachments alone sending an empty text.
103
+ A text past the limit is never cut: the label line says by how many characters to shorten it, with the limit, and the input is marked invalid while the composer is ready. Files come from the attach button's picker, a paste of files without text and a drop, and go to the host (`onAdd`), which checks each with `precheckChatAttachment`; while the model takes no kind or the message holds its limit, they are not handed over and the guide is announced.
104
+ While the host hands a microphone (`microphone`) that records one of the contract's audio types here and the chosen model takes audio, the record button opens it; a page drawn on the server offers no recording, so the hydration matches. The recording row shows the opening, the recording with its clock (a `timer`, not announced as it moves) beside the stop button, and the microphone's problem.
105
+ A recording asks for the bit rate of speech (64 kbit/s, lowered to the rate at which the longest recording fills `CHAT_ATTACHMENT_AUDIO_MAX_BYTES`) in pieces of a second, counts as one of the message's attachments while it is under way, and stops by itself as soon as two more pieces of its longest and largest so far could pass `CHAT_ATTACHMENT_AUDIO_MAX_SECONDS` or `CHAT_ATTACHMENT_AUDIO_MAX_BYTES`, so that, while its pieces keep that pace, it is not refused for them after it was spoken.
106
+ Its end hands `onAdd` one file of its pieces in the asked type, named by its start in the user's time zone; a recording with no byte hands nothing, and the composer leaving discards a recording and releases the microphone. The microphone's answer is read once, and the pieces and the end belong to the recording from the call of `record` on, taken one at a time in their order: those before the microphone's answer once it answers the recording, and those a stop hands before it returns after the call that asked for it.
107
+ A microphone that breaks its port's contract on a start (also by answering a refusal after handing a piece or its end) shows as one that could not be started; one that hands a piece or its end after a refusal, after the end or after a discard, a piece that is not a `Blob` as the browser's `Blob` reads one (a piece counts by the bytes it holds, never by a size it answers itself) or whose time is not a finite number from 0 and at least the previous piece's, and a recording whose stop or discard throws, break it too.
108
+ A broken piece discards the recording, which ends with the pieces before it; a throwing stop's pieces and end are taken first and its breach after them, the operator's stop and the stop at a limit alike (so a broken piece it handed is the breach named), and the recording is discarded, ending with the pieces it holds, only while it is still open after them. The first breach of a recording goes, named, to the page's uncaught errors (`reportError`), and its later calls are dropped.
109
+ The send key (`sendKey`, a word of the contract's vocabulary `send_keys`: the user's setting `send_key`, which the composer never defaults) sends from the input through the form's submit, so it passes the send button's checks: `enter` on Enter without a modifier (Shift + Enter breaks the line), `ctrl_enter` on Control + Enter and ⌘ + Enter (Enter breaks the line). Any other Enter with a modifier, and the Enter that commits an input method's composition (`@aiquants/input-method`'s `isInputMethodKey`: `isComposing`, or Safari's key code 229), are left to the browser.
110
+ While the composer cannot send, the send key adds no line break and never stops a run, and each press announces the label line's reason (the phase's while sending), or the phase's while running or stopping; a held key's automatic repeat counts as no press.
111
+ While the host sends, every hand that makes the message stops, since the send's ID is made from what it sends: the input is read-only, the attach and record buttons and an attachment's try-again, details and remove buttons cannot be pressed, files that arrive are not handed over (the phase's reason is announced instead), and the label line shows that reason, which describes the input and the stopped buttons. The guide below the input row names the send and the line break and describes the input, and `enterkeyhint` labels the on-screen keyboard's Enter key `send` or `enter` to match.
112
+ It stops a run from a separate button in the same place, hands focus on when a pressed button leaves (to the input, to an attachment's remove button, to the next attachment's, or from the recording's stop button to the record button) and from the record button to the stop button when a recording starts, and from the closed details back to their button.
113
+ It announces through the console root's announcer a failed send per occurrence (not again for a change of language), each attachment's sentence, the kinds the chosen model refuses, the end of a wait for the attachments, a recording that stopped before a limit or because the microphone stopped, and a microphone that could not be opened.
114
+ - **The reading of a refused answer** (`./react`): `chatRefusal` reads a refused JSON answer's status and body as one refusal (`ChatRefusal`) that keeps the body's request ID and code: one of the chat's business codes at the code's own status (another status is a `RangeError`), a host refusal role by the numbers the host binds the roles to (`ChatHostRefusalCodes`), or, for a code the screen knows neither way, the class of the answer's status (`ChatRefusalStatusClass`: 401 `unauthenticated`, 408, 429 and every 5xx `unavailable`, every other 4xx `not-accepted`).
115
+ An answer without a body (`null`, at 401, 408, 429 or a 5xx only) is a refusal of its status's class with no request ID or code (`null`).
116
+ `assertValidChatHostRefusalCodes` refuses the host's numbers with the errors `chatRefusal` refuses them with at every reading, before anything depends on them: a key that is not a role, a role left out or inherited, a number that is not a positive safe integer, the number of one of the contract's business codes, and two roles alike.
117
+ The composer's refused send, the attachments refused by their endpoint and the outcome of saving an alternative text carry such a refusal, which names a field the screen marks invalid (the send's `text`, an attachment's `alt_text`) only as a refused request (`REQUEST_INVALID`) one of whose errors ends at the field; another upload is offered for a busy chat, a service that did not answer, a sign-in that ended and an answer the chat could not give then. The screen says a business error's code and detail sentences, and the one sentence of a role or a class, each stating the fact alone.
118
+ - **The microphone the composer records with** (`./react`): `ChatMicrophone` is the port a host hands, which tells whether a media type can be recorded here and starts a recording (`ChatRecordingRequest`: the type, the bit rate and the least interval of the pieces) that hands its pieces, each a `Blob` with the time since its start (a finite number of ms, from 0 and not less than the previous piece's), and then its end (`ChatRecordingListener`).
119
+ It never rejects: it answers the recording (`ChatRecording`, with its stop and discard, neither of which throws) or the microphone's problem (`ChatMicrophoneProblem`: `denied`, `missing` or `unavailable`), which the composer words; a stop may hand the last piece and the end before it returns, and nothing comes with a refusal, after the end or after a discard.
120
+ `chatBrowserMicrophone(globalThis)` is the browser's, over `navigator.mediaDevices.getUserMedia` and `MediaRecorder` (`ChatMicrophoneScope`, whose recorder `ChatMediaRecorderLike` records the stream `ChatMediaStreamLike` its devices open, so `globalThis` passes as it is): it maps the browser's refusals by their names, releases the microphone when a recording ends, at once when it is discarded, and, answering `unavailable`, when the recorder cannot be made or started or the scope's clock throws, and never stops an inactive recorder again.
121
+ - **The attachment rules of the screen** (`./react`): `chatModelTakesKind`, `chatModelAttachmentKinds`, `chatFilePickerAccept`, `chatDeclaredAttachmentKind`, `precheckChatAttachment`, `chatAttachmentsRefusedByModel` and `chatAttachmentHasUnreadText` open each kind of attachment only while the chosen model's flag for it is on, check a file before its upload in the endpoint's order and with its rule tags, find the pending attachments a model switched to does not take, and tell an attachment with text the deployment could not read.
122
+ The limits (`ChatAttachmentLimits`) are five keys of the contract's tunables, the length of one audio attachment among them.
123
+ - **`react`, `react-dom` and `@aiquants/console-ui`** are optional peer dependencies, read only by `./react`.
124
+ - **`@aiquants/markdown`** (`workspace:^14.0.0`; the renderer's `truncated`, `mermaidDrawing` and `maxMermaidDiagrams` and the drawer's types this package reads came in 13.1.0, and it reads none of the viewer that 14.0.0 split) **and `@aiquants/virtualscroll`** (`workspace:^3.26.0`) are optional peer dependencies that only `./react` reads: the answers' rendering reads `@aiquants/markdown`, and the message list reads `@aiquants/virtualscroll`.
125
+ 3.26.0 is the first release of `@aiquants/virtualscroll` with all the list reads: the measured heights `useMeasuredItemHeights`, the focused row retention `useFocusedItemRetention` and `retainedItemIndex`,
126
+ the tail state `onTailChange`, the end-visible state `onEndVisibleChange`, the unpinned landing `scrollToIndex(…, { pin: false })` and the reduced motion `reducedMotion`.
127
+ The floor of `@aiquants/console-ui` is 0.10.0. 0.7.0 is the first release whose dialog stays open on every Escape pressed in a field holding a value, not only on the first, and which keeps what 0.6.5 brought: pressed buttons that take focus in every browser (WebKit and Firefox on macOS move no focus on a pointer press), a dialog that stays open on the Escape that cancels an IME composition, and fields iOS does not zoom into.
128
+ 0.8.0 changes none of console-ui's own code and raises its `@aiquants/auth-core` floor to `^0.9.0`, so it keeps all of these.
129
+ 0.9.0 is the first release whose buttons name the keys that press them (`keyShortcuts`, which the send button sets from the user's send key) and whose root draws as for a reader who prefers reduced motion when the host says so (`reducedMotion`, which the host sets from the user's `reduce_motion`, so the setting stops every motion of the screen); a 0.x caret admits a single minor, so a `^0.8.0` range would not admit it.
130
+ 0.10.0 is the first release with `unavailable` on the choice groups, which the new conversation's choices (and the shared model choice) pass while the first send is under way; a `^0.9.0` range does not admit it.
131
+ The screen's moves of focus from a pressed button that leaves and its dialogs' return of focus to the button that opened them rely on the buttons, and the alternative text's field on the rest.
132
+ - **`@aiquants/input-method`** (`workspace:^0.1.2`) is an optional peer dependency that only `./react` reads: the send key leaves the Enter that commits an input method's composition to the browser by its `isInputMethodKey`; 0.1.2 is the first release whose exports map gives each module format its own type declarations.
133
+ Its root requires the host's presenter of access failures (`accessFailure`, an `AccessFailurePresenter` of `@aiquants/auth-core` 0.9.0 or later, console-ui's own peer dependency), so a host installs `@aiquants/auth-core` beside it.
134
+ - **The stream layer** (`./react`): `ChatAnswerRendering`, put once on the chat screen above its message list, holds the one browser converter the host's factory makes (`ChatMarkdownConverterFactory`, given the two time limits `ChatConverterTimeouts`) for every message of the window, started once the tunables (`ChatAnswerRenderLimits`) are read and released when the screen leaves, shows a stream by the user's `stream_display` (`smooth` as `immediate` while motion is reduced), and holds the diagrams' queue while an answer streams.
135
+ Each answer renders through `@aiquants/markdown`'s renderer with the untrusted text's allowlist, its links and images placed by their targets, with the marks of the characters a reader cannot see and a note that counts them.
136
+ An answer's shallowest heading stands one level below its message's heading and the deeper ones a level per depth below it, so an answer that starts at `##` skips no level; only drawn headings count, and while an answer streams or after it was cut only its settled blocks do, so the line being written moves no heading already drawn.
137
+ - **The message list** (`./react`): `ChatMessageList` lists an open conversation's messages (`ChatListMessage`) as the conversation's feed in `@aiquants/virtualscroll`'s virtual list, one article per message with its author (`ChatMessageAuthor`, with the answer's status `ChatAnswerStatus`), time and body, mounting the visible rows and `CHAT_RENDER_LIST_OVERSCAN_ROWS` around them (`ChatMessageListLimits`).
138
+ It takes the feed's keys (Page Down, Page Up, Control + End, Control + Home, and the arrows and Space on an article), keeps the focused row mounted, shows a focus its ring shows inside its scroll box's view and the box in the page's view, with the "latest" button in a row of its own below the box (so it covers no message), opens at the tail, and keeps the tail by the user's `follow_scroll`.
139
+ The rows of the "latest" button and of the button that reads an earlier page keep the reach of the button's focus ring at the list's edge, so the ring overlaps neither the talk's bar above the list nor the composer below it.
140
+ It lands once on the message the reader sent (`sentMessageUid`), stops the virtual list's motion by the user's `reduce_motion`, and announces an answer's start and end only, as the user's `notification_level` lets it (`all` both, `finish` the end, `none` neither).
141
+ It measures that reveal in the next frame, once the browser's own focus scroll has run, and brings the box into the page's view with `scrollIntoView`, which jsdom lacks.
142
+ - **The window of an open conversation** (`./react`): `useChatConversation` reads one conversation's row and the latest page of its chosen path, holds a view of every answer whose run the read shows active with its stream open (the later of the view it held and the read's seed; a view the run's own end closed outlives an older read), subscribes in the same commit to the stream of every run whose view has not ended from the view's mark, folds the streams into the views,
143
+ and answers the list's messages (each made against the one the window showed last, so a message whose read and view stay is the same object and a text that does not continue the text shown is `replaced`) and the composer's notice with its buttons, a failed read again shown over the stream's notice until a read lands.
144
+ It reads again, one read at a time, on `resync-required`, on the notice's `reread`, and when the window becomes visible or gains focus and the row (one row read at a time, dropped when a read again overtook it) shows activity it does not follow; a read again that lands lets go of the stalled subscriptions, keeps the earlier pages it read, and closes the subscriptions of runs it holds no view of.
145
+ It reads earlier pages (`older`, `loadOlder`), treats a page that repeats a message's uid as a breach of the contract, ends as `refused` on any refusal, answers `failed` with `retry` when its first read fails, holds the one conversation it opened (another `conversationUid` throws a `RangeError`), uses the latest transport, streams and refusal roles' numbers, and stops its reads and closes its subscriptions when it leaves or React's `Activity` hides it.
146
+ An answer whose run's stream is no longer open holds no view and opens no subscription, even while the read shows the run active: it shows the read's text, the answer so far, as a growing text while the read shows the run writing, and moves on when the window reads again on becoming visible or gaining focus.
147
+ - **The sending and the stopping in an open conversation's window** (`./react`): `useChatSend` sends a message under the end of the window's path with the conversation's model and reasoning level (`startRun` of kind `send`) while the phase is `ready`, keeps the request ID for the same content sent again after a send that did not land and makes a new one for new content, answers an accepted send's message (`sentMessageUid`) and has the window read again,
148
+ holding the accepted run as the running one until a read started after the acceptance lands, answers a failed send in the composer's shape (`problem`, numbered by its occurrence) and has the window read again, stops the running run (`cancelRun`), sending the same stop again while the admission is busy until the run ends, and answers the composer's phase (`sending`, `running`, `stopping`, `ready`).
149
+ The window answers `reread`, a promise that settles once a read started after the call lands.
150
+ - **A new conversation** (`./react`): `useChatNewConversation` sends a new conversation's first message with the model, reasoning level and declared level the person chose (`createConversation`), which makes the conversation, and answers the composer's phase (`ready` or `sending`) and failed send; the same content sent again after a send that did not land keeps its ID, so a first send that made the conversation is found rather than made twice.
151
+ `useChatNewConversationChoice` holds the level, model and reasoning level the first send starts it with, and `ChatNewConversationChoices` draws them as three radio groups above the composer, taking the first send's `phase`: while the host sends, the groups cannot be chosen again, described by the phase's reason drawn once after them.
152
+ `useChatConversationCreatedAnnouncer` answers the function that says, through the console root's announcer in the root's language, that the conversation was made; the host calls it once per accepted first send, after focus has moved to the page's title.
153
+ - **The person's settings and their form** (`./react`): `useChatSettings` reads the person's settings (`getSettings`) when it mounts, and again when it is shown while it holds none, saves the changed settings only (`updateSettings`, the body checked by the contract) while they are open and no other save runs, takes the answer's settings whole, and holds a failed save numbered by its occurrence.
154
+ `useChatModels` reads the list of models a new conversation may start with (`listModels` without a query), which the default model is chosen from, and reads it again when asked.
155
+ `ChatSettingsForm` shows the seven settings the chat's screen follows today (the two of a message's actions wait for the message's actions), holds the changes until a save that lands settles them, saves the changed ones with its button, shows and tells a save that changed nothing, landed with no change made meanwhile, or failed, and marks the setting a refusal names.
156
+ The default model is chosen from the organization's default and the models that can be the default (stopped or breaker-paused ones with their state named); the others are listed with their reason, and after a refusal of the default model the form reads the list again and tells why the chosen model cannot be the default.
157
+ A refused read carries a retry when reading again can mend it (an answer the chat cannot give now, a sign-in that ended), and none for a refusal a read again answers alike.
158
+ A button reads the settings or the list again after a failure or a refusal the chat cannot answer now, stays busy while the read it started runs, and hands focus on when it leaves; a sign-in that ended goes to the root's presenter of access failures, once per occurrence (as console-ui's `FailureMessage` hands an access failure).
159
+ `ChatTalkHeading` draws the talk's heading the host puts in the frame's talk bar, in the root's language at the level the host gives: the open conversation's title with the marks of the characters a reader cannot see, the catalog's name of an untitled conversation, or the catalog's new conversation while none is open. Its title's text carries the id the host gives (`labelId`), which the message list names its feed by.
160
+ `ChatSettingsGate` waits for the settings, which the screen's parts take their tunables from: it draws its children with the open settings and, until then, the read under way or the refused or failed read with a button that reads again, and moves focus from a button that leaves to the read's area, or to the element the host names (`focusAfterOpen`) when the settings open.
161
+ `ChatConversationGate` waits for the open conversation's window: it draws its children with the open conversation and, until then, the read under way, a failed read with a button that reads again, a refusal the chat cannot answer now with a button that opens the conversation again (`onReopen`, a new window under a new key, after handing the pressed button's focus to the host's element), an expired sign-in handed to the root's presenter (which opens it again), or any other refusal's paragraph, announced once.
162
+ - **The list of the person's conversations** (`./react`): `useChatConversationList` holds the search box's text and reads the pinned and the recent conversations a page at a time (console-ui's `usePagedResource`), searches the titles once typing pauses for `CHAT_TITLE_SEARCH_PAUSE_MS` with the contract's search text, keeps showing the rows while a new search is read, tells a search's count once, and hands console-ui a failed read's short reason (none for an access failure).
163
+ `ChatConversationList` draws the new conversation's button, the search of the titles, and the two sections of `RowLink` rows (title, last activity, the active run in words, the deletion time) with their `LoadMore`, and hands focus on when a row or a failure's button leaves.
164
+ The contract's tunables add `CHAT_CONVERSATION_PAGE_SIZE` and `CHAT_TITLE_SEARCH_PAUSE_MS` after the rendering ones, 21 keys in all.
165
+ - **The composer's attachments** (`./react`): `useChatComposerAttachments` holds the attachments of the message being written through their life: the check before an upload (a stopped file is never uploaded and does not count), the upload for the chosen model with its outcomes, another try, the read again of an attachment still being read every `CHAT_ATTACHMENT_POLL_INTERVAL_MS`, the expiry before the send, the removal (stopping the upload or read, deleting an uploaded attachment),
166
+ the saving of the alternative text in the order asked, the uids ready to send and the clearing after an accepted send.
167
+ - **The list's read again** (`./react`): `useChatConversationList` reads each section again when the page is shown again or its window gains focus, one read at a time and in turn with the section's reads of more: up to its next cursor in one request (`until`), laid over its rows with console-ui's `updateList` (the pages, the cursor, the rows' DOM and focus stay), an answer cut at the re-read's limit dropped for a read from the first page (`refresh`), and a section read to its end read again from its head; a 401 or a 403 reads the first page again, and any other failure keeps the rows.
168
+ - **The attachments' read again** (`./protocol`): the contract's tunables add `CHAT_ATTACHMENT_POLL_INTERVAL_MS` after the attachments' keys, 22 keys in all: the interval at which a screen reads an uploaded attachment again while it is `processing`.
169
+ - **The send button's keys** (`./react`, inside the composer): the send button names the keys that press it (`aria-keyshortcuts`: `Enter`, or `Control+Enter Meta+Enter`, by the user's send key); the stop button names none.
170
+ - **The name of a saved diagram** (`./react`): `diagramFileName` names a diagram a window saves, `yyyy.mm.dd [AI] chat-<conversation>-<message>-diagram-<n>[ <accTitle>].svg` or `.png`, with the last 8 characters of each uid and the day of the save in the user's time zone.
171
+ The title drops the characters a file name cannot hold, the control characters and the bidirectional controls, keeps one space for each run of spaces and the first 64 grapheme clusters, never starts or ends with a space, and is cut by grapheme clusters until the name fits 255 bytes in UTF-8, by the rule the server's names of a conversation's exports follow.
172
+ A context that is not an object, a number that is not a number, a title that is neither `null` nor a string, an instant that is not a `Date` and a time zone that is not a string are refused with a `TypeError`; a uid of another form, a number outside 1 to 2^53 - 1, a form outside `svg` and `png`, a title with a lone surrogate, a date that cannot be read, an unknown time zone and a day outside years 1 to 9999 with a `RangeError`.
173
+ - **The name of a recording** (`./react`, inside the composer): `yyyy.mm.dd chat-recording-<hhmmss>.<extension>`, the date and the 24-hour time of its start in the user's time zone and the extension of its media type (`.webm`, `.m4a`, `.wav`, `.mp3`, `.ogg` or `.flac`), without `[AI]` since the operator made it.
174
+ - **The golden samples of file names** (`tests/fixtures/export-file-names-golden.json`, not shipped): written by hand, one sample a line with every invisible character escaped, in three sections: `titles` (the title's rule both languages share), `exports` (the server's names of a conversation's exports) and `diagrams` (`diagramFileName`).
175
+ - **The golden samples of an answer's end** (`tests/fixtures/chat-answer-end-golden.json`, not shipped): written by hand, each an ended run's status (the contract's run failure for a failed one) with whether the answer's text shows anything, and the kind of mark both languages give (`chatAnswerEndMark`, the server's `answer_end_kind`), or `null` for none.
176
+ - **The authorization resources** (`./authz`): `CHAT_RESOURCES` (`chat`, `chat_admin`, `chat_audit`) in the shape a host's registry collects, frozen with each definition, so no reader in the process can add, remove or replace a resource or its words.
177
+ `@aiquants/authz-core` is an optional peer dependency (`workspace:^0.6.2`, the first release with `AuthzDefinition` and `collectAuthzDefinitions`): the entry reads nothing of it, and the host's call of the registry needs it.
178
+ - **The testing tools** (`./testing`): `createChatScenarioFetch` makes the scenario a test hands the package's own transport as its `fetch`, answering in the server's place, so the tests of a screen run the transport's writing of requests and reading of answers with no fake transport (`ChatScenarioFetch`, frozen; its options, `ChatScenarioFetchOptions`, are read once and its bases held to the rule of every base, and it checks the members of `Blob` and `AbortSignal` it reads, and `AbortSignal.any`, which it calls, as the transport checks its own).
179
+ A write's target is first read through the host's server's reading of its stamp, the required `unstampWrite` (`ChatUnstampWrite`), so a test runs the host's own stamp over the transport and a write a host leaves unstamped is a breach.
180
+ It reads each request back into the contract's words (`ChatScenarioRequest`): the endpoint its method and path name under the base of its channel, the path's parameters and the query written as the contract's path functions and `chatQueryString` write them, the JSON text or the multipart body in the form the transport writes, and the transport's own check of a request.
181
+ That form is a strict form of RFC 2046's, with no preamble, padding or epilogue and a CRLF after the close delimiter, read byte for byte by the package's own reader of RFC 7578 bodies, a file part as a `Blob` of its type, also where the global `Blob` is jsdom 27's and has no `arrayBuffer`, through a `FileReader`, which a fake `setImmediate` holds until the test's clock moves.
182
+ A runtime with neither `Blob.prototype.arrayBuffer` nor a `FileReader` is refused when the scenario is made, after the members of `Blob` and `AbortSignal` and `AbortSignal.any`. The entry asks for Node.js >= 24, whose `AbortSignal` sets the aborted flags of a signal's dependents before it runs the signal's listeners, as the DOM does: the abort order the scenario relies on.
183
+ An endpoint's steps (`ChatScenarioStep`) are taken in the order its requests arrive: a reply (`ChatScenarioReply`: `answered`, `refused`, `unreached` or `response`), checked once when it is planned, settled or returned by a function step, a function that returns one, or a held step (`hold`, with its handle `ChatScenarioHold`) answered by `settle`; `plan` and `hold` take one endpoint typed as `exchange` takes it, and `plan` at least one step (an array of them may be spread). `chatScenarioRefusal` makes a business code's refused reply at the code's own status.
184
+ A request's signal, read with the browser's members of `AbortSignal` (`aborted`, `reason`) rather than any of the signal's own, stops it: the scenario listens to it as a browser's `fetch` does, through the request's own signal, which the runtime's `AbortSignal.any` makes from it as the `Request` constructor makes a request's, with the browser's `addEventListener` and `removeEventListener`,
185
+ leaving no listener on the init's signal (it adds one and removes it at once, and the same to the request's own signal, so that an init Node's `AbortSignal.any` made follows its sources before the request's own signal and the runtime writes all it writes into the signals for the request when `fetch` is called, as the DOM places them; any other signal Node's `AbortSignal.any` made before `fetch` from the init's signal or a signal it follows keeps Node's place) and removing its own once the request is answered or rejected.
186
+ One already aborted when `fetch` is called rejects with its reason once the init's four fields are read, reading nothing more even of a request it could not read, where the browser's `fetch` checks the init first as it makes its `Request`.
187
+ A request stopped before the scenario has read it, while it waits its turn or while it is read, is read no further, takes no step, is not recorded and is no breach; one stopped after it took its step stays recorded, its held step stopped and what its function returns not answered (a step's function's reply not made into an answer, nor its `response` function called).
188
+ The request's own signal runs its abort steps once the init's signal has run its own listeners, whatever they do (DOM's "signal abort"), so a listener that stops the abort event's immediate propagation does not keep the scenario from hearing it.
189
+ A signal counts as aborted from the moment it is, as no answer of a browser's `fetch` arrives before those steps reject the call: while the abort is being dispatched to the init's signal's listeners, the scenario neither reads nor answers the request, and `settle` and `assertDone` called there read the request as stopped, such a `settle` throwing as one after the abort does; an answer's body is errored by those steps alone, as a browser's is, so a read of it begun there gets its bytes and a cancel of it there succeeds.
190
+ A request whose step is a reply or a function is answered in the jobs that follow the call, once it is read, not in a later task as a browser's answer arrives, so an abort later in the task that called `fetch` finds it answered once those jobs have run.
191
+ A `response` function's thenable is adopted as the language adopts one (its `then` read once where the function is called, only its first outcome counting, a thenable it fulfils with adopted a job later in turn) and awaited within the exchange, its outcome heard the moment the thenable reports it (a promise of the language reports a job after it settles, an async function's throw among them):
192
+ the request has no outcome until then, a held step settled with it refuses another `settle` meanwhile (as it does while the function runs), and a stop before the outcome is reported rejects with the reason, dropping what is reported later.
193
+ A stop after `fetch` resolved with a reply the scenario made with a body (`answered`, `refused`) errors that body with the reason until it is read to its end or cancelled, as a browser's `fetch` does, and then removes its listener; what a `response` function makes is handed over as it is, out of the stop's reach.
194
+ The body is a byte stream, as a browser's is, holding every byte from the start as the body of an answer that has fully arrived does, handed out as each read asks (a reader in `byob` mode included) and closing when its last byte is read, which ends a read still waiting for more (a `byob` read whose `min` passes the bytes left) with those left; a copy `clone()` makes shares it, both copies erroring on a stop before either is read to its end, and neither once one is (a browser's still errors the original's while it is unread).
195
+ A request the scenario cannot read, one no step is left for, a step's function that throws or returns a reply the check refuses, a `response` function that throws, returns a thenable that reports a rejection before the request is stopped (through a thenable it fulfils with too) or returns a value whose `then` throws when read, and a reply the runtime cannot make into a `Response` are breaches, recorded when they happen, which `fetch` rejects with (or with the signal's reason where the function stopped the request itself first).
196
+ A signal the runtime's `AbortSignal.any` refuses to make the request's own signal from (Node.js refuses one frozen, sealed or made non-extensible where it would write into it), or makes an aborted request signal from while it is not aborted (Node.js reads a signal's `aborted` and `reason` members as ordinary members, so it does from one whose own or inherited `aborted` reads true), is a breach as well,
197
+ recorded when `fetch` is called as a `TypeError` naming `init.signal` with the runtime's error, or one naming the aborted signal, as its cause, before anything else of the request is read or kept.
198
+ A request no step is left for is not among `requests()`, and one whose step breaches is.
199
+ `assertDone` throws naming the number of requests still being read (one awaiting a `response` function's thenable among them), the breaches, the number of steps never taken of each endpoint and the held requests neither answered nor stopped (one whose `response` function runs or whose thenable is awaited among them), in that order, and a verdict it gives does not change afterwards. The entry reads only `zod`.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 AI Quants
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.