@burdenoff/fe-libs 2026.920.1 → 2026.920.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/shared/assistant/api.d.ts +17 -0
- package/dist/shared/assistant/api.d.ts.map +1 -1
- package/dist/shared/assistant/api.js +88 -66
- package/dist/shared/assistant/attachmentTurn.d.ts +21 -0
- package/dist/shared/assistant/attachmentTurn.d.ts.map +1 -0
- package/dist/shared/assistant/attachmentTurn.js +48 -0
- package/dist/shared/assistant/attachments.d.ts +85 -6
- package/dist/shared/assistant/attachments.d.ts.map +1 -1
- package/dist/shared/assistant/attachments.js +165 -112
- package/dist/shared/assistant/conversation.d.ts +21 -0
- package/dist/shared/assistant/conversation.d.ts.map +1 -1
- package/dist/shared/assistant/documentExtract.d.ts +11 -2
- package/dist/shared/assistant/documentExtract.d.ts.map +1 -1
- package/dist/shared/assistant/documentExtract.js +39 -37
- package/dist/shared/assistant/gatewayLimits.d.ts +10 -0
- package/dist/shared/assistant/gatewayLimits.d.ts.map +1 -1
- package/dist/shared/assistant/gatewayLimits.js +2 -2
- package/dist/shared/assistant/index.d.ts +1 -0
- package/dist/shared/assistant/index.d.ts.map +1 -1
- package/dist/shared/assistant/ui/AssistantChatArea.d.ts.map +1 -1
- package/dist/shared/assistant/ui/AssistantChatArea.js +342 -325
- package/dist/shared/assistant/ui/composer/AssistantComposer.d.ts +12 -0
- package/dist/shared/assistant/ui/composer/AssistantComposer.d.ts.map +1 -1
- package/dist/shared/assistant/ui/composer/AssistantComposer.js +57 -57
- package/dist/shared/assistant/useAssistantAttachments.d.ts +12 -1
- package/dist/shared/assistant/useAssistantAttachments.d.ts.map +1 -1
- package/dist/shared/assistant/useAssistantAttachments.js +98 -98
- package/dist/shared-assistant.js +116 -115
- package/package.json +1 -1
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
import { MAX_REQUEST_BODY_BYTES as e } from "./gatewayLimits.js";
|
|
2
|
-
import {
|
|
2
|
+
import { MAX_EXTRACTED_CHARS as t, formatPageRanges as n, isMostlyImagePages as r, truncatePagesForInline as i } from "./documentText.js";
|
|
3
3
|
//#region src/shared/assistant/attachments.ts
|
|
4
|
-
var
|
|
5
|
-
function
|
|
4
|
+
var a = 5, o = 10 * 1024 * 1024, s = ["application/pdf", "text/plain"];
|
|
5
|
+
function c(e) {
|
|
6
6
|
if (!e) return !1;
|
|
7
7
|
let t = e.split(";")[0]?.trim().toLowerCase() ?? "";
|
|
8
|
-
return t.startsWith("image/") ? !0 :
|
|
8
|
+
return t.startsWith("image/") ? !0 : s.includes(t);
|
|
9
9
|
}
|
|
10
|
-
var
|
|
10
|
+
var l = 8e3, u = 2e4, d = Object.freeze({
|
|
11
|
+
perFileChars: l,
|
|
12
|
+
totalChars: u
|
|
13
|
+
}), f = class extends Error {
|
|
11
14
|
constructor(e) {
|
|
12
15
|
super(e), this.reason = e, this.name = "AttachmentRejectedError";
|
|
13
16
|
}
|
|
14
17
|
};
|
|
15
|
-
function
|
|
18
|
+
function ee(e) {
|
|
16
19
|
return {
|
|
17
20
|
id: e.id,
|
|
18
21
|
filename: e.filename,
|
|
@@ -22,7 +25,7 @@ function d(e) {
|
|
|
22
25
|
fileId: e.fileId
|
|
23
26
|
};
|
|
24
27
|
}
|
|
25
|
-
var
|
|
28
|
+
var p = new Set([
|
|
26
29
|
"txt",
|
|
27
30
|
"md",
|
|
28
31
|
"markdown",
|
|
@@ -46,31 +49,31 @@ var f = new Set([
|
|
|
46
49
|
"toml",
|
|
47
50
|
"conf"
|
|
48
51
|
]);
|
|
49
|
-
function
|
|
52
|
+
function m(e) {
|
|
50
53
|
let t = e.lastIndexOf(".");
|
|
51
54
|
return t >= 0 ? e.slice(t + 1).toLowerCase() : "";
|
|
52
55
|
}
|
|
53
|
-
function
|
|
54
|
-
return e.startsWith("image/") ? "image" : e.startsWith("text/") || e === "application/json" || e === "application/xml" || e === "application/x-yaml" ||
|
|
56
|
+
function te(e, t) {
|
|
57
|
+
return e.startsWith("image/") ? "image" : e.startsWith("text/") || e === "application/json" || e === "application/xml" || e === "application/x-yaml" || p.has(m(t)) ? "text" : "document";
|
|
55
58
|
}
|
|
56
|
-
var
|
|
59
|
+
var ne = {
|
|
57
60
|
"application/pdf": "pdf",
|
|
58
61
|
"application/x-pdf": "pdf",
|
|
59
62
|
"application/vnd.openxmlformats-officedocument.wordprocessingml.document": "docx",
|
|
60
63
|
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "xlsx"
|
|
61
|
-
},
|
|
64
|
+
}, h = {
|
|
62
65
|
pdf: "pdf",
|
|
63
66
|
docx: "docx",
|
|
64
67
|
xlsx: "xlsx"
|
|
65
68
|
};
|
|
66
|
-
function
|
|
67
|
-
return
|
|
69
|
+
function g(e, t) {
|
|
70
|
+
return ne[e.toLowerCase()] ?? h[m(t)] ?? null;
|
|
68
71
|
}
|
|
69
72
|
var _ = [
|
|
70
73
|
"image/*",
|
|
71
74
|
"text/*",
|
|
72
|
-
...[...
|
|
73
|
-
...Object.keys(
|
|
75
|
+
...[...p].map((e) => `.${e}`),
|
|
76
|
+
...Object.keys(h).map((e) => `.${e}`)
|
|
74
77
|
].join(",");
|
|
75
78
|
function v(e) {
|
|
76
79
|
return e < 1024 ? `${e} B` : e < 1024 * 1024 ? `${(e / 1024).toFixed(1)} KB` : `${(e / (1024 * 1024)).toFixed(1)} MB`;
|
|
@@ -84,10 +87,10 @@ function b(e) {
|
|
|
84
87
|
function x(e, t) {
|
|
85
88
|
return y(e, t) ? "in-flight" : t.some((e) => e.status === "error") ? "failed" : null;
|
|
86
89
|
}
|
|
87
|
-
function
|
|
90
|
+
function re(e, t) {
|
|
88
91
|
return t >= 5 ? "too-many" : e.size === 0 ? "empty" : e.size > 10485760 && !e.type.startsWith("image/") ? "too-large" : null;
|
|
89
92
|
}
|
|
90
|
-
function
|
|
93
|
+
function S(e, t) {
|
|
91
94
|
if (e.length <= t) return {
|
|
92
95
|
text: e,
|
|
93
96
|
truncated: !1
|
|
@@ -98,107 +101,107 @@ function C(e, t) {
|
|
|
98
101
|
truncated: !0
|
|
99
102
|
};
|
|
100
103
|
}
|
|
101
|
-
function
|
|
104
|
+
function C(e) {
|
|
102
105
|
return [
|
|
103
106
|
" ```",
|
|
104
107
|
...e.split("\n").map((e) => ` ${e}`),
|
|
105
108
|
" ```"
|
|
106
109
|
];
|
|
107
110
|
}
|
|
108
|
-
function
|
|
111
|
+
function w(e) {
|
|
109
112
|
return e?.pageNumbers?.length ? e.pageNumbers : e?.pagesIncluded ? Array.from({ length: e.pagesIncluded }, (e, t) => t + 1) : [];
|
|
110
113
|
}
|
|
111
|
-
function
|
|
112
|
-
let
|
|
113
|
-
if (
|
|
114
|
-
let e =
|
|
115
|
-
e.length >=
|
|
114
|
+
function T(e) {
|
|
115
|
+
let t = e.extraction, r = [];
|
|
116
|
+
if (t?.pageCount) {
|
|
117
|
+
let e = w(t);
|
|
118
|
+
e.length >= t.pageCount ? r.push(`${t.pageCount} page${t.pageCount === 1 ? "" : "s"}`) : e.length === 1 ? r.push(`page ${e[0]} of ${t.pageCount}`) : r.push(`pages ${n(e)} of ${t.pageCount}`);
|
|
116
119
|
}
|
|
117
|
-
if (
|
|
118
|
-
let
|
|
119
|
-
r.push(
|
|
120
|
+
if (t?.sheetNames?.length && r.push(`sheets: ${t.sheetNames.join(", ")}`), e.textTruncated && e.textContent) {
|
|
121
|
+
let n = t?.sourceChars;
|
|
122
|
+
r.push(n && n > e.textContent.length ? `first ${e.textContent.length} characters of ${n}; truncated` : `first ${e.textContent.length} characters; truncated`);
|
|
120
123
|
}
|
|
121
124
|
return r.length > 0 ? ` (${r.join("; ")})` : "";
|
|
122
125
|
}
|
|
123
|
-
var
|
|
124
|
-
function
|
|
125
|
-
let
|
|
126
|
-
if (!
|
|
127
|
-
let r = new Set(
|
|
126
|
+
var E = " Do NOT guess at, summarise or characterise its contents — you have not seen them.", D = [" Fetch the URL above if you can; otherwise ask the user to paste the relevant section as text.", E];
|
|
127
|
+
function O(e) {
|
|
128
|
+
let t = e.extraction;
|
|
129
|
+
if (!t?.pageCount) return [];
|
|
130
|
+
let r = new Set(w(t)), i = new Set(t.imagePages ?? []), a = [...i].filter((e) => !r.has(e)).sort((e, t) => e - t), o = [];
|
|
128
131
|
if (a.length > 0) {
|
|
129
|
-
let e = a.length === 1 ? `Page ${a[0]}` : `Pages ${
|
|
132
|
+
let e = a.length === 1 ? `Page ${a[0]}` : `Pages ${n(a)}`;
|
|
130
133
|
o.push(` ${e} of this document contain no extractable text — they are images.`, " Nothing about those pages is available to you.");
|
|
131
134
|
}
|
|
132
135
|
let s = [];
|
|
133
|
-
for (let e = 1; e <=
|
|
136
|
+
for (let e = 1; e <= t.pageCount; e += 1) !r.has(e) && !i.has(e) && s.push(e);
|
|
134
137
|
if (s.length > 0) {
|
|
135
|
-
let e = s.length === 1 ? `Page ${s[0]}` : `Pages ${
|
|
138
|
+
let e = s.length === 1 ? `Page ${s[0]}` : `Pages ${n(s)}`;
|
|
136
139
|
o.push(` ${e} of this document ${s.length === 1 ? "was" : "were"} not read at all.`);
|
|
137
140
|
}
|
|
138
|
-
return o.length > 0 && o.push(
|
|
141
|
+
return o.length > 0 && o.push(E), o;
|
|
139
142
|
}
|
|
140
|
-
function
|
|
143
|
+
function k(e) {
|
|
141
144
|
let t = e.extraction;
|
|
142
145
|
if (!t || t.status === "unsupported") return [" Binary file — contents not inlined. Fetch the URL above if you can; otherwise ask the user", " to paste the relevant section as text."];
|
|
143
146
|
if (t.status === "no-text") return t.format === "docx" || t.format === "xlsx" ? [
|
|
144
147
|
" NO TEXT AVAILABLE — this document holds no readable text; it is either empty or contains only",
|
|
145
148
|
" images, charts or drawings, none of which carry text. No text could be extracted.",
|
|
146
|
-
...
|
|
149
|
+
...D
|
|
147
150
|
] : [
|
|
148
151
|
` NO TEXT AVAILABLE — this document appears to be scanned images; no text could be extracted${t.pagesScanned && t.pageCount && t.pagesScanned < t.pageCount ? ` (the first ${t.pagesScanned} of ${t.pageCount} pages were checked)` : ""}.`,
|
|
149
152
|
" There is no text layer to read, so nothing about its contents is available to you.",
|
|
150
|
-
...
|
|
153
|
+
...D
|
|
151
154
|
];
|
|
152
155
|
if (t.status === "encrypted") return [
|
|
153
156
|
" NO TEXT AVAILABLE — this document is encrypted or password-protected; it could not be opened",
|
|
154
157
|
" and no text could be extracted.",
|
|
155
|
-
...
|
|
158
|
+
...D
|
|
156
159
|
];
|
|
157
|
-
if (t.status === "corrupt") return [` NO TEXT AVAILABLE — this file could not be read${t.detail ? ` (${t.detail})` : ""}; no text could be extracted.`, ...
|
|
160
|
+
if (t.status === "corrupt") return [` NO TEXT AVAILABLE — this file could not be read${t.detail ? ` (${t.detail})` : ""}; no text could be extracted.`, ...D];
|
|
158
161
|
if (!e.textContent) return [
|
|
159
162
|
" Text WAS extracted from this document but is omitted because this turn ran out of inline budget,",
|
|
160
163
|
" not because it is unavailable. Ask the user which part matters so they can re-send just that",
|
|
161
164
|
" section, or fetch the URL above if you can.",
|
|
162
|
-
|
|
165
|
+
E
|
|
163
166
|
];
|
|
164
|
-
let
|
|
165
|
-
if (t.pageCount && i !== void 0 &&
|
|
166
|
-
let
|
|
167
|
+
let n = t.pagesScanned ?? t.pageCount ?? 0, i = t.textPageCount;
|
|
168
|
+
if (t.pageCount && i !== void 0 && r(i, n)) {
|
|
169
|
+
let r = n - i;
|
|
167
170
|
return [
|
|
168
171
|
` NOT READ — this document is mostly images. Only ${i} of its ${t.pageCount} page${t.pageCount === 1 ? "" : "s"} carr${i === 1 ? "ies" : "y"} a text layer;`,
|
|
169
|
-
` the other ${
|
|
172
|
+
` the other ${r} contain no extractable text at all. Treat this as a document you have NOT`,
|
|
170
173
|
" read: the fragment below is the whole of what was available, not a summary of the document.",
|
|
171
|
-
...
|
|
172
|
-
` The only extractable text${
|
|
173
|
-
...
|
|
174
|
+
...O(e),
|
|
175
|
+
` The only extractable text${T(e)}:`,
|
|
176
|
+
...C(e.textContent)
|
|
174
177
|
];
|
|
175
178
|
}
|
|
176
179
|
return [
|
|
177
|
-
` Extracted text${
|
|
178
|
-
...
|
|
179
|
-
...
|
|
180
|
+
` Extracted text${T(e)}:`,
|
|
181
|
+
...C(e.textContent),
|
|
182
|
+
...O(e)
|
|
180
183
|
];
|
|
181
184
|
}
|
|
182
|
-
function
|
|
185
|
+
function A(e, t, n = j) {
|
|
183
186
|
let r = [`[${t + 1}] ${e.filename} — ${e.mimeType}, ${v(e.size)}`];
|
|
184
|
-
return e.downloadUrl && r.push(` URL: ${e.downloadUrl}`), e.kind === "text" && e.textContent ? r.push(e.textTruncated ? ` Contents (first ${e.textContent.length} characters of ${v(e.size)}; truncated):` : " Contents:", ...
|
|
187
|
+
return e.downloadUrl && r.push(` URL: ${e.downloadUrl}`), e.kind === "text" && e.textContent ? r.push(e.textTruncated ? ` Contents (first ${e.textContent.length} characters of ${v(e.size)}; truncated):` : " Contents:", ...C(e.textContent)) : e.kind === "document" ? r.push(...k(e)) : e.kind === "image" ? n.has(e.id) ? r.push(" NOT VIEWABLE IN THIS MESSAGE — this image did not fit the request-size budget, so only its URL", " travelled; its pixels are NOT attached. Fetch the URL above if you can; otherwise ask the user", " to describe it.", E) : r.push(" If this image is attached to the message as an image you can view, answer from what you see in it.", " If you cannot view attached images, say so plainly and ask the user to describe it — never guess.") : e.kind === "text" ? r.push(" Text file — contents omitted because this turn ran out of inline budget, not because they are", " unavailable. Fetch the URL above if you can; otherwise ask the user which part matters so they", " can re-send just that section.") : r.push(" Binary file — contents not inlined. Fetch the URL above if you can; otherwise ask the user", " to paste the relevant section as text."), r.join("\n");
|
|
185
188
|
}
|
|
186
|
-
var
|
|
187
|
-
function
|
|
188
|
-
let n =
|
|
189
|
-
let
|
|
190
|
-
if (
|
|
189
|
+
var j = /* @__PURE__ */ new Set();
|
|
190
|
+
function M(e, t) {
|
|
191
|
+
let n = t.totalChars, r = t.documentChars, a = [...e], o = (e) => {
|
|
192
|
+
let a = !!e.extraction, o = Math.min(n, t.perFileChars, a ? r : Infinity);
|
|
193
|
+
if (o <= 0) return {
|
|
191
194
|
...e,
|
|
192
195
|
textContent: void 0,
|
|
193
196
|
textTruncated: !0
|
|
194
197
|
};
|
|
195
198
|
if (e.documentPages?.length) {
|
|
196
|
-
let t =
|
|
199
|
+
let t = i(e.documentPages, o);
|
|
197
200
|
return t.text === "" ? {
|
|
198
201
|
...e,
|
|
199
202
|
textContent: void 0,
|
|
200
203
|
textTruncated: !0
|
|
201
|
-
} : (n -= t.text.length,
|
|
204
|
+
} : (n -= t.text.length, r -= t.text.length, {
|
|
202
205
|
...e,
|
|
203
206
|
textContent: t.text,
|
|
204
207
|
textTruncated: e.textTruncated || t.truncated,
|
|
@@ -209,11 +212,11 @@ function N(e, t) {
|
|
|
209
212
|
} } : {}
|
|
210
213
|
});
|
|
211
214
|
}
|
|
212
|
-
let { text:
|
|
213
|
-
return n -=
|
|
215
|
+
let { text: s, truncated: c } = S(e.textContent ?? "", o);
|
|
216
|
+
return n -= s.length, a && (r -= s.length), {
|
|
214
217
|
...e,
|
|
215
|
-
textContent:
|
|
216
|
-
textTruncated: e.textTruncated ||
|
|
218
|
+
textContent: s,
|
|
219
|
+
textTruncated: e.textTruncated || c
|
|
217
220
|
};
|
|
218
221
|
};
|
|
219
222
|
for (let t of [!1, !0]) e.forEach((e, n) => {
|
|
@@ -221,76 +224,126 @@ function N(e, t) {
|
|
|
221
224
|
});
|
|
222
225
|
return a;
|
|
223
226
|
}
|
|
224
|
-
|
|
225
|
-
|
|
227
|
+
var ie = (e) => ({
|
|
228
|
+
perFileChars: e.perFileChars,
|
|
229
|
+
totalChars: e.totalChars,
|
|
230
|
+
documentChars: e.totalChars
|
|
231
|
+
});
|
|
232
|
+
function N(e, t, n) {
|
|
233
|
+
let r = M(e, t);
|
|
226
234
|
return [
|
|
227
235
|
"",
|
|
228
236
|
`--- Attachments (${e.length}) ---`,
|
|
229
237
|
"The user attached the following file(s) to this message.",
|
|
230
|
-
...r.map((e, t) =>
|
|
238
|
+
...r.map((e, t) => A(e, t, n)),
|
|
231
239
|
"--- End attachments ---"
|
|
232
240
|
].join("\n");
|
|
233
241
|
}
|
|
234
|
-
var
|
|
235
|
-
function
|
|
236
|
-
let
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
demotedImageIds:
|
|
242
|
+
var P = 2048;
|
|
243
|
+
function ae(e, t, n) {
|
|
244
|
+
let r = L(e, t, n);
|
|
245
|
+
return F(n) ? {
|
|
246
|
+
budget: R(e, t, r.budget, r.demotedImageIds),
|
|
247
|
+
demotedImageIds: r.demotedImageIds
|
|
248
|
+
} : r;
|
|
249
|
+
}
|
|
250
|
+
function F(e) {
|
|
251
|
+
return e.perFileChars > d.perFileChars || e.totalChars > d.totalChars;
|
|
252
|
+
}
|
|
253
|
+
var I = (e, t) => e ? `${e}\n${t}` : t.trimStart();
|
|
254
|
+
function L(e, t, n) {
|
|
255
|
+
let r = ie(n), i = (e) => ({
|
|
256
|
+
...r,
|
|
257
|
+
documentChars: e
|
|
258
|
+
}), a = Q(e);
|
|
259
|
+
if (a.length === 0) return {
|
|
260
|
+
budget: r,
|
|
261
|
+
demotedImageIds: j
|
|
240
262
|
};
|
|
241
|
-
let
|
|
242
|
-
let
|
|
243
|
-
return
|
|
263
|
+
let o = (n, r, o) => {
|
|
264
|
+
let s = new Set(a.slice(0, n).map((e) => e.id)), c = I(t, N(e, i(r), o)), { media: l } = $(e, s);
|
|
265
|
+
return X(c, [{
|
|
244
266
|
type: "text",
|
|
245
267
|
text: c
|
|
246
|
-
}, ...l]) +
|
|
268
|
+
}, ...l]) + P <= G;
|
|
247
269
|
};
|
|
248
|
-
for (let e =
|
|
249
|
-
let t = new Set(
|
|
250
|
-
if (
|
|
251
|
-
|
|
270
|
+
for (let e = a.length; e >= 0; --e) {
|
|
271
|
+
let t = new Set(a.slice(e).map((e) => e.id));
|
|
272
|
+
if (o(e, r.documentChars, t)) return {
|
|
273
|
+
budget: r,
|
|
252
274
|
demotedImageIds: t
|
|
253
275
|
};
|
|
254
|
-
if (!
|
|
255
|
-
let
|
|
256
|
-
for (;
|
|
257
|
-
let
|
|
258
|
-
|
|
276
|
+
if (!o(e, 0, t)) continue;
|
|
277
|
+
let n = 0, s = r.documentChars;
|
|
278
|
+
for (; n < s;) {
|
|
279
|
+
let r = Math.ceil((n + s) / 2);
|
|
280
|
+
o(e, r, t) ? n = r : s = r - 1;
|
|
259
281
|
}
|
|
260
282
|
return {
|
|
261
|
-
|
|
283
|
+
budget: i(n),
|
|
262
284
|
demotedImageIds: t
|
|
263
285
|
};
|
|
264
286
|
}
|
|
265
287
|
return {
|
|
266
|
-
|
|
267
|
-
demotedImageIds: new Set(
|
|
288
|
+
budget: r,
|
|
289
|
+
demotedImageIds: new Set(a.map((e) => e.id))
|
|
268
290
|
};
|
|
269
291
|
}
|
|
270
|
-
function
|
|
271
|
-
let
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
292
|
+
function R(e, t, n, r) {
|
|
293
|
+
let i = (e) => ({
|
|
294
|
+
perFileChars: n.perFileChars,
|
|
295
|
+
totalChars: e,
|
|
296
|
+
documentChars: Math.min(n.documentChars, e)
|
|
297
|
+
}), a = (n) => X(I(t, N(e, n, r))) + P <= G;
|
|
298
|
+
if (a(n)) return n;
|
|
299
|
+
if (!a(i(0))) return i(0);
|
|
300
|
+
let o = 0, s = n.totalChars;
|
|
301
|
+
for (; o < s;) {
|
|
302
|
+
let e = Math.ceil((o + s) / 2);
|
|
303
|
+
a(i(e)) ? o = e : s = e - 1;
|
|
304
|
+
}
|
|
305
|
+
return i(o);
|
|
275
306
|
}
|
|
276
|
-
function
|
|
277
|
-
let
|
|
278
|
-
|
|
307
|
+
function z(e, t = "", n = d) {
|
|
308
|
+
let r = b(e);
|
|
309
|
+
if (r.length === 0) return "";
|
|
310
|
+
let i = ae(r, t, n);
|
|
311
|
+
return N(r, i.budget, i.demotedImageIds);
|
|
279
312
|
}
|
|
280
|
-
|
|
313
|
+
function B(e, t, n = d) {
|
|
314
|
+
let r = z(t, e, n);
|
|
315
|
+
return r ? I(e, r) : e;
|
|
316
|
+
}
|
|
317
|
+
var V = 3, H = 15e5, U = e, W = 32768, G = U - W, K = Math.min(t, G - P);
|
|
281
318
|
function q(e) {
|
|
282
|
-
|
|
319
|
+
if (!(typeof e != "number" || !Number.isFinite(e) || e < 1)) return Math.min(Math.floor(e), K);
|
|
283
320
|
}
|
|
284
|
-
function J(e
|
|
285
|
-
|
|
321
|
+
function J(e) {
|
|
322
|
+
let t = q(e?.maxInlineCharsPerFile), n = q(e?.maxInlineCharsTotal);
|
|
323
|
+
if (t === void 0 && n === void 0) return d;
|
|
324
|
+
let r = t ?? d.perFileChars, i = n ?? Math.max(d.totalChars, r);
|
|
325
|
+
return Object.freeze({
|
|
326
|
+
perFileChars: Math.min(r, i),
|
|
327
|
+
totalChars: i
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
function oe(e) {
|
|
331
|
+
return (e ?? []).reduce((e, t) => Math.max(e, J(t).perFileChars), d.perFileChars);
|
|
332
|
+
}
|
|
333
|
+
var se = 768, ce = .6, Y = typeof TextEncoder == "function" ? new TextEncoder() : null;
|
|
334
|
+
function le(e) {
|
|
335
|
+
return Y ? Y.encode(e).length : e.length;
|
|
336
|
+
}
|
|
337
|
+
function X(e, t) {
|
|
338
|
+
return le(JSON.stringify({
|
|
286
339
|
prompt: e,
|
|
287
340
|
parts: t ?? []
|
|
288
341
|
}));
|
|
289
342
|
}
|
|
290
|
-
function
|
|
343
|
+
function ue(e) {
|
|
291
344
|
return b(e).filter((e) => e.kind === "image" && !!(e.inlineDataUrl ?? e.previewUrl)).length;
|
|
292
345
|
}
|
|
293
|
-
function
|
|
346
|
+
function de(e) {
|
|
294
347
|
return (e ?? []).filter((e) => e.type === "image" && !!e.data).length;
|
|
295
348
|
}
|
|
296
349
|
function Z(e) {
|
|
@@ -332,7 +385,7 @@ function $(e, t) {
|
|
|
332
385
|
});
|
|
333
386
|
continue;
|
|
334
387
|
}
|
|
335
|
-
i.downloadUrl &&
|
|
388
|
+
i.downloadUrl && c(i.mimeType) && n.push({
|
|
336
389
|
type: "file",
|
|
337
390
|
mimeType: i.mimeType,
|
|
338
391
|
url: i.downloadUrl,
|
|
@@ -344,15 +397,15 @@ function $(e, t) {
|
|
|
344
397
|
inlinedIndices: r
|
|
345
398
|
};
|
|
346
399
|
}
|
|
347
|
-
function
|
|
400
|
+
function fe(e, t) {
|
|
348
401
|
let n = b(t);
|
|
349
402
|
if (n.length === 0) return;
|
|
350
403
|
let { media: r, inlinedIndices: i } = $(n, new Set(Q(n).map((e) => e.id)));
|
|
351
404
|
if (r.length !== 0) {
|
|
352
|
-
for (; i.length > 0 &&
|
|
405
|
+
for (; i.length > 0 && X(e, [{
|
|
353
406
|
type: "text",
|
|
354
407
|
text: e
|
|
355
|
-
}, ...r]) >
|
|
408
|
+
}, ...r]) > G;) {
|
|
356
409
|
let e = i.pop();
|
|
357
410
|
if (e === void 0) break;
|
|
358
411
|
let t = r[e];
|
|
@@ -363,14 +416,14 @@ function te(e, t) {
|
|
|
363
416
|
name: t.name
|
|
364
417
|
} : r.splice(e, 1));
|
|
365
418
|
}
|
|
366
|
-
if (r.length !== 0 && !(
|
|
419
|
+
if (r.length !== 0 && !(X(e, [{
|
|
367
420
|
type: "text",
|
|
368
421
|
text: e
|
|
369
|
-
}, ...r]) >
|
|
422
|
+
}, ...r]) > G)) return [{
|
|
370
423
|
type: "text",
|
|
371
424
|
text: e
|
|
372
425
|
}, ...r];
|
|
373
426
|
}
|
|
374
427
|
}
|
|
375
428
|
//#endregion
|
|
376
|
-
export { _ as ATTACHMENT_ACCEPT,
|
|
429
|
+
export { _ as ATTACHMENT_ACCEPT, f as AttachmentRejectedError, d as DEFAULT_INLINE_LIMITS, se as INLINE_IMAGE_MAX_DIM, ce as INLINE_IMAGE_QUALITY, a as MAX_ATTACHMENTS, K as MAX_CONFIGURABLE_INLINE_CHARS, o as MAX_FILE_BYTES, l as MAX_INLINE_CHARS_PER_FILE, u as MAX_INLINE_CHARS_TOTAL, H as MAX_INLINE_IMAGE_BASE64_CHARS, V as MAX_INLINE_IMAGE_PARTS, G as MAX_INLINE_TURN_BODY_BYTES, U as MAX_TURN_BODY_BYTES, P as PROMPT_ENVELOPE_RESERVE_BYTES, s as PROVIDER_READABLE_FILE_MEDIA_TYPES, W as TURN_BODY_HEADROOM_BYTES, z as buildAttachmentPromptBlock, fe as buildPromptParts, B as buildPromptWithAttachments, te as classifyAttachment, ue as countInlineImageCandidates, de as countInlinedImageParts, g as detectDocumentFormat, X as estimateTurnBodyBytes, v as formatBytes, x as getAttachmentSendBlocker, m as getExtension, b as getSendableAttachments, y as hasAttachmentWorkInFlight, c as isProviderReadableFilePart, oe as largestInlineCharsPerFile, Z as parseDataUrl, J as resolveAssistantInlineLimits, ee as toMessageAttachment, S as truncateForInline, re as validateFile };
|
|
@@ -234,5 +234,26 @@ export interface AssistantModeConfig {
|
|
|
234
234
|
* Default: `false` for every mode, built-in or product-declared.
|
|
235
235
|
*/
|
|
236
236
|
accumulatesNarration?: boolean;
|
|
237
|
+
/**
|
|
238
|
+
* How many characters of ONE attached file's text this mode sends inline
|
|
239
|
+
* (BOFF-7334). For a mode that builds from what it is handed — BigConsole's
|
|
240
|
+
* Build designs a data sink from a CSV.
|
|
241
|
+
*
|
|
242
|
+
* Default: `MAX_INLINE_CHARS_PER_FILE` (8,000). A positive number; anything
|
|
243
|
+
* else is ignored, and anything above `MAX_CONFIGURABLE_INLINE_CHARS`
|
|
244
|
+
* (200,000) is held at it. Set alone, the turn total rises to match it.
|
|
245
|
+
* Resolved by `resolveAssistantInlineLimits`.
|
|
246
|
+
*
|
|
247
|
+
* ★ A ceiling, not a promise: however large, a turn still has to fit the
|
|
248
|
+
* gateway's 256 KB body, and text that would not fit is cut — documents first,
|
|
249
|
+
* then text files — with the cut said in the prompt.
|
|
250
|
+
*/
|
|
251
|
+
maxInlineCharsPerFile?: number;
|
|
252
|
+
/**
|
|
253
|
+
* How many characters of attached text, across every file in one turn, this
|
|
254
|
+
* mode sends inline. Default: `MAX_INLINE_CHARS_TOTAL` (20,000), or the
|
|
255
|
+
* per-file limit if that is larger; bounded like `maxInlineCharsPerFile`.
|
|
256
|
+
*/
|
|
257
|
+
maxInlineCharsTotal?: number;
|
|
237
258
|
}
|
|
238
259
|
//# sourceMappingURL=conversation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../../src/shared/assistant/conversation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAC;AAIhE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,MAAM,MAAM,sBAAsB,GAC9B,MAAM,GACN,cAAc,GACd,SAAS,GACT,UAAU,GACV,OAAO,CAAC;AAEZ,MAAM,MAAM,2BAA2B,GACnC,MAAM,GACN,cAAc,GACd,YAAY,GACZ,WAAW,GACX,UAAU,GACV,OAAO,CAAC;AAEZ;;;;;;;;;GASG;AACH,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,wBAAwB;IACvC,SAAS,CAAC,EAAE,sBAAsB,EAAE,CAAC;IACrC,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,WAAW,CAAC,EAAE,0BAA0B,EAAE,CAAC;IAC3C;;;;;;;;;OASG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;;;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E,MAAM,GAAG,IAAI,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,KAAK,CAAC,EAAE,kBAAkB,CAAC;IAC3B;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,aAAa,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,wEAAwE;IACxE,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,kFAAkF;IAClF,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;;;;OAMG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;;;;;;OAOG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;;;;;;OAQG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC;;;;;;;;;;;;;;;OAeG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../../src/shared/assistant/conversation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAC;AAIhE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,MAAM,MAAM,sBAAsB,GAC9B,MAAM,GACN,cAAc,GACd,SAAS,GACT,UAAU,GACV,OAAO,CAAC;AAEZ,MAAM,MAAM,2BAA2B,GACnC,MAAM,GACN,cAAc,GACd,YAAY,GACZ,WAAW,GACX,UAAU,GACV,OAAO,CAAC;AAEZ;;;;;;;;;GASG;AACH,MAAM,WAAW,sBAAsB;IAC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EAAE,MAAM,CAAC;IAC/B;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B"}
|
|
@@ -2,7 +2,10 @@ import { DocumentExtraction } from './documentText';
|
|
|
2
2
|
import { DocumentFormat } from './attachments';
|
|
3
3
|
export interface ExtractedDocument {
|
|
4
4
|
extraction: DocumentExtraction;
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* Already trimmed to the per-file limit passed in (`MAX_INLINE_CHARS_PER_FILE`
|
|
7
|
+
* by default). Absent unless status is 'ok'.
|
|
8
|
+
*/
|
|
6
9
|
textContent?: string;
|
|
7
10
|
/** True when `textContent` is a prefix of what the document actually holds. */
|
|
8
11
|
textTruncated?: boolean;
|
|
@@ -18,5 +21,11 @@ export interface ExtractedDocument {
|
|
|
18
21
|
* generic 'unreadable' rejection, and the user would lose the file over
|
|
19
22
|
* something that is only a partial loss.
|
|
20
23
|
*/
|
|
21
|
-
export declare function extractDocumentText(file: File, format: DocumentFormat
|
|
24
|
+
export declare function extractDocumentText(file: File, format: DocumentFormat,
|
|
25
|
+
/**
|
|
26
|
+
* How much of the text to keep (BOFF-7334). Defaults to the shared per-file
|
|
27
|
+
* limit; the composer passes the largest limit among the modes on offer —
|
|
28
|
+
* see `largestInlineCharsPerFile`.
|
|
29
|
+
*/
|
|
30
|
+
perFileChars?: number): Promise<ExtractedDocument>;
|
|
22
31
|
//# sourceMappingURL=documentExtract.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documentExtract.d.ts","sourceRoot":"","sources":["../../../src/shared/assistant/documentExtract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,OAAO,EAUL,KAAK,kBAAkB,EACxB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAA6B,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AAK/E,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,kBAAkB,CAAC;IAC/B
|
|
1
|
+
{"version":3,"file":"documentExtract.d.ts","sourceRoot":"","sources":["../../../src/shared/assistant/documentExtract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,OAAO,EAUL,KAAK,kBAAkB,EACxB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAA6B,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AAK/E,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,kBAAkB,CAAC;IAC/B;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,+EAA+E;IAC/E,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,oFAAoF;IACpF,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B;AAgQD;;;;;;;;GAQG;AACH,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,cAAc;AACtB;;;;GAIG;AACH,YAAY,GAAE,MAAkC,GAC/C,OAAO,CAAC,iBAAiB,CAAC,CAM5B"}
|