@ -29,6 +29,10 @@ export const documentInputSchema = z.object({
type DocumentInput = z . infer < typeof documentInputSchema > ;
type DocumentInput = z . infer < typeof documentInputSchema > ;
function toISO ( date : Date | null | undefined ) : string | null {
return date ? date . toISOString ( ) : null ;
}
export const documentExecutor : ToolExecutor < DocumentToolConfig > = {
export const documentExecutor : ToolExecutor < DocumentToolConfig > = {
buildInputSchema ( _config : DocumentToolConfig ) : JSONSchema7 {
buildInputSchema ( _config : DocumentToolConfig ) : JSONSchema7 {
return {
return {
@ -129,8 +133,8 @@ export const documentExecutor: ToolExecutor<DocumentToolConfig> = {
title : doc.title ,
title : doc.title ,
summary : doc.summary ,
summary : doc.summary ,
tags : deserializeTags ( doc . tags ) ,
tags : deserializeTags ( doc . tags ) ,
createdAt : doc.createdAt ,
createdAt : toISO ( doc . createdAt ) ,
updatedAt : doc.updatedAt ,
updatedAt : toISO ( doc . updatedAt ) ,
} ,
} ,
metadata : { durationMs : Date.now ( ) - start } ,
metadata : { durationMs : Date.now ( ) - start } ,
} ;
} ;
@ -160,8 +164,8 @@ export const documentExecutor: ToolExecutor<DocumentToolConfig> = {
title : doc.title ,
title : doc.title ,
summary : doc.summary ,
summary : doc.summary ,
tags : deserializeTags ( doc . tags ) ,
tags : deserializeTags ( doc . tags ) ,
createdAt : doc.createdAt ,
createdAt : toISO ( doc . createdAt ) ,
updatedAt : doc.updatedAt ,
updatedAt : toISO ( doc . updatedAt ) ,
} ;
} ;
if ( data . fullContent ) {
if ( data . fullContent ) {
result . content = doc . content ;
result . content = doc . content ;
@ -211,8 +215,8 @@ export const documentExecutor: ToolExecutor<DocumentToolConfig> = {
title : updated.title ,
title : updated.title ,
summary : updated.summary ,
summary : updated.summary ,
tags : deserializeTags ( updated . tags ) ,
tags : deserializeTags ( updated . tags ) ,
createdAt : updated.createdAt ,
createdAt : toISO ( updated . createdAt ) ,
updatedAt : updated.updatedAt ,
updatedAt : toISO ( updated . updatedAt ) ,
} ,
} ,
metadata : { durationMs : Date.now ( ) - start } ,
metadata : { durationMs : Date.now ( ) - start } ,
} ;
} ;
@ -260,8 +264,8 @@ export const documentExecutor: ToolExecutor<DocumentToolConfig> = {
title : item.title ,
title : item.title ,
summary : item.summary ,
summary : item.summary ,
tags : deserializeTags ( item . tags ) ,
tags : deserializeTags ( item . tags ) ,
createdAt : item.createdAt ,
createdAt : toISO ( item . createdAt ) ,
updatedAt : item.updatedAt ,
updatedAt : toISO ( item . updatedAt ) ,
} ) ) ,
} ) ) ,
total : result.total ,
total : result.total ,
page : result.page ,
page : result.page ,