@burdenoff/fe-libs 2026.926.4 → 2026.927.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 (121) hide show
  1. package/dist/chrome/ProductPickerSheet.d.ts.map +1 -1
  2. package/dist/chrome/ProductPickerSheet.js +45 -44
  3. package/dist/chrome/ProductSwitcher.d.ts.map +1 -1
  4. package/dist/chrome/ProductSwitcher.js +83 -82
  5. package/dist/shared/assistant/conversation.d.ts +91 -3
  6. package/dist/shared/assistant/conversation.d.ts.map +1 -1
  7. package/dist/shared/assistant/gatewayClient.d.ts +15 -0
  8. package/dist/shared/assistant/gatewayClient.d.ts.map +1 -1
  9. package/dist/shared/assistant/gatewayClient.js +1 -1
  10. package/dist/shared/assistant/guardedStorage.d.ts +4 -2
  11. package/dist/shared/assistant/guardedStorage.d.ts.map +1 -1
  12. package/dist/shared/assistant/guardedStorage.js +1 -1
  13. package/dist/shared/assistant/history/historyApi.d.ts +38 -0
  14. package/dist/shared/assistant/history/historyApi.d.ts.map +1 -0
  15. package/dist/shared/assistant/history/historyApi.js +153 -0
  16. package/dist/shared/assistant/history/historyEngine.d.ts +96 -0
  17. package/dist/shared/assistant/history/historyEngine.d.ts.map +1 -0
  18. package/dist/shared/assistant/history/historyEngine.js +774 -0
  19. package/dist/shared/assistant/history/historyErrors.d.ts +72 -0
  20. package/dist/shared/assistant/history/historyErrors.d.ts.map +1 -0
  21. package/dist/shared/assistant/history/historyErrors.js +74 -0
  22. package/dist/shared/assistant/history/historyList.d.ts +115 -0
  23. package/dist/shared/assistant/history/historyList.d.ts.map +1 -0
  24. package/dist/shared/assistant/history/historyList.js +116 -0
  25. package/dist/shared/assistant/history/historyMapping.d.ts +65 -0
  26. package/dist/shared/assistant/history/historyMapping.d.ts.map +1 -0
  27. package/dist/shared/assistant/history/historyMapping.js +383 -0
  28. package/dist/shared/assistant/history/historyMerge.d.ts +65 -0
  29. package/dist/shared/assistant/history/historyMerge.d.ts.map +1 -0
  30. package/dist/shared/assistant/history/historyMerge.js +97 -0
  31. package/dist/shared/assistant/history/historyOperations.d.ts +24 -0
  32. package/dist/shared/assistant/history/historyOperations.d.ts.map +1 -0
  33. package/dist/shared/assistant/history/historyOperations.js +125 -0
  34. package/dist/shared/assistant/history/historyResume.d.ts +56 -0
  35. package/dist/shared/assistant/history/historyResume.d.ts.map +1 -0
  36. package/dist/shared/assistant/history/historyResume.js +55 -0
  37. package/dist/shared/assistant/history/historyStatus.d.ts +76 -0
  38. package/dist/shared/assistant/history/historyStatus.d.ts.map +1 -0
  39. package/dist/shared/assistant/history/historyStatus.js +47 -0
  40. package/dist/shared/assistant/history/historyStore.d.ts +192 -0
  41. package/dist/shared/assistant/history/historyStore.d.ts.map +1 -0
  42. package/dist/shared/assistant/history/historyStore.js +503 -0
  43. package/dist/shared/assistant/history/historyTimestamps.d.ts +11 -0
  44. package/dist/shared/assistant/history/historyTimestamps.d.ts.map +1 -0
  45. package/dist/shared/assistant/history/historyTimestamps.js +9 -0
  46. package/dist/shared/assistant/history/historyTypes.d.ts +256 -0
  47. package/dist/shared/assistant/history/historyTypes.d.ts.map +1 -0
  48. package/dist/shared/assistant/history/historyTypes.js +20 -0
  49. package/dist/shared/assistant/history/profileBoundStorage.d.ts +36 -0
  50. package/dist/shared/assistant/history/profileBoundStorage.d.ts.map +1 -0
  51. package/dist/shared/assistant/history/profileBoundStorage.js +74 -0
  52. package/dist/shared/assistant/history/stampRegistry.d.ts +84 -0
  53. package/dist/shared/assistant/history/stampRegistry.d.ts.map +1 -0
  54. package/dist/shared/assistant/history/stampRegistry.js +58 -0
  55. package/dist/shared/assistant/history/useAssistantServerHistory.d.ts +18 -0
  56. package/dist/shared/assistant/history/useAssistantServerHistory.d.ts.map +1 -0
  57. package/dist/shared/assistant/history/useAssistantServerHistory.js +12 -0
  58. package/dist/shared/assistant/i18nManifest.d.ts +18 -0
  59. package/dist/shared/assistant/i18nManifest.d.ts.map +1 -1
  60. package/dist/shared/assistant/i18nManifest.js +18 -0
  61. package/dist/shared/assistant/index.d.ts +16 -0
  62. package/dist/shared/assistant/index.d.ts.map +1 -1
  63. package/dist/shared/assistant/liveTurns.d.ts +7 -0
  64. package/dist/shared/assistant/liveTurns.d.ts.map +1 -1
  65. package/dist/shared/assistant/liveTurns.js +35 -32
  66. package/dist/shared/assistant/spokenTurns.d.ts +20 -0
  67. package/dist/shared/assistant/spokenTurns.d.ts.map +1 -1
  68. package/dist/shared/assistant/spokenTurns.js +13 -8
  69. package/dist/shared/assistant/store.d.ts +35 -1
  70. package/dist/shared/assistant/store.d.ts.map +1 -1
  71. package/dist/shared/assistant/store.js +93 -24
  72. package/dist/shared/assistant/ui/AIAssistantPanel.d.ts +16 -0
  73. package/dist/shared/assistant/ui/AIAssistantPanel.d.ts.map +1 -1
  74. package/dist/shared/assistant/ui/AIAssistantPanel.js +63 -60
  75. package/dist/shared/assistant/ui/AssistantChatArea.d.ts.map +1 -1
  76. package/dist/shared/assistant/ui/AssistantChatArea.js +730 -672
  77. package/dist/shared/assistant/ui/AssistantConversationList.d.ts +17 -0
  78. package/dist/shared/assistant/ui/AssistantConversationList.d.ts.map +1 -1
  79. package/dist/shared/assistant/ui/AssistantConversationList.js +252 -145
  80. package/dist/shared/assistant/ui/AssistantHistoryNotices.d.ts +36 -0
  81. package/dist/shared/assistant/ui/AssistantHistoryNotices.d.ts.map +1 -0
  82. package/dist/shared/assistant/ui/AssistantHistoryNotices.js +103 -0
  83. package/dist/shared/assistant/ui/AssistantOverlay.d.ts +4 -0
  84. package/dist/shared/assistant/ui/AssistantOverlay.d.ts.map +1 -1
  85. package/dist/shared/assistant/ui/AssistantOverlay.js +97 -94
  86. package/dist/shared/assistant/ui/AssistantSpokenTurnsNotice.d.ts +5 -3
  87. package/dist/shared/assistant/ui/AssistantSpokenTurnsNotice.d.ts.map +1 -1
  88. package/dist/shared/assistant/ui/composer/AssistantComposer.d.ts +6 -0
  89. package/dist/shared/assistant/ui/composer/AssistantComposer.d.ts.map +1 -1
  90. package/dist/shared/assistant/ui/composer/AssistantComposer.js +54 -54
  91. package/dist/shared/assistant/ui/voice/VoiceTranscriptDrawer.d.ts +9 -0
  92. package/dist/shared/assistant/ui/voice/VoiceTranscriptDrawer.d.ts.map +1 -1
  93. package/dist/shared/assistant/ui/voice/VoiceTranscriptDrawer.js +37 -32
  94. package/dist/shared/assistant/voice/turnVisibility.d.ts +7 -5
  95. package/dist/shared/assistant/voice/turnVisibility.d.ts.map +1 -1
  96. package/dist/shared/assistant/voice/voiceTranscript.d.ts +3 -2
  97. package/dist/shared/assistant/voice/voiceTranscript.d.ts.map +1 -1
  98. package/dist/shared/config/index.d.ts +3 -1
  99. package/dist/shared/config/index.d.ts.map +1 -1
  100. package/dist/shared/config/productSlug.d.ts +36 -0
  101. package/dist/shared/config/productSlug.d.ts.map +1 -0
  102. package/dist/shared/config/productSlug.js +23 -0
  103. package/dist/shared/config/products.d.ts +8 -1
  104. package/dist/shared/config/products.d.ts.map +1 -1
  105. package/dist/shared/config/products.js +21 -14
  106. package/dist/shared/hooks/shell/useProducts.d.ts +8 -0
  107. package/dist/shared/hooks/shell/useProducts.d.ts.map +1 -1
  108. package/dist/shared/hooks/shell/useProducts.js +46 -42
  109. package/dist/shared/providers/AppShellProvider.d.ts.map +1 -1
  110. package/dist/shared/providers/AppShellProvider.js +228 -227
  111. package/dist/shared/providers/shell/ThemeProvider.d.ts +1 -1
  112. package/dist/shared/providers/shell/ThemeProvider.d.ts.map +1 -1
  113. package/dist/shared/providers/shell/ThemeProvider.js +58 -57
  114. package/dist/shared/providers/shell/brandAttribute.d.ts +11 -0
  115. package/dist/shared/providers/shell/brandAttribute.d.ts.map +1 -0
  116. package/dist/shared/providers/shell/brandAttribute.js +7 -0
  117. package/dist/shared-assistant.js +153 -137
  118. package/dist/shared-config.js +11 -10
  119. package/dist/shared.js +121 -120
  120. package/package.json +2 -2
  121. package/src/vite/types.ts +4 -1
