/**
 * Wires the footer "Agents" action and the agent-tasks selector together.
 * Resolves the current session's task scope, mounts the selector, and routes
 * kill requests back to the shared TaskManager.
 */
import { getTaskScopeId, taskManager } from '../../app/tools/task/manager.js';
import { AgentTasksSelectorComponent } from '../components/selectors/agent-tasks-selector.js';
export class AgentTasksWorkflow {
    options;
    /** Build the workflow holder with session and UI dependencies. */
    constructor(options) {
        this.options = options;
    }
    /** Resolve the task scope id for the current session, if persisted. */
    getCurrentScopeId() {
        return getTaskScopeId(this.options.session.sessionManager);
    }
    /** Open the agent-tasks selector for the current scope. */
    show() {
        const scopeId = this.getCurrentScopeId();
        if (!scopeId) {
            this.options.showWarning('No persisted session is available for agent inspection.');
            return;
        }
        this.options.showSelector((done) => {
            const wrappedDone = () => {
                selector.dispose();
                done();
            };
            const selector = new AgentTasksSelectorComponent(scopeId, taskManager, {
                onCancel: wrappedDone,
                onKill: (agentId) => {
                    taskManager.abort(scopeId, agentId);
                    this.options.ui.requestRender();
                },
                requestRender: () => this.options.ui.requestRender()
            });
            return { component: selector, focus: selector };
        });
    }
}
//# sourceMappingURL=agent-tasks-workflow.js.map