@singlebase/elements 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -52,6 +52,10 @@ export interface SinglebaseChatMessages {
52
52
  restore: string;
53
53
  minimize: string;
54
54
  exportHeading: string;
55
+ viewOptions: string;
56
+ viewHeading: string;
57
+ viewFollowups: string;
58
+ viewSources: string;
55
59
  exportMarkdown: string;
56
60
  exportJson: string;
57
61
  exportText: string;
@@ -80,6 +84,7 @@ export interface SinglebaseChatMessages {
80
84
  sourceLabel: string;
81
85
  openSource: string;
82
86
  citedPassage: string;
87
+ passageCount: string;
83
88
  copyReference: string;
84
89
  alsoCited: string;
85
90
  close: string;
package/dist/chat.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chat-BWcGH9lr.cjs");Object.defineProperty(exports,"SinglebaseChat",{enumerable:!0,get:()=>e.SinglebaseChat});exports.adaptBlocks=e.adaptBlocks;exports.citedNumbers=e.citedNumbers;exports.defaultChatMessages=e.defaultChatMessages;exports.describeSource=e.describeSource;exports.parseInline=e.parseInline;exports.parseMarkdown=e.parseMarkdown;exports.resolveChatMessages=e.resolveChatMessages;exports.settleStreaming=e.settleStreaming;exports.splitFollowups=e.splitFollowups;exports.svgDataUrl=e.svgDataUrl;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chat-Bj6DrOaW.cjs");Object.defineProperty(exports,"SinglebaseChat",{enumerable:!0,get:()=>e.SinglebaseChat});exports.adaptBlocks=e.adaptBlocks;exports.citedNumbers=e.citedNumbers;exports.defaultChatMessages=e.defaultChatMessages;exports.describeSource=e.describeSource;exports.parseInline=e.parseInline;exports.parseMarkdown=e.parseMarkdown;exports.resolveChatMessages=e.resolveChatMessages;exports.settleStreaming=e.settleStreaming;exports.splitFollowups=e.splitFollowups;exports.svgDataUrl=e.svgDataUrl;
2
2
  //# sourceMappingURL=chat.cjs.map
package/dist/chat.js CHANGED
@@ -1,4 +1,4 @@
1
- import { S as e, a as r, c as t, d as l, b as o, p, e as d, r as g, s as i, f as c, g as n } from "./chat-t4o5FsxM.js";
1
+ import { S as e, a as r, c as t, d as l, b as o, p, e as d, r as g, s as i, f as c, g as n } from "./chat-DNiqYF6F.js";
2
2
  export {
3
3
  e as SinglebaseChat,
4
4
  r as adaptBlocks,
@@ -23,6 +23,8 @@ export type ChatClient = {
23
23
  export interface ChatSummary {
24
24
  _id: string;
25
25
  title: string | null;
26
+ /** The caller-chosen key this chat can also be opened by. */
27
+ key?: string | null;
26
28
  bookmarked?: boolean;
27
29
  message_count?: number;
28
30
  _created_at?: string;
@@ -97,6 +99,7 @@ export interface ChatConfig {
97
99
  client: ChatClient | null;
98
100
  /** Opens this saved chat. */
99
101
  chatId: string;
102
+ chatKey: string;
100
103
  embed: ChatEmbed;
101
104
  mode: ChatMode;
102
105
  format: ChatFormat;
@@ -135,6 +138,7 @@ export interface ChatConfig {
135
138
  saveAttachments: boolean;
136
139
  showFollowups: boolean;
137
140
  showSources: boolean;
141
+ allowViewOptions: boolean;
138
142
  showNewChat: boolean;
139
143
  showBookmarked: boolean;
140
144
  allowSearch: boolean;
@@ -151,6 +155,7 @@ export interface ChatConfig {
151
155
  /** A readable view of whatever shape the server recorded for a source. */
152
156
  export declare function describeSource(source: Record<string, unknown>, n: number): {
153
157
  n: number;
158
+ doc: string;
154
159
  title: string;
155
160
  section: string;
156
161
  path: string;
@@ -159,6 +164,20 @@ export declare function describeSource(source: Record<string, unknown>, n: numbe
159
164
  text: string;
160
165
  score: number | null;
161
166
  };
167
+ type DescribedSource = ReturnType<typeof describeSource>;
168
+ /** One document and the passages of it that a reply used. */
169
+ export interface SourceGroup {
170
+ doc: string;
171
+ /** The first passage: it supplies the title, path and preview. */
172
+ first: DescribedSource;
173
+ items: DescribedSource[];
174
+ }
175
+ /**
176
+ * Groups passages by the document they come from, keeping first-seen order.
177
+ * A file split into passages comes back as several numbered sources; shown one
178
+ * by one it looks like the same document repeated.
179
+ */
180
+ export declare function groupSources(sources: DescribedSource[]): SourceGroup[];
162
181
  /**
163
182
  * An AI chat workspace backed by the `llm.*` service.
164
183
  *
@@ -221,6 +240,11 @@ export declare class SinglebaseChat extends LitElement {
221
240
  accessor showBookmarked: boolean;
222
241
  /** Show the follow-up questions under the latest reply. */
223
242
  accessor showFollowups: boolean;
243
+ /**
244
+ * Adds a header menu where the reader can hide suggested questions and
245
+ * sources for a cleaner view. Their choice is remembered in this browser.
246
+ */
247
+ accessor allowViewOptions: boolean;
224
248
  /** The search box in the chat list. */
225
249
  accessor allowSearch: boolean;
226
250
  /** Replace the provisional title with a model-written one after the first reply. */
@@ -245,6 +269,12 @@ export declare class SinglebaseChat extends LitElement {
245
269
  accessor showTitle: boolean;
246
270
  /** Opens this chat on load. */
247
271
  accessor chatIdAttr: string;
272
+ /**
273
+ * A key of your own for this conversation, unique per signed-in user. The
274
+ * chat with this key is opened if there is one; otherwise the first message
275
+ * creates it, so the same key reopens it later. `chat-id` wins if both are set.
276
+ */
277
+ accessor chatKey: string;
248
278
  /** Used in placeholders, exports and labels. Never shown above messages. */
249
279
  accessor assistantName: string;
250
280
  accessor logoUrl: string;
@@ -254,7 +284,9 @@ export declare class SinglebaseChat extends LitElement {
254
284
  accessor eyebrow: string | undefined;
255
285
  /**
256
286
  * Suggested prompts: `|`-separated in markup, an array in JavaScript.
257
- * `"none"` or `[]` shows no suggestions.
287
+ * `"none"` or `[]` shows no suggestions. `"auto"` asks the service for
288
+ * starter questions drawn from the chat's context (`retrieval`, `docsets`
289
+ * and saved attachments); they're stored on the chat and reused on reload.
258
290
  */
259
291
  accessor prompts: string | (string | ChatPrompt)[];
260
292
  accessor bubbleText: string;
@@ -306,6 +338,9 @@ export declare class SinglebaseChat extends LitElement {
306
338
  private accessor width;
307
339
  private accessor panel;
308
340
  private accessor menuOpen;
341
+ private accessor viewOpen;
342
+ /** What the reader chose to hide, when `allow-view-options` lets them. */
343
+ private accessor viewHidden;
309
344
  private accessor editingKey;
310
345
  private accessor editDraft;
311
346
  private accessor editingTitle;
@@ -335,10 +370,22 @@ export declare class SinglebaseChat extends LitElement {
335
370
  private renamed;
336
371
  private observer;
337
372
  private observed;
373
+ private resizeTimer;
374
+ private shownPassage;
338
375
  private media;
339
376
  private focusNext;
340
377
  private bubbleScheduled;
341
378
  private pendingChatId;
379
+ /** Starter questions the service generated for this chat's context. */
380
+ private accessor starterList;
381
+ private accessor startersLoading;
382
+ /** The key the open conversation is created under, until the user leaves it. */
383
+ private boundKey;
384
+ /** The open chat was prepared but has no messages yet. */
385
+ private prepared;
386
+ private syncedKey;
387
+ private syncSignature;
388
+ private syncRun;
342
389
  get msg(): SinglebaseChatMessages;
343
390
  /** An explicit `.client`, else the page default. */
344
391
  get resolvedClient(): ChatClient | null;
@@ -346,6 +393,8 @@ export declare class SinglebaseChat extends LitElement {
346
393
  get chatId(): string | null;
347
394
  /** The open conversation's messages. */
348
395
  get thread(): readonly ChatMessage[];
396
+ /** The starter questions from `prompts="auto"`, if any. */
397
+ get starters(): readonly string[];
349
398
  /** `format`, falling back to the default for anything unknown. */
350
399
  /** `docsets` as a clean list of ids. */
351
400
  private get docsetIds();
@@ -386,6 +435,26 @@ export declare class SinglebaseChat extends LitElement {
386
435
  newChat(): void;
387
436
  /** Opens a saved conversation. */
388
437
  openChat(id: string): Promise<void>;
438
+ /** Suggested questions under answers: the page's setting, then the reader's. */
439
+ private get followupsVisible();
440
+ /** Source cards and the "searched" row: the page's setting, then the reader's. */
441
+ private get sourcesVisible();
442
+ private toggleView;
443
+ /** Puts a chat from `llm.get_chat` (or `llm.prepare_chat`) on screen. */
444
+ private showChat;
445
+ private get wantsStarters();
446
+ /** The user moved to another conversation: stop tying messages to the key. */
447
+ private leaveKeyedChat;
448
+ /** Docsets first, then the page's own retrieval entries. */
449
+ private baseRetrieval;
450
+ /**
451
+ * Opens the chat for `chat-key`, and with `prompts="auto"` prepares the chat
452
+ * with its context so the service returns stored starter questions.
453
+ *
454
+ * It runs when the key or the context changes. A change of context alone
455
+ * never replaces a conversation that already has messages.
456
+ */
457
+ private syncKeyedChat;
389
458
  /** Sends a message; with no argument, sends the composer's text. */
390
459
  send(text?: string): Promise<void>;
391
460
  /** Stops waiting for, or revealing, the current reply. */
@@ -465,6 +534,8 @@ export declare class SinglebaseChat extends LitElement {
465
534
  private renderSidebar;
466
535
  private renderThreadRow;
467
536
  private renderHeader;
537
+ /** Lets the reader hide suggested questions and sources for a cleaner view. */
538
+ private renderViewMenu;
468
539
  private renderExportMenu;
469
540
  /** The suggestion cards. `[]` or `"none"` shows none; unset uses the mode's. */
470
541
  private promptList;
@@ -491,3 +562,4 @@ declare global {
491
562
  "singlebase-chat": SinglebaseChat;
492
563
  }
493
564
  }
565
+ export {};
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./authui-display-C2o9gApg.cjs"),r=require("./uploader-C57vgFME.cjs"),s=require("@singlebase/core"),a=require("./files-4T62wkwj.cjs"),t=require("./chat-BWcGH9lr.cjs");exports.AuthController=e.AuthController;exports.SettingsController=e.SettingsController;Object.defineProperty(exports,"SinglebaseAccountScreen",{enumerable:!0,get:()=>e.SinglebaseAccountScreen});Object.defineProperty(exports,"SinglebaseAuthButtons",{enumerable:!0,get:()=>e.SinglebaseAuthButtons});Object.defineProperty(exports,"SinglebaseAuthDisplay",{enumerable:!0,get:()=>e.SinglebaseAuthDisplay});Object.defineProperty(exports,"SinglebaseAuthGuard",{enumerable:!0,get:()=>e.SinglebaseAuthGuard});Object.defineProperty(exports,"SinglebaseAuthScreen",{enumerable:!0,get:()=>e.SinglebaseAuthScreen});exports.defaultMessages=e.defaultMessages;exports.fullNameOf=e.fullNameOf;exports.initialsOf=e.initialsOf;exports.isGuestScreen=e.isGuestScreen;exports.isProtectedScreen=e.isProtectedScreen;exports.isScreen=e.isScreen;exports.resolveMessages=e.resolveMessages;Object.defineProperty(exports,"SinglebaseUploader",{enumerable:!0,get:()=>r.SinglebaseUploader});exports.inspectFile=r.inspectFile;exports.isInspectable=r.isInspectable;exports.resolveRedirectTarget=r.resolveRedirectTarget;Object.defineProperty(exports,"OPERATORS",{enumerable:!0,get:()=>s.OPERATORS});Object.defineProperty(exports,"matchesPredicate",{enumerable:!0,get:()=>s.matchesPredicate});Object.defineProperty(exports,"validatePredicate",{enumerable:!0,get:()=>s.validatePredicate});exports.TOKEN_DEFAULTS=a.TOKEN_DEFAULTS;exports.defaultUploadMessages=a.defaultUploadMessages;exports.resolveUploadMessages=a.resolveUploadMessages;Object.defineProperty(exports,"SinglebaseChat",{enumerable:!0,get:()=>t.SinglebaseChat});exports.adaptBlocks=t.adaptBlocks;exports.citedNumbers=t.citedNumbers;exports.defaultChatMessages=t.defaultChatMessages;exports.describeSource=t.describeSource;exports.parseInline=t.parseInline;exports.parseMarkdown=t.parseMarkdown;exports.resolveChatMessages=t.resolveChatMessages;exports.settleStreaming=t.settleStreaming;exports.splitFollowups=t.splitFollowups;exports.svgDataUrl=t.svgDataUrl;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./authui-display-C2o9gApg.cjs"),r=require("./uploader-C57vgFME.cjs"),s=require("@singlebase/core"),a=require("./files-4T62wkwj.cjs"),t=require("./chat-Bj6DrOaW.cjs");exports.AuthController=e.AuthController;exports.SettingsController=e.SettingsController;Object.defineProperty(exports,"SinglebaseAccountScreen",{enumerable:!0,get:()=>e.SinglebaseAccountScreen});Object.defineProperty(exports,"SinglebaseAuthButtons",{enumerable:!0,get:()=>e.SinglebaseAuthButtons});Object.defineProperty(exports,"SinglebaseAuthDisplay",{enumerable:!0,get:()=>e.SinglebaseAuthDisplay});Object.defineProperty(exports,"SinglebaseAuthGuard",{enumerable:!0,get:()=>e.SinglebaseAuthGuard});Object.defineProperty(exports,"SinglebaseAuthScreen",{enumerable:!0,get:()=>e.SinglebaseAuthScreen});exports.defaultMessages=e.defaultMessages;exports.fullNameOf=e.fullNameOf;exports.initialsOf=e.initialsOf;exports.isGuestScreen=e.isGuestScreen;exports.isProtectedScreen=e.isProtectedScreen;exports.isScreen=e.isScreen;exports.resolveMessages=e.resolveMessages;Object.defineProperty(exports,"SinglebaseUploader",{enumerable:!0,get:()=>r.SinglebaseUploader});exports.inspectFile=r.inspectFile;exports.isInspectable=r.isInspectable;exports.resolveRedirectTarget=r.resolveRedirectTarget;Object.defineProperty(exports,"OPERATORS",{enumerable:!0,get:()=>s.OPERATORS});Object.defineProperty(exports,"matchesPredicate",{enumerable:!0,get:()=>s.matchesPredicate});Object.defineProperty(exports,"validatePredicate",{enumerable:!0,get:()=>s.validatePredicate});exports.TOKEN_DEFAULTS=a.TOKEN_DEFAULTS;exports.defaultUploadMessages=a.defaultUploadMessages;exports.resolveUploadMessages=a.resolveUploadMessages;Object.defineProperty(exports,"SinglebaseChat",{enumerable:!0,get:()=>t.SinglebaseChat});exports.adaptBlocks=t.adaptBlocks;exports.citedNumbers=t.citedNumbers;exports.defaultChatMessages=t.defaultChatMessages;exports.describeSource=t.describeSource;exports.parseInline=t.parseInline;exports.parseMarkdown=t.parseMarkdown;exports.resolveChatMessages=t.resolveChatMessages;exports.settleStreaming=t.settleStreaming;exports.splitFollowups=t.splitFollowups;exports.svgDataUrl=t.svgDataUrl;
2
2
  //# sourceMappingURL=index.cjs.map
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import { A as a, S as r, a as t, b as l, c as i, d as o, e as n, f as c, g as S,
2
2
  import { S as h, i as m, a as A, r as M } from "./uploader-Cz9yfzfV.js";
3
3
  import { OPERATORS as x, matchesPredicate as C, validatePredicate as O } from "@singlebase/core";
4
4
  import { T as U, d as P, r as k } from "./files-DS-H-3yN.js";
5
- import { S as E, a as F, c as N, d as R, b as w, p as B, e as G, r as I, s as j, f as y, g as K } from "./chat-t4o5FsxM.js";
5
+ import { S as E, a as F, c as N, d as R, b as w, p as B, e as G, r as I, s as j, f as y, g as K } from "./chat-DNiqYF6F.js";
6
6
  export {
7
7
  a as AuthController,
8
8
  x as OPERATORS,