Skip to content

Glirastes 0.27.0

Choose a tag to compare

@github-actions github-actions released this 25 Nov 13:07
· 17 commits to main since this release
8332f1c

Added

  • View context, browser side: useViewContext(entry | null) (glirastes/react) and registerViewContext(source, entry | null) / currentViewContext() (glirastes/browser) let a page declare what the user has open (ViewContextEntry of glirastes/contracts: a record and/or a selection of a declared entity type in one entry, optional label, facts, unsaved, route). Nothing is read from the page or the URL. The bundled Vercel transport (VercelAiChat, useVercelAiChatTransport, <glirastes-chat>) sends it with every new user message as glirastesViewContext: { version: 1, current } when the cleaned snapshot is not empty, read at send time, cleaned and bounded in the browser with the contract (sanitizeViewContext, VIEW_CONTEXT_LIMITS: 8 entries in the order the sources first registered, 50 ids per selection with at most 100 looked at, labels of at most 60 characters); the server checks it again and stays the authority (a selection of a type it does not declare is dropped, the entry stays when it has an entity). Every new user message carries it, including the "continue" message after a cut-off answer, the answer to a clarification and a direct / command (the server adds no block for the last two). Continuations that start after the stream ended (approval resume, continueTurn, budget "Continue") carry none; an automatic continuation the AI SDK starts from the running request (an approval answered or a UI outcome written while the answer streams) can repeat the field of the first send, also an entry unregistered since, which the server ignores for every continuation (no block, model input unchanged). An update and a send in the same event handler send the previous entry (the hook registers after its commit); call registerViewContext first or send after the commit. currentViewContext() creates the shared registry when there is none; sending does not. When it is sent, the field replaces a glirastesViewContext the app puts into bodyExtras. React runs child effects first, so a page registers before its layout; past 8 entries the first 8 are sent and a parent's entry can be dropped. In development the console names each source whose entry is not sent as registered (once per source and reason, never a value). To turn it off: register nothing (or pass null), or set viewContext: false on the server (createAiChatHandler). There is no switch per chat instance: two chats on one page share the registry, and only their server endpoints can turn it off separately. A transport of your own sends nothing unless it adds currentViewContext() itself; ChatTransport is unchanged. Unchanged apps: nothing changes: while no page registers anything no field is sent, so the request body, the model input and the server block are byte-identical; the transport reaches the cleaning code only through registerViewContext, so AiChatProvider with the Vercel transport grows by about 0.4 KB minified (0.15 KB gzip, measured with bun build, React and the AI SDK external) for an app that never registers anything. The view context goes only to the app's chat route, never to the Platform, telemetry, logs or storage. Known limits: a queued message carries the view of the moment it is sent, not of the moment it was queued (binding to the message follows); a view context record does not count as seen for entityLinks.verifyMentions yet; the runtime container keeps the server side off until chat.viewContext; with piiShield a label over 60 characters is still cut before the shield sees it (see 0.25.0), so keep personal data out of long labels.

Changed

  • Behaviour change: "Send now" in the queue sends right away. queue.sendNowBehavior defaults to 'abort': sendNow(id) (and the queue's "Send now" button) stops the running answer and sends the message at once; that stop does not pause the queue. Before, the default 'next' only moved the message to the head, so with one queued message the button did nothing visible until the answer ended. sendNowBehavior: 'next' keeps the old behaviour. With an open approval sendNowDuringApproval applies as before.
  • Editing a queued message (ChatQueue): the text field takes the focus with the caret after the text, Enter saves (Shift+Enter breaks the line, not while composing with an IME), Escape cancels, and after save or cancel the focus returns to the message's Edit button.
  • The recording waveform (RecordingBar, AiTriggerButton) shows the recent loudness as thin bars that fill the width and scroll from right to left, newest on the right, with a dotted baseline for silence and the oldest side fading out. Before, six bars moved with one level. It is drawn on a canvas in the text color (currentColor), so color on [data-part="wave-container"] (or any ancestor) themes it; the element stays [data-element="waveform"] (now aria-hidden, 24 px high). With prefers-reduced-motion the bars step instead of gliding. Styles that sized or colored the old span bars no longer apply. No API change; still no second microphone (it reads the recorder's stream).

Security

  • Look-alike <view-context> tags in user text: while viewContext is on (the default), createAiChatHandler sends <view-context and </view-context in the text of user messages (and the file names of their attachments) to the model as &lt;view-context (escapeTagInText, as for <memory>): the tag in its ASCII spelling, in any case, also with whitespace, zero-width characters or a soft hyphen between < and the name or around the /, and <view-context-…>; an &lt; typed before the name becomes &amp;lt; so the two stay apart. The model still reads the text. It applies to every user message of the history sent to the model (string content and text parts), also on a continuation and with the answer to a clarification, after the PII shield and the guardrails (the PII shield and the intent classification of the pipeline mode get the text as the user wrote it, they see no file names; the guardrails, a custom streamHandler, the chat and the stream get the text and file names as the user wrote them). The block the SDK renders stays as it is. Messages the SDK writes itself are never escaped: the seen-objects memo, the chat memory, the view context block, the budget continuation and the final summary instruction. The filename of a file part is escaped too, in the part itself (providers such as @ai-sdk/openai pass it on for PDFs) and in its placeholder text; the content of files is not. Not verified against the real service: whether the OpenAI API accepts &lt; in the filename of a file part; no locally installed provider refuses the name. Not caught: full-width or look-alike characters (<, homoglyphs, other hyphens), a line break or an invisible character inside the name, control and bidi characters between < and the name (such as U+0001, U+007F, U+0085, U+200E, U+202E, U+2066), in text and file names (issue #218), entities such as &#60;, a tag split across two text parts or two messages, the content of file attachments, the tool call arguments of an approval continuation, the imitated header text without tags, chat memory notes and summaries, tool results and assistant text. Either way the block grants no permission: the server checks types, ids and facts on its own. Text without the name view-context (any case) is returned unchanged without a scan; in text with it, the pattern's rule that a < before 64 or more whitespace or zero-width characters counts as a tag still applies (over-escaping). Known limit: such text with many < and whitespace costs about 0.2 to 0.8 s of CPU per MB on Node, bounded by maxBodyBytes: 1 MB by default, but 50,000,000 bytes by default with attachments.enabled, where one such request can take roughly 10 to 40 s. Unchanged apps: the model input changes only for user text or a file name that contains the name view-context (any case): there for every tag the pattern matches, including the over-escaped < before 64 or more whitespace or zero-width characters; text and file names without the name and everything else, the block and the system prompt included, are byte-identical. With viewContext: false (and in the runtime container, which sets it) nothing changes, since no block can be sent.