MCPcopy Create free account
hub / github.com/anomalyco/opencode / compactDetail

Function compactDetail

packages/opencode/src/cli/cmd/run/subagent-data.ts:527–555  ·  view source on GitHub ↗
(detail: DetailState)

Source from the content-addressed store, hash-verified

525}
526
527function compactDetail(detail: DetailState) {
528 const next = createSessionData({
529 includeUserText: true,
530 })
531 const activePartIDs = new Set(detail.data.part.keys())
532 const framePartIDs = new Set(detail.frames.flatMap((item) => (item.commit.partID ? [item.commit.partID] : [])))
533 const partIDs = new Set([...activePartIDs, ...framePartIDs, ...detail.data.tools])
534 const messageIDs = new Set([
535 ...[...activePartIDs]
536 .map((partID) => detail.data.msg.get(partID))
537 .filter((item): item is string => typeof item === "string"),
538 ...recent(detail.data.role.keys(), SUBAGENT_ROLE_LIMIT),
539 ])
540
541 next.announced = detail.data.announced
542 next.permissions = detail.data.permissions
543 next.questions = detail.data.questions
544 next.ids = compactIDs(detail)
545 next.tools = new Set([...detail.data.tools].filter((item) => partIDs.has(item)))
546 next.call = compactCallMap(detail)
547 next.role = copyMap(detail.data.role, messageIDs)
548 next.msg = copyMap(detail.data.msg, activePartIDs)
549 next.part = copyMap(detail.data.part, activePartIDs)
550 next.text = copyMap(detail.data.text, activePartIDs)
551 next.sent = copyMap(detail.data.sent, activePartIDs)
552 next.end = new Set([...detail.data.end].filter((item) => activePartIDs.has(item)))
553 next.echo = compactEchoMap(detail.data, messageIDs)
554 detail.data = next
555}
556
557function applyChildEvent(input: {
558 detail: DetailState

Callers 3

applyChildEventFunction · 0.85
bootstrapChildMessagesFunction · 0.85
bootstrapSubagentDataFunction · 0.85

Calls 7

createSessionDataFunction · 0.90
compactIDsFunction · 0.85
compactCallMapFunction · 0.85
copyMapFunction · 0.85
compactEchoMapFunction · 0.85
recentFunction · 0.70
getMethod · 0.65

Tested by

no test coverage detected