MCPcopy Create free account
hub / github.com/getagentseal/codeburn / extractLargeUserText

Function extractLargeUserText

src/parser.ts:361–393  ·  view source on GitHub ↗
(source: string, contentBounds: JsonValueBounds | null)

Source from the content-addressed store, hash-verified

359}
360
361function 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
395function extractLargeAddedNames(source: string, attachmentBounds: JsonValueBounds | null): string[] {
396 if (!attachmentBounds || attachmentBounds.kind !== 'object') return []

Callers 1

parseLargeJsonlLineFunction · 0.85

Calls 3

readJsonStringFunction · 0.85
findJsonContainerEndFunction · 0.85
findObjectFieldValueFunction · 0.85

Tested by

no test coverage detected