(source: string, contentBounds: JsonValueBounds | null)
| 359 | } |
| 360 | |
| 361 | function extractLargeUserText(source: string, contentBounds: JsonValueBounds | null): string | undefined { |
| 362 | if (!contentBounds) return undefined |
| 363 | if (contentBounds.kind === 'string') return readJsonString(source, contentBounds, USER_TEXT_CAP) |
| 364 | if (contentBounds.kind !== 'array') return undefined |
| 365 | |
| 366 | let text = '' |
| 367 | let i = contentBounds.start + 1 |
| 368 | while (i < contentBounds.end - 1 && text.length < USER_TEXT_CAP) { |
| 369 | while (i < contentBounds.end && /\s/.test(source[i]!)) i++ |
| 370 | if (source.charCodeAt(i) === 0x2c) { |
| 371 | i++ |
| 372 | continue |
| 373 | } |
| 374 | if (source.charCodeAt(i) !== 0x7b) { |
| 375 | i++ |
| 376 | continue |
| 377 | } |
| 378 | const objectEnd = findJsonContainerEnd(source, i, 0x7b, 0x7d, contentBounds.end) |
| 379 | if (objectEnd === -1) break |
| 380 | const objectBounds = { start: i, end: objectEnd + 1, kind: 'object' as const } |
| 381 | const type = readJsonString(source, findObjectFieldValue(source, objectBounds.start, objectBounds.end, 'type')) |
| 382 | if (type === 'text' || type === 'input_text') { |
| 383 | const part = readJsonString( |
| 384 | source, |
| 385 | findObjectFieldValue(source, objectBounds.start, objectBounds.end, 'text'), |
| 386 | USER_TEXT_CAP - text.length, |
| 387 | ) |
| 388 | if (part) text += (text ? ' ' : '') + part |
| 389 | } |
| 390 | i = objectEnd + 1 |
| 391 | } |
| 392 | return text || undefined |
| 393 | } |
| 394 | |
| 395 | function extractLargeAddedNames(source: string, attachmentBounds: JsonValueBounds | null): string[] { |
| 396 | if (!attachmentBounds || attachmentBounds.kind !== 'object') return [] |
no test coverage detected