/*
 * Copyright 2026, Jaime Terrats.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
import { Messages } from '@salesforce/core';
import { SfCommand } from '@salesforce/sf-plugins-core';
import { getOfflineStatus } from '../../../services/offline-recovery.js';
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
const messages = Messages.loadMessages('@jterrats/setup-agents', 'setup-agents.offline.status');
export default class OfflineStatus extends SfCommand {
    static summary = messages.getMessage('summary');
    static description = messages.getMessage('description');
    static examples = messages.getMessages('examples');
    async run() {
        await this.parse(OfflineStatus);
        const cwd = process.cwd();
        const status = getOfflineStatus(cwd);
        this.log('');
        this.log('Offline Recovery Status');
        this.log('═══════════════════════');
        if (status.activeTask) {
            this.log(`\nActive Task: ${status.activeTask.id} — ${status.activeTask.summary} [${status.activeTask.status}]`);
        }
        else {
            this.log('\nNo active task found.');
        }
        if (status.activeRun) {
            this.log(`Workflow Run: ${status.activeRun.id} [${status.activeRun.status}]`);
        }
        if (status.currentPhase) {
            this.log(`Current Phase: ${status.currentPhase}`);
        }
        if (status.lastHandoff) {
            this.log(`Last Handoff: ${status.lastHandoff.from} → ${status.lastHandoff.to} (${status.lastHandoff.createdAt})`);
        }
        if (status.evidenceGaps.length > 0) {
            this.log('\nEvidence Gaps:');
            for (const gap of status.evidenceGaps) {
                this.log(`  ⚠ ${gap}`);
            }
        }
        if (status.cachedResources.length > 0) {
            this.log(`\nCached Resources: ${status.cachedResources.length} files available`);
        }
        this.log(`\nLocal LLM: ${status.localLlmAvailable ? 'detected' : 'not configured'}`);
        if (status.suggestedCommands.length > 0) {
            this.log('\nSuggested Commands:');
            for (const cmd of status.suggestedCommands) {
                this.log(`  $ ${cmd}`);
            }
        }
        return status;
    }
}
//# sourceMappingURL=status.js.map