@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
@@ -0,0 +1,175 @@
1
+ import { FilesPort } from '../../storage/filesPort';
2
+ import { AssistantAttachment } from './attachments';
3
+ /** files-svc switches to MULTIPART above this size; the browser cannot upload those. */
4
+ export declare const ATTACHMENT_DIRECT_UPLOAD_MAX_BYTES: number;
5
+ /**
6
+ * The commit path's OWN bounded retry policy. It is deliberately not the cold-start ladder
7
+ * `uploadBlobToFiles` walks (10 s then 20 s, up to 75 s): a person is waiting on Send, and
8
+ * Cancel is always there. The Files service is warmed when the panel opens.
9
+ */
10
+ export declare const ATTACHMENT_COMMIT_POLICY: {
11
+ /** Files uploaded at once. */
12
+ readonly concurrency: 2;
13
+ /** ensureFolderByPath / initiateUpload / reads: at most this many attempts. */
14
+ readonly gatewayAttempts: 2;
15
+ readonly gatewayRetryDelayMs: 1500;
16
+ /** The PUT: network error or 5xx is retried this many times. */
17
+ readonly putRetries: 1;
18
+ readonly putRetryDelayMs: 1000;
19
+ /** `getUploadSession` attempts before falling back to `getMyUploadSessions`. */
20
+ readonly lookupAttempts: 2;
21
+ readonly lookupRetryDelayMs: 500;
22
+ /** After a reconcile finds the session still IN_PROGRESS. */
23
+ readonly completeReissues: 1;
24
+ /** How long a stopped commit still waits for an in-flight completeUpload to answer. */
25
+ readonly settleGraceMs: 3000;
26
+ /** Attempts at each rollback step. */
27
+ readonly discardAttempts: 2;
28
+ /**
29
+ * `discardPending()` (panel closed, draft cleared) looks again at what is still undecided, this
30
+ * many times, `finalDrainDelayMs * round` apart: after the committer is gone nothing else will,
31
+ * and a completeUpload that timed out can still land a few seconds later.
32
+ */
33
+ readonly finalDrainRounds: 3;
34
+ readonly finalDrainDelayMs: 5000;
35
+ };
36
+ export type AttachmentCommitPolicy = {
37
+ -readonly [K in keyof typeof ATTACHMENT_COMMIT_POLICY]: number;
38
+ };
39
+ /** Codes for failures the commit decides itself; a server failure keeps the server's own code. */
40
+ export declare const ATTACHMENT_COMMIT_CODES: {
41
+ readonly quotaNotProvisioned: "QUOTA_NOT_PROVISIONED";
42
+ readonly quotaExceeded: "QUOTA_EXCEEDED";
43
+ readonly tooLarge: "ATTACHMENT_TOO_LARGE_FOR_DIRECT_UPLOAD";
44
+ readonly noBytes: "ATTACHMENT_NO_BYTES";
45
+ readonly noDownloadUrl: "ATTACHMENT_NO_DOWNLOAD_URL";
46
+ readonly timeout: "ATTACHMENT_SAVE_TIMEOUT";
47
+ readonly uploadFailed: "ATTACHMENT_UPLOAD_FAILED";
48
+ readonly folderFailed: "ATTACHMENT_FOLDER_FAILED";
49
+ };
50
+ /** One draft attachment and the bytes held for it in memory. */
51
+ export interface CommitDraft {
52
+ attachment: AssistantAttachment;
53
+ /** Null when the bytes are gone (the failure is reported on the chip, nothing is sent). */
54
+ blob: Blob | null;
55
+ }
56
+ export interface AttachmentCommitFailure {
57
+ /** The attachment's id. */
58
+ id: string;
59
+ message: string;
60
+ code: string | undefined;
61
+ }
62
+ /** What a failed rollback leaves for the next commit (or `discardPending`) to retry. */
63
+ export type PendingDiscard =
64
+ /** A file this commit created and could not delete. */
65
+ {
66
+ kind: 'file';
67
+ fileId: string;
68
+ }
69
+ /** A session whose `completeUpload` was issued and whose outcome is unknown: reconcile, delete if FINALIZED. */
70
+ | {
71
+ kind: 'session';
72
+ sessionId: string;
73
+ };
74
+ export interface PendingDiscardStore {
75
+ entries: PendingDiscard[];
76
+ /**
77
+ * The drain that is running now. A drain takes the entries out of `entries` while it works and
78
+ * puts back what it could not settle, so a second drain (or the final one after an unmount)
79
+ * must wait for it instead of reading an empty list.
80
+ */
81
+ draining?: Promise<void>;
82
+ }
83
+ export type CommitMode =
84
+ /** Any failure undoes everything and sends nothing (composer). */
85
+ 'all-or-nothing'
86
+ /** A failed file is dropped and the rest is kept (voice: the spoken question is still asked). */
87
+ | 'best-effort';
88
+ export type AttachmentCommitSuccess = {
89
+ ok: true;
90
+ /** The input attachments in order: committed ones carry fileId/downloadUrl; skipped ones are untouched. */
91
+ attachments: AssistantAttachment[];
92
+ /** Best-effort only: attachments that could not be saved and are NOT in `attachments`. */
93
+ dropped: AttachmentCommitFailure[];
94
+ /** Call once the files are referenced by a sent message; rollback is a no-op from then on. */
95
+ handedOver: () => void;
96
+ /** Hard-delete what this commit created (the turn could not be sent after all). */
97
+ rollback: () => Promise<void>;
98
+ };
99
+ export type AttachmentCommitFailureResult = {
100
+ ok: false;
101
+ cancelled: boolean;
102
+ /** Per-attachment reasons (empty for a plain cancel). */
103
+ failures: AttachmentCommitFailure[];
104
+ /** The first failure's message, ready for a live region. */
105
+ message: string | undefined;
106
+ };
107
+ export type AttachmentCommitResult = AttachmentCommitSuccess | AttachmentCommitFailureResult;
108
+ export interface CommitOptions {
109
+ port: FilesPort;
110
+ /** The product's attachments folder, e.g. `/BigConsole/AI Assistant/Attachments`. */
111
+ folderPath: string;
112
+ drafts: readonly CommitDraft[];
113
+ signal?: AbortSignal;
114
+ mode?: CommitMode;
115
+ /** Total time allowed; when it runs out unfinished files are dropped (or fail the commit). */
116
+ budgetMs?: number;
117
+ /** Chip updates: `uploading` + progress while running, `ready` (+ `saveError`) at the end. */
118
+ onChange?: (id: string, patch: Partial<AssistantAttachment>) => void;
119
+ /** Where failed rollbacks are remembered. Defaults to a fresh store. */
120
+ pendingDiscard?: PendingDiscardStore;
121
+ policy?: Partial<AttachmentCommitPolicy>;
122
+ /** Test seams. `sleep` resolves early when its signal aborts. */
123
+ now?: () => number;
124
+ sleep?: (ms: number, signal?: AbortSignal) => Promise<void>;
125
+ }
126
+ /** Retry earlier failed rollbacks. A session with a FINALIZED outcome becomes a file delete. */
127
+ export declare function drainPendingDiscards(port: FilesPort, store: PendingDiscardStore, options?: Pick<CommitOptions, 'sleep'> & {
128
+ policy?: Partial<AttachmentCommitPolicy>;
129
+ }): Promise<void>;
130
+ export declare function commitAttachments(options: CommitOptions): Promise<AttachmentCommitResult>;
131
+ export interface AttachmentCommitterConfig {
132
+ port: FilesPort;
133
+ folderPath: string;
134
+ onChange?: CommitOptions['onChange'];
135
+ policy?: CommitOptions['policy'];
136
+ now?: CommitOptions['now'];
137
+ sleep?: CommitOptions['sleep'];
138
+ }
139
+ export interface AttachmentCommitter {
140
+ /**
141
+ * Single flight: while a commit is running, another call returns the SAME promise, so
142
+ * Enter held down or a double click yields one set of Files calls.
143
+ */
144
+ commit: (drafts: readonly CommitDraft[], options?: {
145
+ mode?: CommitMode;
146
+ budgetMs?: number;
147
+ signal?: AbortSignal;
148
+ }) => Promise<AttachmentCommitResult>;
149
+ /** Abort the running commit (it rolls back and resolves `{ ok: false, cancelled: true }`). */
150
+ cancel: () => void;
151
+ readonly isCommitting: boolean;
152
+ /** Retry rollbacks that failed earlier (draft cleared, panel closed). */
153
+ discardPending: () => Promise<void>;
154
+ readonly pendingDiscard: readonly PendingDiscard[];
155
+ }
156
+ export declare function createAttachmentCommitter(config: AttachmentCommitterConfig): AttachmentCommitter;
157
+ /**
158
+ * How old a minted download URL may get before a Retry mints a new one. The URL is minted at
159
+ * Send, seconds before the turn; "Try again" on a failed turn can come much later, and the
160
+ * presigned URL has a short life.
161
+ */
162
+ export declare const ATTACHMENT_URL_MAX_AGE_MS: number;
163
+ /**
164
+ * Whether a saved attachment's URL should be re-minted before it is replayed. An unknown age
165
+ * (`urlResolvedAt` unset: sent by an older build) counts as stale; an attachment with no
166
+ * `fileId` has nothing to mint a URL for.
167
+ */
168
+ export declare function attachmentUrlIsStale(attachment: Pick<AssistantAttachment, 'fileId' | 'urlResolvedAt'>, now: number, maxAgeMs?: number): boolean;
169
+ /**
170
+ * The same attachments with a fresh download URL where the old one is stale. A lookup that
171
+ * fails or answers nothing keeps the old URL: the replay still goes out, and its inlined text
172
+ * and metadata are intact.
173
+ */
174
+ export declare function refreshStaleAttachmentUrls(attachments: readonly AssistantAttachment[], resolveUrl: (fileId: string) => Promise<string | null>, now?: number): Promise<AssistantAttachment[]>;
175
+ //# sourceMappingURL=attachmentCommit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attachmentCommit.d.ts","sourceRoot":"","sources":["../../../src/shared/assistant/attachmentCommit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AACH,OAAO,EAIL,KAAK,SAAS,EAEf,MAAM,yBAAyB,CAAC;AAMjC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAIzD,wFAAwF;AACxF,eAAO,MAAM,kCAAkC,QAAkB,CAAC;AAElE;;;;GAIG;AACH,eAAO,MAAM,wBAAwB;IACnC,8BAA8B;;IAE9B,+EAA+E;;;IAG/E,gEAAgE;;;IAGhE,gFAAgF;;;IAGhF,6DAA6D;;IAE7D,uFAAuF;;IAEvF,sCAAsC;;IAEtC;;;;OAIG;;;CAGK,CAAC;AAEX,MAAM,MAAM,sBAAsB,GAAG;IACnC,CAAC,UAAU,CAAC,IAAI,MAAM,OAAO,wBAAwB,GAAG,MAAM;CAC/D,CAAC;AAEF,kGAAkG;AAClG,eAAO,MAAM,uBAAuB;;;;;;;;;CAS1B,CAAC;AAgBX,gEAAgE;AAChE,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,mBAAmB,CAAC;IAChC,2FAA2F;IAC3F,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;CACnB;AAED,MAAM,WA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