import * as plugins from '../ts/plugins.js'; export interface IFlexProjectManagementMigrationOptions { harness: plugins.flexharness.FlexHarness; scopeIds: Iterable; } export class FlexProjectManagementMigration { private readonly harness: plugins.flexharness.FlexHarness; private readonly scopeIds: string[]; constructor(optionsArg: IFlexProjectManagementMigrationOptions) { this.harness = optionsArg.harness; this.scopeIds = [...new Set(optionsArg.scopeIds)].sort(); } public async run(signalArg?: AbortSignal): Promise { for (const scopeId of this.scopeIds) { signalArg?.throwIfAborted(); // listSessions durably repairs legacy session generations before PM state is loaded. const sessions = await this.harness.listSessions(scopeId); for (const session of sessions) { signalArg?.throwIfAborted(); await this.harness.getProjectState(scopeId, session.sessionId); } } } }