mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-23 00:43:14 +00:00
- Added SelectActiveIntentTool for handshake protocol - Implemented middleware gatekeeper in tool execution pipeline - Integrated RecordAgentTraceTool for SHA-256 content hashing - Created .orchestration/ artifacts for machine-readable audit trails
27 lines
821 B
TypeScript
27 lines
821 B
TypeScript
import { getCurrentHash, StaleFileError, validateLock } from "../core/concurrency/OptimisticLock"
|
|
|
|
import type { HookResult, OptimisticLockContext } from "./types"
|
|
|
|
export interface OptimisticLockResult extends HookResult {
|
|
currentHash?: string
|
|
}
|
|
|
|
export async function runOptimisticLockPreWriteHook(context: OptimisticLockContext): Promise<OptimisticLockResult> {
|
|
const expectedHash = String(context.expectedHash ?? "").trim()
|
|
if (!expectedHash) {
|
|
return { ok: true }
|
|
}
|
|
|
|
const isValid = await validateLock(expectedHash, context.filePath)
|
|
if (isValid) {
|
|
return { ok: true }
|
|
}
|
|
|
|
const currentHash = await getCurrentHash(context.filePath).catch(() => "unavailable")
|
|
const error = new StaleFileError(context.filePath, expectedHash, currentHash)
|
|
return {
|
|
ok: false,
|
|
error: error.message,
|
|
currentHash,
|
|
}
|
|
}
|