@fabric-harness/sdk 6.4.0 → 6.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/connector-spec/voice-telephony.md +120 -104
- package/dist/agent-route.d.ts +20 -2
- package/dist/agent-route.d.ts.map +1 -1
- package/dist/agent-route.js +31 -1
- package/dist/agent-route.js.map +1 -1
- package/dist/agent-router.d.ts +42 -0
- package/dist/agent-router.d.ts.map +1 -1
- package/dist/agent-router.js +49 -1
- package/dist/agent-router.js.map +1 -1
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +7 -2
- package/dist/agent.js.map +1 -1
- package/dist/attachment-store.d.ts +69 -0
- package/dist/attachment-store.d.ts.map +1 -1
- package/dist/attachment-store.js +183 -14
- package/dist/attachment-store.js.map +1 -1
- package/dist/attachments.d.ts +136 -0
- package/dist/attachments.d.ts.map +1 -0
- package/dist/attachments.js +332 -0
- package/dist/attachments.js.map +1 -0
- package/dist/channel.d.ts.map +1 -1
- package/dist/channel.js +26 -3
- package/dist/channel.js.map +1 -1
- package/dist/conversation-history.d.ts +186 -0
- package/dist/conversation-history.d.ts.map +1 -0
- package/dist/conversation-history.js +481 -0
- package/dist/conversation-history.js.map +1 -0
- package/dist/conversation-ui.d.ts +43 -2
- package/dist/conversation-ui.d.ts.map +1 -1
- package/dist/conversation-ui.js +44 -14
- package/dist/conversation-ui.js.map +1 -1
- package/dist/cost-budget.d.ts +50 -0
- package/dist/cost-budget.d.ts.map +1 -1
- package/dist/cost-budget.js +74 -4
- package/dist/cost-budget.js.map +1 -1
- package/dist/cost-enforcement.d.ts +32 -0
- package/dist/cost-enforcement.d.ts.map +1 -0
- package/dist/cost-enforcement.js +116 -0
- package/dist/cost-enforcement.js.map +1 -0
- package/dist/delivered-message.d.ts +20 -6
- package/dist/delivered-message.d.ts.map +1 -1
- package/dist/delivered-message.js +37 -8
- package/dist/delivered-message.js.map +1 -1
- package/dist/events.d.ts +13 -1
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js.map +1 -1
- package/dist/experimental.d.ts +2 -2
- package/dist/experimental.d.ts.map +1 -1
- package/dist/experimental.js +1 -1
- package/dist/experimental.js.map +1 -1
- package/dist/governed-voice.d.ts +6 -0
- package/dist/governed-voice.d.ts.map +1 -1
- package/dist/governed-voice.js +142 -35
- package/dist/governed-voice.js.map +1 -1
- package/dist/history.d.ts +3 -2
- package/dist/history.d.ts.map +1 -1
- package/dist/history.js +57 -23
- package/dist/history.js.map +1 -1
- package/dist/index.d.ts +21 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -7
- package/dist/index.js.map +1 -1
- package/dist/loop.d.ts +25 -2
- package/dist/loop.d.ts.map +1 -1
- package/dist/loop.js +409 -60
- package/dist/loop.js.map +1 -1
- package/dist/model-pricing.d.ts +77 -4
- package/dist/model-pricing.d.ts.map +1 -1
- package/dist/model-pricing.js +259 -18
- package/dist/model-pricing.js.map +1 -1
- package/dist/model.d.ts +115 -3
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +487 -75
- package/dist/model.js.map +1 -1
- package/dist/pi-document-attachments.d.ts +43 -0
- package/dist/pi-document-attachments.d.ts.map +1 -0
- package/dist/pi-document-attachments.js +155 -0
- package/dist/pi-document-attachments.js.map +1 -0
- package/dist/pi-loop-runtime.d.ts +103 -1
- package/dist/pi-loop-runtime.d.ts.map +1 -1
- package/dist/pi-loop-runtime.js +907 -114
- package/dist/pi-loop-runtime.js.map +1 -1
- package/dist/prompt-attachments.d.ts +98 -0
- package/dist/prompt-attachments.d.ts.map +1 -0
- package/dist/prompt-attachments.js +279 -0
- package/dist/prompt-attachments.js.map +1 -0
- package/dist/session.d.ts +55 -0
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +443 -41
- package/dist/session.js.map +1 -1
- package/dist/stream-chunks.d.ts +15 -1
- package/dist/stream-chunks.d.ts.map +1 -1
- package/dist/stream-chunks.js +39 -18
- package/dist/stream-chunks.js.map +1 -1
- package/dist/strict.d.ts +23 -16
- package/dist/strict.d.ts.map +1 -1
- package/dist/strict.js +12 -8
- package/dist/strict.js.map +1 -1
- package/dist/submission-context.d.ts +7 -0
- package/dist/submission-context.d.ts.map +1 -1
- package/dist/submission-context.js.map +1 -1
- package/dist/submission-runner.d.ts +5 -0
- package/dist/submission-runner.d.ts.map +1 -1
- package/dist/submission-runner.js +11 -2
- package/dist/submission-runner.js.map +1 -1
- package/dist/tools.d.ts +9 -0
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +1 -0
- package/dist/tools.js.map +1 -1
- package/dist/types.d.ts +26 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/usage-completeness.d.ts +39 -0
- package/dist/usage-completeness.d.ts.map +1 -0
- package/dist/usage-completeness.js +135 -0
- package/dist/usage-completeness.js.map +1 -0
- package/dist/voice-openai-realtime.d.ts +24 -2
- package/dist/voice-openai-realtime.d.ts.map +1 -1
- package/dist/voice-openai-realtime.js +266 -49
- package/dist/voice-openai-realtime.js.map +1 -1
- package/dist/voice-pipeline.d.ts +81 -3
- package/dist/voice-pipeline.d.ts.map +1 -1
- package/dist/voice-pipeline.js +429 -60
- package/dist/voice-pipeline.js.map +1 -1
- package/dist/voice-stt-cartesia.d.ts +8 -0
- package/dist/voice-stt-cartesia.d.ts.map +1 -1
- package/dist/voice-stt-cartesia.js +77 -17
- package/dist/voice-stt-cartesia.js.map +1 -1
- package/dist/voice-stt-deepgram.d.ts +10 -2
- package/dist/voice-stt-deepgram.d.ts.map +1 -1
- package/dist/voice-stt-deepgram.js +78 -18
- package/dist/voice-stt-deepgram.js.map +1 -1
- package/dist/voice-stt.d.ts +13 -3
- package/dist/voice-stt.d.ts.map +1 -1
- package/dist/voice-tts-cartesia.d.ts +8 -0
- package/dist/voice-tts-cartesia.d.ts.map +1 -1
- package/dist/voice-tts-cartesia.js +48 -105
- package/dist/voice-tts-cartesia.js.map +1 -1
- package/dist/voice-tts-elevenlabs.d.ts +10 -1
- package/dist/voice-tts-elevenlabs.d.ts.map +1 -1
- package/dist/voice-tts-elevenlabs.js +50 -113
- package/dist/voice-tts-elevenlabs.js.map +1 -1
- package/dist/voice-ws-client.js +16 -3
- package/dist/voice-ws-client.js.map +1 -1
- package/dist/voice-ws-shared.d.ts +205 -6
- package/dist/voice-ws-shared.d.ts.map +1 -1
- package/dist/voice-ws-shared.js +510 -15
- package/dist/voice-ws-shared.js.map +1 -1
- package/dist/voice.d.ts +98 -4
- package/dist/voice.d.ts.map +1 -1
- package/dist/voice.js +71 -1
- package/dist/voice.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared attachment vocabulary for user messages: image and document (PDF)
|
|
3
|
+
* attachments, their validation, and the text placeholder used when a model
|
|
4
|
+
* API cannot accept a given attachment kind natively.
|
|
5
|
+
*
|
|
6
|
+
* Runtime-neutral: no Node, provider, or storage dependencies. Durable bytes
|
|
7
|
+
* live in an {@link import('./attachment-store.js').AttachmentStore}; this
|
|
8
|
+
* module only describes and validates them.
|
|
9
|
+
*/
|
|
10
|
+
/** Document MIME types accepted on document attachments and `PromptOptions.documents`. */
|
|
11
|
+
export const DOCUMENT_MIME_TYPES = ['application/pdf'];
|
|
12
|
+
/**
|
|
13
|
+
* Image MIME types every native image-capable adapter accepts (Anthropic,
|
|
14
|
+
* Gemini, OpenAI). Other well-formed `image/*` types are admitted but may be
|
|
15
|
+
* replaced with a text placeholder by adapters that cannot send them.
|
|
16
|
+
*/
|
|
17
|
+
export const IMAGE_MIME_TYPES = ['image/png', 'image/jpeg', 'image/gif', 'image/webp'];
|
|
18
|
+
/** Maximum length of an attachment's display filename after sanitization. */
|
|
19
|
+
export const MAX_ATTACHMENT_FILENAME_LENGTH = 255;
|
|
20
|
+
const documentMimeTypes = new Set(DOCUMENT_MIME_TYPES);
|
|
21
|
+
const nativeImageMimeTypes = new Set(IMAGE_MIME_TYPES);
|
|
22
|
+
const IMAGE_MIME_RE = /^image\/[a-z0-9][a-z0-9.+-]{0,126}$/;
|
|
23
|
+
/** True for a supported document MIME type (currently `application/pdf`). */
|
|
24
|
+
export function isDocumentMimeType(mimeType) {
|
|
25
|
+
return documentMimeTypes.has(mimeType);
|
|
26
|
+
}
|
|
27
|
+
/** True for a well-formed `image/*` MIME type. */
|
|
28
|
+
export function isImageMimeType(mimeType) {
|
|
29
|
+
return IMAGE_MIME_RE.test(mimeType);
|
|
30
|
+
}
|
|
31
|
+
/** True for an image MIME type every native image adapter accepts. */
|
|
32
|
+
export function isNativeImageMimeType(mimeType) {
|
|
33
|
+
return nativeImageMimeTypes.has(mimeType);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Normalize an uploader-provided filename into a safe display name: keep the
|
|
37
|
+
* last path segment, drop control characters and quotes, collapse whitespace,
|
|
38
|
+
* and bound the length. Returns `undefined` when nothing printable remains.
|
|
39
|
+
* The result is display metadata only — it never addresses storage.
|
|
40
|
+
*/
|
|
41
|
+
export function sanitizeAttachmentFilename(filename) {
|
|
42
|
+
// Lone surrogates would later break encodeURIComponent in download headers.
|
|
43
|
+
const lastSegment = toWellFormedText(filename).split(/[\\/]/).pop() ?? '';
|
|
44
|
+
const printable = Array.from(lastSegment)
|
|
45
|
+
.filter((char) => {
|
|
46
|
+
const code = char.codePointAt(0) ?? 0;
|
|
47
|
+
return code > 0x1f && (code < 0x7f || code > 0x9f) && char !== '"';
|
|
48
|
+
})
|
|
49
|
+
.join('');
|
|
50
|
+
const cleaned = printable.replace(/\s+/g, ' ').trim();
|
|
51
|
+
if (!cleaned || cleaned === '.' || cleaned === '..')
|
|
52
|
+
return undefined;
|
|
53
|
+
return Array.from(cleaned).slice(0, MAX_ATTACHMENT_FILENAME_LENGTH).join('');
|
|
54
|
+
}
|
|
55
|
+
/** Parse the refs-only records from a persisted `user_prompt` entry. */
|
|
56
|
+
export function promptAttachmentRecordsFromEntryData(value) {
|
|
57
|
+
if (!Array.isArray(value))
|
|
58
|
+
return [];
|
|
59
|
+
const out = [];
|
|
60
|
+
for (const raw of value) {
|
|
61
|
+
if (typeof raw !== 'object' || raw === null)
|
|
62
|
+
continue;
|
|
63
|
+
const record = raw;
|
|
64
|
+
const ref = record.ref;
|
|
65
|
+
if ((record.type !== 'image' && record.type !== 'document') ||
|
|
66
|
+
typeof record.mimeType !== 'string' ||
|
|
67
|
+
!ref ||
|
|
68
|
+
typeof ref.id !== 'string' ||
|
|
69
|
+
typeof ref.digest !== 'string' ||
|
|
70
|
+
typeof ref.sizeBytes !== 'number') {
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
out.push({
|
|
74
|
+
type: record.type,
|
|
75
|
+
mimeType: record.mimeType,
|
|
76
|
+
...(typeof record.filename === 'string' ? { filename: record.filename } : {}),
|
|
77
|
+
ref: { id: ref.id, digest: ref.digest, sizeBytes: ref.sizeBytes },
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
return out;
|
|
81
|
+
}
|
|
82
|
+
/** Thrown when `PromptOptions.images` / `documents` are malformed. */
|
|
83
|
+
export class InvalidPromptAttachmentError extends Error {
|
|
84
|
+
code = 'INVALID_PROMPT_ATTACHMENT';
|
|
85
|
+
constructor(reason) {
|
|
86
|
+
super(`[fabric-harness] ${reason}`);
|
|
87
|
+
this.name = 'InvalidPromptAttachmentError';
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Text that replaces an attachment for a model API that cannot accept it.
|
|
92
|
+
* `reason` distinguishes an unsupported API from bytes that are no longer
|
|
93
|
+
* retained (e.g. a restarted process without a durable attachment store).
|
|
94
|
+
*/
|
|
95
|
+
export function attachmentOmittedPlaceholder(input) {
|
|
96
|
+
const name = input.filename ? ` "${input.filename}"` : '';
|
|
97
|
+
if (input.reason === 'unavailable') {
|
|
98
|
+
return `(${input.kind}${name} omitted: attachment bytes are not available)`;
|
|
99
|
+
}
|
|
100
|
+
if (input.reason === 'unsupported-type') {
|
|
101
|
+
return `(${input.kind}${name} omitted: ${input.mimeType ?? 'this type'} is not supported by model API "${input.api}")`;
|
|
102
|
+
}
|
|
103
|
+
return `(${input.kind}${name} omitted: model API "${input.api}" does not support ${input.kind} input)`;
|
|
104
|
+
}
|
|
105
|
+
const warned = new Set();
|
|
106
|
+
/** Distinct `(api, kind)` pairs that warn before further warnings are suppressed. */
|
|
107
|
+
const MAX_ATTACHMENT_WARNINGS = 1000;
|
|
108
|
+
let attachmentWarningsSuppressed = false;
|
|
109
|
+
/**
|
|
110
|
+
* Emit a single console warning per `(api, kind)` pair when attachments are
|
|
111
|
+
* replaced with a placeholder, so operators learn about the degradation
|
|
112
|
+
* without per-request log noise. Never logs attachment bytes or filenames.
|
|
113
|
+
*/
|
|
114
|
+
export function warnAttachmentOmittedOnce(api, kind) {
|
|
115
|
+
const key = `${api}\u0000${kind}`;
|
|
116
|
+
if (warned.has(key))
|
|
117
|
+
return;
|
|
118
|
+
// Custom providers can name arbitrarily many APIs; keep the set bounded.
|
|
119
|
+
if (warned.size >= MAX_ATTACHMENT_WARNINGS) {
|
|
120
|
+
if (!attachmentWarningsSuppressed) {
|
|
121
|
+
attachmentWarningsSuppressed = true;
|
|
122
|
+
console.warn(`[fabric-harness] Attachment placeholder warnings reached ${MAX_ATTACHMENT_WARNINGS} distinct model APIs; further ones are suppressed. Attachments are still replaced with a text placeholder.`);
|
|
123
|
+
}
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
warned.add(key);
|
|
127
|
+
console.warn(`[fabric-harness] Model API "${api}" does not support native ${kind} input; ` +
|
|
128
|
+
`${kind} attachments are replaced with a text placeholder in the model context.`);
|
|
129
|
+
}
|
|
130
|
+
/** @internal Test seam: forget which APIs already warned. */
|
|
131
|
+
export function resetAttachmentWarningsForTesting() {
|
|
132
|
+
warned.clear();
|
|
133
|
+
attachmentWarningsSuppressed = false;
|
|
134
|
+
}
|
|
135
|
+
/** Replacement text for attachment payloads removed from error messages. */
|
|
136
|
+
const REDACTED_ATTACHMENT_DATA = "[attachment data redacted]";
|
|
137
|
+
// `data:<mime>[;params];base64,<payload>`. Standard and URL-safe alphabets,
|
|
138
|
+
// with optional padding. The MIME prefix is kept for diagnostics.
|
|
139
|
+
const DATA_URL_PAYLOAD_RE = /(data:[a-z0-9][a-z0-9.+-]*\/[a-z0-9][a-z0-9.+-]*(?:;[a-z0-9=._+-]+)*;base64,)[A-Za-z0-9+/_-]+={0,2}/gi;
|
|
140
|
+
// A bare base64 run of 256+ characters is far longer than any identifier,
|
|
141
|
+
// hash, or token a provider error legitimately quotes, and short enough to
|
|
142
|
+
// catch a meaningful fragment of an echoed image or PDF.
|
|
143
|
+
const RAW_BASE64_RUN_RE = /[A-Za-z0-9+/_-]{256,}={0,2}/g;
|
|
144
|
+
/**
|
|
145
|
+
* Shortest submitted payload (or echoed fragment of one) redacted by exact
|
|
146
|
+
* match. Sixteen base64 characters carry 96 bits, so an unrelated identifier
|
|
147
|
+
* in provider error text matching a fragment of a submitted payload is not a
|
|
148
|
+
* practical concern, while every real image or PDF is longer than this.
|
|
149
|
+
*/
|
|
150
|
+
const MIN_SUBMITTED_PAYLOAD_FRAGMENT = 16;
|
|
151
|
+
// Base64 runs as they can appear in provider error text: standard or URL-safe
|
|
152
|
+
// alphabet, optional padding, JSON-escaped slashes (`\/`) and percent-encoded
|
|
153
|
+
// `+`, `/` and `=`.
|
|
154
|
+
const BASE64_FRAGMENT_RE = /(?:[A-Za-z0-9+_-]|\\?\/|%2[BbFf])+(?:=|%3[Dd]){0,2}/g;
|
|
155
|
+
/** Canonical form for comparison: standard alphabet, no padding, whitespace or escapes. */
|
|
156
|
+
function canonicalBase64(value) {
|
|
157
|
+
return value
|
|
158
|
+
.replace(/%2[Bb]/g, '+')
|
|
159
|
+
.replace(/%2[Ff]/g, '/')
|
|
160
|
+
.replace(/%3[Dd]/g, '=')
|
|
161
|
+
.replace(/\\/g, '')
|
|
162
|
+
.replace(/\s+/g, '')
|
|
163
|
+
.replace(/-/g, '+')
|
|
164
|
+
.replace(/_/g, '/')
|
|
165
|
+
.replace(/=+$/, '');
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* @internal The base64 payloads of every attachment carried by `messages`.
|
|
169
|
+
* Callers pass the result to {@link redactAttachmentPayloads} so the exact
|
|
170
|
+
* bytes submitted in a model request are removed from provider error text
|
|
171
|
+
* regardless of their length.
|
|
172
|
+
*/
|
|
173
|
+
export function collectAttachmentPayloads(messages) {
|
|
174
|
+
const out = [];
|
|
175
|
+
for (const message of messages) {
|
|
176
|
+
for (const attachment of message.attachments ?? []) {
|
|
177
|
+
if (typeof attachment.data === 'string' && attachment.data.length > 0)
|
|
178
|
+
out.push(attachment.data);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return out;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Remove every occurrence, or echoed fragment, of the submitted payloads. A
|
|
185
|
+
* base64 run in `text` is compared in canonical form (standard alphabet, no
|
|
186
|
+
* padding, JSON and percent escapes decoded), so standard, URL-safe,
|
|
187
|
+
* unpadded, escaped, truncated and line-wrapped echoes all match. A run that
|
|
188
|
+
* is a 16+ character substring of a submitted payload, or that contains a
|
|
189
|
+
* whole submitted payload, is replaced.
|
|
190
|
+
*/
|
|
191
|
+
function redactSubmittedPayloads(text, payloads) {
|
|
192
|
+
const canonical = [];
|
|
193
|
+
for (const payload of payloads) {
|
|
194
|
+
const value = canonicalBase64(payload);
|
|
195
|
+
if (value.length >= MIN_SUBMITTED_PAYLOAD_FRAGMENT)
|
|
196
|
+
canonical.push(value);
|
|
197
|
+
}
|
|
198
|
+
if (canonical.length === 0)
|
|
199
|
+
return text;
|
|
200
|
+
return text.replace(BASE64_FRAGMENT_RE, (run) => {
|
|
201
|
+
const value = canonicalBase64(run);
|
|
202
|
+
if (value.length < MIN_SUBMITTED_PAYLOAD_FRAGMENT)
|
|
203
|
+
return run;
|
|
204
|
+
const matches = canonical.some((payload) => payload.length >= value.length ? payload.includes(value) : value.includes(payload));
|
|
205
|
+
return matches ? REDACTED_ATTACHMENT_DATA : run;
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* @internal Remove attachment payloads that a provider echoed into an error
|
|
210
|
+
* message. When `payloads` (the attachment data submitted in the failing
|
|
211
|
+
* request, see {@link collectAttachmentPayloads}) is given, those exact
|
|
212
|
+
* payloads and any 16+ character fragment of them are removed regardless of
|
|
213
|
+
* length. As a backstop, `data:<mime>;base64,<...>` URLs and raw base64 runs
|
|
214
|
+
* of 256 or more characters are always removed. Applied before provider error
|
|
215
|
+
* text is thrown, recorded in session entries, or emitted as events, so image
|
|
216
|
+
* and PDF bytes never reach durable state or telemetry through an error path.
|
|
217
|
+
*/
|
|
218
|
+
export function redactAttachmentPayloads(text, payloads) {
|
|
219
|
+
const exact = payloads ? redactSubmittedPayloads(text, payloads) : text;
|
|
220
|
+
if (exact.length < 32)
|
|
221
|
+
return exact;
|
|
222
|
+
return exact
|
|
223
|
+
.replace(DATA_URL_PAYLOAD_RE, `$1${REDACTED_ATTACHMENT_DATA}`)
|
|
224
|
+
.replace(RAW_BASE64_RUN_RE, REDACTED_ATTACHMENT_DATA);
|
|
225
|
+
}
|
|
226
|
+
/** Bounds on the error graph {@link redactErrorAttachmentPayloads} walks. */
|
|
227
|
+
const MAX_ERROR_REDACTION_DEPTH = 4;
|
|
228
|
+
const MAX_ERROR_REDACTION_NODES = 64;
|
|
229
|
+
const ERROR_REDACTION_LIMIT_PLACEHOLDER = '[error detail omitted: redaction limit reached]';
|
|
230
|
+
/**
|
|
231
|
+
* Stand-in for an error-graph branch the redactor did not walk. An `Error`
|
|
232
|
+
* branch becomes a fresh `Error` with the same name and the redacted own
|
|
233
|
+
* message (when it is a plain data property) and no `cause`, `errors` or
|
|
234
|
+
* custom fields; its stack is captured here, so it carries no provider text.
|
|
235
|
+
* Any other object becomes a placeholder string.
|
|
236
|
+
*/
|
|
237
|
+
function redactionLimitPlaceholder(value, payloads) {
|
|
238
|
+
if (!(value instanceof Error))
|
|
239
|
+
return ERROR_REDACTION_LIMIT_PLACEHOLDER;
|
|
240
|
+
const message = Object.getOwnPropertyDescriptor(value, 'message');
|
|
241
|
+
const placeholder = new Error(typeof message?.value === 'string'
|
|
242
|
+
? `${redactAttachmentPayloads(message.value, payloads)} ${ERROR_REDACTION_LIMIT_PLACEHOLDER}`
|
|
243
|
+
: ERROR_REDACTION_LIMIT_PLACEHOLDER);
|
|
244
|
+
let errorName;
|
|
245
|
+
try {
|
|
246
|
+
errorName = value.name;
|
|
247
|
+
}
|
|
248
|
+
catch {
|
|
249
|
+
// A throwing `name` getter keeps the placeholder's default name.
|
|
250
|
+
}
|
|
251
|
+
if (typeof errorName === 'string')
|
|
252
|
+
placeholder.name = redactAttachmentPayloads(errorName, payloads);
|
|
253
|
+
return placeholder;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* @internal Redact attachment payloads from a thrown value in place, so the
|
|
257
|
+
* rejected error keeps its class, identity and fields (a
|
|
258
|
+
* `ProviderHttpError`'s `status`, `retryAfterMs` and `body`, a custom error's
|
|
259
|
+
* `code`) while none of its text carries submitted bytes. Every own string
|
|
260
|
+
* property of an `Error` is redacted, including `message` and `stack`, as are
|
|
261
|
+
* the strings of its `cause`, `errors` and plain-object properties.
|
|
262
|
+
*
|
|
263
|
+
* The walk is bounded (depth 4, 64 nodes) and fails closed: an `Error`,
|
|
264
|
+
* array or plain-object branch beyond either bound is not left unchecked but
|
|
265
|
+
* replaced in place by a placeholder (see `redactionLimitPlaceholder`), so a
|
|
266
|
+
* payload wrapped in many `cause` layers or a wide `AggregateError` cannot
|
|
267
|
+
* survive in the graph that `util.inspect` and loggers print. Cycles are
|
|
268
|
+
* walked once. A property that cannot be rewritten (a frozen error) makes the
|
|
269
|
+
* function return a plain `Error` carrying the redacted message and name, and
|
|
270
|
+
* no cause chain, instead. A non-`Error` thrown value becomes an `Error` with
|
|
271
|
+
* its redacted string form.
|
|
272
|
+
*/
|
|
273
|
+
export function redactErrorAttachmentPayloads(error, payloads) {
|
|
274
|
+
if (!(error instanceof Error))
|
|
275
|
+
return new Error(redactAttachmentPayloads(String(error), payloads));
|
|
276
|
+
const seen = new Set();
|
|
277
|
+
let complete = true;
|
|
278
|
+
const walkable = (value) => value instanceof Error || Array.isArray(value) || Object.getPrototypeOf(value) === Object.prototype;
|
|
279
|
+
const replace = (owner, key, descriptor, next) => {
|
|
280
|
+
try {
|
|
281
|
+
Object.defineProperty(owner, key, { ...descriptor, value: next });
|
|
282
|
+
}
|
|
283
|
+
catch {
|
|
284
|
+
// Frozen or non-configurable: fall through to the verification below.
|
|
285
|
+
}
|
|
286
|
+
if (owner[key] !== next)
|
|
287
|
+
complete = false;
|
|
288
|
+
};
|
|
289
|
+
const visit = (value, depth) => {
|
|
290
|
+
seen.add(value);
|
|
291
|
+
if (!walkable(value))
|
|
292
|
+
return;
|
|
293
|
+
for (const key of Object.getOwnPropertyNames(value)) {
|
|
294
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
295
|
+
if (!descriptor || !('value' in descriptor))
|
|
296
|
+
continue;
|
|
297
|
+
const current = descriptor.value;
|
|
298
|
+
if (typeof current === 'string') {
|
|
299
|
+
const redacted = redactAttachmentPayloads(current, payloads);
|
|
300
|
+
if (redacted !== current)
|
|
301
|
+
replace(value, key, descriptor, redacted);
|
|
302
|
+
}
|
|
303
|
+
else if (current !== null && typeof current === 'object' && !seen.has(current)) {
|
|
304
|
+
if (depth < MAX_ERROR_REDACTION_DEPTH && seen.size < MAX_ERROR_REDACTION_NODES) {
|
|
305
|
+
visit(current, depth + 1);
|
|
306
|
+
}
|
|
307
|
+
else if (walkable(current)) {
|
|
308
|
+
// Fail closed: a branch past the depth or node bound is detached
|
|
309
|
+
// rather than returned unchecked.
|
|
310
|
+
replace(value, key, descriptor, redactionLimitPlaceholder(current, payloads));
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
visit(error, 0);
|
|
316
|
+
if (complete)
|
|
317
|
+
return error;
|
|
318
|
+
const copy = new Error(redactAttachmentPayloads(error.message, payloads));
|
|
319
|
+
copy.name = error.name;
|
|
320
|
+
return copy;
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Replace lone UTF-16 surrogates with U+FFFD (the behavior of
|
|
324
|
+
* `String.prototype.toWellFormed()`). A lone surrogate is not valid Unicode:
|
|
325
|
+
* `encodeURIComponent()` throws `URIError` on it, and UTF-8 encoders turn it
|
|
326
|
+
* into replacement bytes anyway. @internal
|
|
327
|
+
*/
|
|
328
|
+
const LONE_SURROGATE_RE = /[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g;
|
|
329
|
+
function toWellFormedText(value) {
|
|
330
|
+
return value.replace(LONE_SURROGATE_RE, '\uFFFD');
|
|
331
|
+
}
|
|
332
|
+
//# sourceMappingURL=attachments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachments.js","sourceRoot":"","sources":["../src/attachments.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,0FAA0F;AAC1F,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,iBAAiB,CAAU,CAAC;AAKhE;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,CAAU,CAAC;AAEhG,6EAA6E;AAC7E,MAAM,CAAC,MAAM,8BAA8B,GAAG,GAAG,CAAC;AAElD,MAAM,iBAAiB,GAAwB,IAAI,GAAG,CAAC,mBAAmB,CAAC,CAAC;AAC5E,MAAM,oBAAoB,GAAwB,IAAI,GAAG,CAAC,gBAAgB,CAAC,CAAC;AAC5E,MAAM,aAAa,GAAG,qCAAqC,CAAC;AAE5D,6EAA6E;AAC7E,MAAM,UAAU,kBAAkB,CAAC,QAAgB;IACjD,OAAO,iBAAiB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E,IAAI,EAAE,OAAO,CAAC;CACf;AAED;;;;GAIG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,SAAqB,GAAG,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC,CAWtH"}
|
package/dist/channel.js
CHANGED
|
@@ -88,9 +88,32 @@ export async function readRequestBody(request, limitBytes = DEFAULT_BODY_LIMIT)
|
|
|
88
88
|
const contentLength = request.headers.get('content-length');
|
|
89
89
|
if (contentLength && Number(contentLength) > limitBytes)
|
|
90
90
|
return undefined;
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
return undefined;
|
|
91
|
+
if (!request.body) {
|
|
92
|
+
const buffer = new Uint8Array(await request.arrayBuffer());
|
|
93
|
+
return buffer.byteLength > limitBytes ? undefined : buffer;
|
|
94
|
+
}
|
|
95
|
+
// Enforce the bound while streaming: a chunked or mis-declared body must not
|
|
96
|
+
// be buffered whole before it is rejected.
|
|
97
|
+
const reader = request.body.getReader();
|
|
98
|
+
const chunks = [];
|
|
99
|
+
let total = 0;
|
|
100
|
+
for (;;) {
|
|
101
|
+
const { done, value } = await reader.read();
|
|
102
|
+
if (done)
|
|
103
|
+
break;
|
|
104
|
+
total += value.byteLength;
|
|
105
|
+
if (total > limitBytes) {
|
|
106
|
+
await reader.cancel().catch(() => undefined);
|
|
107
|
+
return undefined;
|
|
108
|
+
}
|
|
109
|
+
chunks.push(value);
|
|
110
|
+
}
|
|
111
|
+
const buffer = new Uint8Array(total);
|
|
112
|
+
let offset = 0;
|
|
113
|
+
for (const chunk of chunks) {
|
|
114
|
+
buffer.set(chunk, offset);
|
|
115
|
+
offset += chunk.byteLength;
|
|
116
|
+
}
|
|
94
117
|
return buffer;
|
|
95
118
|
}
|
|
96
119
|
/**
|
package/dist/channel.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channel.js","sourceRoot":"","sources":["../src/channel.ts"],"names":[],"mappings":"AAsDA,MAAM,SAAS,GAAG,U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AC;IACnB,CAAC;IACD,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AAC7B,CAAC"}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { type ConversationStreamRecord, type ConversationStreamStore } from './conversation-stream.js';
|
|
2
|
+
import type { SessionEntry } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Bounded conversation history reads.
|
|
5
|
+
*
|
|
6
|
+
* A long-running persistent conversation should not force a client to fetch
|
|
7
|
+
* and fold every record before it can render the latest exchange. A history
|
|
8
|
+
* window is a contiguous range of the conversation's **active path** (the
|
|
9
|
+
* entries that survive every truncation), selected by projected message count
|
|
10
|
+
* and returned as ordinary entry records, so every existing fold
|
|
11
|
+
* (`projectConversationRecords`, React stores, custom reducers) consumes it
|
|
12
|
+
* unchanged.
|
|
13
|
+
*
|
|
14
|
+
* - `limit=N` — the newest N messages, through the head. Carries `offset`, so
|
|
15
|
+
* it can seed a live observation.
|
|
16
|
+
* - `from=<cursor>` — everything from the cursor's entry through the head.
|
|
17
|
+
* Carries `offset`; used to re-hydrate a window a client already holds.
|
|
18
|
+
* - `before=<cursor>[&limit=N]` — an older page strictly before the cursor.
|
|
19
|
+
* Carries no `offset`: a page cannot seed an observation.
|
|
20
|
+
*
|
|
21
|
+
* **Closure.** A window never splits a dependency. Its start expands backward
|
|
22
|
+
* until no entry inside it depends on an entry before it (a tool result on
|
|
23
|
+
* its tool call; message data and response metadata on the assistant message
|
|
24
|
+
* they decorate, or on the pending data a later assistant message absorbs),
|
|
25
|
+
* and until it holds every message that can still change live (open tool
|
|
26
|
+
* calls and the current assistant message and prompt of every unsettled
|
|
27
|
+
* submission that recorded an entry within the newest 200 messages; an older
|
|
28
|
+
* unsettled submission is treated as abandoned so it cannot pin every window).
|
|
29
|
+
* A window may therefore exceed `limit`. Pages are disjoint entry
|
|
30
|
+
* ranges, each self-projecting, and concatenating them oldest-first yields the
|
|
31
|
+
* full projection.
|
|
32
|
+
*
|
|
33
|
+
* **Settlements.** A settlement that sits before the window start but settles
|
|
34
|
+
* a submission referenced inside it is delivered in `settlements`, so a client
|
|
35
|
+
* never mistakes an old, finished submission for active work. Fold
|
|
36
|
+
* `settlements` before `records` (see {@link conversationHistoryRecords}).
|
|
37
|
+
*
|
|
38
|
+
* **Cursors** are opaque, versioned tokens bound to the stream incarnation. A
|
|
39
|
+
* cursor from another incarnation, or naming an entry no longer on the active
|
|
40
|
+
* path (for example one rewound by a truncation), is gone:
|
|
41
|
+
* {@link ConversationHistoryError} with code `history_cursor_not_found`, which
|
|
42
|
+
* HTTP surfaces map to `410`. Clients must not construct or interpret cursors.
|
|
43
|
+
*/
|
|
44
|
+
export interface ConversationHistoryWindow {
|
|
45
|
+
v: 1;
|
|
46
|
+
/** Stream generation the window and its cursors belong to; `null` when no stream exists yet. */
|
|
47
|
+
incarnation: string | null;
|
|
48
|
+
/** Contiguous active-path entry records in path order. */
|
|
49
|
+
records: ConversationHistoryEntryRecord[];
|
|
50
|
+
/**
|
|
51
|
+
* `submission_settled` entry records located before the window whose
|
|
52
|
+
* submission is referenced inside it, in path order. Fold before `records`.
|
|
53
|
+
*/
|
|
54
|
+
settlements: ConversationHistoryEntryRecord[];
|
|
55
|
+
/** Cursor for the next older page, or `null` when the window starts at the conversation origin. */
|
|
56
|
+
before: string | null;
|
|
57
|
+
/**
|
|
58
|
+
* Cursor naming the window's first entry (`null` when the window is empty).
|
|
59
|
+
* Pass it as `from` to re-hydrate everything the client holds from here on.
|
|
60
|
+
*/
|
|
61
|
+
anchor: string | null;
|
|
62
|
+
/**
|
|
63
|
+
* Stream position after the head the window was read at. Present on `limit`
|
|
64
|
+
* and `from` windows (continue a live observation from it); absent on
|
|
65
|
+
* `before` pages.
|
|
66
|
+
*/
|
|
67
|
+
offset?: string;
|
|
68
|
+
}
|
|
69
|
+
export type ConversationHistoryEntryRecord = Extract<ConversationStreamRecord, {
|
|
70
|
+
kind: 'entry';
|
|
71
|
+
}>;
|
|
72
|
+
/** A validated history request. Use {@link parseConversationHistoryRequest} for query strings. */
|
|
73
|
+
export type ConversationHistoryRequest = {
|
|
74
|
+
kind: 'newest';
|
|
75
|
+
limit?: number;
|
|
76
|
+
} | {
|
|
77
|
+
kind: 'from';
|
|
78
|
+
from: string;
|
|
79
|
+
} | {
|
|
80
|
+
kind: 'before';
|
|
81
|
+
before: string;
|
|
82
|
+
limit?: number;
|
|
83
|
+
};
|
|
84
|
+
export type ConversationHistoryErrorCode = 'history_cursor_not_found' | 'invalid_history_request' | 'history_read_incomplete';
|
|
85
|
+
/**
|
|
86
|
+
* Typed history failure. `status` is the HTTP status every Harness surface
|
|
87
|
+
* returns for it: `410` for a gone cursor, `400` for an invalid request, and
|
|
88
|
+
* `503` when the backing stream stopped advancing before reaching its head.
|
|
89
|
+
*/
|
|
90
|
+
export declare class ConversationHistoryError extends Error {
|
|
91
|
+
readonly code: ConversationHistoryErrorCode;
|
|
92
|
+
readonly status: 400 | 410 | 503;
|
|
93
|
+
constructor(code: ConversationHistoryErrorCode, message: string);
|
|
94
|
+
/** Public error envelope, `{ error: { code, type, message } }`. */
|
|
95
|
+
toResponseBody(): {
|
|
96
|
+
error: {
|
|
97
|
+
code: string;
|
|
98
|
+
type: string;
|
|
99
|
+
message: string;
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
export declare function isConversationHistoryError(error: unknown): error is ConversationHistoryError;
|
|
104
|
+
/** Largest `limit` a history read accepts (the conversation read maximum). */
|
|
105
|
+
export declare const CONVERSATION_HISTORY_MAX_LIMIT = 1000;
|
|
106
|
+
/** Encode an opaque history cursor for one entry in one stream incarnation. */
|
|
107
|
+
export declare function encodeConversationHistoryCursor(incarnation: string, entryId: string): string;
|
|
108
|
+
/**
|
|
109
|
+
* Parse and validate `limit`, `before`, and `from` query parameters.
|
|
110
|
+
* Throws {@link ConversationHistoryError} (`invalid_history_request`) for a
|
|
111
|
+
* malformed cursor or limit, a repeated parameter, `before` with `from`, or
|
|
112
|
+
* `from` with `limit`.
|
|
113
|
+
*/
|
|
114
|
+
export declare function parseConversationHistoryRequest(params: URLSearchParams): ConversationHistoryRequest;
|
|
115
|
+
/** Validate a structured history request (the programmatic twin of the query parser). */
|
|
116
|
+
export declare function validateConversationHistoryRequest(input: {
|
|
117
|
+
limit?: number;
|
|
118
|
+
before?: string;
|
|
119
|
+
from?: string;
|
|
120
|
+
}): ConversationHistoryRequest;
|
|
121
|
+
/** Records to fold for a window: carried settlements first, then the window's entries. */
|
|
122
|
+
export declare function conversationHistoryRecords(window: Pick<ConversationHistoryWindow, 'records' | 'settlements'>): ConversationStreamRecord[];
|
|
123
|
+
/** Fold stream records into the active path (truncations rewind it). */
|
|
124
|
+
export declare function activeConversationEntries(records: readonly ConversationStreamRecord[]): SessionEntry[];
|
|
125
|
+
/**
|
|
126
|
+
* Select a history window from a conversation's complete stream records.
|
|
127
|
+
*
|
|
128
|
+
* `records` must be every record from the stream origin through `offset`
|
|
129
|
+
* (truncations included); the window is computed on their active path.
|
|
130
|
+
* Throws {@link ConversationHistoryError} when a cursor is gone.
|
|
131
|
+
*/
|
|
132
|
+
export declare function selectConversationHistoryWindow(input: {
|
|
133
|
+
records: readonly ConversationStreamRecord[];
|
|
134
|
+
incarnation: string | null;
|
|
135
|
+
offset: string;
|
|
136
|
+
request: ConversationHistoryRequest;
|
|
137
|
+
}): ConversationHistoryWindow;
|
|
138
|
+
/** One page of a transport-level conversation read. */
|
|
139
|
+
export interface ConversationHistorySourcePage {
|
|
140
|
+
incarnation: string | null;
|
|
141
|
+
batches: Array<{
|
|
142
|
+
offset: string;
|
|
143
|
+
records: readonly unknown[];
|
|
144
|
+
}>;
|
|
145
|
+
nextOffset: string;
|
|
146
|
+
upToDate: boolean;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Default bound on stream records one history read may scan (folded
|
|
150
|
+
* checkpoint records count once each). A conversation longer than this
|
|
151
|
+
* without a fold checkpoint fails with `history_read_incomplete` instead of
|
|
152
|
+
* holding a request for an unbounded scan.
|
|
153
|
+
*/
|
|
154
|
+
export declare const CONVERSATION_HISTORY_MAX_SCAN_RECORDS = 250000;
|
|
155
|
+
/** Options shared by the history readers. */
|
|
156
|
+
export interface ConversationHistoryReadOptions {
|
|
157
|
+
/**
|
|
158
|
+
* Cancels the read between pages (pass the HTTP request's signal). An
|
|
159
|
+
* aborted read stops paging and rejects with the signal's reason.
|
|
160
|
+
*/
|
|
161
|
+
signal?: AbortSignal;
|
|
162
|
+
/**
|
|
163
|
+
* Most stream records the read may scan before failing with
|
|
164
|
+
* `history_read_incomplete`. Defaults to
|
|
165
|
+
* {@link CONVERSATION_HISTORY_MAX_SCAN_RECORDS}.
|
|
166
|
+
*/
|
|
167
|
+
maxRecords?: number;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Read a conversation to its head through any offset-paged reader and select a
|
|
171
|
+
* history window. Used by hosts whose conversation reads are already paged
|
|
172
|
+
* (the mountable router's backend). Restarts when the stream incarnation
|
|
173
|
+
* changes mid-read, and fails after repeated changes. Stops paging when
|
|
174
|
+
* `options.signal` aborts, and fails with `history_read_incomplete` once more
|
|
175
|
+
* than `options.maxRecords` records have been scanned.
|
|
176
|
+
*/
|
|
177
|
+
export declare function readConversationHistoryFromPages(readPage: (offset: string, signal?: AbortSignal) => Promise<ConversationHistorySourcePage>, request: ConversationHistoryRequest, options?: ConversationHistoryReadOptions): Promise<ConversationHistoryWindow>;
|
|
178
|
+
/**
|
|
179
|
+
* Read a history window straight from a {@link ConversationStreamStore},
|
|
180
|
+
* starting from its fold checkpoint when one exists. A missing stream yields
|
|
181
|
+
* an empty window for `newest` reads and a gone cursor for `before`/`from`.
|
|
182
|
+
* Honors `options.signal` and `options.maxRecords` like
|
|
183
|
+
* {@link readConversationHistoryFromPages}.
|
|
184
|
+
*/
|
|
185
|
+
export declare function readConversationHistory(store: ConversationStreamStore, path: string, request: ConversationHistoryRequest, options?: ConversationHistoryReadOptions): Promise<ConversationHistoryWindow>;
|
|
186
|
+
//# sourceMappingURL=conversation-history.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversation-history.d.ts","sourceRoot":"","sources":["../src/conversation-history.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,EAC7B,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,MAAM,WAAW,yBAAyB;IACxC,CAAC,EAAE,CAAC,CAAC;IACL,gGAAgG;IAChG,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,0DAA0D;IAC1D,OAAO,EAAE,8BAA8B,EAAE,CAAC;IAC1C;;;OAGG;IACH,WAAW,EAAE,8BAA8B,EAAE,CAAC;IAC9C,mGAAmG;IACnG,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB;;;OAGG;IACH,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,MAAM,8BAA8B,GAAG,OAAO,CAAC,wBAAwB,EAAE;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC,CAAC;AAElG,kGAAkG;AAClG,MAAM,MAAM,0BAA0B,GAClC;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GAClC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC9B;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAEvD,MAAM,MAAM,4BAA4B,GACpC,0BAA0B,GAC1B,yBAAyB,GACzB,yBAAyB,CAAC;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