π File detail
services/teamMemorySync/teamMemSecretGuard.ts
π§© .tsπ 45 linesπΎ 1,552 bytesπ text
β Back to All Filesπ― Use case
This file lives under βservices/β, which covers long-lived services (LSP, MCP, OAuth, tool execution, memory, compaction, voice, settings sync, β¦). On the API surface it exposes checkTeamMemSecrets β mainly functions, hooks, or classes. Dependencies touch bun:bundle.
Generated from folder role, exports, dependency roots, and inline comments β not hand-reviewed for every path.
π§ Inline summary
import { feature } from 'bun:bundle' /** * Check if a file write/edit to a team memory path contains secrets. * Returns an error message if secrets are detected, or null if safe.
π€ Exports (heuristic)
checkTeamMemSecrets
π External import roots
Package roots from from "β¦" (relative paths omitted).
bun:bundle
π₯οΈ Source preview
import { feature } from 'bun:bundle'
/**
* Check if a file write/edit to a team memory path contains secrets.
* Returns an error message if secrets are detected, or null if safe.
*
* This is called from FileWriteTool and FileEditTool validateInput to
* prevent the model from writing secrets into team memory files, which
* would be synced to all repository collaborators.
*
* Callers can import and call this unconditionally β the internal
* feature('TEAMMEM') guard keeps it inert when the build flag is off.
* secretScanner assembles sensitive prefixes at runtime (ANT_KEY_PFX).
*/
export function checkTeamMemSecrets(
filePath: string,
content: string,
): string | null {
if (feature('TEAMMEM')) {
/* eslint-disable @typescript-eslint/no-require-imports */
const { isTeamMemPath } =
require('../../memdir/teamMemPaths.js') as typeof import('../../memdir/teamMemPaths.js')
const { scanForSecrets } =
require('./secretScanner.js') as typeof import('./secretScanner.js')
/* eslint-enable @typescript-eslint/no-require-imports */
if (!isTeamMemPath(filePath)) {
return null
}
const matches = scanForSecrets(content)
if (matches.length === 0) {
return null
}
const labels = matches.map(m => m.label).join(', ')
return (
`Content contains potential secrets (${labels}) and cannot be written to team memory. ` +
'Team memory is shared with all repository collaborators. ' +
'Remove the sensitive content and try again.'
)
}
return null
}