mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-07-11 02:20:48 -07:00
21 lines
538 B
TypeScript
21 lines
538 B
TypeScript
|
|
/**
|
||
|
|
* @license
|
||
|
|
* Copyright 2026 Google LLC
|
||
|
|
* SPDX-License-Identifier: Apache-2.0
|
||
|
|
*/
|
||
|
|
|
||
|
|
import { createHash } from 'node:crypto';
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Derives a stable, deterministic ID from a list of source IDs.
|
||
|
|
* Used for synthetic turns like summaries to ensure that re-summarizing the same
|
||
|
|
* content produces a consistent identity.
|
||
|
|
*/
|
||
|
|
export function deriveStableId(sourceIds: string[]): string {
|
||
|
|
const sortedIds = [...sourceIds].sort();
|
||
|
|
return createHash('sha256')
|
||
|
|
.update(sortedIds.join('|'))
|
||
|
|
.digest('hex')
|
||
|
|
.slice(0, 32);
|
||
|
|
}
|