feat(core): Add step-based progress tracking, task metadata and enhanced TaskManager scheduling/metadata APIs
This commit is contained in:
57
ts/taskbuffer.classes.taskstep.ts
Normal file
57
ts/taskbuffer.classes.taskstep.ts
Normal file
@@ -0,0 +1,57 @@
|
||||
export interface ITaskStep {
|
||||
name: string;
|
||||
description: string;
|
||||
percentage: number; // Weight of this step (0-100)
|
||||
status: 'pending' | 'active' | 'completed';
|
||||
startTime?: number;
|
||||
endTime?: number;
|
||||
duration?: number;
|
||||
}
|
||||
|
||||
export class TaskStep implements ITaskStep {
|
||||
public name: string;
|
||||
public description: string;
|
||||
public percentage: number;
|
||||
public status: 'pending' | 'active' | 'completed' = 'pending';
|
||||
public startTime?: number;
|
||||
public endTime?: number;
|
||||
public duration?: number;
|
||||
|
||||
constructor(config: { name: string; description: string; percentage: number }) {
|
||||
this.name = config.name;
|
||||
this.description = config.description;
|
||||
this.percentage = config.percentage;
|
||||
}
|
||||
|
||||
public start(): void {
|
||||
this.status = 'active';
|
||||
this.startTime = Date.now();
|
||||
}
|
||||
|
||||
public complete(): void {
|
||||
if (this.startTime) {
|
||||
this.endTime = Date.now();
|
||||
this.duration = this.endTime - this.startTime;
|
||||
}
|
||||
this.status = 'completed';
|
||||
}
|
||||
|
||||
public reset(): void {
|
||||
this.status = 'pending';
|
||||
this.startTime = undefined;
|
||||
this.endTime = undefined;
|
||||
this.duration = undefined;
|
||||
}
|
||||
|
||||
public toJSON(): ITaskStep {
|
||||
return {
|
||||
name: this.name,
|
||||
description: this.description,
|
||||
percentage: this.percentage,
|
||||
status: this.status,
|
||||
startTime: this.startTime,
|
||||
endTime: this.endTime,
|
||||
duration: this.duration,
|
||||
};
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user