@theseam/ui-common 1.0.2-beta.84 → 1.0.2-beta.86

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.
@@ -1 +1 @@
1
- {"version":3,"file":"theseam-ui-common-ai.mjs","sources":["../../../projects/ui-common/ai/providers/lm-studio.ai-provider.ts","../../../projects/ui-common/ai/providers/openrouter.ai-provider.ts","../../../projects/ui-common/ai/providers/mock.ai-provider.ts","../../../projects/ui-common/ai/chat-context-registry.service.ts","../../../projects/ui-common/ai/contexts/datatable-chat-context.ts","../../../projects/ui-common/ai/chat/chat-provider.ts","../../../projects/ui-common/ai/chat/chat-response-parser.ts","../../../projects/ui-common/ai/chat/chat-block-registry.ts","../../../projects/ui-common/ai/chat/chat-message.component.ts","../../../projects/ui-common/ai/chat/chat-input.component.ts","../../../projects/ui-common/ai/chat/chat.component.ts","../../../projects/ui-common/ai/chat/chat.component.html","../../../projects/ui-common/ai/chat/testing/chat.harness.ts","../../../projects/ui-common/ai/datatable-prompter/datatable-prompter-prompt-provider.ts","../../../projects/ui-common/ai/datatable-prompter/datatable-prompter.component.ts","../../../projects/ui-common/ai/datatable-prompter/datatable-prompter.component.html","../../../projects/ui-common/ai/theseam-ui-common-ai.ts"],"sourcesContent":["import {\n ChatResponse,\n TheSeamAiChatRequest,\n TheSeamAiProvider,\n} from './ai-provider'\n\nexport class LmStudioAiProvider implements TheSeamAiProvider {\n async chat(request: TheSeamAiChatRequest): Promise<ChatResponse> {\n const url = 'http://localhost:1234/v1/chat/completions'\n const headers = {\n 'Content-Type': 'application/json',\n }\n const model = 'model-identifier'\n\n const response = await fetch(url, {\n method: 'POST',\n headers,\n body: JSON.stringify({\n model,\n messages: request.messages.map((m) => ({\n role: m.role,\n content: m.content,\n })),\n }),\n })\n\n const data = await response.json()\n const content = data.choices[0].message.content\n return { content }\n }\n}\n","import {\n ChatResponse,\n TheSeamAiChatRequest,\n TheSeamAiProvider,\n} from './ai-provider'\n\nexport class OpenRouterAiProvider implements TheSeamAiProvider {\n async chat(request: TheSeamAiChatRequest): Promise<ChatResponse> {\n const defaultApiKey =\n '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'\n\n const url = 'https://openrouter.ai/api/v1/chat/completions'\n const apiKey = localStorage.getItem('openrouter-api-key') || defaultApiKey\n const headers = {\n Authorization: `Bearer ${apiKey}`,\n 'Content-Type': 'application/json',\n }\n const model = 'google/gemini-2.5-flash'\n\n const response = await fetch(url, {\n method: 'POST',\n headers,\n body: JSON.stringify({\n model,\n messages: request.messages.map((m) => ({\n role: m.role,\n content: m.content,\n })),\n response_format: { type: 'json_object' },\n }),\n })\n\n const data = await response.json()\n const content = data.choices[0].message.content\n return { content }\n }\n}\n","import {\n ChatMessage,\n ChatResponse,\n TheSeamAiChatRequest,\n TheSeamAiProvider,\n} from './ai-provider'\n\ntype MockResponse = string | ((messages: ChatMessage[]) => string)\n\nexport class MockAiProvider implements TheSeamAiProvider {\n constructor(private readonly _response: MockResponse = 'Mock response') {}\n\n async chat(request: TheSeamAiChatRequest): Promise<ChatResponse> {\n const content =\n typeof this._response === 'function'\n ? this._response(request.messages)\n : this._response\n return { content }\n }\n}\n","import { Injectable } from '@angular/core'\n\nimport { TheSeamChatContext, TheSeamChatContextPayload } from './chat-context'\n\n@Injectable({ providedIn: 'root' })\nexport class TheSeamChatContextRegistry {\n private readonly _contexts = new Set<TheSeamChatContext>()\n\n /**\n * Register a context. Returns an unregister function — pair it with DestroyRef:\n * inject(DestroyRef).onDestroy(registry.register(ctx))\n */\n register(ctx: TheSeamChatContext): () => void {\n this._contexts.add(ctx)\n return () => this._contexts.delete(ctx)\n }\n\n unregister(ctx: TheSeamChatContext): void {\n this._contexts.delete(ctx)\n }\n\n /**\n * Resolve registered contexts to a wire-ready payload list. Applies the modal-mask\n * rule (a `modal`-typed context hides others unless they set `alwaysVisible`) and\n * drops entries whose `getContext()` returns null/undefined.\n */\n async snapshot(): Promise<TheSeamChatContextPayload[]> {\n const all = [...this._contexts]\n const masked = all.some((c) => c.type === 'modal')\n const visible = masked\n ? all.filter((c) => c.type === 'modal' || c.alwaysVisible)\n : all\n const resolved = await Promise.all(\n visible.map(async (c) => ({ type: c.type, data: await c.getContext() })),\n )\n return resolved.filter((p) => p.data != null)\n }\n}\n","import { OperationDefinitionNode, print } from 'graphql'\n\nimport { TheSeamDatatableColumn } from '@theseam/ui-common/datatable'\nimport {\n DatatableGraphQLQueryRef,\n processGql,\n} from '@theseam/ui-common/graphql'\n\nimport { TheSeamChatContext } from '../chat-context'\n\nexport interface TheSeamDatatableChatContextOptions {\n /** Optional human label, e.g. 'Bales'. Helps the LLM disambiguate when multiple datatables are registered. */\n label?: string\n}\n\nexport interface TheSeamDatatableChatContextData {\n label?: string\n operationName: string\n query: string\n variables: Record<string, unknown>\n columns: { prop: string | number | undefined; name: string | undefined }[]\n}\n\nexport class TheSeamDatatableChatContext implements TheSeamChatContext {\n readonly type = 'datatable'\n\n constructor(\n private readonly _queryRef: DatatableGraphQLQueryRef<any, any, any>,\n private readonly _columns: readonly TheSeamDatatableColumn[],\n private readonly _options: TheSeamDatatableChatContextOptions = {},\n ) {}\n\n getContext(): TheSeamDatatableChatContextData | null {\n const opts = this._queryRef.getOptions()\n if (!opts) return null\n\n const { query, variables } = processGql(\n opts.query,\n this._queryRef.getVariables() as Record<string, any>,\n this._queryRef.getQueryProcessingConfig() ?? { variables: {} },\n )\n\n const operationName =\n query.definitions.find(\n (d): d is OperationDefinitionNode => d.kind === 'OperationDefinition',\n )?.name?.value ?? ''\n\n return {\n label: this._options.label,\n operationName,\n query: print(query),\n variables,\n columns: this._columns.map((c) => ({ prop: c.prop, name: c.name })),\n }\n }\n}\n","import { InjectionToken } from '@angular/core'\n\nimport { TheSeamAiProvider } from '../providers/ai-provider'\n\nexport const THESEAM_CHAT_PROVIDER = new InjectionToken<TheSeamAiProvider>(\n 'TheSeamChatProvider',\n)\n","export type ChatContentSegment =\n | { type: 'markdown'; content: string }\n | { type: 'custom-block'; tag: string; content: string }\n\n/**\n * Splits a raw AI response string into an ordered array of segments.\n * Fenced code blocks with `seam-` prefixed language tags become custom-block\n * segments; everything else stays as markdown.\n */\nexport function parseChatResponse(input: string): ChatContentSegment[] {\n if (!input) {\n return []\n }\n\n const segments: ChatContentSegment[] = []\n const pattern = /^```(seam-[\\w-]+)\\n([\\s\\S]*?)^```/gm\n\n let lastIndex = 0\n let match: RegExpExecArray | null\n\n while ((match = pattern.exec(input)) !== null) {\n if (match.index > lastIndex) {\n segments.push({\n type: 'markdown',\n content: input.slice(lastIndex, match.index),\n })\n }\n\n segments.push({\n type: 'custom-block',\n tag: match[1],\n content: match[2].replace(/\\n$/, ''),\n })\n\n lastIndex = match.index + match[0].length\n }\n\n if (lastIndex < input.length) {\n segments.push({ type: 'markdown', content: input.slice(lastIndex) })\n }\n\n return segments\n}\n","import { InjectionToken, Type } from '@angular/core'\n\nexport type ChatBlockRegistry = Map<string, Type<unknown>>\n\nexport const THESEAM_CHAT_BLOCK_REGISTRY =\n new InjectionToken<ChatBlockRegistry>('TheSeamChatBlockRegistry')\n","import {\n ChangeDetectionStrategy,\n Component,\n inject,\n Input,\n Injector,\n} from '@angular/core'\nimport { NgComponentOutlet, NgForOf, NgIf } from '@angular/common'\nimport { MarkdownComponent } from 'ngx-markdown'\n\nimport { ChatContentSegment } from './chat-response-parser'\nimport {\n ChatBlockRegistry,\n THESEAM_CHAT_BLOCK_REGISTRY,\n} from './chat-block-registry'\n\nexport interface ChatMessageDisplayModel {\n role: 'user' | 'assistant'\n segments: ChatContentSegment[]\n timestamp: Date\n}\n\n@Component({\n selector: 'seam-chat-message',\n imports: [NgForOf, NgIf, MarkdownComponent, NgComponentOutlet],\n changeDetection: ChangeDetectionStrategy.OnPush,\n template: `\n <div\n class=\"seam-chat-message\"\n [class.seam-chat-message--user]=\"message.role === 'user'\"\n [class.seam-chat-message--assistant]=\"message.role === 'assistant'\"\n >\n <div class=\"seam-chat-message__role\">\n {{ message.role === 'user' ? 'You' : 'Assistant' }}\n </div>\n <div class=\"seam-chat-message__content\">\n <ng-container *ngFor=\"let segment of message.segments\">\n <markdown\n *ngIf=\"segment.type === 'markdown'\"\n [data]=\"segment.content\"\n ></markdown>\n <ng-container *ngIf=\"segment.type === 'custom-block'\">\n <ng-container\n *ngIf=\"\n _getBlockComponent(segment.tag) as blockComponent;\n else fallbackBlock\n \"\n >\n <ng-container\n *ngComponentOutlet=\"\n blockComponent;\n injector: _createBlockInjector(segment.content)\n \"\n ></ng-container>\n </ng-container>\n <ng-template #fallbackBlock>\n <markdown\n [data]=\"_buildFallbackMarkdown(segment.tag, segment.content)\"\n ></markdown>\n </ng-template>\n </ng-container>\n </ng-container>\n </div>\n </div>\n `,\n styles: [\n `\n .seam-chat-message {\n display: flex;\n flex-direction: column;\n padding: 8px 12px;\n margin-bottom: 8px;\n }\n\n .seam-chat-message--user {\n align-items: flex-end;\n }\n\n .seam-chat-message--user .seam-chat-message__content {\n background-color: #e8f5e9;\n border-radius: 8px;\n padding: 8px 12px;\n max-width: 80%;\n }\n\n .seam-chat-message--assistant .seam-chat-message__content {\n background-color: #f1f3f5;\n border-radius: 8px;\n padding: 8px 12px;\n max-width: 80%;\n }\n\n .seam-chat-message__role {\n font-size: 0.75rem;\n color: #6c757d;\n margin-bottom: 4px;\n }\n `,\n ],\n})\nexport class SeamChatMessageComponent {\n @Input({ required: true }) message!: ChatMessageDisplayModel\n\n private readonly _blockRegistry = inject(THESEAM_CHAT_BLOCK_REGISTRY, {\n optional: true,\n })\n private readonly _injector = inject(Injector)\n\n _getBlockComponent(tag: string) {\n return this._blockRegistry?.get(tag) ?? null\n }\n\n _createBlockInjector(content: string): Injector {\n return Injector.create({\n providers: [{ provide: 'CHAT_BLOCK_CONTENT', useValue: content }],\n parent: this._injector,\n })\n }\n\n _buildFallbackMarkdown(tag: string, content: string): string {\n return '```' + tag + '\\n' + content + '\\n```'\n }\n}\n","import {\n ChangeDetectionStrategy,\n Component,\n EventEmitter,\n Input,\n Output,\n} from '@angular/core'\nimport { FormControl, ReactiveFormsModule, Validators } from '@angular/forms'\n\nimport { TheSeamRichTextModule } from '@theseam/ui-common/rich-text'\nimport { TheSeamFormFieldModule } from '@theseam/ui-common/form-field'\nimport { TheSeamButtonsModule } from '@theseam/ui-common/buttons'\n\n@Component({\n selector: 'seam-chat-input',\n imports: [\n ReactiveFormsModule,\n TheSeamRichTextModule,\n TheSeamFormFieldModule,\n TheSeamButtonsModule,\n ],\n changeDetection: ChangeDetectionStrategy.OnPush,\n template: `\n <div class=\"seam-chat-input\">\n <seam-form-field>\n <seam-rich-text\n [formControl]=\"_control\"\n [placeholder]=\"placeholder\"\n [disableRichText]=\"true\"\n [rows]=\"2.7\"\n [resizable]=\"false\"\n (keydown.enter)=\"_onEnterKey($event)\"\n ></seam-rich-text>\n </seam-form-field>\n <button\n seamButton\n theme=\"primary\"\n class=\"seam-chat-send-btn\"\n [disabled]=\"disabled || _control.invalid\"\n (click)=\"_onSend()\"\n >\n Send\n </button>\n </div>\n `,\n styles: [\n `\n .seam-chat-input {\n display: flex;\n align-items: flex-end;\n gap: 8px;\n padding: 8px;\n border-top: 1px solid #dee2e6;\n }\n\n seam-form-field {\n flex: 1;\n }\n\n .seam-chat-send-btn {\n flex-shrink: 0;\n }\n `,\n ],\n})\nexport class SeamChatInputComponent {\n @Input() placeholder = 'Type a message...'\n @Input() disabled = false\n\n @Output() messageSent = new EventEmitter<string>()\n\n readonly _control = new FormControl<string>('', [Validators.required])\n\n _onEnterKey(event: Event) {\n const keyEvent = event as KeyboardEvent\n if (keyEvent.shiftKey) {\n return\n }\n keyEvent.preventDefault()\n this._onSend()\n }\n\n _onSend() {\n const value = this._control.value?.trim()\n if (!value || this.disabled) {\n return\n }\n this.messageSent.emit(value)\n this._control.reset()\n }\n}\n","import {\n AfterViewInit,\n ChangeDetectionStrategy,\n ChangeDetectorRef,\n Component,\n ElementRef,\n inject,\n Input,\n NgZone,\n ViewChild,\n} from '@angular/core'\nimport { AsyncPipe, NgForOf, NgIf } from '@angular/common'\nimport { BehaviorSubject } from 'rxjs'\n\nimport { TheSeamOverlayScrollbarDirective } from '@theseam/ui-common/scrollbar'\n\nimport { ChatMessage } from '../providers/ai-provider'\nimport { THESEAM_CHAT_PROVIDER } from './chat-provider'\nimport { TheSeamChatContextRegistry } from '../chat-context-registry.service'\nimport { parseChatResponse } from './chat-response-parser'\nimport {\n ChatMessageDisplayModel,\n SeamChatMessageComponent,\n} from './chat-message.component'\nimport { SeamChatInputComponent } from './chat-input.component'\n\n@Component({\n selector: 'seam-chat',\n imports: [\n AsyncPipe,\n NgForOf,\n NgIf,\n SeamChatMessageComponent,\n SeamChatInputComponent,\n TheSeamOverlayScrollbarDirective,\n ],\n templateUrl: './chat.component.html',\n styleUrls: ['./chat.component.scss'],\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class TheSeamChatComponent implements AfterViewInit {\n private readonly _provider = inject(THESEAM_CHAT_PROVIDER, { optional: true })\n private readonly _chatContextRegistry = inject(TheSeamChatContextRegistry, {\n optional: true,\n })\n private readonly _cdr = inject(ChangeDetectorRef)\n private readonly _ngZone = inject(NgZone)\n\n @Input() placeholder = 'Type a message...'\n\n @ViewChild('messageList') private _messageList?: ElementRef<HTMLElement>\n @ViewChild(TheSeamOverlayScrollbarDirective)\n private _messageListScrollbar?: TheSeamOverlayScrollbarDirective\n\n readonly _loadingSubject = new BehaviorSubject<boolean>(false)\n\n private _messages: ChatMessage[] = []\n _displayMessages: ChatMessageDisplayModel[] = []\n\n // Pixels of slack allowed when deciding if the viewport is \"at the bottom\".\n private readonly _pinnedThreshold = 32\n private _isPinnedToBottom = true\n private _forceScrollOnNextResize = false\n\n ngAfterViewInit() {\n const scrollInstance = this._messageListScrollbar?.instance\n if (!scrollInstance) {\n return\n }\n this._ngZone.runOutsideAngular(() => {\n scrollInstance.options({\n callbacks: {\n onScroll: () => this._updatePinnedState(),\n onContentSizeChanged: () => this._maybeScrollToBottom(),\n },\n })\n })\n }\n\n async _onMessageSent(text: string) {\n if (this._loadingSubject.value || !this._provider) {\n if (!this._provider) {\n console.error('No chat provider configured.')\n }\n return\n }\n\n const userMessage: ChatMessage = { role: 'user', content: text }\n this._messages.push(userMessage)\n this._displayMessages = [\n ...this._displayMessages,\n {\n role: 'user',\n segments: [{ type: 'markdown', content: text }],\n timestamp: new Date(),\n },\n ]\n this._forceScrollOnNextResize = true\n this._cdr.markForCheck()\n\n this._loadingSubject.next(true)\n try {\n const contexts = (await this._chatContextRegistry?.snapshot()) ?? []\n const response = await this._provider.chat({\n messages: this._messages,\n contexts: contexts.length === 0 ? undefined : contexts,\n })\n\n const assistantMessage: ChatMessage = {\n role: 'assistant',\n content: response.content,\n }\n this._messages.push(assistantMessage)\n this._displayMessages = [\n ...this._displayMessages,\n {\n role: 'assistant',\n segments: parseChatResponse(response.content),\n timestamp: new Date(),\n },\n ]\n } catch (err) {\n console.error('Chat provider error:', err)\n } finally {\n this._loadingSubject.next(false)\n this._cdr.markForCheck()\n }\n }\n\n private _updatePinnedState() {\n const scrollInstance = this._messageListScrollbar?.instance\n if (!scrollInstance) {\n return\n }\n const info = scrollInstance.scroll()\n this._isPinnedToBottom =\n info.position.y >= info.max.y - this._pinnedThreshold\n }\n\n private _maybeScrollToBottom() {\n if (this._forceScrollOnNextResize || this._isPinnedToBottom) {\n this._scrollToBottom()\n this._forceScrollOnNextResize = false\n }\n }\n\n private _scrollToBottom() {\n const scrollInstance = this._messageListScrollbar?.instance\n if (scrollInstance) {\n const state = scrollInstance.getState()\n scrollInstance.scroll({ y: state.contentScrollSize.height })\n }\n }\n}\n","<div class=\"seam-chat\">\n <div class=\"seam-chat__messages\" #messageList seamOverlayScrollbar>\n <seam-chat-message\n *ngFor=\"let msg of _displayMessages\"\n [message]=\"msg\"\n ></seam-chat-message>\n\n <div *ngIf=\"_loadingSubject | async\" class=\"seam-chat__loading\">\n <span>Thinking...</span>\n </div>\n </div>\n\n <seam-chat-input\n [placeholder]=\"placeholder\"\n [disabled]=\"!!(_loadingSubject | async)\"\n (messageSent)=\"_onMessageSent($event)\"\n ></seam-chat-input>\n</div>\n","import { ComponentHarness } from '@angular/cdk/testing'\n\nexport class TheSeamChatMessageHarness extends ComponentHarness {\n static hostSelector = 'seam-chat-message'\n\n private readonly _role = this.locatorForOptional('.seam-chat-message__role')\n private readonly _content = this.locatorForOptional(\n '.seam-chat-message__content',\n )\n\n async getRole(): Promise<string> {\n const roleEl = await this._role()\n const text = await roleEl?.text()\n return text?.trim().toLowerCase() ?? ''\n }\n\n async getText(): Promise<string> {\n const contentEl = await this._content()\n return (await contentEl?.text())?.trim() ?? ''\n }\n}\n\nexport class TheSeamChatInputHarness extends ComponentHarness {\n static hostSelector = 'seam-chat-input'\n\n async getSendButton() {\n return this.locatorFor('button')()\n }\n\n async isSendDisabled(): Promise<boolean> {\n const btn = await this.getSendButton()\n return (await btn.getAttribute('disabled')) !== null\n }\n}\n\nexport class TheSeamChatHarness extends ComponentHarness {\n static hostSelector = 'seam-chat'\n\n private readonly _messages = this.locatorForAll(TheSeamChatMessageHarness)\n private readonly _input = this.locatorFor(TheSeamChatInputHarness)\n private readonly _loading = this.locatorForOptional('.seam-chat__loading')\n\n async getMessages(): Promise<TheSeamChatMessageHarness[]> {\n return this._messages()\n }\n\n async getInput(): Promise<TheSeamChatInputHarness> {\n return this._input()\n }\n\n async isLoading(): Promise<boolean> {\n return (await this._loading()) !== null\n }\n}\n","import { InjectionToken } from '@angular/core'\n\nimport { TheSeamAiProvider } from '../providers/ai-provider'\n\nexport const assistantPrompt = `You are a helpful assistant that provides formatting json code for a datatable.\nA datatable is a table that displays data in rows and columns, similar to a spreadsheet, with column sorting and data filtering.\n\nYour job is not to provide a descriptive analysis of the request or any additional information. The user will ignore anything that is not a JSON object.\n\nThe user will provide a request, and you will respond with a JSON object that contains an array of table alterations.\nThe following is the typescript interface for a datatable column and the alterations you can make to it:\n\n\\`\\`\\`typescript\ninterface TableColumn {\n /** Column property */\n prop: string,\n /** Column name */\n name: string,\n /** Column cell type - determines filter type */\n cellType?: 'string' | 'integer' | 'decimal' | 'currency' | 'date' | 'phone',\n /** Whether the column is sortable */\n sortable?: boolean,\n /** Whether the column is filterable */\n filterable?: boolean,\n /** Whether the column is visible */\n visible?: boolean,\n /** Whether the column is resizable */\n resizable?: boolean,\n /** Whether the column is draggable */\n draggable?: boolean,\n /** Column width */\n width?: number,\n /** Column index */\n index?: number,\n}\n\ninterface SortItem {\n /** Column property */\n prop: string,\n /** Sort direction */\n dir: 'asc' | 'desc'\n}\n\ninterface SortState {\n /** The list of sorts */\n sorts: SortItem[]\n}\n\ninterface OrderRecord {\n /** Column property */\n columnProp: string,\n /** Column order, which is the index that it will be placed in the columns array. */\n index: number\n}\n\ninterface OrderState {\n /** The list of column order records */\n columns: OrderRecord[]\n}\n\ninterface WidthState {\n /** The column property that this width alteration applies to */\n columnProp: string\n /** The width of the column. Number is in pixels. */\n width?: number\n /** Whether the column can auto resize. Needs to be false to guarantee a specific width. */\n canAutoResize: boolean\n}\n\ninterface HideColumnState {\n /** The column property that this alteration applies to */\n columnProp: string\n /** Whether the column is hidden */\n hidden: boolean\n}\n\ninterface FilterState {\n /** The column property that this filter applies to */\n columnProp: string,\n /** The filter type based on column cellType */\n filterType: 'text' | 'numeric' | 'date',\n /** The filter operation */\n operation: string,\n /** The filter value (for single value operations) */\n value?: any,\n /** The from value (for range operations like 'between') */\n fromValue?: any,\n /** The to value (for range operations like 'between') */\n toValue?: any\n}\n\ninterface TableAlteration<TType extends string, TState> {\n /**\n * Unique identifier for the alteration.\n */\n id: string\n /**\n * The type of alteration.\n */\n type: TType\n /** The alteration state */\n state: TState\n}\n\n/**\n * Sort alteration for a datatable.\n * \"id\" should always be \"sort\" for this alteration.\n */\ntype SortAlteration = TableAlteration<'sort', SortState>\n\n/**\n * Order alteration for a datatable column.\n *\n * \"id\" should always be \"order\" for this alteration.\n */\ntype OrderAlteration = TableAlteration<'order', OrderState>\n\n/**\n * Width alteration for a datatable column.\n *\n * \"id\" should always be \"width-<prop>\" for this alteration. So, for example, if the column property is \"name\", the id would be \"width-name\".\n */\ntype WidthAlteration = TableAlteration<'width', WidthState>\n\n/**\n * Hide column alteration for a datatable column.\n *\n * \"id\" should always be \"hide-column-<prop>\" for this alteration. So, for example, if the column property is \"name\", the id would be \"hide-column-name\".\n */\ntype HideColumnAlteration = TableAlteration<'hide-column', HideColumnState>\n\n/**\n * Filter alteration for a datatable column.\n * \"id\" should be \"filter--<columnProp>\" for this alteration.\n * For example, if filtering the \"age\" column, the id would be \"filter--age\".\n */\ntype FilterAlteration = TableAlteration<'filter', FilterState>\n\\`\\`\\`\n\n## Filter Operations by Type\n\n### Text Filters (cellType: 'string', 'phone')\n- 'contains': Text contains the value (case-insensitive)\n- 'eq': Text equals the value exactly\n- 'neq': Text does not equal the value\n- 'ncontains': Text does not contain the value\n- 'blank': Field is empty/null\n- 'not-blank': Field is not empty/null\n\n### Numeric Filters (cellType: 'integer', 'decimal', 'currency')\n- 'eq': Equals the value\n- 'gt': Greater than the value\n- 'gte': Greater than or equal to the value\n- 'lt': Less than the value\n- 'lte': Less than or equal to the value\n- 'between': Between fromValue and toValue (inclusive)\n- 'not-between': Not between fromValue and toValue\n- 'blank': Field is empty/null\n- 'not-blank': Field is not empty/null\n\n### Date Filters (cellType: 'date')\n- 'eq': Date equals the value\n- 'gt': Date is after the value\n- 'gte': Date is on or after the value\n- 'lt': Date is before the value\n- 'lte': Date is on or before the value\n- 'between': Date is between fromValue and toValue (inclusive)\n- 'not-between': Date is not between fromValue and toValue\n- 'blank': Field is empty/null\n- 'not-blank': Field is not empty/null\n\n## Examples\n\nFilter age greater than 30:\n\\`\\`\\`json\n{\n \"id\": \"filter--age\",\n \"type\": \"filter\",\n \"state\": {\n \"columnProp\": \"age\",\n \"filterType\": \"numeric\",\n \"operation\": \"gt\",\n \"value\": 30\n }\n}\n\\`\\`\\`\n\nFilter color contains \"red\":\n\\`\\`\\`json\n{\n \"id\": \"filter--color\",\n \"type\": \"filter\",\n \"state\": {\n \"columnProp\": \"color\",\n \"filterType\": \"text\",\n \"operation\": \"contains\",\n \"value\": \"red\"\n }\n}\n\\`\\`\\`\n\nFilter age between 25 and 65:\n\\`\\`\\`json\n{\n \"id\": \"filter--age\",\n \"type\": \"filter\",\n \"state\": {\n \"columnProp\": \"age\",\n \"filterType\": \"numeric\",\n \"operation\": \"between\",\n \"fromValue\": 25,\n \"toValue\": 65\n }\n}\n\\`\\`\\`\n\nSort by name ascending:\n\\`\\`\\`json\n{\n \"id\": \"sort\",\n \"type\": \"sort\",\n \"state\": {\n \"sorts\": [\n {\n \"prop\": \"name\",\n \"dir\": \"asc\"\n }\n ]\n }\n}\n\\`\\`\\`\n\nHide the age column:\n\\`\\`\\`json\n{\n \"id\": \"hide-column-age\",\n \"type\": \"hide-column\",\n \"state\": {\n \"columnProp\": \"age\",\n \"hidden\": true\n }\n}\n\\`\\`\\`\n\nSet name column width to 300 pixels:\n\\`\\`\\`json\n{\n \"id\": \"width-name\",\n \"type\": \"width\",\n \"state\": {\n \"columnProp\": \"name\",\n \"width\": 300,\n \"canAutoResize\": false\n }\n}\n\\`\\`\\`\n\nReorder columns (name first, age second, color third):\n\\`\\`\\`json\n{\n \"id\": \"order\",\n \"type\": \"order\",\n \"state\": {\n \"columns\": [\n { \"columnProp\": \"name\", \"index\": 0 },\n { \"columnProp\": \"age\", \"index\": 1 },\n { \"columnProp\": \"color\", \"index\": 2 }\n ]\n }\n}\n\\`\\`\\`\n`\n\nexport const getUserPrompt = (columns: any[], request: string): string => `\nColumns:\n\\`\\`\\`json\n${JSON.stringify(columns, null, 2)}\n\\`\\`\\`\nRequest: \"${request}\"\n`\n\nexport function parseResponse(\n responseContent: string,\n responseFormat: { type: string } | undefined,\n) {\n if (responseFormat?.type === 'json_object') {\n return JSON.parse(responseContent)\n }\n\n // Parse the JSON string to an object, which is in the string between the code blocks.\n // So, need to find the first and last code block markers.\n const startIndex = responseContent.indexOf('```json') + '```json'.length\n const endIndex = responseContent.lastIndexOf('```')\n const alterations = responseContent.substring(startIndex, endIndex).trim()\n // console.log('Alterations:', alterations)\n\n return JSON.parse(alterations)\n}\n\nexport const THESEAM_DATATABLE_PROMPTER_PROVIDER =\n new InjectionToken<TheSeamAiProvider>('TheSeamDatatablePrompterProvider')\n","import { ChangeDetectorRef, Component, inject, Input } from '@angular/core'\nimport { AsyncPipe, JsonPipe, NgForOf, NgIf } from '@angular/common'\nimport {\n FormControl,\n FormGroup,\n ReactiveFormsModule,\n Validators,\n} from '@angular/forms'\n\nimport {\n BehaviorSubject,\n combineLatest,\n map,\n Observable,\n of,\n shareReplay,\n startWith,\n switchMap,\n tap,\n} from 'rxjs'\nimport {\n ColumnsAlterationState,\n DatatableComponent,\n DatatablePreferencesService,\n EMPTY_DATATABLE_PREFERENCES,\n mapColumnsAlterationsStates,\n THESEAM_DATATABLE_PREFERENCES_ACCESSOR,\n} from '@theseam/ui-common/datatable'\nimport { TheSeamLoadingModule } from '@theseam/ui-common/loading'\nimport { TheSeamRichTextModule } from '@theseam/ui-common/rich-text'\nimport { TheSeamFormFieldModule } from '@theseam/ui-common/form-field'\nimport { TheSeamButtonsModule } from '@theseam/ui-common/buttons'\nimport {\n AlterationDisplayItem,\n AlterationsDiffComponent,\n} from '@theseam/ui-common/datatable-alterations-display'\n\nimport {\n assistantPrompt,\n getUserPrompt,\n parseResponse,\n THESEAM_DATATABLE_PROMPTER_PROVIDER,\n} from './datatable-prompter-prompt-provider'\n\n@Component({\n selector: 'seam-datatable-prompter',\n templateUrl: './datatable-prompter.component.html',\n styleUrls: ['./datatable-prompter.component.scss'],\n imports: [\n ReactiveFormsModule,\n AsyncPipe,\n JsonPipe,\n NgForOf,\n NgIf,\n TheSeamLoadingModule,\n TheSeamRichTextModule,\n TheSeamFormFieldModule,\n TheSeamButtonsModule,\n AlterationsDiffComponent,\n ],\n})\nexport class TheSeamDatatablePrompterComponent {\n // cdr = inject(ChangeDetectorRef)\n\n private readonly _prefsAccessor = inject(\n THESEAM_DATATABLE_PREFERENCES_ACCESSOR,\n { optional: true },\n )\n private readonly _dtPrefsService = inject(DatatablePreferencesService)\n private readonly _aiProvider = inject(THESEAM_DATATABLE_PROMPTER_PROVIDER, {\n optional: true,\n })\n\n readonly _loadingSubject = new BehaviorSubject<boolean>(false)\n readonly _altsDataSubject = new BehaviorSubject<\n | {\n currentItems: AlterationDisplayItem[]\n pendingItems: AlterationDisplayItem[]\n }\n | undefined\n >(undefined)\n\n public readonly loading$ = this._loadingSubject.asObservable()\n\n @Input() diffMode: 'auto' | 'manual' = 'auto'\n @Input() compact = true\n\n @Input()\n set prompt(value: string | undefined | null) {\n if (value) {\n this._form.controls.prompt.setValue(value)\n } else {\n this._form.controls.prompt.setValue('Sort color descending order')\n }\n }\n\n @Input()\n set datatable(value: DatatableComponent | undefined | null) {\n this._datatableSubject.next(value)\n }\n get datatable(): DatatableComponent | undefined | null {\n return this._datatableSubject.value\n }\n private _datatableSubject = new BehaviorSubject<\n DatatableComponent | undefined | null\n >(null)\n\n @Input() showAlts = true\n\n readonly _form = new FormGroup({\n prompt: new FormControl<string | null>('Sort color descending order', [\n Validators.required,\n ]),\n })\n\n _alterations$: Observable<ColumnsAlterationState[]> = this._datatableSubject\n .asObservable()\n .pipe(\n switchMap((dt): Observable<DatatableComponent | null | undefined> => {\n if (!dt) {\n return of(dt)\n }\n return (dt as any)._columnsAlterationsManager.changes.pipe(\n startWith(undefined),\n map(() => dt),\n )\n }),\n switchMap((datatable) => {\n if (!datatable) {\n return of([] as ColumnsAlterationState[])\n }\n const key = datatable.preferencesKey\n if (!key) {\n // eslint-disable-next-line no-console\n console.warn(\n 'No preferences key set on datatable, returning empty alterations.',\n )\n return of([] as ColumnsAlterationState[])\n }\n\n return (\n this._dtPrefsService.preferences(key).pipe(\n switchMap((prefs) => {\n // console.log('~~~~Current preferences:', prefs)\n if (!prefs) {\n return of(\n JSON.parse(JSON.stringify(EMPTY_DATATABLE_PREFERENCES))\n .alterations as ColumnsAlterationState[],\n )\n }\n // return of(JSON.parse(prefs).alterations as ColumnsAlterationState[])\n return of(prefs.alterations as ColumnsAlterationState[])\n }),\n ) ?? of([] as ColumnsAlterationState[])\n )\n }),\n // tap(v => console.log('%cAlterations:', 'color: limegreen;', v)),\n )\n\n _alterationsDisplayItems$: Observable<AlterationDisplayItem[]> =\n this._alterations$.pipe(\n switchMap((alterations) => {\n console.log('~~~~~Current alterations:', alterations)\n if (!alterations || alterations.length === 0) {\n return of([] as AlterationDisplayItem[])\n }\n const alts = mapColumnsAlterationsStates(alterations)\n console.log('~~~~~Mapped alterations:', alts)\n return of(alts.map((a) => a.toDisplayItem()))\n }),\n shareReplay({ bufferSize: 1, refCount: true }),\n )\n\n _pendingAlterationsSubject = new BehaviorSubject<ColumnsAlterationState[]>([])\n _pendingAlterationsDisplayItems$: Observable<AlterationDisplayItem[]> =\n this._pendingAlterationsSubject.asObservable().pipe(\n switchMap((pending) => {\n if (!pending || pending.length === 0) {\n return of([] as AlterationDisplayItem[])\n }\n const alts = mapColumnsAlterationsStates(pending)\n console.log('~~~~~Mapped alterations2:', alts)\n return of(alts.map((a) => a.toDisplayItem()))\n }),\n shareReplay({ bufferSize: 1, refCount: true }),\n )\n\n _onSubmit() {\n console.log('Submitting prompt:', this._form.value)\n if (this._form.invalid) {\n return\n }\n if (this._loadingSubject.value) {\n console.warn('Already loading, ignoring submit.')\n return\n }\n\n const prompt = this._form.value.prompt\n if (!prompt) {\n return\n }\n console.log('datatable', this._datatableSubject.value)\n const columns = (\n this._datatableSubject.value?.ngxDatatable?.columns || []\n ).map((col) => ({\n prop: col.prop,\n name: col.name,\n cellType: (col as any).cellType || 'string',\n sortable: col.sortable,\n filterable: true,\n visible: true,\n resizable: col.resizeable,\n draggable: col.draggable,\n }))\n\n console.log('columns', columns)\n const userPrompt = getUserPrompt(columns, prompt)\n console.log('userPrompt', userPrompt)\n\n this._loadingSubject.next(true)\n if (!this._aiProvider) {\n console.error('No AI provider configured, cannot submit prompt.')\n this._loadingSubject.next(false)\n return\n }\n this._aiProvider\n .chat({\n messages: [\n {\n role: 'user',\n content: `${assistantPrompt}\\n\\n---\\n\\n${userPrompt}`,\n },\n ],\n })\n .then(async (response) => {\n const alterations = parseResponse(response.content, undefined)\n // this._form.reset()\n console.log('Received alterations:', alterations)\n const datatable = this._datatableSubject.value\n if (!datatable) {\n console.error('No datatable found to apply alterations to.')\n return\n }\n\n const key = this.datatable!.preferencesKey as string\n\n const before = await this._prefsAccessor?.get(key).toPromise()\n console.log('Current preferences before update:', before)\n\n const _apply = async () => {\n console.log('Preferences updated successfully.')\n const _cols = this.datatable!.ngxDatatable!.columns\n const cols = [..._cols]\n console.log('this.datatable!.columns', cols)\n\n const after = await this._prefsAccessor?.get(key).toPromise()\n let _after = (JSON.parse(after || '{}').alterations ||\n []) as ColumnsAlterationState[]\n if (!Array.isArray(_after)) {\n _after = [_after]\n }\n\n const mgr = (this.datatable as any)._columnsAlterationsManager\n console.log('_columnsAlterationsManager', mgr, mgr.get())\n const alts = mapColumnsAlterationsStates(_after)\n console.log('Mapped alterations:', alts)\n const columnsBefore = JSON.parse(\n JSON.stringify(\n this.datatable!.ngxDatatable!.columns.map((x) => x.prop),\n ),\n )\n console.log('Columns before applying alterations:', columnsBefore)\n for (const a of alts) {\n console.log('Applying alteration:', a)\n a.apply(cols, this.datatable!)\n }\n console.log('Current preferences after update:', after)\n console.log(_after)\n\n this.datatable!.columns = [...cols]\n const columnsAfter = JSON.parse(\n JSON.stringify(\n this.datatable!.ngxDatatable!.columns.map((x) => x.prop),\n ),\n )\n console.log('Columns after applying alterations:', columnsAfter)\n mgr.add(alts)\n datatable._cdr.detectChanges()\n\n this._pendingAlterationsSubject.next(_after)\n }\n\n this._prefsAccessor\n ?.update(\n key,\n JSON.stringify({\n version: 2,\n alterations,\n }),\n )\n .subscribe(async () => {\n // TODO: Cleanup. This is a hack to ensure the datatable updates after the preferences are set.\n await _apply()\n datatable.rows = [...datatable.rows]\n datatable._cdr.detectChanges()\n await _apply()\n\n this._loadingSubject.next(false)\n })\n })\n .catch((err) => {\n console.error('Error submitting prompt:', err)\n this._loadingSubject.next(false)\n })\n }\n}\n","<div class=\"d-block border rounded border-lightgray\">\n <div\n [formGroup]=\"_form\"\n (ngSubmit)=\"_onSubmit()\"\n class=\"d-block position-relative\"\n >\n <div>\n <div class=\"p-1\">\n <!-- <textarea formControlName=\"prompt\" style=\"width: 800px; height: 100px;\"></textarea> -->\n <seam-form-field [numPaddingErrors]=\"0\">\n <seam-rich-text\n seamInput\n formControlName=\"prompt\"\n placeholder=\"Describe what you want to apply to the datatable.\"\n [rows]=\"3\"\n [resizable]=\"false\"\n [disableRichText]=\"true\"\n ></seam-rich-text>\n </seam-form-field>\n </div>\n <div class=\"p-1\">\n <button\n class=\"mr-1\"\n type=\"submit\"\n seamButton\n theme=\"primary\"\n size=\"sm\"\n (click)=\"_onSubmit()\"\n >\n Submit\n </button>\n <button seamButton theme=\"lightgray\" size=\"sm\" (click)=\"_form.reset()\">\n Reset\n </button>\n </div>\n </div>\n <div\n *ngIf=\"loading$ | async\"\n class=\"d-block position-absolute\"\n style=\"top: 0; left: 0; right: 0; bottom: 0\"\n >\n <seam-loading></seam-loading>\n </div>\n </div>\n\n <div class=\"p-2\" *ngIf=\"showAlts\">\n <div>Active Alterations</div>\n <div class=\"p-2 border rounded bg-lightgray\">\n <!-- {{ _alterations$ | async | json }} -->\n <div *ngFor=\"let alteration of _alterations$ | async; let last = last\">\n <div\n class=\"d-flex align-items-center border border-dark rounded p-1\"\n [class.mb-1]=\"!last\"\n >\n <span class=\"badge bg-secondary\">{{ alteration.type }}</span>\n <!-- <span class=\"badge bg-primary\">{{ alteration.label }}</span> -->\n <!-- <div>\n {{ alteration.value | json }}\n </div> -->\n <div *ngIf=\"alteration.type === 'sort'\">\n <div class=\"d-flex flex-column\">\n <div\n *ngFor=\"let sort of alteration.state.sorts; let last = last\"\n [class.mb-1]=\"!last\"\n >\n <span class=\"badge bg-lightgray\"\n >{{ sort.prop }} ({{ sort.dir }})</span\n >\n </div>\n </div>\n </div>\n </div>\n </div>\n </div>\n <seam-alterations-diff\n [currentItems]=\"(_alterationsDisplayItems$ | async) ?? []\"\n [pendingItems]=\"(_pendingAlterationsDisplayItems$ | async) ?? []\"\n [compact]=\"compact\"\n [diffMode]=\"diffMode\"\n ></seam-alterations-diff>\n </div>\n</div>\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["i4","i2","i5"],"mappings":";;;;;;;;;;;;;;;;;;;;;;MAMa,kBAAkB,CAAA;IAC7B,MAAM,IAAI,CAAC,OAA6B,EAAA;QACtC,MAAM,GAAG,GAAG,2CAA2C;AACvD,QAAA,MAAM,OAAO,GAAG;AACd,YAAA,cAAc,EAAE,kBAAkB;SACnC;QACD,MAAM,KAAK,GAAG,kBAAkB;AAEhC,QAAA,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;AAChC,YAAA,MAAM,EAAE,MAAM;YACd,OAAO;AACP,YAAA,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;gBACnB,KAAK;AACL,gBAAA,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM;oBACrC,IAAI,EAAE,CAAC,CAAC,IAAI;oBACZ,OAAO,EAAE,CAAC,CAAC,OAAO;AACnB,iBAAA,CAAC,CAAC;aACJ,CAAC;AACH,SAAA,CAAC;AAEF,QAAA,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE;AAClC,QAAA,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO;QAC/C,OAAO,EAAE,OAAO,EAAE;IACpB;AACD;;MCxBY,oBAAoB,CAAA;IAC/B,MAAM,IAAI,CAAC,OAA6B,EAAA;QACtC,MAAM,aAAa,GACjB,2EAA2E;QAE7E,MAAM,GAAG,GAAG,+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BACpB,wBAAwB;AACzB,qBAAA,EAAA,QAAA,EAAA,irFAAA,EAAA,MAAA,EAAA,CAAA,wCAAA,CAAA,EAAA;;sBAyBA;;sBACA;;sBAEA;;sBASA;;sBAWA;;;AE3GH;;AAEG;;;;"}
1
+ {"version":3,"file":"theseam-ui-common-ai.mjs","sources":["../../../projects/ui-common/ai/providers/ai-provider.ts","../../../projects/ui-common/ai/providers/lm-studio.ai-provider.ts","../../../projects/ui-common/ai/providers/openrouter.ai-provider.ts","../../../projects/ui-common/ai/providers/mock.ai-provider.ts","../../../projects/ui-common/ai/chat-context-registry.service.ts","../../../projects/ui-common/ai/contexts/datatable-chat-context.ts","../../../projects/ui-common/ai/chat/chat-provider.ts","../../../projects/ui-common/ai/chat/chat-response-parser.ts","../../../projects/ui-common/ai/chat/chat-block-registry.ts","../../../projects/ui-common/ai/chat/chat-message.component.ts","../../../projects/ui-common/ai/chat/chat-input.component.ts","../../../projects/ui-common/ai/chat/chat.component.ts","../../../projects/ui-common/ai/chat/chat.component.html","../../../projects/ui-common/ai/chat/testing/chat.harness.ts","../../../projects/ui-common/ai/datatable-prompter/datatable-prompter-prompt-provider.ts","../../../projects/ui-common/ai/datatable-prompter/datatable-prompter.component.ts","../../../projects/ui-common/ai/datatable-prompter/datatable-prompter.component.html","../../../projects/ui-common/ai/public-api.ts","../../../projects/ui-common/ai/theseam-ui-common-ai.ts"],"sourcesContent":["import { Observable } from 'rxjs'\n\nimport { TheSeamChatContextPayload } from '../chat-context'\n\n/**\n * A single conversation turn. Sent to the LLM via `chat()` and produced by\n * `chat()` as the assistant response. Persisted history (with uid + created)\n * is exposed separately via `ChatSessionMessage`.\n */\nexport interface ChatMessage {\n /** 'user' | 'assistant' in practice; widened to string for forward-compat. */\n role: string\n content: string\n}\n\nexport interface ChatSessionMessage {\n uid: string\n role: string\n content: string\n /** ISO-8601 datetime of when the message was persisted. */\n created: string\n}\n\nexport interface ChatSession {\n uid: string\n label: string\n created: string\n lastActivity: string\n leafMessageId: string | null\n messages: ChatSessionMessage[]\n}\n\nexport interface ChatSessionListItem {\n uid: string\n label: string\n created: string\n lastActivity: string\n}\n\nexport interface TheSeamAiChatRequest {\n messages: ChatMessage[]\n contexts?: TheSeamChatContextPayload[]\n /** When null, the backend creates a new session and returns its uid. */\n sessionId?: string | null\n /**\n * Required when `sessionId` is set. The uid of the message the client\n * believes is the current leaf. Backend returns 409 if it doesn't match.\n */\n expectedLeafMessageId?: string | null\n}\n\nexport interface ChatResponse {\n content: string\n sessionId: string\n label: string\n leafMessageId: string\n}\n\n/**\n * Errored by `TheSeamAiProvider.chat()` when the server reports the\n * session's leaf has advanced since the client last observed it (HTTP 409).\n * The chat component catches this, reloads the session, and emits\n * `(staleSession)`.\n */\nexport class ChatSessionStaleError extends Error {\n constructor(\n public readonly sessionId: string,\n public readonly currentLeafMessageId: string | null,\n ) {\n super('Chat session leaf is stale')\n this.name = 'ChatSessionStaleError'\n }\n}\n\nexport interface TheSeamAiProvider {\n /**\n * Send a chat turn. Errors with `ChatSessionStaleError` when the session's\n * leaf has advanced since the last observed state.\n *\n * Implementations should emit exactly once and complete.\n */\n chat(request: TheSeamAiChatRequest): Observable<ChatResponse>\n\n /**\n * Hook the chat component calls on mount to ask the provider what session\n * to load. Default app implementation prefers a query-param session uid\n * and falls back to the user's most recent session, but apps can override.\n */\n getInitialSession(): Observable<ChatSession | null>\n\n /** Returns the user's most-recently-active session, or null if none exists. */\n getRecentSession(): Observable<ChatSession | null>\n\n /** Loads a specific session with its active-path messages. */\n getSession(uid: string): Observable<ChatSession>\n\n /** Returns session metadata for the user (no messages). */\n listSessions(): Observable<ChatSessionListItem[]>\n\n /** Updates a session's user-visible label. */\n renameSession(uid: string, label: string): Observable<void>\n\n /** Soft-deletes the session. */\n deleteSession(uid: string): Observable<void>\n}\n","import { defer, Observable, of, throwError } from 'rxjs'\n\nimport {\n ChatResponse,\n ChatSession,\n ChatSessionListItem,\n TheSeamAiChatRequest,\n TheSeamAiProvider,\n} from './ai-provider'\n\nexport class LmStudioAiProvider implements TheSeamAiProvider {\n chat(request: TheSeamAiChatRequest): Observable<ChatResponse> {\n return defer(() => {\n const controller = new AbortController()\n const promise = (async () => {\n const url = 'http://localhost:1234/v1/chat/completions'\n const headers = { 'Content-Type': 'application/json' }\n const model = 'model-identifier'\n\n const response = await fetch(url, {\n method: 'POST',\n headers,\n body: JSON.stringify({\n model,\n messages: request.messages.map((m) => ({\n role: m.role,\n content: m.content,\n })),\n }),\n signal: controller.signal,\n })\n\n const data = await response.json()\n const content = data.choices[0].message.content\n return {\n content,\n // LM Studio is provider-only; no real session backend.\n sessionId: request.sessionId ?? 'lm-studio-local',\n label: 'LM Studio',\n leafMessageId: crypto.randomUUID(),\n } satisfies ChatResponse\n })()\n promise.finally(() => {\n /* avoid unhandled-rejection on unsubscribe */\n })\n return new Observable<ChatResponse>((subscriber) => {\n promise.then(\n (value) => {\n subscriber.next(value)\n subscriber.complete()\n },\n (err) => subscriber.error(err),\n )\n return () => controller.abort()\n })\n })\n }\n\n getInitialSession(): Observable<ChatSession | null> {\n return of(null)\n }\n\n getRecentSession(): Observable<ChatSession | null> {\n return of(null)\n }\n\n getSession(_uid: string): Observable<ChatSession> {\n return throwError(\n () =>\n new Error('LmStudioAiProvider does not support session persistence.'),\n )\n }\n\n listSessions(): Observable<ChatSessionListItem[]> {\n return of([])\n }\n\n renameSession(_uid: string, _label: string): Observable<void> {\n return throwError(\n () =>\n new Error('LmStudioAiProvider does not support session persistence.'),\n )\n }\n\n deleteSession(_uid: string): Observable<void> {\n return throwError(\n () =>\n new Error('LmStudioAiProvider does not support session persistence.'),\n )\n }\n}\n","import { defer, Observable, of, throwError } from 'rxjs'\n\nimport {\n ChatResponse,\n ChatSession,\n ChatSessionListItem,\n TheSeamAiChatRequest,\n TheSeamAiProvider,\n} from './ai-provider'\n\nexport class OpenRouterAiProvider implements TheSeamAiProvider {\n chat(request: TheSeamAiChatRequest): Observable<ChatResponse> {\n return defer(() => {\n const controller = new AbortController()\n const promise = (async () => {\n const defaultApiKey =\n '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'\n const url = 'https://openrouter.ai/api/v1/chat/completions'\n const apiKey =\n localStorage.getItem('openrouter-api-key') || defaultApiKey\n const headers = {\n Authorization: `Bearer ${apiKey}`,\n 'Content-Type': 'application/json',\n }\n const model = 'google/gemini-2.5-flash'\n\n const response = await fetch(url, {\n method: 'POST',\n headers,\n body: JSON.stringify({\n model,\n messages: request.messages.map((m) => ({\n role: m.role,\n content: m.content,\n })),\n response_format: { type: 'json_object' },\n }),\n signal: controller.signal,\n })\n\n const data = await response.json()\n const content = data.choices[0].message.content\n return {\n content,\n sessionId: request.sessionId ?? 'openrouter-remote',\n label: 'OpenRouter',\n leafMessageId: crypto.randomUUID(),\n } satisfies ChatResponse\n })()\n promise.finally(() => {\n /* avoid unhandled-rejection on unsubscribe */\n })\n return new Observable<ChatResponse>((subscriber) => {\n promise.then(\n (value) => {\n subscriber.next(value)\n subscriber.complete()\n },\n (err) => subscriber.error(err),\n )\n return () => controller.abort()\n })\n })\n }\n\n getInitialSession(): Observable<ChatSession | null> {\n return of(null)\n }\n\n getRecentSession(): Observable<ChatSession | null> {\n return of(null)\n }\n\n getSession(_uid: string): Observable<ChatSession> {\n return throwError(\n () =>\n new Error('OpenRouterAiProvider does not support session persistence.'),\n )\n }\n\n listSessions(): Observable<ChatSessionListItem[]> {\n return of([])\n }\n\n renameSession(_uid: string, _label: string): Observable<void> {\n return throwError(\n () =>\n new Error('OpenRouterAiProvider does not support session persistence.'),\n )\n }\n\n deleteSession(_uid: string): Observable<void> {\n return throwError(\n () =>\n new Error('OpenRouterAiProvider does not support session persistence.'),\n )\n }\n}\n","import { defer, Observable, of, throwError } from 'rxjs'\nimport { delay as rxDelay } from 'rxjs/operators'\n\nimport {\n ChatMessage,\n ChatResponse,\n ChatSession,\n ChatSessionListItem,\n ChatSessionStaleError,\n TheSeamAiChatRequest,\n TheSeamAiProvider,\n} from './ai-provider'\n\ntype MockResponse = string | ((messages: ChatMessage[]) => string)\n\nexport interface MockAiProviderConfig {\n response?: MockResponse\n initialSession?: ChatSession | null\n sessionsByUid?: ReadonlyMap<string, ChatSession>\n sessionsList?: ChatSessionListItem[]\n\n /** First chat() call errors with this; subsequent calls succeed normally. */\n throwOnFirstChat?: Error\n\n /** Artificial delay (ms) applied uniformly. Overridable per method. */\n delayMs?: number\n delayMsByMethod?: Partial<Record<keyof TheSeamAiProvider, number>>\n}\n\ntype LegacyArg = MockAiProviderConfig | MockResponse | undefined\n\nexport class MockAiProvider implements TheSeamAiProvider {\n private readonly _config: MockAiProviderConfig\n private _throwOnNextChat?: Error\n\n constructor(configOrLegacy?: LegacyArg) {\n if (\n typeof configOrLegacy === 'string' ||\n typeof configOrLegacy === 'function'\n ) {\n this._config = { response: configOrLegacy }\n } else {\n this._config = configOrLegacy ?? {}\n }\n this._throwOnNextChat = this._config.throwOnFirstChat\n }\n\n chat(request: TheSeamAiChatRequest): Observable<ChatResponse> {\n return defer(() => {\n if (this._throwOnNextChat) {\n const err = this._throwOnNextChat\n this._throwOnNextChat = undefined\n return throwError(() => err) as Observable<ChatResponse>\n }\n const content =\n typeof this._config.response === 'function'\n ? this._config.response(request.messages)\n : (this._config.response ?? 'Mock response')\n const response: ChatResponse = {\n content,\n sessionId: request.sessionId ?? `mock-session-${cryptoRandomId()}`,\n label: 'Mock',\n leafMessageId: cryptoRandomId(),\n }\n return this._withDelay('chat', of(response))\n })\n }\n\n getInitialSession(): Observable<ChatSession | null> {\n return defer(() =>\n this._withDelay(\n 'getInitialSession',\n of(this._config.initialSession ?? null),\n ),\n )\n }\n\n getRecentSession(): Observable<ChatSession | null> {\n return defer(() =>\n this._withDelay(\n 'getRecentSession',\n of(this._config.initialSession ?? null),\n ),\n )\n }\n\n getSession(uid: string): Observable<ChatSession> {\n return defer(() => {\n const found = this._config.sessionsByUid?.get(uid)\n if (!found) {\n return throwError(\n () => new Error(`MockAiProvider: session not found for uid \"${uid}\"`),\n )\n }\n return this._withDelay('getSession', of(found))\n })\n }\n\n listSessions(): Observable<ChatSessionListItem[]> {\n return defer(() =>\n this._withDelay('listSessions', of(this._config.sessionsList ?? [])),\n )\n }\n\n renameSession(_uid: string, _label: string): Observable<void> {\n return defer(() => this._withDelay('renameSession', of(undefined as void)))\n }\n\n deleteSession(_uid: string): Observable<void> {\n return defer(() => this._withDelay('deleteSession', of(undefined as void)))\n }\n\n private _withDelay<T>(\n method: keyof TheSeamAiProvider,\n source$: Observable<T>,\n ): Observable<T> {\n const ms =\n this._config.delayMsByMethod?.[method] ?? this._config.delayMs ?? 0\n return ms > 0 ? source$.pipe(rxDelay(ms)) : source$\n }\n}\n\nfunction cryptoRandomId(): string {\n return typeof crypto !== 'undefined' && 'randomUUID' in crypto\n ? crypto.randomUUID()\n : `${Date.now()}-${Math.random().toString(36).slice(2)}`\n}\n","import { Injectable } from '@angular/core'\n\nimport { TheSeamChatContext, TheSeamChatContextPayload } from './chat-context'\n\n@Injectable({ providedIn: 'root' })\nexport class TheSeamChatContextRegistry {\n private readonly _contexts = new Set<TheSeamChatContext>()\n\n /**\n * Register a context. Returns an unregister function — pair it with DestroyRef:\n * inject(DestroyRef).onDestroy(registry.register(ctx))\n */\n register(ctx: TheSeamChatContext): () => void {\n this._contexts.add(ctx)\n return () => this._contexts.delete(ctx)\n }\n\n unregister(ctx: TheSeamChatContext): void {\n this._contexts.delete(ctx)\n }\n\n /**\n * Resolve registered contexts to a wire-ready payload list. Applies the modal-mask\n * rule (a `modal`-typed context hides others unless they set `alwaysVisible`) and\n * drops entries whose `getContext()` returns null/undefined.\n */\n async snapshot(): Promise<TheSeamChatContextPayload[]> {\n const all = [...this._contexts]\n const masked = all.some((c) => c.type === 'modal')\n const visible = masked\n ? all.filter((c) => c.type === 'modal' || c.alwaysVisible)\n : all\n const resolved = await Promise.all(\n visible.map(async (c) => ({ type: c.type, data: await c.getContext() })),\n )\n return resolved.filter((p) => p.data != null)\n }\n}\n","import { OperationDefinitionNode, print } from 'graphql'\n\nimport { TheSeamDatatableColumn } from '@theseam/ui-common/datatable'\nimport {\n DatatableGraphQLQueryRef,\n processGql,\n} from '@theseam/ui-common/graphql'\n\nimport { TheSeamChatContext } from '../chat-context'\n\nexport interface TheSeamDatatableChatContextOptions {\n /** Optional human label, e.g. 'Bales'. Helps the LLM disambiguate when multiple datatables are registered. */\n label?: string\n}\n\nexport interface TheSeamDatatableChatContextData {\n label?: string\n operationName: string\n query: string\n variables: Record<string, unknown>\n columns: { prop: string | number | undefined; name: string | undefined }[]\n}\n\nexport class TheSeamDatatableChatContext implements TheSeamChatContext {\n readonly type = 'datatable'\n\n constructor(\n private readonly _queryRef: DatatableGraphQLQueryRef<any, any, any>,\n private readonly _columns: readonly TheSeamDatatableColumn[],\n private readonly _options: TheSeamDatatableChatContextOptions = {},\n ) {}\n\n getContext(): TheSeamDatatableChatContextData | null {\n const opts = this._queryRef.getOptions()\n if (!opts) return null\n\n const { query, variables } = processGql(\n opts.query,\n this._queryRef.getVariables() as Record<string, any>,\n this._queryRef.getQueryProcessingConfig() ?? { variables: {} },\n )\n\n const operationName =\n query.definitions.find(\n (d): d is OperationDefinitionNode => d.kind === 'OperationDefinition',\n )?.name?.value ?? ''\n\n return {\n label: this._options.label,\n operationName,\n query: print(query),\n variables,\n columns: this._columns.map((c) => ({ prop: c.prop, name: c.name })),\n }\n }\n}\n","import { InjectionToken } from '@angular/core'\n\nimport { TheSeamAiProvider } from '../providers/ai-provider'\n\nexport const THESEAM_CHAT_PROVIDER = new InjectionToken<TheSeamAiProvider>(\n 'TheSeamChatProvider',\n)\n","export type ChatContentSegment =\n | { type: 'markdown'; content: string }\n | { type: 'custom-block'; tag: string; content: string }\n\n/**\n * Splits a raw AI response string into an ordered array of segments.\n * Fenced code blocks with `seam-` prefixed language tags become custom-block\n * segments; everything else stays as markdown.\n */\nexport function parseChatResponse(input: string): ChatContentSegment[] {\n if (!input) {\n return []\n }\n\n const segments: ChatContentSegment[] = []\n const pattern = /^```(seam-[\\w-]+)\\n([\\s\\S]*?)^```/gm\n\n let lastIndex = 0\n let match: RegExpExecArray | null\n\n while ((match = pattern.exec(input)) !== null) {\n if (match.index > lastIndex) {\n segments.push({\n type: 'markdown',\n content: input.slice(lastIndex, match.index),\n })\n }\n\n segments.push({\n type: 'custom-block',\n tag: match[1],\n content: match[2].replace(/\\n$/, ''),\n })\n\n lastIndex = match.index + match[0].length\n }\n\n if (lastIndex < input.length) {\n segments.push({ type: 'markdown', content: input.slice(lastIndex) })\n }\n\n return segments\n}\n","import { InjectionToken, Type } from '@angular/core'\n\nexport type ChatBlockRegistry = Map<string, Type<unknown>>\n\nexport const THESEAM_CHAT_BLOCK_REGISTRY =\n new InjectionToken<ChatBlockRegistry>('TheSeamChatBlockRegistry')\n","import {\n ChangeDetectionStrategy,\n Component,\n inject,\n Input,\n Injector,\n} from '@angular/core'\nimport { NgComponentOutlet, NgForOf, NgIf } from '@angular/common'\nimport { MarkdownComponent } from 'ngx-markdown'\n\nimport { ChatContentSegment } from './chat-response-parser'\nimport {\n ChatBlockRegistry,\n THESEAM_CHAT_BLOCK_REGISTRY,\n} from './chat-block-registry'\n\nexport interface ChatMessageDisplayModel {\n /** Present for messages loaded from a persisted session. */\n uid?: string\n /** 'user' | 'assistant' rendered specially; other roles fall through to a neutral style. */\n role: string\n segments: ChatContentSegment[]\n timestamp: Date\n}\n\n@Component({\n selector: 'seam-chat-message',\n imports: [NgForOf, NgIf, MarkdownComponent, NgComponentOutlet],\n changeDetection: ChangeDetectionStrategy.OnPush,\n template: `\n <div\n class=\"seam-chat-message\"\n [class.seam-chat-message--user]=\"message.role === 'user'\"\n [class.seam-chat-message--assistant]=\"message.role === 'assistant'\"\n >\n <div class=\"seam-chat-message__role\">\n {{ message.role === 'user' ? 'You' : 'Assistant' }}\n </div>\n <div class=\"seam-chat-message__content\">\n <ng-container *ngFor=\"let segment of message.segments\">\n <markdown\n *ngIf=\"segment.type === 'markdown'\"\n [data]=\"segment.content\"\n ></markdown>\n <ng-container *ngIf=\"segment.type === 'custom-block'\">\n <ng-container\n *ngIf=\"\n _getBlockComponent(segment.tag) as blockComponent;\n else fallbackBlock\n \"\n >\n <ng-container\n *ngComponentOutlet=\"\n blockComponent;\n injector: _createBlockInjector(segment.content)\n \"\n ></ng-container>\n </ng-container>\n <ng-template #fallbackBlock>\n <markdown\n [data]=\"_buildFallbackMarkdown(segment.tag, segment.content)\"\n ></markdown>\n </ng-template>\n </ng-container>\n </ng-container>\n </div>\n </div>\n `,\n styles: [\n `\n .seam-chat-message {\n display: flex;\n flex-direction: column;\n padding: 8px 12px;\n margin-bottom: 8px;\n }\n\n .seam-chat-message--user {\n align-items: flex-end;\n }\n\n .seam-chat-message--user .seam-chat-message__content {\n background-color: #e8f5e9;\n border-radius: 8px;\n padding: 8px 12px;\n max-width: 80%;\n }\n\n .seam-chat-message--assistant .seam-chat-message__content {\n background-color: #f1f3f5;\n border-radius: 8px;\n padding: 8px 12px;\n max-width: 80%;\n }\n\n .seam-chat-message__role {\n font-size: 0.75rem;\n color: #6c757d;\n margin-bottom: 4px;\n }\n `,\n ],\n})\nexport class SeamChatMessageComponent {\n @Input({ required: true }) message!: ChatMessageDisplayModel\n\n private readonly _blockRegistry = inject(THESEAM_CHAT_BLOCK_REGISTRY, {\n optional: true,\n })\n private readonly _injector = inject(Injector)\n\n _getBlockComponent(tag: string) {\n return this._blockRegistry?.get(tag) ?? null\n }\n\n _createBlockInjector(content: string): Injector {\n return Injector.create({\n providers: [{ provide: 'CHAT_BLOCK_CONTENT', useValue: content }],\n parent: this._injector,\n })\n }\n\n _buildFallbackMarkdown(tag: string, content: string): string {\n return '```' + tag + '\\n' + content + '\\n```'\n }\n}\n","import {\n ChangeDetectionStrategy,\n Component,\n EventEmitter,\n Input,\n Output,\n} from '@angular/core'\nimport { FormControl, ReactiveFormsModule, Validators } from '@angular/forms'\n\nimport { TheSeamRichTextModule } from '@theseam/ui-common/rich-text'\nimport { TheSeamFormFieldModule } from '@theseam/ui-common/form-field'\nimport { TheSeamButtonsModule } from '@theseam/ui-common/buttons'\n\n@Component({\n selector: 'seam-chat-input',\n imports: [\n ReactiveFormsModule,\n TheSeamRichTextModule,\n TheSeamFormFieldModule,\n TheSeamButtonsModule,\n ],\n changeDetection: ChangeDetectionStrategy.OnPush,\n template: `\n <div class=\"seam-chat-input\">\n <seam-form-field>\n <seam-rich-text\n [formControl]=\"_control\"\n [placeholder]=\"placeholder\"\n [disableRichText]=\"true\"\n [rows]=\"2.7\"\n [resizable]=\"false\"\n (keydown.enter)=\"_onEnterKey($event)\"\n ></seam-rich-text>\n </seam-form-field>\n <button\n seamButton\n theme=\"primary\"\n class=\"seam-chat-send-btn\"\n [disabled]=\"disabled || _control.invalid\"\n (click)=\"_onSend()\"\n >\n Send\n </button>\n </div>\n `,\n styles: [\n `\n .seam-chat-input {\n display: flex;\n align-items: flex-end;\n gap: 8px;\n padding: 8px;\n border-top: 1px solid #dee2e6;\n }\n\n seam-form-field {\n flex: 1;\n }\n\n .seam-chat-send-btn {\n flex-shrink: 0;\n }\n `,\n ],\n})\nexport class SeamChatInputComponent {\n @Input() placeholder = 'Type a message...'\n @Input() disabled = false\n\n @Output() messageSent = new EventEmitter<string>()\n\n readonly _control = new FormControl<string>('', [Validators.required])\n\n _onEnterKey(event: Event) {\n const keyEvent = event as KeyboardEvent\n if (keyEvent.shiftKey) {\n return\n }\n keyEvent.preventDefault()\n this._onSend()\n }\n\n _onSend() {\n const value = this._control.value?.trim()\n if (!value || this.disabled) {\n return\n }\n this.messageSent.emit(value)\n this._control.reset()\n }\n\n /**\n * Restores the given text into the input control. Called by the parent\n * chat component during stale-leaf recovery so the user can edit and\n * resend their message after the conversation is refreshed.\n */\n restoreText(text: string): void {\n this._control.setValue(text)\n }\n}\n","import {\n AfterViewInit,\n ChangeDetectionStrategy,\n ChangeDetectorRef,\n Component,\n effect,\n ElementRef,\n inject,\n input,\n NgZone,\n OnDestroy,\n output,\n ViewChild,\n} from '@angular/core'\nimport { AsyncPipe } from '@angular/common'\nimport { BehaviorSubject, EMPTY, Observable, of, Subject } from 'rxjs'\nimport { catchError, switchMap, takeUntil, tap } from 'rxjs/operators'\n\nimport { TheSeamOverlayScrollbarDirective } from '@theseam/ui-common/scrollbar'\n\nimport {\n ChatMessage,\n ChatSession,\n ChatSessionStaleError,\n} from '../providers/ai-provider'\nimport { THESEAM_CHAT_PROVIDER } from './chat-provider'\nimport { TheSeamChatContextRegistry } from '../chat-context-registry.service'\nimport { parseChatResponse } from './chat-response-parser'\nimport {\n ChatMessageDisplayModel,\n SeamChatMessageComponent,\n} from './chat-message.component'\nimport { SeamChatInputComponent } from './chat-input.component'\n\n@Component({\n selector: 'seam-chat',\n imports: [\n AsyncPipe,\n SeamChatMessageComponent,\n SeamChatInputComponent,\n TheSeamOverlayScrollbarDirective,\n ],\n templateUrl: './chat.component.html',\n styleUrls: ['./chat.component.scss'],\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class TheSeamChatComponent implements AfterViewInit, OnDestroy {\n private readonly _provider = inject(THESEAM_CHAT_PROVIDER, { optional: true })\n private readonly _chatContextRegistry = inject(TheSeamChatContextRegistry, {\n optional: true,\n })\n private readonly _cdr = inject(ChangeDetectorRef)\n private readonly _ngZone = inject(NgZone)\n\n @ViewChild('messageList') private _messageList?: ElementRef<HTMLElement>\n @ViewChild(TheSeamOverlayScrollbarDirective)\n private _messageListScrollbar?: TheSeamOverlayScrollbarDirective\n @ViewChild(SeamChatInputComponent) private _chatInput?: SeamChatInputComponent\n\n /**\n * The session this chat should display.\n *\n * - `null` on first init: the component asks the provider for an initial\n * session via `getInitialSession()` (default app behavior: prefers\n * `?chatSession=<uid>`, falls back to the user's most recent session).\n * - `null` after init: resets to a new empty chat. Equivalent to calling\n * `newSession()`.\n * - A session uid: loads and displays that session.\n *\n * Pair with `(sessionIdChange)` for two-way binding.\n */\n readonly sessionId = input<string | null>(null)\n\n readonly placeholder = input<string>('Type a message...')\n\n /**\n * Emits whenever the chat's active session changes — after the initial\n * load resolves, after a send creates a new session, after the input is\n * reassigned, or after `newSession()` clears the chat.\n */\n readonly sessionIdChange = output<string | null>()\n\n /**\n * Emits after the chat has recovered from a server-reported stale-leaf\n * 409. The component has already reloaded the session and restored the\n * user's typed text; consuming apps typically respond by surfacing a toast.\n */\n readonly staleSession = output<void>()\n\n // Internal conversation state — same as before, just relocated for clarity.\n private _messages: ChatMessage[] = []\n _displayMessages: ChatMessageDisplayModel[] = []\n\n // Pixels of slack allowed when deciding if the viewport is \"at the bottom\".\n private readonly _pinnedThreshold = 32\n private _isPinnedToBottom = true\n private _forceScrollOnNextResize = false\n\n private readonly _loadingSubject = new BehaviorSubject<boolean>(false)\n readonly loading$ = this._loadingSubject.asObservable()\n\n private _currentSessionId: string | null = null\n private _currentLeafMessageId: string | null = null\n private _initialized = false\n\n private readonly _sessionLoadRequest$ = new Subject<\n Observable<ChatSession | null>\n >()\n private readonly _destroy$ = new Subject<void>()\n\n private readonly _initialLoadingSubject = new BehaviorSubject<boolean>(false)\n readonly initialLoading$ = this._initialLoadingSubject.asObservable()\n\n constructor() {\n this._sessionLoadRequest$\n .pipe(\n tap(() =>\n this._initialLoadingSubject.next(this._messages.length === 0),\n ),\n switchMap((load$) =>\n load$.pipe(\n catchError((err) => {\n console.error('Chat session load failed:', err)\n return of(null)\n }),\n ),\n ),\n takeUntil(this._destroy$),\n )\n .subscribe((session) => {\n this._initialLoadingSubject.next(false)\n if (session) {\n const wasNoSession = this._currentSessionId === null\n this._applySession(session)\n if (wasNoSession) {\n this.sessionIdChange.emit(session.uid)\n }\n }\n this._cdr.markForCheck()\n })\n\n effect(() => {\n const incoming = this.sessionId()\n if (!this._initialized) {\n this._initialize(incoming)\n } else {\n this._reactToSessionInputChange(incoming)\n }\n })\n }\n\n ngAfterViewInit() {\n const scrollInstance = this._messageListScrollbar?.instance\n if (!scrollInstance) {\n return\n }\n this._ngZone.runOutsideAngular(() => {\n scrollInstance.options({\n callbacks: {\n onScroll: () => this._updatePinnedState(),\n onContentSizeChanged: () => this._maybeScrollToBottom(),\n },\n })\n })\n }\n\n ngOnDestroy() {\n this._destroy$.next()\n this._destroy$.complete()\n }\n\n /**\n * Resets the chat to a new empty session. Idempotent — safe to call when\n * the chat has no session loaded. Emits `(sessionIdChange)` with `null`.\n */\n newSession(): void {\n // Push EMPTY through the load pipeline so switchMap cancels any\n // in-flight session load before we clear state.\n this._sessionLoadRequest$.next(EMPTY)\n this._currentSessionId = null\n this._currentLeafMessageId = null\n this._messages = []\n this._displayMessages = []\n this._loadingSubject.next(false)\n this._initialLoadingSubject.next(false)\n this.sessionIdChange.emit(null)\n this._cdr.markForCheck()\n }\n\n async _onMessageSent(text: string): Promise<void> {\n if (this._loadingSubject.value) return\n if (!this._provider) {\n console.error('No chat provider configured.')\n return\n }\n\n const userMessage: ChatMessage = { role: 'user', content: text }\n this._messages.push(userMessage)\n this._displayMessages = [\n ...this._displayMessages,\n {\n role: 'user',\n segments: [{ type: 'markdown', content: text }],\n timestamp: new Date(),\n },\n ]\n this._forceScrollOnNextResize = true\n this._loadingSubject.next(true)\n this._cdr.markForCheck()\n\n const contexts = (await this._chatContextRegistry?.snapshot()) ?? []\n this._provider\n .chat({\n messages: this._messages,\n contexts: contexts.length === 0 ? undefined : contexts,\n sessionId: this._currentSessionId,\n expectedLeafMessageId: this._currentLeafMessageId,\n })\n .pipe(takeUntil(this._destroy$))\n .subscribe({\n next: (response) => {\n this._messages.push({ role: 'assistant', content: response.content })\n this._displayMessages = [\n ...this._displayMessages,\n {\n role: 'assistant',\n segments: parseChatResponse(response.content),\n timestamp: new Date(),\n },\n ]\n const wasNoSession = this._currentSessionId === null\n this._currentSessionId = response.sessionId\n this._currentLeafMessageId = response.leafMessageId\n if (wasNoSession) {\n this.sessionIdChange.emit(response.sessionId)\n }\n this._loadingSubject.next(false)\n this._cdr.markForCheck()\n },\n error: (err) => {\n if (err instanceof ChatSessionStaleError) {\n this._handleStaleSession(text)\n } else {\n console.error('Chat provider error:', err)\n this._loadingSubject.next(false)\n this._cdr.markForCheck()\n }\n },\n })\n }\n\n private _updatePinnedState() {\n const scrollInstance = this._messageListScrollbar?.instance\n if (!scrollInstance) {\n return\n }\n const info = scrollInstance.scroll()\n this._isPinnedToBottom =\n info.position.y >= info.max.y - this._pinnedThreshold\n }\n\n private _maybeScrollToBottom() {\n if (this._forceScrollOnNextResize || this._isPinnedToBottom) {\n this._scrollToBottom()\n this._forceScrollOnNextResize = false\n }\n }\n\n private _scrollToBottom() {\n const scrollInstance = this._messageListScrollbar?.instance\n if (scrollInstance) {\n const state = scrollInstance.getState()\n scrollInstance.scroll({ y: state.contentScrollSize.height })\n }\n }\n\n private _initialize(incoming: string | null): void {\n this._initialized = true\n if (!this._provider) {\n console.error('No chat provider configured.')\n return\n }\n if (incoming) {\n this._sessionLoadRequest$.next(this._provider.getSession(incoming))\n } else {\n this._sessionLoadRequest$.next(this._provider.getInitialSession())\n }\n }\n\n private _reactToSessionInputChange(incoming: string | null): void {\n if (incoming === this._currentSessionId) return\n if (!this._provider) {\n console.error('No chat provider configured.')\n return\n }\n if (incoming === null) {\n this.newSession()\n return\n }\n this._sessionLoadRequest$.next(this._provider.getSession(incoming))\n }\n\n private _applySession(session: ChatSession): void {\n this._currentSessionId = session.uid\n this._currentLeafMessageId = session.leafMessageId\n this._messages = session.messages.map((m) => ({\n role: m.role,\n content: m.content,\n }))\n this._displayMessages = session.messages.map((m) => ({\n uid: m.uid,\n role: m.role,\n segments:\n m.role === 'assistant'\n ? parseChatResponse(m.content)\n : [{ type: 'markdown', content: m.content }],\n timestamp: new Date(m.created),\n }))\n this._forceScrollOnNextResize = true\n }\n\n private _handleStaleSession(originalText: string): void {\n const sessionId = this._currentSessionId\n if (!sessionId || !this._provider) {\n this._loadingSubject.next(false)\n this._cdr.markForCheck()\n return\n }\n this._provider\n .getSession(sessionId)\n .pipe(takeUntil(this._destroy$))\n .subscribe({\n next: (reloaded) => {\n this._applySession(reloaded)\n this._chatInput?.restoreText(originalText)\n this._loadingSubject.next(false)\n this.staleSession.emit()\n this._cdr.markForCheck()\n },\n error: (reloadErr) => {\n console.error(\n 'Chat session reload failed during stale-leaf recovery:',\n reloadErr,\n )\n this._chatInput?.restoreText(originalText)\n this._loadingSubject.next(false)\n this.staleSession.emit()\n this._cdr.markForCheck()\n },\n })\n }\n}\n","<div class=\"seam-chat\">\n <div class=\"seam-chat__messages\" #messageList seamOverlayScrollbar>\n @if (initialLoading$ | async) {\n <div class=\"seam-chat__initial-loading\">\n <span>Loading…</span>\n </div>\n } @else {\n @for (msg of _displayMessages; track $index) {\n <seam-chat-message [message]=\"msg\"></seam-chat-message>\n }\n\n @if (loading$ | async) {\n <div class=\"seam-chat__loading\">\n <span>Thinking...</span>\n </div>\n }\n }\n </div>\n\n <seam-chat-input\n [placeholder]=\"placeholder()\"\n [disabled]=\"!!(loading$ | async) || !!(initialLoading$ | async)\"\n (messageSent)=\"_onMessageSent($event)\"\n ></seam-chat-input>\n</div>\n","import { ComponentHarness } from '@angular/cdk/testing'\n\nexport class TheSeamChatMessageHarness extends ComponentHarness {\n static hostSelector = 'seam-chat-message'\n\n private readonly _role = this.locatorForOptional('.seam-chat-message__role')\n private readonly _content = this.locatorForOptional(\n '.seam-chat-message__content',\n )\n\n async getRole(): Promise<string> {\n const roleEl = await this._role()\n const text = await roleEl?.text()\n return text?.trim().toLowerCase() ?? ''\n }\n\n async getText(): Promise<string> {\n const contentEl = await this._content()\n return (await contentEl?.text())?.trim() ?? ''\n }\n}\n\nexport class TheSeamChatInputHarness extends ComponentHarness {\n static hostSelector = 'seam-chat-input'\n\n async getSendButton() {\n return this.locatorFor('button')()\n }\n\n async isSendDisabled(): Promise<boolean> {\n const btn = await this.getSendButton()\n return (await btn.getAttribute('disabled')) !== null\n }\n}\n\nexport class TheSeamChatHarness extends ComponentHarness {\n static hostSelector = 'seam-chat'\n\n private readonly _messages = this.locatorForAll(TheSeamChatMessageHarness)\n private readonly _input = this.locatorFor(TheSeamChatInputHarness)\n private readonly _loading = this.locatorForOptional('.seam-chat__loading')\n private readonly _initialLoading = this.locatorForOptional(\n '.seam-chat__initial-loading',\n )\n\n async getMessages(): Promise<TheSeamChatMessageHarness[]> {\n return this._messages()\n }\n\n async getMessageCount(): Promise<number> {\n return (await this._messages()).length\n }\n\n async getInput(): Promise<TheSeamChatInputHarness> {\n return this._input()\n }\n\n async isLoading(): Promise<boolean> {\n return (await this._loading()) !== null\n }\n\n async isInitialLoading(): Promise<boolean> {\n return (await this._initialLoading()) !== null\n }\n}\n","import { InjectionToken } from '@angular/core'\n\nimport { TheSeamAiProvider } from '../providers/ai-provider'\n\nexport const assistantPrompt = `You are a helpful assistant that provides formatting json code for a datatable.\nA datatable is a table that displays data in rows and columns, similar to a spreadsheet, with column sorting and data filtering.\n\nYour job is not to provide a descriptive analysis of the request or any additional information. The user will ignore anything that is not a JSON object.\n\nThe user will provide a request, and you will respond with a JSON object that contains an array of table alterations.\nThe following is the typescript interface for a datatable column and the alterations you can make to it:\n\n\\`\\`\\`typescript\ninterface TableColumn {\n /** Column property */\n prop: string,\n /** Column name */\n name: string,\n /** Column cell type - determines filter type */\n cellType?: 'string' | 'integer' | 'decimal' | 'currency' | 'date' | 'phone',\n /** Whether the column is sortable */\n sortable?: boolean,\n /** Whether the column is filterable */\n filterable?: boolean,\n /** Whether the column is visible */\n visible?: boolean,\n /** Whether the column is resizable */\n resizable?: boolean,\n /** Whether the column is draggable */\n draggable?: boolean,\n /** Column width */\n width?: number,\n /** Column index */\n index?: number,\n}\n\ninterface SortItem {\n /** Column property */\n prop: string,\n /** Sort direction */\n dir: 'asc' | 'desc'\n}\n\ninterface SortState {\n /** The list of sorts */\n sorts: SortItem[]\n}\n\ninterface OrderRecord {\n /** Column property */\n columnProp: string,\n /** Column order, which is the index that it will be placed in the columns array. */\n index: number\n}\n\ninterface OrderState {\n /** The list of column order records */\n columns: OrderRecord[]\n}\n\ninterface WidthState {\n /** The column property that this width alteration applies to */\n columnProp: string\n /** The width of the column. Number is in pixels. */\n width?: number\n /** Whether the column can auto resize. Needs to be false to guarantee a specific width. */\n canAutoResize: boolean\n}\n\ninterface HideColumnState {\n /** The column property that this alteration applies to */\n columnProp: string\n /** Whether the column is hidden */\n hidden: boolean\n}\n\ninterface FilterState {\n /** The column property that this filter applies to */\n columnProp: string,\n /** The filter type based on column cellType */\n filterType: 'text' | 'numeric' | 'date',\n /** The filter operation */\n operation: string,\n /** The filter value (for single value operations) */\n value?: any,\n /** The from value (for range operations like 'between') */\n fromValue?: any,\n /** The to value (for range operations like 'between') */\n toValue?: any\n}\n\ninterface TableAlteration<TType extends string, TState> {\n /**\n * Unique identifier for the alteration.\n */\n id: string\n /**\n * The type of alteration.\n */\n type: TType\n /** The alteration state */\n state: TState\n}\n\n/**\n * Sort alteration for a datatable.\n * \"id\" should always be \"sort\" for this alteration.\n */\ntype SortAlteration = TableAlteration<'sort', SortState>\n\n/**\n * Order alteration for a datatable column.\n *\n * \"id\" should always be \"order\" for this alteration.\n */\ntype OrderAlteration = TableAlteration<'order', OrderState>\n\n/**\n * Width alteration for a datatable column.\n *\n * \"id\" should always be \"width-<prop>\" for this alteration. So, for example, if the column property is \"name\", the id would be \"width-name\".\n */\ntype WidthAlteration = TableAlteration<'width', WidthState>\n\n/**\n * Hide column alteration for a datatable column.\n *\n * \"id\" should always be \"hide-column-<prop>\" for this alteration. So, for example, if the column property is \"name\", the id would be \"hide-column-name\".\n */\ntype HideColumnAlteration = TableAlteration<'hide-column', HideColumnState>\n\n/**\n * Filter alteration for a datatable column.\n * \"id\" should be \"filter--<columnProp>\" for this alteration.\n * For example, if filtering the \"age\" column, the id would be \"filter--age\".\n */\ntype FilterAlteration = TableAlteration<'filter', FilterState>\n\\`\\`\\`\n\n## Filter Operations by Type\n\n### Text Filters (cellType: 'string', 'phone')\n- 'contains': Text contains the value (case-insensitive)\n- 'eq': Text equals the value exactly\n- 'neq': Text does not equal the value\n- 'ncontains': Text does not contain the value\n- 'blank': Field is empty/null\n- 'not-blank': Field is not empty/null\n\n### Numeric Filters (cellType: 'integer', 'decimal', 'currency')\n- 'eq': Equals the value\n- 'gt': Greater than the value\n- 'gte': Greater than or equal to the value\n- 'lt': Less than the value\n- 'lte': Less than or equal to the value\n- 'between': Between fromValue and toValue (inclusive)\n- 'not-between': Not between fromValue and toValue\n- 'blank': Field is empty/null\n- 'not-blank': Field is not empty/null\n\n### Date Filters (cellType: 'date')\n- 'eq': Date equals the value\n- 'gt': Date is after the value\n- 'gte': Date is on or after the value\n- 'lt': Date is before the value\n- 'lte': Date is on or before the value\n- 'between': Date is between fromValue and toValue (inclusive)\n- 'not-between': Date is not between fromValue and toValue\n- 'blank': Field is empty/null\n- 'not-blank': Field is not empty/null\n\n## Examples\n\nFilter age greater than 30:\n\\`\\`\\`json\n{\n \"id\": \"filter--age\",\n \"type\": \"filter\",\n \"state\": {\n \"columnProp\": \"age\",\n \"filterType\": \"numeric\",\n \"operation\": \"gt\",\n \"value\": 30\n }\n}\n\\`\\`\\`\n\nFilter color contains \"red\":\n\\`\\`\\`json\n{\n \"id\": \"filter--color\",\n \"type\": \"filter\",\n \"state\": {\n \"columnProp\": \"color\",\n \"filterType\": \"text\",\n \"operation\": \"contains\",\n \"value\": \"red\"\n }\n}\n\\`\\`\\`\n\nFilter age between 25 and 65:\n\\`\\`\\`json\n{\n \"id\": \"filter--age\",\n \"type\": \"filter\",\n \"state\": {\n \"columnProp\": \"age\",\n \"filterType\": \"numeric\",\n \"operation\": \"between\",\n \"fromValue\": 25,\n \"toValue\": 65\n }\n}\n\\`\\`\\`\n\nSort by name ascending:\n\\`\\`\\`json\n{\n \"id\": \"sort\",\n \"type\": \"sort\",\n \"state\": {\n \"sorts\": [\n {\n \"prop\": \"name\",\n \"dir\": \"asc\"\n }\n ]\n }\n}\n\\`\\`\\`\n\nHide the age column:\n\\`\\`\\`json\n{\n \"id\": \"hide-column-age\",\n \"type\": \"hide-column\",\n \"state\": {\n \"columnProp\": \"age\",\n \"hidden\": true\n }\n}\n\\`\\`\\`\n\nSet name column width to 300 pixels:\n\\`\\`\\`json\n{\n \"id\": \"width-name\",\n \"type\": \"width\",\n \"state\": {\n \"columnProp\": \"name\",\n \"width\": 300,\n \"canAutoResize\": false\n }\n}\n\\`\\`\\`\n\nReorder columns (name first, age second, color third):\n\\`\\`\\`json\n{\n \"id\": \"order\",\n \"type\": \"order\",\n \"state\": {\n \"columns\": [\n { \"columnProp\": \"name\", \"index\": 0 },\n { \"columnProp\": \"age\", \"index\": 1 },\n { \"columnProp\": \"color\", \"index\": 2 }\n ]\n }\n}\n\\`\\`\\`\n`\n\nexport const getUserPrompt = (columns: any[], request: string): string => `\nColumns:\n\\`\\`\\`json\n${JSON.stringify(columns, null, 2)}\n\\`\\`\\`\nRequest: \"${request}\"\n`\n\nexport function parseResponse(\n responseContent: string,\n responseFormat: { type: string } | undefined,\n) {\n if (responseFormat?.type === 'json_object') {\n return JSON.parse(responseContent)\n }\n\n // Parse the JSON string to an object, which is in the string between the code blocks.\n // So, need to find the first and last code block markers.\n const startIndex = responseContent.indexOf('```json') + '```json'.length\n const endIndex = responseContent.lastIndexOf('```')\n const alterations = responseContent.substring(startIndex, endIndex).trim()\n // console.log('Alterations:', alterations)\n\n return JSON.parse(alterations)\n}\n\nexport const THESEAM_DATATABLE_PROMPTER_PROVIDER =\n new InjectionToken<TheSeamAiProvider>('TheSeamDatatablePrompterProvider')\n","import { ChangeDetectorRef, Component, inject, Input } from '@angular/core'\nimport { AsyncPipe, JsonPipe, NgForOf, NgIf } from '@angular/common'\nimport {\n FormControl,\n FormGroup,\n ReactiveFormsModule,\n Validators,\n} from '@angular/forms'\n\nimport {\n BehaviorSubject,\n combineLatest,\n firstValueFrom,\n map,\n Observable,\n of,\n shareReplay,\n startWith,\n switchMap,\n tap,\n} from 'rxjs'\nimport {\n ColumnsAlterationState,\n DatatableComponent,\n DatatablePreferencesService,\n EMPTY_DATATABLE_PREFERENCES,\n mapColumnsAlterationsStates,\n THESEAM_DATATABLE_PREFERENCES_ACCESSOR,\n} from '@theseam/ui-common/datatable'\nimport { TheSeamLoadingModule } from '@theseam/ui-common/loading'\nimport { TheSeamRichTextModule } from '@theseam/ui-common/rich-text'\nimport { TheSeamFormFieldModule } from '@theseam/ui-common/form-field'\nimport { TheSeamButtonsModule } from '@theseam/ui-common/buttons'\nimport {\n AlterationDisplayItem,\n AlterationsDiffComponent,\n} from '@theseam/ui-common/datatable-alterations-display'\n\nimport {\n assistantPrompt,\n getUserPrompt,\n parseResponse,\n THESEAM_DATATABLE_PROMPTER_PROVIDER,\n} from './datatable-prompter-prompt-provider'\n\n@Component({\n selector: 'seam-datatable-prompter',\n templateUrl: './datatable-prompter.component.html',\n styleUrls: ['./datatable-prompter.component.scss'],\n imports: [\n ReactiveFormsModule,\n AsyncPipe,\n JsonPipe,\n NgForOf,\n NgIf,\n TheSeamLoadingModule,\n TheSeamRichTextModule,\n TheSeamFormFieldModule,\n TheSeamButtonsModule,\n AlterationsDiffComponent,\n ],\n})\nexport class TheSeamDatatablePrompterComponent {\n // cdr = inject(ChangeDetectorRef)\n\n private readonly _prefsAccessor = inject(\n THESEAM_DATATABLE_PREFERENCES_ACCESSOR,\n { optional: true },\n )\n private readonly _dtPrefsService = inject(DatatablePreferencesService)\n private readonly _aiProvider = inject(THESEAM_DATATABLE_PROMPTER_PROVIDER, {\n optional: true,\n })\n\n readonly _loadingSubject = new BehaviorSubject<boolean>(false)\n readonly _altsDataSubject = new BehaviorSubject<\n | {\n currentItems: AlterationDisplayItem[]\n pendingItems: AlterationDisplayItem[]\n }\n | undefined\n >(undefined)\n\n public readonly loading$ = this._loadingSubject.asObservable()\n\n @Input() diffMode: 'auto' | 'manual' = 'auto'\n @Input() compact = true\n\n @Input()\n set prompt(value: string | undefined | null) {\n if (value) {\n this._form.controls.prompt.setValue(value)\n } else {\n this._form.controls.prompt.setValue('Sort color descending order')\n }\n }\n\n @Input()\n set datatable(value: DatatableComponent | undefined | null) {\n this._datatableSubject.next(value)\n }\n get datatable(): DatatableComponent | undefined | null {\n return this._datatableSubject.value\n }\n private _datatableSubject = new BehaviorSubject<\n DatatableComponent | undefined | null\n >(null)\n\n @Input() showAlts = true\n\n readonly _form = new FormGroup({\n prompt: new FormControl<string | null>('Sort color descending order', [\n Validators.required,\n ]),\n })\n\n _alterations$: Observable<ColumnsAlterationState[]> = this._datatableSubject\n .asObservable()\n .pipe(\n switchMap((dt): Observable<DatatableComponent | null | undefined> => {\n if (!dt) {\n return of(dt)\n }\n return (dt as any)._columnsAlterationsManager.changes.pipe(\n startWith(undefined),\n map(() => dt),\n )\n }),\n switchMap((datatable) => {\n if (!datatable) {\n return of([] as ColumnsAlterationState[])\n }\n const key = datatable.preferencesKey\n if (!key) {\n // eslint-disable-next-line no-console\n console.warn(\n 'No preferences key set on datatable, returning empty alterations.',\n )\n return of([] as ColumnsAlterationState[])\n }\n\n return (\n this._dtPrefsService.preferences(key).pipe(\n switchMap((prefs) => {\n // console.log('~~~~Current preferences:', prefs)\n if (!prefs) {\n return of(\n JSON.parse(JSON.stringify(EMPTY_DATATABLE_PREFERENCES))\n .alterations as ColumnsAlterationState[],\n )\n }\n // return of(JSON.parse(prefs).alterations as ColumnsAlterationState[])\n return of(prefs.alterations as ColumnsAlterationState[])\n }),\n ) ?? of([] as ColumnsAlterationState[])\n )\n }),\n // tap(v => console.log('%cAlterations:', 'color: limegreen;', v)),\n )\n\n _alterationsDisplayItems$: Observable<AlterationDisplayItem[]> =\n this._alterations$.pipe(\n switchMap((alterations) => {\n console.log('~~~~~Current alterations:', alterations)\n if (!alterations || alterations.length === 0) {\n return of([] as AlterationDisplayItem[])\n }\n const alts = mapColumnsAlterationsStates(alterations)\n console.log('~~~~~Mapped alterations:', alts)\n return of(alts.map((a) => a.toDisplayItem()))\n }),\n shareReplay({ bufferSize: 1, refCount: true }),\n )\n\n _pendingAlterationsSubject = new BehaviorSubject<ColumnsAlterationState[]>([])\n _pendingAlterationsDisplayItems$: Observable<AlterationDisplayItem[]> =\n this._pendingAlterationsSubject.asObservable().pipe(\n switchMap((pending) => {\n if (!pending || pending.length === 0) {\n return of([] as AlterationDisplayItem[])\n }\n const alts = mapColumnsAlterationsStates(pending)\n console.log('~~~~~Mapped alterations2:', alts)\n return of(alts.map((a) => a.toDisplayItem()))\n }),\n shareReplay({ bufferSize: 1, refCount: true }),\n )\n\n _onSubmit() {\n console.log('Submitting prompt:', this._form.value)\n if (this._form.invalid) {\n return\n }\n if (this._loadingSubject.value) {\n console.warn('Already loading, ignoring submit.')\n return\n }\n\n const prompt = this._form.value.prompt\n if (!prompt) {\n return\n }\n console.log('datatable', this._datatableSubject.value)\n const columns = (\n this._datatableSubject.value?.ngxDatatable?.columns || []\n ).map((col) => ({\n prop: col.prop,\n name: col.name,\n cellType: (col as any).cellType || 'string',\n sortable: col.sortable,\n filterable: true,\n visible: true,\n resizable: col.resizeable,\n draggable: col.draggable,\n }))\n\n console.log('columns', columns)\n const userPrompt = getUserPrompt(columns, prompt)\n console.log('userPrompt', userPrompt)\n\n this._loadingSubject.next(true)\n if (!this._aiProvider) {\n console.error('No AI provider configured, cannot submit prompt.')\n this._loadingSubject.next(false)\n return\n }\n firstValueFrom(\n this._aiProvider.chat({\n messages: [\n {\n role: 'user',\n content: `${assistantPrompt}\\n\\n---\\n\\n${userPrompt}`,\n },\n ],\n }),\n )\n .then(async (response) => {\n const alterations = parseResponse(response.content, undefined)\n // this._form.reset()\n console.log('Received alterations:', alterations)\n const datatable = this._datatableSubject.value\n if (!datatable) {\n console.error('No datatable found to apply alterations to.')\n return\n }\n\n const key = this.datatable!.preferencesKey as string\n\n const before = await this._prefsAccessor?.get(key).toPromise()\n console.log('Current preferences before update:', before)\n\n const _apply = async () => {\n console.log('Preferences updated successfully.')\n const _cols = this.datatable!.ngxDatatable!.columns\n const cols = [..._cols]\n console.log('this.datatable!.columns', cols)\n\n const after = await this._prefsAccessor?.get(key).toPromise()\n let _after = (JSON.parse(after || '{}').alterations ||\n []) as ColumnsAlterationState[]\n if (!Array.isArray(_after)) {\n _after = [_after]\n }\n\n const mgr = (this.datatable as any)._columnsAlterationsManager\n console.log('_columnsAlterationsManager', mgr, mgr.get())\n const alts = mapColumnsAlterationsStates(_after)\n console.log('Mapped alterations:', alts)\n const columnsBefore = JSON.parse(\n JSON.stringify(\n this.datatable!.ngxDatatable!.columns.map((x) => x.prop),\n ),\n )\n console.log('Columns before applying alterations:', columnsBefore)\n for (const a of alts) {\n console.log('Applying alteration:', a)\n a.apply(cols, this.datatable!)\n }\n console.log('Current preferences after update:', after)\n console.log(_after)\n\n this.datatable!.columns = [...cols]\n const columnsAfter = JSON.parse(\n JSON.stringify(\n this.datatable!.ngxDatatable!.columns.map((x) => x.prop),\n ),\n )\n console.log('Columns after applying alterations:', columnsAfter)\n mgr.add(alts)\n datatable._cdr.detectChanges()\n\n this._pendingAlterationsSubject.next(_after)\n }\n\n this._prefsAccessor\n ?.update(\n key,\n JSON.stringify({\n version: 2,\n alterations,\n }),\n )\n .subscribe(async () => {\n // TODO: Cleanup. This is a hack to ensure the datatable updates after the preferences are set.\n await _apply()\n datatable.rows = [...datatable.rows]\n datatable._cdr.detectChanges()\n await _apply()\n\n this._loadingSubject.next(false)\n })\n })\n .catch((err) => {\n console.error('Error submitting prompt:', err)\n this._loadingSubject.next(false)\n })\n }\n}\n","<div class=\"d-block border rounded border-lightgray\">\n <div\n [formGroup]=\"_form\"\n (ngSubmit)=\"_onSubmit()\"\n class=\"d-block position-relative\"\n >\n <div>\n <div class=\"p-1\">\n <!-- <textarea formControlName=\"prompt\" style=\"width: 800px; height: 100px;\"></textarea> -->\n <seam-form-field [numPaddingErrors]=\"0\">\n <seam-rich-text\n seamInput\n formControlName=\"prompt\"\n placeholder=\"Describe what you want to apply to the datatable.\"\n [rows]=\"3\"\n [resizable]=\"false\"\n [disableRichText]=\"true\"\n ></seam-rich-text>\n </seam-form-field>\n </div>\n <div class=\"p-1\">\n <button\n class=\"mr-1\"\n type=\"submit\"\n seamButton\n theme=\"primary\"\n size=\"sm\"\n (click)=\"_onSubmit()\"\n >\n Submit\n </button>\n <button seamButton theme=\"lightgray\" size=\"sm\" (click)=\"_form.reset()\">\n Reset\n </button>\n </div>\n </div>\n <div\n *ngIf=\"loading$ | async\"\n class=\"d-block position-absolute\"\n style=\"top: 0; left: 0; right: 0; bottom: 0\"\n >\n <seam-loading></seam-loading>\n </div>\n </div>\n\n <div class=\"p-2\" *ngIf=\"showAlts\">\n <div>Active Alterations</div>\n <div class=\"p-2 border rounded bg-lightgray\">\n <!-- {{ _alterations$ | async | json }} -->\n <div *ngFor=\"let alteration of _alterations$ | async; let last = last\">\n <div\n class=\"d-flex align-items-center border border-dark rounded p-1\"\n [class.mb-1]=\"!last\"\n >\n <span class=\"badge bg-secondary\">{{ alteration.type }}</span>\n <!-- <span class=\"badge bg-primary\">{{ alteration.label }}</span> -->\n <!-- <div>\n {{ alteration.value | json }}\n </div> -->\n <div *ngIf=\"alteration.type === 'sort'\">\n <div class=\"d-flex flex-column\">\n <div\n *ngFor=\"let sort of alteration.state.sorts; let last = last\"\n [class.mb-1]=\"!last\"\n >\n <span class=\"badge bg-lightgray\"\n >{{ sort.prop }} ({{ sort.dir }})</span\n >\n </div>\n </div>\n </div>\n </div>\n </div>\n </div>\n <seam-alterations-diff\n [currentItems]=\"(_alterationsDisplayItems$ | async) ?? []\"\n [pendingItems]=\"(_pendingAlterationsDisplayItems$ | async) ?? []\"\n [compact]=\"compact\"\n [diffMode]=\"diffMode\"\n ></seam-alterations-diff>\n </div>\n</div>\n","// Shared providers\nexport {\n ChatMessage,\n ChatResponse,\n ChatSession,\n ChatSessionListItem,\n ChatSessionMessage,\n ChatSessionStaleError,\n TheSeamAiChatRequest,\n TheSeamAiProvider,\n} from './providers/ai-provider'\nexport { LmStudioAiProvider } from './providers/lm-studio.ai-provider'\nexport { OpenRouterAiProvider } from './providers/openrouter.ai-provider'\nexport {\n MockAiProvider,\n MockAiProviderConfig,\n} from './providers/mock.ai-provider'\n\n// Context registry\nexport { TheSeamChatContext, TheSeamChatContextPayload } from './chat-context'\nexport { TheSeamChatContextRegistry } from './chat-context-registry.service'\nexport {\n TheSeamDatatableChatContext,\n TheSeamDatatableChatContextOptions,\n TheSeamDatatableChatContextData,\n} from './contexts/datatable-chat-context'\n\n// Chat\nexport { TheSeamChatComponent } from './chat/chat.component'\nexport { THESEAM_CHAT_PROVIDER } from './chat/chat-provider'\nexport {\n ChatBlockRegistry,\n THESEAM_CHAT_BLOCK_REGISTRY,\n} from './chat/chat-block-registry'\nexport {\n ChatContentSegment,\n parseChatResponse,\n} from './chat/chat-response-parser'\nexport { TheSeamChatHarness } from './chat/testing/chat.harness'\n\n// Datatable prompter\nexport {\n THESEAM_DATATABLE_PROMPTER_PROVIDER,\n assistantPrompt,\n getUserPrompt,\n parseResponse,\n} from './datatable-prompter/datatable-prompter-prompt-provider'\nexport { TheSeamDatatablePrompterComponent } from './datatable-prompter/datatable-prompter.component'\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["rxDelay","i4","switchMap","i2","i5"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA0DA;;;;;AAKG;AACG,MAAO,qBAAsB,SAAQ,KAAK,CAAA;AAE5B,IAAA,SAAA;AACA,IAAA,oBAAA;IAFlB,WAAA,CACkB,SAAiB,EACjB,oBAAmC,EAAA;QAEnD,KAAK,CAAC,4BAA4B,CAAC;QAHnB,IAAA,CAAA,SAAS,GAAT,SAAS;QACT,IAAA,CAAA,oBAAoB,GAApB,oBAAoB;AAGpC,QAAA,IAAI,CAAC,IAAI,GAAG,uBAAuB;IACrC;AACD;;MC9DY,kBAAkB,CAAA;AAC7B,IAAA,IAAI,CAAC,OAA6B,EAAA;QAChC,OAAO,KAAK,CAAC,MAAK;AAChB,YAAA,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE;AACxC,YAAA,MAAM,OAAO,GAAG,CAAC,YAAW;gBAC1B,MAAM,GAAG,GAAG,2CAA2C;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