/*
 * 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 { Hono } from 'hono';
import { listWorkflowRuns, readWorkflowRun } from '../../services/workflow-state.js';
import { getWorkspaceCwd } from '../middleware/workspace.js';
export function workflowsRoutes(cwd) {
    const app = new Hono();
    app.get('/', (c) => {
        const dir = getWorkspaceCwd(c, cwd);
        const runs = listWorkflowRuns(dir);
        return c.json({ runs });
    });
    app.get('/:id', (c) => {
        const dir = getWorkspaceCwd(c, cwd);
        const id = c.req.param('id');
        const run = readWorkflowRun(dir, id);
        if (!run)
            return c.json({ error: 'Workflow run not found' }, 404);
        return c.json(run);
    });
    return app;
}
//# sourceMappingURL=workflows.js.map