11import type { OpenClawConfig } from "../config/types.openclaw.js" ;
22import type { PluginInstallRecord } from "../config/types.plugins.js" ;
33import {
4- readPersistedInstalledPluginIndex ,
5- readPersistedInstalledPluginIndexSync ,
6- refreshPersistedInstalledPluginIndex ,
7- resolveInstalledPluginIndexStorePath ,
8- } from "./installed-plugin-index-store.js" ;
9- import {
10- extractPluginInstallRecordsFromInstalledPluginIndex ,
11- type RefreshInstalledPluginIndexParams ,
12- } from "./installed-plugin-index.js" ;
4+ loadInstalledPluginIndexInstallRecords ,
5+ loadInstalledPluginIndexInstallRecordsSync ,
6+ readPersistedInstalledPluginIndexInstallRecords ,
7+ readPersistedInstalledPluginIndexInstallRecordsSync ,
8+ } from "./installed-plugin-index-record-reader.js" ;
9+ import { resolveInstalledPluginIndexStorePath } from "./installed-plugin-index-store-path.js" ;
10+ import { refreshPersistedInstalledPluginIndex } from "./installed-plugin-index-store.js" ;
11+ import { type RefreshInstalledPluginIndexParams } from "./installed-plugin-index.js" ;
1312import { recordPluginInstall , type PluginInstallUpdate } from "./installs.js" ;
1413
14+ export {
15+ loadInstalledPluginIndexInstallRecords ,
16+ loadInstalledPluginIndexInstallRecordsSync ,
17+ readPersistedInstalledPluginIndexInstallRecords ,
18+ readPersistedInstalledPluginIndexInstallRecordsSync ,
19+ } ;
20+
1521export const PLUGIN_INSTALLS_CONFIG_PATH = [ "plugins" , "installs" ] as const ;
1622
1723export type InstalledPluginIndexRecordStoreOptions = {
@@ -25,39 +31,12 @@ type InstalledPluginIndexRecordRefreshOptions = InstalledPluginIndexRecordStoreO
2531 now ?: ( ) => Date ;
2632 } ;
2733
28- function toInstallRecords (
29- index : Awaited < ReturnType < typeof readPersistedInstalledPluginIndex > > ,
30- ) : Record < string , PluginInstallRecord > | null {
31- if ( ! index ) {
32- return null ;
33- }
34- return extractPluginInstallRecordsFromInstalledPluginIndex ( index ) ;
35- }
36-
37- function cloneInstallRecords (
38- records : Record < string , PluginInstallRecord > | undefined ,
39- ) : Record < string , PluginInstallRecord > {
40- return structuredClone ( records ?? { } ) ;
41- }
42-
4334export function resolveInstalledPluginIndexRecordsStorePath (
4435 options : InstalledPluginIndexRecordStoreOptions = { } ,
4536) : string {
4637 return resolveInstalledPluginIndexStorePath ( options ) ;
4738}
4839
49- export async function readPersistedInstalledPluginIndexInstallRecords (
50- options : InstalledPluginIndexRecordStoreOptions = { } ,
51- ) : Promise < Record < string , PluginInstallRecord > | null > {
52- return toInstallRecords ( await readPersistedInstalledPluginIndex ( options ) ) ;
53- }
54-
55- export function readPersistedInstalledPluginIndexInstallRecordsSync (
56- options : InstalledPluginIndexRecordStoreOptions = { } ,
57- ) : Record < string , PluginInstallRecord > | null {
58- return toInstallRecords ( readPersistedInstalledPluginIndexSync ( options ) ) ;
59- }
60-
6140export async function writePersistedInstalledPluginIndexInstallRecords (
6241 records : Record < string , PluginInstallRecord > ,
6342 options : InstalledPluginIndexRecordRefreshOptions = { } ,
@@ -70,18 +49,6 @@ export async function writePersistedInstalledPluginIndexInstallRecords(
7049 return resolveInstalledPluginIndexRecordsStorePath ( options ) ;
7150}
7251
73- export async function loadInstalledPluginIndexInstallRecords (
74- params : InstalledPluginIndexRecordStoreOptions = { } ,
75- ) : Promise < Record < string , PluginInstallRecord > > {
76- return cloneInstallRecords ( ( await readPersistedInstalledPluginIndexInstallRecords ( params ) ) ?? { } ) ;
77- }
78-
79- export function loadInstalledPluginIndexInstallRecordsSync (
80- params : InstalledPluginIndexRecordStoreOptions = { } ,
81- ) : Record < string , PluginInstallRecord > {
82- return cloneInstallRecords ( readPersistedInstalledPluginIndexInstallRecordsSync ( params ) ?? { } ) ;
83- }
84-
8552export function withPluginInstallRecords (
8653 config : OpenClawConfig ,
8754 records : Record < string , PluginInstallRecord > ,
0 commit comments