MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / getAutoModeAttachments

Function getAutoModeAttachments

source code/utils/attachments.ts:1337–1376  ·  view source on GitHub ↗
(
  messages: Message[] | undefined,
  toolUseContext: ToolUseContext,
)

Source from the content-addressed store, hash-verified

1335}
1336
1337async function getAutoModeAttachments(
1338 messages: Message[] | undefined,
1339 toolUseContext: ToolUseContext,
1340): Promise<Attachment[]> {
1341 const appState = toolUseContext.getAppState()
1342 const permissionContext = appState.toolPermissionContext
1343 const inAuto = permissionContext.mode === 'auto'
1344 const inPlanWithAuto =
1345 permissionContext.mode === 'plan' &&
1346 (autoModeStateModule?.isAutoModeActive() ?? false)
1347 if (!inAuto && !inPlanWithAuto) {
1348 return []
1349 }
1350
1351 // Check if we should attach based on turn count (except for first turn)
1352 if (messages && messages.length > 0) {
1353 const { turnCount, foundAutoModeAttachment } =
1354 getAutoModeAttachmentTurnCount(messages)
1355 // Only throttle if we've already sent an auto_mode attachment before
1356 // On first turn in auto mode, always attach
1357 if (
1358 foundAutoModeAttachment &&
1359 turnCount < AUTO_MODE_ATTACHMENT_CONFIG.TURNS_BETWEEN_ATTACHMENTS
1360 ) {
1361 return []
1362 }
1363 }
1364
1365 // Determine if this should be a full or sparse reminder
1366 const attachmentCount =
1367 countAutoModeAttachmentsSinceLastExit(messages ?? []) + 1
1368 const reminderType: 'full' | 'sparse' =
1369 attachmentCount %
1370 AUTO_MODE_ATTACHMENT_CONFIG.FULL_REMINDER_EVERY_N_ATTACHMENTS ===
1371 1
1372 ? 'full'
1373 : 'sparse'
1374
1375 return [{ type: 'auto_mode', reminderType }]
1376}
1377
1378/**
1379 * Returns an auto_mode_exit attachment if we just exited auto mode.

Callers 1

getAttachmentsFunction · 0.85

Tested by

no test coverage detected