@icanbwell/baileyai-chat-ui 1.0.17 → 1.0.19

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/dist/index.d.ts CHANGED
@@ -246,6 +246,19 @@ export declare interface BaileyChatTransport {
246
246
  * error state (the partial text stays visible) instead of treating it as a finished
247
247
  * answer. A transport that never sets it behaves exactly as before. */
248
248
  interrupted?: boolean;
249
+ /** Optional. Why a request that never got a response failed. Set by `createBaileyClient`
250
+ * together with `status: undefined` when `fetch` rejects or the host's `getHeaders`
251
+ * throws (`'network'`); the type is a subset of `BaileyApiErrorKind`. `'timeout'` is reserved
252
+ * for a transport that resolves instead of throwing on a timeout: `createBaileyClient`
253
+ * still rethrows its idle-timeout `TimeoutError`. `errorMessage` stays a fixed string.
254
+ * Hosts that ignore this field behave exactly as before. */
255
+ errorKind?: Extract<BaileyApiErrorKind, 'network' | 'timeout'>;
256
+ /** Optional. The error `fetch` threw, set only with `errorKind` when the failure came
257
+ * from `fetch`; never set when `getHeaders` threw (it can carry auth detail) and never
258
+ * a request or response body. Browsers do not distinguish CORS, DNS or offline: all
259
+ * surface as a generic `TypeError`. Do not show `cause.message` to users without review,
260
+ * and do not log the request URL (it can carry identifiers). */
261
+ errorCause?: unknown;
249
262
  }>;
250
263
  }
251
264
 
@@ -335,8 +348,16 @@ export declare type BaileyContentPart = {
335
348
  export declare interface BaileyContextLossInfo {
336
349
  /** The id the turn sent. */
337
350
  sentId: string;
338
- /** The id the server reported instead; undefined when it reported none. */
351
+ /** The id the server reported instead; undefined when it reported none. For
352
+ * `reason: 'history'` it is the id the server reported, normally equal to `sentId`. */
339
353
  reportedId?: string;
354
+ /** `'id'`: the server reported no id or a different one. `'history'`: the server reported the
355
+ * same id but said it loaded no history (`conversation.history_status` of `'failed'` or
356
+ * `'empty'`). Only newer backends send the status; older ones can only produce `'id'`. The
357
+ * accompanying `history_loaded` count is not used by the library. Optional in the type so hosts that
358
+ * construct this object keep compiling; the library always sets it on what it passes to
359
+ * `onContextLoss`. */
360
+ reason?: 'id' | 'history';
340
361
  }
341
362
 
342
363
  export declare interface BaileyConversationList {
@@ -613,6 +634,14 @@ export declare interface BaileyServerMessage {
613
634
 
614
635
  export declare type BaileyStorageOperation = 'read' | 'write' | 'remove' | 'key';
615
636
 
637
+ /** The `conversation` object on `response.created` / `response.completed`. Every member is optional
638
+ * and `unknown`: older backends omit them and the library ignores values it does not recognise. */
639
+ export declare interface BaileyStreamConversation {
640
+ id?: unknown;
641
+ history_status?: unknown;
642
+ history_loaded?: unknown;
643
+ }
644
+
616
645
  export declare type BaileyStreamEvent = {
617
646
  type: 'response.output_text.delta';
618
647
  delta: string;
@@ -631,17 +660,13 @@ export declare type BaileyStreamEvent = {
631
660
  } | {
632
661
  type: 'response.created';
633
662
  response?: {
634
- conversation?: {
635
- id?: unknown;
636
- } | null;
663
+ conversation?: BaileyStreamConversation | null;
637
664
  };
638
665
  } | {
639
666
  type: 'response.completed';
640
667
  message_id?: string;
641
668
  response?: {
642
- conversation?: {
643
- id?: unknown;
644
- } | null;
669
+ conversation?: BaileyStreamConversation | null;
645
670
  };
646
671
  } | {
647
672
  type: 'error';
@@ -1054,9 +1079,11 @@ export declare interface UseBaileyChatConfig {
1054
1079
  * provided but blank (operation `'key'`). Chat keeps working with the id in memory only and
1055
1080
  * `persistence` becomes `'degraded'`. Receives the underlying error; nothing is logged. */
1056
1081
  onStorageError?: (error: unknown, operation: BaileyStorageOperation) => void;
1057
- /** Called when a turn that sent a held id came back with no id or a different one: the server
1058
- * did not continue that conversation (persistence off, unknown or foreign id, or history that
1059
- * could not be loaded). The held id and its stored value are dropped, so the next turn sends
1082
+ /** Called when a turn that sent a held id came back with no id or a different one
1083
+ * (`reason: 'id'`), or with the same id but `conversation.history_status` of `'failed'` or
1084
+ * `'empty'` (`reason: 'history'`, newer backends only): the server did not continue that
1085
+ * conversation (persistence off, unknown or foreign id, or history that could not be loaded).
1086
+ * The held id and its stored value are dropped, so the next turn sends
1060
1087
  * the full transcript. */
1061
1088
  onContextLoss?: (info: BaileyContextLossInfo) => void;
1062
1089
  }
@@ -1066,8 +1093,8 @@ export declare interface UseBaileyChatResult {
1066
1093
  * storage call failed or `sub` was blank, so the id lives in memory only. Optional in the type
1067
1094
  * so hosts that construct their own result objects still compile. */
1068
1095
  persistence?: 'ok' | 'degraded' | 'off';
1069
- /** True from a turn whose reported id was missing or different from the one sent (see
1070
- * `onContextLoss`) until the next turn starts or the conversation is replaced. */
1096
+ /** True from a turn whose reported id was missing or different from the one sent, or whose
1097
+ * history load failed or was empty (see `onContextLoss`) until the next turn starts or the conversation is replaced. */
1071
1098
  contextLost?: boolean;
1072
1099
  /** Read-only. The held conversation id (seeded, restored from `storage`, or reported by the
1073
1100
  * transport via `onConversationId`); `undefined` until one exists and after `newChat()`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@icanbwell/baileyai-chat-ui",
3
- "version": "1.0.17",
3
+ "version": "1.0.19",
4
4
  "description": "Shared React chat UI and streaming logic for Bailey, the icanbwell AI assistant",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {