@burdenoff/fe-libs 2026.1007.6 → 2026.1008.1

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.
Files changed (39) hide show
  1. package/dist/shared/assistant/attachmentCommit.d.ts +175 -0
  2. package/dist/shared/assistant/attachmentCommit.d.ts.map +1 -0
  3. package/dist/shared/assistant/attachmentCommit.js +638 -0
  4. package/dist/shared/assistant/attachments.d.ts +39 -19
  5. package/dist/shared/assistant/attachments.d.ts.map +1 -1
  6. package/dist/shared/assistant/history/historyEngine.js +280 -280
  7. package/dist/shared/assistant/i18nManifest.d.ts +14 -2
  8. package/dist/shared/assistant/i18nManifest.d.ts.map +1 -1
  9. package/dist/shared/assistant/i18nManifest.js +17 -3
  10. package/dist/shared/assistant/index.d.ts +3 -0
  11. package/dist/shared/assistant/index.d.ts.map +1 -1
  12. package/dist/shared/assistant/ui/AssistantChatArea.d.ts.map +1 -1
  13. package/dist/shared/assistant/ui/AssistantChatArea.js +1390 -1371
  14. package/dist/shared/assistant/ui/composer/AssistantAttachmentChips.d.ts +8 -5
  15. package/dist/shared/assistant/ui/composer/AssistantAttachmentChips.d.ts.map +1 -1
  16. package/dist/shared/assistant/ui/composer/AssistantAttachmentChips.js +26 -9
  17. package/dist/shared/assistant/ui/composer/AssistantComposer.d.ts +3 -2
  18. package/dist/shared/assistant/ui/composer/AssistantComposer.d.ts.map +1 -1
  19. package/dist/shared/assistant/ui/composer/AssistantComposer.js +214 -125
  20. package/dist/shared/assistant/ui/voice/AssistantVoiceSession.d.ts +10 -0
  21. package/dist/shared/assistant/ui/voice/AssistantVoiceSession.d.ts.map +1 -1
  22. package/dist/shared/assistant/ui/voice/AssistantVoiceSession.js +124 -116
  23. package/dist/shared/assistant/useAssistantAttachments.d.ts +20 -2
  24. package/dist/shared/assistant/useAssistantAttachments.d.ts.map +1 -1
  25. package/dist/shared/assistant/useAssistantAttachments.js +146 -202
  26. package/dist/shared/assistant/useAttachmentCommitter.d.ts +17 -0
  27. package/dist/shared/assistant/useAttachmentCommitter.d.ts.map +1 -0
  28. package/dist/shared/assistant/useAttachmentCommitter.js +41 -0
  29. package/dist/shared/assistant/voiceCommit.d.ts +36 -0
  30. package/dist/shared/assistant/voiceCommit.d.ts.map +1 -0
  31. package/dist/shared/assistant/voiceCommit.js +24 -0
  32. package/dist/shared-assistant.js +161 -158
  33. package/dist/storage/filesPort.d.ts +111 -0
  34. package/dist/storage/filesPort.d.ts.map +1 -0
  35. package/dist/storage/filesPort.js +262 -0
  36. package/dist/storage/index.d.ts +2 -0
  37. package/dist/storage/index.d.ts.map +1 -1
  38. package/dist/storage/index.js +9 -8
  39. package/package.json +1 -1
@@ -1,245 +1,189 @@
1
- import { graphqlFetch as e } from "../graphql/fetch.js";
2
- import "../../shared-graphql.js";
3
- import { downscaleImage as t } from "../utils/imageDownscale.js";
4
- import { useAssistantStorageFolders as n } from "./product.js";
5
- import { useAssistantTr as r } from "./i18n.js";
6
- import { AttachmentRejectedError as i, INLINE_IMAGE_QUALITY as a, classifyAttachment as o, detectDocumentFormat as s, getAttachmentSendBlocker as c, resolveAssistantInlineLimits as l, truncateForInline as u, validateFile as d } from "./attachments.js";
7
- import { getWorkspaceId as f } from "./context.js";
8
- import { useSaveToFiles as p } from "../../storage/useSaveToFiles.js";
9
- import "../../storage/index.js";
10
- import { extractDocumentText as m } from "./documentExtract.js";
11
- import { useCallback as h, useEffect as g, useRef as _, useState as v } from "react";
1
+ import { downscaleImage as e } from "../utils/imageDownscale.js";
2
+ import { AttachmentRejectedError as t, INLINE_IMAGE_QUALITY as n, classifyAttachment as r, detectDocumentFormat as i, getAttachmentSendBlocker as a, resolveAssistantInlineLimits as o, truncateForInline as s, validateFile as c } from "./attachments.js";
3
+ import "./attachmentCommit.js";
4
+ import { useAttachmentCommitter as l } from "./useAttachmentCommitter.js";
5
+ import { extractDocumentText as u } from "./documentExtract.js";
6
+ import { useCallback as d, useEffect as f, useRef as p, useState as m } from "react";
12
7
  //#region src/shared/assistant/useAssistantAttachments.ts
13
- var y = "\n query AssistantAttachmentUrl($id: ID!) {\n getFileDownloadUrl(id: $id)\n }\n";
14
- async function b(t, n) {
15
- if (!t || !n) return null;
16
- try {
17
- return (await e({
18
- gateway: "workspace",
19
- query: y,
20
- variables: { id: t },
21
- workspaceToken: !0,
22
- workspaceId: n,
23
- suppressGlobalErrorEvent: !0
24
- })).data?.getFileDownloadUrl ?? null;
25
- } catch {
26
- return null;
27
- }
28
- }
29
- var x = 0;
30
- function S() {
31
- return x += 1, `att-${Date.now()}-${x}`;
8
+ var h = 0;
9
+ function g() {
10
+ return h += 1, `att-${Date.now()}-${h}`;
32
11
  }
33
- async function C(e, n) {
34
- let r = o(e.type, e.name), c = {
35
- id: S(),
12
+ async function _(a, o) {
13
+ let c = r(a.type, a.name), l = {
14
+ id: g(),
36
15
  status: "pending"
37
16
  };
38
- if (r === "image") {
39
- let n = await t(e, {
17
+ if (c === "image") {
18
+ let r = await e(a, {
40
19
  encodeFallback: !1,
41
20
  inline: {
42
21
  maxDim: 768,
43
- quality: a
22
+ quality: n
44
23
  }
45
24
  });
46
- if (!n.downscaled && n.blob.size > 10485760) throw new i("unsupported-image");
47
- return {
25
+ if (!r.downscaled && r.blob.size > 10485760) throw new t("unsupported-image");
26
+ return v({
48
27
  attachment: {
49
- ...c,
50
- filename: n.filename,
51
- mimeType: n.mimeType,
52
- size: n.blob.size,
53
- kind: r,
54
- previewUrl: n.dataUrl || void 0,
55
- inlineDataUrl: n.inlineDataUrl
28
+ ...l,
29
+ filename: r.filename,
30
+ mimeType: r.mimeType,
31
+ size: r.blob.size,
32
+ kind: c,
33
+ previewUrl: r.dataUrl || void 0,
34
+ inlineDataUrl: r.inlineDataUrl
56
35
  },
57
- blob: n.blob
58
- };
36
+ blob: r.blob
37
+ });
59
38
  }
60
- if (r === "text") {
61
- let { text: t, truncated: i } = u(await e.text(), n);
62
- return {
39
+ let d = new Blob([await a.arrayBuffer()], { type: a.type || "application/octet-stream" });
40
+ if (c === "text") {
41
+ let { text: e, truncated: t } = s(await d.text(), o);
42
+ return v({
63
43
  attachment: {
64
- ...c,
65
- filename: e.name,
66
- mimeType: e.type || "text/plain",
67
- size: e.size,
68
- kind: r,
69
- textContent: t,
70
- textTruncated: i
44
+ ...l,
45
+ filename: a.name,
46
+ mimeType: a.type || "text/plain",
47
+ size: a.size,
48
+ kind: c,
49
+ textContent: e,
50
+ textTruncated: t
71
51
  },
72
- blob: e
73
- };
52
+ blob: d
53
+ });
74
54
  }
75
- let l = s(e.type, e.name);
76
- if (l) {
77
- let t = await m(e, l, n);
78
- return {
55
+ let f = i(a.type, a.name);
56
+ if (f) {
57
+ let e = await u(new File([d], a.name, { type: d.type }), f, o);
58
+ return v({
79
59
  attachment: {
80
- ...c,
81
- filename: e.name,
82
- mimeType: e.type || "application/octet-stream",
83
- size: e.size,
84
- kind: r,
85
- extraction: t.extraction,
86
- textContent: t.textContent,
87
- textTruncated: t.textTruncated,
88
- documentPages: t.documentPages
60
+ ...l,
61
+ filename: a.name,
62
+ mimeType: a.type || "application/octet-stream",
63
+ size: a.size,
64
+ kind: c,
65
+ extraction: e.extraction,
66
+ textContent: e.textContent,
67
+ textTruncated: e.textTruncated,
68
+ documentPages: e.documentPages
89
69
  },
90
- blob: e
91
- };
70
+ blob: d
71
+ });
92
72
  }
93
- return {
73
+ return v({
94
74
  attachment: {
95
- ...c,
96
- filename: e.name,
97
- mimeType: e.type || "application/octet-stream",
98
- size: e.size,
99
- kind: r
75
+ ...l,
76
+ filename: a.name,
77
+ mimeType: a.type || "application/octet-stream",
78
+ size: a.size,
79
+ kind: c
100
80
  },
101
- blob: e
81
+ blob: d
82
+ });
83
+ }
84
+ function v(e) {
85
+ if (e.blob.size <= 5242880) return e;
86
+ let { attachment: n } = e;
87
+ if (n.kind === "image" || !n.textContent) throw new t("too-large-to-save");
88
+ return {
89
+ ...e,
90
+ attachment: {
91
+ ...n,
92
+ inlineOnly: !0
93
+ }
102
94
  };
103
95
  }
104
- function w(e = {}) {
105
- let t = r(), a = l({ maxInlineCharsPerFile: e.perFileChars }).perFileChars, o = n(), { save: s } = p(), [u, m] = v([]), [y, x] = v(null), S = _(Promise.resolve()), [w, T] = v(0), E = _(0), D = _(/* @__PURE__ */ new Map()), O = _(/* @__PURE__ */ new Set()), k = _(0), A = _(!0);
106
- g(() => () => {
107
- A.current = !1;
108
- }, []);
109
- let j = _([]);
110
- g(() => {
111
- j.current = u;
112
- }, [u]);
113
- let M = h((e, t) => {
114
- A.current && m((n) => n.map((n) => n.id === e ? {
96
+ function y(e = {}) {
97
+ let n = o({ maxInlineCharsPerFile: e.perFileChars }).perFileChars, [r, i] = m([]), [s, u] = m(null), [h, g] = m(!1), v = p(Promise.resolve()), [y, b] = m(0), x = p(0), S = p(/* @__PURE__ */ new Map()), C = p(0), w = p(!0), T = p(r);
98
+ T.current = r;
99
+ let E = d((e, t) => {
100
+ w.current && i((n) => n.map((n) => n.id === e ? {
115
101
  ...n,
116
102
  ...t
117
103
  } : n));
118
- }, []), N = h(async ({ attachment: e, blob: n }) => {
119
- if (!O.current.has(e.id)) {
120
- M(e.id, {
121
- status: "uploading",
122
- progressNote: void 0
123
- });
124
- try {
125
- let r = await s({
126
- source: {
127
- kind: "blob",
128
- filename: e.filename,
129
- mimeType: e.mimeType,
130
- getBlob: async () => ({
131
- blob: n,
132
- filename: e.filename,
133
- mimeType: e.mimeType
134
- })
135
- },
136
- folderPath: o.attachments,
137
- onRetry: (n) => {
138
- O.current.has(e.id) || M(e.id, { progressNote: n.kind === "cold-start" ? t("attachments.waking", "File service is starting up — retry {{attempt}} of {{max}}", {
139
- attempt: String(n.attempt),
140
- max: String(n.maxAttempts)
141
- }) : t("attachments.retrying", "Retrying {{attempt}} of {{max}}", {
142
- attempt: String(n.attempt),
143
- max: String(n.maxAttempts)
144
- }) });
145
- }
146
- });
147
- if (O.current.has(e.id)) return;
148
- let i = r?.id ? await b(r.id, f()) : null;
149
- if (O.current.has(e.id)) return;
150
- M(e.id, {
151
- status: "ready",
152
- fileId: r?.id,
153
- downloadUrl: i ?? void 0,
154
- progressNote: void 0
155
- });
156
- } catch (t) {
157
- if (O.current.has(e.id)) return;
158
- if (e.kind === "text" || e.textContent) {
159
- M(e.id, {
160
- status: "ready",
161
- progressNote: void 0
162
- });
163
- return;
164
- }
165
- M(e.id, {
166
- status: "error",
167
- error: t instanceof Error ? t.message : "Upload failed",
168
- progressNote: void 0
169
- });
170
- }
171
- }
172
- }, [
173
- M,
174
- s,
175
- t
176
- ]), P = h((e) => {
177
- if (!e) return;
178
- let t = Array.from(e);
179
- if (t.length === 0) return;
180
- x(null);
181
- let n = [];
182
- for (let e of t) {
183
- let t = d(e, k.current);
104
+ }, []), D = l(E), O = p(D);
105
+ O.current = D, f(() => (w.current = !0, () => {
106
+ w.current = !1, O.current.cancel(), O.current.discardPending();
107
+ }), []);
108
+ let k = d((e) => {
109
+ if (!e || O.current.isCommitting) return;
110
+ let r = Array.from(e);
111
+ if (r.length === 0) return;
112
+ u(null);
113
+ let a = [];
114
+ for (let e of r) {
115
+ let t = c(e, C.current);
184
116
  if (t) {
185
- x(t);
117
+ u(t);
186
118
  continue;
187
119
  }
188
- n.push(e), k.current += 1;
120
+ a.push(e), C.current += 1;
189
121
  }
190
- if (n.length !== 0) {
191
- T((e) => e + n.length);
192
- for (let e of n) {
193
- let t = E.current;
194
- S.current = S.current.then(async () => {
195
- let n = null;
122
+ if (a.length !== 0) {
123
+ b((e) => e + a.length);
124
+ for (let e of a) {
125
+ let r = x.current;
126
+ v.current = v.current.then(async () => {
127
+ let a = null;
196
128
  try {
197
- n = await C(e, a);
129
+ a = await _(e, n);
198
130
  } catch (e) {
199
- k.current = Math.max(0, k.current - 1), A.current && x(e instanceof i ? e.reason : "unreadable");
131
+ C.current = Math.max(0, C.current - 1), w.current && u(e instanceof t ? e.reason : "unreadable");
200
132
  }
201
- if (!A.current || (T((e) => Math.max(0, e - 1)), !n)) return;
202
- if (t !== E.current) {
203
- k.current = Math.max(0, k.current - 1);
133
+ if (!w.current || (b((e) => Math.max(0, e - 1)), !a)) return;
134
+ if (r !== x.current) {
135
+ C.current = Math.max(0, C.current - 1);
204
136
  return;
205
137
  }
206
- let r = n;
207
- D.current.set(r.attachment.id, r.blob), m((e) => [...e, r.attachment]), await N(r);
138
+ let o = a;
139
+ S.current.set(o.attachment.id, o.blob), i((e) => [...e, {
140
+ ...o.attachment,
141
+ status: "ready"
142
+ }]);
208
143
  });
209
144
  }
210
145
  }
211
- }, [N, a]), F = h((e) => {
212
- O.current.add(e), D.current.delete(e), k.current = Math.max(0, k.current - 1), m((t) => t.filter((t) => t.id !== e));
213
- }, []), I = h((e) => {
214
- let t = j.current.find((t) => t.id === e), n = D.current.get(e);
215
- !t || t.status !== "error" || !n || (O.current.delete(e), M(e, {
216
- status: "pending",
146
+ }, [n]), A = d((e) => {
147
+ T.current.find((t) => t.id === e)?.status !== "uploading" && (S.current.delete(e), C.current = Math.max(0, C.current - 1), i((t) => t.filter((t) => t.id !== e)));
148
+ }, []), j = d((e) => {
149
+ let t = T.current.find((t) => t.id === e);
150
+ !t || !S.current.has(e) || t.status === "uploading" || t.status === "pending" || E(e, {
151
+ status: "ready",
217
152
  error: void 0,
153
+ saveError: void 0,
154
+ progress: void 0,
218
155
  progressNote: void 0
219
- }), S.current = S.current.then(() => N({
220
- attachment: {
221
- ...t,
222
- status: "pending",
223
- error: void 0
224
- },
225
- blob: n
226
- })));
227
- }, [M, N]), L = h(() => {
228
- E.current += 1, k.current = 0, j.current.forEach((e) => O.current.add(e.id)), D.current.clear(), m([]);
229
- }, []), R = c(w, u);
156
+ });
157
+ }, [E]), M = d(() => O.current.cancel(), []), N = d(async (e) => {
158
+ let t = T.current.filter((e) => e.status === "ready").map((e) => ({
159
+ attachment: e,
160
+ blob: S.current.get(e.id) ?? null
161
+ }));
162
+ g(!0);
163
+ try {
164
+ return await O.current.commit(t, e);
165
+ } finally {
166
+ w.current && g(!1);
167
+ }
168
+ }, []), P = d(() => {
169
+ O.current.cancel(), O.current.discardPending(), x.current += 1, C.current = 0, S.current.clear(), i([]);
170
+ }, []), F = d(() => u(null), []), I = a(y, r);
230
171
  return {
231
- attachments: u,
232
- isBusy: R === "in-flight",
233
- preparingCount: w,
234
- sendBlocker: R,
235
- rejection: y,
236
- addFiles: P,
237
- remove: F,
238
- retry: I,
239
- clear: L,
240
- clearRejection: h(() => x(null), []),
241
- canAddMore: k.current < 5
172
+ attachments: r,
173
+ isBusy: I === "in-flight",
174
+ preparingCount: y,
175
+ sendBlocker: I,
176
+ rejection: s,
177
+ addFiles: k,
178
+ remove: A,
179
+ retry: j,
180
+ clear: P,
181
+ clearRejection: F,
182
+ canAddMore: C.current < 5,
183
+ commit: N,
184
+ cancelCommit: M,
185
+ isCommitting: h
242
186
  };
243
187
  }
244
188
  //#endregion
245
- export { w as useAssistantAttachments };
189
+ export { y as useAssistantAttachments };
@@ -0,0 +1,17 @@
1
+ import { FilesPort } from '../../storage/filesPort';
2
+ import { AttachmentCommitter, CommitOptions } from './attachmentCommit';
3
+ /**
4
+ * A test seam: a `FilesPort` that replaces the Apollo-backed one for everything below it. Never
5
+ * provided in production.
6
+ */
7
+ export declare const AttachmentFilesPortContext: import('react').Context<FilesPort | null>;
8
+ /** The Files port for this tree: the override if one is provided, else the Apollo client's. */
9
+ export declare function useAttachmentFilesPort(): FilesPort | null;
10
+ /** Mint a download URL for a saved file (Retry replays an old turn's attachments). */
11
+ export declare function useAttachmentUrlResolver(): (fileId: string) => Promise<string | null>;
12
+ /**
13
+ * One committer per mounted draft. `onChange` and the product's folder are read at call time, so
14
+ * the committer (and the failed rollbacks it remembers) survives re-renders.
15
+ */
16
+ export declare function useAttachmentCommitter(onChange: NonNullable<CommitOptions['onChange']>): AttachmentCommitter;
17
+ //# sourceMappingURL=useAttachmentCommitter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAttachmentCommitter.d.ts","sourceRoot":"","sources":["../../../src/shared/assistant/useAttachmentCommitter.ts"],"names":[],"mappings":"AAQA,OAAO,EAGL,KAAK,SAAS,EAEf,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAEL,KAAK,mBAAmB,EACxB,KAAK,aAAa,EACnB,MAAM,oBAAoB,CAAC;AAG5B;;;GAGG;AACH,eAAO,MAAM,0BAA0B,2CAAwC,CAAC;AAEhF,+FAA+F;AAC/F,wBAAgB,sBAAsB,IAAI,SAAS,GAAG,IAAI,CAOzD;AAED,sFAAsF;AACtF,wBAAgB,wBAAwB,IAAI,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAGrF;AAkBD;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,WAAW,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,GAC/C,mBAAmB,CAqBrB"}
@@ -0,0 +1,41 @@
1
+ import { useAssistantStorageFolders as e } from "./product.js";
2
+ import { FilesPortError as t, createApolloFilesPort as n } from "../../storage/filesPort.js";
3
+ import { createAttachmentCommitter as r } from "./attachmentCommit.js";
4
+ import { getWorkspaceId as i } from "./context.js";
5
+ import { createContext as a, useCallback as o, useContext as s, useMemo as c, useRef as l } from "react";
6
+ import { getApolloContext as u } from "@apollo/client/react";
7
+ //#region src/shared/assistant/useAttachmentCommitter.ts
8
+ var d = a(null);
9
+ function f() {
10
+ let e = s(d), { client: t } = s(u());
11
+ return c(() => e ?? (t ? n(t, { getWorkspaceId: i }) : null), [e, t]);
12
+ }
13
+ function p() {
14
+ let e = f();
15
+ return o(async (t) => e ? e.getDownloadUrl(t) : null, [e]);
16
+ }
17
+ var m = (e) => () => Promise.reject(new t(e, "File storage is not available here.", void 0)), h = {
18
+ ensureFolder: m("ensureFolder"),
19
+ initiate: m("initiate"),
20
+ put: m("put"),
21
+ complete: m("complete"),
22
+ getSession: m("getSession"),
23
+ listSessions: m("listSessions"),
24
+ abort: m("abort"),
25
+ getDownloadUrl: m("getDownloadUrl"),
26
+ deleteFile: m("deleteFile")
27
+ };
28
+ function g(t) {
29
+ let n = f(), i = e(), a = l(t);
30
+ a.current = t;
31
+ let o = l(i.attachments);
32
+ return o.current = i.attachments, c(() => r({
33
+ port: n ?? h,
34
+ get folderPath() {
35
+ return o.current;
36
+ },
37
+ onChange: (e, t) => a.current(e, t)
38
+ }), [n]);
39
+ }
40
+ //#endregion
41
+ export { d as AttachmentFilesPortContext, g as useAttachmentCommitter, f as useAttachmentFilesPort, p as useAttachmentUrlResolver };
@@ -0,0 +1,36 @@
1
+ import { AssistantAttachment } from './attachments';
2
+ import { AttachmentCommitFailure, AttachmentCommitResult, CommitOptions } from './attachmentCommit';
3
+ /** How long a spoken turn waits for its files to be saved before it drops them. */
4
+ export declare const VOICE_COMMIT_BUDGET_MS = 20000;
5
+ /** The slice of the attachment draft this needs; `useAssistantAttachments` provides it. */
6
+ export interface SpokenTurnDraft {
7
+ readonly attachments: readonly AssistantAttachment[];
8
+ commit: (options?: {
9
+ mode?: CommitOptions['mode'];
10
+ budgetMs?: number;
11
+ signal?: AbortSignal;
12
+ }) => Promise<AttachmentCommitResult>;
13
+ clear: () => void;
14
+ }
15
+ export interface SettleSpokenTurnDeps {
16
+ draft: SpokenTurnDraft;
17
+ /** `maySendSpokenTurn` for this turn: false once the session ended or the conversation went. */
18
+ maySend: () => boolean;
19
+ /** Hand the turn over. Called after the commit, with only the attachments that may travel. */
20
+ sendTurn: (attachments: AssistantAttachment[]) => void;
21
+ /** Some files could not be saved and were not sent. Called once, before `sendTurn`. */
22
+ announceDropped: (count: number, failures: readonly AttachmentCommitFailure[]) => void;
23
+ budgetMs?: number;
24
+ }
25
+ export type SpokenTurnOutcome =
26
+ /** The turn was sent (possibly without some files). */
27
+ {
28
+ kind: 'sent';
29
+ dropped: number;
30
+ }
31
+ /** The turn no longer belongs anywhere; nothing was sent and the draft is cleared. */
32
+ | {
33
+ kind: 'abandoned';
34
+ };
35
+ export declare function settleAndCommitSpokenTurn(deps: SettleSpokenTurnDeps): Promise<SpokenTurnOutcome>;
36
+ //# sourceMappingURL=voiceCommit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"voiceCommit.d.ts","sourceRoot":"","sources":["../../../src/shared/assistant/voiceCommit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAA0B,KAAK,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACjF,OAAO,KAAK,EACV,uBAAuB,EACvB,sBAAsB,EACtB,aAAa,EACd,MAAM,oBAAoB,CAAC;AAE5B,mFAAmF;AACnF,eAAO,MAAM,sBAAsB,QAAS,CAAC;AAE7C,2FAA2F;AAC3F,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,WAAW,EAAE,SAAS,mBAAmB,EAAE,CAAC;IACrD,MAAM,EAAE,CAAC,OAAO,CAAC,EAAE;QACjB,IAAI,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;QAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,MAAM,CAAC,EAAE,WAAW,CAAC;KACtB,KAAK,OAAO,CAAC,sBAAsB,CAAC,CAAC;IACtC,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAED,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,eAAe,CAAC;IACvB,gGAAgG;IAChG,OAAO,EAAE,MAAM,OAAO,CAAC;IACvB,8FAA8F;IAC9F,QAAQ,EAAE,CAAC,WAAW,EAAE,mBAAmB,EAAE,KAAK,IAAI,CAAC;IACvD,uFAAuF;IACvF,eAAe,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,uBAAuB,EAAE,KAAK,IAAI,CAAC;IACvF,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,MAAM,iBAAiB;AAC3B,uDAAuD;AACrD;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE;AACnC,sFAAsF;GACpF;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,CAAC;AAQ1B,wBAAsB,yBAAyB,CAC7C,IAAI,EAAE,oBAAoB,GACzB,OAAO,CAAC,iBAAiB,CAAC,CAyC5B"}
@@ -0,0 +1,24 @@
1
+ import { getSendableAttachments as e } from "./attachments.js";
2
+ //#region src/shared/assistant/voiceCommit.ts
3
+ var t = 2e4;
4
+ function n(e) {
5
+ return e.some((e) => e.status === "ready" && !e.fileId && !e.inlineOnly);
6
+ }
7
+ async function r(t) {
8
+ let { draft: r } = t;
9
+ if (!t.maySend()) return r.clear(), { kind: "abandoned" };
10
+ if (!n(r.attachments)) return t.sendTurn(e([...r.attachments])), r.clear(), {
11
+ kind: "sent",
12
+ dropped: 0
13
+ };
14
+ let i = await r.commit({
15
+ mode: "best-effort",
16
+ budgetMs: t.budgetMs ?? 2e4
17
+ });
18
+ return i.ok ? t.maySend() ? (i.dropped.length > 0 && t.announceDropped(i.dropped.length, i.dropped), t.sendTurn(e(i.attachments)), i.handedOver(), r.clear(), {
19
+ kind: "sent",
20
+ dropped: i.dropped.length
21
+ }) : (await i.rollback(), r.clear(), { kind: "abandoned" }) : (r.clear(), { kind: "abandoned" });
22
+ }
23
+ //#endregion
24
+ export { t as VOICE_COMMIT_BUDGET_MS, r as settleAndCommitSpokenTurn };