@epam/ai-dial-chat-hooks 1.3.0-dev.149 → 1.3.0-dev.157

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,6 +1,7 @@
1
1
  import { CatalogItemLimits, UsageLimitProgressRow } from '@epam/ai-dial-catalog';
2
- import { DeploymentLimitsResponseDto, LimitStatsDto } from '@epam/ai-dial-chat-api-client';
2
+ import { LimitStatsDto } from '@epam/ai-dial-chat-api-client';
3
3
  import { FormatResetTime } from '../usage/map-usage-data-to-dashboard';
4
+ import { UsageLimitsSources } from '../usage/useDeploymentUsageLimits/useDeploymentUsageLimits';
4
5
  /** Labels and formatter callbacks for the conversation-input limits mapping utility. */
5
6
  export interface ConversationInputLimitsLabels {
6
7
  /** Heading of the group listing the selected deployment's token limits. */
@@ -23,6 +24,6 @@ export interface ConversationInputLimitsLabels {
23
24
  }) => string;
24
25
  }
25
26
  export declare const buildResetFields: (stats: LimitStatsDto, formatResetTime: FormatResetTime | undefined) => Pick<UsageLimitProgressRow, "resetLabel" | "resetIsoValue" | "resetAriaLabel">;
26
- /** Maps a deployment's day, week, and month token limits and the caller's cost budget to display-ready rows, or `undefined` when none qualify. */
27
- export declare const mapDeploymentLimitsToInput: (dto: DeploymentLimitsResponseDto | undefined, labels: ConversationInputLimitsLabels, formatResetTime?: FormatResetTime) => CatalogItemLimits | undefined;
27
+ /** Maps the deployment's day, week, and month token limits (from `sources.deployment`) and the account cost budget (from `sources.account`) to display-ready rows, or `undefined` when none qualify. */
28
+ export declare const mapDeploymentLimitsToInput: (sources: UsageLimitsSources, labels: ConversationInputLimitsLabels, formatResetTime?: FormatResetTime) => CatalogItemLimits | undefined;
28
29
  //# sourceMappingURL=map-deployment-limits-to-input.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"map-deployment-limits-to-input.d.ts","sourceRoot":"","sources":["../../src/catalog/map-deployment-limits-to-input.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,iBAAiB,EAEtB,KAAK,qBAAqB,EAC3B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EACV,2BAA2B,EAC3B,aAAa,EACd,MAAM,+BAA+B,CAAC;AAEvC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAE5E,wFAAwF;AACxF,MAAM,WAAW,6BAA6B;IAC5C,2EAA2E;IAC3E,UAAU,EAAE,MAAM,CAAC;IACnB,kFAAkF;IAClF,SAAS,EAAE,MAAM,CAAC;IAClB,8DAA8D;IAC9D,SAAS,EAAE,MAAM,CAAC;IAClB,+DAA+D;IAC/D,UAAU,EAAE,MAAM,CAAC;IACnB,gEAAgE;IAChE,WAAW,EAAE,MAAM,CAAC;IACpB,sEAAsE;IACtE,gBAAgB,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IAC1D,wDAAwD;IACxD,uBAAuB,EAAE,CAAC,MAAM,EAAE;QAChC,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;KACf,KAAK,MAAM,CAAC;CACd;AA+FD,eAAO,MAAM,gBAAgB,GAC3B,OAAO,aAAa,EACpB,iBAAiB,eAAe,GAAG,SAAS,KAC3C,IAAI,CACL,qBAAqB,EACrB,YAAY,GAAG,eAAe,GAAG,gBAAgB,CAYlD,CAAC;AAuGF,kJAAkJ;AAClJ,eAAO,MAAM,0BAA0B,GACrC,KAAK,2BAA2B,GAAG,SAAS,EAC5C,QAAQ,6BAA6B,EACrC,kBAAkB,eAAe,KAChC,iBAAiB,GAAG,SAyCtB,CAAC"}
