@@ -2820,13 +2820,16 @@ function normalizeOpenclawWorkspaceFileName(input) {
28202820
28212821function readOpenclawConfigFile ( ) {
28222822 const filePath = OPENCLAW_CONFIG_FILE ;
2823+ const authProfilesByProvider = sanitizeOpenclawAuthProfilesForClient (
2824+ readOpenclawAuthProfilesSummary ( ) . providers
2825+ ) ;
28232826 if ( ! fs . existsSync ( filePath ) ) {
28242827 return {
28252828 exists : false ,
28262829 path : filePath ,
28272830 content : '' ,
28282831 lineEnding : os . EOL === '\r\n' ? '\r\n' : '\n' ,
2829- authProfilesByProvider : readOpenclawAuthProfilesSummary ( ) . providers
2832+ authProfilesByProvider
28302833 } ;
28312834 }
28322835
@@ -2837,7 +2840,7 @@ function readOpenclawConfigFile() {
28372840 path : filePath ,
28382841 content : stripUtf8Bom ( raw ) ,
28392842 lineEnding : detectLineEnding ( raw ) ,
2840- authProfilesByProvider : readOpenclawAuthProfilesSummary ( ) . providers
2843+ authProfilesByProvider
28412844 } ;
28422845 } catch ( e ) {
28432846 return { error : `读取 OpenClaw 配置失败: ${ e . message } ` } ;
@@ -3049,6 +3052,22 @@ function readOpenclawAuthProfilesSummary() {
30493052 } ;
30503053}
30513054
3055+ function sanitizeOpenclawAuthProfilesForClient ( providers ) {
3056+ if ( ! isPlainObject ( providers ) ) {
3057+ return { } ;
3058+ }
3059+ const sanitized = { } ;
3060+ for ( const [ providerKey , summary ] of Object . entries ( providers ) ) {
3061+ if ( ! isPlainObject ( summary ) ) {
3062+ continue ;
3063+ }
3064+ const normalized = { ...summary } ;
3065+ delete normalized . resolvedValue ;
3066+ sanitized [ providerKey ] = normalized ;
3067+ }
3068+ return sanitized ;
3069+ }
3070+
30523071function normalizeOpenclawAuthProfileUpdate ( entry ) {
30533072 if ( ! isPlainObject ( entry ) ) return null ;
30543073 const profileId = typeof entry . profileId === 'string' ? entry . profileId . trim ( ) : '' ;
@@ -5756,19 +5775,11 @@ async function listSessionUsage(params = {}) {
57565775 const limit = Number . isFinite ( rawLimit )
57575776 ? Math . max ( 1 , Math . min ( rawLimit , MAX_SESSION_LIST_SIZE ) )
57585777 : 200 ;
5759- const sessions = await listAllSessions ( {
5778+ return await listAllSessionsData ( {
57605779 source,
57615780 limit,
57625781 forceRefresh : ! ! params . forceRefresh
57635782 } ) ;
5764- return sessions . map ( ( item ) => {
5765- if ( ! item || typeof item !== 'object' || Array . isArray ( item ) ) {
5766- return item ;
5767- }
5768- const normalized = { ...item } ;
5769- delete normalized . __messageCountExact ;
5770- return normalized ;
5771- } ) ;
57725783}
57735784
57745785function listSessionPaths ( params = { } ) {
@@ -11036,12 +11047,16 @@ function createWebServer({ htmlPath, assetsDir, webDir, host, port, openBrowser
1103611047 break ;
1103711048 case 'list-sessions-usage' :
1103811049 {
11039- const source = typeof params . source === 'string' ? params . source . trim ( ) . toLowerCase ( ) : '' ;
11050+ const usageParams = isPlainObject ( params ) ? params : { } ;
11051+ const source = typeof usageParams . source === 'string' ? usageParams . source . trim ( ) . toLowerCase ( ) : '' ;
1104011052 if ( source && source !== 'codex' && source !== 'claude' && source !== 'all' ) {
1104111053 result = { error : 'Invalid source. Must be codex, claude, or all' } ;
1104211054 } else {
1104311055 result = {
11044- sessions : await listSessionUsage ( params || { } ) ,
11056+ sessions : await listSessionUsage ( {
11057+ ...usageParams ,
11058+ source : source || 'all'
11059+ } ) ,
1104511060 source : source || 'all'
1104611061 } ;
1104711062 }
0 commit comments