update_document_lifecycle
Change document lifecycle states like draft, review, or published, and schedule reviews when needed for document management.
Instructions
Update the lifecycle state of a document with optional review scheduling
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| documentId | Yes | UUID of the document | |
| newState | Yes | New lifecycle state | |
| reviewComment | No | Optional review comment | |
| scheduledReview | No | ISO datetime for scheduled review |
Implementation Reference
- src/tools/enhanced/index.ts:408-435 (handler)The main handler function that executes the tool logic: updates document state via lifecycleService, schedules reviews if provided, fetches updated document, and returns confirmation details.tools.set('update_document_lifecycle', async (args: any) => { try { logger.info(`Updating document ${args.documentId} to state: ${args.newState}`); // Update document state await lifecycleService.updateDocumentState(args.documentId, args.newState); // Schedule review if provided if (args.scheduledReview) { await lifecycleService.scheduleReview(args.documentId, args.scheduledReview); } // Get updated document for confirmation const document = await lifecycleService.getDocumentById(args.documentId); return { success: true, document: document?.title || 'Unknown', newState: args.newState, reviewComment: args.reviewComment, scheduledReview: args.scheduledReview ? localizationService.formatDateTime(new Date(args.scheduledReview)) : null, updatedAt: localizationService.getCurrentDateTimeString() }; } catch (error) { logger.error('Failed to update document lifecycle:', error); throw error; } });
- src/types/enhanced.types.ts:124-129 (schema)Zod schema defining input validation for the update_document_lifecycle tool parameters.export const UpdateDocumentLifecycleSchema = z.object({ documentId: z.string().uuid(), newState: z.nativeEnum(DocumentLifecycleState), reviewComment: z.string().optional(), scheduledReview: z.string().datetime().optional(), });
- src/tools/enhanced/index.ts:161-187 (registration)Tool registration entry defining name, description, and JSON input schema.{ name: 'update_document_lifecycle', description: 'Update the lifecycle state of a document with optional review scheduling', inputSchema: { type: 'object', properties: { documentId: { type: 'string', description: 'UUID of the document' }, newState: { type: 'string', enum: ['draft', 'review', 'approved', 'published', 'outdated', 'archived'], description: 'New lifecycle state' }, reviewComment: { type: 'string', description: 'Optional review comment' }, scheduledReview: { type: 'string', description: 'ISO datetime for scheduled review' } }, required: ['documentId', 'newState'] } },