@box/box-ai-content-answers 0.139.4 → 0.140.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,146 +1,162 @@
1
- import { Text as k } from "@box/blueprint-web";
2
- import { AlertTriangle as j } from "@box/blueprint-web-assets/icons/Line";
3
- import { Gray65 as z, Size4 as E } from "@box/blueprint-web-assets/tokens/tokens";
4
- import p from "clsx";
5
- import * as l from "react";
6
- import { useIntl as W } from "react-intl";
1
+ import { Text as z } from "@box/blueprint-web";
2
+ import { AlertTriangle as W } from "@box/blueprint-web-assets/icons/Line";
3
+ import { Gray65 as q, Size4 as I } from "@box/blueprint-web-assets/tokens/tokens";
4
+ import g from "clsx";
5
+ import * as c from "react";
6
+ import { useIntl as J } from "react-intl";
7
7
  import { A as n } from "../../../../chunks/types.js";
8
- import { MediaContainer as N } from "../common/media-container.js";
9
- import { AnswerContent as q } from "./answer-content.js";
10
- import { CopyButton as J } from "./copy-button.js";
11
- import { InlineError as K } from "./inline-error.js";
12
- import { LoadingIndicator as Q } from "./loading-indicator.js";
13
- import m from "./messages.js";
14
- import { References as X } from "./references.js";
15
- import { ThumbButtons as Y } from "./thumb-buttons.js";
16
- import { jsxs as a, jsx as e } from "react/jsx-runtime";
17
- import '../../../../styles/answer.css';const Z = "_answer_140hd_1", $ = "_alertIcon_140hd_5", tt = "_error_140hd_8", ot = "_footer_140hd_12", et = "_copyButtonContainer_140hd_18", nt = "_feedbackButtonsContainer_140hd_19", st = "_shouldHaveMarginTop_140hd_23", rt = "_shouldUseAnimation_140hd_26", at = "_shouldAnimateHeight_140hd_30", it = "_footerButtons_140hd_34", dt = "_iconAvatar_140hd_40", ct = "_buttonsVisible_140hd_56", t = {
18
- answer: Z,
19
- alertIcon: $,
20
- error: tt,
21
- footer: ot,
22
- copyButtonContainer: et,
23
- feedbackButtonsContainer: nt,
24
- shouldHaveMarginTop: st,
25
- shouldUseAnimation: rt,
26
- shouldAnimateHeight: at,
27
- footerButtons: it,
28
- iconAvatar: dt,
29
- buttonsVisible: ct
30
- }, lt = /* @__PURE__ */ new Set([n.RATE_LIMITING, n.NO_CONTENT, n.PRECONDITION_FAILED, n.GENERAL, n.AGENT_NOT_FOUND]), bt = /* @__PURE__ */ l.memo(({
8
+ import { extractBoxLinks as K, extractFileNames as Q } from "../../utils/getBoxLinks.js";
9
+ import { MediaContainer as S } from "../common/media-container.js";
10
+ import { AnswerContent as X } from "./answer-content.js";
11
+ import { CopyButton as Y } from "./copy-button.js";
12
+ import { InlineError as Z } from "./inline-error.js";
13
+ import { LoadingIndicator as $ } from "./loading-indicator.js";
14
+ import u from "./messages.js";
15
+ import { References as tt } from "./references.js";
16
+ import { ThumbButtons as ot } from "./thumb-buttons.js";
17
+ import { jsxs as l, jsx as e } from "react/jsx-runtime";
18
+ import '../../../../styles/answer.css';const et = "_answer_140hd_1", nt = "_alertIcon_140hd_5", st = "_error_140hd_8", rt = "_footer_140hd_12", at = "_copyButtonContainer_140hd_18", it = "_feedbackButtonsContainer_140hd_19", lt = "_shouldHaveMarginTop_140hd_23", ct = "_shouldUseAnimation_140hd_26", dt = "_shouldAnimateHeight_140hd_30", mt = "_footerButtons_140hd_34", ut = "_iconAvatar_140hd_40", ft = "_buttonsVisible_140hd_56", t = {
19
+ answer: et,
20
+ alertIcon: nt,
21
+ error: st,
22
+ footer: rt,
23
+ copyButtonContainer: at,
24
+ feedbackButtonsContainer: it,
25
+ shouldHaveMarginTop: lt,
26
+ shouldUseAnimation: ct,
27
+ shouldAnimateHeight: dt,
28
+ footerButtons: mt,
29
+ iconAvatar: ut,
30
+ buttonsVisible: ft
31
+ }, _t = /* @__PURE__ */ new Set([n.RATE_LIMITING, n.NO_CONTENT, n.PRECONDITION_FAILED, n.GENERAL, n.AGENT_NOT_FOUND]), xt = /* @__PURE__ */ c.memo(({
31
32
  answer: s,
32
- citations: I,
33
+ citations: T,
33
34
  error: o,
34
- contentType: S,
35
- hostAppName: A,
36
- feedbackValue: T,
37
- isCitationsEnabled: R = !1,
38
- isCompleted: i = !1,
39
- isFeedbackEnabled: g = !1,
40
- isFeedbackFormEnabled: O,
41
- isFeedbackTooltipOpen: u,
42
- isLoading: b = !1,
43
- isMarkdownEnabled: w = !1,
44
- items: B = [],
45
- onAnswerCopy: P,
46
- onCitationClick: C,
35
+ contentType: R,
36
+ hostAppName: d,
37
+ feedbackValue: b,
38
+ isCitationsEnabled: A = !1,
39
+ isCompleted: a = !1,
40
+ isFeedbackEnabled: O = !1,
41
+ isFeedbackFormEnabled: B,
42
+ isFeedbackTooltipOpen: f,
43
+ isLoading: P = !1,
44
+ isMarkdownEnabled: C = !1,
45
+ items: w = [],
46
+ onAnswerCopy: x,
47
+ onCitationClick: L,
47
48
  onFeedbackFormSubmit: v,
48
49
  onFeedbackTooltipOpenChange: M,
49
50
  promptType: y,
50
- recordAction: d,
51
+ recordAction: i,
51
52
  shouldFeedbackFormIncludeFeedbackText: D,
52
- useAnimation: H = !0,
53
+ useAnimation: F = !0,
53
54
  variant: r = "modal",
54
- setAnswerFeedback: L,
55
- questionId: U
55
+ setAnswerFeedback: H,
56
+ questionId: k
56
57
  }) => {
57
- const _ = lt.has(o), h = b && !s && !o, [x, F] = l.useState(i), {
58
- formatMessage: c
59
- } = W();
60
- l.useEffect(() => {
61
- setTimeout(() => F(i), 0);
62
- }, [i]);
63
- const f = () => /* @__PURE__ */ e(j, {
58
+ const _ = _t.has(o), h = P && !s && !o, [U, G] = c.useState(a), {
59
+ formatMessage: m
60
+ } = J();
61
+ c.useEffect(() => {
62
+ if (s && i && a) {
63
+ const p = K(s), N = Q(s);
64
+ (p.length > 0 || N.length > 0) && i({
65
+ action: "programmatic",
66
+ component: r,
67
+ feature: "answers",
68
+ target: "links_detected",
69
+ data: {
70
+ hostAppName: d,
71
+ linkCount: p.length,
72
+ fileNameCount: N.length
73
+ }
74
+ });
75
+ }
76
+ }, [s, r, d, a]), c.useEffect(() => {
77
+ setTimeout(() => G(a), 0);
78
+ }, [a]);
79
+ const E = () => /* @__PURE__ */ e(W, {
64
80
  className: t.alertIcon,
65
- color: z,
81
+ color: q,
66
82
  "data-testid": "content-answers-error-alert-icon",
67
- height: E,
83
+ height: I,
68
84
  role: "presentation",
69
- width: E
70
- }), G = () => /* @__PURE__ */ a(k, {
85
+ width: I
86
+ }), V = () => /* @__PURE__ */ l(z, {
71
87
  as: "p",
72
88
  className: t.error,
73
89
  color: "textOnLightSecondary",
74
90
  "data-testid": "content-answers-error",
75
91
  variant: "caption",
76
- children: [o === n.RESPONSE_INTERRUPTED && c(m.responseInterruptedError), o === n.RESPONSE_FAILED && c(m.responseFailedError), o === n.RESPONSE_STOPPED && c(m.responseStoppedError), o !== n.RESPONSE_STOPPED && f()]
77
- }), V = () => o !== n.RESPONSE_STOPPED ? /* @__PURE__ */ a("div", {
78
- className: p(t.footerButtons, "footer-buttons-container", {
79
- [t.buttonsVisible]: u
92
+ children: [o === n.RESPONSE_INTERRUPTED && m(u.responseInterruptedError), o === n.RESPONSE_FAILED && m(u.responseFailedError), o === n.RESPONSE_STOPPED && m(u.responseStoppedError), o !== n.RESPONSE_STOPPED && E()]
93
+ }), j = () => o !== n.RESPONSE_STOPPED ? /* @__PURE__ */ l("div", {
94
+ className: g(t.footerButtons, "footer-buttons-container", {
95
+ [t.buttonsVisible]: f
80
96
  }),
81
- children: [g ? /* @__PURE__ */ e("div", {
97
+ children: [O ? /* @__PURE__ */ e("div", {
82
98
  className: t.feedbackButtonsContainer,
83
- children: /* @__PURE__ */ e(Y, {
84
- feedbackValue: T,
85
- hostAppName: A,
86
- isFeedbackFormEnabled: O,
87
- isFeedbackTooltipOpen: u,
88
- items: B,
99
+ children: /* @__PURE__ */ e(ot, {
100
+ feedbackValue: b,
101
+ hostAppName: d,
102
+ isFeedbackFormEnabled: B,
103
+ isFeedbackTooltipOpen: f,
104
+ items: w,
89
105
  onFeedbackFormSubmit: v,
90
106
  onFeedbackTooltipOpenChange: M,
91
107
  promptType: y,
92
- questionId: U,
93
- recordAction: d,
94
- setAnswerFeedback: L,
108
+ questionId: k,
109
+ recordAction: i,
110
+ setAnswerFeedback: H,
95
111
  shouldFeedbackFormIncludeFeedbackText: D,
96
112
  variant: r
97
113
  })
98
114
  }) : null, /* @__PURE__ */ e("div", {
99
115
  className: t.copyButtonContainer,
100
- children: /* @__PURE__ */ e(J, {
116
+ children: /* @__PURE__ */ e(Y, {
101
117
  answer: s,
102
- onAnswerCopy: P,
103
- recordAction: d
118
+ onAnswerCopy: x,
119
+ recordAction: i
104
120
  })
105
121
  })]
106
- }) : s ? null : f();
107
- return /* @__PURE__ */ a("div", {
122
+ }) : s ? null : E();
123
+ return /* @__PURE__ */ l("div", {
108
124
  "aria-live": "polite",
109
125
  className: t.answer,
110
126
  "data-testid": "content-answers-answer",
111
- children: [h && /* @__PURE__ */ e(Q, {}), !_ && !h && /* @__PURE__ */ e(N, {
127
+ children: [h && /* @__PURE__ */ e($, {}), !_ && !h && /* @__PURE__ */ e(S, {
112
128
  className: "answer",
113
129
  variant: r,
114
- children: /* @__PURE__ */ a(N.Content, {
130
+ children: /* @__PURE__ */ l(S.Content, {
115
131
  isUsedInsideSidebar: r === "sidebar",
116
132
  variant: "answer",
117
- children: [/* @__PURE__ */ e(q, {
133
+ children: [/* @__PURE__ */ e(X, {
118
134
  answer: s,
119
- isMarkdownEnabled: w,
135
+ isMarkdownEnabled: C,
120
136
  variant: r
121
- }), i && /* @__PURE__ */ a("div", {
122
- className: p(t.footer, {
137
+ }), a && /* @__PURE__ */ l("div", {
138
+ className: g(t.footer, {
123
139
  [t.shouldHaveMarginTop]: s,
124
- [t.shouldAnimateHeight]: x,
125
- [t.shouldUseAnimation]: H
140
+ [t.shouldAnimateHeight]: U,
141
+ [t.shouldUseAnimation]: F
126
142
  }),
127
143
  "data-testid": "content-answers-answer-footer",
128
- children: [o && G(), R && !o && /* @__PURE__ */ e(X, {
129
- citations: I,
130
- onCitationClick: C,
131
- recordAction: d
132
- }), V()]
144
+ children: [o && V(), A && !o && /* @__PURE__ */ e(tt, {
145
+ citations: T,
146
+ onCitationClick: L,
147
+ recordAction: i
148
+ }), j()]
133
149
  })]
134
150
  })
135
- }), _ && /* @__PURE__ */ e(K, {
136
- contentType: S,
151
+ }), _ && /* @__PURE__ */ e(Z, {
152
+ contentType: R,
137
153
  error: o,
138
- recordAction: d,
154
+ recordAction: i,
139
155
  variant: r
140
156
  })]
141
157
  });
142
158
  });
143
159
  export {
144
- bt as Answer,
145
- bt as default
160
+ xt as Answer,
161
+ xt as default
146
162
  };
@@ -0,0 +1,165 @@
1
+ const s = [
2
+ // Audio
3
+ "aac",
4
+ "aif",
5
+ "aifc",
6
+ "aiff",
7
+ "amr",
8
+ "au",
9
+ "flac",
10
+ "m4a",
11
+ "mp3",
12
+ "ogg",
13
+ "ra",
14
+ "wav",
15
+ "wma",
16
+ // CAD
17
+ "3ds",
18
+ "box3d",
19
+ "dae",
20
+ "dwg",
21
+ "dxf",
22
+ "fbx",
23
+ "mtl",
24
+ "obj",
25
+ "ply",
26
+ "stl",
27
+ // Document
28
+ "as",
29
+ "as3",
30
+ "asm",
31
+ "bat",
32
+ "boxnote",
33
+ "c",
34
+ "cc",
35
+ "cmake",
36
+ "cpp",
37
+ "cs",
38
+ "css",
39
+ "cxx",
40
+ "diff",
41
+ "doc",
42
+ "docx",
43
+ "eml",
44
+ "erb",
45
+ "groovy",
46
+ "h",
47
+ "haml",
48
+ "hh",
49
+ "hpp",
50
+ "htm",
51
+ "html",
52
+ "java",
53
+ "js",
54
+ "json",
55
+ "jww",
56
+ "less",
57
+ "log",
58
+ "m",
59
+ "make",
60
+ "md",
61
+ "ml",
62
+ "msg",
63
+ "olk14Message",
64
+ "pdf",
65
+ "php",
66
+ "pl",
67
+ "properties",
68
+ "py",
69
+ "rb",
70
+ "rst",
71
+ "sass",
72
+ "scala",
73
+ "scm",
74
+ "script",
75
+ "sh",
76
+ "sml",
77
+ "sql",
78
+ "vb",
79
+ "vi",
80
+ "vim",
81
+ "wpd",
82
+ "xhtml",
83
+ "xml",
84
+ "xsd",
85
+ "xsl",
86
+ "xbd",
87
+ "xdw",
88
+ "pyc",
89
+ // Drawing
90
+ "ai",
91
+ "boxcanvas",
92
+ "indd",
93
+ "odg",
94
+ "psd",
95
+ "svg",
96
+ // Image
97
+ "arw",
98
+ "bmp",
99
+ "cr2",
100
+ "dcm",
101
+ "dicm",
102
+ "dicom",
103
+ "dng",
104
+ "eps",
105
+ "exr",
106
+ "gif",
107
+ "heic",
108
+ "indd",
109
+ "indml",
110
+ "indt",
111
+ "inx",
112
+ "jpeg",
113
+ "jpg",
114
+ "nef",
115
+ "png",
116
+ "svg",
117
+ "tif",
118
+ "tiff",
119
+ "tga",
120
+ "svs",
121
+ // Presentation
122
+ "fodp",
123
+ "gslide",
124
+ "gslides",
125
+ "key",
126
+ "keynote",
127
+ "odp",
128
+ "otp",
129
+ "pez",
130
+ "pot",
131
+ "ppt",
132
+ "pptx",
133
+ // Spreadsheet
134
+ "csv",
135
+ "fods",
136
+ "gsheet",
137
+ "numbers",
138
+ "ods",
139
+ "tsv",
140
+ "xls",
141
+ "xlsm",
142
+ "xlsx",
143
+ "xlsb",
144
+ // Video
145
+ "3g2",
146
+ "3gp",
147
+ "avi",
148
+ "fla",
149
+ "flv",
150
+ "m2v",
151
+ "m2ts",
152
+ "m4v",
153
+ "mkv",
154
+ "mov",
155
+ "mpeg",
156
+ "mpg",
157
+ "mts",
158
+ "swf",
159
+ "ogg",
160
+ "qt",
161
+ "ts"
162
+ ];
163
+ export {
164
+ s as BOX_SUPPORTED_FILE_EXTENSIONS
165
+ };
@@ -0,0 +1,13 @@
1
+ import { BOX_SUPPORTED_FILE_EXTENSIONS as o } from "./constants.js";
2
+ function s(t) {
3
+ const e = /(https?:\/\/([^\/\s\)]+\.)?box\.com[^\s\)]*)/gi, n = t.match(e) || [];
4
+ return [...new Set(n)];
5
+ }
6
+ function i(t) {
7
+ const e = new RegExp(`\\b[\\w\\-.]+\\.(${o.join("|")})\\b`, "gi"), n = t.match(e) || [];
8
+ return [...new Set(n)];
9
+ }
10
+ export {
11
+ s as extractBoxLinks,
12
+ i as extractFileNames
13
+ };
@@ -175,6 +175,10 @@ export type RecordActionType = {
175
175
  issue_type: FeedbackIssueType | '';
176
176
  prompt_type?: string;
177
177
  question_id: string;
178
+ } | {
179
+ hostAppName: string;
180
+ linkCount: number;
181
+ fileNameCount: number;
178
182
  };
179
183
  component: string;
180
184
  feature: string;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Box supported file extensions from https://developer.box.com/guides/representations/supported-file-types/
3
+ */
4
+ export declare const BOX_SUPPORTED_FILE_EXTENSIONS: readonly ["aac", "aif", "aifc", "aiff", "amr", "au", "flac", "m4a", "mp3", "ogg", "ra", "wav", "wma", "3ds", "box3d", "dae", "dwg", "dxf", "fbx", "mtl", "obj", "ply", "stl", "as", "as3", "asm", "bat", "boxnote", "c", "cc", "cmake", "cpp", "cs", "css", "cxx", "diff", "doc", "docx", "eml", "erb", "groovy", "h", "haml", "hh", "hpp", "htm", "html", "java", "js", "json", "jww", "less", "log", "m", "make", "md", "ml", "msg", "olk14Message", "pdf", "php", "pl", "properties", "py", "rb", "rst", "sass", "scala", "scm", "script", "sh", "sml", "sql", "vb", "vi", "vim", "wpd", "xhtml", "xml", "xsd", "xsl", "xbd", "xdw", "pyc", "ai", "boxcanvas", "indd", "odg", "psd", "svg", "arw", "bmp", "cr2", "dcm", "dicm", "dicom", "dng", "eps", "exr", "gif", "heic", "indd", "indml", "indt", "inx", "jpeg", "jpg", "nef", "png", "svg", "tif", "tiff", "tga", "svs", "fodp", "gslide", "gslides", "key", "keynote", "odp", "otp", "pez", "pot", "ppt", "pptx", "csv", "fods", "gsheet", "numbers", "ods", "tsv", "xls", "xlsm", "xlsx", "xlsb", "3g2", "3gp", "avi", "fla", "flv", "m2v", "m2ts", "m4v", "mkv", "mov", "mpeg", "mpg", "mts", "swf", "ogg", "qt", "ts"];
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Utility functions for tracking files and links in AI responses
3
+ */
4
+ /**
5
+ * Gets all box.com file links from text
6
+ * @param text - The text content to analyze
7
+ * @returns Array of box.com file links
8
+ */
9
+ export declare function extractBoxLinks(text: string): string[];
10
+ /**
11
+ * Extracts file names with extensions from text content
12
+ * @param text - The text content to analyze
13
+ * @returns Array of detected file names
14
+ */
15
+ export declare function extractFileNames(text: string): string[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@box/box-ai-content-answers",
3
- "version": "0.139.4",
3
+ "version": "0.140.0",
4
4
  "peerDependencies": {
5
5
  "@box/blueprint-web": "^7.8.0",
6
6
  "@box/blueprint-web-assets": "^4.56.1",
@@ -17,11 +17,11 @@
17
17
  },
18
18
  "devDependencies": {
19
19
  "@box/babel-plugin-target-attributes": "1.3.0",
20
- "@box/blueprint-web": "^12.33.1",
21
- "@box/blueprint-web-assets": "^4.58.0",
22
- "@box/box-ai-agent-selector": "^0.47.13",
23
- "@box/item-icon": "^0.13.13",
24
- "@box/storybook-utils": "^0.13.12",
20
+ "@box/blueprint-web": "^12.33.2",
21
+ "@box/blueprint-web-assets": "^4.59.0",
22
+ "@box/box-ai-agent-selector": "^0.47.14",
23
+ "@box/item-icon": "^0.14.0",
24
+ "@box/storybook-utils": "^0.13.13",
25
25
  "@testing-library/react": "^15.0.6",
26
26
  "react": "^18.3.0",
27
27
  "react-dom": "^18.3.0",