MCPcopy Create free account
hub / github.com/Noumena-Network/code / addSlowOperation

Function addSlowOperation

src/bootstrap/state.ts:1585–1603  ·  view source on GitHub ↗
(operation: string, durationMs: number)

Source from the content-addressed store, hash-verified

1583const SLOW_OPERATION_TTL_MS = 10000
1584
1585export function addSlowOperation(operation: string, durationMs: number): void {
1586 if ((process.env.NCODE_BUILD_MODE !== 'noumena' && process.env.USER_TYPE !== 'ant')) return
1587 // Skip tracking for editor sessions (user editing a prompt file in $EDITOR)
1588 // These are intentionally slow since the user is drafting text
1589 if (operation.includes('exec') && operation.includes('claude-prompt-')) {
1590 return
1591 }
1592 const now = Date.now()
1593 // Remove stale operations
1594 STATE.slowOperations = STATE.slowOperations.filter(
1595 op => now - op.timestamp < SLOW_OPERATION_TTL_MS,
1596 )
1597 // Add new operation
1598 STATE.slowOperations.push({ operation, durationMs, timestamp: now })
1599 // Keep only the most recent operations
1600 if (STATE.slowOperations.length > MAX_SLOW_OPERATIONS) {
1601 STATE.slowOperations = STATE.slowOperations.slice(-MAX_SLOW_OPERATIONS)
1602 }
1603}
1604
1605const EMPTY_SLOW_OPERATIONS: ReadonlyArray<{
1606 operation: string

Callers 1

[Symbol.dispose]Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected