@@ -2,6 +2,7 @@ import type { KnownProvider, ModelThinkingLevel } from "@earendil-works/pi-ai";
22import { getSupportedThinkingLevels } from "@earendil-works/pi-ai" ;
33import { getBuiltinModels } from "@earendil-works/pi-ai/providers/all" ;
44import { DEFAULT_LOCALE , type Locale , normalizeLocale } from "../../i18n/config" ;
5+ import { createUuid } from "../shared/id" ;
56import { mergeAlwaysEnabledSkillNames } from "../skills/builtin" ;
67import { SYSTEM_TOOL_OPTIONS , type SystemToolId } from "../tools/systemToolOptions" ;
78import { normalizeApiKey , normalizeBaseUrl , normalizeModels } from "./normalize" ;
@@ -497,7 +498,7 @@ function normalizeWorkspaceProject(input: unknown): WorkspaceProject | null {
497498 const obj = ( input && typeof input === "object" ? input : { } ) as Record < string , unknown > ;
498499 const path = normalizeWorkspaceProjectPath ( obj . path ) ;
499500 if ( ! path ) return null ;
500- const id = typeof obj . id === "string" && obj . id . trim ( ) ? obj . id . trim ( ) : crypto . randomUUID ( ) ;
501+ const id = typeof obj . id === "string" && obj . id . trim ( ) ? obj . id . trim ( ) : createUuid ( ) ;
501502 const name =
502503 typeof obj . name === "string" && obj . name . trim ( )
503504 ? obj . name . trim ( )
@@ -549,7 +550,7 @@ function normalizeWorkspaceProjects(input: unknown): WorkspaceProject[] {
549550 seenPaths . add ( pathKey ) ;
550551 let id = project . id ;
551552 if ( seenIds . has ( id ) ) {
552- id = crypto . randomUUID ( ) ;
553+ id = createUuid ( ) ;
553554 }
554555 seenIds . add ( id ) ;
555556 out . push ( { ...project , id } ) ;
@@ -635,7 +636,7 @@ export function resolveWorkspaceProjects(
635636 seenPaths . add ( pathKey ) ;
636637 let id = project . id ;
637638 if ( ! id || id === DEFAULT_WORKSPACE_PROJECT_ID || seenIds . has ( id ) ) {
638- id = crypto . randomUUID ( ) ;
639+ id = createUuid ( ) ;
639640 }
640641 seenIds . add ( id ) ;
641642 projects . push ( {
@@ -1298,7 +1299,7 @@ export function normalizeCustomProvider(input: unknown): CustomProvider {
12981299 const models = normalizeProviderModelConfigs ( obj . models , type ) ;
12991300 const validModelIds = new Set ( models . map ( ( model ) => model . id ) ) ;
13001301 const apiKey = normalizeApiKey ( typeof obj . apiKey === "string" ? obj . apiKey : "" ) ;
1301- const id = typeof obj . id === "string" && obj . id . trim ( ) ? obj . id . trim ( ) : crypto . randomUUID ( ) ;
1302+ const id = typeof obj . id === "string" && obj . id . trim ( ) ? obj . id . trim ( ) : createUuid ( ) ;
13021303
13031304 return {
13041305 id,
@@ -1324,7 +1325,7 @@ export function normalizeAgentPromptTemplate(input: unknown): AgentPromptTemplat
13241325 const obj = ( input && typeof input === "object" ? input : { } ) as Record < string , unknown > ;
13251326
13261327 return {
1327- id : typeof obj . id === "string" && obj . id . trim ( ) ? obj . id . trim ( ) : crypto . randomUUID ( ) ,
1328+ id : typeof obj . id === "string" && obj . id . trim ( ) ? obj . id . trim ( ) : createUuid ( ) ,
13281329 name : typeof obj . name === "string" && obj . name . trim ( ) ? obj . name . trim ( ) : "未命名模板" ,
13291330 description : normalizeOptionalText ( obj . description ) ,
13301331 prompt : normalizeOptionalText ( obj . prompt ) ,
@@ -1396,7 +1397,7 @@ export function normalizeSshHostConfig(input: unknown): SshHostConfig {
13961397 ( privateKeyPassphrase . length > 0 || obj . privateKeyPassphraseConfigured === true ) ;
13971398
13981399 return {
1399- id : typeof obj . id === "string" && obj . id . trim ( ) ? obj . id . trim ( ) : crypto . randomUUID ( ) ,
1400+ id : typeof obj . id === "string" && obj . id . trim ( ) ? obj . id . trim ( ) : createUuid ( ) ,
14001401 name,
14011402 description : normalizeOptionalText ( obj . description ) ,
14021403 host,
@@ -1424,7 +1425,7 @@ export function normalizeSshSettings(input: unknown): SshSettings {
14241425 seenIds . add ( normalized . id ) ;
14251426 return normalized ;
14261427 }
1427- const id = crypto . randomUUID ( ) ;
1428+ const id = createUuid ( ) ;
14281429 seenIds . add ( id ) ;
14291430 return { ...normalized , id } ;
14301431 } ) ;
@@ -2216,11 +2217,7 @@ const RIGHT_DOCK_WRITER_ID_STORAGE_KEY = "liveagent.client-id";
22162217let cachedRightDockWriterId = "" ;
22172218
22182219function generateRightDockWriterId ( ) : string {
2219- const uuid =
2220- typeof globalThis . crypto ?. randomUUID === "function"
2221- ? globalThis . crypto . randomUUID ( )
2222- : `${ Date . now ( ) . toString ( 36 ) } ${ Math . random ( ) . toString ( 36 ) . slice ( 2 ) } ` ;
2223- return uuid . replace ( / - / g, "" ) . slice ( 0 , 12 ) ;
2220+ return createUuid ( ) . replace ( / - / g, "" ) . slice ( 0 , 12 ) ;
22242221}
22252222
22262223// Stable per-client id used to break stateVersion ties deterministically in
0 commit comments