Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
feat(ai): bufferedStream (#3810)
Eric Hayes5c4a1f8e1632
diff --git a/js/app/packages/core/component/AI/state/createChatController.ts b/js/app/packages/core/component/AI/state/createChatController.tsindex a8332041f1..72262a6022 100644--- a/js/app/packages/core/component/AI/state/createChatController.ts+++ b/js/app/packages/core/component/AI/state/createChatController.ts@@ -1,5 +1,6 @@import type { ChatMessageWithAttachments } from '@core/component/AI/types';import { asChatMessage } from '@core/component/AI/util/message';+import { bufferedStream } from '@core/component/AI/util/stream';import { toast } from '@core/component/Toast/Toast';import type { ChatMessageStream } from '@service-connection/stream';import { getEntityStreams } from '@service-connection/stream';@@ -109,7 +110,17 @@ export function createChatController(function dispatch(event: ControllerEvent) {// Handle stream attachment through the state transitionif (event.type === 'stream_connected' && 'stream' in event) {- const { stream: newStream, owner = getOwner() } = event;+ const { owner = getOwner() } = event;+ let newStream: ChatMessageStream;+ if (owner) {+ const ownedStream = runWithOwner(owner, () =>+ bufferedStream(event.stream)+ );+ if (!ownedStream) return;+ newStream = ownedStream;+ } else {+ newStream = bufferedStream(event.stream);+ }setStream(newStream);const result = transition(untrack(phase), { type: 'stream_connected' });diff --git a/js/app/packages/core/component/AI/util/stream/bufferedStream.ts b/js/app/packages/core/component/AI/util/stream/bufferedStream.tsnew file mode 100644index 0000000000..429c027d48--- /dev/null+++ b/js/app/packages/core/component/AI/util/stream/bufferedStream.ts@@ -0,0 +1,448 @@+import type {+ AssistantMessagePart,+ ChatStream,+} from '@service-cognition/generated/schemas';+import {+ type ChatMessageStream,+ type ChatStreamController,+ createStreamController,+} from '@service-connection/stream';+import { createEffect, on } from 'solid-js';+import { match, P } from 'ts-pattern';++/* Target latency between character */+const TARGET_LATENCY_MS = 6;+/*+ Catchup is triggered if the buffered stream is significantly trailing behind+ the source stream. This can happen on reconnects+*/+const CATCHUP_LATENCY_CHUNKS = 2;++/*+ Communicates what part of source stream has been consumed+ used for hand-off between smoothConsumer and catchUpConsumer+*/+interface Consumed {+ /* outer index in stream of AssistantMessagePart */+ anchor: number;+ /*+ smoothConsumer splits TextPart into many TextPart+ this is the index within a textPart+ */+ textPartOffset?: number;+ /* index the stream at the consumed marker */+ index(stream: BufferedStream): ChatStream | undefined;+ /* increment the consumed marker */+ increment(stream: BufferedStream): void;+ /* emit everything possible */+ takeRemaining(stream: BufferedStream): ChatStream[];+}++interface ConsumerHandle {+ cleanup(): Consumed;+}++type BufferedStream = {+ source: ChatMessageStream;+ controller: ChatStreamController;+ dispatch: (event: BufferEvent) => void;+};++type BufferState =+ | { type: 'catching-up'; stream: BufferedStream; consumer: ConsumerHandle }+ | { type: 'consuming'; stream: BufferedStream; consumer: ConsumerHandle }+ | { type: 'waiting'; stream: BufferedStream; consumed?: Consumed }+ | { type: 'done'; stream: BufferedStream };++type BufferEvent =+ | { event: 'source-data'; data: ChatStream[] }+ | { event: 'fall-behind-detected' }+ | { event: 'consumer-done' }+ | { event: 'catch-up-done' }+ | { event: 'source-done' };++/**+ * True when the source has run far enough ahead of the consumed marker to+ * justify a catch-up jump instead of continuing to drip one unit at a time.+ * Distance is measured in whole source parts (not characters), so a single huge+ * text part never trips this on its own. Typically happens after a reconnect,+ * when a backlog of parts lands at once.+ */+function isBehind(stream: BufferedStream, consumed?: Consumed): boolean {+ const data = stream.source.data();+ if (!consumed) {+ return data.length > CATCHUP_LATENCY_CHUNKS;+ } else {+ return data.length - consumed.anchor > CATCHUP_LATENCY_CHUNKS;+ }+}++/**+ * Returns the single ChatStream unit sitting at the current consumed marker, or+ * `undefined` when nothing remains to emit there. A text part is narrowed to the+ * one code point at `textPartOffset` (this is how the smooth consumer emits a+ * character at a time); any other part type is returned whole at `anchor`. Read+ * only — it never moves the marker (see `increment`). Backs `Consumed.index`.+ */+function indexConsumed(+ this: Consumed,+ stream: BufferedStream+): ChatStream | undefined {+ if (this.anchor >= stream.source.data().length) return;+ const data = stream.source.data()[this.anchor];+ if (data.type !== 'chat_message_response') return data;++ return (+ match<AssistantMessagePart, ChatStream | undefined>(data.content)+ .with({ type: 'text' }, (textPart) => {+ /* index by code point, not UTF-16 unit, so surrogate pairs stay intact */+ const chars = Array.from(textPart.text);+ if (chars.length === 0) return;+ /* End of stream */+ if (this.textPartOffset && this.textPartOffset >= chars.length) {+ return;+ } else if (this.textPartOffset) {+ /* have an index into the text part -> use it*/+ return {+ ...data,+ content: {+ ...data.content,+ text: chars[this.textPartOffset],+ },+ };+ } else {+ /* Don't have an index assume 0 */+ return {+ ...data,+ content: {+ ...data.content,+ text: chars[0],+ },+ };+ }+ })+ /* not a text part -> use anchor */+ .otherwise((part) => ({+ ...data,+ content: part,+ }))+ );+}++/**+ * Advances the consumed marker by exactly one emittable unit, mirroring what+ * `index` just returned: step `textPartOffset` to the next code point inside a+ * text part, or move `anchor` to the next source part once the current one is+ * exhausted. Must stay in lock-step with `index` (both count code points, not+ * UTF-16 units) or content would be skipped or duplicated. Backs+ * `Consumed.increment`.+ */+function incrementConsumed(this: Consumed, stream: BufferedStream) {+ const data = stream.source.data();+ const current = data[this.anchor];+ if (!current) return;+ if (current.type !== 'chat_message_response') {+ this.anchor += 1;+ this.textPartOffset = undefined;+ return;+ }+ match([current.content, this.textPartOffset])+ .with([{ type: 'text' }, undefined], ([part, _]) => {+ /* count by code point to match indexConsumed */+ if (Array.from(part.text).length > 1) {+ this.textPartOffset = 1;+ } else {+ this.textPartOffset = undefined;+ this.anchor += 1;+ }+ })+ .with([{ type: 'text' }, P.number], ([part, i]) => {+ /* count by code point to match indexConsumed */+ if (i + 1 < Array.from(part.text).length) {+ this.textPartOffset = i + 1;+ } else {+ this.textPartOffset = undefined;+ this.anchor += 1;+ }+ })+ .otherwise(() => {+ this.textPartOffset = undefined;+ this.anchor += 1;+ });+}++/**+ * Emits everything from the consumed marker to the end of the currently+ * available source data in one shot and advances the marker past all of it.+ * Powers catch-up jumps and the final flush: a partially-consumed text part is+ * emitted from `textPartOffset` onward, followed by every later part whole.+ * Preserves source order and content exactly. Backs `Consumed.takeRemaining`.+ */+function takeRemainingConsumed(+ this: Consumed,+ stream: BufferedStream+): ChatStream[] {+ const data = stream.source.data();+ return match<[ChatStream | undefined, number | undefined], ChatStream[]>([+ data[this.anchor],+ this.textPartOffset,+ ])+ .with([undefined, P._], () => [])+ .with(+ [{ type: 'chat_message_response', content: { type: 'text' } }, P.number],+ ([textPart, i]) => {+ const firstText = Array.from(textPart.content.text).slice(i).join('');+ const firstPart = {+ ...textPart,+ content: { ...textPart.content, text: firstText },+ };+ const remaining = data.slice(this.anchor + 1);+ this.textPartOffset = undefined;+ this.anchor = data.length;+ return [firstPart, ...remaining];+ }+ )+ .otherwise(() => {+ const remaining = data.slice(this.anchor);+ this.textPartOffset = undefined;+ this.anchor = data.length;+ return remaining;+ });+}++/**+ * Builds a fresh consumed marker at the start of the source (anchor 0, no text+ * offset) wired to the index/increment/takeRemaining behaviour.+ */+function createConsumed(): Consumed {+ return {+ anchor: 0,+ index: indexConsumed,+ increment: incrementConsumed,+ takeRemaining: takeRemainingConsumed,+ };+}++/**+ * Drives the smooth playback loop: emits one unit (a single character for text)+ * every TARGET_LATENCY_MS via setTimeout, resuming from `prev` when handed an+ * existing marker. Dispatches `fall-behind-detected` when the source has raced+ * too far ahead (so the machine hands off to a catch-up consumer) or+ * `consumer-done` once it drains everything currently available. `cleanup`+ * cancels the pending tick and returns the marker so the next consumer resumes+ * exactly where this one stopped.+ */+function createSmoothConsumer(+ stream: BufferedStream,+ prev?: Consumed+): ConsumerHandle {+ let timeout: ReturnType<typeof setTimeout> | undefined;++ const consumed = prev ? prev : createConsumed();++ /* Emit one unit then schedule the next tick — unless we've fallen behind or run dry. */+ function takeOne() {+ let part: ChatStream | undefined;+ if (isBehind(stream, consumed)) {+ stream.dispatch({ event: 'fall-behind-detected' });+ return;+ }+ part = consumed.index(stream);+ consumed.increment(stream);++ if (!part) {+ stream.dispatch({ event: 'consumer-done' });+ } else {+ stream.controller.setData((p) => [...p, part]);+ timeout = setTimeout(takeOne, TARGET_LATENCY_MS);+ }+ }++ takeOne();++ /* Stop the playback loop and hand back the marker for the next consumer. */+ function cleanup() {+ if (timeout) clearTimeout(timeout);+ return consumed;+ }+ return { cleanup };+}++/**+ * Closes a large gap in one go: flushes all currently-buffered source data to+ * the output without per-character pacing, then dispatches `catch-up-done`. Used+ * after the smooth consumer falls behind (e.g. a reconnect backlog) so the+ * viewer snaps to the live position instead of crawling. `cleanup` returns the+ * now fully-advanced marker for the consumer that takes over.+ */+function createCatchUpConsumer(+ stream: BufferedStream,+ prev?: Consumed+): ConsumerHandle {+ const consumed = prev ? prev : createConsumed();+ const rest = consumed.takeRemaining(stream);+ stream.controller.setData((p) => [...p, ...rest]);+ stream.dispatch({ event: 'catch-up-done' });++ /* Nothing to tear down; just surface the advanced marker. */+ function cleanup() {+ return consumed;+ }++ return { cleanup };+}++/**+ * Single step of the buffering state machine: maps (current state, event) to the+ * next state and performs that edge's side effects — spawning or cleaning up+ * consumers, flushing buffered data, and signalling done on the output+ * controller. The flow is waiting (idle, nothing to emit) -> consuming (dripping+ * smoothly) -> catching-up (jumping ahead after falling behind) -> done, with+ * consuming and waiting cycling as data arrives. Each match arm is annotated+ * with the edge it handles; unlisted (state, event) pairs are intentional no-ops.+ */+function transition(+ currentState: BufferState,+ event: BufferEvent+): BufferState {+ return (+ match<[BufferState, BufferEvent], BufferState>([currentState, event])+ /* ignore events */+ /* ignore any event in done state*/+ .with([{ type: 'done' }, P._], ([state, _]) => state)+ /* ignore any event while catching up except catch-up-done */+ .with(+ [{ type: 'catching-up' }, P.not({ event: 'catch-up-done' })],+ ([state, _]) => state+ )+ /* ignore source finished if consuming*/+ .with(+ [{ type: 'consuming' }, { event: 'source-done' }],+ ([state, _]) => state+ )+ /* waiting -> consuming */+ .with([{ type: 'waiting' }, { event: 'source-data' }], ([state, _]) => {+ const consumer = createSmoothConsumer(state.stream, state.consumed);+ return { type: 'consuming', stream: state.stream, consumer };+ })+ .narrow()+ /* waiting -> done */+ .with([{ type: 'waiting' }, { event: 'source-done' }], ([state]) => {+ /* flush anything buffered past the consumed marker before completing */+ const consumed = state.consumed ?? createConsumed();+ const rest = consumed.takeRemaining(state.stream);+ state.stream.controller.setData((p) => [...p, ...rest]);+ state.stream.controller.setDone();+ return { type: 'done', stream: state.stream };+ })+ /* ignore waiting [consumer-done, catch-up-done, fall-behind-detected] */+ .with([{ type: 'waiting' }, P._], ([state, _e]) => state)+ /* catching-up -> consume | done */+ .with(+ [{ type: 'catching-up' }, { event: 'catch-up-done' }],+ ([state, _]) => {+ if (state.stream.source.isDone()) {+ state.consumer.cleanup();+ state.stream.controller.setDone();+ return { type: 'done', stream: state.stream };+ } else {+ const consumed = state.consumer.cleanup();+ const consumer = createSmoothConsumer(state.stream, consumed);+ return { type: 'consuming', stream: state.stream, consumer };+ }+ }+ )+ /* consuming -> catching-up */+ .with(+ [{ type: 'consuming' }, { event: 'fall-behind-detected' }],+ ([state, _e]) => {+ const consumed = state.consumer.cleanup();+ const consumer = createCatchUpConsumer(state.stream, consumed);+ return { type: 'catching-up', stream: state.stream, consumer };+ }+ )+ /* consuming -> waiting | done */+ .with(+ [{ type: 'consuming' }, { event: 'consumer-done' }],+ ([state, _e]) => {+ if (state.stream.source.isDone()) {+ state.consumer.cleanup();+ state.stream.controller.setDone();+ return { type: 'done', stream: state.stream };+ } else {+ const consumed = state.consumer.cleanup();+ return { type: 'waiting', stream: state.stream, consumed };+ }+ }+ )+ .narrow()+ .with([{ type: 'consuming' }, P._], ([state, _e]) => state)+ .exhaustive()+ );+}++/**+ * FIFO event bus with a synchronous, reentrancy-guarded drain. A dispatch made+ * while a drain is already running (e.g. a consumer emitting from inside+ * `transition`) is enqueued and processed only after the current handler+ * returns, so nested events always observe the already-updated state. Unlike a+ * single Solid signal used as an event slot, events are never coalesced or lost.+ */+function createEventQueue<E>(handler: (event: E) => void) {+ const queue: E[] = [];+ let draining = false;++ return function dispatch(event: E) {+ queue.push(event);+ if (draining) return;+ draining = true;+ try {+ while (queue.length > 0) {+ handler(queue.shift()!);+ }+ } finally {+ draining = false;+ }+ };+}++/**+ * Wraps a raw chat stream in a smoothing buffer. Rather than dumping tokens as+ * they arrive, it replays them character-by-character at a steady cadence for a+ * typewriter feel, while still snapping forward to the live position whenever it+ * falls too far behind (e.g. on reconnect). The returned stream emits the same+ * content in the same order as the source — only the chunking and timing differ.+ *+ * Solid is used purely to observe the source (`data`/`isDone`); all sequencing+ * runs through the FIFO event queue feeding the `transition` state machine.+ */+export function bufferedStream(source: ChatMessageStream): ChatMessageStream {+ const controller = createStreamController<'chat'>(source.id);++ let state: BufferState;+ const dispatch = createEventQueue<BufferEvent>((event) => {+ state = transition(state, event);+ });++ const stream: BufferedStream = { source, controller, dispatch };+ state = { type: 'waiting', stream };++ /* Solid only bridges the reactive inputs into the queue */++ /* source stream new data */+ createEffect(+ on(source.data, (data) => {+ stream.dispatch({ event: 'source-data', data });+ })+ );++ /* source stream finished */+ createEffect(+ on(source.isDone, (isDone) => {+ if (!isDone) return;+ stream.dispatch({ event: 'source-done' });+ })+ );++ return controller.stream;+}diff --git a/js/app/packages/core/component/AI/util/stream/index.ts b/js/app/packages/core/component/AI/util/stream/index.tsindex eb77d7e2a1..ec0ed45960 100644--- a/js/app/packages/core/component/AI/util/stream/index.ts+++ b/js/app/packages/core/component/AI/util/stream/index.ts@@ -1,3 +1,4 @@+export * from './bufferedStream';export * from './mockStream';export * from './networkProfile';export * from './pausableStream';diff --git a/js/app/packages/service-clients/service-cognition/generated/schemas/chatStream.ts b/js/app/packages/service-clients/service-cognition/generated/schemas/chatStream.tsindex deb8267344..4f40170419 100644--- a/js/app/packages/service-clients/service-cognition/generated/schemas/chatStream.ts+++ b/js/app/packages/service-clients/service-cognition/generated/schemas/chatStream.ts@@ -7,30 +7,10 @@import type { ChatStreamOneOf } from './chatStreamOneOf';import type { ChatStreamOneOfEight } from './chatStreamOneOfEight';import type { ChatStreamOneOfFour } from './chatStreamOneOfFour';-import type { ChatStreamOneOfOnefour } from './chatStreamOneOfOnefour';-import type { ChatStreamOneOfOnenine } from './chatStreamOneOfOnenine';-import type { ChatStreamOneOfOneseven } from './chatStreamOneOfOneseven';-import type { ChatStreamOneOfOnetwo } from './chatStreamOneOfOnetwo';-import type { ChatStreamOneOfOnezero } from './chatStreamOneOfOnezero';import type { ChatStreamOneOfSix } from './chatStreamOneOfSix';-import type { ChatStreamOneOfTwofive } from './chatStreamOneOfTwofive';-import type { ChatStreamOneOfTwonine } from './chatStreamOneOfTwonine';-import type { ChatStreamOneOfTwoone } from './chatStreamOneOfTwoone';-import type { ChatStreamOneOfTwoseven } from './chatStreamOneOfTwoseven';-import type { ChatStreamOneOfTwothree } from './chatStreamOneOfTwothree';export type ChatStream =| ChatStreamOneOf| ChatStreamOneOfFour| ChatStreamOneOfSix- | ChatStreamOneOfEight- | ChatStreamOneOfOnezero- | ChatStreamOneOfOnetwo- | ChatStreamOneOfOnefour- | ChatStreamOneOfOneseven- | ChatStreamOneOfOnenine- | ChatStreamOneOfTwoone- | ChatStreamOneOfTwothree- | ChatStreamOneOfTwofive- | ChatStreamOneOfTwoseven- | ChatStreamOneOfTwonine;+ | ChatStreamOneOfEight;diff --git a/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfEight.ts b/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfEight.tsindex b8d778d50b..32491346ef 100644--- a/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfEight.ts+++ b/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfEight.ts@@ -4,16 +4,9 @@* Document Cognition Service* OpenAPI spec version: 1.0.0*/-import type { AssistantMessagePart } from './assistantMessagePart';import type { ChatStreamOneOfEightType } from './chatStreamOneOfEightType';-/**- * Indicates a response from the chat completion API for a given message- */export type ChatStreamOneOfEight = {- chat_id: string;- content: AssistantMessagePart;- message_id: string;stream_id: string;type: ChatStreamOneOfEightType;};diff --git a/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfEightType.ts b/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfEightType.tsindex 491c383ed8..32ce5f7fb5 100644--- a/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfEightType.ts+++ b/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfEightType.ts@@ -10,5 +10,5 @@ export type ChatStreamOneOfEightType =// eslint-disable-next-line @typescript-eslint/no-redeclareexport const ChatStreamOneOfEightType = {- chat_message_response: 'chat_message_response',+ stream_end: 'stream_end',} as const;diff --git a/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfFour.ts b/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfFour.tsindex 4b27390428..d193508a62 100644--- a/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfFour.ts+++ b/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfFour.ts@@ -4,13 +4,19 @@* Document Cognition Service* OpenAPI spec version: 1.0.0*/+import type { ChatStreamOneOfFourType } from './chatStreamOneOfFourType';+import type { Entity } from './entity';/**- * Acknowledges that a message has been received for processing+ * The user message that initiated this stream, sent as the first item+so other clients can add it to their local chat state.*/export type ChatStreamOneOfFour = {+ attachments: Entity[];chat_id: string;+ content: string;message_id: string;+ stream_id: string;type: ChatStreamOneOfFourType;};diff --git a/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfFourType.ts b/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfFourType.tsindex 336af9ac25..4669d8d5bd 100644--- a/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfFourType.ts+++ b/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfFourType.ts@@ -10,5 +10,5 @@ export type ChatStreamOneOfFourType =// eslint-disable-next-line @typescript-eslint/no-redeclareexport const ChatStreamOneOfFourType = {- chat_message_ack: 'chat_message_ack',+ chat_user_message: 'chat_user_message',} as const;diff --git a/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfOnefour.ts b/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfOnefour.tsdeleted file mode 100644index 105c5e7138..0000000000--- a/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfOnefour.ts+++ /dev/null@@ -1,19 +0,0 @@-/**- * Generated by orval v7.21.0 🍺- * Do not edit manually.- * Document Cognition Service- * OpenAPI spec version: 1.0.0- */-import type { AgentModel } from './agentModel';-import type { ChatStreamOneOfOnefourNewModel } from './chatStreamOneOfOnefourNewModel';-import type { ChatStreamOneOfOnefourType } from './chatStreamOneOfOnefourType';--/**- * Notifies the client that the available models have changed- */-export type ChatStreamOneOfOnefour = {- available_models: AgentModel[];- chat_id: string;- new_model?: ChatStreamOneOfOnefourNewModel;- type: ChatStreamOneOfOnefourType;-};diff --git a/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfOnefourNewModel.ts b/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfOnefourNewModel.tsdeleted file mode 100644index 062d47029d..0000000000--- a/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfOnefourNewModel.ts+++ /dev/null@@ -1,9 +0,0 @@-/**- * Generated by orval v7.21.0 🍺- * Do not edit manually.- * Document Cognition Service- * OpenAPI spec version: 1.0.0- */-import type { AgentModel } from './agentModel';--export type ChatStreamOneOfOnefourNewModel = null | AgentModel;diff --git a/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfOnefourType.ts b/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfOnefourType.tsdeleted file mode 100644index 7bf45e6f14..0000000000--- a/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfOnefourType.ts+++ /dev/null@@ -1,14 +0,0 @@-/**- * Generated by orval v7.21.0 🍺- * Do not edit manually.- * Document Cognition Service- * OpenAPI spec version: 1.0.0- */--export type ChatStreamOneOfOnefourType =- (typeof ChatStreamOneOfOnefourType)[keyof typeof ChatStreamOneOfOnefourType];--// eslint-disable-next-line @typescript-eslint/no-redeclare-export const ChatStreamOneOfOnefourType = {- model_selection_changed: 'model_selection_changed',-} as const;diff --git a/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfOnenine.ts b/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfOnenine.tsdeleted file mode 100644index 6e7ce1041e..0000000000--- a/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfOnenine.ts+++ /dev/null@@ -1,17 +0,0 @@-/**- * Generated by orval v7.21.0 🍺- * Do not edit manually.- * Document Cognition Service- * OpenAPI spec version: 1.0.0- */-import type { ChatStreamOneOfOnenineType } from './chatStreamOneOfOnenineType';--/**- * Status update- */-export type ChatStreamOneOfOnenine = {- chat_id: string;- message: string;- message_id: string;- type: ChatStreamOneOfOnenineType;-};diff --git a/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfOnenineType.ts b/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfOnenineType.tsdeleted file mode 100644index 1f7d0be337..0000000000--- a/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfOnenineType.ts+++ /dev/null@@ -1,14 +0,0 @@-/**- * Generated by orval v7.21.0 🍺- * Do not edit manually.- * Document Cognition Service- * OpenAPI spec version: 1.0.0- */--export type ChatStreamOneOfOnenineType =- (typeof ChatStreamOneOfOnenineType)[keyof typeof ChatStreamOneOfOnenineType];--// eslint-disable-next-line @typescript-eslint/no-redeclare-export const ChatStreamOneOfOnenineType = {- chat_message_status_update: 'chat_message_status_update',-} as const;diff --git a/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfOneseven.ts b/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfOneseven.tsdeleted file mode 100644index 152181216a..0000000000--- a/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfOneseven.ts+++ /dev/null@@ -1,13 +0,0 @@-/**- * Generated by orval v7.21.0 🍺- * Do not edit manually.- * Document Cognition Service- * OpenAPI spec version: 1.0.0- */-import type { ChatStreamOneOfOnesevenType } from './chatStreamOneOfOnesevenType';--export type ChatStreamOneOfOneseven = {- chat_id: string;- token_count: number;- type: ChatStreamOneOfOnesevenType;-};diff --git a/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfOnesevenType.ts b/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfOnesevenType.tsdeleted file mode 100644index abe5140d0b..0000000000--- a/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfOnesevenType.ts+++ /dev/null@@ -1,14 +0,0 @@-/**- * Generated by orval v7.21.0 🍺- * Do not edit manually.- * Document Cognition Service- * OpenAPI spec version: 1.0.0- */--export type ChatStreamOneOfOnesevenType =- (typeof ChatStreamOneOfOnesevenType)[keyof typeof ChatStreamOneOfOnesevenType];--// eslint-disable-next-line @typescript-eslint/no-redeclare-export const ChatStreamOneOfOnesevenType = {- token_count_changed: 'token_count_changed',-} as const;diff --git a/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfOnetwo.ts b/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfOnetwo.tsdeleted file mode 100644index c5629b98a8..0000000000--- a/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfOnetwo.ts+++ /dev/null@@ -1,17 +0,0 @@-/**- * Generated by orval v7.21.0 🍺- * Do not edit manually.- * Document Cognition Service- * OpenAPI spec version: 1.0.0- */-import type { ChatStreamOneOfOnetwoType } from './chatStreamOneOfOnetwoType';--/**- * Indicates that a chat has been renamed- */-export type ChatStreamOneOfOnetwo = {- chat_id: string;- name: string;- stream_id: string;- type: ChatStreamOneOfOnetwoType;-};diff --git a/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfOnetwoType.ts b/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfOnetwoType.tsdeleted file mode 100644index 2fde685761..0000000000--- a/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfOnetwoType.ts+++ /dev/null@@ -1,14 +0,0 @@-/**- * Generated by orval v7.21.0 🍺- * Do not edit manually.- * Document Cognition Service- * OpenAPI spec version: 1.0.0- */--export type ChatStreamOneOfOnetwoType =- (typeof ChatStreamOneOfOnetwoType)[keyof typeof ChatStreamOneOfOnetwoType];--// eslint-disable-next-line @typescript-eslint/no-redeclare-export const ChatStreamOneOfOnetwoType = {- chat_renamed: 'chat_renamed',-} as const;diff --git a/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfOnezero.ts b/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfOnezero.tsdeleted file mode 100644index 21d9a8e114..0000000000--- a/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfOnezero.ts+++ /dev/null@@ -1,17 +0,0 @@-/**- * Generated by orval v7.21.0 🍺- * Do not edit manually.- * Document Cognition Service- * OpenAPI spec version: 1.0.0- */-import type { ChatStreamOneOfOnezeroType } from './chatStreamOneOfOnezeroType';--/**- * Indicates that a message has been finished- */-export type ChatStreamOneOfOnezero = {- chat_id: string;- message_id: string;- type: ChatStreamOneOfOnezeroType;- user_message_id: string;-};diff --git a/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfOnezeroType.ts b/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfOnezeroType.tsdeleted file mode 100644index d4b188cec4..0000000000--- a/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfOnezeroType.ts+++ /dev/null@@ -1,14 +0,0 @@-/**- * Generated by orval v7.21.0 🍺- * Do not edit manually.- * Document Cognition Service- * OpenAPI spec version: 1.0.0- */--export type ChatStreamOneOfOnezeroType =- (typeof ChatStreamOneOfOnezeroType)[keyof typeof ChatStreamOneOfOnezeroType];--// eslint-disable-next-line @typescript-eslint/no-redeclare-export const ChatStreamOneOfOnezeroType = {- chat_message_finished: 'chat_message_finished',-} as const;diff --git a/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfSix.ts b/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfSix.tsindex 493ec3e56a..4fd75c7281 100644--- a/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfSix.ts+++ b/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfSix.ts@@ -4,18 +4,15 @@* Document Cognition Service* OpenAPI spec version: 1.0.0*/-+import type { AssistantMessagePart } from './assistantMessagePart';import type { ChatStreamOneOfSixType } from './chatStreamOneOfSixType';-import type { Entity } from './entity';/**- * The user message that initiated this stream, sent as the first item-so other clients can add it to their local chat state.+ * Indicates a response from the chat completion API for a given message*/export type ChatStreamOneOfSix = {- attachments: Entity[];chat_id: string;- content: string;+ content: AssistantMessagePart;message_id: string;stream_id: string;type: ChatStreamOneOfSixType;diff --git a/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfSixType.ts b/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfSixType.tsindex db698101f8..50f5cfc311 100644--- a/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfSixType.ts+++ b/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfSixType.ts@@ -10,5 +10,5 @@ export type ChatStreamOneOfSixType =// eslint-disable-next-line @typescript-eslint/no-redeclareexport const ChatStreamOneOfSixType = {- chat_user_message: 'chat_user_message',+ chat_message_response: 'chat_message_response',} as const;diff --git a/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfTwofive.ts b/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfTwofive.tsdeleted file mode 100644index 68591fa329..0000000000--- a/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfTwofive.ts+++ /dev/null@@ -1,17 +0,0 @@-/**- * Generated by orval v7.21.0 🍺- * Do not edit manually.- * Document Cognition Service- * OpenAPI spec version: 1.0.0- */-import type { ChatStreamOneOfTwofiveType } from './chatStreamOneOfTwofiveType';--/**- * pdf completion- */-export type ChatStreamOneOfTwofive = {- completion_id: string;- content: string;- done: boolean;- type: ChatStreamOneOfTwofiveType;-};diff --git a/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfTwofiveType.ts b/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfTwofiveType.tsdeleted file mode 100644index a83290dc5d..0000000000--- a/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfTwofiveType.ts+++ /dev/null@@ -1,14 +0,0 @@-/**- * Generated by orval v7.21.0 🍺- * Do not edit manually.- * Document Cognition Service- * OpenAPI spec version: 1.0.0- */--export type ChatStreamOneOfTwofiveType =- (typeof ChatStreamOneOfTwofiveType)[keyof typeof ChatStreamOneOfTwofiveType];--// eslint-disable-next-line @typescript-eslint/no-redeclare-export const ChatStreamOneOfTwofiveType = {- completion_response: 'completion_response',-} as const;diff --git a/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfTwonine.ts b/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfTwonine.tsdeleted file mode 100644index b62247248d..0000000000--- a/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfTwonine.ts+++ /dev/null@@ -1,12 +0,0 @@-/**- * Generated by orval v7.21.0 🍺- * Do not edit manually.- * Document Cognition Service- * OpenAPI spec version: 1.0.0- */-import type { ChatStreamOneOfTwonineType } from './chatStreamOneOfTwonineType';--export type ChatStreamOneOfTwonine = {- stream_id: string;- type: ChatStreamOneOfTwonineType;-};diff --git a/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfTwonineType.ts b/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfTwonineType.tsdeleted file mode 100644index 55ce2f59b5..0000000000--- a/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfTwonineType.ts+++ /dev/null@@ -1,14 +0,0 @@-/**- * Generated by orval v7.21.0 🍺- * Do not edit manually.- * Document Cognition Service- * OpenAPI spec version: 1.0.0- */--export type ChatStreamOneOfTwonineType =- (typeof ChatStreamOneOfTwonineType)[keyof typeof ChatStreamOneOfTwonineType];--// eslint-disable-next-line @typescript-eslint/no-redeclare-export const ChatStreamOneOfTwonineType = {- stream_end: 'stream_end',-} as const;diff --git a/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfTwoone.ts b/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfTwoone.tsdeleted file mode 100644index 0788de3254..0000000000--- a/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfTwoone.ts+++ /dev/null@@ -1,21 +0,0 @@-/**- * Generated by orval v7.21.0 🍺- * Do not edit manually.- * Document Cognition Service- * OpenAPI spec version: 1.0.0- */--import type { ChatStreamOneOfTwooneType } from './chatStreamOneOfTwooneType';-import type { ExtractionStatusEnum } from './extractionStatusEnum';--/**- * Acknowledges the request to get extraction status-if the `status` field is 'incomplete', we need to await the extraction status updates-if the `status` field is 'empty', extraction is complete but text content is empty-if the `status` field is 'complete', the extraction is already complete- */-export type ChatStreamOneOfTwoone = {- attachment_id: string;- status: ExtractionStatusEnum;- type: ChatStreamOneOfTwooneType;-};diff --git a/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfTwooneType.ts b/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfTwooneType.tsdeleted file mode 100644index ef2b78f25f..0000000000--- a/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfTwooneType.ts+++ /dev/null@@ -1,14 +0,0 @@-/**- * Generated by orval v7.21.0 🍺- * Do not edit manually.- * Document Cognition Service- * OpenAPI spec version: 1.0.0- */--export type ChatStreamOneOfTwooneType =- (typeof ChatStreamOneOfTwooneType)[keyof typeof ChatStreamOneOfTwooneType];--// eslint-disable-next-line @typescript-eslint/no-redeclare-export const ChatStreamOneOfTwooneType = {- extraction_status_ack: 'extraction_status_ack',-} as const;diff --git a/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfTwoseven.ts b/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfTwoseven.tsdeleted file mode 100644index 277373953d..0000000000--- a/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfTwoseven.ts+++ /dev/null@@ -1,14 +0,0 @@-/**- * Generated by orval v7.21.0 🍺- * Do not edit manually.- * Document Cognition Service- * OpenAPI spec version: 1.0.0- */-import type { ChatStreamOneOfTwosevenType } from './chatStreamOneOfTwosevenType';--export type ChatStreamOneOfTwoseven = {- completion_id: string;- content: string;- done: boolean;- type: ChatStreamOneOfTwosevenType;-};diff --git a/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfTwosevenType.ts b/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfTwosevenType.tsdeleted file mode 100644index fb596bf9b9..0000000000--- a/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfTwosevenType.ts+++ /dev/null@@ -1,14 +0,0 @@-/**- * Generated by orval v7.21.0 🍺- * Do not edit manually.- * Document Cognition Service- * OpenAPI spec version: 1.0.0- */--export type ChatStreamOneOfTwosevenType =- (typeof ChatStreamOneOfTwosevenType)[keyof typeof ChatStreamOneOfTwosevenType];--// eslint-disable-next-line @typescript-eslint/no-redeclare-export const ChatStreamOneOfTwosevenType = {- completion_stream_chunk: 'completion_stream_chunk',-} as const;diff --git a/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfTwothree.ts b/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfTwothree.tsdeleted file mode 100644index c3ad5cd897..0000000000--- a/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfTwothree.ts+++ /dev/null@@ -1,18 +0,0 @@-/**- * Generated by orval v7.21.0 🍺- * Do not edit manually.- * Document Cognition Service- * OpenAPI spec version: 1.0.0- */--import type { ChatStreamOneOfTwothreeType } from './chatStreamOneOfTwothreeType';-import type { ExtractionStatusEnum } from './extractionStatusEnum';--/**- * Status update for the extraction status- */-export type ChatStreamOneOfTwothree = {- attachment_id: string;- status: ExtractionStatusEnum;- type: ChatStreamOneOfTwothreeType;-};diff --git a/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfTwothreeType.ts b/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfTwothreeType.tsdeleted file mode 100644index 061064a753..0000000000--- a/js/app/packages/service-clients/service-cognition/generated/schemas/chatStreamOneOfTwothreeType.ts+++ /dev/null@@ -1,14 +0,0 @@-/**- * Generated by orval v7.21.0 🍺- * Do not edit manually.- * Document Cognition Service- * OpenAPI spec version: 1.0.0- */--export type ChatStreamOneOfTwothreeType =- (typeof ChatStreamOneOfTwothreeType)[keyof typeof ChatStreamOneOfTwothreeType];--// eslint-disable-next-line @typescript-eslint/no-redeclare-export const ChatStreamOneOfTwothreeType = {- extraction_status_update: 'extraction_status_update',-} as const;diff --git a/js/app/packages/service-clients/service-cognition/generated/schemas/extractionStatusEnum.ts b/js/app/packages/service-clients/service-cognition/generated/schemas/extractionStatusEnum.tsdeleted file mode 100644index 9662c9d52a..0000000000--- a/js/app/packages/service-clients/service-cognition/generated/schemas/extractionStatusEnum.ts+++ /dev/null@@ -1,16 +0,0 @@-/**- * Generated by orval v7.21.0 🍺- * Do not edit manually.- * Document Cognition Service- * OpenAPI spec version: 1.0.0- */-import type { ExtractionStatusEnumOneOf } from './extractionStatusEnumOneOf';-import type { ExtractionStatusEnumOneOfFive } from './extractionStatusEnumOneOfFive';-import type { ExtractionStatusEnumOneOfSeven } from './extractionStatusEnumOneOfSeven';-import type { ExtractionStatusEnumOneOfThree } from './extractionStatusEnumOneOfThree';--export type ExtractionStatusEnum =- | ExtractionStatusEnumOneOf- | ExtractionStatusEnumOneOfThree- | ExtractionStatusEnumOneOfFive- | ExtractionStatusEnumOneOfSeven;diff --git a/js/app/packages/service-clients/service-cognition/generated/schemas/extractionStatusEnumOneOf.ts b/js/app/packages/service-clients/service-cognition/generated/schemas/extractionStatusEnumOneOf.tsdeleted file mode 100644index 4980daa01d..0000000000--- a/js/app/packages/service-clients/service-cognition/generated/schemas/extractionStatusEnumOneOf.ts+++ /dev/null@@ -1,11 +0,0 @@-/**- * Generated by orval v7.21.0 🍺- * Do not edit manually.- * Document Cognition Service- * OpenAPI spec version: 1.0.0- */-import type { ExtractionStatusEnumOneOfType } from './extractionStatusEnumOneOfType';--export type ExtractionStatusEnumOneOf = {- type: ExtractionStatusEnumOneOfType;-};diff --git a/js/app/packages/service-clients/service-cognition/generated/schemas/extractionStatusEnumOneOfFive.ts b/js/app/packages/service-clients/service-cognition/generated/schemas/extractionStatusEnumOneOfFive.tsdeleted file mode 100644index 9462695af5..0000000000--- a/js/app/packages/service-clients/service-cognition/generated/schemas/extractionStatusEnumOneOfFive.ts+++ /dev/null@@ -1,11 +0,0 @@-/**- * Generated by orval v7.21.0 🍺- * Do not edit manually.- * Document Cognition Service- * OpenAPI spec version: 1.0.0- */-import type { ExtractionStatusEnumOneOfFiveType } from './extractionStatusEnumOneOfFiveType';--export type ExtractionStatusEnumOneOfFive = {- type: ExtractionStatusEnumOneOfFiveType;-};diff --git a/js/app/packages/service-clients/service-cognition/generated/schemas/extractionStatusEnumOneOfFiveType.ts b/js/app/packages/service-clients/service-cognition/generated/schemas/extractionStatusEnumOneOfFiveType.tsdeleted file mode 100644index 7d06eea685..0000000000--- a/js/app/packages/service-clients/service-cognition/generated/schemas/extractionStatusEnumOneOfFiveType.ts+++ /dev/null@@ -1,14 +0,0 @@-/**- * Generated by orval v7.21.0 🍺- * Do not edit manually.- * Document Cognition Service- * OpenAPI spec version: 1.0.0- */--export type ExtractionStatusEnumOneOfFiveType =- (typeof ExtractionStatusEnumOneOfFiveType)[keyof typeof ExtractionStatusEnumOneOfFiveType];--// eslint-disable-next-line @typescript-eslint/no-redeclare-export const ExtractionStatusEnumOneOfFiveType = {- insufficient: 'insufficient',-} as const;diff --git a/js/app/packages/service-clients/service-cognition/generated/schemas/extractionStatusEnumOneOfSeven.ts b/js/app/packages/service-clients/service-cognition/generated/schemas/extractionStatusEnumOneOfSeven.tsdeleted file mode 100644index 9ca2f5d07a..0000000000--- a/js/app/packages/service-clients/service-cognition/generated/schemas/extractionStatusEnumOneOfSeven.ts+++ /dev/null@@ -1,11 +0,0 @@-/**- * Generated by orval v7.21.0 🍺- * Do not edit manually.- * Document Cognition Service- * OpenAPI spec version: 1.0.0- */-import type { ExtractionStatusEnumOneOfSevenType } from './extractionStatusEnumOneOfSevenType';--export type ExtractionStatusEnumOneOfSeven = {- type: ExtractionStatusEnumOneOfSevenType;-};diff --git a/js/app/packages/service-clients/service-cognition/generated/schemas/extractionStatusEnumOneOfSevenType.ts b/js/app/packages/service-clients/service-cognition/generated/schemas/extractionStatusEnumOneOfSevenType.tsdeleted file mode 100644index 5265ac6db0..0000000000--- a/js/app/packages/service-clients/service-cognition/generated/schemas/extractionStatusEnumOneOfSevenType.ts+++ /dev/null@@ -1,14 +0,0 @@-/**- * Generated by orval v7.21.0 🍺- * Do not edit manually.- * Document Cognition Service- * OpenAPI spec version: 1.0.0- */--export type ExtractionStatusEnumOneOfSevenType =- (typeof ExtractionStatusEnumOneOfSevenType)[keyof typeof ExtractionStatusEnumOneOfSevenType];--// eslint-disable-next-line @typescript-eslint/no-redeclare-export const ExtractionStatusEnumOneOfSevenType = {- complete: 'complete',-} as const;diff --git a/js/app/packages/service-clients/service-cognition/generated/schemas/extractionStatusEnumOneOfThree.ts b/js/app/packages/service-clients/service-cognition/generated/schemas/extractionStatusEnumOneOfThree.tsdeleted file mode 100644index b3a17106b1..0000000000--- a/js/app/packages/service-clients/service-cognition/generated/schemas/extractionStatusEnumOneOfThree.ts+++ /dev/null@@ -1,11 +0,0 @@-/**- * Generated by orval v7.21.0 🍺- * Do not edit manually.- * Document Cognition Service- * OpenAPI spec version: 1.0.0- */-import type { ExtractionStatusEnumOneOfThreeType } from './extractionStatusEnumOneOfThreeType';--export type ExtractionStatusEnumOneOfThree = {- type: ExtractionStatusEnumOneOfThreeType;-};diff --git a/js/app/packages/service-clients/service-cognition/generated/schemas/extractionStatusEnumOneOfThreeType.ts b/js/app/packages/service-clients/service-cognition/generated/schemas/extractionStatusEnumOneOfThreeType.tsdeleted file mode 100644index fac488349d..0000000000--- a/js/app/packages/service-clients/service-cognition/generated/schemas/extractionStatusEnumOneOfThreeType.ts+++ /dev/null@@ -1,14 +0,0 @@-/**- * Generated by orval v7.21.0 🍺- * Do not edit manually.- * Document Cognition Service- * OpenAPI spec version: 1.0.0- */--export type ExtractionStatusEnumOneOfThreeType =- (typeof ExtractionStatusEnumOneOfThreeType)[keyof typeof ExtractionStatusEnumOneOfThreeType];--// eslint-disable-next-line @typescript-eslint/no-redeclare-export const ExtractionStatusEnumOneOfThreeType = {- empty: 'empty',-} as const;diff --git a/js/app/packages/service-clients/service-cognition/generated/schemas/extractionStatusEnumOneOfType.ts b/js/app/packages/service-clients/service-cognition/generated/schemas/extractionStatusEnumOneOfType.tsdeleted file mode 100644index 76521e5970..0000000000--- a/js/app/packages/service-clients/service-cognition/generated/schemas/extractionStatusEnumOneOfType.ts+++ /dev/null@@ -1,14 +0,0 @@-/**- * Generated by orval v7.21.0 🍺- * Do not edit manually.- * Document Cognition Service- * OpenAPI spec version: 1.0.0- */--export type ExtractionStatusEnumOneOfType =- (typeof ExtractionStatusEnumOneOfType)[keyof typeof ExtractionStatusEnumOneOfType];--// eslint-disable-next-line @typescript-eslint/no-redeclare-export const ExtractionStatusEnumOneOfType = {- incomplete: 'incomplete',-} as const;diff --git a/js/app/packages/service-clients/service-cognition/generated/schemas/index.ts b/js/app/packages/service-clients/service-cognition/generated/schemas/index.tsindex 1aeb728399..d058d3e6c1 100644--- a/js/app/packages/service-clients/service-cognition/generated/schemas/index.ts+++ b/js/app/packages/service-clients/service-cognition/generated/schemas/index.ts@@ -79,29 +79,8 @@ export * from './chatStreamOneOfEight';export * from './chatStreamOneOfEightType';export * from './chatStreamOneOfFour';export * from './chatStreamOneOfFourType';-export * from './chatStreamOneOfOnefour';-export * from './chatStreamOneOfOnefourNewModel';-export * from './chatStreamOneOfOnefourType';-export * from './chatStreamOneOfOnenine';-export * from './chatStreamOneOfOnenineType';-export * from './chatStreamOneOfOneseven';-export * from './chatStreamOneOfOnesevenType';-export * from './chatStreamOneOfOnetwo';-export * from './chatStreamOneOfOnetwoType';-export * from './chatStreamOneOfOnezero';-export * from './chatStreamOneOfOnezeroType';export * from './chatStreamOneOfSix';export * from './chatStreamOneOfSixType';-export * from './chatStreamOneOfTwofive';-export * from './chatStreamOneOfTwofiveType';-export * from './chatStreamOneOfTwonine';-export * from './chatStreamOneOfTwonineType';-export * from './chatStreamOneOfTwoone';-export * from './chatStreamOneOfTwooneType';-export * from './chatStreamOneOfTwoseven';-export * from './chatStreamOneOfTwosevenType';-export * from './chatStreamOneOfTwothree';-export * from './chatStreamOneOfTwothreeType';export * from './chatTokenCount';export * from './chatUpdatedAt';export * from './conversationRecord';@@ -120,15 +99,6 @@ export * from './dynamicSchemaDescription';export * from './entity';export * from './entityType';export * from './errorResponse';-export * from './extractionStatusEnum';-export * from './extractionStatusEnumOneOf';-export * from './extractionStatusEnumOneOfFive';-export * from './extractionStatusEnumOneOfFiveType';-export * from './extractionStatusEnumOneOfSeven';-export * from './extractionStatusEnumOneOfSevenType';-export * from './extractionStatusEnumOneOfThree';-export * from './extractionStatusEnumOneOfThreeType';-export * from './extractionStatusEnumOneOfType';export * from './fileType';export * from './genericErrorResponse';export * from './getBatchPreviewRequest';diff --git a/js/app/packages/service-clients/service-cognition/openapi.json b/js/app/packages/service-clients/service-cognition/openapi.jsonindex 3e09ab219d..e514f792a8 100644--- a/js/app/packages/service-clients/service-cognition/openapi.json+++ b/js/app/packages/service-clients/service-cognition/openapi.json@@ -2001,23 +2001,6 @@],"description": "Misc error"},- {- "type": "object",- "description": "Acknowledges that a message has been received for processing",- "required": ["message_id", "chat_id", "type"],- "properties": {- "chat_id": {- "type": "string"- },- "message_id": {- "type": "string"- },- "type": {- "type": "string",- "enum": ["chat_message_ack"]- }- }- },{"type": "object","description": "The user message that initiated this stream, sent as the first item\nso other clients can add it to their local chat state.",@@ -2083,186 +2066,6 @@}}},- {- "type": "object",- "description": "Indicates that a message has been finished",- "required": ["message_id", "chat_id", "user_message_id", "type"],- "properties": {- "chat_id": {- "type": "string"- },- "message_id": {- "type": "string"- },- "type": {- "type": "string",- "enum": ["chat_message_finished"]- },- "user_message_id": {- "type": "string"- }- }- },- {- "type": "object",- "description": "Indicates that a chat has been renamed",- "required": ["stream_id", "chat_id", "name", "type"],- "properties": {- "chat_id": {- "type": "string"- },- "name": {- "type": "string"- },- "stream_id": {- "type": "string"- },- "type": {- "type": "string",- "enum": ["chat_renamed"]- }- }- },- {- "type": "object",- "description": "Notifies the client that the available models have changed",- "required": ["chat_id", "available_models", "type"],- "properties": {- "available_models": {- "type": "array",- "items": {- "$ref": "#/components/schemas/AgentModel"- }- },- "chat_id": {- "type": "string"- },- "new_model": {- "oneOf": [- {- "type": "null"- },- {- "$ref": "#/components/schemas/AgentModel"- }- ]- },- "type": {- "type": "string",- "enum": ["model_selection_changed"]- }- }- },- {- "type": "object",- "required": ["chat_id", "token_count", "type"],- "properties": {- "chat_id": {- "type": "string"- },- "token_count": {- "type": "integer",- "format": "int64"- },- "type": {- "type": "string",- "enum": ["token_count_changed"]- }- }- },- {- "type": "object",- "description": "Status update",- "required": ["chat_id", "message_id", "message", "type"],- "properties": {- "chat_id": {- "type": "string"- },- "message": {- "type": "string"- },- "message_id": {- "type": "string"- },- "type": {- "type": "string",- "enum": ["chat_message_status_update"]- }- }- },- {- "type": "object",- "description": "Acknowledges the request to get extraction status\nif the `status` field is 'incomplete', we need to await the extraction status updates\nif the `status` field is 'empty', extraction is complete but text content is empty\nif the `status` field is 'complete', the extraction is already complete",- "required": ["attachment_id", "status", "type"],- "properties": {- "attachment_id": {- "type": "string"- },- "status": {- "$ref": "#/components/schemas/ExtractionStatusEnum"- },- "type": {- "type": "string",- "enum": ["extraction_status_ack"]- }- }- },- {- "type": "object",- "description": "Status update for the extraction status",- "required": ["attachment_id", "status", "type"],- "properties": {- "attachment_id": {- "type": "string"- },- "status": {- "$ref": "#/components/schemas/ExtractionStatusEnum"- },- "type": {- "type": "string",- "enum": ["extraction_status_update"]- }- }- },- {- "type": "object",- "description": "pdf completion",- "required": ["completion_id", "content", "done", "type"],- "properties": {- "completion_id": {- "type": "string"- },- "content": {- "type": "string"- },- "done": {- "type": "boolean"- },- "type": {- "type": "string",- "enum": ["completion_response"]- }- }- },- {- "type": "object",- "required": ["completion_id", "content", "done", "type"],- "properties": {- "completion_id": {- "type": "string"- },- "content": {- "type": "string"- },- "done": {- "type": "boolean"- },- "type": {- "type": "string",- "enum": ["completion_stream_chunk"]- }- }- },{"type": "object","required": ["stream_id", "type"],@@ -2412,50 +2215,6 @@}}},- "ExtractionStatusEnum": {- "oneOf": [- {- "type": "object",- "required": ["type"],- "properties": {- "type": {- "type": "string",- "enum": ["incomplete"]- }- }- },- {- "type": "object",- "required": ["type"],- "properties": {- "type": {- "type": "string",- "enum": ["empty"]- }- }- },- {- "type": "object",- "required": ["type"],- "properties": {- "type": {- "type": "string",- "enum": ["insufficient"]- }- }- },- {- "type": "object",- "required": ["type"],- "properties": {- "type": {- "type": "string",- "enum": ["complete"]- }- }- }- ]- },"FileType": {"type": "string","description": "Generates a FileType enum and associated ContentType enum with their implementations.\n\nThis macro takes a list of tuples in the format:\n(Variant, \"extension\", \"mime_type\", CONTENT_TYPE_VARIANT)\n\nFor each tuple it generates:\n- A variant in the FileType enum\n- A variant in the ContentType enum\n- Implementations for:\n - FileType::to_str() - Converts FileType to extension string\n - FileType::from_str() - Converts extension string to FileType\n - From<FileType> for ContentType - Maps FileType to ContentType\n - ContentType::mime_type() - Gets MIME type for ContentType\n",diff --git a/js/app/packages/service-clients/service-connection/stream.ts b/js/app/packages/service-clients/service-connection/stream.tsindex 5879101de8..cb912776b2 100644--- a/js/app/packages/service-clients/service-connection/stream.ts+++ b/js/app/packages/service-clients/service-connection/stream.ts@@ -34,26 +34,27 @@ export interface Stream<K extends keyof StreamType> {isDone: Accessor<boolean>;}-type StreamController<K extends keyof StreamType> = {+export type StreamController<K extends keyof StreamType> = {stream: Stream<K>;setData: Setter<StreamType[K][]>;setDone: () => void;- id: StreamId;+ id: Accessor<StreamId | undefined>;};-function newController<K extends keyof StreamType>(- id: StreamId+export function createStreamController<K extends keyof StreamType>(+ id: StreamId | Accessor<StreamId | undefined>): StreamController<K> {const [data, setData] = createSignal<StreamType[K][]>([]);const [isDone, setIsDone] = createSignal(false);+ const idSignal = typeof id === 'function' ? id : () => id;return {stream: {- id: () => id,+ id: idSignal,data,isDone,},- id,+ id: idSignal,setData,setDone: () => setIsDone(true),};@@ -128,7 +129,7 @@ createConnectionWebsocketEffect((message) => {// is 1st itemelse {// new stream- const newStream = newController(item.id);+ const newStream = createStreamController(item.id);// process itemif (streamIsDone(item.id.entity_type, item.payload)) {newStream.setDone();@@ -156,7 +157,7 @@ export function subscribe<K extends keyof StreamType>(}return streams[entity_id][stream_id].stream.stream as Stream<K>;} else {- const controller = newController({+ const controller = createStreamController({entity_id,entity_type,stream_id,@@ -184,3 +185,4 @@ export function getEntityStreams<K extends keyof StreamType>(}export type ChatMessageStream = Stream<'chat'>;+export type ChatStreamController = StreamController<'chat'>;diff --git a/rust/cloud-storage/document_cognition_service/src/model/stream.rs b/rust/cloud-storage/document_cognition_service/src/model/stream.rsindex 9431a5b66e..8028eb819d 100644--- a/rust/cloud-storage/document_cognition_service/src/model/stream.rs+++ b/rust/cloud-storage/document_cognition_service/src/model/stream.rs@@ -40,52 +40,12 @@ pub struct SendChatMessagePayload {pub jwt: JwtPayload,}-#[derive(Deserialize, Serialize, ToSchema, Debug, Clone, PartialEq, Copy)]-#[serde(tag = "type", rename_all = "lowercase")]-pub enum ExtractionStatusEnum {- // Extraction incomplete- Incomplete,-- // Extraction complete, but text content is empty- Empty,-- // Extraction complete, but text content is insufficient- Insufficient,-- // Extraction complete and sufficient- Complete,-}--// Akkad prospers and we cope-impl From<macro_db_client::dcs::get_document_text::ExtractionStatusEnum> for ExtractionStatusEnum {- fn from(value: macro_db_client::dcs::get_document_text::ExtractionStatusEnum) -> Self {- match value {- macro_db_client::dcs::get_document_text::ExtractionStatusEnum::Complete => {- Self::Complete- }- macro_db_client::dcs::get_document_text::ExtractionStatusEnum::Empty => Self::Empty,- macro_db_client::dcs::get_document_text::ExtractionStatusEnum::Insufficient => {- Self::Insufficient- }- macro_db_client::dcs::get_document_text::ExtractionStatusEnum::Incomplete => {- Self::Incomplete- }- }- }-}-#[derive(Serialize, Deserialize, ToSchema, Debug, Clone)]#[serde(tag = "type", rename_all = "snake_case")]pub enum ChatStream {/// Misc errorError(StreamError),- /// Acknowledges that a message has been received for processing- ChatMessageAck {- message_id: String,- chat_id: String,- },-/// The user message that initiated this stream, sent as the first item/// so other clients can add it to their local chat state.ChatUserMessage {@@ -104,67 +64,6 @@ pub enum ChatStream {content: AssistantMessagePart,},- /// Indicates that a message has been finished- ChatMessageFinished {- message_id: String,- chat_id: String,- user_message_id: String,- },-- /// Indicates that a chat has been renamed- ChatRenamed {- stream_id: String,- chat_id: String,- name: String,- },-- /// Notifies the client that the available models have changed- ModelSelectionChanged {- chat_id: String,- available_models: Vec<AgentModel>,- new_model: Option<AgentModel>,- },-- TokenCountChanged {- chat_id: String,- token_count: i64,- },-- /// Status update- ChatMessageStatusUpdate {- chat_id: String,- message_id: String,- message: String,- },-- /// Acknowledges the request to get extraction status- /// if the `status` field is 'incomplete', we need to await the extraction status updates- /// if the `status` field is 'empty', extraction is complete but text content is empty- /// if the `status` field is 'complete', the extraction is already complete- ExtractionStatusAck {- attachment_id: String,- status: ExtractionStatusEnum,- },-- /// Status update for the extraction status- ExtractionStatusUpdate {- attachment_id: String,- status: ExtractionStatusEnum,- },-- /// pdf completion- CompletionResponse {- completion_id: String,- content: String,- done: bool,- },-- CompletionStreamChunk {- completion_id: String,- content: String,- done: bool,- },-StreamEnd {stream_id: String,},