@@ -0,0 +1,383 @@
1
+ import { isAssistantModeId as e } from "../modeIds.js";
2
+ import { MAX_REQUEST_BODY_BYTES as t } from "../gatewayLimits.js";
3
+ import { sanitize as n } from "../progress.js";
4
+ import { ASSISTANT_HISTORY_SAVE_MUTATION as r, ASSISTANT_HISTORY_SAVE_OPERATION as i, buildHistorySaveVariables as a } from "./historyOperations.js";
5
+ import { historyTimestampToIso as o } from "./historyTimestamps.js";
6
+ import "./historyTypes.js";
7
+ //#region src/shared/assistant/history/historyMapping.ts
8
+ var s = /^[A-Za-z0-9][A-Za-z0-9._:-]{7,127}$/, c = 131072, l = 98304, u = 16384, ee = 16384, d = 8, f = d - 2 - 1, p = 1024, te = 4096, m = 10, h = 20, g = 8, ne = 64, _ = /^[a-z][a-z0-9._-]{0,63}$/, v = new Set([
9
+ "kind",
10
+ "version",
11
+ "status",
12
+ "summary",
13
+ "data",
14
+ "at"
15
+ ]), y = [
16
+ "proposed",
17
+ "applied",
18
+ "failed",
19
+ "expired",
20
+ "cancelled"
21
+ ], re = /^pending[-_]?write$/i, b = "\n\n[…truncated in saved history]";
22
+ function x(e) {
23
+ return typeof e == "string" && s.test(e);
24
+ }
25
+ var ie = new TextEncoder();
26
+ function S(e) {
27
+ return ie.encode(e).length;
28
+ }
29
+ function C(e) {
30
+ return S(JSON.stringify(e));
31
+ }
32
+ function w(e) {
33
+ if (typeof e != "object" || !e || Array.isArray(e)) return !1;
34
+ let t = Object.getPrototypeOf(e);
35
+ return t === Object.prototype || t === null;
36
+ }
37
+ function T(e, t) {
38
+ if (e === null || typeof e == "string" || typeof e == "boolean") return 0;
39
+ if (typeof e == "number") return Number.isFinite(e) ? 0 : Infinity;
40
+ let n = Array.isArray(e) ? e : w(e) ? Object.values(e) : null;
41
+ if (n === null || t <= 0) return Infinity;
42
+ let r = 0;
43
+ for (let e of n) if (r = Math.max(r, T(e, t - 1)), r === Infinity) return Infinity;
44
+ return r + 1;
45
+ }
46
+ var E = /[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/, D = /[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g, O = "\0";
47
+ function k(e) {
48
+ return !e.includes(O) && !E.test(e);
49
+ }
50
+ function A(e) {
51
+ return k(e) ? e : e.replaceAll(O, "�").replace(D, "�");
52
+ }
53
+ function j(e) {
54
+ return typeof e == "string" ? k(e) : Array.isArray(e) ? e.every(j) : w(e) ? Object.entries(e).every(([e, t]) => k(e) && j(t)) : !0;
55
+ }
56
+ function M(e) {
57
+ if (Array.isArray(e)) return e.map(M);
58
+ if (!w(e)) return e;
59
+ let t = {};
60
+ for (let [n, r] of Object.entries(e)) re.test(n) || Object.defineProperty(t, n, {
61
+ value: M(r),
62
+ enumerable: !0,
63
+ writable: !0,
64
+ configurable: !0
65
+ });
66
+ return t;
67
+ }
68
+ var N = (e) => e === !0, P = (e) => (t) => typeof t == "string" && t.length <= e, F = (e) => (t) => w(t) && T(t, d) <= d && C(t) <= e, I = (e, t) => (n) => Array.isArray(n) && n.length <= e && n.every(F(t));
69
+ function L(e) {
70
+ return typeof e == "string" && e.length <= ne && k(e) && Number.isFinite(Date.parse(e));
71
+ }
72
+ function R(e) {
73
+ if (!w(e) || !Object.keys(e).every((e) => v.has(e))) return !1;
74
+ let { kind: t, version: n, status: r, summary: i, data: a, at: o } = e;
75
+ return typeof t == "string" && _.test(t) && typeof n == "number" && Number.isSafeInteger(n) && n >= 1 && (r === void 0 || P(16)(r)) && (i === void 0 || P(500)(i)) && (a === void 0 || F(te)(a)) && (o === void 0 || L(o));
76
+ }
77
+ var z = new Map([
78
+ ["voice", N],
79
+ ["voiceSessionId", P(64)],
80
+ ["lang", P(35)],
81
+ ["mode", P(64)],
82
+ ["sandboxId", P(128)],
83
+ ["sessionId", P(128)],
84
+ ["attachments", I(m, p)],
85
+ ["artifacts", I(h, p)],
86
+ ["localAction", F(p)],
87
+ ["continuedVoiceTurns", (e) => typeof e == "number" && Number.isSafeInteger(e) && e >= 0],
88
+ ["approvalFollowUp", N],
89
+ ["incomplete", N],
90
+ ["truncated", N],
91
+ ["records", (e) => Array.isArray(e) && e.length <= g && e.every(R)]
92
+ ]), ae = [...z.keys()];
93
+ function B(e) {
94
+ let t = {}, n = [];
95
+ if (!w(e)) return {
96
+ kept: t,
97
+ dropped: n
98
+ };
99
+ for (let [r, i] of Object.entries(e)) {
100
+ let e = z.get(r);
101
+ if (!e || !e(i) || !j(i)) {
102
+ n.push(r);
103
+ continue;
104
+ }
105
+ let a = M(i);
106
+ if (T(a, f) > f) {
107
+ n.push(r);
108
+ continue;
109
+ }
110
+ t[r] = a;
111
+ }
112
+ return {
113
+ kept: t,
114
+ dropped: n
115
+ };
116
+ }
117
+ var V = [
118
+ "artifacts",
119
+ "attachments",
120
+ "records",
121
+ "localAction"
122
+ ], H = (e) => {
123
+ let t = V.indexOf(e);
124
+ return t === -1 ? V.length : t;
125
+ };
126
+ function U(e, t, n) {
127
+ let r = n;
128
+ for (;;) {
129
+ if (C({ assistant: {
130
+ v: 1,
131
+ kind: e,
132
+ clientCreatedAt: t,
133
+ data: r
134
+ } }) <= 16384) return r;
135
+ let n = Object.entries(r).map(([e, t]) => [e, C({ [e]: t })]);
136
+ n.sort(([e, t], [n, r]) => r - t || H(e) - H(n) || (e < n ? -1 : Number(e > n)));
137
+ let i = n[0]?.[0];
138
+ if (i === void 0) return r;
139
+ r = Object.fromEntries(Object.entries(r).filter(([e]) => e !== i));
140
+ }
141
+ }
142
+ var W = {
143
+ user: "USER",
144
+ assistant: "ASSISTANT",
145
+ system: "NOTE"
146
+ };
147
+ function G(e) {
148
+ return {
149
+ id: e.id,
150
+ filename: e.filename,
151
+ mimeType: e.mimeType,
152
+ size: e.size,
153
+ kind: e.kind,
154
+ ...e.fileId ? { fileId: e.fileId } : {}
155
+ };
156
+ }
157
+ function K(e) {
158
+ return {
159
+ name: e.name,
160
+ path: e.path,
161
+ type: e.type,
162
+ size: e.size,
163
+ ...e.downloadPath ? { downloadPath: e.downloadPath } : {}
164
+ };
165
+ }
166
+ function q(e) {
167
+ if (!e) return {};
168
+ let t = {};
169
+ e.voice === !0 && (t.voice = !0), e.voice === !0 && typeof e.voiceSessionId == "string" && (t.voiceSessionId = e.voiceSessionId);
170
+ for (let n of [
171
+ "lang",
172
+ "mode",
173
+ "sandboxId",
174
+ "sessionId"
175
+ ]) {
176
+ let r = e[n];
177
+ typeof r == "string" && r.length > 0 && (t[n] = r);
178
+ }
179
+ let n = F(p);
180
+ if (Array.isArray(e.attachments)) {
181
+ let r = e.attachments.map(G).filter(n).slice(0, m);
182
+ r.length > 0 && (t.attachments = r);
183
+ }
184
+ if (Array.isArray(e.artifacts)) {
185
+ let r = e.artifacts.map(K).filter(n).slice(0, h);
186
+ r.length > 0 && (t.artifacts = r);
187
+ }
188
+ if (e.localAction && (t.localAction = { ...e.localAction }), typeof e.continuedVoiceTurns == "number" && (t.continuedVoiceTurns = e.continuedVoiceTurns), e.approvalFollowUp === !0 && (t.approvalFollowUp = !0), e.incomplete === !0 && (t.incomplete = !0), e.truncated === !0 && (t.truncated = !0), Array.isArray(e.records)) {
189
+ let n = e.records.filter(R).slice(0, g);
190
+ n.length > 0 && (t.records = n);
191
+ }
192
+ return t;
193
+ }
194
+ function oe(e) {
195
+ let t = e.codePointAt(0) ?? 0;
196
+ return e === "\"" || e === "\\" ? 2 : t < 32 ? "\b\f\n\r ".includes(e) ? 2 : 6 : t < 128 ? 1 : t < 2048 ? 2 : t < 65536 ? 3 : 4;
197
+ }
198
+ function se(e, t) {
199
+ let n = 0, r = 0;
200
+ for (let i of e) {
201
+ let e = oe(i);
202
+ if (n + e > t) break;
203
+ n += e, r += i.length;
204
+ }
205
+ return e.slice(0, r);
206
+ }
207
+ function J(e, t) {
208
+ if (S(e) <= t) return e;
209
+ let n = 0, r = 0;
210
+ for (let i of e) {
211
+ let e = S(i);
212
+ if (n + e > t) break;
213
+ n += e, r += i.length;
214
+ }
215
+ return e.slice(0, r);
216
+ }
217
+ var Y = (e) => C(e) - 2;
218
+ function X(e, t, n) {
219
+ if (!n) return {
220
+ ...e,
221
+ input: {
222
+ ...e.input,
223
+ content: t
224
+ }
225
+ };
226
+ let r = {
227
+ ...e.input.metadata ?? {},
228
+ truncated: !0
229
+ };
230
+ return {
231
+ ...e,
232
+ input: {
233
+ ...e.input,
234
+ content: t,
235
+ metadata: r
236
+ }
237
+ };
238
+ }
239
+ function Z(e, t) {
240
+ return C({
241
+ operationName: i,
242
+ query: r,
243
+ variables: a({
244
+ product: e.productId,
245
+ actorId: "",
246
+ workspaceId: ""
247
+ }, {
248
+ clientConversationId: e.clientConversationId,
249
+ kind: e.kind,
250
+ entries: t
251
+ })
252
+ });
253
+ }
254
+ var Q = t - u;
255
+ function $(e, t) {
256
+ let r = e.map((e) => {
257
+ let r = A(n(e.content)), i = L(e.timestamp) ? e.timestamp : null, a = U(t.kind, i, B(q(e.metadata)).kept), o = {
258
+ input: {
259
+ clientMessageId: e.id,
260
+ role: W[e.role],
261
+ content: r,
262
+ ...i ? { clientCreatedAt: i } : {},
263
+ ...Object.keys(a).length > 0 ? { metadata: a } : {}
264
+ },
265
+ source: r
266
+ };
267
+ return S(r) <= 98304 ? o : X(o, J(r, l - S(b)) + b, !0);
268
+ }), i = Y(b);
269
+ for (let e = 0; e < 3; e += 1) {
270
+ let e = Z(t, r.map((e) => e.input)) - Q;
271
+ if (e <= 0) break;
272
+ let n = -1, a = -1;
273
+ r.forEach((e, t) => {
274
+ let r = Y(e.input.content);
275
+ r > a && (n = t, a = r);
276
+ });
277
+ let o = r[n];
278
+ if (!o) break;
279
+ let s = Math.max(0, a - e - i - 64), c = se(o.source, s) + b;
280
+ r = r.map((e, t) => t === n ? X(e, c, !0) : e);
281
+ }
282
+ return r.map((e) => e.input);
283
+ }
284
+ function ce(e, t) {
285
+ let n = e === "NOTE" ? ["NOTE"] : ["USER", "ASSISTANT"];
286
+ return t.length === n.length ? new Set(t.map((e) => e.clientMessageId)).size === t.length && t.every((e, t) => e.role === n[t] && x(e.clientMessageId)) : !1;
287
+ }
288
+ var le = {
289
+ USER: "user",
290
+ ASSISTANT: "assistant",
291
+ NOTE: "system"
292
+ }, ue = [
293
+ "image",
294
+ "text",
295
+ "document"
296
+ ];
297
+ function de(e) {
298
+ if (!w(e)) return null;
299
+ let { id: t, filename: n, mimeType: r, size: i, kind: a, fileId: o } = e, s = ue.find((e) => e === a);
300
+ return typeof t != "string" || typeof n != "string" || typeof r != "string" || typeof i != "number" || !s ? null : {
301
+ id: t,
302
+ filename: n,
303
+ mimeType: r,
304
+ size: i,
305
+ kind: s,
306
+ ...typeof o == "string" ? { fileId: o } : {}
307
+ };
308
+ }
309
+ function fe(e) {
310
+ if (!w(e)) return null;
311
+ let { name: t, path: n, type: r, size: i, downloadPath: a } = e;
312
+ return typeof t != "string" || typeof n != "string" || r !== "file" && r !== "directory" || typeof i != "number" ? null : {
313
+ name: t,
314
+ path: n,
315
+ type: r,
316
+ size: i,
317
+ ...typeof a == "string" ? { downloadPath: a } : {}
318
+ };
319
+ }
320
+ function pe(e) {
321
+ if (!w(e)) return null;
322
+ if (e.kind === "theme" && typeof e.mode == "string" && typeof e.alreadyApplied == "boolean") return {
323
+ kind: "theme",
324
+ mode: e.mode,
325
+ alreadyApplied: e.alreadyApplied
326
+ };
327
+ if (e.kind === "navigate" && typeof e.destinationId == "string" && typeof e.path == "string" && typeof e.alreadyHere == "boolean") return {
328
+ kind: "navigate",
329
+ destinationId: e.destinationId,
330
+ path: e.path,
331
+ alreadyHere: e.alreadyHere
332
+ };
333
+ let { candidateIds: t } = e;
334
+ return e.kind === "choose-destination" && Array.isArray(t) && t.every((e) => typeof e == "string") ? {
335
+ kind: "choose-destination",
336
+ candidateIds: [...t]
337
+ } : null;
338
+ }
339
+ function me(e) {
340
+ if (!R(e) || !w(e)) return null;
341
+ let { kind: t, version: n, status: r, summary: i, data: a, at: o } = e;
342
+ if (typeof t != "string" || typeof n != "number") return null;
343
+ let s = y.find((e) => e === r), c = s === "proposed" ? "expired" : s;
344
+ return {
345
+ kind: t,
346
+ version: n,
347
+ ...c ? { status: c } : {},
348
+ ...typeof i == "string" ? { summary: i } : {},
349
+ ...w(a) ? { data: a } : {},
350
+ ...typeof o == "string" ? { at: o } : {}
351
+ };
352
+ }
353
+ function he(t) {
354
+ let { kept: n } = B(t), r = {};
355
+ if (n.voice === !0 && (r.voice = !0, typeof n.voiceSessionId == "string" && n.voiceSessionId.length > 0 && (r.voiceSessionId = n.voiceSessionId)), typeof n.lang == "string" && n.lang.length > 0 && (r.lang = n.lang), e(n.mode) && (r.mode = n.mode), typeof n.sandboxId == "string" && (r.sandboxId = n.sandboxId), typeof n.sessionId == "string" && (r.sessionId = n.sessionId), Array.isArray(n.attachments)) {
356
+ let e = n.attachments.map(de).filter((e) => e !== null);
357
+ e.length > 0 && (r.attachments = e);
358
+ }
359
+ if (Array.isArray(n.artifacts)) {
360
+ let e = n.artifacts.map(fe).filter((e) => e !== null);
361
+ e.length > 0 && (r.artifacts = e);
362
+ }
363
+ let i = pe(n.localAction);
364
+ if (i && (r.localAction = i), typeof n.continuedVoiceTurns == "number" && (r.continuedVoiceTurns = n.continuedVoiceTurns), n.approvalFollowUp === !0 && (r.approvalFollowUp = !0), n.incomplete === !0 && (r.incomplete = !0), n.truncated === !0 && (r.truncated = !0), Array.isArray(n.records)) {
365
+ let e = n.records.map(me).filter((e) => e !== null);
366
+ e.length > 0 && (r.records = e);
367
+ }
368
+ return r;
369
+ }
370
+ function ge(e) {
371
+ let t = he(e.metadata);
372
+ return {
373
+ id: e.clientMessageId ?? `legacy:${e.id}`,
374
+ role: le[e.role],
375
+ content: n(e.content),
376
+ timestamp: o(e.clientCreatedAt) ?? o(e.createdAt) ?? e.createdAt,
377
+ ...Object.keys(t).length > 0 ? { metadata: t } : {},
378
+ historyState: "saved",
379
+ ...typeof e.seq == "number" ? { historySeq: e.seq } : {}
380
+ };
381
+ }
382
+ //#endregion
383
+ export { s as HISTORY_CLIENT_ID_PATTERN, l as HISTORY_ENTRY_CONTENT_CAP_BYTES, c as HISTORY_MAX_CONTENT_BYTES, ee as HISTORY_METADATA_ENVELOPE_MAX_BYTES, ae as HISTORY_METADATA_KEYS, u as HISTORY_REQUEST_HEADROOM_BYTES, Q as HISTORY_SAVE_REQUEST_BUDGET_BYTES, b as HISTORY_TRUNCATION_MARKER, B as filterHistoryMetadata, U as fitHistoryMetadataEnvelope, ge as fromHistoryEntry, ce as historyEntriesMatchKind, x as isHistoryClientId, Z as measureHistorySaveRequest, $ as toHistoryEntries, A as toStorableHistoryText, J as truncateUtf8, S as utf8ByteLength };
@@ -0,0 +1,65 @@
1
+ import { ConversationSyncStamp, Message } from '../conversation';
2
+ import { AssistantHistoryEntryPage, AssistantHistoryEntryPaging } from './historyTypes';
3
+ /** Messages per backward page (the newest, or the next older window). */
4
+ export declare const HISTORY_LOAD_PAGE = 50;
5
+ /** Messages per forward (catch-up) page — the server's maximum. */
6
+ export declare const HISTORY_CATCH_UP_PAGE = 100;
7
+ /**
8
+ * Past this many unseen messages, catching up forward is not worth it: the
9
+ * newest window is loaded instead, and the gap is reached through "Show
10
+ * earlier messages", like any older history.
11
+ */
12
+ export declare const HISTORY_CATCH_UP_MAX_GAP = 300;
13
+ /**
14
+ * The conversation's messages after a load: every message with a server
15
+ * position in `seq` order — the local object wherever this device has one —
16
+ * and every local message without one put back: after its nearest preceding
17
+ * local neighbour (or first, when it had none), or, when no positioned
18
+ * message follows it here, at the end.
19
+ */
20
+ export declare function mergeHistoryMessages(local: readonly Message[], loaded: readonly Message[]): Message[];
21
+ /** The highest `seq` reached from `from` without a gap in `messages` (`from` itself when the next is missing). */
22
+ export declare function highestContiguousHistorySeq(messages: readonly Message[], from: number): number;
23
+ /** What to fetch for a conversation, and why. */
24
+ export type HistoryLoadPlan =
25
+ /** The newest window (nothing held yet, or too far behind to catch up). */
26
+ {
27
+ kind: "latest";
28
+ paging: AssistantHistoryEntryPaging;
29
+ }
30
+ /** Everything after the last contiguous message held. */
31
+ | {
32
+ kind: "catch-up";
33
+ paging: AssistantHistoryEntryPaging;
34
+ }
35
+ /** The window before the oldest held ("Show earlier messages"). */
36
+ | {
37
+ kind: "earlier";
38
+ paging: AssistantHistoryEntryPaging;
39
+ };
40
+ /**
41
+ * The load a conversation needs when it is opened, or null when it holds
42
+ * everything the server is known to have.
43
+ *
44
+ * `serverLastSeq` is the header's `lastMessageSeq` (what the feed last said
45
+ * the server holds), or null when no header is known — a conversation created
46
+ * here that the server has not acknowledged yet needs no load.
47
+ */
48
+ export declare function planHistoryOpenLoad(sync: ConversationSyncStamp, serverLastSeq: number | null): HistoryLoadPlan | null;
49
+ /** "Show earlier messages", or null when nothing older is known. */
50
+ export declare function planHistoryEarlierLoad(sync: ConversationSyncStamp): HistoryLoadPlan | null;
51
+ /**
52
+ * Apply one fetched page: the merged messages and the stamp fields that change
53
+ * with them.
54
+ *
55
+ * - `lastSeq` only ever grows. The newest window moves it to the window's end
56
+ * (the gap below is older history, reached through `olderCursor`); a
57
+ * catch-up or an earlier window moves it only as far as it is contiguous.
58
+ * - `hasOlder`/`olderCursor` follow a BACKWARD page only; a catch-up page says
59
+ * nothing about what lies before the window.
60
+ */
61
+ export declare function applyHistoryPage(sync: ConversationSyncStamp, local: readonly Message[], loaded: readonly Message[], page: Pick<AssistantHistoryEntryPage, "conversation" | "pageInfo">, plan: HistoryLoadPlan): {
62
+ messages: Message[];
63
+ syncPatch: Partial<ConversationSyncStamp>;
64
+ };
65
+ //# sourceMappingURL=historyMerge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"historyMerge.d.ts","sourceRoot":"","sources":["../../../../src/shared/assistant/history/historyMerge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,qBAAqB,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AACtE,OAAO,KAAK,EACV,yBAAyB,EACzB,2BAA2B,EAC5B,MAAM,gBAAgB,CAAC;AAExB,yEAAyE;AACzE,eAAO,MAAM,iBAAiB,KAAK,CAAC;AACpC,mEAAmE;AACnE,eAAO,MAAM,qBAAqB,MAAM,CAAC;AACzC;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,MAAM,CAAC;AAM5C;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,SAAS,OAAO,EAAE,EACzB,MAAM,EAAE,SAAS,OAAO,EAAE,GACzB,OAAO,EAAE,CAiDX;AAED,kHAAkH;AAClH,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,SAAS,OAAO,EAAE,EAC5B,IAAI,EAAE,MAAM,GACX,MAAM,CAOR;AAED,iDAAiD;AACjD,MAAM,MAAM,eAAe;AACzB,2EAA2E;AACzE;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,2BAA2B,CAAA;CAAE;AACzD,yDAAyD;GACvD;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,MAAM,EAAE,2BAA2B,CAAA;CAAE;AAC3D,mEAAmE;GACjE;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,MAAM,EAAE,2BAA2B,CAAA;CAAE,CAAC;AAE7D;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,qBAAqB,EAC3B,aAAa,EAAE,MAAM,GAAG,IAAI,GAC3B,eAAe,GAAG,IAAI,CAcxB;AAED,oEAAoE;AACpE,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,qBAAqB,GAC1B,eAAe,GAAG,IAAI,CAMxB;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,qBAAqB,EAC3B,KAAK,EAAE,SAAS,OAAO,EAAE,EACzB,MAAM,EAAE,SAAS,OAAO,EAAE,EAC1B,IAAI,EAAE,IAAI,CAAC,yBAAyB,EAAE,cAAc,GAAG,UAAU,CAAC,EAClE,IAAI,EAAE,eAAe,GACpB;IAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;IAAC,SAAS,EAAE,OAAO,CAAC,qBAAqB,CAAC,CAAA;CAAE,CAyBpE"}
@@ -0,0 +1,97 @@
1
+ //#region src/shared/assistant/history/historyMerge.ts
2
+ var e = 50, t = 100, n = 300;
3
+ function r(e) {
4
+ return typeof e.historySeq == "number" ? e.historySeq : null;
5
+ }
6
+ function i(e, t) {
7
+ let n = new Map(t.map((e) => [e.id, e])), i = /* @__PURE__ */ new Map();
8
+ for (let t of e) {
9
+ let e = n.get(t.id);
10
+ if (e) {
11
+ let n = r(e);
12
+ i.set(t.id, {
13
+ ...t,
14
+ historyState: "saved",
15
+ ...n === null ? {} : { historySeq: n }
16
+ });
17
+ } else r(t) !== null && i.set(t.id, t);
18
+ }
19
+ t.forEach((e) => {
20
+ i.has(e.id) || i.set(e.id, e);
21
+ });
22
+ let a = new Map([...i.keys()].map((e, t) => [e, t])), o = [...i.values()].sort((e, t) => {
23
+ let n = r(e) ?? Infinity, i = r(t) ?? Infinity;
24
+ return n === i ? (a.get(e.id) ?? 0) - (a.get(t.id) ?? 0) : n < i ? -1 : 1;
25
+ }), s = -1;
26
+ e.forEach((e, t) => {
27
+ i.has(e.id) && (s = t);
28
+ });
29
+ let c = [], l = -1;
30
+ return e.forEach((e, t) => {
31
+ if (i.has(e.id)) {
32
+ l = o.findIndex((t) => t.id === e.id);
33
+ return;
34
+ }
35
+ if (t > s) {
36
+ c.push(e);
37
+ return;
38
+ }
39
+ o.splice(l + 1, 0, e), l += 1;
40
+ }), [...o, ...c];
41
+ }
42
+ function a(e, t) {
43
+ let n = new Set(e.map(r).filter((e) => e !== null)), i = t;
44
+ for (; n.has(i + 1);) i += 1;
45
+ return i;
46
+ }
47
+ function o(e, t) {
48
+ let n = e.lastSeq ?? 0;
49
+ return t === null ? e.origin === "created" ? null : n === 0 ? {
50
+ kind: "latest",
51
+ paging: { last: 50 }
52
+ } : {
53
+ kind: "catch-up",
54
+ paging: {
55
+ first: 100,
56
+ sinceSeq: n
57
+ }
58
+ } : t <= n ? null : n === 0 || t - n > 300 ? {
59
+ kind: "latest",
60
+ paging: { last: 50 }
61
+ } : {
62
+ kind: "catch-up",
63
+ paging: {
64
+ first: 100,
65
+ sinceSeq: n
66
+ }
67
+ };
68
+ }
69
+ function s(e) {
70
+ return !e.hasOlder || !e.olderCursor ? null : {
71
+ kind: "earlier",
72
+ paging: {
73
+ last: 50,
74
+ before: e.olderCursor
75
+ }
76
+ };
77
+ }
78
+ function c(e, t, n, o, s) {
79
+ let c = i(t, n), l = e.lastSeq ?? 0, u = n.map(r).filter((e) => e !== null), d = u.length > 0 ? Math.max(...u) : l, f = s.kind === "latest" ? Math.max(a(c, l), d) : a(c, l), p = s.kind !== "catch-up", m = p && o.pageInfo.hasPreviousPage && o.pageInfo.startCursor ? {
80
+ hasOlder: !0,
81
+ olderCursor: o.pageInfo.startCursor
82
+ } : {
83
+ hasOlder: void 0,
84
+ olderCursor: void 0
85
+ };
86
+ return {
87
+ messages: c,
88
+ syncPatch: {
89
+ serverId: o.conversation.id,
90
+ revision: Math.max(e.revision ?? 0, o.conversation.revision),
91
+ lastSeq: f,
92
+ ...p ? m : {}
93
+ }
94
+ };
95
+ }
96
+ //#endregion
97
+ export { n as HISTORY_CATCH_UP_MAX_GAP, t as HISTORY_CATCH_UP_PAGE, e as HISTORY_LOAD_PAGE, c as applyHistoryPage, a as highestContiguousHistorySeq, i as mergeHistoryMessages, s as planHistoryEarlierLoad, o as planHistoryOpenLoad };
@@ -0,0 +1,24 @@
1
+ import { AssistantHistoryConvRef, AssistantHistoryEntryPaging, AssistantHistorySaveInput, AssistantHistoryScope } from './historyTypes';
2
+ export declare const ASSISTANT_HISTORY_CHANGES_OPERATION = "AssistantHistoryChanges";
3
+ export declare const ASSISTANT_HISTORY_CHANGES_QUERY = "\n query AssistantHistoryChanges($productId: String!, $first: Int, $after: String) {\n myAssistantHistoryChanges(productId: $productId, first: $first, after: $after) {\n nodes {\n id\n clientConversationId\n productId\n title\n legacy\n revision\n lastMessageSeq\n deleted\n deletedAt\n createdAt\n updatedAt\n}\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n}\n resetRequired\n }\n }\n";
4
+ export declare const ASSISTANT_HISTORY_CONVERSATIONS_OPERATION = "AssistantHistoryConversations";
5
+ export declare const ASSISTANT_HISTORY_CONVERSATIONS_QUERY = "\n query AssistantHistoryConversations($productId: String!, $first: Int, $after: String) {\n myAssistantConversations(productId: $productId, first: $first, after: $after) {\n nodes {\n id\n clientConversationId\n productId\n title\n legacy\n revision\n lastMessageSeq\n deleted\n deletedAt\n createdAt\n updatedAt\n}\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n}\n }\n }\n";
6
+ export declare const ASSISTANT_HISTORY_ENTRIES_OPERATION = "AssistantHistoryEntries";
7
+ export declare const ASSISTANT_HISTORY_ENTRIES_QUERY = "\n query AssistantHistoryEntries(\n $productId: String!\n $clientConversationId: ID\n $conversationId: ID\n $first: Int\n $after: String\n $sinceSeq: Int\n $last: Int\n $before: String\n ) {\n myAssistantConversationEntries(\n productId: $productId\n clientConversationId: $clientConversationId\n conversationId: $conversationId\n first: $first\n after: $after\n sinceSeq: $sinceSeq\n last: $last\n before: $before\n ) {\n conversation {\n id\n clientConversationId\n productId\n title\n legacy\n revision\n lastMessageSeq\n deleted\n deletedAt\n createdAt\n updatedAt\n}\n nodes {\n id\n clientMessageId\n kind\n role\n content\n seq\n createdAt\n clientCreatedAt\n metadata\n}\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n}\n }\n }\n";
8
+ export declare const ASSISTANT_HISTORY_SAVE_OPERATION = "SaveAssistantHistoryEntries";
9
+ export declare const ASSISTANT_HISTORY_SAVE_MUTATION = "\n mutation SaveAssistantHistoryEntries($input: SaveMyAssistantHistoryEntriesInput!) {\n saveMyAssistantHistoryEntries(input: $input) {\n outcome\n conversation {\n id\n clientConversationId\n productId\n title\n legacy\n revision\n lastMessageSeq\n deleted\n deletedAt\n createdAt\n updatedAt\n}\n entries {\n id\n clientMessageId\n kind\n role\n content\n seq\n createdAt\n clientCreatedAt\n metadata\n}\n droppedMetadataKeys\n }\n }\n";
10
+ export declare const ASSISTANT_HISTORY_DELETE_OPERATION = "DeleteAssistantHistoryConversation";
11
+ export declare const ASSISTANT_HISTORY_DELETE_MUTATION = "\n mutation DeleteAssistantHistoryConversation(\n $productId: String!\n $clientConversationId: ID\n $conversationId: ID\n ) {\n deleteMyAssistantConversation(\n productId: $productId\n clientConversationId: $clientConversationId\n conversationId: $conversationId\n ) {\n outcome\n conversation {\n id\n clientConversationId\n productId\n title\n legacy\n revision\n lastMessageSeq\n deleted\n deletedAt\n createdAt\n updatedAt\n}\n }\n }\n";
12
+ /** Every operation, for the contract test and for anything that audits what the client sends. */
13
+ export declare const ASSISTANT_HISTORY_OPERATIONS: ReadonlyArray<{
14
+ operationName: string;
15
+ document: string;
16
+ }>;
17
+ export declare function buildHistoryPageVariables(scope: AssistantHistoryScope, page: {
18
+ first: number;
19
+ after: string | null;
20
+ }): Record<string, unknown>;
21
+ export declare function buildHistoryEntriesVariables(scope: AssistantHistoryScope, ref: AssistantHistoryConvRef, page: AssistantHistoryEntryPaging): Record<string, unknown>;
22
+ export declare function buildHistorySaveVariables(scope: AssistantHistoryScope, input: AssistantHistorySaveInput): Record<string, unknown>;
23
+ export declare function buildHistoryDeleteVariables(scope: AssistantHistoryScope, ref: AssistantHistoryConvRef): Record<string, unknown>;
24
+ //# sourceMappingURL=historyOperations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"historyOperations.d.ts","sourceRoot":"","sources":["../../../../src/shared/assistant/history/historyOperations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EACV,uBAAuB,EACvB,2BAA2B,EAC3B,yBAAyB,EACzB,qBAAqB,EACtB,MAAM,gBAAgB,CAAC;AAmCxB,eAAO,MAAM,mCAAmC,4BAA4B,CAAC;AAC7E,eAAO,MAAM,+BAA+B,scAQ3C,CAAC;AAEF,eAAO,MAAM,yCAAyC,kCACrB,CAAC;AAClC,eAAO,MAAM,qCAAqC,sbAOjD,CAAC;AAEF,eAAO,MAAM,mCAAmC,4BAA4B,CAAC;AAC7E,eAAO,MAAM,+BAA+B,k3BA0B3C,CAAC;AAEF,eAAO,MAAM,gCAAgC,gCAAgC,CAAC;AAC9E,eAAO,MAAM,+BAA+B,0eAS3C,CAAC;AAEF,eAAO,MAAM,kCAAkC,uCAAuC,CAAC;AACvF,eAAO,MAAM,iCAAiC,qfAe7C,CAAC;AAEF,iGAAiG;AACjG,eAAO,MAAM,4BAA4B,EAAE,aAAa,CAAC;IACvD,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAqBA,CAAC;AAIF,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,qBAAqB,EAC5B,IAAI,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GAC5C,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEzB;AAED,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,qBAAqB,EAC5B,GAAG,EAAE,uBAAuB,EAC5B,IAAI,EAAE,2BAA2B,GAChC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAQzB;AAED,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,qBAAqB,EAC5B,KAAK,EAAE,yBAAyB,GAC/B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAiBzB;AAED,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,qBAAqB,EAC5B,GAAG,EAAE,uBAAuB,GAC3B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEzB"}