@box/box-ai-content-answers 0.67.2 → 0.69.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.
@@ -1,10 +1,10 @@
1
- import { useReducer as I, useEffect as J } from "react";
1
+ import { useReducer as J, useEffect as K } from "react";
2
2
  import { R as a } from "../../../../chunks/types.js";
3
- import { useContentAnswers as K } from "./hooks/useContentAnswers.js";
4
- import { ContentAnswersRecord as M, ContentAnswersItemRecord as V } from "./records.js";
5
- import W from "./reducer.js";
6
- import { jsx as X } from "react/jsx-runtime";
7
- const ne = ({
3
+ import { useContentAnswers as M } from "./hooks/useContentAnswers.js";
4
+ import { ContentAnswersRecord as V, ContentAnswersItemRecord as W } from "./records.js";
5
+ import X from "./reducer.js";
6
+ import { jsx as Y } from "react/jsx-runtime";
7
+ const re = ({
8
8
  WrappedComponent: d,
9
9
  createSessionRequest: f,
10
10
  getAgentConfig: m,
@@ -25,28 +25,29 @@ const ne = ({
25
25
  isStopResponseEnabled: q,
26
26
  isStreamingEnabled: r,
27
27
  itemID: o,
28
- onCloseModal: E,
29
- shouldRenderProviders: j = !0,
30
- suggestedQuestions: U,
31
- warningNotice: _,
32
- warningNoticeAriaLabel: v
28
+ itemIDs: E,
29
+ onCloseModal: j,
30
+ shouldRenderProviders: U = !0,
31
+ suggestedQuestions: _,
32
+ warningNotice: v,
33
+ warningNoticeAriaLabel: x
33
34
  }) => {
34
- const [u, x] = I(W, new M({
35
- item: new V({
35
+ const [u, y] = J(X, new V({
36
+ item: new W({
36
37
  id: o
37
38
  })
38
39
  })), {
39
- clearConversation: y,
40
- createSession: L,
40
+ clearConversation: L,
41
+ createSession: N,
41
42
  fetchAgentConfig: c,
42
43
  fetchSuggestedQuestions: i,
43
- retryQuestion: N,
44
- sendQuestion: O,
45
- stopQuestion: P
46
- } = K({
44
+ retryQuestion: O,
45
+ sendQuestion: P,
46
+ stopQuestion: b
47
+ } = M({
47
48
  contentAnswers: u,
48
49
  createSessionRequest: f,
49
- dispatchStateUpdate: x,
50
+ dispatchStateUpdate: y,
50
51
  fetchTimeout: g,
51
52
  formatCitations: A,
52
53
  getAgentConfig: m,
@@ -58,53 +59,54 @@ const ne = ({
58
59
  isStreamingEnabled: r,
59
60
  itemID: o
60
61
  }), {
61
- encodedSession: b,
62
- error: k,
63
- isLoading: z,
64
- hasRequestInProgress: B = !1,
65
- questions: D,
62
+ encodedSession: k,
63
+ error: z,
64
+ isLoading: B,
65
+ hasRequestInProgress: D = !1,
66
+ questions: F,
66
67
  suggestedQuestions: t
67
68
  } = u;
68
- J(() => {
69
+ K(() => {
69
70
  s && t.requestState === a.NOT_STARTED && i();
70
71
  }, [s, i, t.requestState]);
71
- const F = {
72
- createSession: L,
73
- encodedSession: b,
74
- error: k,
72
+ const G = {
73
+ createSession: N,
74
+ encodedSession: k,
75
+ error: z,
75
76
  getAIStudioAgents: S,
76
77
  hostAppName: R,
77
78
  hasCustomSuggestedQuestions: !!e,
78
- hasRequestInProgress: B,
79
+ hasRequestInProgress: D,
79
80
  isAgentSelectorEnabled: w,
80
81
  isAIStudioAgentSelectorEnabled: Q,
81
82
  isCitationsEnabled: n,
82
83
  isDebugModeEnabled: T,
83
84
  isMarkdownEnabled: h,
84
- isLoading: z,
85
+ isLoading: B,
85
86
  isOpen: s,
86
87
  isResetChatEnabled: l,
87
88
  isStreamingEnabled: r,
88
89
  itemID: o,
89
- onClearAction: y,
90
- onCloseModal: E,
90
+ itemIDs: E,
91
+ onClearAction: L,
92
+ onCloseModal: j,
91
93
  onSelectAgent: c,
92
94
  onAgentEditorToggle: c,
93
- questions: D,
94
- retryQuestion: N,
95
- sendQuestion: O,
96
- shouldRenderProviders: j,
97
- stopQuestion: P,
95
+ questions: F,
96
+ retryQuestion: O,
97
+ sendQuestion: P,
98
+ shouldRenderProviders: U,
99
+ stopQuestion: b,
98
100
  suggestedQuestionsRequestState: e ? t.requestState : a.SUCCESS,
99
- suggestedQuestions: e ? t.suggestions : U,
100
- warningNotice: _,
101
- warningNoticeAriaLabel: v
102
- }, G = Object.fromEntries(Object.entries(F).filter(([Y, H]) => H !== void 0));
103
- return /* @__PURE__ */ X(d, {
104
- ...G
101
+ suggestedQuestions: e ? t.suggestions : _,
102
+ warningNotice: v,
103
+ warningNoticeAriaLabel: x
104
+ }, H = Object.fromEntries(Object.entries(G).filter(([Z, I]) => I !== void 0));
105
+ return /* @__PURE__ */ Y(d, {
106
+ ...H
105
107
  });
106
108
  };
107
109
  export {
108
- ne as ContentAnswersComponent,
109
- ne as default
110
+ re as ContentAnswersComponent,
111
+ re as default
110
112
  };
@@ -1,33 +1,34 @@
1
1
  import B from "lodash/camelCase";
2
- import o, { useCallback as Z } from "react";
3
- import { useAgentsDispatch as h } from "../../../contexts/AgentsContext.js";
4
- import { A as T, C as w, R as q } from "../../../../../chunks/types.js";
5
- import { SET_NEW_ITEM as U, UPDATE_QUESTION as ss, SET_MODAL_ERROR as es, SET_MODAL_SUCCESS as ts, SET_IS_LOADING as os, CLEAR_CONVERSATION_HISTORY as ns, SET_SUGGESTED_QUESTIONS_REQUEST_STATE as D, SET_SUGGESTED_QUESTIONS as as } from "../actions.js";
6
- import { QuestionRecord as is } from "../records.js";
7
- import { defaultFormatSuggestions as us, defaultFormatCitations as ls } from "../utils/format.js";
8
- import { getAnswerRequest as cs } from "../utils/request.js";
9
- import Q from "../utils/stream.js";
10
- const Es = /Too Many Requests/i, j = "Agent not found";
11
- function ds({
2
+ import t, { useCallback as Z } from "react";
3
+ import { useAgentsDispatch as w } from "../../../contexts/AgentsContext.js";
4
+ import { A as T, C as U, R as j } from "../../../../../chunks/types.js";
5
+ import { SET_NEW_ITEM as ss, UPDATE_QUESTION as es, SET_MODAL_ERROR as os, SET_MODAL_SUCCESS as ts, SET_IS_LOADING as ns, CLEAR_CONVERSATION_HISTORY as as, SET_SUGGESTED_QUESTIONS_REQUEST_STATE as x, SET_SUGGESTED_QUESTIONS as is } from "../actions.js";
6
+ import { QuestionRecord as us } from "../records.js";
7
+ import { defaultFormatSuggestions as ls, defaultFormatCitations as cs } from "../utils/format.js";
8
+ import { getAnswerRequest as rs } from "../utils/request.js";
9
+ import G from "../utils/stream.js";
10
+ const Es = /Too Many Requests/i, $ = "Agent not found";
11
+ function ms({
12
12
  contentAnswers: i,
13
- createSessionRequest: G,
14
- dispatchStateUpdate: t,
15
- fetchTimeout: m,
16
- getAgentConfig: S,
13
+ createSessionRequest: g,
14
+ dispatchStateUpdate: o,
15
+ fetchTimeout: S,
16
+ getAgentConfig: y,
17
17
  getAnswerStreaming: k,
18
- getAnswer: g,
19
- getSuggestedQuestions: d,
20
- isCitationsEnabled: rs,
21
- isStopResponseEnabled: p,
22
- isStreamingEnabled: O,
18
+ getAnswer: p,
19
+ getSuggestedQuestions: m,
20
+ isCitationsEnabled: fs,
21
+ isStopResponseEnabled: M,
22
+ isStreamingEnabled: N,
23
23
  itemID: l,
24
- formatCitations: I = ls
24
+ itemIDs: O,
25
+ formatCitations: F = cs
25
26
  }) {
26
- const x = o.useRef(null), M = h(), F = Z((s) => Array.isArray(s) ? I(s) : null, [I]);
27
- o.useEffect(
27
+ const V = t.useRef(null), I = w(), P = Z((s) => Array.isArray(s) ? F(s) : null, [F]);
28
+ t.useEffect(
28
29
  (s) => {
29
- l && l !== i.item.id && t({
30
- type: U,
30
+ l && l !== i.item.id && o({
31
+ type: ss,
31
32
  itemID: l,
32
33
  fileVersionID: s
33
34
  });
@@ -35,29 +36,29 @@ function ds({
35
36
  // eslint-disable-next-line react-hooks/exhaustive-deps
36
37
  [l]
37
38
  );
38
- const E = o.useCallback((s, e) => {
39
- t({
40
- type: ss,
39
+ const r = t.useCallback((s, e) => {
40
+ o({
41
+ type: es,
41
42
  newQuestion: s,
42
43
  session: e
43
- }), x.current = s;
44
- }, [t]), P = o.useCallback((s) => {
45
- t({
46
- type: es,
44
+ }), V.current = s;
45
+ }, [o]), v = t.useCallback((s) => {
46
+ o({
47
+ type: os,
47
48
  error: s
48
49
  });
49
- }, [t]), y = o.useCallback((s, e, n) => {
50
+ }, [o]), A = t.useCallback((s, e, n) => {
50
51
  const {
51
52
  answer: u,
52
53
  error: c,
53
54
  citations: a = [],
54
- createdAt: r = null,
55
+ createdAt: E = null,
55
56
  encodedSession: f = void 0,
56
57
  contextSession: _ = void 0
57
- } = s, R = e.set("citations", F(a)).merge({
58
+ } = s, R = e.set("citations", P(a)).merge({
58
59
  answer: u,
59
60
  error: c,
60
- created_at: r,
61
+ created_at: E,
61
62
  isLoading: !1,
62
63
  isCompleted: n
63
64
  });
@@ -66,71 +67,71 @@ function ds({
66
67
  encodedSession: f
67
68
  }), _ && (C = {
68
69
  contextSession: _
69
- }), E(R, C);
70
- }, [E, F]), b = o.useCallback(
70
+ }), r(R, C);
71
+ }, [r, P]), b = t.useCallback(
71
72
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
72
73
  (s, e) => {
73
- var R, C, N;
74
- const n = (s == null ? void 0 : s.message) || "", u = ((R = s == null ? void 0 : s.response) == null ? void 0 : R.status) === 429 || Es.test(n), c = (s == null ? void 0 : s.code) === j || (s == null ? void 0 : s.errorCode) === j, a = ((C = s == null ? void 0 : s.response) == null ? void 0 : C.status) === 204, r = ((N = s == null ? void 0 : s.response) == null ? void 0 : N.status) === 412, f = a ? T.NO_CONTENT : u ? T.RATE_LIMITING : r ? T.PRECONDITION_FAILED : c ? T.AGENT_NOT_FOUND : T.GENERAL, _ = e.merge({
74
+ var R, C, d;
75
+ const n = (s == null ? void 0 : s.message) || "", u = ((R = s == null ? void 0 : s.response) == null ? void 0 : R.status) === 429 || Es.test(n), c = (s == null ? void 0 : s.code) === $ || (s == null ? void 0 : s.errorCode) === $, a = ((C = s == null ? void 0 : s.response) == null ? void 0 : C.status) === 204, E = ((d = s == null ? void 0 : s.response) == null ? void 0 : d.status) === 412, f = a ? T.NO_CONTENT : u ? T.RATE_LIMITING : E ? T.PRECONDITION_FAILED : c ? T.AGENT_NOT_FOUND : T.GENERAL, _ = e.merge({
75
76
  error: f,
76
77
  isLoading: !1,
77
78
  isCompleted: !0
78
79
  });
79
- E(_, void 0);
80
+ r(_, void 0);
80
81
  },
81
- [E]
82
- ), A = o.useCallback(async (s, e) => {
82
+ [r]
83
+ ), L = t.useCallback(async (s, e) => {
83
84
  try {
84
85
  const n = {
85
86
  prompt: s.prompt,
86
87
  aiAgent: e || void 0
87
88
  }, u = `content-answers-${s.id}`;
88
89
  let c;
89
- O && (c = Q.createAbortRequest(u));
90
- const a = await cs(n, O, u, l, i, g, k, c, m);
91
- O ? Q.receiveStreamedResponse(u, a, (r) => {
90
+ N && (c = G.createAbortRequest(u));
91
+ const a = await rs(n, N, u, l, O, i, p, k, c, S);
92
+ N ? G.receiveStreamedResponse(u, a, (E) => {
92
93
  const {
93
94
  code: f,
94
95
  data: _,
95
96
  error: R,
96
97
  citations: C,
97
- contextSession: N,
98
- isCompleted: X,
99
- createdAt: Y
100
- } = r, z = {
98
+ contextSession: d,
99
+ isCompleted: Y,
100
+ createdAt: h
101
+ } = E, z = {
101
102
  answer: _,
102
103
  citations: C,
103
104
  error: R,
104
- contextSession: N,
105
- createdAt: Y
105
+ contextSession: d,
106
+ createdAt: h
106
107
  };
107
- a.ok && a.status === 200 ? y({
108
+ a.ok && a.status === 200 ? A({
108
109
  ...z
109
- }, s, X) : b({
110
+ }, s, Y) : b({
110
111
  response: a,
111
112
  code: f
112
113
  }, s);
113
- }, void 0, m) : (Object.entries(a).forEach(([r, f]) => {
114
- const _ = B(r);
115
- delete a[r], a[_] = f;
116
- }), y(a, s, !0));
114
+ }, void 0, S) : (Object.entries(a).forEach(([E, f]) => {
115
+ const _ = B(E);
116
+ delete a[E], a[_] = f;
117
+ }), A(a, s, !0));
117
118
  } catch (n) {
118
- if (p && n instanceof Error && n.name === "AbortError") {
119
+ if (M && n instanceof Error && n.name === "AbortError") {
119
120
  const u = s.set("error", []).merge({
120
121
  error: T.RESPONSE_STOPPED,
121
122
  isLoading: !1,
122
123
  isCompleted: !0
123
124
  });
124
- E(u);
125
+ r(u);
125
126
  } else
126
127
  b(n, s);
127
128
  }
128
- }, [O, l, i, g, k, m, y, b, p, E]), L = o.useCallback((s, e, n = !0) => {
129
+ }, [N, l, O, i, p, k, S, A, b, M, r]), Q = t.useCallback((s, e, n = !0) => {
129
130
  const u = (i == null ? void 0 : i.questions) || [];
130
131
  n && (s.id = `${u.length}`);
131
- const c = new is(s);
132
- return E(c), A(c, e), c;
133
- }, [i == null ? void 0 : i.questions, A, E]), v = o.useCallback((s) => {
132
+ const c = new us(s);
133
+ return r(c), L(c, e), c;
134
+ }, [i == null ? void 0 : i.questions, L, r]), q = t.useCallback((s) => {
134
135
  const {
135
136
  encoded_session: e,
136
137
  metadata: {
@@ -139,81 +140,82 @@ function ds({
139
140
  is_large_file: !1
140
141
  }
141
142
  } = s;
142
- t({
143
+ o({
143
144
  type: ts,
144
145
  encodedSession: e,
145
146
  isLargeFile: n
146
147
  });
147
- }, [t]), $ = o.useCallback(async () => {
148
+ }, [o]), W = t.useCallback(async () => {
148
149
  try {
149
- t({
150
- type: os,
150
+ o({
151
+ type: ns,
151
152
  isLoading: !0
152
153
  });
153
- const s = await G({
154
+ const s = await g({
154
155
  items: [i.item]
155
156
  }, l);
156
- v(s);
157
+ q(s);
157
158
  } catch {
158
- P(w.GENERAL);
159
+ v(U.GENERAL);
159
160
  }
160
- }, [t, G, i.item, l, v, P]), V = o.useCallback(() => {
161
- t({
162
- type: ns
161
+ }, [o, g, i.item, l, q, v]), D = t.useCallback(() => {
162
+ o({
163
+ type: as
163
164
  });
164
- }, [t]), W = o.useCallback(async (s, e) => {
165
- L({
165
+ }, [o]), H = t.useCallback(async (s, e) => {
166
+ Q({
166
167
  ...s.toJS(),
167
168
  answer: "",
168
169
  isLoading: !0,
169
170
  isCompleted: !1,
170
171
  error: null
171
172
  }, e, !1);
172
- }, [L]), H = o.useCallback((s) => {
173
- Q.abortRequest(`content-answers-${s.id}`, !0);
174
- }, []), J = o.useCallback(async (s) => {
175
- if (S)
173
+ }, [Q]), J = t.useCallback((s) => {
174
+ G.abortRequest(`content-answers-${s.id}`, !0);
175
+ }, []), K = t.useCallback(async (s) => {
176
+ if (y)
176
177
  try {
177
- const e = await S(s);
178
- M({
178
+ const e = await y(s);
179
+ I({
179
180
  type: "OVERRIDE_AGENT_CONFIG",
180
181
  agentName: s.name,
181
182
  agentConfig: e
182
183
  });
183
184
  } catch {
184
185
  }
185
- }, [M, S]), K = o.useCallback(async () => {
186
- if (d) {
187
- t({
188
- type: D,
189
- requestState: q.IN_PROGRESS
186
+ }, [I, y]), X = t.useCallback(async () => {
187
+ const s = Array.isArray(O) && O.length > 1;
188
+ if (!(!m || s)) {
189
+ o({
190
+ type: x,
191
+ requestState: j.IN_PROGRESS
190
192
  });
191
193
  try {
192
- const s = us(await d(l));
193
- t({
194
- type: as,
195
- suggestedQuestions: s
194
+ const e = ls(await m(l));
195
+ o({
196
+ type: is,
197
+ suggestedQuestions: e
196
198
  });
197
199
  } catch {
198
- t({
199
- type: D,
200
- requestState: q.ERROR
200
+ o({
201
+ type: x,
202
+ requestState: j.ERROR
201
203
  });
202
204
  }
203
205
  }
204
- }, [t, d, l]);
206
+ }, [o, m, l, O]);
205
207
  return {
206
- clearConversation: V,
207
- createSession: $,
208
- fetchAgentConfig: J,
209
- fetchSuggestedQuestions: K,
210
- retryQuestion: W,
211
- sendQuestion: L,
212
- sendQuestionAnswerRequest: A,
213
- stopQuestion: H,
214
- updateQuestionInState: E
208
+ clearConversation: D,
209
+ createSession: W,
210
+ fetchAgentConfig: K,
211
+ fetchSuggestedQuestions: X,
212
+ retryQuestion: H,
213
+ sendQuestion: Q,
214
+ sendQuestionAnswerRequest: L,
215
+ stopQuestion: J,
216
+ updateQuestionInState: r
215
217
  };
216
218
  }
217
219
  export {
218
- ds as useContentAnswers
220
+ ms as useContentAnswers
219
221
  };
@@ -1,11 +1,11 @@
1
- import b, { FETCH_TIMEOUT as m } from "./stream.js";
2
- const p = (i, s) => setTimeout(() => {
3
- b.abortRequest(i);
4
- }, s), E = async (i, s = !1, l, a, o, r, e, u, t) => {
1
+ import p, { FETCH_TIMEOUT as q } from "./stream.js";
2
+ const E = (i, s) => setTimeout(() => {
3
+ p.abortRequest(i);
4
+ }, s), m = async (i, s = !1, u, a, o, r, e, l, T, t) => {
5
5
  let n;
6
- const T = (t == null ? void 0 : t.initial) || m.initial, w = p(l, T);
7
- return s && e ? n = await e(i, a, u, o) : r && (n = await r(i, a, o)), clearTimeout(w), n;
6
+ const w = (t == null ? void 0 : t.initial) || q.initial, b = E(u, w);
7
+ return s && l ? n = await l(i, a, o, T, r) : e && (n = await e(i, a, o, r)), clearTimeout(b), n;
8
8
  };
9
9
  export {
10
- E as getAnswerRequest
10
+ m as getAnswerRequest
11
11
  };
@@ -1,10 +1,10 @@
1
1
  import "../../../../styles/footer.css";
2
2
  import * as e from "react";
3
3
  import { useIntl as D } from "react-intl";
4
- import { useBreakpoint as S, Breakpoint as Y, Avatar as J, TextArea as Q, Button as V } from "@box/blueprint-web";
5
- import { ArrowUp as Z } from "@box/blueprint-web-assets/icons/Line";
6
- import { useAgents as g } from "@box/box-ai-agent-selector";
7
- import { useAgents as q } from "../../contexts/AgentsContext.js";
4
+ import { useBreakpoint as S, Breakpoint as Y, Avatar as q, TextArea as J, Button as Q } from "@box/blueprint-web";
5
+ import { ArrowUp as V } from "@box/blueprint-web-assets/icons/Line";
6
+ import { useAgents as Z } from "@box/box-ai-agent-selector";
7
+ import { useAgents as g } from "../../contexts/AgentsContext.js";
8
8
  import { FooterActions as P } from "./footer-actions.js";
9
9
  import tt from "../../messages.js";
10
10
  import { getAIAgentConfig as X } from "../common/agentUtils.js";
@@ -19,48 +19,48 @@ const st = "_questionInput_1pdo1_1", it = "_avatar_1pdo1_11", nt = "_submitButto
19
19
  submitButton: nt,
20
20
  textArea: mt,
21
21
  submitButtonTooltip: ut
22
- }, Et = ({
22
+ }, Tt = ({
23
23
  askSuggestedQuestion: h,
24
- contentType: T,
24
+ contentType: x,
25
25
  enableDebugMode: b = !1,
26
26
  hasRequestInProgress: r,
27
27
  isAgentSelectorEnabled: f,
28
28
  isAIStudioAgentSelectorEnabled: _,
29
- isDebugModeShown: k,
29
+ isDebugModeShown: L,
30
30
  isSidebarOpen: H = !1,
31
31
  isStopResponseEnabled: y,
32
32
  isStreamingEnabled: F,
33
- lastQuestion: L,
34
- onRetryQuestion: E,
33
+ lastQuestion: M,
34
+ onRetryQuestion: T,
35
35
  onStopQuestion: I,
36
36
  recordAction: o,
37
- sendQuestion: M,
37
+ sendQuestion: E,
38
38
  setAskSuggestedQuestion: B,
39
39
  toggleDebugMode: n,
40
40
  user: G
41
41
  }) => {
42
42
  const s = D(), K = S(), a = /* @__PURE__ */ e.createRef(), v = K <= Y.Medium || H, [c, N] = e.useState(!0), [j, O] = e.useState(!1), {
43
43
  selectedAgent: d
44
- } = q(), {
44
+ } = g(), {
45
45
  selectedAgent: C
46
- } = g(), x = e.useCallback(() => {
46
+ } = Z(), k = e.useCallback(() => {
47
47
  a.current && a.current.focus();
48
48
  }, [a]), U = e.useCallback(() => {
49
49
  var m;
50
50
  let t = ((m = a.current) == null ? void 0 : m.value) ?? "";
51
51
  a.current && t.length > i.MAX_LENGTH && (a.current.value = t.slice(0, i.MAX_LENGTH), t = a.current.value), O(t.length >= i.MAX_LENGTH), N(t.trim().length === 0);
52
52
  }, [a]), l = e.useCallback(() => {
53
- if (x(), !r && a.current) {
53
+ if (k(), !r && a.current) {
54
54
  const t = {
55
55
  prompt: a.current.value
56
56
  };
57
57
  if (t.prompt && t.prompt.trim()) {
58
58
  const m = X(f, d, _, C);
59
- M(t, m), a.current.value = "", N(!0), O(!1);
59
+ E(t, m), a.current.value = "", N(!0), O(!1);
60
60
  }
61
- k && n && n();
61
+ L && n && n();
62
62
  }
63
- }, [C, x, r, a, _, f, k, d, M, n]), W = e.useCallback((t) => {
63
+ }, [C, k, r, a, _, f, L, d, E, n]), W = e.useCallback((t) => {
64
64
  t.preventDefault(), !r && !c && o && o({
65
65
  ...R,
66
66
  action: rt,
@@ -74,17 +74,17 @@ const st = "_questionInput_1pdo1_1", it = "_avatar_1pdo1_11", nt = "_submitButto
74
74
  }), l());
75
75
  }, [b, r, c, o, l, n]), z = e.useCallback((t) => {
76
76
  const m = X(f, d, _, C);
77
- E(t, m);
78
- }, [C, _, f, E, d]);
77
+ T(t, m);
78
+ }, [C, _, f, T, d]);
79
79
  return e.useEffect(() => {
80
- setTimeout(x, 0);
80
+ queueMicrotask(k);
81
81
  }, []), e.useEffect(() => {
82
82
  h && a.current && !r && B && (a.current.value = h, l(), B(null));
83
83
  }, [h]), /* @__PURE__ */ w("div", {
84
- children: [L && /* @__PURE__ */ p(P, {
84
+ children: [M && /* @__PURE__ */ p(P, {
85
85
  isStopResponseEnabled: y,
86
86
  isStreamingEnabled: F,
87
- lastQuestion: L,
87
+ lastQuestion: M,
88
88
  onRetryQuestion: z,
89
89
  onStopQuestion: I,
90
90
  recordAction: o
@@ -93,13 +93,13 @@ const st = "_questionInput_1pdo1_1", it = "_avatar_1pdo1_11", nt = "_submitButto
93
93
  children: [!v && /* @__PURE__ */ p("div", {
94
94
  className: A.avatar,
95
95
  "data-testid": "content-answers-question-input-avatar",
96
- children: /* @__PURE__ */ p(J, {
96
+ children: /* @__PURE__ */ p(q, {
97
97
  alt: s.formatMessage(tt.userAvatar),
98
98
  colorIndex: 0,
99
99
  src: G.avatarURL,
100
100
  text: G.name.charAt(0)
101
101
  })
102
- }), /* @__PURE__ */ p(Q, {
102
+ }), /* @__PURE__ */ p(J, {
103
103
  ref: a,
104
104
  className: A.textArea,
105
105
  "data-testid": "content-answers-question-input",
@@ -108,21 +108,21 @@ const st = "_questionInput_1pdo1_1", it = "_avatar_1pdo1_11", nt = "_submitButto
108
108
  }),
109
109
  hideLabel: !0,
110
110
  label: s.formatMessage(u.askQuestionPlaceholder, {
111
- type: T
111
+ type: x
112
112
  }),
113
113
  maxLength: i.MAX_LENGTH,
114
114
  maxRows: v ? i.MAX_ROWS_MOBILE : i.MAX_ROWS,
115
115
  onChange: U,
116
116
  onKeyDown: $,
117
117
  placeholder: s.formatMessage(u.askQuestionPlaceholder, {
118
- type: T
118
+ type: x
119
119
  })
120
- }), /* @__PURE__ */ p(V, {
120
+ }), /* @__PURE__ */ p(Q, {
121
121
  "aria-label": s.formatMessage(u.ask),
122
122
  className: A.submitButton,
123
123
  "data-testid": "content-answers-submit-button",
124
124
  disabled: c || r,
125
- icon: v ? Z : void 0,
125
+ icon: v ? V : void 0,
126
126
  loading: r,
127
127
  loadingAriaLabel: s.formatMessage(u.askDisabledTooltip),
128
128
  onClick: W,
@@ -133,5 +133,5 @@ const st = "_questionInput_1pdo1_1", it = "_avatar_1pdo1_11", nt = "_submitButto
133
133
  });
134
134
  };
135
135
  export {
136
- Et as Footer
136
+ Tt as Footer
137
137
  };
@@ -1,43 +1,43 @@
1
1
  import "../../../../styles/suggested-questions.css";
2
- import { Text as u, LoadingIndicator as E } from "@box/blueprint-web";
3
- import { AlertTriangle as O } from "@box/blueprint-web-assets/icons/Line";
4
- import { Gray65 as R, Size4 as d } from "@box/blueprint-web-assets/tokens/tokens";
5
- import m from "clsx";
6
- import * as b from "react";
7
- import { useIntl as h } from "react-intl";
2
+ import { Text as E, LoadingIndicator as O } from "@box/blueprint-web";
3
+ import { AlertTriangle as R } from "@box/blueprint-web-assets/icons/Line";
4
+ import { Gray65 as b, Size4 as m } from "@box/blueprint-web-assets/tokens/tokens";
5
+ import g from "clsx";
6
+ import * as h from "react";
7
+ import { useIntl as u } from "react-intl";
8
8
  import { Suggestions as v } from "./suggestions.js";
9
9
  import { R as r } from "../../../../chunks/types.js";
10
- import { LOGGER_BASE_CONFIG as C } from "../common/constants.js";
10
+ import { LOGGER_BASE_CONFIG as N } from "../common/constants.js";
11
11
  import i from "./messages.js";
12
- import { jsxs as N, jsx as o } from "react/jsx-runtime";
13
- const w = "_wrapper_10vng_1", x = "_isSidebarOpen_10vng_5", G = "_label_10vng_9", T = "_loadingIndicator_10vng_20", y = "_alertIcon_10vng_28", a = {
14
- wrapper: w,
15
- isSidebarOpen: x,
12
+ import { jsxs as w, jsx as n } from "react/jsx-runtime";
13
+ const x = "_wrapper_10vng_1", C = "_isSidebarOpen_10vng_5", G = "_label_10vng_9", T = "_loadingIndicator_10vng_20", y = "_alertIcon_10vng_28", a = {
14
+ wrapper: x,
15
+ isSidebarOpen: C,
16
16
  label: G,
17
17
  loadingIndicator: T,
18
18
  alertIcon: y
19
19
  }, H = ({
20
- askSuggestedQuestion: g,
21
- hasCustomSuggestedQuestions: p,
20
+ askSuggestedQuestion: p,
21
+ hasCustomSuggestedQuestions: d,
22
22
  isLoading: _,
23
23
  isSidebarOpen: t = !1,
24
24
  recordAction: s,
25
25
  setAskSuggestedQuestion: l,
26
- suggestedQuestions: S,
27
- suggestedQuestionsRequestState: n = r.SUCCESS
26
+ suggestedQuestions: f,
27
+ suggestedQuestionsRequestState: o = r.SUCCESS
28
28
  }) => {
29
29
  const {
30
30
  formatMessage: e
31
- } = h(), f = b.useCallback((c) => {
31
+ } = u(), S = h.useCallback((c) => {
32
32
  l && (l(c), s && c && s({
33
- ...C,
33
+ ...N,
34
34
  target: "suggested_questions",
35
35
  data: {
36
- selectedQuestion: p ? "dynamic" : c
36
+ selectedQuestion: d ? "dynamic" : c
37
37
  }
38
38
  }));
39
- }, [l, s]), I = () => {
40
- switch (n) {
39
+ }, [l, s, d]), I = () => {
40
+ switch (o) {
41
41
  case r.IN_PROGRESS:
42
42
  return e(i.loadingSuggestedQuestions);
43
43
  case r.ERROR:
@@ -46,33 +46,33 @@ const w = "_wrapper_10vng_1", x = "_isSidebarOpen_10vng_5", G = "_label_10vng_9"
46
46
  return e(i.suggestedQuestions);
47
47
  }
48
48
  };
49
- return /* @__PURE__ */ N("div", {
50
- className: m(a.wrapper, t && a.isSidebarOpen),
51
- children: [/* @__PURE__ */ o(u, {
49
+ return /* @__PURE__ */ w("div", {
50
+ className: g(a.wrapper, t && a.isSidebarOpen),
51
+ children: [/* @__PURE__ */ n(E, {
52
52
  as: "p",
53
- className: m(a.label, t && a.isSidebarOpen),
53
+ className: g(a.label, t && a.isSidebarOpen),
54
54
  color: "textOnLightSecondary",
55
55
  children: I()
56
- }), n === r.SUCCESS && /* @__PURE__ */ o(v, {
57
- askSuggestedQuestion: g,
56
+ }), o === r.SUCCESS && /* @__PURE__ */ n(v, {
57
+ askSuggestedQuestion: p,
58
58
  isLoading: _,
59
59
  isSidebarOpen: t,
60
- onSuggestedQuestionClick: f,
61
- suggestedQuestions: S
62
- }), n === r.IN_PROGRESS && /* @__PURE__ */ o("div", {
60
+ onSuggestedQuestionClick: S,
61
+ suggestedQuestions: f
62
+ }), o === r.IN_PROGRESS && /* @__PURE__ */ n("div", {
63
63
  className: a.loadingIndicator,
64
- children: /* @__PURE__ */ o(E, {
64
+ children: /* @__PURE__ */ n(O, {
65
65
  "aria-label": e(i.loadingSuggestedQuestions),
66
66
  className: a.loadingIndicator,
67
67
  variant: "dark"
68
68
  })
69
- }), n === r.ERROR && /* @__PURE__ */ o(O, {
69
+ }), o === r.ERROR && /* @__PURE__ */ n(R, {
70
70
  className: a.alertIcon,
71
- color: R,
71
+ color: b,
72
72
  "data-testid": "content-answers-suggested-questions-failed-alert-icon",
73
- height: d,
73
+ height: m,
74
74
  role: "presentation",
75
- width: d
75
+ width: m
76
76
  })]
77
77
  });
78
78
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@box/box-ai-content-answers",
3
- "version": "0.67.2",
3
+ "version": "0.69.0",
4
4
  "peerDependencies": {
5
5
  "@box/blueprint-web": "^7.8.0",
6
6
  "@box/blueprint-web-assets": "^4.16.0",
@@ -14,9 +14,9 @@
14
14
  "remarkable": "^2.0.1"
15
15
  },
16
16
  "devDependencies": {
17
- "@box/blueprint-web": "^8.9.0",
17
+ "@box/blueprint-web": "^9.0.0",
18
18
  "@box/blueprint-web-assets": "^4.30.0",
19
- "@box/box-ai-agent-selector": "^0.16.2",
19
+ "@box/box-ai-agent-selector": "^0.17.0",
20
20
  "@box/storybook-utils": "^0.7.0",
21
21
  "@testing-library/react": "^15.0.6",
22
22
  "react": "^18.3.0",
@@ -54,5 +54,5 @@
54
54
  "**/*.css"
55
55
  ],
56
56
  "license": "SEE LICENSE IN LICENSE",
57
- "gitHead": "e669d84470d9435b870ce82b9cb5cdb0c24fbe12"
57
+ "gitHead": "b4a64fc7d3792a0bcf1ab8f2e75b7f4a989a6d7a"
58
58
  }
@@ -2,5 +2,5 @@ import { type ApiWrapperProps } from './types';
2
2
  export type ContentAnswersComponentProps = ApiWrapperProps & {
3
3
  WrappedComponent: React.ComponentType<ApiWrapperProps>;
4
4
  };
5
- export declare const ContentAnswersComponent: ({ WrappedComponent, createSessionRequest, getAgentConfig, getAIStudioAgents, fetchTimeout, formatCitations, getAnswer, getAnswerStreaming, getSuggestedQuestions, hostAppName, isAgentSelectorEnabled, isAIStudioAgentSelectorEnabled, isCitationsEnabled, isDebugModeEnabled, isMarkdownEnabled, isOpen, isResetChatEnabled, isStopResponseEnabled, isStreamingEnabled, itemID, onCloseModal, shouldRenderProviders, suggestedQuestions, warningNotice, warningNoticeAriaLabel, }: ContentAnswersComponentProps) => import("react/jsx-runtime").JSX.Element;
5
+ export declare const ContentAnswersComponent: ({ WrappedComponent, createSessionRequest, getAgentConfig, getAIStudioAgents, fetchTimeout, formatCitations, getAnswer, getAnswerStreaming, getSuggestedQuestions, hostAppName, isAgentSelectorEnabled, isAIStudioAgentSelectorEnabled, isCitationsEnabled, isDebugModeEnabled, isMarkdownEnabled, isOpen, isResetChatEnabled, isStopResponseEnabled, isStreamingEnabled, itemID, itemIDs, onCloseModal, shouldRenderProviders, suggestedQuestions, warningNotice, warningNoticeAriaLabel, }: ContentAnswersComponentProps) => import("react/jsx-runtime").JSX.Element;
6
6
  export default ContentAnswersComponent;
@@ -1,7 +1,7 @@
1
1
  import { type AgentType, type QuestionType } from '../../../types';
2
2
  import { type QuestionRecordType } from '../records';
3
3
  import { type UseContentAnswersProps } from '../types';
4
- export declare function useContentAnswers({ contentAnswers, createSessionRequest, dispatchStateUpdate, fetchTimeout, getAgentConfig, getAnswerStreaming, getAnswer, getSuggestedQuestions, isCitationsEnabled, isStopResponseEnabled, isStreamingEnabled, itemID, formatCitations, }: UseContentAnswersProps): {
4
+ export declare function useContentAnswers({ contentAnswers, createSessionRequest, dispatchStateUpdate, fetchTimeout, getAgentConfig, getAnswerStreaming, getAnswer, getSuggestedQuestions, isCitationsEnabled, isStopResponseEnabled, isStreamingEnabled, itemID, itemIDs, formatCitations, }: UseContentAnswersProps): {
5
5
  clearConversation: () => void;
6
6
  createSession: () => Promise<void>;
7
7
  fetchAgentConfig: (agent: AgentType) => Promise<void>;
@@ -43,8 +43,8 @@ export type PremissionsResponse = {
43
43
  };
44
44
  export type agentFetcherType = (payload: Record<string, unknown>) => Promise<unknown>;
45
45
  export type SuggestedQuestionFetcherType = (itemID?: string) => Promise<SuggestedQuestionsResponse>;
46
- export type fetcherType = (payload: Record<string, unknown>, itemID?: string, state?: ContentAnswersRecordType) => Promise<unknown>;
47
- export type fetcherStreamingType = (payload: Record<string, unknown>, itemID?: string, abortController?: AbortController, state?: ContentAnswersRecordType) => Promise<unknown>;
46
+ export type fetcherType = (payload: Record<string, unknown>, itemID?: string, itemIDs?: Array<string>, state?: ContentAnswersRecordType) => Promise<unknown>;
47
+ export type fetcherStreamingType = (payload: Record<string, unknown>, itemID?: string, itemIDs?: Array<string>, abortController?: AbortController, state?: ContentAnswersRecordType) => Promise<unknown>;
48
48
  export type fetchError = {
49
49
  message?: string;
50
50
  response?: {
@@ -76,7 +76,13 @@ export type ApiWrapperProps = {
76
76
  isMarkdownEnabled?: boolean;
77
77
  isOpen?: boolean;
78
78
  isStreamingEnabled?: boolean;
79
+ /**
80
+ * Item ID for the content answers
81
+ * Prefer passing itemIDs instead since this prop will be removed soon
82
+ * @deprecated
83
+ */
79
84
  itemID?: string;
85
+ itemIDs?: Array<string>;
80
86
  onCloseModal?: () => void;
81
87
  shouldRenderProviders?: boolean;
82
88
  suggestedQuestionsRequestState?: REQUEST_STATE;
@@ -1,4 +1,4 @@
1
1
  import { type ContentAnswersRecordType } from '../records';
2
2
  import { type fetcherStreamingType, type fetcherType, type StreamResponseTimeout } from '../types';
3
- declare const getAnswerRequest: (payload: Record<string, unknown>, isStreamingRequest: boolean, requestID: string, itemID?: string, state?: ContentAnswersRecordType, fetcher?: fetcherType, fetcherStreaming?: fetcherStreamingType, abortController?: AbortController, fetchTimeout?: StreamResponseTimeout) => Promise<any>;
3
+ declare const getAnswerRequest: (payload: Record<string, unknown>, isStreamingRequest: boolean, requestID: string, itemID?: string, itemIDs?: Array<string>, state?: ContentAnswersRecordType, fetcher?: fetcherType, fetcherStreaming?: fetcherStreamingType, abortController?: AbortController, fetchTimeout?: StreamResponseTimeout) => Promise<any>;
4
4
  export { getAnswerRequest };