1
+ {"version":3,"file":"map-deployment-limits-to-input.d.ts","sourceRoot":"","sources":["../../src/catalog/map-deployment-limits-to-input.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,iBAAiB,EAEtB,KAAK,qBAAqB,EAC3B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAEV,aAAa,EACd,MAAM,+BAA+B,CAAC;AAEvC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAC5E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4DAA4D,CAAC;AAErG,wFAAwF;AACxF,MAAM,WAAW,6BAA6B;IAC5C,2EAA2E;IAC3E,UAAU,EAAE,MAAM,CAAC;IACnB,kFAAkF;IAClF,SAAS,EAAE,MAAM,CAAC;IAClB,8DAA8D;IAC9D,SAAS,EAAE,MAAM,CAAC;IAClB,+DAA+D;IAC/D,UAAU,EAAE,MAAM,CAAC;IACnB,gEAAgE;IAChE,WAAW,EAAE,MAAM,CAAC;IACpB,sEAAsE;IACtE,gBAAgB,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IAC1D,wDAAwD;IACxD,uBAAuB,EAAE,CAAC,MAAM,EAAE;QAChC,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;KACf,KAAK,MAAM,CAAC;CACd;AAgGD,eAAO,MAAM,gBAAgB,GAC3B,OAAO,aAAa,EACpB,iBAAiB,eAAe,GAAG,SAAS,KAC3C,IAAI,CACL,qBAAqB,EACrB,YAAY,GAAG,eAAe,GAAG,gBAAgB,CAYlD,CAAC;AA4GF,wMAAwM;AACxM,eAAO,MAAM,0BAA0B,GACrC,SAAS,kBAAkB,EAC3B,QAAQ,6BAA6B,EACrC,kBAAkB,eAAe,KAChC,iBAAiB,GAAG,SAqCtB,CAAC"}
@@ -61,7 +61,7 @@ var n = [
61
61
  return r >= 1 ? t.LimitReached : r >= a && e !== t.LimitReached ? t.RunningLow : e;
62
62
  }, void 0), _ = (e, t, n, r, i, a, o) => {
63
63
  let s = t.flatMap((t) => {
64
- let n = e[t.key];
64
+ let n = e?.[t.key];
65
65
  return !u(n) || !h(n) ? [] : (o.push(n), [p(n, r[t.labelField], r, i, a)]);
66
66
  });
67
67
  return s.length > 0 ? {
@@ -69,11 +69,10 @@ var n = [
69
69
  rows: s
70
70
  } : void 0;
71
71
  }, v = (t, i, a) => {
72
- if (t == null) return;
73
- let o = [], u = [_(t, n, i.tokenGroup, i, {
72
+ let o = [], u = [_(t.deployment, n, i.tokenGroup, i, {
74
73
  format: (e) => s.format(l(e)),
75
74
  formatFull: (e) => c.format(e)
76
- }, a, o), _(t, r, i.costGroup, i, {
75
+ }, a, o), _(t.account, r, i.costGroup, i, {
77
76
  format: e,
78
77
  formatFull: e
79
78
  }, a, o)].filter((e) => e != null);
@@ -42,6 +42,12 @@ export interface ResumeGenerationOptions {
42
42
  onSettled?: () => void;
43
43
  /** Resumes even though the path is already in `resumingPathsRef`, for a caller that reserved it itself. */
44
44
  skipDedupe?: boolean;
45
+ /**
46
+ * Takes the `generationId` the attach `snapshot` carries so Stop can reach a resumed
47
+ * non-background generation. Set only by the public entry point: stream recovery
48
+ * already knows its local id, and the conflict handover keeps Stop unavailable.
49
+ */
50
+ trackAttachGenerationId?: boolean;
45
51
  }
46
52
  /** Host-owned state {@link createResumeIfAwaitingGeneration} reads/writes through. */
47
53
  export interface ResumeIfAwaitingGenerationDeps {
@@ -66,6 +72,13 @@ export interface ResumeIfAwaitingGenerationDeps {
66
72
  * its id is removed when the resume settles.
67
73
  */
68
74
  stoppedGenerationIdsRef?: MutableRefObject<Set<string>>;
75
+ /** Records the id an attach `snapshot` supplied for `path`, so the host can offer Stop for it. */
76
+ rememberResumedGenerationId?: (path: string, generationId: string) => void;
77
+ /**
78
+ * Drops that id again once the resume no longer owns an attached generation. Compare-and-clear:
79
+ * the host removes the entry only while it still holds `generationId`.
80
+ */
81
+ forgetResumedGenerationId?: (path: string, generationId: string) => void;
69
82
  }
70
83
  /**
71
84
  * Builds `resumeIfAwaitingGeneration`: a hard refresh mid-generation loads a
@@ -81,5 +94,5 @@ export interface ResumeIfAwaitingGenerationDeps {
81
94
  * backend's finalize save resolves the placeholder whenever attach is
82
95
  * unavailable or ends without a terminal event.
83
96
  */
84
- export declare const createResumeIfAwaitingGeneration: ({ transport, setConversation, conversationRef, resumingPathsRef, bufferedGenerationsRef, addStreamingPath, removeStreamingPath, isPathDisplayed, generationPersistenceErrorMessage, frameScheduler, stoppedGenerationIdsRef, onReloadError, onReloadSuccess, }: ResumeIfAwaitingGenerationDeps) => (currentConversationId: string, conversation: Conversation, options?: ResumeGenerationOptions) => void;
97
+ export declare const createResumeIfAwaitingGeneration: ({ transport, setConversation, conversationRef, resumingPathsRef, bufferedGenerationsRef, addStreamingPath, removeStreamingPath, isPathDisplayed, generationPersistenceErrorMessage, frameScheduler, stoppedGenerationIdsRef, rememberResumedGenerationId, forgetResumedGenerationId, onReloadError, onReloadSuccess, }: ResumeIfAwaitingGenerationDeps) => (currentConversationId: string, conversation: Conversation, options?: ResumeGenerationOptions) => void;
85
98
  //# sourceMappingURL=generation-resume.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"generation-resume.d.ts","sourceRoot":"","sources":["../../../src/conversation/useConversationStream/generation-resume.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,YAAY,EAEjB,KAAK,OAAO,EAEb,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAOxE,OAAO,EACL,KAAK,kBAAkB,EAExB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AAE3E;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,GAAI,SAAS,OAAO,KAAG,OAWtD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,iCAAiC,GAC5C,cAAc,YAAY,KACzB,MAKA,CAAC;AAEJ;;;;;;;GAOG;AACH,eAAO,MAAM,0BAA0B,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O,KACrB,IAAI,CAAC;IACV,2DAA2D;IAC3D,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,iFAAiF;IACjF,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC;;;;OAIG;IACH,uBAAuB,CAAC,EAAE,gBAAgB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;CACzD;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,gCAAgC,GAAI,gQAc9C,8BAA8B,MAE7B,uBAAuB,MAAM,EAC7B,cAAc,YAAY,EAC1B,UAAS,uBAA4B,KACpC,IA8QJ,CAAC"}
1
+ {"version":3,"file":"generation-resume.d.ts","sourceRoot":"","sources":["../../../src/conversation/useConversationStream/generation-resume.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,YAAY,EAEjB,KAAK,OAAO,EAEb,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAOxE,OAAO,EACL,KAAK,kBAAkB,EAExB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AAE3E;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,GAAI,SAAS,OAAO,KAAG,OAWtD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,iCAAiC,GAC5C,cAAc,YAAY,KACzB,MAKA,CAAC;AAEJ;;;;;;;GAOG;AACH,eAAO,MAAM,0BAA0B,GACrC,cAAc,YAAY,KACzB,OAUF,CAAC;AA6BF,eAAO,MAAM,0BAA0B,UAAkC,CAAC;AAe1E;;;;;GAKG;AACH,eAAO,MAAM,4BAA4B,GACvC,MAAM,MAAM,OAAO,CAAC,YAAY,CAAC,EACjC,YAAY,MAAM,OAAO,EACzB,YA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Ac,CAAC;IAChC;;;;OAIG;IACH,uBAAuB,CAAC,EAAE,gBAAgB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;IACxD,kGAAkG;IAClG,2BAA2B,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3E;;;OAGG;IACH,yBAAyB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,KAAK,IAAI,CAAC;CAC1E;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,gCAAgC,GAAI,wTAgB9C,8BAA8B,MAE7B,uBAAuB,MAAM,EAC7B,cAAc,YAAY,EAC1B,UAAS,uBAA4B,KACpC,IA6SJ,CAAC"}
@@ -63,67 +63,76 @@ var c = (e) => {
63
63
  } catch {} finally {
64
64
  n.releaseLock();
65
65
  }
66
- }, _ = ({ transport: o, setConversation: s, conversationRef: p, resumingPathsRef: m, bufferedGenerationsRef: h, addStreamingPath: _, removeStreamingPath: v, isPathDisplayed: y, generationPersistenceErrorMessage: b = t, frameScheduler: x, stoppedGenerationIdsRef: S, onReloadError: C, onReloadSuccess: w }) => (t, T, E = {}) => {
67
- if (!u(T)) {
68
- E.onSettled?.();
66
+ }, _ = ({ transport: o, setConversation: s, conversationRef: p, resumingPathsRef: m, bufferedGenerationsRef: h, addStreamingPath: _, removeStreamingPath: v, isPathDisplayed: y, generationPersistenceErrorMessage: b = t, frameScheduler: x, stoppedGenerationIdsRef: S, rememberResumedGenerationId: C, forgetResumedGenerationId: w, onReloadError: T, onReloadSuccess: E }) => (t, D, O = {}) => {
67
+ if (!u(D)) {
68
+ O.onSettled?.();
69
69
  return;
70
70
  }
71
- let D = r(t);
72
- if (!E.skipDedupe && m.current.has(D)) return;
73
- m.current.add(D), _(D);
74
- let O = l(T), k = O !== -1, A = k ? O : T.messages.length - 1, j = {
71
+ let k = r(t);
72
+ if (!O.skipDedupe && m.current.has(k)) return;
73
+ m.current.add(k), _(k);
74
+ let A = l(D), j = A !== -1, M = j ? A : D.messages.length - 1, N = {
75
75
  generationId: f,
76
- messageIndex: A,
77
- message: E.seedMessage ?? T.messages[A]
76
+ messageIndex: M,
77
+ message: O.seedMessage ?? D.messages[M]
78
78
  };
79
- h.current.set(D, j);
80
- let M = () => h.current.get(D) === j, N = k ? T.messages[A].backgroundGeneration?.generationId : void 0, P = () => N != null && (S?.current.has(N) ?? !1), F = (e, t = !1) => {
81
- if (x?.flush(D), N != null && S?.current.delete(N), !M()) return;
82
- m.current.delete(D), v(D);
83
- let n = !k && e && e.messages.length - 1 === A && u(e) && c(j.message);
84
- t || n ? (j.message = {
85
- ...j.message,
79
+ h.current.set(k, N);
80
+ let P = () => h.current.get(k) === N, F = j ? D.messages[M].backgroundGeneration?.generationId : void 0, I, L = () => {
81
+ let e = F ?? I;
82
+ return e != null && (S?.current.has(e) ?? !1);
83
+ }, R = (e) => {
84
+ O.trackAttachGenerationId && !j && e != null && P() && (I = e, C?.(k, e));
85
+ }, z = () => {
86
+ if (I == null) return;
87
+ let e = I;
88
+ I = void 0, S?.current.delete(e), w?.(k, e);
89
+ }, B = (e, t = !1) => {
90
+ if (x?.flush(k), F != null && S?.current.delete(F), z(), !P()) return;
91
+ m.current.delete(k), v(k);
92
+ let n = !j && e && e.messages.length - 1 === M && u(e) && c(N.message);
93
+ t || n ? (N.message = {
94
+ ...N.message,
86
95
  streamErrorMessage: b
87
- }, y(D) && s((e) => {
88
- if (!e || !M() || !y(D)) return e;
89
- let t = a(e, j);
96
+ }, y(k) && s((e) => {
97
+ if (!e || !P() || !y(k)) return e;
98
+ let t = a(e, N);
90
99
  return p.current = t, t;
91
- })) : (h.current.delete(D), e && y(D) && (s(e), p.current = e));
92
- }, I = async () => {
93
- if (M()) try {
100
+ })) : (h.current.delete(k), e && y(k) && (s(e), p.current = e));
101
+ }, V = async () => {
102
+ if (P()) try {
94
103
  let n = await o.getConversation(e(t));
95
- if (!M()) return;
96
- w?.(D), F(n);
104
+ if (!P()) return;
105
+ E?.(k), B(n);
97
106
  } catch {
98
- if (!M()) return;
99
- x?.flush(D), m.current.delete(D), v(D), N != null && S?.current.delete(N), C?.(D, I, M);
107
+ if (!P()) return;
108
+ x?.flush(k), m.current.delete(k), v(k), F != null && S?.current.delete(F), z(), T?.(k, V, P);
100
109
  }
101
- }, L = (e) => {
102
- x?.cancel(D), M() && (j.message = e, y(D) && s((e) => {
103
- if (!e || !M() || !y(D)) return e;
104
- let t = a(e, j);
110
+ }, H = (e) => {
111
+ x?.cancel(k), P() && (N.message = e, y(k) && s((e) => {
112
+ if (!e || !P() || !y(k)) return e;
113
+ let t = a(e, N);
105
114
  return p.current = t, t;
106
115
  }));
107
- }, R = () => s((e) => {
108
- if (!e || !M() || !y(D)) return e;
109
- let t = a(e, j);
116
+ }, U = () => s((e) => {
117
+ if (!e || !P() || !y(k)) return e;
118
+ let t = a(e, N);
110
119
  return p.current = t, t;
111
- }), z = (e) => {
112
- if (!M() || P()) return;
113
- let t = i([j.message], 0, e);
114
- t && (j.message = t[0]), y(D) && (x ? x.schedule(D, R) : R());
115
- }, B = async () => {
120
+ }), W = (e) => {
121
+ if (!P() || L()) return;
122
+ let t = i([N.message], 0, e);
123
+ t && (N.message = t[0]), y(k) && (x ? x.schedule(k, U) : U());
124
+ }, G = async () => {
116
125
  let n = new AbortController(), r;
117
126
  try {
118
- r = await o.watchConversation(D, n.signal);
127
+ r = await o.watchConversation(k, n.signal);
119
128
  } catch {
120
- await I();
129
+ await V();
121
130
  return;
122
131
  }
123
132
  try {
124
133
  let i = await o.getConversation(e(t));
125
134
  if (!u(i)) {
126
- n.abort(), r.cancel().catch(() => void 0), F(i);
135
+ n.abort(), r.cancel().catch(() => void 0), B(i);
127
136
  return;
128
137
  }
129
138
  } catch {}
@@ -135,38 +144,38 @@ var c = (e) => {
135
144
  if (n?.action !== "UPDATE") return !1;
136
145
  try {
137
146
  let n = await o.getConversation(e(t));
138
- if (!u(n)) return F(n), i = !0, !0;
147
+ if (!u(n)) return B(n), i = !0, !0;
139
148
  } catch {}
140
149
  return !1;
141
150
  });
142
151
  } finally {
143
152
  clearTimeout(a);
144
153
  }
145
- i || await I();
146
- }, V = async () => {
154
+ i || await V();
155
+ }, K = async () => {
147
156
  let e = new AbortController(), t;
148
157
  try {
149
- t = await o.attachToGeneration(D, e.signal);
158
+ t = await o.attachToGeneration(k, e.signal);
150
159
  } catch {
151
160
  return !1;
152
161
  }
153
162
  let r = !1, i = !1;
154
163
  return await g(t, (e) => {
155
- if (!M()) return !0;
164
+ if (!P()) return !0;
156
165
  switch (e.type) {
157
- case "snapshot": return L(e.message), !1;
158
- case "chunk": return z(e.chunk), !1;
166
+ case "snapshot": return R(e.generationId), H(e.message), !1;
167
+ case "chunk": return W(e.chunk), !1;
159
168
  case "done":
160
169
  case "error":
161
170
  case "stopped": return i = e.type === "error" && e.errorType === n.type, r = !0, !0;
162
171
  }
163
- }), r ? (i ? F(void 0, !0) : await I(), !0) : !M();
172
+ }), r ? (i ? B(void 0, !0) : await V(), !0) : (z(), !P());
164
173
  };
165
174
  (async () => {
166
175
  try {
167
- await V() || await B();
176
+ await K() || await G();
168
177
  } finally {
169
- E.onSettled?.();
178
+ O.onSettled?.();
170
179
  }
171
180
  })();
172
181
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useConversationStream.d.ts","sourceRoot":"","sources":["../../../src/conversation/useConversationStream/useConversationStream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,EACL,KAAK,YAAY,EAEjB,KAAK,oBAAoB,EAEzB,KAAK,WAAW,EACjB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,gBAAgB,EACrB,KAAK,cAAc,EAMpB,MAAM,OAAO,CAAC;AA6Cf,gFAAgF;AAChF,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,CAAC,KAAK,EAAE,WAAW,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useConversationStream.d.ts","sourceRoot":"","sources":["../../../src/conversation/useConversationStream/useConversationStream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,EACL,KAAK,YAAY,EAEjB,KAAK,oBAAoB,EAEzB,KAAK,WAAW,EACjB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,gBAAgB,EACrB,KAAK,cAAc,EAMpB,MAAM,OAAO,CAAC;AA6Cf,gFAAgF;AAChF,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;IACtC,UAAU,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvC,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAChC,MAAM,EAAE,WAAW,CAAC;CACrB;AAED;;;;GAIG;AACH,MAAM,WAAW,2BAA2B;IAC1C,6GAA6G;IAC7G,gBAAgB,CACd,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,uBAAuB,EAChC,aAAa,CAAC,EAAE,oBAAoB,EACpC,YAAY,CAAC,EAAE,MAAM,EACrB,IAAI,CAAC,EAAE,yBAAyB,EAChC,YAAY,CAAC,EAAE,MAAM,EACrB,eAAe,CAAC,EAAE,MAAM,GACvB,IAAI,CAAC;IACR;;;OAGG;IACH,cAAc,CAAC,MAAM,EAAE;QACrB,YAAY,EAAE,MAAM,CAAC;QACrB,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAClB,uFAAuF;IACvF,iBAAiB,CACf,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,cAAc,CAAC,UAAU,CA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B,EAAE,MAAM,EAC7B,YAAY,EAAE,YAAY,KACvB,YAAY,CAAC;IAClB,WAAW,EAAE,OAAO,CAAC;IACrB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,iEAAiE;IACjE,0BAA0B,EAAE,OAAO,CAAC;IACpC,iDAAiD;IACjD,uBAAuB,EAAE,OAAO,CAAC;IACjC,yEAAyE;IACzE,uBAAuB,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9C;AAkBD;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,GAAI,mQAYnC,2BAA2B,KAAG,2BA88BhC,CAAC"}
@@ -5,166 +5,174 @@ import { applyChunkToMessages as l } from "./apply-chunk.js";
5
5
  import { restoreBufferedMessage as u } from "./buffered-generation.js";
6
6
  import { createResumeIfAwaitingGeneration as ee, fetchConversationForRecovery as te, findPendingBackgroundMessageIndex as d, hasGeneratedPayload as ne, isAwaitingGenerationResume as f } from "./generation-resume.js";
7
7
  import { createFrameScheduler as re } from "./frame-scheduler.js";
8
- import { MessageRole as p, generateUUID as ie } from "@epam/ai-dial-chat-shared";
9
- import { useCallback as m, useEffect as h, useMemo as g, useRef as _, useState as v } from "react";
10
- import { SendCompletionDtoModeEnum as y } from "@epam/ai-dial-chat-api-client";
8
+ import { MessageRole as ie, generateUUID as ae } from "@epam/ai-dial-chat-shared";
9
+ import { useCallback as p, useEffect as m, useMemo as h, useRef as g, useState as _ } from "react";
10
+ import { SendCompletionDtoModeEnum as oe } from "@epam/ai-dial-chat-api-client";
11
11
  //#region src/conversation/useConversationStream/useConversationStream.ts
12
- var ae = 2e4, oe = 401, b = 404, x = 2e3, S = 100, se = (e, t, n) => e instanceof i ? n : e instanceof r ? t : e instanceof s ? e.message : "", C = (e) => {
12
+ var se = 2e4, ce = 401, v = 404, y = 2e3, b = 100, le = (e, t, n) => e instanceof i ? n : e instanceof r ? t : e instanceof s ? e.message : "", x = (e) => {
13
13
  if (!e) return;
14
14
  let t = d(e);
15
15
  return t === -1 ? void 0 : e.messages[t].backgroundGeneration?.generationId;
16
- }, w = ({ conversationId: s, state: { setConversation: w, conversationRef: T }, transport: E, generation: { startGeneration: ce, completeGeneration: le }, channel: D, overlay: O, onStopError: ue, generationConflictMessage: de = t, generationPersistenceErrorMessage: k = n, onStreamError: A, batchChunksPerFrame: j = !1 }) => {
17
- let fe = _(A);
18
- h(() => {
19
- fe.current = A;
20
- }, [A]);
21
- let pe = _(j);
22
- h(() => {
23
- pe.current = j;
24
- }, [j]);
25
- let [M] = v(re), [N, P] = v(() => /* @__PURE__ */ new Set()), F = _(N);
26
- F.current = N;
27
- let [I, me] = v(() => /* @__PURE__ */ new Set()), L = _(/* @__PURE__ */ new Map()), R = _(/* @__PURE__ */ new Set()), z = _(/* @__PURE__ */ new Map()), B = _(/* @__PURE__ */ new Set()), V = _(/* @__PURE__ */ new Set()), he = _(/* @__PURE__ */ new Map()), H = _(!0), U = _(/* @__PURE__ */ new Map()), [ge, W] = v(U.current), G = _(/* @__PURE__ */ new Set()), [_e, ve] = v(G.current);
28
- h(() => (H.current = !0, () => {
29
- H.current = !1;
16
+ }, S = ({ conversationId: s, state: { setConversation: S, conversationRef: C }, transport: w, generation: { startGeneration: ue, completeGeneration: de }, channel: T, overlay: E, onStopError: fe, generationConflictMessage: pe = t, generationPersistenceErrorMessage: D = n, onStreamError: O, batchChunksPerFrame: k = !1 }) => {
17
+ let me = g(O);
18
+ m(() => {
19
+ me.current = O;
20
+ }, [O]);
21
+ let he = g(k);
22
+ m(() => {
23
+ he.current = k;
24
+ }, [k]);
25
+ let [A] = _(re), [j, M] = _(() => /* @__PURE__ */ new Set()), N = g(j);
26
+ N.current = j;
27
+ let [P, ge] = _(() => /* @__PURE__ */ new Set()), F = g(/* @__PURE__ */ new Map()), I = g(/* @__PURE__ */ new Map()), L = g(/* @__PURE__ */ new Set()), R = g(/* @__PURE__ */ new Map()), z = g(/* @__PURE__ */ new Set()), B = g(/* @__PURE__ */ new Set()), _e = g(/* @__PURE__ */ new Map()), V = g(!0), H = g(/* @__PURE__ */ new Map()), [U, ve] = _(H.current), W = g(/* @__PURE__ */ new Set()), [ye, be] = _(W.current);
28
+ m(() => (V.current = !0, () => {
29
+ V.current = !1;
30
30
  }), []);
31
- let K = m((e) => {
32
- if (!U.current.has(e)) return;
33
- let t = new Map(U.current);
34
- t.delete(e), U.current = t, H.current && W(t);
35
- }, []), q = m((e, t, n) => {
36
- if (!H.current || !n()) return;
37
- let r = new Map(U.current);
31
+ let G = p((e) => {
32
+ if (!H.current.has(e)) return;
33
+ let t = new Map(H.current);
34
+ t.delete(e), H.current = t, V.current && ve(t);
35
+ }, []), K = p((e, t, n) => {
36
+ if (!V.current || !n()) return;
37
+ let r = new Map(H.current);
38
38
  r.set(e, {
39
39
  retry: t,
40
40
  isCurrent: n
41
- }), U.current = r, W(r);
42
- }, []), ye = m(async () => {
41
+ }), H.current = r, ve(r);
42
+ }, []), xe = p(async () => {
43
43
  if (!s) return;
44
- let e = U.current.get(c(s));
45
- if (e && e.isCurrent() && !G.current.has(e)) {
46
- G.current.add(e), ve(new Set(G.current));
44
+ let e = H.current.get(c(s));
45
+ if (e && e.isCurrent() && !W.current.has(e)) {
46
+ W.current.add(e), be(new Set(W.current));
47
47
  try {
48
48
  await e.retry();
49
49
  } finally {
50
- G.current.delete(e), H.current && ve(new Set(G.current));
50
+ W.current.delete(e), V.current && be(new Set(W.current));
51
51
  }
52
52
  }
53
- }, [s]), be = _(s);
54
- h(() => (be.current = s, () => M.cancelAll()), [s, M]);
55
- let J = m((e) => H.current && c(be.current ?? "") === e, []), Y = m((e) => {
56
- K(e), P((t) => {
53
+ }, [s]), Se = g(s);
54
+ m(() => (Se.current = s, () => A.cancelAll()), [s, A]);
55
+ let q = p((e) => V.current && c(Se.current ?? "") === e, []), J = p((e) => {
56
+ G(e), M((t) => {
57
57
  if (t.has(e)) return t;
58
58
  let n = new Set(t);
59
59
  return n.add(e), n;
60
60
  });
61
- }, [K]), X = m((e) => {
62
- P((t) => {
61
+ }, [G]), Y = p((e) => {
62
+ M((t) => {
63
63
  if (!t.has(e)) return t;
64
64
  let n = new Set(t);
65
65
  return n.delete(e), n;
66
66
  });
67
- }, []), Z = m((e, t) => {
68
- me((n) => {
67
+ }, []), X = p((e, t) => {
68
+ ge((n) => {
69
69
  if (n.has(e) === t) return n;
70
70
  let r = new Set(n);
71
71
  return t ? r.add(e) : r.delete(e), r;
72
72
  });
73
- }, []), xe = m((e, t) => {
74
- L.current.get(e) === t && (L.current.delete(e), Z(e, !1));
75
- }, [Z]), Q = g(() => ee({
76
- transport: E,
77
- setConversation: w,
78
- conversationRef: T,
79
- resumingPathsRef: R,
80
- bufferedGenerationsRef: z,
81
- addStreamingPath: Y,
82
- removeStreamingPath: X,
83
- isPathDisplayed: J,
84
- generationPersistenceErrorMessage: k,
85
- frameScheduler: j ? M : void 0,
86
- stoppedGenerationIdsRef: B,
87
- onReloadError: q,
88
- onReloadSuccess: K
73
+ }, []), Ce = p((e, t) => {
74
+ F.current.get(e) === t && (F.current.delete(e), X(e, !1));
75
+ }, [X]), we = p((e, t) => {
76
+ F.current.has(e) || (I.current.set(e, t), X(e, !0));
77
+ }, [X]), Te = p((e, t) => {
78
+ I.current.get(e) === t && (I.current.delete(e), F.current.has(e) || X(e, !1));
79
+ }, [X]), Z = h(() => ee({
80
+ transport: w,
81
+ setConversation: S,
82
+ conversationRef: C,
83
+ resumingPathsRef: L,
84
+ bufferedGenerationsRef: R,
85
+ addStreamingPath: J,
86
+ removeStreamingPath: Y,
87
+ isPathDisplayed: q,
88
+ generationPersistenceErrorMessage: D,
89
+ frameScheduler: k ? A : void 0,
90
+ stoppedGenerationIdsRef: z,
91
+ rememberResumedGenerationId: we,
92
+ forgetResumedGenerationId: Te,
93
+ onReloadError: K,
94
+ onReloadSuccess: G
89
95
  }), [
90
- Y,
91
- X,
92
96
  J,
93
- E,
94
- k,
95
- j,
96
- M,
97
+ Y,
97
98
  q,
98
- K
99
- ]), Se = m((t, n, a, s, ee, re, m = y.Append, h = {}) => {
100
- let g = re ?? ie(), _ = c(t);
101
- M.flush(_), R.current.delete(_), L.current.set(_, g), he.current.set(_, g), Z(_, !0);
102
- let v;
103
- m === y.Regenerate ? v = a : m === y.Edit && (v = a - 1);
104
- let b = () => he.current.get(_) !== g, x = ce(_, g), S = T.current?.messages[a];
105
- S ? z.current.set(_, {
106
- generationId: g,
99
+ w,
100
+ D,
101
+ k,
102
+ A,
103
+ we,
104
+ Te,
105
+ K,
106
+ G
107
+ ]), Ee = p((t, n, a, s, ee, re, p = oe.Append, m = {}) => {
108
+ let h = re ?? ae(), g = c(t);
109
+ A.flush(g), L.current.delete(g), F.current.set(g, h), _e.current.set(g, h), X(g, !0);
110
+ let _;
111
+ p === oe.Regenerate ? _ = a : p === oe.Edit && (_ = a - 1);
112
+ let v = () => _e.current.get(g) !== h, y = ue(g, h), b = C.current?.messages[a];
113
+ b ? R.current.set(g, {
114
+ generationId: h,
107
115
  messageIndex: a,
108
- message: S
109
- }) : z.current.delete(_), Y(_), O?.notifyGenerationStart?.(), D?.ensureConnected();
110
- let C = () => {
111
- b() || X(_), xe(_, g), le(_, g), D?.notifyGenerationSettled?.();
112
- }, ue = () => {
113
- if (b()) return;
114
- let e = z.current.get(_);
115
- e && e.generationId === g && (e.message = {
116
+ message: b
117
+ }) : R.current.delete(g), J(g), E?.notifyGenerationStart?.(), T?.ensureConnected();
118
+ let x = () => {
119
+ v() || Y(g), Ce(g, h), de(g, h), T?.notifyGenerationSettled?.();
120
+ }, fe = () => {
121
+ if (v()) return;
122
+ let e = R.current.get(g);
123
+ e && e.generationId === h && (e.message = {
116
124
  ...e.message,
117
- streamErrorMessage: k
118
- }, fe.current?.(new i()), J(_) && w((t) => {
119
- if (!t || b() || !J(_)) return t;
125
+ streamErrorMessage: D
126
+ }, me.current?.(new i()), q(g) && S((t) => {
127
+ if (!t || v() || !q(g)) return t;
120
128
  let n = u(t, e);
121
- return T.current = n, n;
129
+ return C.current = n, n;
122
130
  }));
123
- }, A = z.current.get(_), j = () => H.current && !b() && z.current.get(_) === A, N = async () => {
124
- if (j()) {
125
- if (!J(_)) A && z.current.delete(_);
131
+ }, O = R.current.get(g), k = () => V.current && !v() && R.current.get(g) === O, j = async () => {
132
+ if (k()) {
133
+ if (!q(g)) O && R.current.delete(g);
126
134
  else try {
127
- let n = await E.getConversation(e(t));
128
- if (!j()) return;
129
- if (K(_), !J(_)) {
130
- A && z.current.delete(_);
135
+ let n = await w.getConversation(e(t));
136
+ if (!k()) return;
137
+ if (G(g), !q(g)) {
138
+ O && R.current.delete(g);
131
139
  return;
132
140
  }
133
141
  if (d(n) !== -1) {
134
- Q(t, n, { seedMessage: A?.message });
142
+ Z(t, n, { seedMessage: O?.message });
135
143
  return;
136
144
  }
137
- if (A && A.messageIndex === n.messages.length - 1 && f(n) && ne(A.message)) {
138
- ue();
145
+ if (O && O.messageIndex === n.messages.length - 1 && f(n) && ne(O.message)) {
146
+ fe();
139
147
  return;
140
148
  }
141
- A && z.current.delete(_), w(n), T.current = n;
149
+ O && R.current.delete(g), S(n), C.current = n;
142
150
  } catch {
143
- j() && q(_, N, j);
151
+ k() && K(g, j, k);
144
152
  }
145
153
  }
146
- }, P = {
147
- signal: x.signal,
154
+ }, M = {
155
+ signal: y.signal,
148
156
  onChunk: (e) => {
149
- if (b()) return;
150
- let t = z.current.get(_);
151
- if (t?.generationId === g) {
157
+ if (v()) return;
158
+ let t = R.current.get(g);
159
+ if (t?.generationId === h) {
152
160
  let n = l([t.message], 0, e);
153
161
  n && (t.message = n[0]);
154
162
  }
155
- J(_) && (pe.current && t?.generationId === g ? M.schedule(_, () => {
156
- let e = z.current.get(_);
157
- if (b() || !J(_) || e?.generationId !== g) return;
163
+ q(g) && (he.current && t?.generationId === h ? A.schedule(g, () => {
164
+ let e = R.current.get(g);
165
+ if (v() || !q(g) || e?.generationId !== h) return;
158
166
  let t = { ...e };
159
- w((e) => {
167
+ S((e) => {
160
168
  if (!e) return e;
161
169
  let n = u(e, t);
162
- return T.current = n, n;
170
+ return C.current = n, n;
163
171
  });
164
- }) : w((t) => {
172
+ }) : S((t) => {
165
173
  if (!t) return t;
166
- let n = z.current.get(_), r;
167
- if (n?.generationId === g) r = u(t, n);
174
+ let n = R.current.get(g), r;
175
+ if (n?.generationId === h) r = u(t, n);
168
176
  else {
169
177
  let n = l(t.messages, a, e);
170
178
  if (!n) return t;
@@ -173,157 +181,157 @@ var ae = 2e4, oe = 401, b = 404, x = 2e3, S = 100, se = (e, t, n) => e instanceo
173
181
  messages: n
174
182
  };
175
183
  }
176
- return T.current = r, r;
184
+ return C.current = r, r;
177
185
  }));
178
186
  },
179
187
  onComplete: async () => {
180
- M.flush(_), C(), B.current.has(g) ? B.current.delete(g) : b() || O?.notifyGenerationEnd?.(), await N();
188
+ A.flush(g), x(), z.current.has(h) ? z.current.delete(h) : v() || E?.notifyGenerationEnd?.(), await j();
181
189
  },
182
190
  onError: (e) => {
183
- M.flush(_), fe.current?.(e), e instanceof o && !b() ? U(e) : e instanceof r && h.resumeOnConflict && !b() ? ge(e) : F(e);
191
+ A.flush(g), me.current?.(e), e instanceof o && !v() ? B(e) : e instanceof r && m.resumeOnConflict && !v() ? H(e) : N(e);
184
192
  }
185
- }, F = (e) => {
186
- let t = z.current.get(_), n = t?.generationId === g ? t : void 0;
187
- n && !(e instanceof i) && z.current.delete(_), C(), n && E.saveConversation && e instanceof i && e.status === oe ? me(e, n, E.saveConversation.bind(E)) : I(e, n);
188
- }, I = (e, t) => {
193
+ }, N = (e) => {
194
+ let t = R.current.get(g), n = t?.generationId === h ? t : void 0;
195
+ n && !(e instanceof i) && R.current.delete(g), x(), n && w.saveConversation && e instanceof i && e.status === ce ? ge(e, n, w.saveConversation.bind(w)) : P(e, n);
196
+ }, P = (e, t) => {
189
197
  if (t && e instanceof i && (t.message = {
190
198
  ...t.message,
191
- streamErrorMessage: k
192
- }), b() || !J(_)) return;
193
- let n = se(e, de, k);
194
- w((e) => {
195
- if (!e || b() || !J(_)) return e;
196
- let r = t?.generationId === g ? u(e, t) : e, i = {
199
+ streamErrorMessage: D
200
+ }), v() || !q(g)) return;
201
+ let n = le(e, pe, D);
202
+ S((e) => {
203
+ if (!e || v() || !q(g)) return e;
204
+ let r = t?.generationId === h ? u(e, t) : e, i = {
197
205
  ...r,
198
206
  messages: r.messages.map((e, t) => t === a ? {
199
207
  ...e,
200
208
  streamErrorMessage: n
201
209
  } : e)
202
210
  };
203
- return T.current = i, i;
211
+ return C.current = i, i;
204
212
  });
205
- }, me = async (n, r, i) => {
206
- let a = () => H.current && !b() && z.current.get(_) === r;
213
+ }, ge = async (n, r, i) => {
214
+ let a = () => V.current && !v() && R.current.get(g) === r;
207
215
  try {
208
- let o = await E.getConversation(e(t));
216
+ let o = await w.getConversation(e(t));
209
217
  if (!a()) return;
210
218
  if (r.messageIndex !== o.messages.length - 1 || !f(o)) {
211
- I(n, r);
219
+ P(n, r);
212
220
  return;
213
221
  }
214
- let s = await i(_, u(o, r));
215
- if (!a() || (z.current.delete(_), !J(_))) return;
216
- w(s), T.current = s;
222
+ let s = await i(g, u(o, r));
223
+ if (!a() || (R.current.delete(g), !q(g))) return;
224
+ S(s), C.current = s;
217
225
  } catch {
218
- a() && I(n, r);
226
+ a() && P(n, r);
219
227
  }
220
- }, V = () => {
221
- C(), B.current.has(g) ? B.current.delete(g) : b() || O?.notifyGenerationEnd?.();
222
- }, U = async (n) => {
223
- R.current.add(_);
224
- let r = await te(() => E.getConversation(e(t)), b);
225
- W(r, n, !1);
226
- }, ge = async (n) => {
227
- L.current.get(_) === g && Z(_, !1), R.current.add(_);
228
- let r = await te(() => E.getConversation(e(t)), b, (e) => e.messages.length === a && e.messages.at(-1)?.role === p.User);
229
- W(r, n, !0);
230
- }, W = (e, n, r) => {
231
- if (b()) {
232
- C();
228
+ }, I = () => {
229
+ x(), z.current.has(h) ? z.current.delete(h) : v() || E?.notifyGenerationEnd?.();
230
+ }, B = async (n) => {
231
+ L.current.add(g);
232
+ let r = await te(() => w.getConversation(e(t)), v);
233
+ U(r, n, !1);
234
+ }, H = async (n) => {
235
+ F.current.get(g) === h && X(g, !1), L.current.add(g);
236
+ let r = await te(() => w.getConversation(e(t)), v, (e) => e.messages.length === a && e.messages.at(-1)?.role === ie.User);
237
+ U(r, n, !0);
238
+ }, U = (e, n, r) => {
239
+ if (v()) {
240
+ x();
233
241
  return;
234
242
  }
235
- let i = e?.messages[e.messages.length - 1], o = e != null && e.messages.length - 1 === a && i?.role === p.Assistant, s = r && e != null && d(e) !== -1;
243
+ let i = e?.messages[e.messages.length - 1], o = e != null && e.messages.length - 1 === a && i?.role === ie.Assistant, s = r && e != null && d(e) !== -1;
236
244
  if (!e || !o && !s) {
237
- R.current.delete(_), F(n);
245
+ L.current.delete(g), N(n);
238
246
  return;
239
247
  }
240
- let c = z.current.get(_), l = c?.generationId === g ? c : void 0;
241
- f(e) ? Q(t, e, {
248
+ let c = R.current.get(g), l = c?.generationId === h ? c : void 0;
249
+ f(e) ? Z(t, e, {
242
250
  seedMessage: o ? l?.message : void 0,
243
251
  skipDedupe: !0,
244
- onSettled: V
245
- }) : (R.current.delete(_), l && z.current.delete(_), J(_) && (w(e), T.current = e), V());
252
+ onSettled: I
253
+ }) : (L.current.delete(g), l && R.current.delete(g), q(g) && (S(e), C.current = e), I());
246
254
  };
247
255
  (async () => {
248
256
  try {
249
- let e = D?.channelId ?? await D?.waitForChannel(ae) ?? void 0, t = B.current.has(g);
250
- if (x.signal.aborted || b() || t) {
251
- z.current.get(_)?.generationId === g && z.current.delete(_), b() || X(_), xe(_, g), le(_, g), D?.notifyGenerationSettled?.(), t ? B.current.delete(g) : b() || O?.notifyGenerationEnd?.();
257
+ let e = T?.channelId ?? await T?.waitForChannel(se) ?? void 0, t = z.current.has(h);
258
+ if (y.signal.aborted || v() || t) {
259
+ R.current.get(g)?.generationId === h && R.current.delete(g), v() || Y(g), Ce(g, h), de(g, h), T?.notifyGenerationSettled?.(), t ? z.current.delete(h) : v() || E?.notifyGenerationEnd?.();
252
260
  return;
253
261
  }
254
- E.streamCompletion(_, n, s, P, ee, g, m, v, e);
262
+ w.streamCompletion(g, n, s, M, ee, h, p, _, e);
255
263
  } catch (e) {
256
- P.onError(e instanceof Error ? e : Error(String(e)));
264
+ M.onError(e instanceof Error ? e : Error(String(e)));
257
265
  }
258
266
  })();
259
267
  }, [
260
- ce,
261
- le,
268
+ ue,
269
+ de,
270
+ J,
262
271
  Y,
263
272
  X,
264
- Z,
265
- xe,
266
- J,
267
- D?.channelId,
268
- D?.ensureConnected,
269
- D?.waitForChannel,
270
- D?.notifyGenerationSettled,
271
- O,
272
- E,
273
- Q,
274
- de,
275
- k,
276
- M,
273
+ Ce,
277
274
  q,
278
- K
279
- ]), Ce = m((e, t) => {
280
- let n = c(e), r = z.current.get(n);
281
- return U.current.get(n)?.isCurrent() && r && t.messages.length - 1 >= r.messageIndex && t.messages[r.messageIndex].role === p.Assistant && !f(t) ? (K(n), z.current.delete(n), t) : r ? u(t, r) : t;
282
- }, [K]), we = m(() => {
275
+ T?.channelId,
276
+ T?.ensureConnected,
277
+ T?.waitForChannel,
278
+ T?.notifyGenerationSettled,
279
+ E,
280
+ w,
281
+ Z,
282
+ pe,
283
+ D,
284
+ A,
285
+ K,
286
+ G
287
+ ]), De = p((e, t) => {
288
+ let n = c(e), r = R.current.get(n);
289
+ return H.current.get(n)?.isCurrent() && r && t.messages.length - 1 >= r.messageIndex && t.messages[r.messageIndex].role === ie.Assistant && !f(t) ? (G(n), R.current.delete(n), t) : r ? u(t, r) : t;
290
+ }, [G]), Oe = p(() => {
283
291
  if (!s) return;
284
- let e = c(s), t = L.current.get(e), n = t ?? C(T.current);
285
- if (!n || V.current.has(n)) return;
286
- V.current.add(n), B.current.add(n), M.flush(e), O?.notifyStopGenerating?.();
287
- let r = z.current.get(e)?.message.content, i = () => L.current.get(e) === n || t == null && F.current.has(e), o = async () => {
288
- let e = x / S;
292
+ let e = c(s), t = F.current.get(e), n = t ?? x(C.current) ?? I.current.get(e);
293
+ if (!n || B.current.has(n)) return;
294
+ B.current.add(n), z.current.add(n), A.flush(e), E?.notifyStopGenerating?.();
295
+ let r = R.current.get(e)?.message.content, i = () => F.current.get(e) === n || t == null && N.current.has(e), o = async () => {
296
+ let e = y / b;
289
297
  for (let t = 0; t < e; t++) {
290
- if (!i() || !H.current) return !0;
291
- await new Promise((e) => setTimeout(e, S));
298
+ if (!i() || !V.current) return !0;
299
+ await new Promise((e) => setTimeout(e, b));
292
300
  }
293
301
  return !i();
294
302
  };
295
303
  (async () => {
296
304
  try {
297
- await E.stopCompletion({
305
+ await w.stopCompletion({
298
306
  generationId: n,
299
307
  path: e,
300
308
  content: r
301
309
  });
302
310
  } catch (e) {
303
311
  let t = e instanceof Error ? e : Error(String(e));
304
- if (t instanceof a && t.status === b && await o()) return;
305
- V.current.delete(n), ue?.(t);
312
+ if (t instanceof a && t.status === v && await o()) return;
313
+ B.current.delete(n), fe?.(t);
306
314
  }
307
315
  })();
308
316
  }, [
309
317
  s,
310
- T,
311
- M,
312
- ue,
313
- O,
314
- E
315
- ]), Te = m((e, t) => Q(e, t), [Q]), Ee = s != null && N.has(c(s)), $ = s == null ? null : c(s), De = $ != null && (I.has($) || Ee && C(T.current) != null), Oe = $ ? ge.get($) : void 0, ke = Oe?.isCurrent() ?? !1;
318
+ C,
319
+ A,
320
+ fe,
321
+ E,
322
+ w
323
+ ]), ke = p((e, t) => Z(e, t, { trackAttachGenerationId: !0 }), [Z]), Ae = s != null && j.has(c(s)), Q = s == null ? null : c(s), je = Q != null && (P.has(Q) || Ae && x(C.current) != null), $ = Q ? U.get(Q) : void 0, Me = $?.isCurrent() ?? !1;
316
324
  return {
317
- hasConversationReloadError: ke,
318
- isReloadingConversation: !!Oe && ke && _e.has(Oe),
319
- retryConversationReload: ye,
320
- startStream: Se,
321
- handleStop: we,
322
- resumeIfAwaitingGeneration: Te,
323
- restoreBufferedGeneration: Ce,
324
- isStreaming: Ee,
325
- canStopStreaming: De
325
+ hasConversationReloadError: Me,
326
+ isReloadingConversation: !!$ && Me && ye.has($),
327
+ retryConversationReload: xe,
328
+ startStream: Ee,
329
+ handleStop: Oe,
330
+ resumeIfAwaitingGeneration: ke,
331
+ restoreBufferedGeneration: De,
332
+ isStreaming: Ae,
333
+ canStopStreaming: je
326
334
  };
327
335
  };
328
336
  //#endregion
329
- export { w as useConversationStream };
337
+ export { S as useConversationStream };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@epam/ai-dial-chat-hooks",
3
3
  "description": "Framework-level React hooks extracted from AI DIAL Chat for building custom chat interfaces",
4
- "version": "1.3.0-dev.149",
4
+ "version": "1.3.0-dev.157",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
7
7
  "main": "./index.js",
@@ -121,7 +121,7 @@
121
121
  }
122
122
  },
123
123
  "dependencies": {
124
- "@epam/ai-dial-chat-api-client": "1.3.0-dev.149",
124
+ "@epam/ai-dial-chat-api-client": "1.3.0-dev.157",
125
125
  "dompurify": "3.4.16",
126
126
  "fflate": "^0.8.3",
127
127
  "lru-cache": "^10.4.3",
@@ -130,22 +130,22 @@
130
130
  },
131
131
  "peerDependencies": {
132
132
  "react": "^19.2.8",
133
- "@epam/ai-dial-attachment-canvas": "1.3.0-dev.149",
134
- "@epam/ai-dial-attachment-input": "1.3.0-dev.149",
135
- "@epam/ai-dial-catalog": "1.3.0-dev.149",
136
- "@epam/ai-dial-chat-overlay": "1.3.0-dev.149",
137
- "@epam/ai-dial-chat-shared": "1.3.0-dev.149",
138
- "@epam/ai-dial-conversation-input": "1.3.0-dev.149",
139
- "@epam/ai-dial-mcp-apps": "1.3.0-dev.149",
140
- "@epam/ai-dial-publish-panel": "1.3.0-dev.149",
141
- "@epam/ai-dial-quotations": "1.3.0-dev.149",
133
+ "@epam/ai-dial-attachment-canvas": "1.3.0-dev.157",
134
+ "@epam/ai-dial-attachment-input": "1.3.0-dev.157",
135
+ "@epam/ai-dial-catalog": "1.3.0-dev.157",
136
+ "@epam/ai-dial-chat-overlay": "1.3.0-dev.157",
137
+ "@epam/ai-dial-chat-shared": "1.3.0-dev.157",
138
+ "@epam/ai-dial-conversation-input": "1.3.0-dev.157",
139
+ "@epam/ai-dial-mcp-apps": "1.3.0-dev.157",
140
+ "@epam/ai-dial-publish-panel": "1.3.0-dev.157",
141
+ "@epam/ai-dial-quotations": "1.3.0-dev.157",
142
142
  "@epam/ai-dial-react-file-manager": "^0.4.0-dev.11",
143
- "@epam/ai-dial-scheduled-tasks": "1.3.0-dev.149",
144
- "@epam/ai-dial-share": "1.3.0-dev.149",
145
- "@epam/ai-dial-skill-editor": "1.3.0-dev.149",
146
- "@epam/ai-dial-source-panel": "1.3.0-dev.149",
143
+ "@epam/ai-dial-scheduled-tasks": "1.3.0-dev.157",
144
+ "@epam/ai-dial-share": "1.3.0-dev.157",
145
+ "@epam/ai-dial-skill-editor": "1.3.0-dev.157",
146
+ "@epam/ai-dial-source-panel": "1.3.0-dev.157",
147
147
  "@epam/ai-dial-ui-kit": "^0.16.0-dev.22",
148
- "@epam/ai-dial-usage-dashboard": "1.3.0-dev.149",
148
+ "@epam/ai-dial-usage-dashboard": "1.3.0-dev.157",
149
149
  "@modelcontextprotocol/sdk": "^1.32.1",
150
150
  "@epam/pdf-highlighter-kit": "^0.0.19",
151
151
  "@mcp-ui/client": "^7.1.1"
@@ -1,6 +1,6 @@
1
- import { DeploymentLimitsResponseDto } from '@epam/ai-dial-chat-api-client';
2
1
  import { UsageLimitBannerSeverity } from '@epam/ai-dial-conversation-input';
3
2
  import { UsagePeriod } from './usage-period';
3
+ import { UsageLimitsSources } from './useDeploymentUsageLimits/useDeploymentUsageLimits';
4
4
  /** The day/week/month usage stat the composer banner reports on, and how close it is to its limit. */
5
5
  export interface UsageBannerSource {
6
6
  /** Calendar period of the stat. */
@@ -15,9 +15,10 @@ export interface UsageBannerSource {
15
15
  /** `true` when `total` is a real cap: finite, positive, and below DIAL Core's unlimited sentinel. */
16
16
  export declare const isCappedStat: (total: number) => boolean;
17
17
  /**
18
- * Returns the capped day/week/month token or cost stat with the highest
19
- * used/total ratio, classified against `thresholdPercent`, or `undefined` when
20
- * no stat is capped or the worst one is below the threshold.
18
+ * Returns the capped day/week/month token stat of `sources.deployment` or cost
19
+ * stat of `sources.account` with the highest used/total ratio, classified
20
+ * against `thresholdPercent`, or `undefined` when no stat is capped or the
21
+ * worst one is below the threshold.
21
22
  */
22
- export declare const selectUsageBannerSource: (dto: DeploymentLimitsResponseDto | undefined, thresholdPercent: number) => UsageBannerSource | undefined;
23
+ export declare const selectUsageBannerSource: (sources: UsageLimitsSources, thresholdPercent: number) => UsageBannerSource | undefined;
23
24
  //# sourceMappingURL=usage-banner-source.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"usage-banner-source.d.ts","sourceRoot":"","sources":["../../src/usage/usage-banner-source.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,2BAA2B,EAE5B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,sGAAsG;AACtG,MAAM,WAAW,iBAAiB;IAChC,mCAAmC;IACnC,MAAM,EAAE,WAAW,CAAC;IACpB,uDAAuD;IACvD,QAAQ,EAAE,wBAAwB,CAAC;IACnC,wEAAwE;IACxE,WAAW,EAAE,MAAM,CAAC;IACpB,6DAA6D;IAC7D,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;CAC9B;AAQD,qGAAqG;AACrG,eAAO,MAAM,YAAY,GAAI,OAAO,MAAM,KAAG,OAC4B,CAAC;AA8B1E;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,GAClC,KAAK,2BAA2B,GAAG,SAAS,EAC5C,kBAAkB,MAAM,KACvB,iBAAiB,GAAG,SAoCtB,CAAC"}
1
+ {"version":3,"file":"usage-banner-source.d.ts","sourceRoot":"","sources":["../../src/usage/usage-banner-source.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qDAAqD,CAAC;AAE9F,sGAAsG;AACtG,MAAM,WAAW,iBAAiB;IAChC,mCAAmC;IACnC,MAAM,EAAE,WAAW,CAAC;IACpB,uDAAuD;IACvD,QAAQ,EAAE,wBAAwB,CAAC;IACnC,wEAAwE;IACxE,WAAW,EAAE,MAAM,CAAC;IACpB,6DAA6D;IAC7D,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;CAC9B;AAQD,qGAAqG;AACrG,eAAO,MAAM,YAAY,GAAI,OAAO,MAAM,KAAG,OAC4B,CAAC;AAsC1E;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,GAClC,SAAS,kBAAkB,EAC3B,kBAAkB,MAAM,KACvB,iBAAiB,GAAG,SAsCtB,CAAC"}
@@ -2,22 +2,46 @@ import { UsagePeriod as e } from "./usage-period.js";
2
2
  import { UsageLimitBannerSeverity as t } from "@epam/ai-dial-conversation-input";
3
3
  //#region src/usage/usage-banner-source.ts
4
4
  var n = 2 ** 53 - 1, r = (e) => Number.isFinite(e) && e > 0 && e < n, i = [
5
- ["monthTokenStats", e.Month],
6
- ["monthCostStats", e.Month],
7
- ["weekTokenStats", e.Week],
8
- ["weekCostStats", e.Week],
9
- ["dayTokenStats", e.Day],
10
- ["dayCostStats", e.Day]
5
+ [
6
+ "deployment",
7
+ "monthTokenStats",
8
+ e.Month
9
+ ],
10
+ [
11
+ "account",
12
+ "monthCostStats",
13
+ e.Month
14
+ ],
15
+ [
16
+ "deployment",
17
+ "weekTokenStats",
18
+ e.Week
19
+ ],
20
+ [
21
+ "account",
22
+ "weekCostStats",
23
+ e.Week
24
+ ],
25
+ [
26
+ "deployment",
27
+ "dayTokenStats",
28
+ e.Day
29
+ ],
30
+ [
31
+ "account",
32
+ "dayCostStats",
33
+ e.Day
34
+ ]
11
35
  ], a = (e, n) => {
12
36
  let a;
13
- for (let [t, n] of i) {
14
- let i = e?.[t];
37
+ for (let [t, n, o] of i) {
38
+ let i = e[t]?.[n];
15
39
  if (i == null || !r(i.total)) continue;
16
- let o = Math.max(i.used, 0) / i.total;
17
- (a == null || o > a.ratio) && (a = {
40
+ let s = Math.max(i.used, 0) / i.total;
41
+ (a == null || s > a.ratio) && (a = {
18
42
  stat: i,
19
- period: n,
20
- ratio: o
43
+ period: o,
44
+ ratio: s
21
45
  });
22
46
  }
23
47
  if (a == null) return;
@@ -1,32 +1,56 @@
1
- import { DeploymentLimitsResponseDto } from '@epam/ai-dial-chat-api-client';
2
- /** Host-configured call that fetches the limits of one deployment. */
3
- export type GetDeploymentLimits = (deploymentId: string) => Promise<DeploymentLimitsResponseDto>;
1
+ import { DeploymentLimitsResponseDto, UserLimitStatsResponseDto } from '@epam/ai-dial-chat-api-client';
2
+ /** The caller's account-wide cost budget and spend: the top level of a user-usage response. */
3
+ export type AccountUsage = Pick<UserLimitStatsResponseDto, 'dayCostStats' | 'weekCostStats' | 'monthCostStats'>;
4
+ /**
5
+ * What the usage dial and the usage banner are mapped from. Each field has a
6
+ * single scope, so a deployment's figures are never read as the account's or
7
+ * the other way round.
8
+ */
9
+ export interface UsageLimitsSources {
10
+ /** The selected deployment's own stats (its deployment-usage response). Only its token stats are read. */
11
+ deployment: DeploymentLimitsResponseDto | undefined;
12
+ /** The caller's account budget and spend. Only its cost stats are read. */
13
+ account: AccountUsage | undefined;
14
+ }
15
+ /** Host-configured calls that fetch the two usage sources. */
16
+ export interface UsageLimitsApi {
17
+ /** Fetches one deployment's own usage, every stat scoped to that deployment. */
18
+ getDeploymentUsage: (deploymentId: string) => Promise<DeploymentLimitsResponseDto>;
19
+ /** Fetches the caller's account usage; only its top-level cost stats are read. */
20
+ getAccountUsage: () => Promise<AccountUsage>;
21
+ }
4
22
  /** Return shape of {@link useDeploymentUsageLimits}. */
5
23
  export interface UseDeploymentUsageLimitsResult {
6
- /** Raw limits response for the selected deployment, or `undefined` before the first success. */
7
- limitsDto: DeploymentLimitsResponseDto | undefined;
8
- /** `true` while a fetch is in flight. */
24
+ /** The last successfully fetched value of each source. */
25
+ sources: UsageLimitsSources;
26
+ /** `true` until both calls of the current fetch have settled. */
9
27
  isLoading: boolean;
10
- /** `true` after the most recent fetch rejected. */
28
+ /** `true` after either call of the most recent fetch rejected. */
11
29
  hasError: boolean;
12
- /** Re-fetches the current deployment when no request is in flight. */
30
+ /** Re-fetches both sources when no request is in flight. */
13
31
  refresh: () => void;
14
32
  }
15
33
  /**
16
- * Fetches the selected deployment's usage limits via the provided
17
- * `getDeploymentLimits` function. The hook accepts the fetch function as a
18
- * parameter so the caller supplies an already-configured API client — the hook
19
- * never constructs or imports one itself. The function's identity is not a
20
- * re-fetch trigger; only `deploymentId` and `refresh()` are.
34
+ * Fetches the selected deployment's own usage and the caller's account usage
35
+ * through the provided `api`. The hook accepts the calls as a parameter so the
36
+ * caller supplies an already-configured API client; the hook never constructs
37
+ * or imports one itself. The identity of `api` is not a re-fetch trigger; only
38
+ * `deploymentId` and `refresh()` are.
39
+ *
40
+ * Two sources rather than one deployment-limits response: there, the cost
41
+ * stats add an application's aggregated callee cost to the account spend that
42
+ * already contains it, so an agent's spend would be counted twice.
21
43
  *
22
- * A monotonic request ID prevents a slower response for a previous deployment
23
- * from replacing the current value. Refresh failures preserve the last known
24
- * response so the open popover can surface a non-blocking error.
44
+ * Both calls share one monotonic request ID, so a slower response for a
45
+ * previous deployment never replaces the current value. Each source keeps its
46
+ * last known value when its own call fails, so the open popover can surface a
47
+ * non-blocking error while the other source still renders. The account source
48
+ * survives a deployment change, since it does not depend on the selection.
25
49
  *
26
- * The raw response is returned rather than a mapped display model: mapping
50
+ * The raw responses are returned rather than a mapped display model: mapping
27
51
  * needs the caller's translated labels and locale-bound reset formatter, and
28
52
  * holding the mapped value in state here would leave it stale after a language
29
53
  * change until the next fetch.
30
54
  */
31
- export declare const useDeploymentUsageLimits: (deploymentId: string | undefined, getDeploymentLimits: GetDeploymentLimits) => UseDeploymentUsageLimitsResult;
55
+ export declare const useDeploymentUsageLimits: (deploymentId: string | undefined, api: UsageLimitsApi) => UseDeploymentUsageLimitsResult;
32
56
  //# sourceMappingURL=useDeploymentUsageLimits.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useDeploymentUsageLimits.d.ts","sourceRoot":"","sources":["../../../src/usage/useDeploymentUsageLimits/useDeploymentUsageLimits.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAGjF,sEAAsE;AACtE,MAAM,MAAM,mBAAmB,GAAG,CAChC,YAAY,EAAE,MAAM,KACjB,OAAO,CAAC,2BAA2B,CAAC,CAAC;AAE1C,wDAAwD;AACxD,MAAM,WAAW,8BAA8B;IAC7C,gGAAgG;IAChG,SAAS,EAAE,2BAA2B,GAAG,SAAS,CAAC;IACnD,yCAAyC;IACzC,SAAS,EAAE,OAAO,CAAC;IACnB,mDAAmD;IACnD,QAAQ,EAAE,OAAO,CAAC;IAClB,sEAAsE;IACtE,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,wBAAwB,GACnC,cAAc,MAAM,GAAG,SAAS,EAChC,qBAAqB,mBAAmB,KACvC,8BAgEF,CAAC"}
1
+ {"version":3,"file":"useDeploymentUsageLimits.d.ts","sourceRoot":"","sources":["../../../src/usage/useDeploymentUsageLimits/useDeploymentUsageLimits.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,2BAA2B,EAC3B,yBAAyB,EAC1B,MAAM,+BAA+B,CAAC;AAGvC,+FAA+F;AAC/F,MAAM,MAAM,YAAY,GAAG,IAAI,CAC7B,yBAAyB,EACzB,cAAc,GAAG,eAAe,GAAG,gBAAgB,CACpD,CAAC;AAEF;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC,0GAA0G;IAC1G,UAAU,EAAE,2BAA2B,GAAG,SAAS,CAAC;IACpD,2EAA2E;IAC3E,OAAO,EAAE,YAAY,GAAG,SAAS,CAAC;CACnC;AAED,8DAA8D;AAC9D,MAAM,WAAW,cAAc;IAC7B,gFAAgF;IAChF,kBAAkB,EAAE,CAClB,YAAY,EAAE,MAAM,KACjB,OAAO,CAAC,2BAA2B,CAAC,CAAC;IAC1C,kFAAkF;IAClF,eAAe,EAAE,MAAM,OAAO,CAAC,YAAY,CAAC,CAAC;CAC9C;AAED,wDAAwD;AACxD,MAAM,WAAW,8BAA8B;IAC7C,0DAA0D;IAC1D,OAAO,EAAE,kBAAkB,CAAC;IAC5B,iEAAiE;IACjE,SAAS,EAAE,OAAO,CAAC;IACnB,kEAAkE;IAClE,QAAQ,EAAE,OAAO,CAAC;IAClB,4DAA4D;IAC5D,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,wBAAwB,GACnC,cAAc,MAAM,GAAG,SAAS,EAChC,KAAK,cAAc,KAClB,8BA6EF,CAAC"}
@@ -1,39 +1,34 @@
1
- import { useCallback as e, useEffect as t, useRef as n, useState as r } from "react";
1
+ import { useCallback as e, useEffect as t, useMemo as n, useRef as r, useState as i } from "react";
2
2
  //#region src/usage/useDeploymentUsageLimits/useDeploymentUsageLimits.ts
3
- var i = (i, a) => {
4
- let [o, s] = r(), [c, l] = r(!1), [u, d] = r(!1), [f, p] = r(0), m = n(0), h = n(!1), g = n(void 0), _ = n(a);
5
- _.current = a;
6
- let v = e(() => {
7
- h.current || p((e) => e + 1);
3
+ var a = (a, o) => {
4
+ let [s, c] = i(), [l, u] = i(), [d, f] = i(!1), [p, m] = i(!1), [h, g] = i(0), _ = r(0), v = r(!1), y = r(void 0), b = r(o);
5
+ b.current = o;
6
+ let x = e(() => {
7
+ v.current || g((e) => e + 1);
8
8
  }, []);
9
9
  return t(() => {
10
- let e = g.current !== i;
11
- if (g.current = i, !i) {
12
- m.current += 1, s(void 0), l(!1), d(!1), h.current = !1;
10
+ let e = y.current !== a;
11
+ if (y.current = a, !a) {
12
+ _.current += 1, c(void 0), f(!1), m(!1), v.current = !1;
13
13
  return;
14
14
  }
15
- e && s(void 0);
16
- let t = ++m.current, n = !1;
17
- return l(!0), d(!1), h.current = !0, (async () => {
18
- try {
19
- let e = await _.current(i);
20
- if (n || t !== m.current) return;
21
- s(e);
22
- } catch {
23
- if (n || t !== m.current) return;
24
- d(!0);
25
- } finally {
26
- !n && t === m.current && (l(!1), h.current = !1);
27
- }
15
+ e && c(void 0);
16
+ let t = ++_.current, n = !1, r = () => !n && t === _.current;
17
+ return f(!0), m(!1), v.current = !0, (async () => {
18
+ let [e, t] = await Promise.allSettled([b.current.getDeploymentUsage(a), b.current.getAccountUsage()]);
19
+ r() && (e.status === "fulfilled" && c(e.value), t.status === "fulfilled" && u(t.value), m(e.status === "rejected" || t.status === "rejected"), f(!1), v.current = !1);
28
20
  })(), () => {
29
21
  n = !0;
30
22
  };
31
- }, [i, f]), {
32
- limitsDto: o,
33
- isLoading: c,
34
- hasError: u,
35
- refresh: v
23
+ }, [a, h]), {
24
+ sources: n(() => ({
25
+ deployment: s,
26
+ account: l
27
+ }), [s, l]),
28
+ isLoading: d,
29
+ hasError: p,
30
+ refresh: x
36
31
  };
37
32
  };
38
33
  //#endregion
39
- export { i as useDeploymentUsageLimits };
34
+ export { a as useDeploymentUsageLimits };
@@ -1,6 +1,6 @@
1
1
  import { UsageLimitBannerViewProps } from '@epam/ai-dial-conversation-input';
2
2
  import { TranslateFn } from '../usage-reset-time';
3
- import { GetDeploymentLimits } from '../useDeploymentUsageLimits/useDeploymentUsageLimits';
3
+ import { UsageLimitsApi } from '../useDeploymentUsageLimits/useDeploymentUsageLimits';
4
4
  /**
5
5
  * i18n key strings the consuming app's translation bundle must define for
6
6
  * `useUsageLimitBanner` to produce translated strings, in addition to
@@ -29,8 +29,10 @@ export interface UseUsageLimitBannerOptions {
29
29
  deploymentId: string | undefined;
30
30
  /** Whether the selected deployment is currently generating a response. Defaults to `false`. */
31
31
  isGenerationInProgress?: boolean;
32
- /** Host-configured call that fetches one deployment's limits. */
33
- getDeploymentLimits: GetDeploymentLimits;
32
+ /** Host-configured call that fetches one deployment's own usage. */
33
+ getDeploymentUsage: UsageLimitsApi['getDeploymentUsage'];
34
+ /** Host-configured call that fetches the caller's account usage. */
35
+ getAccountUsage: UsageLimitsApi['getAccountUsage'];
34
36
  /** Used percentage at or above which a not-yet-exhausted limit raises a warning. */
35
37
  warningThresholdPercent: number;
36
38
  /** Active UI locale, used to format the reset time. */
@@ -47,10 +49,10 @@ export interface UseUsageLimitBannerResult {
47
49
  }
48
50
  /**
49
51
  * Everything the composer usage banner needs except its rendering: fetches the
50
- * selected deployment's limits, refreshes them after each generation, picks
51
- * the limit worth reporting, formats its sentences, and tracks tab-lifetime
52
- * dismissal. Spread `banner` onto `UsageLimitBannerView` from
53
- * `@epam/ai-dial-conversation-input`.
52
+ * selected deployment's own usage and the account usage, refreshes both after
53
+ * each generation, picks the limit worth reporting, formats its sentences, and
54
+ * tracks tab-lifetime dismissal. Spread `banner` onto `UsageLimitBannerView`
55
+ * from `@epam/ai-dial-conversation-input`.
54
56
  */
55
- export declare const useUsageLimitBanner: ({ deploymentId, isGenerationInProgress, getDeploymentLimits, warningThresholdPercent, activeLocale, t, }: UseUsageLimitBannerOptions) => UseUsageLimitBannerResult;
57
+ export declare const useUsageLimitBanner: ({ deploymentId, isGenerationInProgress, getDeploymentUsage, getAccountUsage, warningThresholdPercent, activeLocale, t, }: UseUsageLimitBannerOptions) => UseUsageLimitBannerResult;
56
58
  //# sourceMappingURL=useUsageLimitBanner.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useUsageLimitBanner.d.ts","sourceRoot":"","sources":["../../../src/usage/useUsageLimitBanner/useUsageLimitBanner.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,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AAC;AAC9E,OAAO,EACL,KAAK,cAAc,EAEpB,MAAM,sDAAsD,CAAC;AAI9D;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB;IACjC,0EAA0E;;IAE1E,2EAA2E;;IAE3E,4EAA4E;;IAE5E,0EAA0E;;IAE1E,2EAA2E;;IAE3E,4EAA4E;;IAE5E,2CAA2C;;CAEnC,CAAC;AAkBX,6CAA6C;AAC7C,MAAM,WAAW,0BAA0B;IACzC,+CAA+C;IAC/C,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,+FAA+F;IAC/F,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,oEAAoE;IACpE,kBAAkB,EAAE,cAAc,CAAC,oBAAoB,CAAC,CAAC;IACzD,oEAAoE;IACpE,eAAe,EAAE,cAAc,CAAC,iBAAiB,CAAC,CAAC;IACnD,oFAAoF;IACpF,uBAAuB,EAAE,MAAM,CAAC;IAChC,uDAAuD;IACvD,YAAY,EAAE,MAAM,CAAC;IACrB,gEAAgE;IAChE,CAAC,EAAE,WAAW,CAAC;CAChB;AAED,gEAAgE;AAChE,MAAM,MAAM,qBAAqB,GAAG,IAAI,CACtC,yBAAyB,EACzB,UAAU,GAAG,WAAW,GAAG,OAAO,GAAG,SAAS,GAAG,gBAAgB,CAClE,CAAC;AAEF,mDAAmD;AACnD,MAAM,WAAW,yBAAyB;IACxC,wIAAwI;IACxI,MAAM,EAAE,qBAAqB,GAAG,SAAS,CAAC;CAC3C;AAED;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,GAAI,0HAQjC,0BAA0B,KAAG,yBAqE/B,CAAC"}
@@ -26,41 +26,44 @@ var l = {
26
26
  [e.Week]: l.reachedWeek,
27
27
  [e.Month]: l.reachedMonth
28
28
  }
29
- }, d = ({ deploymentId: e, isGenerationInProgress: c = !1, getDeploymentLimits: d, warningThresholdPercent: f, activeLocale: p, t: m }) => {
30
- let { limitsDto: h, isLoading: g, refresh: _ } = r(e, d), { isDismissed: v, dismiss: y } = a();
29
+ }, d = ({ deploymentId: e, isGenerationInProgress: c = !1, getDeploymentUsage: d, getAccountUsage: f, warningThresholdPercent: p, activeLocale: m, t: h }) => {
30
+ let g = s(() => ({
31
+ getDeploymentUsage: d,
32
+ getAccountUsage: f
33
+ }), [d, f]), { sources: _, isLoading: v, refresh: y } = r(e, g), { isDismissed: b, dismiss: x } = a();
31
34
  i({
32
35
  isGenerationInProgress: c,
33
- isLoading: g,
34
- refresh: _
36
+ isLoading: v,
37
+ refresh: y
35
38
  });
36
- let b = s(() => t(h, f), [h, f]), x = s(() => {
37
- if (b != null && e) return {
38
- dismissalKey: `${e}:${b.period}:${b.severity}`,
39
- limitText: m(u[b.severity][b.period], { percent: b.usedPercent }),
40
- reset: n(b.resetsAt, b.period, p, m)
39
+ let S = s(() => t(_, p), [_, p]), C = s(() => {
40
+ if (S != null && e) return {
41
+ dismissalKey: `${e}:${S.period}:${S.severity}`,
42
+ limitText: h(u[S.severity][S.period], { percent: S.usedPercent }),
43
+ reset: n(S.resetsAt, S.period, m, h)
41
44
  };
42
45
  }, [
43
- b,
46
+ S,
44
47
  e,
45
- p,
46
- m
47
- ]), S = x?.dismissalKey, C = o(() => {
48
- S != null && y(S);
49
- }, [y, S]), w = m(l.closeLabel);
48
+ m,
49
+ h
50
+ ]), w = C?.dismissalKey, T = o(() => {
51
+ w != null && x(w);
52
+ }, [x, w]), E = h(l.closeLabel);
50
53
  return { banner: s(() => {
51
- if (!(b == null || x == null || v(x.dismissalKey))) return {
52
- severity: b.severity,
53
- limitText: x.limitText,
54
- reset: x.reset,
55
- onClose: C,
56
- closeAriaLabel: w
54
+ if (!(S == null || C == null || b(C.dismissalKey))) return {
55
+ severity: S.severity,
56
+ limitText: C.limitText,
57
+ reset: C.reset,
58
+ onClose: T,
59
+ closeAriaLabel: E
57
60
  };
58
61
  }, [
59
- b,
60
- x,
61
- v,
62
+ S,
62
63
  C,
63
- w
64
+ b,
65
+ T,
66
+ E
64
67
  ]) };
65
68
  };
66
69
  //#endregion