@origonai/web-sdk 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -66,6 +66,15 @@ await client.endSession(sessionId)
66
66
  - `getSessions()` — GET `/sessions` (prior sessions; every `SessionSummary`
67
67
  includes required live-owner `active: boolean`)
68
68
  - `getSession(sessionId)` — GET `/session/{id}` (transcript + control)
69
+ - `getSessionsPage({ pageSize?, cursor?, search?, signal? })` — fetch a strict
70
+ directory page (50 by default, 100 maximum); `search` matches subject,
71
+ contact name, latest visible message text, and attachment names
72
+ - `getSessionPage(sessionId, { pageSize?, cursor?, signal? })` — fetch a strict
73
+ chronological history page (100 by default, 250 maximum)
74
+ - `SessionDirectoryPager` / `SessionHistoryPager` — generation-fenced page
75
+ reducers for dedupe, live-event reconciliation, prepend accumulation, and
76
+ bounded empty-page continuation; keep search state separate from the default
77
+ cached directory
69
78
 
70
79
  ### Chat
71
80
  - `sendMessage(sessionId, payload)` — post a message with optional `metadata: {audience}`; ordinary participant sends omit it and the server resolves the audience to `all`. The SDK fires `onMessageAdded` immediately with `status: 'sending'`, then `onMessageUpdated` with `'delivered'` or `'failed'` after the server acks
package/dist/index.d.ts CHANGED
@@ -174,6 +174,8 @@ export declare interface JoinSessionOptions {
174
174
  chat?: ProvisionedChatJoinOptions;
175
175
  }
176
176
 
177
+ export declare const MAX_EMPTY_PAGE_CONTINUATIONS = 8;
178
+
177
179
  export declare interface Message {
178
180
  role: MessageRole;
179
181
  id: string;
@@ -259,6 +261,8 @@ export declare type MessageStatus = 'sending' | 'delivered' | 'failed';
259
261
  /** Mirrors `media-server::MuteScope`. */
260
262
  export declare type MuteScope = 'none' | 'uplink' | 'downlink' | 'both';
261
263
 
264
+ export declare function normalizeSearchField(value: string): string;
265
+
262
266
  /**
263
267
  * A non-OK orpc reply (an ERROR frame). `code` is the wire status — a base code
264
268
  * (§5) or a `0x1000+` auth code; `reason` is the server's UTF-8 message.
@@ -382,11 +386,77 @@ export declare interface SendMessagePayload {
382
386
 
383
387
  export declare type SessionControl = 'ai' | 'user';
384
388
 
389
+ export declare interface SessionDirectoryPage {
390
+ sessions: SessionSummary[];
391
+ nextCursor: string | null;
392
+ }
393
+
394
+ export declare interface SessionDirectoryPageOptions {
395
+ /** Defaults to 50; server maximum is 100. */
396
+ pageSize?: number;
397
+ cursor?: string;
398
+ search?: string;
399
+ signal?: AbortSignal;
400
+ }
401
+
402
+ export declare class SessionDirectoryPager {
403
+ private generationValue;
404
+ private query;
405
+ private live;
406
+ private value;
407
+ get generation(): number;
408
+ get search(): string | null;
409
+ get state(): Readonly<SessionDirectoryPageState>;
410
+ begin(search?: string, cached?: SessionSummary[]): number;
411
+ applyLive(summary: SessionSummary): void;
412
+ merge(generation: number, page: SessionDirectoryPage, firstPage: boolean): boolean;
413
+ canLoadMore(): boolean;
414
+ }
415
+
416
+ export declare interface SessionDirectoryPageState {
417
+ sessions: SessionSummary[];
418
+ nextCursor: string | null;
419
+ emptyContinuations: number;
420
+ }
421
+
385
422
  export declare interface SessionHistory {
386
423
  history: Message[];
387
424
  control: SessionControl;
388
425
  }
389
426
 
427
+ export declare interface SessionHistoryPage {
428
+ history: Message[];
429
+ control: SessionControl;
430
+ nextCursor: string | null;
431
+ }
432
+
433
+ export declare interface SessionHistoryPageOptions {
434
+ /** Defaults to 100; server maximum is 250. */
435
+ pageSize?: number;
436
+ cursor?: string;
437
+ signal?: AbortSignal;
438
+ }
439
+
440
+ export declare class SessionHistoryPager {
441
+ private generationValue;
442
+ private live;
443
+ private value;
444
+ get generation(): number;
445
+ get state(): Readonly<SessionHistoryPageState>;
446
+ begin(cached?: SessionHistory): number;
447
+ applyLive(message: Message): void;
448
+ removeLive(identity: Pick<Message, 'id' | 'localId'>): void;
449
+ merge(generation: number, page: SessionHistoryPage, firstPage: boolean): boolean;
450
+ canLoadMore(): boolean;
451
+ }
452
+
453
+ export declare interface SessionHistoryPageState {
454
+ history: Message[];
455
+ control: SessionControl;
456
+ nextCursor: string | null;
457
+ emptyContinuations: number;
458
+ }
459
+
390
460
  /**
391
461
  * Top-level entry point. One instance per app — see `getSessionManager()`
392
462
  * for the singleton accessor.
@@ -418,6 +488,8 @@ export declare class SessionManager {
418
488
  }>;
419
489
  getSessions(): Promise<SessionSummary[]>;
420
490
  getSession(sessionId: string): Promise<SessionHistory>;
491
+ getSessionsPage(options?: SessionDirectoryPageOptions): Promise<SessionDirectoryPage>;
492
+ getSessionPage(sessionId: string, options?: SessionHistoryPageOptions): Promise<SessionHistoryPage>;
421
493
  startSession(opts: StartSessionOptions): Promise<{
422
494
  sessionId: string;
423
495
  }>;
@@ -493,6 +565,8 @@ export declare class SessionManager {
493
565
  private requireHttp;
494
566
  }
495
567
 
568
+ export declare function sessionMatchesSearch(summary: SessionSummary, normalizedSearch: string): boolean;
569
+
496
570
  export declare interface SessionSummary {
497
571
  sessionId: string;
498
572
  subject: string;